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

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

int main() {
  double x[4];
  double y[4];
  while (true) {
    for (int i = 0; i < 4; i++) {
      if (!(cin >> x[i] >> y[i]))
        return 0;
    }

    double dx1 = x[1] - x[0];
    double dy1 = y[1] - y[0];
    double dx2 = x[3] - x[2];
    double dy2 = y[3] - y[2];
    double innerProduct = (dx1 * dx2) + (dy1 * dy2);

    if (fabs(innerProduct) < 0.000000000001)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  double x[4];
  double y[4];
  while (true) {
    for (int i = 0; i < 4; i++) {
      if (!(cin >> x[i] >> y[i]))
        break;
    }

    double dx1 = x[1] - x[0];
    double dy1 = y[1] - y[0];
    double dx2 = x[3] - x[2];
    double dy2 = y[3] - y[2];
    double innerProduct = (dx1 * dx2) + (dy1 * dy2);

    if (fabs(innerProduct) < 0.0000001)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

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

#include <cstdio>
int main() {
  double xA, yA, xB, yB, xC, yC, xD, yD;
  while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xA, &yA, &xB, &yB, &xC, &yC, &xD,
               &yD) != EOF) {
    if ((xA - xB) * (xC - xD) + (yA - yB) * (yC - yD) == 0) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}

Error: -11

Fixed submission:

#include <cstdio>
int main() {
  float xA, yA, xB, yB, xC, yC, xD, yD;
  while (scanf("%f%f%f%f%f%f%f%f", xA, yA, xB, yB, xC, yC, xD, yD) != EOF) {
    if ((xA == xB && yC == yD) || (yA == yB && xC == xD)) {
      puts("YES");
      continue;
    } else if (xA == xB || yC == yD || yA == yB || xC == xD) {
      puts("NO");
      continue;
    }
    double AB = (yA - yB) / (xA - xB);
    double CD = (yC - yD) / (xC - xD);
    if (-1 * AB == CD) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}
Problem p00058 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

double eps = 1.0e-10;
int main() {
  double x1, x2, x3, x4, y1, y2, y3, y4;
  while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
               &x4, &y4) == 8) {
    double vec1_x, vec2_x, vec1_y, vec2_y;
    vec1_x = x2 - x1;
    vec1_y = y2 - y1;
    vec2_x = x4 - x3;
    vec2_y = y4 - y3;
    if (fabs(vec2_y * vec1_y + vec2_x * vec1_x) < eps)
      printf("YES\\n");
    else
      printf("NO\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

double eps = 1.0e-5;
int main() {
  double x1, x2, x3, x4, y1, y2, y3, y4;
  while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
               &x4, &y4) != 0) {
    double vec1_x, vec2_x, vec1_y, vec2_y;
    vec1_x = x2 - x1;
    vec1_y = y2 - y1;
    vec2_x = x4 - x3;
    vec2_y = y4 - y3;
    if (fabs(vec2_y * vec1_y + vec2_x * vec1_x) < eps)
      printf("YES\\n");
    else
      printf("NO\\n");
  }
  return 0;
}
Problem p00058 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string in;
  double x[4], y[4];
  while (1) {
    getline(cin, in);
    if (in.length() == 0)
      return 0;
    sscanf(in.c_str(), "%lf %lf %lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1],
           &y[1], &x[2], &y[2], &x[3], &y[3]);
    double v1[2] = {x[1] - x[0], y[1] - y[0]},
           v2[2] = {x[3] - x[2], y[3] - y[2]};
    if (v1[0] * v2[0] + v1[1] * v2[1] == 0.0)
      printf("YES\\n");
    else
      printf("NO\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  double x[4], y[4];
  while (1) {
    for (int i = 0; i < 4; i++)
      if (scanf("%lf %lf", &x[i], &y[i]) != 2)
        break;
    double v1[2] = {x[1] - x[0], y[1] - y[0]},
           v2[2] = {x[3] - x[2], y[3] - y[2]};
    if (v1[0] * v2[0] + v1[1] * v2[1] == 0.0)
      printf("YES\\n");
    else
      printf("NO\\n");
  }
  return 0;
}
Problem p00059 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define range(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rep(i, n) range(i, 0, n)
using namespace std;

typedef complex<double> P;

int main(void) {
  P p[4];
  while (1) {
    rep(i, 4) {
      double x, y;
      cin >> x >> y;
      p[i] = {x, y};
    }
    if (cin.eof())
      break;
    bool ok = true;
    if (p[1].real() < p[2].real())
      ok = false;
    if (p[3].real() < p[0].real())
      ok = false;
    if (p[1].imag() < p[2].imag())
      ok = false;
    if (p[3].imag() < p[0].imag())
      ok = false;
    if (ok)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define range(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rep(i, n) range(i, 0, n)
using namespace std;

typedef complex<double> P;

int main(void) {
  P p[4];
  while (1) {
    rep(i, 4) {
      double x, y;
      cin >> x >> y;
      p[i] = {x, y};
    }
    bool ok = true;
    if (p[1].real() < p[2].real())
      ok = false;
    if (p[3].real() < p[0].real())
      ok = false;
    if (p[1].imag() < p[2].imag())
      ok = false;
    if (p[3].imag() < p[0].imag())
      ok = false;
    if (ok)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
Problem p00059 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

typedef struct {
  double x, y;
} _z;

int main() {

  _z p[4];

  while (cin >> p[0].x >> p[0].y) {
    for (int i = 1; i < 4; i++) {
      cin >> p[i].x >> p[i].y;
    }

    if (p[3].x < p[0].x || p[2].x > p[1].x || p[2].y > p[1].y ||
        p[3].y < p[0].y) {
      cout << "NO" << endl;
    } else
      cout << "YES" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

typedef struct {
  double x, y;
} _z;

int main() {

  _z p[4];

  while (1) {
    for (int i = 0; i < 4; i++) {
      cin >> p[i].x >> p[i].y;
    }

    if (p[3].x < p[0].x || p[2].x > p[1].x || p[2].y > p[1].y ||
        p[3].y < p[0].y) {
      cout << "NO" << endl;
    } else
      cout << "YES" << endl;
  }

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

#include <stdio.h>

int main() {
  double ax, ay, bx, by, cx, cy, dx, dy;
  while (~scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &ax, &ay, &bx, &by, &cx, &cy, &dx,
                &dy)) {
    if (ax > dx || by < cy || cx > bx || dy < ay)
      printf("NO\\n");
    else
      printf("YES\\n");
  }
}

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


Fixed submission:

#include <stdio.h>

int main() {
  int ax, ay, bx, by, cx, cy, dx, dy;
  while (~scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &ax, &ay, &bx, &by, &cx, &cy, &dx,
                &dy)) {
    if ((ax >= dx && by <= cy) || (cx >= bx && dy <= ay))
      printf("NO\\n");
    else
      printf("YES\\n");
  }
}
Problem p00060 (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;
const ld eps = 1e-9;

//// < "d:\\d_download\\visual studio
///2015\\projects\\programing_contest_c++\\debug\\a.txt" > "d:\\d_download\\visual
///studio 2015\\projects\\programing_contest_c++\\debug\\b.txt"

int main() {
  int a, b, c;
  while (cin >> a >> b >> c) {
    int num = 0;
    for (int i = 1; i <= 10; ++i) {
      if (i != a && i != b && i != c) {
        int sum = a + b + i;
        if (sum <= 20)
          num++;
      }
    }
    if (num >= 4)
      cout << "YES" << endl;
    else
      cout << "NO" << 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;
const ld eps = 1e-9;

//// < "d:\\d_download\\visual studio
///2015\\projects\\programing_contest_c++\\debug\\a.txt" > "d:\\d_download\\visual
///studio 2015\\projects\\programing_contest_c++\\debug\\b.txt"

int main() {
  int a, b, c;
  while (scanf("%d %d %d", &a, &b, &c)) {
    int num = 0;
    for (int i = 1; i <= 10; ++i) {
      if (i != a && i != b && i != c) {
        int sum = a + b + i;
        if (sum <= 20)
          num++;
      }
    }
    if (num >= 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00060 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  int x, y, z;
  int c = 0;
  bool f[12];
  while (scanf("%d %d %d", &x, &y, &z) != EOF) {
    for (int i = 0; i < 11; i++)
      f[i] = true;

    f[x] = false;
    f[y] = false;
    f[z] = false;

    for (int i = 1; i < 11; i++) {
      if (f[i] == true) {
        if (x + y + i <= 20)
          c++;
      }
    }

    if (c >= 4)
      printf("YES\\n");

    else
      printf("NO\\n");
    c = 0;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  bool w[11];
  int x, y, z;
  int S = 0, W = 0;
  while (scanf("%d %d %d", &x, &y, &z) != 0) {
    for (int i = 0; i < 12; i++)
      w[i] = true;

    for (int i = 0; i < 12; i++) {
      if (x == i || y == i || z == i)
        w[i] = false;
    }
    for (int i = 1; i < 11; i++) {
      if (w[i] = true) {
        if (i != z && x + y + i > 20)
          W++;
        else if (i != z && x + y + i <= 20)
          S++;
      }
    }

    if (S >= 4)
      printf("YES\\n");
    else if (S < 4)
      printf("NO\\n");
    S = 0, W = 0;
  }
  return 0;
}
Problem p00060 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  char buf;
  int buf_cnt = 0;
  int c[3];
  int my_cards;
  int ok = 0;
  int cnt = 0;
  double probability;
  for (int i = 0; i < 3; i++) {
    c[i] = 0;
  }

  while ((buf = getchar()) != EOF) {
    if (buf >= '0' && buf <= '9') {
      buf -= '0';
      c[buf_cnt] = c[buf_cnt] * 10 + buf;
      continue;
    } else if (buf != '\\n') {
      if (c[buf_cnt] != 0) {
        buf_cnt++;
        continue;
      } else if (buf_cnt < 3) {
        continue;
      }
    } else {
      if (c[2] == 0) {
        for (int i = 0; i < 3; i++) {
          c[i] = 0;
        }
        continue;
      }
    }

    my_cards = c[0] + c[1];

    for (int i = 1; i <= 10; i++) {
      // c[0],2,c3??¨?¢??????´???????????????
      if (i == c[0] || i == c[1] || i == c[2]) {
        continue;
      }

      if (my_cards + i <= 20) {
        ok++;
      }
      cnt++;
    }
    probability = (double)ok / (double)cnt;

    if (probability >= 0.5) {
      printf("YES\\n");
    } else {
      printf("NO\\n");
    }
    for (int i = 0; i < 3; i++) {
      c[i] = 0;
    }
    ok = 0;
    cnt = 0;
    buf_cnt = 0;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  char buf;
  int buf_cnt = 0;
  int c[3];
  int my_cards;
  int ok = 0;
  int cnt = 0;
  double probability;
  for (int i = 0; i < 3; i++) {
    c[i] = 0;
  }

  while ((buf = getchar()) != EOF) {
    if (buf >= '0' && buf <= '9') {
      buf -= '0';
      c[buf_cnt] = c[buf_cnt] * 10 + buf;
      continue;
    } else if (buf != '\\n') {
      if (c[buf_cnt] != 0) {
        buf_cnt++;
        continue;
      } else if (buf_cnt < 3) {
        continue;
      }
    } else {
      if (c[2] == 0) {
        for (int i = 0; i < 3; i++) {
          c[i] = 0;
        }
        continue;
      }
    }

    my_cards = c[0] + c[1];

    for (int i = 1; i <= 10; i++) {
      // c[0],2,c3??¨?¢??????´???????????????
      if (i == c[0] || i == c[1] || i == c[2]) {
        continue;
      }

      if (my_cards + i <= 20) {
        ok++;
      }
      cnt++;
    }
    probability = (double)ok / (double)cnt;

    if (probability >= 0.5) {
      printf("YES\\n");
    } else {
      printf("NO\\n");
    }
    for (int i = 0; i < 3; i++) {
      c[i] = 0;
    }
    ok = 0;
    cnt = 0;
    buf_cnt = 0;
    rewind(stdin);
  }

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

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

using namespace std;

#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define allof(a) (a).begin(), (a).end()

typedef vector<int> vi;

int main() {
  for (int a, b, c; cin >> a >> b >> c;) {
    vi cards;
    repi(i, 1, 10 + 1) if (i != a && i != b && i != c) cards.push_back(i);
    int i = distance(cards.begin(), upper_bound(allof(cards), 20 - a - b));
    if (i >= 4)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int c1, c2, c3, c, d;
  while (1) {
    cin >> c1 >> c2 >> c3;
    if (c1 == 0 && c2 == 0 && c3 == 0)
      return 0;
    d = 0;
    n[c1 - 1] = 11;
    n[c2 - 1] = 11;
    n[c3 - 1] = 11;
    c = 20 - c1 - c2;
    for (int i = 0; i < 10; i++)
      if (n[i] <= c)
        d++;
    if (d > 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    for (int i = 0; i < 10; i++)
      n[i] = i + 1;
  }
  return 0;
}
Problem p00060 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <map>

using namespace std;

int main() {
  int c1, c2, c3, my, count = 0;
  map<int, bool> card;
  while (cin >> c1 >> c2 >> c3) {
    for (int i = 1; i <= 10; i++)
      card[i] = false;
    card[c1] = true;
    card[c2] = true;
    card[c3] = true;
    my = c1 + c2;
    for (int i = 1; i <= 10; i++) {
      if (card[i] == false) {
        if (my + i <= 20) {
          count++;
        }
      }
    }
    if (count >= 4) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    count = 0;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <map>

using namespace std;

int main() {
  int c1, c2, c3, my, count = 0;
  map<int, bool> card;
  for (int i = 1; i <= 10; i++)
    card[i] = false;
  while (scanf("%d %d %d", &c1, &c2, &c3)) {
    card[c1] = true;
    card[c2] = true;
    card[c3] = true;
    my = c1 + c2;
    for (int i = 1; i <= 10; i++) {
      if (card[i] == false) {
        if (my + i <= 20) {
          count++;
        }
      }
    }
    if (count >= 4) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00060 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <fstream>

int main() {
  int C1, C2, C3, counter;
  while (scanf("%d %d %d", &C1, &C2, &C3) != EOF) {
    counter = 0;
    for (int i = 1; i < 11; i++) {
      if ((i != C1 && i != C2 && i != C3) && (C1 + C2 + i <= 20)) {
        counter++;
      }
    }
    if (counter < 4) {
      printf("NO\\n");
    } else {
      printf("YES\\n");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <fstream>

int main() {
  int C1, C2, C3;
  int list[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

  while (scanf("%d%d%d", &C1, &C2, &C3)) {
    int counter = 0;
    for (int i = 0; i < 10; i++) {
      int j = list[i];
      if ((j != C1 && j != C2 && j != C3) && (C1 + C2 + j <= 20)) {
        counter++;
      }
    }
    if (counter < 4) {
      printf("No\\n");
    } else {
      printf("Yes\\n");
    }
  }
  return 0;
}
Problem p00061 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>

typedef std::pair<int, int> Entrant;

bool descending_Entrant(const Entrant &e1, const Entrant &e2) {
  return e1.second > e2.second;
}

int main() {
  int num, points;
  std::vector<Entrant> v;
  std::map<int, int> m;
  while (scanf("%d,%d", &num, &points), num) {
    v.push_back(Entrant(num, points));
  }

  std::sort(v.begin(), v.end(), descending_Entrant);

  int rank = 1;
  for (int i = 0; i < v.size(); i++) {
    m[v[i].first] = rank;
    if (i + 1 < v.size() && v[i].second != v[i + 1].second)
      rank++;
  }

  int n;
  while (~scanf("%d", &n)) {
    printf("%d\\n", m[n]);
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>

typedef std::pair<int, int> Entrant;

bool descending_Entrant(const Entrant &e1, const Entrant &e2) {
  return e1.second > e2.second;
}

int main() {
  int num, points;
  std::vector<Entrant> v;
  std::map<int, int> m;
  while (scanf("%d,%d", &num, &points), num && points) {
    v.push_back(Entrant(num, points));
  }

  std::sort(v.begin(), v.end(), descending_Entrant);

  int rank = 1;
  for (int i = 0; i < v.size(); i++) {
    m[v[i].first] = rank;
    if (i + 1 < v.size() && v[i].second != v[i + 1].second)
      rank++;
  }

  int n;
  while (~scanf("%d", &n)) {
    printf("%d\\n", m[n]);
  }
}
Problem p00061 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int a, b, x[1000], y[1000], p, sum, ok;
char c;
int main() {
  while (cin >> a >> c >> b) {
    if (a + b == 0) {
      break;
    }
    x[a] = b;
    p++;
  }
  sum = 1;
  for (int i = 30; i >= 0; i--) {
    ok = 0;
    for (int j = 1; j <= p; j++) {
      if (x[j] == i) {
        y[j] = sum;
        ok = 1;
      }
    }
    if (ok) {
      sum++;
    }
  }
  while (cin >> a) {
    cout << y[a] << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int a, b, x[1000], y[1000], p, sum, ok;
char c;
int main() {
  while (cin >> a >> c >> b) {
    if (a + b == 0) {
      break;
    }
    x[a] = b;
    p++;
  }
  sum = 1;
  for (int i = 30; i >= 0; i++) {
    ok = 0;
    for (int j = 1; j <= p; j++) {
      if (x[j] == i) {
        y[j] = sum;
        ok = 1;
      }
    }
    if (ok) {
      sum++;
    }
  }
  while (cin >> a) {
    cout << y[a] << endl;
  }
}
Problem p00061 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef pair<int, int> pi;
/*
#define num first
#define score second
*/
bool cmp(pi lhs, pi rhs) { return (lhs.second > rhs.second); }

int main() {
  int n, a;
  vector<pi> p;

  while (scanf("%d,%d", &n, &a), n != 0 || a != 0) {
    p.push_back(make_pair(n, a));
  }

  sort(p.begin(), p.end(), cmp);

  int pt = 31, minnum = 0;
  for (int i = 0; i < p.size(); i++) {
    if (pt == p[i].second) {
      p[i].second = minnum;
    } else {
      pt = p[i].second;
      minnum++;
      p[i].second = minnum;
    }
  }

  /*for (int i = 0; i < p.size(); i++){
          cout << p[i].first << " " << p[i].second << endl;
  }*/

  int team;
  while (scanf("%d", &team) != EOF) {
    for (int i = 0; i < p.size(); i++) {
      if (team == p[i].first) {
        cout << p[i].second << endl;
      }
    }
  }

  return (0);
}

Error: TLE

Fixed submission:

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

typedef pair<int, int> pi;

bool cmp(pi lhs, pi rhs) { return (lhs.second > rhs.second); }

int main() {
  int n, a;
  int c;
  vector<pi> p(100);

  for (int i = 0; n != 0 && a != 0; i++) {
    scanf("%d,%d", &n, &a);
    p[i] = make_pair(n, a);
    c = i;
  }

  sort(p.begin(), p.end(), cmp);

  int pin = 31, minnum = 0;
  for (int i = 0; i < c; i++) {
    if (pin == p[i].second) {
      p[i].second = minnum;
    }

    else if (pin > p[i].second) {
      pin = p[i].second;
      minnum++;
      p[i].second = minnum;
    }
  }

  int team;
  while (scanf("%d", &team) != EOF) {
    cout << p[team].second << endl;
  }
  return (0);
}
Problem p00061 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

struct ST_team {
public:
  int no;
  int score;
  int rank;

public:
  ST_team() {
    no = 0;
    score = 0;
    rank = 0;
  }
  ST_team(int n, int s) {
    no = n;
    score = s;
    rank = 0;
  }
};
typedef struct ST_team team;

bool desc_score(const ST_team &t1, const ST_team &t2) {
  return t1.score > t2.score;
}
bool asc_no(const ST_team &t1, const ST_team &t2) { return t1.no < t2.no; }

int main() {
  vector<team> t;
  char dummy;
  int no, score;

  while (true) {
    cin >> no >> dummy >> score;
    if (no == 0 && score == 0)
      break;
    team tmp_t(no, score);
    t.push_back(tmp_t);
  }

  sort(t.begin(), t.end(), desc_score);

  int curr_rank = 0;
  int curr_score = 100;
  for (vector<team>::iterator it = t.begin(); it != t.end(); it++) {
    if (curr_score > (*it).score) {
      curr_rank++;
      curr_score = (*it).score;
    }
    (*it).rank = curr_rank;
  }

  sort(t.begin(), t.end(), asc_no);

  // for (vector<team>::iterator it = t.begin(); it != t.end(); it++) cout <<
  // (*it).no << ":" << (*it).score << "," << (*it).rank << endl;

  int q;
  while (cin >> q)
    cout << t.at(q - 1).rank << endl;

  return 0;
}

Error: 0

Fixed submission:

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

using namespace std;

struct ST_team {
public:
  int no;
  int score;
  int rank;

public:
  ST_team() {
    no = 0;
    score = 0;
    rank = 0;
  }
  ST_team(int n, int s) {
    no = n;
    score = s;
    rank = 0;
  }
};
typedef struct ST_team team;

bool desc_score(const ST_team &t1, const ST_team &t2) {
  return t1.score > t2.score;
}
bool asc_no(const ST_team &t1, const ST_team &t2) {
  return t1.score > t2.score;
}

int main() {
  vector<team> t;
  char dummy;
  int no, score;

  while (true) {
    cin >> no >> dummy >> score;
    if (no == 0 && score == 0)
      break;
    team tmp_t(no, score);
    t.push_back(tmp_t);
  }

  sort(t.begin(), t.end(), desc_score);

  int curr_rank = 0;
  int curr_score = 100;
  for (vector<team>::iterator it = t.begin(); it != t.end(); it++) {
    if (curr_score > (*it).score) {
      curr_rank++;
      curr_score = (*it).score;
    }
    (*it).rank = curr_rank;
  }

  sort(t.begin(), t.end(), asc_no);

  int q;
  while (cin >> q)
    cout << t.at(q).rank << endl;

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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  map<int, int> M;
  vector<pair<int, int>> V;
  int a, b;
  while (scanf("%d,%d", &a, &b), a || b) {
    V.push_back(make_pair(b, a));
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  int buf = 100, cnt = 0;
  for (int i = 0; i < V.size(); i++) {
    if (buf > V[i].first) {
      buf = V[i].first;
      cnt++;
    }
    M[buf] = cnt;
  }
  int n;
  while (cin >> n) {
    int p;
    for (int j = 0; j < V.size(); j++) {
      if (V[j].second == n) {
        p = j;
        break;
      }
    }
    cout << M[V[p].first] << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  map<int, int> M;
  vector<pair<int, int>> V;
  int a, b;
  while (scanf("%d,%d", &a, &b), a && b) {
    V.push_back(make_pair(b, a));
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  int buf = 100, cnt = 0;
  for (int i = 0; i < V.size(); i++) {
    if (buf > V[i].first) {
      buf = V[i].first;
      cnt++;
    }
    M[buf] = cnt;
  }
  int n;
  while (cin >> n) {
    int p;
    for (int j = 0; j < V.size(); j++) {
      if (V[j].second == n) {
        p = j;
        break;
      }
    }
    cout << M[V[p].first] << endl;
  }
}