Inception (UVA 13055) by aizu_f
Contest: 3738    RunID: 20173901    Status: Accepted    Date: Sat Oct 14 14:44:17 JST 2017


#include <bits/stdc++.h>

using namespace std;

int main(){
	int t;
	cin >> t;
	int i = 1;
	stack <string> s;
	while(t--){
		string query;
		string who;
		cin >> query;
		if(query.compare("Sleep") == 0) {
			cin >> who;
			s.push(who);
		}else if(query.compare("Kick") == 0){
			if(!s.empty()) s.pop();
		} else if(query.compare("Test") == 0){
			if(s.empty()) cout << "Not in a dream" << endl;
			else cout << s.top() << endl;
		}

	}
	return 0;
}