alexjercan/bugnet huggingface dataset:
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

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

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

  while (head != tail) {
    u = dequeue();
    if (q <= u.t)
      c = q;
    if (q > u.t)
      c = u.t;
    u.t -= c;
    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;
}

Error: TLE

Fixed submission:

#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;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
using namespace std;

int main() {
  int n, q, head = -1, tail, time_queue[100001] = {}, now = 0;
  char name_queue[100001][15];
  cin >> n >> q;
  for (int i = 0; i < n; i++)
    cin >> name_queue[i] >> time_queue[i];
  tail = (n - 1) % 100001;
  while (tail != head) {
    head = (head + 1) % 100001;
    if (time_queue[head] <= q) {
      now += time_queue[head];
      cout << name_queue[head] << " " << now << endl;
    } else {
      now += q;
      time_queue[(tail + 1) % 100001] = time_queue[head] - q;
      strcpy(name_queue[(tail + 1) % 100001], name_queue[head]);
      tail = (tail + 1) % 100001;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <cstring>
#include <iostream>
using namespace std;

int main() {
  int n, q, head = -1, tail, time_queue[100001] = {}, now = 0;
  char name_queue[100001][15];
  cin >> n >> q;
  for (int i = 0; i < n; i++)
    cin >> name_queue[i] >> time_queue[i];
  tail = (n - 1) % 100001;
  while (tail != head) {
    head++;
    if (time_queue[head] <= q) {
      now += time_queue[head];
      cout << name_queue[head] << " " << now << endl;
    } else {
      now += q;
      time_queue[(tail + 1) % 100001] = time_queue[head] - q;
      strcpy(name_queue[(tail + 1) % 100001], name_queue[head]);
      tail = (tail + 1) % 100001;
    }
  }

  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  int n, q;
  queue<pair<string, int>> Q;
  string tmp_name;
  int tmp_time;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> tmp_name >> tmp_time;
    Q.push(make_pair(tmp_name, tmp_time));
  }

  pair<string, int> tmp;
  int ans = 0;

  while (!Q.empty()) {
    tmp = Q.front();
    Q.pop();
    tmp_time = tmp.second;
    if (tmp_time <= q) {
      ans += tmp_time;
      cout << tmp.first << " " << ans << endl;
    } else {
      ans += q;
      Q.push(make_pair(tmp.first, tmp_time - q));
    }
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  int n, q;
  queue<pair<string, int>> Q;
  string tmp_name;
  int tmp_time;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> tmp_name >> tmp_time;
    Q.push(make_pair(tmp_name, tmp_time));
  }

  pair<string, int> tmp;
  int ans = 0;

  while (!Q.empty()) {
    tmp = Q.front();
    tmp_time = tmp.second;
    if (tmp_time <= q) {
      ans += tmp_time;
      cout << tmp.first << " " << ans << endl;
    } else {
      Q.push(make_pair(tmp.first, tmp_time - q));
    }
  }
  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100100;

typedef struct pp {
  char name[100];
  int t;
} P;
P S[MAX_N];
int n, q, w, head, tail;

void enq(P x) {
  S[tail] = x;
  tail = (tail + 1) % MAX_N;
}
P deq() {
  P w = S[head];
  head = (head + 1) % MAX_N;
  return w;
}
int min(int a, int b) { return (a < b) ? a : b; }
int main() {
  int elaps = 0;
  int c, i;
  P u;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++) {
    scanf("%s", S[i].name);
    scanf("%d", &S[i].t);
  }
  head = 1;
  tail = n + 1;
  while (head != tail) {
    u = deq();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) {
      enq(u);
    } else {
      printf("%s %d\\n", u.name, elaps);
    }
  }
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100100;

typedef struct pp {
  char name[100];
  int t;
} P;
P S[MAX_N];
int n, q, w, head, tail;

void enq(P x) {
  S[tail] = x;
  tail = (tail + 1) % tail;
}
P deq() {
  P w = S[head];
  head = (head + 1) % head;
  return w;
}
int min(int a, int b) { return (a < b) ? a : b; }
int main() {
  int elaps = 0;
  int c, i;
  P u;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++) {
    scanf("%s", S[i].name);
    scanf("%d", &S[i].t);
  }
  head = 1;
  tail = n + 1;
  while (head != tail) {
    u = deq();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) {
      enq(u);
    } else {
      printf("%s %d\\n", u.name, elaps);
    }
  }
  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Memory Limit Exceeded

//
//  ALDS1_3_B.cpp
//
//
//  Created by mk on 2015/12/02.
//
//

#include <iostream>
#include <stdio.h>
#include <string.h>
#define LEN 100005

using namespace ::std;

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

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

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

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

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

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

  return 0;
}

Error: MLE

Fixed submission:

//
//  ALDS1_3_B.cpp
//
//
//  Created by mk on 2015/12/02.
//
//

#include <iostream>
#include <stdio.h>
#include <string.h>
#define LEN 100005

using namespace ::std;

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

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

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

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

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

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

  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

/* last edited at 31.8.2015 by charis
http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_3_B
*/

#include <iostream>
#include <string>
using namespace std;

class Queue {
private:
  int head, tail;

public:
  int Q[100001];
  string name[100001];

  void initialize() {
    head = 0;
    tail = 0;
  }
  int isEmpty() { return head == tail; }
  int isFull() { return head == (tail + 1) % 100001; }
  void enqueue(int x, string c) {
    if (isFull())
      cout << "Error" << endl;
    Q[tail] = x;
    name[tail] = c;
    if (tail + 1 == 100001)
      tail = 0;
    else
      tail++;
  }
  int dequeue() {
    if (isEmpty())
      cout << "Error" << endl;
    int x = Q[head];
    if (head + 1 == 100001)
      head = 0;
    else
      head++;
    return x;
  }
  string outname() {
    if (head == 0)
      return name[100000];
    else
      return name[head - 1];
  }
};

int main() {
  int total = 0;
  int n, q;
  cin >> n >> q;

  Queue que;
  que.initialize();

  for (int i = 0; i < n; i++) {
    string c;
    int x;
    cin >> c >> x;
    que.enqueue(x, c);
  }
  if (n == 1 && q == 1) {
    int x = que.dequeue();
    string c = que.outname();
    cout << c << " " << x << endl;
  } else {
    int cnt = 0;
    while (1) {
      if (que.isEmpty())
        break;
      int x = que.dequeue();
      string c = que.outname();
      if (x > q) {
        x = x - q;
        total += q;
        que.enqueue(x, c);
      } else if (x <= q) {
        total += x;
        cout << c << " " << total << endl;
      }
      cnt++;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

/* last edited at 31.8.2015 by charis
http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_3_B
*/

#include <iostream>
#include <string>
using namespace std;

class Queue {
private:
  int head, tail;

public:
  int Q[100];
  string name[100];

  void initialize() {
    head = 0;
    tail = 0;
  }
  int isEmpty() { return head == tail; }
  int isFull() { return head == (tail + 1) % 100; }
  void enqueue(int x, string c) {
    if (isFull())
      cout << "Error" << endl;
    Q[tail] = x;
    name[tail] = c;
    if (tail + 1 == 100)
      tail = 0;
    else
      tail++;
  }
  int dequeue() {
    if (isEmpty())
      cout << "Error" << endl;
    int x = Q[head];
    if (head + 1 == 100)
      head = 0;
    else
      head++;
    return x;
  }
  string outname() { return name[head - 1]; }
};

int main() {
  int total = 0;
  int n, q;
  cin >> n >> q;

  Queue que;
  que.initialize();

  for (int i = 0; i < n; i++) {
    string c;
    int x;
    cin >> c >> x;
    que.enqueue(x, c);
  }

  int cnt = 0;
  while (1) {
    if (que.isEmpty())
      break;
    int x = que.dequeue();
    string c = que.outname();
    if (x > q) {
      x = x - q;
      total += q;
      que.enqueue(x, c);
    } else if (x <= q) {
      total += x;
      cout << c << " " << total << endl;
    }
    cnt++;
  }

  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define SIZE 100000
using namespace std;

struct Queue {
  int work[SIZE];
  int head, tail;

  void init() { head = tail = 0; }

  bool empty() { return head == tail; }

  void inqueue(int x) {
    work[tail++] = x;
    tail %= SIZE;
  }

  int dequeue() {
    int a = work[head++];
    head %= SIZE;
    return a;
  }
};

int main() {
  struct Queue q1, q2;
  int curr = 0, all = 0;
  string name[SIZE];
  q1.init();
  q2.init();
  int n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> name[i] >> t;
    q1.inqueue(t);
    q2.inqueue(i);
    all += t;
  }

  while (!q1.empty()) {
    int a = q1.dequeue();
    int b = q2.dequeue();

    if (a <= l) {
      curr += a;
      cout << name[b] << " " << curr << endl;
    } else {
      curr += l;
      a -= l;
      q1.inqueue(a);
      q2.inqueue(b);
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

struct Task {
  string name;
  int work_time;
  // int spend;
};

int curr = 0;
int all = 0;

struct Task t[100000];
bool chk[100000] = {false};

/*
bool compare(struct Task a, struct Task b)
{
    return a.spend < b.spend;
}
*/

int main() {
  int n;
  int limit;
  cin >> n >> limit;

  for (int i = 0; i < n; i++) {
    cin >> t[i].name;
    cin >> t[i].work_time;
    all += t[i].work_time;
  }

  int i = 0;

  while (curr < all) {
    if (i >= n)
      i = 0;

    if (chk[i]) {
      i++;
      continue;
    } else if (t[i].work_time <= limit) {
      curr += t[i].work_time;
      chk[i] = true;
      cout << t[i].name << " " << curr << endl;
    } else {
      curr += limit;
      t[i].work_time -= limit;
    }

    i++;
  }
  /*
  sort(t, t + n, compare);

  for(int j = 0;j < n;j++)
  {
     cout<<t[j].name<<" "<<t[j].spend<<endl;
  }
  */
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  int n, q;
  int elapsed_time = 0; //????????????
  queue<int> TIME;
  queue<string> NAME;
  cin >> n >> q;

  //??\\???
  for (int i = 0; i < n; i++) {
    string name;
    int time;
    cin >> name >> time;
    NAME.push(name);
    TIME.push(time);
  }

  //??????
  while (!NAME.empty()) {
    if (TIME.front() > q) {
      elapsed_time += q;

      //?????????????????£?????????????????????
      string temp_name = NAME.front();
      NAME.pop();
      NAME.push(temp_name);

      int temp_time = TIME.front() - q;
      TIME.pop();
      TIME.push(temp_time);
    } else {
      elapsed_time += TIME.front();
      TIME.pop();
      cout << NAME.front() << " " << elapsed_time << endl;
      NAME.pop();
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  int n, q;
  int elapsed_time = 0; //????????????
  queue<int> TIME;
  queue<string> NAME;
  cin >> n >> q;

  //??\\???
  for (int i = 0; i < n; i++) {
    string name;
    int time;
    cin >> name >> time;
    NAME.push(name);
    TIME.push(time);
  }

  //??????
  while (!NAME.empty()) {
    if (TIME.front() > q) {
      elapsed_time += q;

      //?????????????????£?????????????????????
      string temp_name = NAME.front();
      NAME.pop();
      NAME.push(temp_name);

      int temp_time = TIME.front();
      TIME.pop();
      TIME.push(temp_time);
    } else {
      elapsed_time += TIME.front();
      TIME.pop();
      cout << NAME.front() << " " << elapsed_time << endl;
      NAME.pop();
    }
  }

  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

#define MAX 100000

class Queue_c {

private:
  int time[MAX];
  string name[MAX];
  int head, tail;
  int sum;

public:
  Queue_c();
  bool isEmpty();
  bool isFull();
  void enqueue(string n, int t);
  void dequeue(int q);
};

Queue_c::Queue_c() { head = tail = sum = 0; }
bool Queue_c::isEmpty() { return head == tail; }
bool Queue_c::isFull() { return head == (tail + 1) % MAX; }
void Queue_c::enqueue(string n, int t) {

  time[tail] = t;
  name[tail] = n;

  if (++tail == MAX)
    tail = 0;
}
void Queue_c::dequeue(int q) {

  if (time[head] - q <= 0) {
    sum += time[head];
    cout << name[head] + ' ' << sum << endl;
    head++;
  } else {
    enqueue(name[head], time[head] - q);
    if (++head == MAX) {
      head = 0;
    }
    sum += q;
  }
}

int main() {

  int n, q;
  int time;
  string name;

  Queue_c Que;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> name >> time;
    Que.enqueue(name, time);
  }

  while (!Que.isEmpty()) {

    Que.dequeue(q);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int n, q;
  int time[100000];
  string name[100000];
  int sum = 0;
  int fin = 0;
  int tmp1;
  string tmp2;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> name[i] >> time[i];
  }

  // cout << "first:";
  // for(int i=0; i<n; i++){ cout << name[i]+' '; }
  // cout << ":last" << endl;

  while (fin < n) {

    tmp1 = time[0];
    tmp2 = name[0];

    for (int i = 0; i < n - 1 - fin; i++) {
      time[i] = time[i + 1];
      name[i] = name[i + 1];
    }
    time[n - 1 - fin] = tmp1;
    name[n - 1 - fin] = tmp2;

    if (time[n - 1 - fin] - q <= 0) {
      sum += time[n - 1 - fin];
      cout << name[n - 1 - fin] << ' ' << sum << endl;
      fin++;
    } else {
      sum += q;
      time[n - 1 - fin] -= q;
    }

    // cout << "first:";
    // for(int i=0; i<n-fin; i++){ cout << name[i]+' '; }
    // cout << ":last" << endl;
  }

  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
using namespace std;

int main() {
  int N, q;
  cin >> N >> q;
  int Q1[100000] = {};
  string Q2[100000] = {};
  int T = 0;
  int head = 0;
  int tail = N;
  for (int i = 0; i < N; i++) {
    cin >> Q2[i] >> Q1[i];
  }
  while (head != tail || Q1[head] != 0 || Q1[tail] != 0) {
    if (Q1[head] <= q) {
      T += Q1[head];
      cout << Q2[head] << " " << T << endl;
      Q1[head] = 0;
      Q2[head] = " ";
      if (head == N) {
        head = 0;
      } else {
        head++;
      }
    } else {
      T += q;
      Q1[head] -= q;
      Q1[tail] = Q1[head];
      Q2[tail] = Q2[head];
      Q1[head] = 0;
      Q2[head] = " ";
      if (tail == N) {
        head++;
        tail = 0;
      } else {
        if (head == N) {
          head = 0;
        } else {
          head++;
        }
        tail++;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N, q;
  cin >> N >> q;
  string QN[N];
  int QT[N];
  int T = 0;
  int count = 0;
  int time = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> QN[i] >> QT[i];
    if (QT[i] % q == 0) {
      time += QT[i] / q;
    } else if (QT[i] % q != 0) {
      time += QT[i] / q + 1;
    }
  }
  while (cnt != time) {
    if (QT[count] == 0 && count != N - 1) {
      count++;
      continue;
    } else if (QT[count] == 0 && count == N - 1) {
      count = 0;
      continue;
    }
    if (QT[count] <= q) {
      T += QT[count];
      cout << QN[count] << " " << T << endl;
      QT[count] = 0;
    } else if (QT[count] > q) {
      T += q;
      QT[count] -= q;
    }
    if (count == N - 1) {
      count = 0;
      cnt++;
      continue;
    }
    count++;
    cnt++;
  }
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;

class Queue {
public:
  pair<string, int> data[100001];
  int dp, ep;

  Queue() {
    dp = 0;
    ep = 0;
  }

  void enqueue(pair<string, int> proc) {
    data[ep++] = proc;
    if (ep > 100000)
      ep = 0;
  }
  pair<string, int> dequeue() {
    pair<string, int> tmp = data[dp++];
    if (dp > 100000)
      dp = 0;
    return tmp;
  }

  int isSize() { return ep - dp; }
};

int main() {
  int n, q, time = 0;
  cin >> n >> q;
  pair<string, int> proc;
  Queue queue;
  while (cin >> proc.first >> proc.second) {
    queue.enqueue(proc);
  }
  while (queue.isSize() != 0) {
    proc = queue.dequeue();
    if (proc.second - q > 0) {
      time += q;
      proc.second -= q;
      queue.enqueue(proc);
    } else {
      time += proc.second;
      cout << proc.first << ' ' << time << endl;
    }
  }
}


Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

class Queue {
public:
  pair<string, int> data[100001];
  int dp, ep;

  Queue() {
    dp = 0;
    ep = 0;
  }

  void enqueue(pair<string, int> proc) {
    data[ep] = proc;
    ep++;
  }
  pair<string, int> dequeue() { return data[dp++]; }

  int isSize() { return ep - dp; }
};

int main() {
  int n, q, time = 0;
  cin >> n >> q;
  pair<string, int> proc;
  Queue queue;
  while (cin >> proc.first >> proc.second) {
    queue.enqueue(proc);
  }
  while (queue.isSize() > 1) {
    proc = queue.dequeue();
    if (proc.second - q > 0) {
      time += q;
      proc.second -= q;
      queue.enqueue(proc);
    } else {
      time += proc.second;
      cout << proc.first << ' ' << time << endl;
    }
  }
  proc = queue.dequeue();
  cout << proc.first << ' ' << time + proc.second << endl;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
using namespace std;

#if 0
queue<pair<string, int>>はダメです。queue<pair<string, int> >の中の’’は必要です。
#endif
pair<string, int> process;
queue<pair<string, int>> Q;
int main() {
  int j = 0, times = 0;
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> process.first >> process.second;
    Q.push(process);
  }
  while (!Q.empty()) {
    process = Q.front();
    Q.pop();
    if (process.second > q) {
      process.second -= q;
      times += q;
      Q.push(process);
    } else {
      times += process.second;
      cout << process.first << " " << times << endl;
    }
  }
  return 0;
}


Error: 1

Fixed submission:

#include <iostream>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
using namespace std;

int n, q, times = 0;
pair<string, int> process1;
queue<pair<string, int>> Q;

int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> process1.first >> process1.second;
    Q.push(process1);
  }
  while (!Q.empty()) {
    process1 = Q.front();
    Q.pop();
    if (process1.second <= q) {
      times += process1.second;
      cout << process1.first << " " << times << endl;
    } else {
      times += q;
      process1.second -= q;
      Q.push(process1);
    }
  }
  return 1;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
using namespace std;

#if 0
queue<pair<string, int>>はダメです。queue<pair<string, int> >の中の’’は必要です。
#endif
#define MAX_SIZE 100000
pair<string, int> process1, process2;
queue<pair<string, int>> Q;
int main() {
  int j = 0, sum = 0;
  int n, t, flag = 0;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> process1.first >> process1.second;
    Q.push(process1);
  }
  while (!Q.empty()) {
    process2 = Q.front();
    Q.pop();
    if (process2.second > t) {
      process2.second -= t;
      sum += t;
      Q.push(process2);
    } else {
      sum += process2.second;
      cout << process2.first << " " << sum << endl;
    }
  }
  return 0;
}


Error: 1

Fixed submission:

#include <iostream>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
using namespace std;

int n, q, times;
pair<string, int> process1;
queue<pair<string, int>> Q;
void solve() {
  while (!Q.empty()) {
    process1 = Q.front();
    Q.pop();
    if (process1.second <= q) {
      times += process1.second;
      cout << process1.first << " " << times << endl;
    } else {
      times += q;
      process1.second -= q;
      Q.push(process1);
    }
  }
}
int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> process1.first >> process1.second;
    Q.push(process1);
  }
  solve();
  return 1;
}