Language: C++

#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

typedef struct {
	char name[11] = "\0";
	int time;
} P;

class Queue {
private:
	int size;
	P *queue;
	int head = 0;
	int tail = 0;
public:
	Queue(int n);
	void enqueue(P p);
	void dequeue();
	bool isEmpty();
	*P get();
	void clear()
}

Queue::Queue(int n)
{
	size = n;
	queue = new P[n];
}

void Queue::enqueue(P p)
{
	queue[tail] = p;
	tail = (tail + 1) % size;
}

void Queue::dequeue()
{
	head = (head + 1) % size;
}

bool Queue::isEmpty()
{
	return head == tail;
}

*P Queue::get()
{
	return &queue[head];
}

void Queue::clear()
{
	delete[] queue;
}

int main(void)
{	
	int n, q;
	cin >> n >> q;
	
	Queue queue(n);
	for (int i = 0; i < n; i++) {
		P p;
		cin >> p.name;
		cin >> p.time;
		queue.enqueue(p);
	}
	
	int time = 0;
	while (!queue.isEmpty()) {
		P *p = queue.get();
		if (p->time <= q) {
			time += p->time;
			queue.dequeue();
			cout << p->name << " ";
			cout << time << endl;
		} else {
			time += q;
			p->time -= q;
			queue.dequeue();
			queue.enqueue(p);
		}
	}
	
	queue.clear();
	return 0;
}

Compiler output:
a.cc:22:10: error: ISO C++ forbids declaration of 'P' with no type [-fpermissive]
   22 |         *P get();
      |          ^
a.cc:22:10: error: expected ';' at end of member declaration
   22 |         *P get();
      |          ^
      |           ;
a.cc:22:10: error: declaration of 'int* Queue::P' changes meaning of 'P' [-Wchanges-meaning]
a.cc:14:9: note: used here to mean 'typedef struct P P'
   14 |         P *queue;
      |         ^
a.cc:9:3: note: declared here
    9 | } P;
      |   ^
a.cc:22:12: error: ISO C++ forbids declaration of 'get' with no type [-fpermissive]
   22 |         *P get();
      |            ^~~
a.cc:23:20: error: expected ';' at end of member declaration
   23 |         void clear()
      |                    ^
      |                     ;
a.cc:11:1: error: new types may not be defined in a return type
   11 | class Queue {
      | ^~~~~
a.cc:11:1: note: (perhaps a semicolon is missing after the definition of 'Queue')
a.cc:11:1: error: return type specification for constructor invalid
a.cc: In constructor 'Queue::Queue(int)':
a.cc:29:21: error: 'P' does not name a type
   29 |         queue = new P[n];
      |                     ^
a.cc: At global scope:
a.cc:32:6: error: variable or field 'enqueue' declared void
   32 | void Queue::enqueue(P p)
      |      ^~~~~
a.cc:32:23: error: expected primary-expression before 'p'
   32 | void Queue::enqueue(P p)
      |                       ^
a.cc:48:4: error: expected constructor, destructor, or type conversion before 'Queue'
   48 | *P Queue::get()
      |    ^~~~~
a.cc: In function 'int main()':
a.cc:73:33: error: invalid conversion from 'int' to 'P*' [-fpermissive]
   73 |                 P *p = queue.get();
      |                        ~~~~~~~~~^~
      |                                 |
      |                                 int
a.cc:83:39: error: cannot convert 'P*' to 'P'
   83 |                         queue.enqueue(p);
      |                                       ^
      |                                       |
      |                                       P*
a.cc:19:24: note:   initializing argument 1 of 'void Queue::enqueue(P)'
   19 |         void enqueue(P p);
      |                      ~~^