#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(empty())
{
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());
}
I2luY2x1ZGU8c3RkaW8uaD4KI2RlZmluZSBNYXhfU2l6ZSAzCmludCBxdWV1ZVtNYXhfU2l6ZV07CmludCBmcm9udD0wLGJhY2s9LTE7CmludCBzaXplKCkKewpyZXR1cm4gYmFjay1mcm9udCsxOwp9CmludCBlbXB0eSgpCnsKcmV0dXJuIHNpemUoKT09MDsKfQp2b2lkIHB1c2goaW50IHgpCnsKaWYoYmFjazxNYXhfU2l6ZS0xKQp7CnF1ZXVlWysrYmFja109eDsKfQplbHNlCnsKcHJpbnRmKCJvdnJyXG4iKTsKfQp9CnZvaWQgcG9wKCkKewppZihlbXB0eSgpKQp7CnByaW50ZigidVxuIik7Cn0KZWxzZQp7CmZyb250Kys7Cn0KfQppbnQgZnJvbnRfZWxlbWVudCgpCnsKaWYoIWVtcHR5KCkpCnsKcmV0dXJuIHF1ZXVlW2Zyb250XTsKfQplbHNlCnsKcHJpbnRmKCJlbVxuIik7CnJldHVybiAtMTsKfQp9CmludCBiYWNrX2VsZW1lbnQoKQp7CmlmKCFlbXB0eSgpKQp7CnJldHVybiBxdWV1ZVtiYWNrXTsKfQplbHNlCnsKcHJpbnRmKCJlbVxuIik7CnJldHVybiAtMTsKfQp9CmludCBtYWluKCkKewpwdXNoKDkpOwpwcmludGYoIiVkXG4iLGZyb250X2VsZW1lbnQoKSk7CnBvcCgpOwpwcmludGYoIiVkXG4iLHNpemUoKSk7Cn0=