stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#include <vector>

#include <queue>

#include <set>

#include <map>

#include <string>

#include <cmath>

#include <cstdlib>

using namespace std;



const int MAX = 100010;

struct Node {

    char s[10];

    int v;

};



Node Queue[MAX];

int len;

int head;

int last;



void init() {

    len = head = last = 0;

}



void push(Node node) {

    strcpy(Queue[last].s, node.s);

    Queue[last].v = node.v;

    len++;

    last = (last + 1) % MAX;

}



Node front() {

    return Queue[head];

}



void pop() {

    len--;

    head = (head + 1) % MAX;

}



int n;

int tm;



int main() {

    //freopen("in.txt", "r", stdin);

    //freopen("out.txt", "w", stdout);

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

    init();

    for (int i = 0; i < n; i++) {

        char s[10];

        Node node;

        scanf("%s %d", node.s, &node.v);

        push(node);

    }

    int tt = 0;

    while (len > 0) {

        Node node = front();

        pop();

        if (node.v <= tm) {

            tt += node.v;

            node.v = 0;

        } else {

            tt += tm;

            node.v -= tm;

        }

        if (node.v <= 0) {

            printf("%s %d\n", node.s, tt);

        } else {

            push(node);

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.103090825677954x):
#include <cstdio>

#include <cstdlib>

#define MAXN 100010

int n,q;

typedef struct p{

    char name[10];

    int time;

}P;

P que[MAXN];

int head,tail,tot;







void get_input() {

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

    for(int i=0;i<n;i++) {

        scanf("%s %d",que[i].name,&que[i].time);

    }

    tail=n;

}



void solve() {

    P item;

    while(head!=tail) {

        item=que[head];

        head=(head+1)%(n+1);

        if(item.time>q) {

            item.time-=q;

            tot+=q;

            que[tail]=item;

            tail=(tail+1)%(n+1);

        } else {

            tot+=item.time;

            printf("%s %d\n",item.name,tot);

        }

    }

}



void display_output() {

    

}



int main() {

#ifdef debug

    freopen("in.txt","r",stdin);

#endif

    get_input();

    solve();

    display_output();

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <queue>

using namespace std;



struct Node{

	char name[10];

	int time;

};



queue<Node >Q;



int t = 0;



int main(){

	int n,m;

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

	for(int i = 1;i <= n; i++){

		Node p;

		scanf("%s%d",p.name,&p.time);

		Q.push(p);

	}

	while(!Q.empty()){

		Node point = Q.front();Q.pop();

		if(point.time > m){

			point.time -= m;	

			t += m;

			Q.push(point);

			continue;

		}

		t += point.time;

		printf("%s %d\n",point.name,t);

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.142430801909296x):
#include <cstdio>

#include <cstdlib>

#define MAXN 100010

int n,q;

typedef struct p{

    char name[10];

    int time;

}P;

P que[MAXN];

int head,tail,tot;







void get_input() {

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

    for(int i=0;i<n;i++) {

        scanf("%s %d",que[i].name,&que[i].time);

    }

    tail=n;

}



void solve() {

    P item;

    while(head!=tail) {

        item=que[head];

        head=(head+1)%(n+1);

        if(item.time>q) {

            item.time-=q;

            tot+=q;

            que[tail]=item;

            tail=(tail+1)%(n+1);

        } else {

            tot+=item.time;

            printf("%s %d\n",item.name,tot);

        }

    }

}



void display_output() {

    

}



int main() {

#ifdef debug

    freopen("in.txt","r",stdin);

#endif

    get_input();

    solve();

    display_output();

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



const int MAXN = 100000 + 5;



struct process {

  string name;

  int time;

};



process Q[MAXN];

int head, tail;

int n, q, total_time = 0;



void enqueue(process x) {

  Q[tail] = x;

  tail++;

  tail %= MAXN;

}



process dequeue() {

  process x = Q[head];

  head++;

  head %= MAXN;

  return x;

}



bool isEmpty() {

  return head == tail;

}



int main() {

  cin >> n >> q;

  for (int i = 0; i < n; i++) {

    cin >> Q[i].name >> Q[i].time;

  }

  head = 0, tail = n;

  while (!isEmpty()) {

    process crt = dequeue();

    int need = min(crt.time, q);

    crt.time -= need;

    total_time += need;

    if (crt.time == 0) {

      cout << crt.name << " " << total_time << endl;

    } else {

      enqueue(crt);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 27.606084826098314x):
#include <cstdio>

#include <cstdlib>

#define MAXN 100010

int n,q;

typedef struct p{

    char name[10];

    int time;

}P;

P que[MAXN];

int head,tail,tot;







void get_input() {

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

    for(int i=0;i<n;i++) {

        scanf("%s %d",que[i].name,&que[i].time);

    }

    tail=n;

}



void solve() {

    P item;

    while(head!=tail) {

        item=que[head];

        head=(head+1)%(n+1);

        if(item.time>q) {

            item.time-=q;

            tot+=q;

            que[tail]=item;

            tail=(tail+1)%(n+1);

        } else {

            tot+=item.time;

            printf("%s %d\n",item.name,tot);

        }

    }

}



void display_output() {

    

}



int main() {

#ifdef debug

    freopen("in.txt","r",stdin);

#endif

    get_input();

    solve();

    display_output();

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <queue>

#include <string>

using namespace std;



queue < pair<string,int> > que;



int main()

{

    int n,q,t;

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

    string name;

    for(int i=1; i<=n; i++)

    {

        cin >> name >> t;

        que.push(make_pair(name,t));

    }

    int sumt=0;

    pair <string,int> u;

    while(!que.empty())

    {

        u=que.front();

        que.pop();

        int temp=min(u.second,q);

        u.second-=temp;

        sumt+=temp;

        if(u.second>0)

            que.push(u);

        else

            cout << u.first << " " << sumt << endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.256320479347709x):
#include <cstdio>

#include <cstdlib>

#define MAXN 100010

int n,q;

typedef struct p{

    char name[10];

    int time;

}P;

P que[MAXN];

int head,tail,tot;







void get_input() {

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

    for(int i=0;i<n;i++) {

        scanf("%s %d",que[i].name,&que[i].time);

    }

    tail=n;

}



void solve() {

    P item;

    while(head!=tail) {

        item=que[head];

        head=(head+1)%(n+1);

        if(item.time>q) {

            item.time-=q;

            tot+=q;

            que[tail]=item;

            tail=(tail+1)%(n+1);

        } else {

            tot+=item.time;

            printf("%s %d\n",item.name,tot);

        }

    }

}



void display_output() {

    

}



int main() {

#ifdef debug

    freopen("in.txt","r",stdin);

#endif

    get_input();

    solve();

    display_output();

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



const int MAXN = 100000 + 5;



struct process {

  string name;

  int time;

};



process Q[MAXN];

int head, tail;

int n, q, total_time = 0;



void enqueue(process x) {

  Q[tail] = x;

  tail++;

  tail %= MAXN;

}



process dequeue() {

  process x = Q[head];

  head++;

  head %= MAXN;

  return x;

}



bool isEmpty() {

  return head == tail;

}



int main() {

  cin >> n >> q;

  for (int i = 0; i < n; i++) {

    cin >> Q[i].name >> Q[i].time;

  }

  head = 0, tail = n;

  while (!isEmpty()) {

    process crt = dequeue();

    int need = min(crt.time, q);

    crt.time -= need;

    total_time += need;

    if (crt.time == 0) {

      cout << crt.name << " " << total_time << endl;

    } else {

      enqueue(crt);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.24120402265568x):
#include <bits/stdc++.h>

using namespace std;



int main() {

    int n, q, t;

    string name;

    queue<pair<string, int>> Q;



    cin >> n >> q;

    for (int i = 0; i < n; ++i) {

        cin >> name >> t;

        Q.push(make_pair(name, t));

    }



    pair<string, int> u;

    int elaps = 0, a;



    while (!Q.empty()) {

        u = Q.front();

        Q.pop();

        a = min(u.second, q);

        u.second -= q;

        elaps += a;

        if (u.second > 0) {

            Q.push(u);

        } else {

            cout << u.first << " " << elaps << endl;

        }

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <queue>

using namespace std;

typedef struct pp{

    char name[100];

    int t;

} P;

queue<P> m;

int main()

{

    int i,n,q,ans=0;

    P u;

    cin>>n>>q;

    for(i=0;i<n;i++)

    {

        cin>>u.name>>u.t;

        m.push(u);

    }

    while(!m.empty())

    {

        u=m.front();

        if(q>=u.t)

        {

            ans+=u.t;

            m.pop();

            cout<<u.name<<" "<<ans<<endl;

        }

        else

        {

            ans+=q;

            u.t-=q;

            m.push(u);

            m.pop();

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.120766395211062x):
#include<stdio.h>

#include<fstream>

#include<vector>

#include<algorithm>

using namespace std;

struct renwu{

  char m[100];

  int t;

}a[100000];

int main()

{

    int n;int p;

    int x=0;

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

    int k=0,l=0;

    for(int i=1;i<=n;i++)

    {

        scanf("%s%d",a[i].m,&a[i].t);

    }

    int head=1;

    int tail=n+1;

    while(head!=tail)

    {

        k=min(p,a[head].t);

        x+=k;

        a[head].t-=k;

        if(a[head].t>0)

        {

           a[tail]=a[head];tail=(tail+1)%100005;

        }

        else

        {

          printf("%s %d\n",a[head].m,x);

        }

        head=(head+1)%100005;

    }

    return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#include <vector>

#include <queue>

#include <set>

#include <map>

#include <string>

#include <cmath>

#include <cstdlib>

using namespace std;



const int MAX = 100010;

struct Node {

    char s[10];

    int v;

};



Node Queue[MAX];

int len;

int head;

int last;



void init() {

    len = head = last = 0;

}



void push(Node node) {

    strcpy(Queue[last].s, node.s);

    Queue[last].v = node.v;

    len++;

    last = (last + 1) % MAX;

}



Node front() {

    return Queue[head];

}



void pop() {

    len--;

    head = (head + 1) % MAX;

}



int n;

int tm;



int main() {

    //freopen("in.txt", "r", stdin);

    //freopen("out.txt", "w", stdout);

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

    init();

    for (int i = 0; i < n; i++) {

        char s[10];

        Node node;

        scanf("%s %d", node.s, &node.v);

        push(node);

    }

    int tt = 0;

    while (len > 0) {

        Node node = front();

        pop();

        if (node.v <= tm) {

            tt += node.v;

            node.v = 0;

        } else {

            tt += tm;

            node.v -= tm;

        }

        if (node.v <= 0) {

            printf("%s %d\n", node.s, tt);

        } else {

            push(node);

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.004561145421493x):
#include<stdio.h>

#include<fstream>

#include<vector>

#include<algorithm>

using namespace std;

struct renwu{

  char m[100];

  int t;

}a[100000];

int main()

{

    int n;int p;

    int x=0;

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

    int k=0,l=0;

    for(int i=1;i<=n;i++)

    {

        scanf("%s%d",a[i].m,&a[i].t);

    }

    int head=1;

    int tail=n+1;

    while(head!=tail)

    {

        k=min(p,a[head].t);

        x+=k;

        a[head].t-=k;

        if(a[head].t>0)

        {

           a[tail]=a[head];tail=(tail+1)%100005;

        }

        else

        {

          printf("%s %d\n",a[head].m,x);

        }

        head=(head+1)%100005;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <queue>

using namespace std;



struct Node{

	char name[10];

	int time;

};



queue<Node >Q;



int t = 0;



int main(){

	int n,m;

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

	for(int i = 1;i <= n; i++){

		Node p;

		scanf("%s%d",p.name,&p.time);

		Q.push(p);

	}

	while(!Q.empty()){

		Node point = Q.front();Q.pop();

		if(point.time > m){

			point.time -= m;	

			t += m;

			Q.push(point);

			continue;

		}

		t += point.time;

		printf("%s %d\n",point.name,t);

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.043141551539x):
#include<stdio.h>

#include<fstream>

#include<vector>

#include<algorithm>

using namespace std;

struct renwu{

  char m[100];

  int t;

}a[100000];

int main()

{

    int n;int p;

    int x=0;

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

    int k=0,l=0;

    for(int i=1;i<=n;i++)

    {

        scanf("%s%d",a[i].m,&a[i].t);

    }

    int head=1;

    int tail=n+1;

    while(head!=tail)

    {

        k=min(p,a[head].t);

        x+=k;

        a[head].t-=k;

        if(a[head].t>0)

        {

           a[tail]=a[head];tail=(tail+1)%100005;

        }

        else

        {

          printf("%s %d\n",a[head].m,x);

        }

        head=(head+1)%100005;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



const int MAXN = 100000 + 5;



struct process {

  string name;

  int time;

};



process Q[MAXN];

int head, tail;

int n, q, total_time = 0;



void enqueue(process x) {

  Q[tail] = x;

  tail++;

  tail %= MAXN;

}



process dequeue() {

  process x = Q[head];

  head++;

  head %= MAXN;

  return x;

}



bool isEmpty() {

  return head == tail;

}



int main() {

  cin >> n >> q;

  for (int i = 0; i < n; i++) {

    cin >> Q[i].name >> Q[i].time;

  }

  head = 0, tail = n;

  while (!isEmpty()) {

    process crt = dequeue();

    int need = min(crt.time, q);

    crt.time -= need;

    total_time += need;

    if (crt.time == 0) {

      cout << crt.name << " " << total_time << endl;

    } else {

      enqueue(crt);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 27.07307085398527x):
#include<stdio.h>

#include<fstream>

#include<vector>

#include<algorithm>

using namespace std;

struct renwu{

  char m[100];

  int t;

}a[100000];

int main()

{

    int n;int p;

    int x=0;

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

    int k=0,l=0;

    for(int i=1;i<=n;i++)

    {

        scanf("%s%d",a[i].m,&a[i].t);

    }

    int head=1;

    int tail=n+1;

    while(head!=tail)

    {

        k=min(p,a[head].t);

        x+=k;

        a[head].t-=k;

        if(a[head].t>0)

        {

           a[tail]=a[head];tail=(tail+1)%100005;

        }

        else

        {

          printf("%s %d\n",a[head].m,x);

        }

        head=(head+1)%100005;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <queue>

#include <string>

using namespace std;



queue < pair<string,int> > que;



int main()

{

    int n,q,t;

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

    string name;

    for(int i=1; i<=n; i++)

    {

        cin >> name >> t;

        que.push(make_pair(name,t));

    }

    int sumt=0;

    pair <string,int> u;

    while(!que.empty())

    {

        u=que.front();

        que.pop();

        int temp=min(u.second,q);

        u.second-=temp;

        sumt+=temp;

        if(u.second>0)

            que.push(u);

        else

            cout << u.first << " " << sumt << endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.154832264881759x):
#include<stdio.h>

#include<fstream>

#include<vector>

#include<algorithm>

using namespace std;

struct renwu{

  char m[100];

  int t;

}a[100000];

int main()

{

    int n;int p;

    int x=0;

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

    int k=0,l=0;

    for(int i=1;i<=n;i++)

    {

        scanf("%s%d",a[i].m,&a[i].t);

    }

    int head=1;

    int tail=n+1;

    while(head!=tail)

    {

        k=min(p,a[head].t);

        x+=k;

        a[head].t-=k;

        if(a[head].t>0)

        {

           a[tail]=a[head];tail=(tail+1)%100005;

        }

        else

        {

          printf("%s %d\n",a[head].m,x);

        }

        head=(head+1)%100005;

    }

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

    int n, q, t;

    string name;

    queue<pair<string, int>> Q;



    cin >> n >> q;

    for (int i = 0; i < n; ++i) {

        cin >> name >> t;

        Q.push(make_pair(name, t));

    }



    pair<string, int> u;

    int elaps = 0, a;



    while (!Q.empty()) {

        u = Q.front();

        Q.pop();

        a = min(u.second, q);

        u.second -= q;

        elaps += a;

        if (u.second > 0) {

            Q.push(u);

        } else {

            cout << u.first << " " << elaps << endl;

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.165429686949592x):
#include<stdio.h>

#include<fstream>

#include<vector>

#include<algorithm>

using namespace std;

struct renwu{

  char m[100];

  int t;

}a[100000];

int main()

{

    int n;int p;

    int x=0;

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

    int k=0,l=0;

    for(int i=1;i<=n;i++)

    {

        scanf("%s%d",a[i].m,&a[i].t);

    }

    int head=1;

    int tail=n+1;

    while(head!=tail)

    {

        k=min(p,a[head].t);

        x+=k;

        a[head].t-=k;

        if(a[head].t>0)

        {

           a[tail]=a[head];tail=(tail+1)%100005;

        }

        else

        {

          printf("%s %d\n",a[head].m,x);

        }

        head=(head+1)%100005;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



const int MAXN = 100000 + 5;



struct process {

  string name;

  int time;

};



process Q[MAXN];

int head, tail;

int n, q, total_time = 0;



void enqueue(process x) {

  Q[tail] = x;

  tail++;

  tail %= MAXN;

}



process dequeue() {

  process x = Q[head];

  head++;

  head %= MAXN;

  return x;

}



bool isEmpty() {

  return head == tail;

}



int main() {

  cin >> n >> q;

  for (int i = 0; i < n; i++) {

    cin >> Q[i].name >> Q[i].time;

  }

  head = 0, tail = n;

  while (!isEmpty()) {

    process crt = dequeue();

    int need = min(crt.time, q);

    crt.time -= need;

    total_time += need;

    if (crt.time == 0) {

      cout << crt.name << " " << total_time << endl;

    } else {

      enqueue(crt);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.283398105674236x):
#include<iostream>

#include<queue>

#include<string>

using namespace std;

struct Node

{

   string name;

   int time;

};

int main()

{

   int n,q;

   cin>>n>>q;

   queue<Node>qe;

   for(int i=0;i<n;i++)

   {

      Node temp;

      cin>>temp.name;

      cin>>temp.time;

      qe.push(temp);

   }

   int endTime=0;

   while(!qe.empty())

   {

      Node temp=qe.front();

      qe.pop();

      if(temp.time-q<=0)

      {

         endTime+=temp.time;

         cout<<temp.name<<" "<<endTime<<endl;

      }

      else

      {

         endTime+=q;

         temp.time-=q;

         qe.push(temp);

      }

   }

   return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



const int MAXN = 100000 + 5;



struct process {

  string name;

  int time;

};



process Q[MAXN];

int head, tail;

int n, q, total_time = 0;



void enqueue(process x) {

  Q[tail] = x;

  tail++;

  tail %= MAXN;

}



process dequeue() {

  process x = Q[head];

  head++;

  head %= MAXN;

  return x;

}



bool isEmpty() {

  return head == tail;

}



int main() {

  cin >> n >> q;

  for (int i = 0; i < n; i++) {

    cin >> Q[i].name >> Q[i].time;

  }

  head = 0, tail = n;

  while (!isEmpty()) {

    process crt = dequeue();

    int need = min(crt.time, q);

    crt.time -= need;

    total_time += need;

    if (crt.time == 0) {

      cout << crt.name << " " << total_time << endl;

    } else {

      enqueue(crt);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.262164029261616x):
#include<bits/stdc++.h>

using namespace std;

struct node

{

    string s;

    int num;

};

queue <node> qu;

int main()

{

    int n,m;

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

    while(n--)

    {

        node temp;

        cin>>temp.s>>temp.num;

        qu.push(temp);

    }

    long long times = 0;

    while(!qu.empty())

    {

        node temp = qu.front();

        qu.pop();

        if(temp.num > m)

        {

            times += m;

            temp.num -= m;

            qu.push(temp);

        }

        else

        {

            times += temp.num;

            cout<<temp.s<<" "<<times;

            printf("\n");

        }

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



const int MAXN = 100000 + 5;



struct process {

  string name;

  int time;

};



process Q[MAXN];

int head, tail;

int n, q, total_time = 0;



void enqueue(process x) {

  Q[tail] = x;

  tail++;

  tail %= MAXN;

}



process dequeue() {

  process x = Q[head];

  head++;

  head %= MAXN;

  return x;

}



bool isEmpty() {

  return head == tail;

}



int main() {

  cin >> n >> q;

  for (int i = 0; i < n; i++) {

    cin >> Q[i].name >> Q[i].time;

  }

  head = 0, tail = n;

  while (!isEmpty()) {

    process crt = dequeue();

    int need = min(crt.time, q);

    crt.time -= need;

    total_time += need;

    if (crt.time == 0) {

      cout << crt.name << " " << total_time << endl;

    } else {

      enqueue(crt);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.777550670682514x):
#include<cstdio>

#include<queue>



using namespace std;



#define FOR(i, a, b) for(int i = a; i <= b; i++)



const int MAX = 20;



struct Point

{

	char name[MAX];

	int timeneeded;

};



queue<Point> q;



int main()

{

	int n, per;

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

	{

		FOR(i, 1, n)

		{

			Point tmp;

			scanf("%s%d", tmp.name, &tmp.timeneeded);

			q.push(tmp);

		}



		int sum = 0;

		while(!q.empty())

		{

			Point cur = q.front();

			q.pop();

			if(cur.timeneeded <= per)

			{

				sum += cur.timeneeded;

				printf("%s %d\n", cur.name, sum);

			}

			else

			{

				sum += per;

				cur.timeneeded -= per;

				q.push(cur);

			}

		}

	}

	return 0;

}