alexjercan/bugnet huggingface dataset:
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str1, first, last, mix;
  int n, h, a;
  while (true) {
    cin >> str1;
    if (str1 == "-")
      break;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> h;
      first = str1.substr(0, h);
      last = str1.substr(h, a - h);
      mix = last + first;
      str1 = mix;
    }
    cout << mix << endl;
  }
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str1, str2;
  int n, h, a;
  while (true) {
    cin >> str1;
    if (str1 == "-")
      break;
    str2 = "";
    a = str1.size();
    for (int i = 0; i < a; i++) {
      str2 += str1[i];
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> h;
      str1 + str2.substr(0, h);
      str1.erase(str1.begin(), str1.begin() + h);
    }
    cout << str1 << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  int m, h;
  while (1) {
    char tmp[400];
    string str;
    cin >> str;
    if (str == "-") {
      break;
    }
    for (int i = 0; i < str.size(); i++) {
      tmp[i] = str[i];
      tmp[str.size() + i] = str[i];
    }
    cin >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
      cin >> h;
      sum += h;
    }
    int count = 0;
    for (int i = sum % str.size();; i++) {
      cout << tmp[i];
      count++;
      if (count == str.size()) {
        break;
      }
    }
    cout << endl;
  }
  return 0;
}


Error: -8

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int m, h;
  while (1) {
    char tmp[400];
    string str;
    cin >> str;
    if (str == "~") {
      break;
    }
    for (int i = 0; i < str.size(); i++) {
      tmp[i] = str[i];
      tmp[str.size() + i] = str[i];
    }
    cin >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
      cin >> h;
      sum += h;
    }
    int count = 0;
    for (int i = sum % str.size();; i++) {
      cout << tmp[i];
      count++;
      if (count == str.size()) {
        break;
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string word;
  int m, h;
  while (true) {
    cin >> word;
    if (word == "-")
      break;

    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      word += word.substr(0, h);
      word.erase(0, h);
    }
    cout << word << endl;
  }
}


Error: -11

Fixed submission:

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

  while (true) {
    cin >> word;
    if (word == "-")
      break;

    cin >> m;
    for (int i = 0; i < m; i++) {
      scanf("%d", h);
      word += word.substr(0, h);
      word.erase(0, h);
    }
    cout << word << endl;
  }
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define eps LDBL_EPSILON
#define int long long
#define moder 1000000007
#define P std::pair<int, int>
using namespace std;

string s;
int m;
signed main() {
  while (true) {
    cin >> s;
    if (s == "-")
      break;
    cin >> m;
    rep(i, m) {
      int h;
      cin >> h;
      s = s.substr(h, s.size() - h) + s.substr(0, h);
    }
    cout << s << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
// Library
/*Union-Find木
int par[1000010], rankh[1000010];
void init(int n) {
        for (int i = 0; i <= n; i++) {
                par[i] = i;
                rankh[i] = 0;
        }
}
int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
}
void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rankh[x] < rankh[y])par[x] = y;
        else {
                par[y] = x;
                if (rankh[x] == rankh[y])rankh[x]++;
        }
}
bool same(int x, int y) {
        return find(x) == find(y);
}
template<typename t>
t GCD(t a, t b) {
        while (max(a, b) % min(a, b)) {
                if (a > b)a %= b;
                else b %= a;
        }
        return min(a, b);
}
Union-Find木end*/
// Library end
int main() {
  string s;
  int m, h;
  cin >> s >> m;
  while (s != "-") {
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      s = s.substr(s.size() - h, h) + s.substr(0, s.size() - h);
    }
    cout << s << endl;
    cin >> s;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char s[500];
  char sub1[200];
  int m, h;
  int i, j;
  while (1) {
    for (int i = 0; i < 500; i++) {
      s[i] = 0;
    }
    scanf("%s", s);
    int len = strlen(s);
    if (strcmp(s, "-") == 0) {
      break;
    }
    scanf("%d", &m);
    for (int x = 0; x < m; x++) {
      for (int j = 0; j < 200; j++) {
        sub1[j] = 0;
      }
      scanf("%d", &h);
      for (i = 0; i < h; i++) {
        sub1[i] = s[i];
      }
      for (i = 0; i < len - h; i++) {
        s[i] = s[h + i];
      }
      s[len - h] = '\\0';
      strcat(s, sub1);
    }
    printf("%s\\n", s);
  }
}


Error: 0

Fixed submission:

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

int main() {
  char s[201];
  char sub1[101];
  int m, h;
  int i, j;
  while (1) {
    for (int i = 0; i < 201; i++) {
      s[i] = 0;
    }
    scanf("%s", s);
    int len = strlen(s);
    if (strcmp(s, "-") == 0) {
      break;
    }
    scanf("%d", &m);
    for (int x = 0; x < m; x++) {
      for (int j = 0; j < 101; j++) {
        sub1[j] = 0;
      }
      scanf("%d", &h);
      for (i = 0; i < h; i++) {
        sub1[i] = s[i];
      }
      for (i = 0; i < len - h; i++) {
        s[i] = s[h + i];
      }
      s[len - h] = '\\0';
      strcat(s, sub1);
    }
    printf("%s\\n", s);
  }
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {

  string data, data_copy;
  int m, h;

  for (;;) {
    cin >> data;
    if (data == "-")
      break;
    data_copy = data;
    cin >> m;

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

      for (int j = 0; j < data.length(); j++) {
        if ((j + 1 - h) <= 0) {
          data[data.length() - h + j] = data_copy[j];

        } else {
          data[j - h] = data_copy[j];
        }

      } // data?????¨????????????
      for (int j = 0; j < data.length(); j++) {
        data_copy[j] = data[j];
      }

    } //?????£??????????????°???????????????
    cout << data << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {

  string data, data_copy;
  int m, h;

  for (;;) {
    cin >> data;
    if (data == "_")
      break;
    data_copy = data;
    cin >> m;

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

      for (int j = 0; j < data.length(); j++) {
        if ((j + 1 - h) <= 0) {
          data[data.length() - h + j] = data_copy[j];

        } else {
          data[j - h] = data_copy[j];
        }

      } // data?????¨????????????
      for (int j = 0; j < data.length(); j++) {
        data_copy[j] = data[j];
      }

    } //?????£??????????????°???????????????
    cout << data << endl;
  }

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

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

int main() {
  string str;
  string copy[201];
  int m;
  int h;

  while (cin >> str) {
    if (str == "-")
      break;
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      string cat = str.substr(0, h);
      str.erase(0, h);
      str += cat;
    }
    cout << str << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  string str;
  string copy[201];
  int m;
  int h;

  cin >> str;
  cin >> m;
  while (1) {
    if (str == "-")
      break;
    for (int i = 0; i < m; i++) {
      cin >> h;
    }
    string cat = str.substr(0, h);
    str.erase(0, h);
    str += cat;
  }
  cout << str << endl;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;
  int m, h;

  while (1) {

    cin >> str >> m;
    if (str == "-")
      break;
    for (int i = 0; i < m; i++) {
      cin >> h;
      str = str.substr(h, str.size() - h) + str.substr(0, h);
    }
    cout << str << endl;
  }
  return 0;
}


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


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;
  int m, h;

  while (1) {

    cin >> str >> m;
    if (str == "-")
      break;
    for (int i = 0; i < m; i++) {
      cin >> h;
      str = str.substr(h + 1, str.size() - h) + str.substr(0, h);
    }
    cout << str << 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: Runtime Error

#include <iostream>
#include <string>

int main() {
  std::string str;

  int n, h;
  while (1) {
    std::cin >> str;
    if (str == "-")
      break;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
      std::cin >> h;
      str = str.substr(h, str.size() - h) + str.substr(0, h);
    }
    std::cout << str << std::endl;
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  std::string str;
  int n;

  while (1) {
    std::cin >> str;
    if (str[0] == '-')
      break;
    if (isdigit(str[0]))
      n = std::atoi(str.c_str());
    std::string sub = str.substr(0, n);
    for (int i = 0; sub[i] != '\\0'; ++i) {
      str[i] = str[n + i];
      str[n + i] = sub[i];
    }
    std::cout << str << std::endl;
  }

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

#include <iostream>
#include <string>

using namespace std;

int main() {
  string ss, left, right, end;
  int times, in;

  while (true) {
    cin >> ss;
    if (ss == "-") {
      break;
    }

    cin >> times;
    for (int i = 0; i < times; i++) {
      cin >> in;

      right = ss.substr(0, in);
      left = ss.substr(in, ss.size() - 1);

      ss = left + right;
    }

    cout << ss << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string ss, left, right, end;
  int times, in;
  cin >> ss >> times;

  while (true) {
    if (ss == "-") {
      break;
    }

    cin >> in;

    for (int i = 0; i < times; i++) {
      for (int j = 1; j <= in; j++) {
        right += ss[in + j];
      }
      for (int k = 0; k < ss.size() - in; k++) {
        left += ss[k];
      }
    }

    cout << left + right << endl;
    cin >> ss;
  }

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

#include <stdio.h>

int main() {
  char cards[200];
  char newCards[200];
  int m, cardsLen;
  // int h[100];
  int h;

  while (true) {
    scanf("%s", cards);
    if (cards[0] == '-')
      break;

    cardsLen = 0;
    while (cards[cardsLen] != '\\0')
      cardsLen++;

    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      // scanf("%d",&h[i]);
      scanf("%d", &h);

      for (int j = 0; j < cardsLen; j++) {
        newCards[j] = cards[(j + h) % cardsLen];
      }

      for (int j = 0; j < cardsLen; j++) {
        cards[j] = newCards[j];
      }
    }

    printf("%s\\n", cards);
  }

length:
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char cards[200];
  char newCards[200];
  int m, cardsLen;
  // int h[100];
  int h;

  while (true) {
    scanf("%s", cards);
    if (cards == "-")
      goto length;

    cardsLen = 0;
    while (cards[cardsLen] != '\\0')
      cardsLen++;

    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      // scanf("%d",&h[i]);
      scanf("%d", &h);

      for (int j = 0; j < cardsLen; j++) {
        newCards[j] = cards[(j + h) % cardsLen];
      }

      for (int j = 0; j < cardsLen; j++) {
        cards[j] = newCards[j];
      }
    }

    printf("%s\\n", cards);
  }

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

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

void calc(char *cs) {
  std::queue<char> qu;
  int size;
  for (int i = 0; cs[i] != '\\0'; i++) {
    qu.push(cs[i]);
  }
  int n, h;
  scanf("%d", &n);
  size = qu.size();
  while (n--) {
    scanf("%d", &h);
    for (int i = 0; i < h; i++) {
      int a = qu.front();
      qu.pop();
      qu.push(a);
    }
  }
  while (qu.empty() == false) {
    printf("%c", qu.front());
    qu.pop();
  }
  printf("\\n");
}

int main() {
  // your code goes here
  char cs[201];
  while (1) {
    scanf("%s", cs);
    if (cs[0] == '-')
      break;
    calc(cs);
  }
  return 0;
}


Error: MLE

Fixed submission:

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

void shuffle(string s, int *index) {
  char array[s.size()];
  strcpy(array, s.c_str());

  queue<char> card;
  for (char c : array)
    card.push(c);

  for (int i = 0; i < sizeof(index); i++) {
    for (int j = 0; j < *index; j++) {
      char temp = card.front();
      card.pop();
      card.push(temp);
    }
  }

  while (!card.empty()) {
    cout << card.front();
    card.pop();
  }
  cout << endl;
}
int main() {
  while (1) {
    string s;
    int m;
    cin >> s >> m;
    if (s == "-")
      break;
    int index[m];
    for (int i = 0; i < m; i++)
      cin >> index[i];
    shuffle(s, index);
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

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

string suffle(string s, int len, int num);

int main() {
  int m;
  string s;
  string haki;
  int count = 0;
  int h[100] = {0};
  bool q = false;
  int l = 0;
  while (1) {
    getline(cin, s);
    if (s == "-")
      break;
    cin >> m;
    getline(cin, haki);
    int s_num = s.length();
    for (int i = 0; i < m; i++) {
      cin >> h[i];
      getline(cin, haki);
    }
    for (int i = 0; i < m; i++) {
      s = suffle(s, s_num, h[i]);
    }
    cout << s << endl;
  }
  return 0;
}
string suffle(string s, int len, int num) {
  char k[200] = {""};
  for (int i = 0; i < num; i++) {
    k[i] = s[i];
  }
  for (int i = 0; i < len - num; i++) {
    s[i] = s[i + num];
  }
  for (int i = len - num; i < len; i++) {
    s[i] = k[i - len + num];
  }
  return s;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

string suffle(string s, int len, int num);

int main() {
  int m;
  int count = 0;
  string s;
  int h[100] = {0};
  while (1) {
    getline(cin, s);
    if (s == "-")
      break;
    cin >> m;
    int s_num = s.length();
    for (int i = 0; i < m; i++) {
      cin >> h[i];
    }
    for (int i = 0; i < m; i++) {
      s = suffle(s, s_num, h[i]);
    }
    cout << s << endl;
  }
}

string suffle(string s, int len, int num) {
  char k[100] = {""};
  for (int i = 0; i < num; i++) {
    k[i] = s[i];
  }
  for (int i = 0; i < len - num; i++) {
    s[i] = s[i + num];
  }
  for (int i = len - num; i < len; i++) {
    s[i] = k[i - len + num];
  }
  return s;
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

int main() {
  std::string str;
  int m, h;

  while (true) {
    std::cin >> str;
    if (str == "-")
      break;
    std::cin >> m;

    for (int i = 0; i < m; i++) {
      std::cin >> h;
      str = str.substr(h) + str.substr(0, h);
    }
    std::cout << str << std::endl;
  }
}


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


Fixed submission:

#include <iostream>

int main() {
  std::string str;
  int m, h;

  while (true) {
    std::cin >> str;
    if (str == "-")
      break;
    std::cin >> m;

    for (int i = 0; i < m; i++) {
      std::cin >> h;
      str = str.substr(h) + str.erase(h);
    }
    std::cout << str << std::endl;
  }
}
Problem p02420 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
#define rep(i, a) for (int i = 0; i < a; ++i)

int main(void) {
  char s[250], t[250];
  int m, i, j, n, a;
  while (1) {
    scanf("%s", s);
    n = strlen(s);
    if (n == 1 && s[0] == '-')
      break;
    scanf("%d", &m);
    rep(i, m) {
      scanf("%d", &a);
      rep(j, a) t[j] = s[j];
      t[a] = 0;
      rep(j, (n - a)) s[j] = s[j + a];
      rep(j, a) s[j + n - a] = t[j];
    }
    printf("%s\\n", s);
  }
  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>
#include <string.h>
#define rep(i, a) for (int i = 0; i < a; ++i)

int main(void) {
  char s[250], t[250];
  int m, i, j, n, a;
  while (1) {
    scanf("%s", s);
    n = strlen(s);
    if (n == 1 && s[0] == '-')
      break;
    scanf("%d", &m);
    rep(i, m) {
      scanf("%d", a);
      rep(j, a) t[j] = s[j];
      t[a] = 0;
      rep(j, (n - a)) s[j] = s[j + a];
      rep(j, a) s[j + n - a] = t[j];
    }
    printf("%s\\n", s);
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string str;
  char work;
  int h, n;

  while (true) {
    cin >> str;

    if (str == "-")
      break;

    cin >> n;

    for (int l = 0; l < n; ++l) {
      cin >> h;

      for (int i = 0; i < h; ++i) {
        work = str[0];
        for (int k = 0; k < (int)str.size() - 1; ++k) {
          str[k] = str[k + 1];
        }
        str[(int)str.size() - 1] = work;
      }
    }

    cout << str << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int change(string s) {
  int res = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    char ch = s[i];
    res = res * 10 + (ch - '0');
  }
  return res;
}

int main() {
  string str, result;
  char work;
  int h, n, counter = 1;

  while (true) {
    cin >> str;

    if (str == "-")
      break;

    cin >> n;

    for (int l = 0; l < n; ++l) {
      cin >> h;

      for (int i = 0; i < h; ++i) {
        work = str[0];
        for (int k = 0; k < (int)str.size() - 1; ++i) {
          str[k] = str[k + 1];

          if (k == (int)str.size() - 1)
            str[k + 1] = work;
        }
      }
    }
    cout << str << endl;
  }

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

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

int main() {
  string card;
  string right;
  string left;
  int n;
  int m;

  while (cin >> card, card != "-") {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> m;
      right = card.substr(0, m);
      left = card.substr(m);
      card = left + right;
    }
    cout << card << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string card;
  string right;
  string left;
  int n;
  int m;

  while (cin >> card, card != "-") {
    cin >> m;
    for (int i = 0; i < n; i++) {
      cin >> m;
      right = card.substr(0, m);
      left = card.substr(m);
      card = left + right;
    }
    cout << card << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int i, j, m, h, sc;
  char tmp, dum;
  while (1) {
    queue<char> c;
    while (1) {
      cin.get(tmp);
      if (tmp == '-')
        return 0;
      else if (tmp == '\\n')
        break;
      c.push(tmp);
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> h;
      for (j = 0; j < h; j++) {
        c.push(c.front());
        c.pop();
      }
    }
    sc = c.size();
    for (i = 0; i < sc; i++) {
      cout << c.front();
      c.pop();
    }
    cout << endl;
    cin.get(dum);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int i, j, m, h, sc;
  char tmp;
  while (1) {
    queue<char> c;
    while (1) {
      cin.get(tmp);
      if (tmp == '-')
        return 0;
      else if (tmp == '\\n')
        break;
      c.push(tmp);
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> h;
      for (j = 0; j < h; j++) {
        c.push(c.front());
        c.pop();
      }
    }
    sc = c.size();
    for (i = 0; i < sc; i++) {
      cout << c.front();
      c.pop();
    }
    cout << endl;
  }
  return 0;
}
Problem p02420 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int main() {
  string s;
  while (cin >> s && s != "-") {
    int m, x = 0;
    cin >> m;
    while (m--) {
      int a;
      cin >> a;
      x += a;
    }
    REP(i, s.length()) { cout << s[(i + x) % s.length()]; }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int main() {
  string s;
  while (cin >> s && s != "-") {
    int m, x = 0;
    while (m--) {
      int a;
      cin >> a;
      x += a;
    }
    REP(i, s.length()) { cout << s[(i + x) % s.length()]; }
    cout << endl;
  }
  return 0;
}