Language: C++

#include<stdio.h>
#include<string.h>
#define LEN 100005
#define N 100

typedef struct pp{
  char name[N];
  int t;
}P;

void enqueue(P);
P dequeue(void);

P Q[LEN+1];
int head,tail,n;

int main()
{
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  c=100;
  for (i=0;i<n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].t);
    }
  head++,tail=n+1;

  while(head!=tail)
    {
      u=dequeue();
      if(q<=u.t) c=q;
      if(q>u.t) c=u.t;
      elaps+=c;
      if(u.t>0) enqueue(u);
      else    printf("%s %d\n",u.name,elaps);
    }

  return 0;
}

void enqueue(P x)
{
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define N 100

typedef struct pp{
  char name[N];
  int t;
}P;

void enqueue(P);
P dequeue(void);

P Q[LEN+1];
int head,tail,n;

int main()
{
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  c=100;
  for (i=0;i<n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].t);
    }
  head++,tail=n+1;

  while(head!=tail)
    {
      u=dequeue();
      if(q<=u.t) c=q;
      if(q>u.t) c=u.t;
      elaps+=c;
      if(u.t>0) enqueue(u);
      else    printf("%s %d\n",u.name,elaps);
    }

  return 0;
}

void enqueue(P x)
{
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

#include<stdio.h>
#include<string.h>
#define LEN 100005
#define N 100

typedef struct pp{
  char name[N];
  int t;
}P;

void enqueue(P);
P dequeue(void);

P Q[LEN+1];
int head,tail,n;

int main()
{
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  c=100;
  for (i=0;i<n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].t);
    }
  head++,tail=n+1;

  while(head!=tail)
    {
      u=dequeue();
      if(q<=u.t) c=q;
      if(q>u.t) c=u.t;
      elaps+=c;
      if(u.t>0) enqueue(u);
      else    printf("%s %d\n",u.name,elaps);
    }

  return 0;
}

void enqueue(P x)
{
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue()
{
  P x;
  x=Q[head];
  head=(head+1)%LEN;
  return x;
}

Compiler output:
a.cc:54:16: error: redefinition of 'struct pp'
   54 | typedef struct pp{
      |                ^~
a.cc:6:16: note: previous definition of 'struct pp'
    6 | typedef struct pp{
      |                ^~
a.cc:57:2: error: conflicting declaration 'typedef int P'
   57 | }P;
      |  ^
a.cc:9:2: note: previous declaration as 'typedef struct pp P'
    9 | }P;
      |  ^
a.cc:62:3: error: redefinition of 'P Q [100006]'
   62 | P Q[LEN+1];
      |   ^
a.cc:14:3: note: 'P Q [100006]' previously declared here
   14 | P Q[LEN+1];
      |   ^
a.cc:63:5: error: redefinition of 'int head'
   63 | int head,tail,n;
      |     ^~~~
a.cc:15:5: note: 'int head' previously declared here
   15 | int head,tail,n;
      |     ^~~~
a.cc:63:10: error: redefinition of 'int tail'
   63 | int head,tail,n;
      |          ^~~~
a.cc:15:10: note: 'int tail' previously declared here
   15 | int head,tail,n;
      |          ^~~~
a.cc:63:15: error: redefinition of 'int n'
   63 | int head,tail,n;
      |               ^
a.cc:15:15: note: 'int n' previously declared here
   15 | int head,tail,n;
      |               ^
a.cc:65:5: error: redefinition of 'int main()'
   65 | int main()
      |     ^~~~
a.cc:17:5: note: 'int main()' previously defined here
   17 | int main()
      |     ^~~~
a.cc:92:6: error: redefinition of 'void enqueue(P)'
   92 | void enqueue(P x)
      |      ^~~~~~~
a.cc:44:6: note: 'void enqueue(P)' previously defined here
   44 | void enqueue(P x)
      |      ^~~~~~~
a.cc:103:16: error: redefinition of 'struct pp'
  103 | typedef struct pp{
      |                ^~
a.cc:6:16: note: previous definition of 'struct pp'
    6 | typedef struct pp{
      |                ^~
a.cc:106:2: error: conflicting declaration 'typedef int P'
  106 | }P;
      |  ^
a.cc:9:2: note: previous declaration as 'typedef struct pp P'
    9 | }P;
      |  ^
a.cc:111:3: error: redefinition of 'P Q [100006]'
  111 | P Q[LEN+1];
      |   ^
a.cc:14:3: note: 'P Q [100006]' previously declared here
   14 | P Q[LEN+1];
      |   ^
a.cc:112:5: error: redefinition of 'int head'
  112 | int head,tail,n;
      |     ^~~~
a.cc:15:5: note: 'int head' previously declared here
   15 | int head,tail,n;
      |     ^~~~
a.cc:112:10: error: redefinition of 'int tail'
  112 | int head,tail,n;
      |          ^~~~
a.cc:15:10: note: 'int tail' previously declared here
   15 | int head,tail,n;
      |          ^~~~
a.cc:112:15: error: redefinition of 'int n'
  112 | int head,tail,n;
      |               ^
a.cc:15:15: note: 'int n' previously declared here
   15 | int head,tail,n;
      |               ^
a.cc:114:5: error: redefinition of 'int main()'
  114 | int main()
      |     ^~~~
a.cc:17:5: note: 'int main()' previously defined here
   17 | int main()
      |     ^~~~
a.cc:141:6: error: redefinition of 'void enqueue(P)'
  141 | void enqueue(P x)
      |      ^~~~~~~
a.cc:44:6: note: 'void enqueue(P)' previously defined here
   44 | void enqueue(P x)
      |      ^~~~~~~