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

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

using namespace std;

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

  queue<pair<string, int>> que;
  for (int i = 0; i < n; i++) {
    string s;
    int time;
    cin >> s >> time;
    pair<string, int> p(s, time);
    que.push(p);
  }
  int count = 0;
  while (count < n) {
    pair<string, int> p = que.front();
    que.pop();

    if (p.second <= q) {
      timecounter += p.second;
      cout << p.first << " " << timecounter << endl;
      count += 1;
    } else {
      p.second -= q;
      timecounter += q;
      que.push(p);
    }
  }
  return 0;
}


Error: MLE

Fixed submission:

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

struct Qtime {
  char name[15];
  int time;
};

int main() {
  int n, q, sum = 0;
  ;
  Qtime a;
  queue<Qtime> s;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a.name >> a.time;
    if (a.time <= q) {
      sum += a.time;
      cout << a.name << " " << sum << endl;
    } else {
      sum += q;
      a.time -= q;
      s.push(a);
    }
  }

  while (s.size() > 0) {
    a = s.front();
    if (a.time <= q) {
      sum += a.time;
      cout << a.name << " " << sum << endl;
      s.pop();
    } else {
      sum += q;
      a.time -= q;
      s.push(a);
    }
  }

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

#include <iostream>
#include <queue>

using namespace std;

struct Process {
  string name;
  int time;

  Process(string name = "", int time = 0) : name(name), time(time) {}
};

int main() {

  long long passtime = 0;
  int n, q;
  string s;
  int t;
  queue<Process> que;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> s;
    cin >> t;
    que.push(Process(s, t));
  }

  while (!que.empty()) {
    Process np = que.front();
    que.pop();
    if (np.time <= q) {
      passtime += np.time;
      cout << np.name << " " << passtime << endl;
    } else {
      passtime += q;
      np.time -= q;
      que.push(np);
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, q, sum = 0, t;
  string na;
  vector<string> name, nout;
  vector<int> time, tout;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> na >> t;
    name.push_back(na);
    time.push_back(t);
  }
  while (time.size() != 0) {
    if (time.at(0) > q) {
      time.at(0) -= q;
      sum += q;
      time.push_back(time.at(0));
      time.erase(time.begin());
      name.push_back(name.at(0));
      name.erase(name.begin());

    } else {
      sum += time.at(0);
      tout.push_back(sum);
      nout.push_back(name.at(0));
      time.erase(time.begin());
      name.erase(name.begin());
    }
  }

  for (int i = 0; i < nout.size(); i++)
    cout << nout.at(i) << " " << tout.at(i) << endl;
}
Problem p02264 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <fstream>
#include <stdio.h>
#include <vector>
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;
}

Error: MLE

Fixed submission:

#include <stdio.h>
// #include<fstream>
#include <algorithm>
using namespace std;
struct renwu {
  char m[1000];
  int t;
} a[1000000];
int main() {
  int n;
  int p;
  int x = 0;
  scanf("%d%d", &n, &p);
  int k = 0, l = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s%d", a[i].m, &a[i].t);
  }
  int head = 0;
  int tail = n;
  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;
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#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);
  }
}

Error: TLE

Fixed submission:

#include <iostream>

struct task {
  char name[12];
  int time;
  int sum;
  int bool_; //????´???
};

task Queue[100005];

int main(void) {
  using namespace std;

  int n, q, top;

  while (cin >> n >> q) {
    for (int i = 0; i < n; i++) {
      cin >> Queue[i].name >> Queue[i].time;
      Queue[i].sum = 0;
      Queue[i].bool_ = 1;
    }

    int Last = n;
    top = 0;
    int Sum = 0;

    while (Last) {
      for (int i = 0; i < n; i++) {
        if (Queue[i].bool_ == 1 && Queue[i].time <= q) {
          Sum += Queue[i].time;
          cout << Queue[i].name << " " << Sum << endl;
          Queue[i].bool_ = 0;
          Last--;
        } else if (Queue[i].bool_ == 1) {
          Sum += q;
          Queue[i].time -= q;
        }
      }
    }
  }

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

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

#define MAX_P 100000
#define Q_size 100001

typedef struct {
  char name[10];
  int time;
} Process;

Process Queue[Q_size];
int head, tail;

void push(Process p) { Queue[tail++ % Q_size] = p; }

Process pop() { return Queue[head++ % Q_size]; }

int main() {
  int i, n, p_time, total = 0;
  Process p;

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

  for (i = 0; i < n; i++) {
    scanf("%s %d", p.name, &p.time);
    push(p);
  }

  while (head != tail) {
    p = pop();

    if (p.time <= p_time) {
      total += p.time;
      printf("%s %d\\n", p.name, total);
    } else {
      total += p_time;
      p.time -= p_time;
      push(p);
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

#define MAX_P 100000
#define Q_size 100001

// int Queue[Q_size];
// int head, tail;

typedef struct {
  char name[10];
  int time;
} Process;

Process Queue[Q_size];
int head, tail;

void push(Process p) {
  Queue[tail] = p;
  tail = (tail + 1) % Q_size;
}

Process pop() { return Queue[head++ % Q_size]; }

int main() {
  int i, n, p_time, total = 0;
  Process p;

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

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

  while (head != tail) {
    p = pop();

    if (p.time <= p_time) {
      total += p.time;
      printf("%s %d\\n", p.name, total);
    } else {
      total += p_time;
      p.time -= p_time;
      push(p);
    }
  }

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

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

#define MAX_DATA_NUM 10000000

int Q[MAX_DATA_NUM];
int head, tail;

void enqueue(int num) {
  Q[tail] = num;
  tail++;
  if (tail == MAX_DATA_NUM)
    tail = 0;
}

int dequeue() {
  int res = Q[head];
  head++;
  if (head == MAX_DATA_NUM - 1)
    head = 0;
  return res;
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<string> name(n);
  vector<int> name_num(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> name[i] >> tmp;
    name_num[i] = i;
    enqueue(tmp);
  }
  int cnt = 0, num = 0;
  while (1) {
    int i;
    for (i = 0; i < n - num; i++) {
      int s = dequeue() - q;
      if (s <= 0) {
        cnt += s + q;
        cout << name[name_num[i]] << " " << cnt << endl;
        name_num.erase(name_num.begin() + i);
        i--;
        num++;
      } else {
        cnt += q;
        enqueue(s);
      }
    }
    if (num == n)
      break;
  }
}

Error: TLE

Fixed submission:

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

#define MAX_DATA_NUM 10000000

int Q[MAX_DATA_NUM];
int head, tail;

void enqueue(int num) {
  Q[tail] = num;
  tail++;
  if (tail == MAX_DATA_NUM)
    tail = 0;
}

int dequeue() {
  int res = Q[head];
  head++;
  if (head == MAX_DATA_NUM - 1)
    head = 0;
  return res;
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<string> name(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> name[i] >> tmp;
    enqueue(tmp);
  }
  int cnt = 0, num = 0;
  while (1) {
    for (int i = 0; i < n; i++) {
      int s = dequeue() - q;
      if (s <= 0) {
        cnt += s + q;
        cout << name[i] << " " << cnt << endl;
        enqueue(10000);
        num++;
      } else {
        if (s + q != 10000) {
          cnt += q;
          enqueue(s);
        } else {
          enqueue(10000);
        }
      }
    }
    if (num == n)
      break;
  }
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <stdio.h>
using namespace std;
const int LEN = 100000; //??????????????§??????
struct pp {
  char name[10];
  int time;
};
pp P[LEN];
int head, tail, n;
void enqueue(struct pp x) //??\\????????°
{
  P[tail] = x;             //?°?x?????\\??°????°?
  tail = (tail + 1) % LEN; //??¨?????????????????????????????????head=(tail + 1)
                           //% LEN??¶??´???????????????
}
struct pp dequeue() //???????????°
{
  struct pp x = P[head]; //?°?head??????????????´????´?????????\\??????x
  head = (head + 1) % LEN;
  return x; //????????????????´?
}

int main() {
  int alltime = 0; //?´??????¶??´  ?±???¨????????????????§????
  int n, q;        // n??¨???????????°???q??¨?????¶??´????????§?°?
  struct pp u;
  scanf("%d%d", &n, &q);
  //?°?????????????????????°?????????
  for (int i = 0; i < n; i++) {
    scanf("%s%d", &P[i].name, &P[i].time); // cin >> P[i].name >> P[i].time;
  }
  head = 0;
  tail = n;
  //?¨??????¶??´????????¬???
  while (head != tail) {
    u = dequeue(); //?????´????´???????
    int c =
        min(q, u.time); //????????¶??´????????§?°??????\\????????????????????¶??´
    u.time = u.time - q; //????????????????????????????????¶??´
    alltime = alltime + c;
    if (u.time > 0)
      enqueue(u); //??????????????¬????????\\??°????°?
    else {
      printf("%s %d\\n", u.name, alltime);
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
const int LEN = 100000; //??????????????§??????
struct pp {
  char name[10];
  int time;
};
pp P[LEN];
int head, tail, n;
void enqueue(struct pp x) //??\\????????°
{
  P[tail] = x;     //?°?x?????\\??°????°?
  tail = tail + 1; //??¨?????????????????????????????????head=(tail + 1) %
                   //LEN??¶??´???????????????
}
struct pp dequeue() //???????????°
{
  struct pp x = P[head]; //?°?head??????????????´????´?????????\\??????x
  head = head + 1;
  return x; //????????????????´?
}

int main() {
  int alltime = 0; //?´??????¶??´  ?±???¨????????????????§????
  int n, q;        // n??¨???????????°???q??¨?????¶??´????????§?°?
  struct pp u;
  scanf("%d%d", &n, &q);
  //?°?????????????????????°?????????
  for (int i = 0; i < n; i++) {
    scanf("%s%d", &P[i].name, &P[i].time); // cin >> P[i].name >> P[i].time;
  }
  head = 0;
  tail = n;
  //?¨??????¶??´????????¬???
  while (head != tail) {
    u = dequeue(); //?????´????´???????
    int c =
        min(q, u.time); //????????¶??´????????§?°??????\\????????????????????¶??´
    u.time = u.time - q; //????????????????????????????????¶??´
    alltime = alltime + c;
    if (u.time > 0)
      enqueue(u); //??????????????¬????????\\??°????°?
    else {
      printf("%s %d\\n", u.name, alltime);
    }
  }
  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int i, n, q, sum = 0, x, tin;
  string s, sin;
  queue<string> Name;
  queue<int> Time;

  cin >> n >> q;

  for (i = 0; i < n; i++) {
    cin >> sin >> tin;
    Name.push(sin);
    Time.push(tin);
  }
  while (Name.empty() == 0) {
    s = Name.front();
    x = Time.front();
    if (x <= q) {
      sum += x;
      cout << s << " " << sum << endl;
    } else {
      sum += q;
      x -= q;
      Name.push(s);
      Time.push(x);
    }
    Name.pop();
    Time.pop();
  }
  return 0;
}


Error: 0

Fixed submission:

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

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

int main() {
  int i, n, q, sum = 0, x;
  string s;
  P A[1000];
  queue<string> Name;
  queue<int> Time;

  cin >> n >> q;

  for (i = 0; i < n; i++) {
    cin >> A[i].name >> A[i].t;
    Name.push(A[i].name);
    Time.push(A[i].t);
  }
  while (Name.empty() == 0) {
    s = Name.front();
    x = Time.front();
    if (x <= q) {
      sum += x;
      cout << s << " " << sum << endl;
    } else {
      sum += q;
      x -= q;
      Name.push(s);
      Time.push(x);
    }
    Name.pop();
    Time.pop();
  }
  return 0;
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdlib>
#include <iostream>
#include <stdio.h>
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 + 1;
  queue = new P[size];
}

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;
}

Error: TLE

Fixed submission:

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

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

int main(void) {
  int n, q;
  cin >> n >> q;

  PROCESS *queue = new PROCESS[n];
  for (int i = 0; i < n; i++) {
    cin >> queue[i].name;
    cin >> queue[i].time;
  }

  int time = 0;
  int idx = 0;
  int cnt = 0;
  while (cnt < n) {
    if (queue[idx].time <= q) {
      if (queue[idx].time != 0) {
        time += queue[idx].time;
        queue[idx].time = 0;
        cnt++;

        cout << queue[idx].name << " ";
        cout << time << endl;
      }
    } else {
      time += q;
      queue[idx].time -= q;
    }
    idx = (idx + 1) % n;
  }

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

#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
using namespace std;
int main(void) {
  queue<pair<string, int>> Q;
  int n, q, x, a, cou = 0, time = 0;
  string name;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> name >> x;
    Q.push(make_pair(name, x));
  }
  while (!(Q.empty())) {
    pair<string, int> p = Q.front();
    Q.pop();
    if (p.second > q) {
      Q.push(make_pair(p.first, p.second - q));
      time += q;
    } else {
      time += p.second;
      cout << p.first << " " << time << endl;
    }
  }
}

Error: -11

Fixed submission:

#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
using namespace std;
#define N 1000000
int main(void) {
  char str[N][11];
  queue<int> Q;
  int n, q, x, a, cou = 0, time = 0;

  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> str[i] >> x;
    Q.push(x);
  }
  a = n;
  for (int i = 0; i < a; i++) {
    x = Q.front();
    Q.pop();
    if (x > q) {
      Q.push(x - q);
      time += q;
      for (int j = 0; str[i][j - 1] != '\\0' && str[i - cou][j - 1] != '\\0';
           j++) {
        str[i - cou][j] = str[i][j];
      }
    } else {
      time += x;
      if (i < a) {
        cou++;
        cout << str[i] << " " << time << endl;
      }
    }
    if (i >= a - 1) {
      i = -1;
      a = a - cou;
      cou = 0;
    }
  }
}
Problem p02264 (C++) — buggy submission, verdict: Time Limit Exceeded

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

class Process {
public:
  std::string name;
  int reqtime;
};

int main() {
  std::queue<Process> queProcess;

  int processNum;
  std::cin >> processNum;

  int quantumTime;
  std::cin >> quantumTime;

  for (int i = 0; i < processNum; i++) {
    Process tempProcess;
    std::cin >> tempProcess.name >> tempProcess.reqtime;
    queProcess.push(tempProcess);
  }

  int elapsedTime = 0;
  while (!queProcess.empty()) {
    Process tempProcess;
    tempProcess = queProcess.front();
    queProcess.pop();

    if (tempProcess.reqtime <= quantumTime) {
      elapsedTime += tempProcess.reqtime;
      tempProcess.reqtime = 0;
      std::cout << tempProcess.name << " " << elapsedTime << std::endl;
    } else {
      elapsedTime += quantumTime;
      tempProcess.reqtime -= quantumTime;
      queProcess.push(tempProcess);
    }
  }
}


Error: TLE

Fixed submission:

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

typedef struct {
  string name;
  int time;
} Process;

void remove(Process *, int);
void move(Process *, int);
void output(Process *, int);

int main(void) {
  int pronum;
  int quantum;
  Process *process;
  int totaltime = 0;

  cin >> pronum >> quantum;

  process = new Process[pronum];

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

  while (pronum > 0) {
    if (process[0].time - quantum <= 0) {
      totaltime += process[0].time;
      cout << process[0].name << " " << totaltime << endl;
      remove(process, pronum);
      // cout << "remove" << endl;
      // output(process,pronum);
      pronum--;
    } else {
      totaltime += quantum;
      process[0].time -= quantum;
      move(process, pronum);
      // cout << "move" << endl;
      // output(process,pronum);
    }
  }
}

void remove(Process *process, int pronum) {
  for (int i = 0; i < pronum - 1; i++) {
    process[i].name = process[i + 1].name;
    process[i].time = process[i + 1].time;
  }
}

void move(Process *process, int pronum) {
  Process temp;
  temp.name = process[0].name;
  temp.time = process[0].time;
  for (int i = 0; i < pronum - 1; i++) {
    process[i].name = process[i + 1].name;
    process[i].time = process[i + 1].time;
  }
  process[pronum - 1].name = temp.name;
  process[pronum - 1].time = temp.time;
}

void output(Process *process, int pronum) {
  for (int i = 0; i < pronum; i++) {
    cout << "process[" << i << "]:" << process[i].name << " " << process[i].time
         << endl;
  }
}
Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct qeu {
  int n;
  char name[10];
} Qeu;
void init();
void enque(Qeu);
Qeu deque();

int head, tail;
Qeu Qo[100000];

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

void enque(Qeu Q) {
  Qo[tail++] = Q;
  tail = tail % 100000;
}

Qeu deque() {
  Qeu x;
  x = Qo[head];
  head++;
  head = head % 100000;
  return x;
}

int mini(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}

int main() {
  Qeu Q, Qt[1000], Qnow;
  int i, n, time;
  int total, tt;
  total = 0;
  scanf("%d %d", &n, &time);

  for (i = 0; i < n; i++) {
    scanf("%s %d", Q.name, &Q.n);
    enque(Q);
  }
  while (1) {
    if (head == tail)
      break;
    Qnow = deque();
    tt = mini(Qnow.n, time);
    Qnow.n -= tt;
    total += tt;
    if (Qnow.n == 0) {
      printf("%s %d\\n", Qnow.name, total);
    } else {
      enque(Qnow);
    }
  }
  return 0;
}

Error: 0

Fixed submission:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct qeu {
  int n;
  char name[10];
} Qeu;
void init();
void enque(Qeu);
Qeu deque();

int head, tail;
Qeu Qo[100000];

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

void enque(Qeu Q) {
  Qo[tail++] = Q;
  tail = tail % 100000;
}

Qeu deque() {
  Qeu x;
  x = Qo[head];
  head++;
  head = head % 100000;
  return x;
}

int mini(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}

int main() {
  Qeu Q, Qt[1000], Qnow;
  int i, n, time;
  int total, tt;
  int count = 0;
  total = 0;
  scanf("%d %d", &n, &time);

  for (i = 0; i < n; i++) {
    scanf("%s %d", Q.name, &Q.n);
    enque(Q);
  }
  while (1) {
    if (head == tail)
      break;
    Qnow = deque();
    tt = mini(Qnow.n, time);
    Qnow.n -= tt;
    total += tt;
    if (Qnow.n == 0) {
      Qt[count] = Qnow;
      Qt[count].n = total;
      count++;
    } else {
      enque(Qnow);
    }
  }
  for (i = 0; i < n; i++) {
    printf("%s %d\\n", Qt[i].name, Qt[i].n);
  }

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

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

#define MAX 200000

int sum_time = 0;

typedef struct process {
  char name[20];
  int time;
} process;

process q[MAX];
int head = 0;
int tail = 0;
bool is_full = false;
bool is_empty = false;

void enqueue(process p) {
  is_empty = false;
  q[tail] = p;
  if (tail == MAX - 1) {
    tail = 0;
  } else {
    tail += 1;
  }
  if (tail == head) {
    is_full = true;
  }
}

process dequeue() {
  process p;
  if (head == MAX - 1) {
    p = q[head];
    head = 0;
  } else {
    p = q[head];
    head += 1;
  }
  if (head == tail) {
    is_empty = true;
  }
  return p;
}

int main(void) {
  int n, quantum;
  scanf("%d %d", &n, &quantum);

  for (int i = 0; i < n; i++) {
    process p;
    scanf("%s %d", p.name, &p.time);
    enqueue(p);
  }

  while (!is_empty) {
    process p = dequeue();
    if (p.time > quantum) {
      sum_time += quantum;
      p.time -= quantum;
      enqueue(p);
    } else {
      sum_time += p.time;
      printf("%s %d\\n", p.name, sum_time);
    }
  }
}


Error: TLE

Fixed submission:

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

#define MAX 2000

int sum_time = 0;

typedef struct process {
  char name[20];
  int time;
} process;

process q[MAX];
int head = 0;
int tail = 0;
bool is_full = false;

bool is_empty() {
  if (is_full) {
    return false;
  }
  if (tail == head) {
    return true;
  }
  return false;
}

void enqueue(process p) {
  q[tail] = p;
  if (tail == MAX - 1) {
    tail = 0;
  } else {
    tail += 1;
  }
  if (tail == head) {
    is_full = true;
  }
}

process dequeue() {
  process p;
  if (head == MAX - 1) {
    p = q[head];
    head = 0;
  } else {
    p = q[head];
    head += 1;
  }
  return p;
}

int main(void) {
  int n, quantum;
  scanf("%d %d", &n, &quantum);

  for (int i = 0; i < n; i++) {
    process p;
    scanf("%s %d", p.name, &p.time);
    enqueue(p);
  }

  while (!is_empty()) {
    process p = dequeue();
    if (p.time > quantum) {
      sum_time += quantum;
      p.time -= quantum;
      enqueue(p);
    } else {
      sum_time += p.time;
      printf("%s %d\\n", p.name, sum_time);
    }
  }
}