#include <stdio.h>
#include <string.h>
#include <queue>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    queue<int> S;

    for(int i=0; i<n; i++) {
        char s[10];
        scanf("%s", s);

        if(!strcmp(s, "push")) {
            int k;
            scanf("%d", &k);
            S.push(k);
        }
        else if(!strcmp(s, "pop")) {
            if(S.empty()) printf("-1\n");
            else {
                int k=S.front();
                S.pop();
                printf("%d\n", k);
            }
        }
        else if(!strcmp(s, "front")) {
            if(S.empty()) printf("-1\n");
            else {
                int k=S.front();
                printf("%d\n", k);
            }
        }
        else if(!strcmp(s, "size")) {
            int k=S.size();
            printf("%d\n", k);
        }
        else if(!strcmp(s, "empty")) {
            printf("%d\n", S.empty());
        }
        else {
            if(S.empty()) printf("-1\n");
            else printf("%d\n", S.back());
        }
        int k=S.front();

        //debug : printf("%d\n", k);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: