#include<stdio.h>
#define Max_Size 3
int queue[Max_Size];
int front=0,back=-1;
int size()
{
return back-front+1;
}
int empty()
{
return size()==0;
}
void push(int x)
{
if(back<Max_Size-1)
{
queue[++back]=x;
}
else
{
printf("ovrr\n");
}
}
void pop()
{
if(size()==0)
{
printf("u\n");
}
else
{
front++;
}
}
int front_element()
{
if(!empty())
{
return queue[front];
}
else
{
printf("em\n");
return -1;
}
}
int back_element()
{
if(!empty())
{
return queue[back];
}
else
{
printf("em\n");
return -1;
}
}
int main()
{
push(9);
printf("%d\n",front_element());
pop();
printf("%d\n",size());
}
I2luY2x1ZGU8c3RkaW8uaD4KI2RlZmluZSBNYXhfU2l6ZSAzCmludCBxdWV1ZVtNYXhfU2l6ZV07CmludCBmcm9udD0wLGJhY2s9LTE7CmludCBzaXplKCkKewpyZXR1cm4gYmFjay1mcm9udCsxOwp9CmludCBlbXB0eSgpCnsKcmV0dXJuIHNpemUoKT09MDsKfQp2b2lkIHB1c2goaW50IHgpCnsKaWYoYmFjazxNYXhfU2l6ZS0xKQp7CnF1ZXVlWysrYmFja109eDsKfQplbHNlCnsKcHJpbnRmKCJvdnJyXG4iKTsKfQp9CnZvaWQgcG9wKCkKewppZihzaXplKCk9PTApCnsKcHJpbnRmKCJ1XG4iKTsKfQplbHNlCnsKZnJvbnQrKzsKfQp9CmludCBmcm9udF9lbGVtZW50KCkKewppZighZW1wdHkoKSkKewpyZXR1cm4gcXVldWVbZnJvbnRdOwp9CmVsc2UKewpwcmludGYoImVtXG4iKTsKcmV0dXJuIC0xOwp9Cn0KaW50IGJhY2tfZWxlbWVudCgpCnsKaWYoIWVtcHR5KCkpCnsKcmV0dXJuIHF1ZXVlW2JhY2tdOwp9CmVsc2UKewpwcmludGYoImVtXG4iKTsKcmV0dXJuIC0xOwp9Cn0KaW50IG1haW4oKQp7CnB1c2goOSk7CnByaW50ZigiJWRcbiIsZnJvbnRfZWxlbWVudCgpKTsKcG9wKCk7CnByaW50ZigiJWRcbiIsc2l6ZSgpKTsKfQ==