Inception (UVA 13055) by UKUNICHIA
Contest: 3738    RunID: 20173588    Status: Accepted    Date: Sat Oct 14 13:50:46 JST 2017


#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int q;
  cin>>q;
  stack<string> ss;
  while(q--){
    string s;
    cin>>s;
    if(s=="Sleep"){
      string t;
      cin>>t;
      ss.push(t);
    }
    if(s=="Kick"){
      if(!ss.empty()) ss.pop();
    }
    if(s=="Test"){
      if(ss.empty()) cout<<"Not in a dream"<<endl;
      else cout<<ss.top()<<endl;
    }
  }
  return 0;
}