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

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int n;
string s;
int calc(int l, int r) {
  int d = 0, c = 0, w = l;
  for (int i = l; i < r; i++)
    c += (s[i] == '[' || s[i] == ']' ? 1 : 0);
  if (c == 0)
    return stoi(s.substr(l, r)) / 2 + 1;
  vector<int> v;
  for (int i = l; i < r; i++) {
    if (s[i] == '[')
      d++;
    if (s[i] == ']')
      d--;
    if (d == 0)
      v.push_back(calc(w + 1, i)), w = i + 1;
  }
  sort(v.begin(), v.end());
  int ret = 0;
  for (int i = 0; i <= v.size() / 2; i++)
    ret += v[i];
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    cout << calc(0, s.size()) << endl;
  }
  return 0;
}

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


Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int n;
string s;
int calc(int l, int r) {
  int d = 0, c = 0, w = l;
  for (int i = l; i < r; i++)
    c += (s[i] == '[' || s[i] == ']' ? 1 : 0);
  if (c == 0)
    return stoi(s.substr(l + 1, r - l - 2));
  vector<int> v;
  for (int i = l; i < r; i++) {
    if (s[i] == '[')
      d++;
    if (s[i] == ']')
      d--;
    if (d == 0)
      v.push_back(calc(w + 1, i)), w = i + 1;
  }
  sort(v.begin(), v.end());
  int ret = 0;
  for (int i = 0; i <= v.size() / 2; i++)
    ret += v[i];
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    cout << calc(0, s.size()) << endl;
  }
  return 0;
}
Problem p00769 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int a[100][1000], n, cnt[100], u, sum, chain;
string S, T;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S;
    u = 0;
    sum = 0;
    for (int i = 0; i < 10; i++) {
      cnt[i] = 0;
    }
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == '[') {
        u++;
        T = "";
        chain = 0;
      } else if (S[i] == ']') {
        if (T != "") {
          cnt[u] = 0;
          u--;
          a[u][cnt[u]] = stoi(T);
          cnt[u]++;
          T = "";
        } else {
          chain++;
          sum = 0;
          sort(a[u], a[u] + cnt[u]);
          if (chain == 1) {
            for (int i = 0; i < cnt[u] / 2 + 1; i++) {
              sum += a[u][i] / 2 + 1;
            }
            cnt[u] = 0;
            u--;
            a[u][cnt[u]] = sum;
          } else {
            sum = 0;
            for (int i = 0; i < cnt[u] / 2 + 1; i++) {
              sum += a[u][i];
            }
            cnt[u] = 0;
            u--;
            a[u][cnt[u]] = sum;
          }
          cnt[u]++;
        }
      } else {
        T += S[i];
        chain = 0;
      }
    }
    u = 0;
    cout << sum << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int a[10][100], n, cnt[10], u, sum, chain;
string S, T;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S;
    u = 0;
    sum = 0;
    for (int i = 0; i < 10; i++) {
      cnt[i] = 0;
    }
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == '[') {
        u++;
        T = "";
        chain = 0;
      } else if (S[i] == ']') {
        if (T != "") {
          cnt[u] = 0;
          u--;
          a[u][cnt[u]] = stoi(T);
          cnt[u]++;
          T = "";
        } else {
          chain++;
          sum = 0;
          sort(a[u], a[u] + cnt[u]);
          if (chain == 1) {
            for (int i = 0; i < cnt[u] / 2 + 1; i++) {
              sum += a[u][i] / 2 + 1;
            }
            cnt[u] = 0;
            u--;
            a[u][cnt[u]] = sum;
          } else {
            sum = 0;
            for (int i = 0; i < cnt[u] / 2 + 1; i++) {
              sum += a[u][i];
            }
            cnt[u] = 0;
            u--;
            a[u][cnt[u]] = sum;
          }
          cnt[u]++;
        }
      } else {
        T += S[i];
        chain = 0;
      }
    }
    u = 0;
    cout << sum << endl;
  }
}
Problem p00769 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>

int func(std::string str, int &i) {
  std::vector<int> data;
  i++;
  if (str[i] == '[') {
    do {
      data.push_back(func(str, i));
    } while (str[i] != ']');
    ++i;
  } else {
    int j = i;
    for (; str[j] != ']'; j++)
      ;
    j--;
    std::string num = str.substr(i, j - i + 1);
    // std::cout << num << std::endl;
    i = j + 2;
    return std::stoi(num) / 2 + 1;
  }

  //	std::vector<int> perm(data.size(), 0);
  //	for ( int i = 0; i < data.size() / 2 + 1; ++i ) {
  //		perm[i] = 1;
  //	}
  //
  //	int min = 0xfffffff;;
  //	do{
  //		int a = 0;
  //		for ( int i = 0; i < data.size(); ++i ) {
  //			if ( perm[i] == 1 ) {
  //				a += data[i];
  //			}
  //		}
  //		if ( min > a )  min = a;
  //	} while(std::prev_permutation(perm.begin(), perm.end()));
  int min = 0;
  std::sort(data.begin(), data.end());
  for (int i = 0; i < data.size() / 2 + 1; ++i) {
    min += data[i];
  }

  return min;
}

int main() {
  int N;

  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::string str;
    // std::getline(std::cin, str);
    std::cin >> str;

    int j = 0;
    std::cout << func(str, j) << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

int func(std::string str, int &i) {
  std::vector<int> data;
  i++;
  if (str[i] == '[') {
    do {
      data.push_back(func(str, i));
    } while (str[i] != ']');
    ++i;
  } else {
    int j = i;
    for (; str[j] != ']'; j++)
      ;
    j--;
    std::string num = str.substr(i, j - i + 1);
    // std::cout << num << std::endl;
    i = j + 2;
    return std::stoi(num) / 2 + 1;
  }

  std::vector<int> perm(data.size(), 0);
  for (int i = 0; i < data.size() / 2 + 1; ++i) {
    perm[i] = 1;
  }

  int min = 0xfffffff;
  ;
  do {
    int a = 0;
    for (int i = 0; i < data.size(); ++i) {
      if (perm[i] == 1) {
        a += data[i];
        // std::cout << data[i] << " ";
      }
    }
    // std::cout << std::endl;
    if (min > a)
      min = a;
  } while (std::prev_permutation(perm.begin(), perm.end()));

  return min;
}

int main() {
  int N;

  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::string str;
    // std::getline(std::cin, str);
    std::cin >> str;

    int j = 0;
    std::cout << func(str, j) << std::endl;
  }
  return 0;
}
Problem p00769 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int block(string &s, int &i);
int number(string &s, int &i);

int block(string &s, int &i) {
  i++;
  if (s[i] == '[') {
    vector<int> v;
    while (s[i] == '[') {
      v.push_back(block(s, i));
      i++;
    }
    sort(v.begin(), v.end());
    return accumulate(v.begin(), v.begin() + v.size() / 2 + 1, 0);
  } else {
    return number(s, i);
  }
}

int number(string &s, int &i) {
  int n = s[i] - '0';
  i++;
  while (isdigit(s[i])) {
    n *= 10;
    n += s[i] - '0';
    i++;
  }
  return n / 2 + 1;
}

int main() {
  int n;
  cin >> n;
  for (int j = 0; j < n; j++) {
    string s;
    cin >> s;
    int i = 0;
    cout << block(s, i) << endl;
  }
}

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


Fixed submission:

#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int block(string &s, int &i);
int number(string &s, int &i);

int block(string &s, int &i) {
  i++;
  if (s[i] == '[') {
    vector<int> v;
    while (s[i] == '[') {
      v.push_back(block(s, i));
      i++;
    }
    sort(v.begin(), v.end());
    return accumulate(v.begin(), v.begin() + v.size() / 2, 0);
  } else {
    return number(s, i);
  }
}

int number(string &s, int &i) {
  string n = "";
  n += s[i];
  i++;
  while (isdigit(s[i]))
    n += s[i];
  return atoi(s.c_str()) / 2 + 1;
}

int main() {
  int n;
  cin >> n;
  for (int j = 0; j < n; j++) {
    string s;
    cin >> s;
    int i = 0;
    cout << block(s, i) << endl;
  }
}
Problem p00769 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int INF = 1 << 30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
#define MOD 1000000007
typedef pair<int, int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
string s;
int INDEX;
int expr() {
  INDEX++;
  if (isdigit(s[INDEX])) {
    int num = s[INDEX] - '0';
    INDEX++;
    while (isdigit(s[INDEX])) {
      num = num * 10 + s[INDEX] - '0';
      INDEX++;
    }
    INDEX++;
    return num / 2 + 1;
  }
  vi p;
  while (s[INDEX] != ']') {
    p.PB(expr());
  }
  INDEX++;
  sort(p.begin(), p.end());
  int tmp = 0;
  rep(i, p.size() / 2 + 1) { tmp += p[i]; }
  return tmp;
}
int main() {
  int N;
  cin >> N;
  while (N--) {
    INDEX = 0;
    cin >> s;
    cout << expr() << "\\n";
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int INF = 1 << 30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
#define MOD 1000000007
typedef pair<int, int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int depth;
int calc(vi a, int b) {
  int tmp = 0;
  sort(a.begin(), a.end());
  rep(i, a.size() / 2 + 1) { tmp += a[i] / b + 1; }
  return tmp;
}
int dfs(string str) {
  vi num;
// printf("**%d**\\n",depth);
label:;
  if (depth == str.size()) {
    /* printf("$");
     rep(i,num.size()){
         printf("%d ",num[i]);
     }
     puts("$");*/
    sort(num.begin(), num.end());
    int ret = 0;
    rep(i, num.size() / 2 + 1) { ret += num[i]; }
    return ret;
  }
  if (str[depth] == '[' && str[depth + 1] == '[') {
    depth++;
    int a = dfs(str);
    depth++;
    // printf("%d#%d#\\n",depth,a);
    num.PB(a);
    goto label;
  } else if (str[depth] == ']') {
    depth++;
    // return calc(num,1);
    goto label;
  } else if (str[depth] == '[') {
    int index = depth;
    while (str[index] == '[') {
      int ret = 0;
      string s = "";
      index++;
      if (isdigit(str[index])) {
        while (str[index] != ']') {
          s += str[index];
          index++;
        }
        index++;
        ret = atoi(s.c_str());
      }
      depth = index;
      num.PB(ret);
    }
    if (num.size() == 1)
      return num[0];
    return calc(num, 2);
  } else
    return calc(num, 1);
}
int main() {
  int N;
  scanf("%d", &N);
  while (N--) {
    string str;
    cin >> str;
    depth = 0;
    int ans = dfs(str);
    int cnt = 0;
    rep(i, str.size()) {
      if (str[i] != '[')
        break;
      cnt++;
    }
    cnt -= 2;
    printf("%d\\n", ans - cnt);
  }
  return 0;
}
Problem p00770 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
#define N 1000
#define N2 N *N
bool prime[N2 + 1];
int cave[N + 2][N + 2] = {};
pair<int, int> locate[N2 + 1];
int last[N + 2][N + 2];
int dp[N + 2][N + 2];
int m, n;

bool wall(int x, int y) { return x == 0 || y == 0 || x == N + 1 || y == N + 1; }

int rec(int x, int y) {
  if (wall(x, y) || cave[x][y] > m)
    return 0;
  if (dp[x][y])
    return dp[x][y];
  pair<int, int> child[3];
  rep(i, 3) child[i] =
      pair<int, int>(rec(x + i - 1, y - 1), last[x + i - 1][y - 1]);
  sort(child, child + 3);
  dp[x][y] = child[2].first;
  if (prime[cave[x][y]])
    dp[x][y]++;
  last[x][y] = child[2].second;
  if (last[x][y] == 0 && prime[cave[x][y]])
    last[x][y] = cave[x][y];
  return dp[x][y];
}

int main(void) {
  fill(prime, prime + N2 + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= N2; i++) {
    if (prime[i])
      for (int k = 2; i * k <= N2; k++)
        prime[i * k] = false;
  }

  int x = 1, y = N, d = 0;
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};
  for (int i = N2; i > 0; i--) {
    cave[x][y] = i;
    locate[i] = pair<int, int>(x, y);
    if (wall(x + dx[d], y + dy[d]) || cave[x + dx[d]][y + dy[d]])
      d = (d + 1) % 4;
    x += dx[d];
    y += dy[d];
  }

  while (cin >> m >> n, m | n) {
    rep1(x, N) rep1(y, N) dp[x][y] = last[x][y] = 0;
    int x = locate[n].first, y = locate[n].second;
    int cnt = rec(x, y);
    printf("%d %d\\n", cnt, last[x][y]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
#define N 1000
#define N2 N *N
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
bool prime[N2 + 1];
int cave[N][N] = {};
int last[N][N];
int dp[N][N];
int m, n;

bool wall(int x, int y) { return x < 0 || y < 0 || x >= N || y >= N; }

int rec(int x, int y) {
  if (wall(x, y) || cave[x][y] > m)
    return 0;
  if (dp[x][y])
    return dp[x][y];
  pair<int, int> child[3];
  rep(i, 3) child[i] =
      pair<int, int>(rec(x + i - 1, y - 1), last[x + i - 1][y - 1]);
  dp[x][y] = child[2].first;
  if (prime[cave[x][y]])
    dp[x][y]++;
  last[x][y] = child[2].second;
  if (last[x][y] == 0 && prime[cave[x][y]])
    last[x][y] = cave[x][y];
  return dp[x][y];
}

int main(void) {
  fill(prime, prime + N2 + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= N2; i++) {
    if (!prime[i])
      continue;
    for (int k = 2; i * k <= N2; k++)
      prime[i * k] = false;
  }

  int x = 0, y = N - 1, d = 0;
  pair<int, int> locate[N2 + 1];
  for (int i = N2; i > 0; i--) {
    cave[x][y] = i;
    locate[i] = pair<int, int>(x, y);
    if (wall(x + dx[d], y + dy[d]) || cave[x + dx[d]][y + dy[d]])
      d = (d + 1) % 4;
    x += dx[d];
    y += dy[d];
  }

  while (cin >> m >> n, m | n) {
    rep(x, N) rep(y, N) dp[x][y] = last[x][y] = 0;
    int x = locate[n].first, y = locate[n].second;
    cout << rec(x, y) << " " << last[x][y] << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  int a[1000];
  int i, j, k, n = 0, t;
  int m1, m2;
  int mm1, mm2;
  int temp;

  while (1) {
    int x, y, s; // x???????¨????,y??´??°???????¨????,z??????????¨?

    cin >> x >> y >> s;

    if (x == 0 && y == 0 && s == 0)
      break;

    int max = 0;

    for (m1 = 1; m1 < s; m1++) {
      for (m2 = 1; m2 < s; m2++) {
        if (m1 >= m2) {
          //			mm1 = (m1 * (100 + x)) / 100;
          //			mm2 = s - mm1;

          //			m2 = (100 * (mm2 + 0.5)) / (100 + x);
          temp = 0;
          if ((((m1 * (100 + x)) / 100) + ((m2 * (100 + x)) / 100)) == s) {
            //			cout << m1 << ' ' << m2 << endl;

            temp = (m1 * (100 + y)) / 100;
            temp += (m2 * (100 + y)) / 100;
            if (temp > max) {
              max = temp;
              // cout << max << endl;
            }
          }
        }
      }
    }
    //		cout << max << endl;
    a[n++] = max;
  }

  for (i = 0; i < n; i++)
    cout << a[i] << endl;

  return (0);
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[100];
  int i, j, k, n = 0, t;
  int m1, m2;
  int mm1, mm2;
  int temp;

  while (1) {
    int x, y, s; // x???????¨????,y??´??°???????¨????,z??????????¨?

    cin >> x >> y >> s;

    if (x == 0 && y == 0 && s == 0)
      break;

    int max = 0;

    for (m1 = 1; m1 < s; m1++) {
      for (m2 = 1; m2 < s; m2++) {
        if (m1 >= m2) {
          //			mm1 = (m1 * (100 + x)) / 100;
          //			mm2 = s - mm1;

          //			m2 = (100 * (mm2 + 0.5)) / (100 + x);
          temp = 0;
          if ((((m1 * (100 + x)) / 100) + ((m2 * (100 + x)) / 100)) == s) {
            //			cout << m1 << ' ' << m2 << endl;

            temp = (m1 * (100 + y)) / 100;
            temp += (m2 * (100 + y)) / 100;
            if (temp > max) {
              max = temp;
              // cout << max << endl;
            }
          }
        }
      }
    }
    //		cout << max << endl;
    a[n++] = max;
  }

  for (i = 0; i < n; i++)
    cout << a[i] << endl;

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

#include <stdio.h>

int max(int m1, int m2) { return m1 < m2 ? m2 : m1; }

int main() {
  int t1, t2, sum, a, i, j;
  for (; scanf("%d %d %d", &t1, &t2, &sum), sum;) {
    static int A[10000];
    for (j = 0; j < 1001; j++)
      A[j] = 0;
    int m = 0;
    for (i = 1; i < sum; i++) {
      a = i * (100 + t1) / 100;
      A[a] = i;
    }
    for (i = 1; i < sum; i++) {
      if (A[i] == 0 && A[sum - i] == 0)
        continue;
      m = max(A[i] * (100 + t2) / 100 + A[sum - i] * (100 + t2) / 100, m);
    }
    printf("%d\\n", m);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int max(int m1, int m2) { return m1 < m2 ? m2 : m1; }

int main() {
  int t1, t2, sum, a, i, j;
  for (; scanf("%d %d %d", &t1, &t2, &sum), sum;) {
    static int A[1001];
    for (j = 0; j < 1001; j++)
      A[j] = 0;
    int m = 0;
    for (i = 1; i < sum; i++) {
      a = i * (100 + t1) / 100;
      A[a] = i;
    }
    for (i = 1; i < sum; i++) {
      if (A[i] == 0 && A[sum - i] == 0)
        continue;
      m = max(A[i] * (100 + t2) / 100 + A[sum - i] * (100 + t2) / 100, m);
    }
    printf("%d\\n", m);
  }
  return 0;
}
Problem p00773 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int x, y, s;
  while (1) {
    cin >> x >> y >> s;
    int max = 0;
    if (x == y)
      break;
    for (int i = 1; i < s / 2 + 1; i++) {
      int temp1, temp2;
      temp1 = int(ceil(double((s - i)) * 100 / (100 + x)));
      temp2 = int(ceil(double(i) * 100 / (100 + x)));
      if (temp1 * (100 + x) / 100 == s - i) {
        if (temp2 * (100 + x) / 100 == i) {
          temp1 = temp1 * (100 + y) / 100;
          temp2 = temp2 * (100 + y) / 100;
          if (max < temp1 + temp2)
            max = temp1 + temp2;
        }
      }
    }
    cout << max << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int x, y, s;
  while (1) {
    cin >> x >> y >> s;
    if (x == y == s)
      break;
    int max = 0;
    for (int i = 1; i < s / 2; i++) {
      int temp;
      temp = (s - i) * (100 + y - x) / 100 + i * (100 + y - x) / 100;
      if (max < temp)
        max = temp;
    }
    cout << max << endl;
  }

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

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

//??\\?????????????¨????????¨????????????????????????????????????????????????????????±??????????????????????????????§?????´???????¨??????????????????§??§?????????????????¢???

int main() {
  int X;
  int Y;
  int S;
  vector<int> A_array;
  vector<int> B_array;

  for (int a = 0; a < 1000; a++) {
    for (int b = 0; b < 1000; b++) {
      if ((a > 0) && (b > 0)) {
        A_array.push_back(a);
        B_array.push_back(b);
      }
    }
  }

  while (true) {

    cin >> X >> Y >> S;

    if ((X == 0) && (Y == 0) && (S == 0))
      break;

    vector<int> newvalue;
    int maxvalue = 0;

    for (int j = 0; j < A_array.size(); j++) {
      int taxsum = A_array[j] * (X + 100) / 100 + B_array[j] * (X + 100) / 100;
      int newtaxsum =
          A_array[j] * (Y + 100) / 100 + B_array[j] * (Y + 100) / 100;
      if ((S == taxsum) && (A_array[j] < S) && (B_array[j] < S) && (S > 10) &&
          (S < 1000))
        newvalue.push_back(newtaxsum);
    }

    for (int k = 0; k < newvalue.size(); k++) {
      if (maxvalue < newvalue[k]) {
        maxvalue = newvalue[k];
      }
    }

    cout << maxvalue << endl;
  }

  return 0;
}

Error: MLE

Fixed submission:

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

//??\\?????????????¨????????¨????????????????????????????????????????????????????????±??????????????????????????????§?????´???????¨??????????????????§??§?????????????????¢???

int main() {
  vector<int> X;
  vector<int> Y;
  vector<int> S;
  int tempx, tempy, temps;
  int i = 0;
  vector<int> allvalue;
  vector<int> A_array;
  vector<int> B_array;

  while (true) {

    cin >> tempx >> tempy >> temps;
    X.push_back(tempx);
    Y.push_back(tempy);
    S.push_back(temps);

    for (int a = 0; a < 1000; a++) {
      for (int b = 0; b < 1000; b++) {
        allvalue.push_back(a * (100 + X[i]) / 100 + b * (100 + X[i]) / 100);
        A_array.push_back(a);
        B_array.push_back(b);
      }
    }

    vector<int> newvalue;
    int maxvalue = 0;

    for (int j = 0; j < A_array.size(); j++) {
      if (S[i] ==
          (A_array[j] * (X[i] + 100) / 100) + (B_array[j] * (X[i] + 100) / 100))
        newvalue.push_back((A_array[j] * (Y[i] + 100) / 100 +
                            B_array[j] * (Y[i] + 100) / 100));
    }

    for (int k = 0; k < newvalue.size(); k++) {
      if (maxvalue < newvalue[k]) {
        maxvalue = newvalue[k];
      }
    }

    cout << maxvalue << endl;

    if ((X[i] == 0) && (Y[i] == 0) && (S[i] == 0))
      break;

    i++;
    vector<int> vec;
    vector<int>().swap(vec);
  }

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

#include <iostream>
using namespace std;

int tax(int a, int t) {
  int p;
  p = a * (100 + t) / 100;
  return p;
}

int main() {
  int x, y, s;
  while (cin >> x >> y >> s && s > 0) {
    int m = 0;
    for (int i = 1; i < s; ++i) {
      for (int j = 1; j < s; ++j) {
        if (tax(i, x) + tax(j, x) == s) {
          m = max(m, tax(i, y) + tax(j, y));
        }
      }
    }
    cout << m << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int btax(int a, int t) {
  for (int k = 1; k < a; ++k) {
    if (k * (100 + t) / 100 == a)
      return k;
  }
}

int main() {
  int x, y, s;
  int m = 0;
  while (cin >> x >> y >> s, s > 0) {
    for (int i = 1; i < s; ++i) {
      for (int j = 1; j <= s - i; ++j) {
        if (btax(i, x) + btax(j, x) == s) {
          m = max(m, ((100 + y) / 100) * btax(i, x) +
                         ((100 + y) / 100) * btax(j, x));
        }
      }
    }
    cout << m << endl;
  }
}
Problem p00773 (C++) — buggy submission, verdict: Runtime Error

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

int tax(int p, int t) { return p + p * t / 100; }

int main() {
  int x, y, s;

  for (int i = 0; true; i++) {
    cin >> x >> y >> s;
    if (x == 0) {
      break;
    }
    int a = 0;
    for (int j = 1; j < s; j++) {
      for (int k = s - 1; j <= k && k <= s; k--) {
        if (tax(j, x) + tax(k, x) == s) {
          if (tax(j, y) + tax(k, y) > a) {
            a = tax(j, y) + tax(k, y);
          }
        }
      }
    }

    cout << a << endl;
  }
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 105) >= this->size() (which is 105)


Fixed submission:

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

int tax(int p, int t) { return p + p * t / 100; }

int main() {
  int x, y, s;

  cin >> x >> y >> s;
  if (x != 0) {
    vector<int> a(s);
    for (int j = 1; j < s; j++) {
      if (tax(j, y) == s) {
        a.at(j - 1) = tax(j, x);
      }
      sort(a.begin(), a.end());
      cout << a.at(s) << endl;
    }
  }
}