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

#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
  char W[201], Wbuf[201];
  int h;
  int n, i, j, k;

  while (1) {
    scanf("%s\\n%d", W, &n);
    if (W[0] == '-')
      break;
    for (i = 0; i < n; i++) {
      scanf("%d", &h);
      for (j = h; W[j] != '\\0'; j++)
        Wbuf[j - h] = W[j];
      for (k = 0; k < h; k++)
        Wbuf[j - h + k] = W[k];
      for (j = 0; W[j] != '\\0'; j++)
        W[j] = Wbuf[j];
    }
    printf("%s\\n", W);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
  char W[201], Wbuf[201];
  int h;
  int n, i, j, k;
  while (1) {
    scanf("%s\\n%d", W, &n);
    if (W[0] == '-')
      break;
    for (i = 0; i < n; i++) {
      scanf("%d", &h);
      for (j = h; W[j] != '\\0'; j++) {
        Wbuf[j - h] = W[j];

        for (k = 0; k < h; k++)
          Wbuf[j - h + k] = W[k];
        for (j = 0; W[j] != '\\0'; j++)
          W[j] = Wbuf[j];
      }
      printf("%s\\n", W);
    }
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

int main(void) {
  std::string s;
  int m, h;
  while (std::cin >> s) {
    if (s == "-")
      break;
    std::cin >> m;
    while (m-- > 0) {
      std::cin >> h;
      s = s.substr(h) + s.substr(0, h);
    }
    std::cout << s << std::endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>

int main(void) {
  std::string s;
  int m, h;
  while (1) {
    std::cin >> s;
    if (s == "-")
      break;
    std::cin >> m;
    while (m-- >= 0) {
      std::cin >> h;
      s = s.substr(h) + s.substr(0, h);
    }
  }
  std::cout << s << std::endl;
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstring>

int main(void) {
  int i, j;
  int m[256];
  int s[256] = {0};
  char c[256][201];
  int d[256] = {0};
  int k = 0;
  while (1) {
    scanf("%s", c[k]);
    if (strcmp(c[k], "-") == 0)
      break;
    while (c[k][d[k]] != '\\0') {
      d[k]++;
    };

    scanf("%d", &m[k]);
    for (i = 0; i < m[k]; i++) {
      scanf("%d", &j);
      s[k] = s[k] + j;
    };
    s[k] = s[k] % d[k];
    k++;
  }

  for (i = 0; i < k; i++) {
    for (j = 0; j < d[i]; j++) {
      c[i][j + d[i]] = c[i][j];
    };
    for (j = 0; j < d[i]; j++) {
      printf("%c", c[i][j + s[i]]);
    };
    printf("\\n");
  };
  return 0;
}

Error: -8

Fixed submission:

#include <cstdio>
#include <cstring>

int main(void) {
  int i, j;
  int m[256];
  int s[256] = {0};
  char c[256][201];
  int d[256] = {0};
  int k = 0;
  while (1) {
    scanf("%s", c[k]);
    if (strcmp(c[k], "_") == 0)
      break;
    while (c[k][d[k]] != '\\0') {
      d[k]++;
    };

    scanf("%d", &m[k]);
    for (i = 0; i < m[k]; i++) {
      scanf("%d", &j);
      s[k] = s[k] + j;
    };
    s[k] = s[k] % d[k];
    k++;
  }

  for (i = 0; i < k; i++) {
    for (j = 0; j < d[i]; j++) {
      c[i][j + d[i]] = c[i][j];
    };
    for (j = 0; j < d[i]; j++) {
      printf("%c", c[i][j + s[i]]);
    };
    printf("\\n");
  };
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  char s[201], t[201];
  int len, n, h;
  while (1) {
    cin >> s;
    len = strlen(s);
    if (len == 1 && s[0] == '-')
      break;
    cin >> n;
    while (n--) {
      cin >> h;
      for (int i = 0, j = h; i < len; i++, ++j %= len) {
        if (i < h)
          t[i] = s[j];
        else
          t[i] = s[j];
      }
      for (int i = 0; i < len; i++)
        s[i] = t[i];
      s[len] = '\\0';
    }
    cout << s << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  char c[200];
  while (1) {
    cin >> c;
    if (c == "-")
      break;
    int clen = strlen(c);
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      int h;
      cin >> h;
      int tmp[200];
      for (int j = 0; j < h; j++)
        tmp[j] = c[j];
      for (int j = h; j < clen; j++)
        c[j - h] = c[j];
      for (int j = 0; j < h; j++)
        c[clen - h + j] = tmp[j];
    }
    cout << c << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int m, n;
  std::string str, tes;
  while (true) {
    std::cin >> str >> m;
    if (str == "-")
      break;
    for (int a = 0; a < m; a++) {
      std::cin >> n;
      tes = str.substr(0, n);
      str.erase(str.begin(), str.begin() + n);
      str += tes;
    }
    std::cout << str << std::endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int m, n;
  std::string str, tes;
  while (true) {
    std::cin >> str >> m;
    if (m == '-')
      break;
    for (int a = 0; a < m; a++) {
      std::cin >> n;
      tes = str.substr(0, n);
      str.erase(str.begin(), str.begin() + n);
      str += tes;
    }
    std::cout << str << std::endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  cin >> str;
  do {

    int n;
    cin >> n;
    int total = 0;
    int temp = 0;

    while (n--) {
      cin >> temp;
      total += temp;
    }
    temp = total % str.size();
    cout << str.substr(temp) << str.substr(0, temp) << endl;
  } while (cin >> str, str != "-");

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  do {
    cin >> str;
    int n;
    cin >> n;
    int total = 0;
    int temp = 0;

    while (n--) {
      cin >> temp;
      total += temp;
    }
    temp = total % str.size();
    cout << str.substr(temp) << str.substr(0, temp) << endl;
  } while (cin >> str, str != "-");

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

#include <iostream>
using namespace std;

int main() {
  int s, k, m, n;
  char str[201];
  while (1) {
    cin >> str;
    if (str[0] == '-')
      break;
    n = 0;
    while (str[n++])
      ;
    n -= 1;
    cin >> s;
    m = 0;
    for (int i = 0; i < s; i++) {
      cin >> k;
      m += k;
    }
    k = m % n;

    for (int i = k; i < n; i++)
      cout << str[i];
    for (int i = 0; i < k; i++)
      cout << str[i];
    cout << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int s, k, m, n;
  char *str;
  while (1) {
    cin >> str;
    if (*str == '-')
      break;
    n = 0;
    while (*str) {
      str++;
      n++;
    }
    for (int i = 0; i < n; i++)
      str--;
    cin >> s;
    m = 0;
    for (int i = 0; i < s; i++) {
      cin >> k;
      m += k;
    }
    k = m % n;
    if (k) {
      for (int i = k; i < n; i++)
        cout << str[i];
      for (int i = 0; i < (n - k - 1); i++)
        cout << str[i];
    } else
      for (int i = 0; i < (n - k); i++)
        cout << str[i];
    cout << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int s, k, m, n;
  string str;
  while (1) {
    cin >> str;
    if (str[0] == '-')
      break;
    n = str.size();
    cin >> s;
    m = 0;
    for (int i = 0; i < s; i++) {
      cin >> k;
      m += k;
    }
    k = m % n;
    for (int i = k; i < n; i++)
      cout << str[i];
    for (int i = 0; i < k; i++)
      cout << str[i];
    cout << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int s, k, m, n;
  char *str;
  while (1) {
    cin >> str;
    if (*str == '-')
      break;
    n = 0;
    while (*str) {
      str++;
      n++;
    }
    str -= n;
    cin >> s;
    m = 0;
    for (int i = 0; i < s; i++) {
      cin >> k;
      m += k;
    }
    k = m % n;

    for (int i = k; i < n; i++)
      cout << str[i];
    for (int i = 0; i < k; i++)
      cout << str[i];
    cout << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <cctype>
#include <iostream>
#include <string>

#define rep(i, start, n) for (int i = 0; i < n; i++) //???????????????

using namespace std;

int main() {

  long long int
      count_change = 0,
      b[100] = {
          0}; // count_change??????????????£????????????????????????b[100]??????????????????????????????????????????????´????????????°
  string member,
      change; // member?????????????????????????????????????´????change????????£????????????????????????????´????????????°

  while (1) {

    cin >> member; //????????????????????????????????\\???
    if (member == "-")
      break;                  // ???????????????????????????????????¶
    cin >> count_change;      //?????£????????????????????°?????\\???
    rep(i, 0, count_change) { //???????????????
      cin >> b[i];            //?????£????????????????????°?????\\???
      change = member.substr(
          0,
          b[i]); //???????????????????????????????????????????????\\?????????????????£????????????????????°?????§???????????????change???????´?
      member += change; // member????????????????????????????????£?????????
      member = member.substr(
          b[i],
          member
              .length()); //????????????????????????????????????member???????´?
    }
    cout << member << endl; //??¨???
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cctype>
#include <iostream>
#include <string>

#define rep(i, start, n) for (int i = 0; i < n; i++) //???????????????

using namespace std;

int main() {

  int count_change = 0,
      b[100] = {
          0}; // count_change??????????????£????????????????????????b[100]??????????????????????????????????????????????´????????????°
  string member,
      change; // member?????????????????????????????????????´????change????????£????????????????????????????´????????????°

  while (1) {

    cin >> member; //????????????????????????????????\\???
    if (member == "-")
      break;                  // ???????????????????????????????????¶
    cin >> count_change;      //?????£????????????????????°?????\\???
    rep(i, 0, count_change) { //???????????????
      cin >> b[i];            //?????£????????????????????°?????\\???
      change = member.substr(
          0,
          b[i]); //???????????????????????????????????????????????\\?????????????????£????????????????????°?????§???????????????change???????´?
      member += change; // member????????????????????????????????£?????????
      member = member.substr(
          b[i],
          member[i]); //????????????????????????????????????member???????´?
    }
    cout << member << endl; //??¨???
  }

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

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

string shuffle(string str, int h) {
  string head = str.substr(0, h);
  string tail = str.substr(h, str.size() - h);
  return tail + head;
}

int main() {
  string cards;
  int m, h;

  while (1) {
    cin >> cards;
    if (cards == "-")
      break;

    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      cards = shuffle(cards, h);
    }
    cout << cards << endl;
  }

  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 4) > this->size() (which is 1)


Fixed submission:

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

string shuffle(string str, int h) {
  string head = str.substr(0, h);
  string tail = str.substr(h, str.size() - h);
  return tail + head;
}

int main() {
  string cards;
  int m, h;

  while (1) {
    cin >> cards;
    if (cards == "_")
      break;

    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      cards = shuffle(cards, h);
    }
    cout << cards << endl;
  }

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

#include <stdio.h>
int main() {
  char card[20001];
  int maze, i, mvc, j, fc, cm, end = 0;
  while (1) {
    cm = 0;
    while (1) {
      scanf("%c", &card[cm]);
      if (card[0] == '\\n') {
        continue;
      }
      if (card[0] == '-') {
        goto theend;
      }
      if (card[cm] == '\\n' && cm != 0) {
        break;
      }
      cm++;
    }
    // printf("%s",card);//
    scanf("%d", &maze);
    fc = 0;
    for (i = 0; i < maze; i++) {
      scanf("%d", &mvc);
      for (j = 0; j < mvc; j++) {
        card[fc + cm] = card[fc];
        fc++;
      }
    }
    for (i = 0; i < cm; i++) {
      printf("%c", card[fc]);
      fc++;
    }
    printf("%c", '\\n');
  }
theend:
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  char card[20001];
  int maze, i, mvc, j, fc, cm, end = 0;
  while (1) {
    cm = 0;
    while (1) {
      scanf("%c", &card[cm]);
      if (card[0] == '-') {
        end++;
      }
      if (card[cm] == '\\n') {
        break;
      }
      cm++;
    }
    if (end == 1) {
      break;
    }
    scanf("%d", &maze);
    fc = 0;
    for (i = 0; i < maze; i++) {
      scanf("%d", &mvc);
      for (j = 0; j < mvc; j++) {
        card[fc + cm] = card[fc];
        // printf("%c",card[4]);//
        // printf("%d",fc);//
        fc++;
        // printf("%d",fc);//
        // printf("hoge");//
        // printf("%s\\n",card);//
      }
    }
    for (i = 0; i < cm; i++) {
      printf("%c", card[fc]);
      fc++;
    }
    printf("%c", '\\n');
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string S;
  int m, h;
  while (1) {
    cin >> S;
    if (S == "-")
      break;
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      S = S.substr(h) + S.substr(0, h);
    }
    cout << S << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string W, S;
  int cnt = 0;
  cin >> W;
  for (int i = 0; i < W.size(); i++)
    W[i] = tolower(W[i]);
  while (1) {
    cin >> S;
    if (S == "END_OF_TEXT")
      break;
    for (int i = 0; i < S.size(); i++)
      S[i] = tolower(S[i]);
    if (S == W)
      cnt++;
  }
  cout << cnt << endl;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  int h[100], m, n;

  string a, left, right;

  for (int A = 0; A < 50; A++) {
    cin >> a;

    if (a == "-") {
      break;
    }

    cin >> m;

    for (int B = 0; B < m; B++) {
      cin >> h[B];

      n = 0;
      n = a.size();

      left = a.substr(0, h[B]);
      right = a.substr(h[B], n);

      a = right + left;
    }
    cout << a << endl;
  }
}

Error: WA

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  int h[100], m;

  string a, left, right, P;

  for (int A = 0; A < 50; A++) {
    cin >> a;

    if (a == "-") {
      break;
    }

    cin >> m;

    for (int B = 0; B < m; B++) {
      cin >> h[B];

      left = a.substr(0, h[B]);
      right = a.substr(h[B + 1], h[m]);

      P = right + left;
    }
  }
  cout << P << endl;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  string str;
  int count;
  int h;

  while (true) {
    cin >> str;

    if (str == "-")
      break;

    cin >> count;

    for (int i = 0; i < count; i++) {
      cin >> h;

      str.append(str.begin(), str.begin() + h);
      str.erase(0, h);
    }

    cout << str << "\\n";
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main(void) {
  string str;
  int count;
  char ch;

  while (true) {
    cin >> str;

    if (str == "-")
      break;

    cin >> count;

    for (int i = 0; i < count; i++) {
      cin >> ch;

      str.append(str.begin(), str.begin() + (ch - '0'));
      str.erase(0, (ch - '0'));
    }

    cout << str << "\\n";
  }

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

#include <stdio.h>
int main() {
  int m, now, temp, tot;
  char a[1001], b[1001];
  for (int i = 0; i < 1001; i++)
    b[i] = a[i] = '\\0';
  while (1) {
    scanf("%s", a);
    if (a[0] == '-')
      return 0;
    now = 0;
    while (a[now] != '\\0')
      now++;
    scanf("%d", &m);
    tot = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d", &temp);
      tot += temp;
    }
    temp = tot % now;
    for (int j = 0; j < temp; j++)
      b[j] = a[j];
    for (int j = temp; j < now; j++) {
      a[j - temp] = a[j];
    }
    for (int j = 0; j < temp; j++) {
      a[now - temp + j] = b[j];
    }

    for (int i = 0; i < now; i++) {
      printf("%c", a[i]);
      b[i] = a[i] = '\\0';
    }
    printf("\\n");
  }
}

Error: 0

Fixed submission:

#include <stdio.h>
int main() {
  int m, now, temp, tot;
  char a[101], b[101];
  for (int i = 0; i < 101; i++)
    b[i] = a[i] = '\\0';
  while (1) {
    scanf("%s", a);
    if (a[0] == '-')
      return 0;
    now = 0;
    while (a[now] != '\\0')
      now++;
    scanf("%d", &m);
    tot = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d", &temp);
      tot += temp;
    }
    temp = tot % now;
    for (int j = 0; j < temp; j++)
      b[j] = a[j];
    for (int j = temp; j < now; j++) {
      a[j - temp] = a[j];
    }
    for (int j = 0; j < temp; j++) {
      a[now - temp + j] = b[j];
    }

    for (int i = 0; i < now; i++) {
      printf("%c", a[i]);
      b[i] = a[i] = '\\0';
    }
    printf("\\n");
  }
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  while (1) {
    string Previous;
    cin >> Previous;
    if (Previous == "-")
      break;

    int m;
    cin >> m;
    vector<int> h;
    for (int i = 0; i < m; i++) {
      int g;
      cin >> g;
      h.push_back(g);
    }

    char After[200];
    int n = Previous.size();
    for (int i = 0; i < m; i++) {
      for (int j = h[i]; j < n; j++)
        After[j - h[i]] = Previous[j];
      for (int j = 0; j < h[i]; j++)
        After[n - h[i] + j] = Previous[j];
      for (int j = 0; j < n; j++)
        Previous[j] = After[j];
    }

    for (int i = 0; i < n; i++)
      cout << After[i];
    cout << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  vector<char> Previous;
  char Letter;
  while (cin >> Letter) {
    if (Letter == '-')
      break;
    Previous.push_back(Letter);
  }
  char After[200];
  int n = Previous.size();
  int m;
  cin >> m;
  int h[100];
  for (int i = 0; i < m; i++)
    cin >> h[i];

  for (int i = 0; i < m; i++) {
    for (int j = h[i]; j < n; j++)
      After[j - h[i]] = Previous[j];
    for (int j = 0; j < h[i]; j++)
      After[n - h[i] + j] = Previous[j];
    for (int j = 0; j < n; j++)
      Previous[j] = After[j];
  }
  for (int i = 0; i < n; i++)
    cout << After[i];
  cout << endl;
  //	system("pause");
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string ch, x;
  int kai, shu;
  while (1) {
    cin >> ch;
    x = ch;
    if (ch == "-")
      break;
    cin >> kai;
    for (int i = 0; i < kai; i++) {
      cin >> shu;
      for (int j = 0; j < shu; j++) {
        x[j] = ch[j];
      }
      // cout << ch << endl;
      for (int j = 0; j < ch.size() - shu; j++) {
        ch[j] = ch[j + shu];
      }
      for (int j = 0; j < shu; j++) {
        ch[(ch.size() - shu) + j] = x[j];
      }
      // cout << ch << endl;
    }
    cout << ch << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  string ch, x;
  int kai, shu;
  while (1) {
    cin >> ch;
    x = ch;
    if (ch == "_")
      break;
    cin >> kai;
    for (int i = 0; i < kai; i++) {
      cin >> shu;
      for (int j = 0; j < shu; j++) {
        x[j] = ch[j];
      }
      // cout << ch << endl;
      for (int j = 0; j < ch.size() - shu; j++) {
        ch[j] = ch[j + shu];
      }
      for (int j = 0; j < shu; j++) {
        ch[(ch.size() - shu) + j] = x[j];
      }
      // cout << ch << endl;
    }
    cout << ch << endl;
  }

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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> P;
typedef vector<P> vp;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FORR(i, n, m) for (int i = n - 1; i >= m; i--)
#define all(in) in.begin(), in.end()
#define ALL(in, K) in, in + K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 3.14159265358979323846

int main() {
  REP(k, 10) {
    string s;
    cin >> s;
    if (s == "-") {
      return 0;
    }
    ll m, j = 0;
    cin >> m;
    REP(i, m) {
      ll h;
      cin >> h;
      ll limit = j;
      FOR(i, j, h + limit) {
        s += s[j];
        s[j] = '|';
        j = i + 1;
      }
    }
    REP(i, s.size()) {
      if (s[i] != '|') {
        cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> P;
typedef vector<P> vp;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FORR(i, n, m) for (int i = n - 1; i >= m; i--)
#define all(in) in.begin(), in.end()
#define ALL(in, K) in, in + K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 3.14159265358979323846

int sub() {
  string s;
  cin >> s;
  if (s[0] == '\\0') {
    return 0;
  }
  ll m, j = 0;
  cin >> m;
  REP(i, m) {
    ll h;
    cin >> h;
    ll limit = j;
    FOR(i, j, h + limit) {
      s += s[j];
      s[j] = '|';
      j = i + 1;
    }
  }
  REP(i, s.size()) {
    if (s[i] != '|') {
      cout << s[i];
    }
  }
  cout << endl;
}

int main() {
  while (1) {
    sub();
  }
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  string card, card1;
  int m, h;

  while (1) {
    int i = 0;
    cin >> card >> m;
    if (card == "-")
      break;

    while (i < m) {
      cin >> h;
      i++;
      card1 = card.substr(0, h);
      card.erase(0, h);
      card += card1;
    }
    cout << card << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string card, card1;
  int m, h;
  cin >> card >> m;

  while (1) {
    cin >> m;
    if (m == '-')
      break;
    card1 = card.substr(0, m);
    card.erase(0, m);
    card += card1;
  }

  cout << card << endl;
  return 0;
}