队列:先进先出
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int queue[N], head, tail;
void push(int x) {
queue[tail ++] = x;
}
void pop() {
head ++;
}
string empty() {
if (head == tail) return "YES";
return "NO";
}
int query() {
return queue[head];
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i ++) {
string op;
int x;
cin >> op;
if (op == "push") {
cin >> x;
push(x);
}
else if (op == "pop") pop();
else if (op == "empty") cout << empty() << endl;
else cout << query() << endl;
}
return 0;
}