#include <stdio.h>
#include <stdlib.h>
#define F0R(i,n) for (int i = 0; i < (n); i++)

struct queue {
	int size;
	int capacity;
	int *arr;
};

void enqueue(struct queue *q, int item) {
	if (q->size == q->capacity) {
		puts("overflow");
		return;
	}
	q->arr[q->size++] = item;
}

int dequeue(struct queue *q) {
	if (q->size == 0) return -1;
	q->size--;
	F0R(i,q->size) q->arr[i] = q->arr[i+1];
	return q->arr[q->size];
}

int peek(struct queue *q) {
	return q->arr[0];
}

int is_empty(struct queue *q) {
	return q->size == 0;
}

int size(struct queue *q) {
	return q->size;
}

int main(void) {
	struct queue *q = malloc(sizeof(struct queue));
	q->capacity = 1000;
	q->arr = malloc(q->capacity * sizeof(int));
	q->size = 0;
	printf("Enter size of queue: ");
	int n;
	scanf("%i", &n);
	printf("Enter elements of queue: ");
	F0R(i,n) {
		int elem;
		scanf("%i", &elem);
		enqueue(q, elem);
	}
	F0R(i,size(q)) printf(i == size(q)-1 ? "%i\n" : "%i ", q->arr[i]);
	printf("Enter number of elements to dequeue: ");
	int ndequeue;
	scanf("%i", &ndequeue);
	F0R(i,ndequeue) dequeue(q);
	F0R(i,size(q)) printf(i == size(q)-1 ? "%i\n" : "%i ", q->arr[i]);
	free(q->arr);
	free(q);
}