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

#include <iostream>
#include <string>

using namespace std;

int l1, l2;
string s1, s2, res;

string func(char cn, string str1, string str2, int p, int q, int l) {
  if (p >= l1 && q >= l2) {
    str2 += cn;
    return str2;
  }

  if (l < res.size() && cn == res[l])
    return func(s1[p], (str1 + cn), str2, p + 1, q, l + 1);
  return func(s2[q], str1, (str2 + cn), p, q + 1, l);
}

int main() {
  while (cin >> s1 && s1 != "-") {
    cin >> s2 >> res;
    l1 = s1.size();
    l2 = s2.size();

    cout << func(s2[0], "", "", 0, 1, 0) << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int l1, l2;
string s1, s2, res;

bool func(char cn, string str1, string str2, int p, int q) {
  if (p == l1 && q == l2) {
    string t1 = str1, t2 = str2;
    str1 += cn;
    str2 += cn;
    if (str1 == res) {
      res = t2;
      return true;
    } else if (str2 == res) {
      res = t1;
      return true;
    } else if (t1 == res) {
      res = str2;
      return true;
    } else if (t2 == res) {
      res = str1;
      return true;
    }

    return false;
  }

  if (cn == '*') {
    if (p < l1 && func(s1[p], str1, str2, p + 1, q))
      return true;
    if (q < l2 && func(s2[q], str1, str2, p, q + 1))
      return true;
  } else {
    if (p < l1 && func(s1[p], (str1 + cn), str2, p + 1, q))
      return true;
    if (q < l2 && func(s2[q], str1, (str2 + cn), p, q + 1))
      return true;
  }

  return false;
}

int main() {
  while (cin >> s1 && s1 != "-") {
    cin >> s2 >> res;
    l1 = s1.size();
    l2 = s2.size();

    func('*', "", "", 0, 0);
    cout << res << endl;
  }

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

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

int main(int argc, const char *argv[]) {
  while (true) {
    string str[2] = {"", ""};
    string result[2] = {"", ""};
    int pointer[2] = {0, 1};

    cin >> str[0];
    if (str[0][0] == '-')
      return 0;
    cin >> str[1] >> result[0];
    result[2] = "";
    // pointer[0] = 0;
    // pointer[1] = 1;
    char next = str[1][0];

    int i = 0;
    while (i < result[0].length()) {
      if (next == result[0][i]) {
        // push down
        next = str[0][pointer[0]];
        pointer[0]++;
        i++;
      } else {
        // push right
        cout << next;
        next = str[1][pointer[1]];
        pointer[1]++;
      }
    }
    cout << next;
    for (; pointer[1] < str[1].length(); pointer[1]++) {
      cout << str[1][pointer[1]];
    }
    cout << result[2] << endl;
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

string str[2];
string result[2];
int pointer[2];

int main(int argc, const char *argv[]) {
  while (true) {
    cin >> str[0];
    if (str[0][0] == '-')
      return 0;
    cin >> str[1] >> result[0];
    result[2] = "";
    pointer[0] = 0;
    pointer[1] = 1;
    char next = str[1][0];

    int i = 0;
    while (i < result[0].length()) {
      if (next == result[0][i]) {
        // push down
        next = str[0][pointer[0]];
        pointer[0]++;
        i++;
      } else {
        // push right
        cout << next;
        next = str[1][pointer[1]];
        pointer[1]++;
      }
    }
    cout << next;
    for (; pointer[1] < str[1].length(); pointer[1]++) {
      cout << str[1][pointer[1]];
    }
    cout << result[2] << endl;
  }
}
Problem p00622 (C++) — buggy submission, verdict: Runtime Error

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

queue<char> to_queue(string s) {
  queue<char> q;
  for (int i = 0; i < (int)s.size(); ++i) {
    q.push(s[i]);
  }
  return q;
}

int main() {
  string red, green, down;
  while (cin >> red, red != "-") {
    cin >> green >> down;

    queue<char> r, g, d;
    r = to_queue(red);
    g = to_queue(green);
    d = to_queue(down);

    string res = "";
    char c = g.front();
    g.pop();
    while (!r.empty() || !g.empty()) {
      if (c == d.front()) {
        d.pop();
        c = r.front();
        r.pop();
      } else {
        res += c;
        c = g.front();
        g.pop();
      }
    }
    res += c;
    cout << res << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

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

queue<char> to_queue(string s) {
  queue<char> q;
  for (int i = 0; i < (int)s.size(); ++i) {
    q.push(s[i]);
  }
  return q;
}

int main() {
  string red, green, down;
  while (cin >> red, red != "-") {
    cin >> green >> down;

    queue<char> r, g, d;
    r = to_queue(red);
    g = to_queue(green);
    d = to_queue(down);

    string res = "";
    char c = g.front();
    g.pop();
    while (!r.empty() || !g.empty()) {
      cout << c << endl;
      if (c == d.front()) {
        d.pop();
        c = r.front();
        r.pop();
      } else {
        res += c;
        c = g.front();
        g.pop();
      }
    }
    res += c;
    cout << res << endl;
  }
  return 0;
}
Problem p00623 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
string expr;
int n, sweet[10], s, ans;
int eval(int b, int e) {
  if (b + 1 == e)
    return sweet[expr[b] - '1'];
  int l, o, r, d;
  for (o = b, d = 0; o < e; o++) {
    char c = expr[o];
    if (c == '(')
      d++;
    if (c == ')')
      d--;
    if (d == 0 && (c == '&' || c == '|' || c == '^'))
      break;
  }
  if (o == e && expr[b] == '(')
    return eval(b + 1, e - 1);
  l = eval(b, o), r = eval(o + 1, e);
  char c = expr[o];
  return c != '&' ? c == '^' ? l ^ r : l | r : l & r;
}
void op(int c) {
  for (; c < s; c++)
    if (expr[c] == ' ')
      break;
  if (c < s)
    rep(i, 3) {
      expr[c] = "&|^"[i];
      op(c + 1);
      expr[c] = ' ';
    }
  else if (eval(0, s) == 15)
    ans++;
}
int main() {
  while (getline(cin, expr), expr != "END") {
    s = expr.size(), ans = 0;
    cin >> n;
    rep(i, n) {
      int t;
      sweet[i] = 0;
      rep(j, 4) cin >> t, sweet[i] <<= 1, sweet[i] += t;
    }
    op(0);
    cout << ans << endl;
    cin.ignore();
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
string expr;
int n, sweet[4], s, ans;
int eval(int b, int e) {
  if (b + 1 == e)
    return sweet[expr[b] - '1'];
  int l, o, r, d;
  for (o = b, d = 0; o < e; o++) {
    char c = expr[o];
    if (c == '(')
      d++;
    if (c == ')')
      d--;
    if (d == 0 && (c == '&' || c == '|' || c == '^'))
      break;
  }
  if (o == e && expr[b] == '(')
    return eval(b + 1, e - 1);
  l = eval(b, o), r = eval(o + 1, e);
  char c = expr[o];
  return c != '&' ? c == '^' ? l ^ r : l | r : l & r;
}
void op(int c) {
  for (; c < s; c++)
    if (expr[c] == ' ')
      break;
  if (c < s)
    rep(i, 3) {
      expr[c] = "&|^"[i];
      op(c + 1);
      expr[c] = ' ';
    }
  else if (eval(0, s) == 15)
    ans++;
}
int main() {
  while (getline(cin, expr), expr != "END") {
    s = expr.size(), ans = 0;
    cin >> n;
    rep(i, n) {
      int t;
      sweet[i] = 0;
      rep(j, 4) cin >> t, sweet[i] <<= 1, sweet[i] += t;
    }
    op(0);
    cout << ans << endl;
    cin.ignore();
  }
  return 0;
}
Problem p00623 (C++) — buggy submission, verdict: Runtime Error

#include <ctype.h>
#include <map>
#include <stdio.h>
#include <vector>
typedef std::map<int, int> M;
typedef M::iterator I;
typedef std::pair<int, int> P;
std::vector<P> v;
int x[10];
int F(char *&p, int n) {
  if (isdigit(*p))
    return -*p + '0';
  v.push_back(P(0, 0));
  int s = v.size();
  v[n].first = F(++p, s);
  s = v.size();
  v[n].second = F(p += 2, s);
  ++p;
  return n;
}
M G(int i) {
  M m;
  if (i < 0)
    m[x[-i]] = 1;
  else {
    M a(G(v[i].first)), b(G(v[i].second));
    for (I p = a.begin(); p != a.end(); ++p)
      for (I q = b.begin(); q != b.end(); ++q) {
        int a = p->first, b = q->first, c = p->second * q->second;
        m[a & b] += c;
        m[a | b] += c;
        m[a ^ b] += c;
      }
  }
  return m;
}
int main() {
  int n, i, j, t;
  char *p, s[512];
  v.reserve(64);
  while (fgets(s, 512, stdin), *s - 'E') {
    v.clear();
    scanf("%d", &n);
    for (i = 1; i <= n; ++i)
      for (x[i] = j = 0; j < 4; ++j)
        scanf("%d", &t), x[i] = x[i] * 2 + t;
    t = F(p = s, 0);
    printf("%d\\n", t ? x[-t] == 15 : G(0)[15]);
    fgets(s, 512, stdin);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <ctype.h>
#include <map>
#include <stdio.h>
#include <vector>
typedef std::map<int, int> M;
typedef M::iterator I;
typedef std::pair<int, int> P;
std::vector<P> v;
int x[10];
int F(char *&p, int n) {
  if (isdigit(*p))
    return -*p + '0';
  v.push_back(P(0, 0));
  int s = v.size();
  v[n].first = F(++p, s);
  s = v.size();
  v[n].second = F(p += 2, s);
  ++p;
  return n;
}
M G(int i) {
  M m;
  if (i < 0)
    m[x[-i]] = 1;
  else {
    M a(G(v[i].first)), b(G(v[i].second));
    for (I p = a.begin(); p != a.end(); ++p)
      for (I q = b.begin(); q != b.end(); ++q) {
        int a = p->first, b = q->first, c = p->second * q->second;
        m[a & b] += c;
        m[a | b] += c;
        m[a ^ b] += c;
      }
  }
  return m;
}
int main() {
  int n, i, j, t;
  char *p, s[512];
  while (fgets(s, 512, stdin), *s - 'E') {
    v.clear();
    scanf("%d", &n);
    for (i = 1; i <= n; ++i)
      for (x[i] = j = 0; j < 4; ++j)
        scanf("%d", &t), x[i] = x[i] * 2 + t;
    t = F(p = s, 0);
    printf("%d\\n", t ? x[-t] == 15 : G(0)[15]);
    fgets(s, 512, stdin);
  }
  return 0;
}
Problem p00623 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <string>

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

using namespace std;

int subset[10];

/*
        <TREE> ::= <LEAF>|(<TREE><OPE><TREE>)
        <LEAF> ::= 1,2,..,8
        <OPE>  ::= a,o,x
*/
int TREE(const string &, int &);
int LEAF(const string &, int &);
char OPE(const string &, int &);

int TREE(const string &exp, int &idx) {
  if (isdigit(exp[idx]))
    return LEAF(exp, idx);

  idx++;
  int a = TREE(exp, idx);
  char o = OPE(exp, idx);
  int b = TREE(exp, idx);
  idx++;

  if (o == 'a')
    return a & b;
  else if (o == 'o')
    return a | b;
  else
    return a ^ b;
}

int LEAF(const string &exp, int &idx) { return subset[exp[idx++] - '0' - 1]; }

char OPE(const string &exp, int &idx) { return exp[idx++]; }

int parse(string s) {
  int idx = 0;
  string exp = s;
  return TREE(exp, idx) == 15;
}

int main() {
  for (string s; getline(cin, s), s != "END";) {
    int len = s.length();
    int n;
    cin >> n;
    rep(i, n) {
      subset[i] = 0;
      rep(j, 4) {
        int t;
        cin >> t;
        subset[i] |= t << j;
      }
    }
    cin.ignore();

    int spnum = 0, sppos[8];
    rep(i, len) if (s[i] == ' ') sppos[spnum++] = i;

    int cnt = 0;
    char op[] = "aox";
    rep(i, (int)pow(3., spnum)) {
      int k = i;
      string exp = s;
      rep(j, spnum) {
        exp[sppos[j]] = op[k % 3];
        k /= 3;
      }
      if (parse(exp))
        cnt++;
    }

    cout << cnt << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <cmath>
#include <iostream>
#include <string>

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

using namespace std;

int subset[8];

int TREE(const string &, int &);
int LEAF(const string &, int &);
char OPE(const string &, int &);

int TREE(const string &exp, int &idx) {
  if (isdigit(exp[idx]))
    return LEAF(exp, idx);

  idx++;
  int a = TREE(exp, idx);
  char o = OPE(exp, idx);
  int b = TREE(exp, idx);
  idx++;

  if (o == 'a')
    return a & b;
  else if (o == 'o')
    return a | b;
  else
    return a ^ b;
}

int LEAF(const string &exp, int &idx) { return subset[exp[idx++] - '0' - 1]; }

char OPE(const string &exp, int &idx) { return exp[idx++]; }

int parse(string s) {
  int idx = 0;
  string exp = s;
  return TREE(exp, idx) == 15;
}

int main() {
  for (string s; getline(cin, s), s != "END";) {
    int len = s.length();
    int n;
    cin >> n;
    rep(i, n) {
      subset[i] = 0;
      rep(j, 4) {
        int t;
        cin >> t;
        subset[i] |= t << j;
      }
    }
    cin.ignore();

    int spnum = 0, sppos[7];
    rep(i, len) if (s[i] == ' ') sppos[spnum++] = i;

    int cnt = 0;
    char op[] = "aox";
    rep(i, (int)pow(3., spnum)) {
      int k = i;
      string exp = s;
      rep(j, spnum) {
        exp[sppos[j]] = op[k % 3];
        k /= 3;
      }
      if (parse(exp))
        cnt++, cout << exp << endl;
    }

    cout << cnt << endl;
  }

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

#include <iostream>
using namespace std;
int n, a, sum;
int main() {
  while (true) {
    sum = 0;
    cin >> n;
    if (!n) {
      break;
    }
    n /= 4;
    for (int i = 0; i < n; i++) {
      cin >> a;
      sum += a;
    }
    cout << sum << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int n, a, sum;
int main() {
  while (true) {
    sum = 0;
    cin >> n;
    n /= 4;
    for (int i = 0; i < n; i++) {
      cin >> a;
      sum += a;
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p00627 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  while (1) {
    int n, k[100005], ans = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n / 4; ++i) {
      cin >> k[i];
      ans += k[i];
    }
    cout << ans << endl;
  }
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  while (1) {
    int n, k[5], ans = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n / 4; ++i) {
      cin >> k[i];
      ans += k[i];
    }
    cout << ans << endl;
  }
}
Problem p00627 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int s = 0, a;
    while (n) {
      n -= 4;
      cin >> a;
      s += a;
    }
    cout << s << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int s = 0, a;
    while (n--) {
      cin >> a;
      s += a;
    }
    cout << s << endl;
  }
}
Problem p00627 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  for (; cin >> n, n;) {
    int sum = 0;
    for (; n > 0; n = n - 4) {
      int tmp;
      cin >> tmp;
      sum += tmp;
    }
    cout << sum << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  for (; cin >> n, n;) {
    int sum = 0;
    for (;; n = n / 5) {
      int tmp;
      cin >> tmp;
      sum += tmp;
    }
    cout << sum << endl;
  }
}
Problem p00627 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int s, n, i, x;
  while (1) {
    scanf("%d", &n);
    if (!n)
      break;
    s = 0;
    for (i = 0; i < n / 4; i++) {
      scanf("%d", &x);
      s += x;
    }
    printf("%d\\n", s);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int s, n, i, x;
  while (1) {
    scanf("%d", &n);
    s = 0;
    for (i = 0; i < n / 4; i++) {
      scanf("%d", &x);
      s += x;
    }
    printf("%d\\n", s);
  }
  return 0;
}
Problem p00627 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
int main() {
  int n;
  std::vector<int> v;
  while (1) {
    std::cin >> n;
    if (n == 0) {
      break;
    }
    int a = 0;
    for (int i = 0; i < n / 4; ++i) {
      int b;
      std::cin >> b;
      a += b;
    }
    v.push_back(a);
  }
  for (int i = 0; i < v.size(); ++i) {
    std::cout << v[i] << std::endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>
int main() {
  std::vector<int> v;
  std::vector<int> y;
  while (1) {
    int n;
    std::cin >> n;
    int a = 0;
    for (int i = 0; i < n / 4; ++i) {
      if (v[i] == 0) {
        break;
      }
      std::cin >> v[i];
      v.push_back(v[i]);
      a += v[i];
    }
    y.push_back(a);
  }
  for (int i = 0; i < y.size(); ++i) {
    std::cout << y[i] << std::endl;
  }
  return 0;
}
Problem p00627 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;

const int mod = 1000000007;

int main() {
  int n;
  while (cin >> n, n) {
    int a = 0, b = 0;
    n /= 4;
    while (n--) {
      cin >> a;
      b += a;
    }
    cout << b << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;

const int mod = 1000000007;

int main() {
  int n;
  while (cin >> n, n) {
    int a, b;
    while (n--) {
      cin >> a;
      b += a;
    }
    cout << b << endl;
  }
}
Problem p00628 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
string S, T;
int chain;
int main() {
  while (true) {
    getline(cin, S);
    S += ' ';
    T = "";
    if (S == "END OF INPUT ") {
      break;
    }
    for (int i = 0; i < S.size(); i++) {
      if (S[i] != ' ') {
        chain++;
      } else {
        T += to_string(chain);
        chain = 0;
      }
    }
    cout << T << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
string S, T;
int chain;
int main() {
  while (true) {
    getline(cin, S);
    S += ' ';
    T = "";
    if (S == "END OF INPUT") {
      break;
    }
    for (int i = 0; i < S.size(); i++) {
      if (S[i] != ' ') {
        chain++;
      } else {
        T += to_string(chain);
        chain = 0;
      }
    }
    cout << T << endl;
  }
}
Problem p00628 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;

  while (getline(cin, str)) {
    if (str == "END OF INPUT")
      break;

    string ans = "";
    int cnt = 0;

    for (int i = 0; i < str.size(); i++) {
      if (i == str.size() - 1)
        ans += cnt + 1 + '0';
      else if (str[i] != ' ')
        cnt++;
      else {
        ans += cnt + '0';
        cnt = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  string s;
  int ans[1000];
  while (getline(cin, s), s != "END OF INPUT") {
    int anscnt = 0;
    for (int i = 0; i < s.size(); i++) {
      int cnt = 0;
      anscnt++;
      while (s[i] != ' ') {
        cnt++;
      }
      ans[anscnt] = cnt;
    }

    for (int i = 0; i < anscnt; i++) {
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}
Problem p00628 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

char *c;
int n;

int main() {
  string s;
  string a = "END OF INPUT";

  while (1) {
    getline(cin, s);
    if (s == a) {
      // cout << endl;
      break;
    }
    n = s.length();
    int series = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == ' ') {
        if (i > 0) {
          if (s[i - 1] == ' ') {
            cout << "0";
            continue;
          }
        }
        cout << series;
        series = 0;
        continue;
      }
      series++;
      if (i == n - 1)
        cout << series;
    }
    cout << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

char *c;
int n;

int main() {
  string s;
  string a = "OUT OF INPUT";

  while (1) {
    getline(cin, s);
    if (s == a) {
      cout << endl;
      break;
    }
    n = s.length();
    int series = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == ' ') {
        if (i > 0) {
          if (s[i - 1] == ' ') {
            cout << "0";
            continue;
          }
        }
        cout << series;
        series = 0;
        continue;
      }
      series++;
      if (i == n - 1)
        cout << series;
    }
    cout << endl;
  }

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

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> I, U, A, P, C;

  while (true) {
    cin >> N;

    if (N == 0) {
      break;
    }

    I = vector<int>(N);
    U = vector<int>(N);
    A = vector<int>(N);
    P = vector<int>(N);

    for (int i = 0; i < N; i++) {
      cin >> I[i] >> U[i] >> A[i] >> P[i];
    }

    C = vector<int>(1001, 0);

    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (A[i] < A[j] || (A[i] == A[j] && P[i] > P[j])) {
          swap(A[i], A[j]);
          swap(P[i], P[j]);
          swap(I[i], I[j]);
          swap(U[i], U[j]);
        }
      }
    }

    int count_ = 0;

    for (int i = 0; i < N; i++) {
      if ((count_ < 10 && C[U[i]] < 3) || (count_ < 20 && C[U[i]] < 2) ||
          (count_ < 26 && C[U[i]] == 0)) {
        cout << I[i] << endl;

        C[U[i]]++;
        count_++;
      }
    }
  }

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> I, U, A, P, C;

  while (true) {
    cin >> N;

    if (N == 0) {
      break;
    }

    for (int i = 0; i < N; i++) {
      cin >> I[i] >> U[i] >> A[i] >> P[i];
    }

    C = vector<int>(1001, 0);

    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (A[i] < A[j] || (A[i] == A[j] && P[i] > P[j])) {
          swap(A[i], A[j]);
          swap(P[i], P[j]);
          swap(I[i], I[j]);
          swap(U[i], U[j]);
        }
      }
    }

    int count_ = 0;

    for (int i = 0; i < N; i++) {
      if ((count_ < 10 && C[U[i]] < 3) || (count_ < 20 && C[U[i]] < 2) ||
          (count_ < 26 && C[U[i]] == 0)) {
        cout << I[i] << endl;

        C[U[i]]++;
        count_++;
      }
    }
  }

  return 0;
}