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

#include <cstdio>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    int t[100], tt[200], i, ii;
    string ans[1000];
    i = 1;
    for (i = 1; n >= i; i++) {
      // cout << i << endl;
      cin >> t[1] >> t[2] >> t[3];
      tt[1] = (t[1] + t[2]) / 2;
      tt[2] = (t[1] + t[2] + t[3]) / 3;
      if (t[1] == 100 or t[2] == 100 or t[3] == 100 or tt[1] >= 90 or
          tt[2] >= 80) {
        ans[i] = "A";
      } else if (tt[2] >= 70) {
        ans[i] = "B";
      } else if (tt[2] >= 50 and t[1] >= 80 or tt[2] >= 50 and t[2] >= 80) {
        ans[i] = "B";
      } else {
        ans[i] = "C";
      }
    }
    ii = 1;
    // cout << "OK" << endl;
    for (ii = 1; n >= ii; ii++) {
      cout << ans[ii] << endl;
    }
  }
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    int t[3], tt[2];
    string ans[n];
    for (int i = 1; n >= i; i++) {
      for (int ii = 1; 3 >= ii; ii++) {
        cin >> t[1] >> t[2] >> t[3];
        tt[1] = (t[1] + t[2]) / 2;
        tt[2] = (t[1] + t[2] + t[3]) / 3;
        if (t[1] == 100 or t[2] == 100 or t[3] == 100 or tt[1] >= 90 or
            t[2] >= 80) {
          ans[i] = "A";
        } else if (tt[2] >= 70) {
          ans[i] = "B";
        } else if (tt[2] >= 50 and t[1] >= 80 or tt[2] >= 50 and t[2] >= 80) {
          ans[i] = "B";
        } else {
          ans[i] = "C";
        }
      }
    }
    for (int iii = 1; n >= iii; iii++) {
      cout << ans[iii] << endl;
    }
  }
}
Problem p00218 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n, pm, pj, pe;
  while (n) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> pm >> pe >> pj;
      if (pm == 100 || pj == 100 || pe == 100) {
        cout << "A" << endl;
      } else if ((pm + pe) / 2 >= 90) {
        cout << "A" << endl;
      } else if ((pe + pj + pm) / 3 >= 80) {
        cout << "A" << endl;
      } else if ((pm + pj + pe) / 3 >= 70) {
        cout << "B" << endl;
      } else if ((pm + pe + pj) / 3 >= 50 && pm >= 80 || pe >= 80) {
        cout << "B" << endl;
      } else {
        cout << "C" << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, pe, pj, pm;
  cin >> n;
  while (n)
    for (int i = 0; i <= n; i++) {
      cin >> pm >> pe >> pj;
      if (pm == 100 && pe == 100 && pj == 100) {
        cout << "A" << endl;
      } else if ((pm + pe) / 2 >= 90) {
        cout << "A" << endl;
      } else if ((pe + pm + pj) / 3 >= 80) {
        cout << "A" << endl;
      } else if ((pe + pj + pm) / 3 >= 70) {
        cout << "B" << endl;
      } else if ((pe + pj + pm) / 3 >= 50 || pm >= 80 && pe >= 80) {
        cout << "B" << endl;
      } else if ((pe + pj + pm) / 3 > 50) {
        cout << "C" << endl;
      }
    }
}
Problem p00218 (C++) — buggy submission, verdict: Time Limit Exceeded

/*100 点の科目がある 	A
数学と英語の平均点が 90 点以上 	A
3 科目の平均点が 80 点以上 	A
3 科目の平均点が 70 点以上 	B
3 科目の平均点が 50 点以上で数学か英語が 80 点以上 	B
上の条件を満たさない 	C*/
#include <iostream>
using namespace std;
int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a;
      cin >> b >> c;
      if (a == 100 || b == 100 || c == 100) {
        cout << "A" << endl;
      } else if ((a + b) / 2 >= 90) {
        cout << "A" << endl;
      } else if ((a + b + c) / 3 >= 80) {
        cout << "A" << endl;
      } else if ((a + b + c) / 3 >= 70) {
        cout << "B" << endl;
      } else if ((a + b + c) / 3 >= 50 && a >= 80) {
        cout << "B" << endl;
      } else if ((a + b + c) / 3 >= 50 && b >= 80) {
        cout << "B" << endl;
      } else {
        cout << "C" << endl;
      }
    }
  }
}


Error: TLE

Fixed submission:

/*100 点の科目がある 	A
数学と英語の平均点が 90 点以上 	A
3 科目の平均点が 80 点以上 	A
3 科目の平均点が 70 点以上 	B
3 科目の平均点が 50 点以上で数学か英語が 80 点以上 	B
上の条件を満たさない 	C*/
#include <iostream>
using namespace std;
int main() {
  for (;;) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a;
      if (a == 0)
        break;
      cin >> b >> c;
      if (a == 100 || b == 100 || c == 100) {
        cout << "A" << endl;
      } else if ((a + b) / 2 >= 90) {
        cout << "A" << endl;
      } else if ((a + b + c) / 3 >= 80) {
        cout << "A" << endl;
      } else if ((a + b + c) / 3 >= 70) {
        cout << "B" << endl;
      } else if ((a + b + c) / 3 >= 50 && a >= 80) {
        cout << "B" << endl;
      } else if ((a + b + c) / 3 >= 50 && b >= 80) {
        cout << "B" << endl;
      } else {
        cout << "C" << endl;
      }
    }
  }
}
Problem p00218 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int pa(void) { printf("A\\n"); }

int pb(void) { printf("B\\n"); }

int pc(void) { printf("C\\n"); }

int main(void) {
  int n, i, sum, pm[10000], pj[10000], pe[10000];
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    sum = pm[i] + pe[i] + pj[i];
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &pm[i], &pj[i], &pe[i]);
      sum = pm[i] + pe[i] + pj[i];
      if (pm[i] == 100 || pj[i] == 100 || pe[i] == 100) {
        pa();
      } else if (pm[i] + pe[i] >= 180) {
        pa();
      } else if (sum >= 240) {
        pa();
      } else if (sum >= 210) {
        pb();
      } else if (sum >= 150 && (pm[i] >= 80 || pe[i] >= 80)) {
        pb();
      } else {
        pc();
      }
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int pa(void) { printf("A\\n"); }

int pb(void) { printf("B\\n"); }

int pc(void) { printf("C\\n"); }

int main(void) {
  int n, i, sum, pm[10000], pj[10000], pe[10000];
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    sum = pm[i] + pe[i] + pj[i];
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &pm[i], &pj[i], &pe[i]);
      if (pm[i] == 100 || pj[i] == 100 || pe[i] == 100) {
        pa();
      } else if (pm[i] + pe[i] >= 90) {
        pa();
      } else if (sum >= 240) {
        pa();
      } else if (sum >= 210) {
        pb();
      } else if (sum >= 150 && (pm[i] >= 80 || pe[i] >= 80)) {
        pb();
      } else {
        pc();
      }
    }
  }
  return 0;
}
Problem p00218 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n, pj, pm, pe;
  while (n) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> pm >> pe >> pj;
      if (pm == 100 || pj == 100 || pe == 100) {
        cout << "A" << endl;
      } else if ((pm + pe) / 2 >= 90) {
        cout << "A" << endl;
      } else if ((pm + pe + pj) / 3 >= 80) {
        cout << "A" << endl;
      } else if ((pm + pe + pj) / 3 >= 70) {
        cout << "B" << endl;
      } else if ((pm + pe + pj) / 3 >= 50 && pm >= 80 || pe >= 80) {
        cout << "B" << endl;
      } else {
        cout << "C" << endl;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  while (1) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      int pj, pm, pe;
      cin >> pm >> pe >> pj;
      if (pj == 100 || pe == 100 || pm == 100) {
        cout << "A" << endl;
      } else if ((pe + pm) / 2 >= 90) {
        cout << "A" << endl;
      } else if ((pj + pm + pe) / 3 >= 80) {
        cout << "A" << endl;
      } else if ((pj + pe + pm) / 3 >= 70) {
        cout << "B" << endl;
      } else if ((pj + pe + pm) / 3 >= 50 && pe >= 80) {
        cout << "B" << endl;
      } else if ((pj + pe + pm) / 3 >= 50 && pm >= 80) {
        cout << "B" << endl;
      } else {
        cout << "C" << endl;
      }
    }
  }
}
Problem p00219 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  for (int u = 0; u < 20; u++) {
    int a[10001];
    long n = 0, co[11];

    cin >> n;
    if (n == 0) {
      break;
    }

    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int j = 0; j < 10; j++) {
      co[j] = 0;
    }

    for (int i = 0; i < n; i++) {
      co[a[i]] += 1;
    }

    for (int j = 0; j < 10; j++) {
      if (co[j] == 0) {
        cout << '-';
      } else {
        for (int k = 0; k < co[j]; k++) {
          cout << '*';
        }
      }
      cout << endl;
    }
  }
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  for (int u = 0; u < 20; u++) {
    int n, a[100];
    int co[100];

    cin >> n;
    if (n == 0) {
      break;
    }

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

    for (int i = 0; i < n; i++) {
      co[a[i]] += 1;
    }

    for (int i = 0; i < n; i++) {
      if (co[i] == 0) {
        cout << '-' << endl;
      } else {
        for (int j = 0; j < co[i]; j++) {
          cout << '*';
        }
        cout << endl;
      }
    }
  }
}
Problem p00219 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main() {

  int n;
  while (cin >> n && n != 0) {
    int v[10];
    fill(v, v + 10, 0);
    for (int i = 0; i < n; i++) {
      int t;
      cin >> t;
      v[t]++;
    }
    for (int i = 0; i < 10; i++) {
      int num = v[i];
      if (num >= 1) {
        for (int j = 0; j < num; j++)
          cout << '*';
        cout << endl;
      } else {
        cout << '-' << endl;
      }
    }
  }

  return 0;
}

Error: -8

Fixed submission:

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

using namespace std;

typedef unsigned long long ll;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void div(ll &d, ll &v) {
  for (ll i = 2; i <= min(d, v); i++) {
    if (d % i == 0 && v % i == 0) {
      d /= i;
      v /= i;
      i = 1;
    }
  }
}

int main() {

  ll n;
  while (cin >> n && n != 0) {
    ll d, v;
    vector<ll> ds;
    vector<ll> vs;
    bool oo = false;
    for (ll i = 0; i < n; i++) {
      cin >> d >> v;

      div(d, v);

      ds.push_back(d);
      vs.push_back(v);
    }

    ll z = 1;
    ll nums[11];
    ll allv = 1;
    // for(ll i = 0; i < n; i++){
    //	allv*=vs[i];
    // }

    // for(ll i = 0; i < n; i++){
    //	nums[i]=ds[i]*allv/vs[i];
    //	z=lcm(z,nums[i]);
    // }
    // for(ll i = 0; i < n; i++){
    //	cout<<(z/nums[i])<<endl;
    // }
    bool same = true;
    for (ll i = 1; i < n; i++) {
      ll n1 = ds[i - 1] * vs[i];
      ll n2 = ds[i] * vs[i - 1];
      ll ret = lcm(n1, n2);
      ll r1 = ret / n1;
      ll r2 = ret / n2;
      if (ds[i - 1] == ds[i] && vs[i - 1] == vs[i]) {
        z = lcm(z, 1);
        same = true;
      } else {
        z = lcm(z, r1 * ds[i - 1] / vs[i - 1]);
        same = false;
      }
    }
    vector<ll> vll;
    ll m;
    if (!same) {
      for (ll i = 0; i < n; i++) {
        vll.push_back(z * vs[i] / ds[i]);
        if (i == 0) {
          m = z * vs[i] / ds[i];
        } else {
          m = gcd(m, z * vs[i] / ds[i]);
        }
      }
      for (int i = 0; i < n; i++) {
        cout << vll[i] / m << endl;
      }
    } else {
      for (int i = 0; i < n; i++) {
        cout << 1 << endl;
      }
    }
  }

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

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\\D_Download\\Visual Studio
///2015\\Projects\\programing_contest_c++\\Debug\\a.txt"
int main() {
  while (1) {
    int N;
    cin >> N;
    if (!N)
      break;
    vector<int> nums(10000);
    for (int i = 0; i < N; ++i) {
      int a;
      cin >> a;
      nums[a]++;
    }
    for (int i = 0; i < 10; ++i) {
      if (nums[i]) {
        for (int j = 0; j < nums[i]; ++j) {
          cout << '*';
        }
      } else {
        cout << '-';
      }
      cout << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\\D_Download\\Visual Studio
///2015\\Projects\\programing_contest_c++\\Debug\\a.txt"
int main() {
  while (1) {
    int N;
    cin >> N;
    vector<int> nums(10000);
    for (int i = 0; i < N; ++i) {
      int a;
      cin >> a;
      nums[a]++;
    }
    for (int i = 0; i < 10; ++i) {
      if (nums[i]) {
        for (int j = 0; j < nums[i]; ++j) {
          cout << '*';
        }
      } else {
        cout << '-';
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p00219 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  while (cin >> n, n) {
    int c[10];
    fill(c, c + 10, 0);
    for (int i = 0; i < n; i++)
      cin >> t, c[t]++;
    for (int i = 0; i < 10; i++) {
      if (!c[i])
        cout << '-';
      else
        for (int j = 0; j < c[i]; j++)
          cout << '*';
      cout << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  while (cin >> n, n) {
    int c[10];
    fill(c, c + 10, 0);
    for (int i = 0; i < n; i++)
      cin >> t, c[t]++;
    for (int i = 0; i < n; i++) {
      if (!c[i])
        cout << '-';
      else
        for (int j = 0; j < c[i]; j++)
          cout << '*';
      cout << endl;
    }
  }
}
Problem p00219 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main(void) {
  int a, n;
  while (1) {
    map<int, string> str;
    cin >> n;
    if (n == 0)
      break;
    for (a = 0; a < n; a++) {
      int b;
      cin >> b;
      str[b].push_back('*');
    }
    for (a = 0; a <= 9; a++) {
      if (str.size() > 0)
        cout << str[a] << endl;
      else
        cout << "-" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main(void) {
  int a, n;
  while (1) {
    map<int, string> str;
    cin >> n;
    for (a = 0; a < n; a++) {
      int b;
      cin >> b;
      str[b].push_back('*');
    }
    for (a = 0; a <= 9; a++) {
      if (str.size() > 0)
        cout << str[a] << endl;
      else
        cout << "-" << endl;
    }
  }
  return 0;
}
Problem p00219 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    int menu[15];
    fill_n(menu, 15, 0);
    rep(i, n) {
      int a;
      cin >> a;
      menu[a]++;
    }
    rep(i, 10) {
      if (menu[i] == 0) {
        cout << "-" << endl;
      } else {
        rep(j, menu[i]) { cout << "*"; }
        cout << endl;
      }
    }
  }

  return 0;
}

int StrToInt(string s) {
  stringstream ss;
  ss << s;
  int val;
  ss >> val;
  return val;
}
string IntToStr(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    int menu[10];
    fill_n(menu, n, 0);
    rep(i, n) {
      int a;
      cin >> a;
      menu[a]++;
    }
    rep(i, 10) {
      if (menu[i] == 0) {
        cout << "-" << endl;
      } else {
        rep(j, menu[i]) { cout << "*"; }
        cout << endl;
      }
    }
  }

  return 0;
}

int StrToInt(string s) {
  stringstream ss;
  ss << s;
  int val;
  ss >> val;
  return val;
}
string IntToStr(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}
Problem p00219 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n;
  int buy;
  int ice[10];

  while (scanf("%d", &n), n != 0) {
    for (int i = 0; i < 10; i++) {
      ice[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &buy);
      ice[buy]++;
    }

    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < ice[i]; j++) {
        if (ice[i] == 0) {
          cout << "-" << endl;
          break;
        } else {
          cout << "*";
        }
      }
      cout << endl;
    }
  }

  return (0);
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n;
  int buy;
  int ice[10];

  while (scanf("%d", &n), n != 0) {
    for (int i = 0; i < 10; i++) {
      ice[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &buy);
      ice[buy]++;
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < ice[i]; j++) {
        if (ice[i] == 0) {
          cout << "-" << endl;
          break;
        } else {
          cout << "*";
        }
      }
      cout << endl;
    }
  }

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

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, a;
  while (cin >> n, n) {
    int b[10] = {};
    for (int i = 0; i < n; i++) {
      cin >> a;
      b[a] += 1;
    }
    for (int i = 0; i < 10; i++) {
      if (b[i] > 0) {
        string s(b[i], '*');
        cout << s << endl;
      } else if (b[i] <= 0) {
        cout << '-' << endl;
      }
    }
  }
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, a;
  cin >> n;
  int b[10] = {};
  while (cin >> a) {
    b[a] += 1;
  }
  for (int i = 0; i < 10; i++) {
    if (b[i] > 0) {
      string s(b[i], '*');
      cout << s << endl;
    } else {
      cout << '-' << endl;
    }
  }
  return 0;
}
Problem p00219 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    int x, m;
    int a[10000];
    for (int i = 0; i < 1000; i++) {
      a[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> m;
      a[m] += 1;
    }
    for (int j = 0; j < 10; j++) {
      if (a[j] == 0) {
        cout << "-";
      } else {
        for (int k = 0; k < a[j]; k++) {
          cout << "*";
        }
      }
      cout << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  while (1) {
    int x, m, n;
    int a[10000];
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> m;
      a[m] += 1;
    }
    for (int j = 0; j < 10; j++) {
      if (a[j] == 0) {
        cout << "-";
      } else {
        for (int k = 0; k < a[j]; k++) {
          cout << "*";
        }
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p00219 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> a(10);
  int n, sort;
  while (cin >> n) {
    if (n == 0)
      break;
    else {
      fill(a.begin(), a.end(), 0);
      for (int i = 0; i < n; i++) {
        cin >> sort;
        a[sort]++;
      }
      for (int i = 0; i < 10; i++) {
        if (a[i] == 0) {
          cout << "-";
        } else {
          for (int j = 0; j < a[i]; j++) {
            cout << "*";
          }
        }
        cout << endl;
      }
    }
  }
}

Error: WA

Fixed submission:

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

int main() {
  vector<int> a(9);
  int n, sort;
  while (cin >> n) {
    if (n == 0)
      break;
    else {
      fill(a.begin(), a.end(), 0);
      for (int i = 0; i < n; i++) {
        cin >> sort;
        a[sort]++;
      }
      for (int i = 0; i < 10; i++) {
        if (a[i] == 0) {
          cout << "-";
        } else {
          for (int j = 0; j < a[i]; j++) {
            cout << "*";
          }
        }
        cout << endl;
      }
    }
  }
}
Problem p00219 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main(void) {
  int n, x, cnt[10], i, j;
  while (1) {
    for (i = 0; i < 10; i++) {
      cnt[i] = 0;
    }
    scanf("%d", &n);
    if (n < 1)
      break;
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      cnt[x]++;
    }
    for (i = 0; i < 10; i++) {
      if (cnt[i] > 0) {
        for (j = 0; j < cnt[i]; j++) {
          printf("*");
        }
        printf("\\n");
      } else {
        printf("-\\n");
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int n, x, cnt[10], i, j;
  while (1) {
    for (i = 0; i < 10; i++) {
      cnt[i] = 0;
    }
    scanf("%d", &n);
    if (n < 1)
      break;
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      cnt[x]++;
    }
    for (i = 0; i < 10; i++) {
      if (cnt[i] > 0) {
        for (j = 0; i < cnt[i]; j++) {
          printf("*");
          if (i == cnt[i] - 1) {
            printf("\\n");
          }
        }
      } else {
        printf("-\\n");
      }
    }
  }
  return 0;
}