Inception (UVA 13055) by beet1333
Contest: 3738    RunID: 20173609    Status: Accepted    Date: Sat Oct 14 13:54:22 JST 2017


#include<bits/stdc++.h>

using namespace std;

struct BeetAizu
{
  BeetAizu()
  {

  }

  void run()
  {
    int N;
    cin >> N;
    stack< string > st;
    while(N--) {
      string S;
      cin >> S;
      if(S == "Sleep") {
        string T;
        cin >> T;
        st.emplace(T);
      } else if(S == "Kick") {
        if(!st.empty()) st.pop();
      } else {
        if(st.empty()) cout << "Not in a dream" << endl;
        else cout << st.top() << endl;
      }
    }

  }
};

int main()
{
  BeetAizu beet;
  int T = 1;
  // cin >> T;

  for(int i = 1; i <= T; i++) {
    // cout << "Case " << i << ": ";
    beet.run();
  }
}