Language: C++

#include <stdio.h>

#define N 100000
#define Q 1000

void enq1(int);
int deq1(void);
void enq2(int);
int deq2(void);

int head=0,tail=0,p;
int S1[N],S2[N];

int main(){

  int n,q,i,T=0,a,b,c=0;
  char name[N][10];
  int time[N];

  scanf("%d %d",&n,&q);

  for(i=0 ; i<n ; i++){
    scanf("%s %d",name[i],&time[i]);
    enq1(time[i]);
    enq2(i);
  }


  while(1){
    a=deq1();
    b=deq2();

    if(head==N) head=0;
    if(tail==N) tail=0;

    if(a-q<=0){
      T+=a;
      printf("%s %d\n",name[b],T);
      c++;
      if(c==n) break;
    }
    else{
      T+=q;
      a-=q;
      enq1(a);
      enq2(b);
    }
  }

  return 0;
}

void enq1(int n){
  S1[tail]=n;
  tail++;
}

int deq1(){
  head++;
  return S1[head-1];
}

void enq2(int n){
  S2[tail]=n;
  tail++;
}

int deq2(){
  head++;
  return S2[head-1];
}
#include <stdio.h>

#define N 100000
#define Q 1000

void enq1(int);
int deq1(void);
void enq2(int);
int deq2(void);

int head=0,tail=0,p;
int S1[N],S2[N];

int main(){

  int n,q,i,T=0,a,b,c=0;
  char name[N][10];
  int time[N];

  scanf("%d %d",&n,&q);

  for(i=0 ; i<n ; i++){
    scanf("%s %d",name[i],&time[i]);
    enq1(time[i]);
    enq2(i);
  }


  while(1){
    a=deq1();
    b=deq2();

    if(head==N) head=0;
    if(tale==0) tale=0;

    if(a-q<=0){
      T+=a;
      printf("%s %d\n",name[b],T);
      c++;
      if(c==n) break;
    }
    else{
      T+=q;
      a-=q;
      enq1(a);
      enq2(b);
    }
  }

  return 0;
}

void enq1(int n){
  S1[tail]=n;
  tail++;
}

int deq1(){
  head++;
  return S1[head-1];
}

void enq2(int n){
  S2[tail]=n;
  tail++;
}

int deq2(){
  head++;
  return S2[head-1];
}



Compiler output:
a.cc:82:5: error: redefinition of 'int head'
   82 | int head=0,tail=0,p;
      |     ^~~~
a.cc:11:5: note: 'int head' previously defined here
   11 | int head=0,tail=0,p;
      |     ^~~~
a.cc:82:12: error: redefinition of 'int tail'
   82 | int head=0,tail=0,p;
      |            ^~~~
a.cc:11:12: note: 'int tail' previously defined here
   11 | int head=0,tail=0,p;
      |            ^~~~
a.cc:82:19: error: redefinition of 'int p'
   82 | int head=0,tail=0,p;
      |                   ^
a.cc:11:19: note: 'int p' previously declared here
   11 | int head=0,tail=0,p;
      |                   ^
a.cc:83:5: error: redefinition of 'int S1 [100000]'
   83 | int S1[N],S2[N];
      |     ^~
a.cc:12:5: note: 'int S1 [100000]' previously declared here
   12 | int S1[N],S2[N];
      |     ^~
a.cc:83:11: error: redefinition of 'int S2 [100000]'
   83 | int S1[N],S2[N];
      |           ^~
a.cc:12:11: note: 'int S2 [100000]' previously declared here
   12 | int S1[N],S2[N];
      |           ^~
a.cc:85:5: error: redefinition of 'int main()'
   85 | int main(){
      |     ^~~~
a.cc:14:5: note: 'int main()' previously defined here
   14 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:105:8: error: 'tale' was not declared in this scope
  105 |     if(tale==0) tale=0;
      |        ^~~~
a.cc: At global scope:
a.cc:124:6: error: redefinition of 'void enq1(int)'
  124 | void enq1(int n){
      |      ^~~~
a.cc:53:6: note: 'void enq1(int)' previously defined here
   53 | void enq1(int n){
      |      ^~~~
a.cc:129:5: error: redefinition of 'int deq1()'
  129 | int deq1(){
      |     ^~~~
a.cc:58:5: note: 'int deq1()' previously defined here
   58 | int deq1(){
      |     ^~~~
a.cc:134:6: error: redefinition of 'void enq2(int)'
  134 | void enq2(int n){
      |      ^~~~
a.cc:63:6: note: 'void enq2(int)' previously defined here
   63 | void enq2(int n){
      |      ^~~~
a.cc:139:5: error: redefinition of 'int deq2()'
  139 | int deq2(){
      |     ^~~~
a.cc:68:5: note: 'int deq2()' previously defined here
   68 | int deq2(){
      |     ^~~~