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

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
long long fn(long long p, long long q) {
  long long s;
  while (q) {
    p %= q;
    s = p;
    p = q;
    q = s;
  }
  return p;
}
int main() {
  int i, j, k;
  int n;
  while (cin >> n && n) {
    long long a[31400], b[31400];
    j = 0;
    k = 0;
    for (i = 0; i < n * (n + 1) / 2; i++) {
      long long p;
      cin >> p;
      if (p % 2) {
        a[j] = p;
        j++;
      } else {
        b[k] = p;
        k++;
      }
    }
    sort(a, a + j);
    sort(b, b + k);
    long long c = fn(a[0], b[0]);
    c = (long long)sqrt(b[0] / c * (b[1] / (a[0] / c)));
    cout << c << endl;
    for (i = 0; i < k - 1; i++)
      cout << b[i] / c << " ";
    cout << b[i] / c << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
long long fn(long long p, long long q) {
  long long s;
  while (q) {
    p %= q;
    s = p;
    p = q;
    q = s;
  }
  return p;
}
int main() {
  int i, j, k;
  int n;
  while (cin >> n && n) {
    long long a[31400], b[31400];
    j = 0;
    k = 0;
    for (i = 0; i < n * (n + 1) / 2; i++) {
      long long p;
      cin >> p;
      if (p % 2) {
        a[j] = p;
        j++;
      } else {
        b[k] = p;
        k++;
      }
    }
    sort(a, a + j);
    sort(b, b + k);
    long long c = b[0];
    for (i = 1; i < k; i++)
      c = fn(c, b[i]);
    for (; a[0] != (b[0] / c) * (b[1] / c); c /= 2)
      ;
    cout << c << endl;
    for (i = 0; i < k - 1; i++)
      cout << b[i] / c << " ";
    cout << b[i] / c << endl;
  }
  return 0;
}
Problem p00654 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

long long gcd(unsigned long long int x, unsigned long long int y) {
  return y == 0 ? x : gcd(y, x % y);
}

void solve() {
  int n;
  while (cin >> n, n) {
    int size = (n + 1) * n / 2;
    vector<unsigned long long int> Vecodd;
    vector<unsigned long long int> Veceven;
    for (int i = 0; i < size; ++i) {
      unsigned long long int temp;
      cin >> temp;
      if (temp % 2 == 0) {
        Veceven.push_back(temp);
      } else {
        Vecodd.push_back(temp);
      }
    }
    sort(Veceven.begin(), Veceven.end());
    sort(Vecodd.begin(), Vecodd.end());
    unsigned long long int minodd = Vecodd[0];
    unsigned long long int mineven[2] = {Veceven[0], Veceven[1]};
    unsigned long long int g = gcd(mineven[0], minodd);
    unsigned long long int Even = (unsigned long long int)sqrt(
        (double)mineven[0] / g * (mineven[1] / (minodd / g)));
    cout << Even << endl;
    size = Veceven.size();
    for (int i = 0; i < size - 1; ++i) {
      cout << Veceven[i] / Even << " ";
    }
    cout << Veceven[size - 1] / Even << endl;
  }
}

int main() {
  solve();
  return (0);
}

Error: 0

Fixed submission:

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

using namespace std;

long long gcd(unsigned long long int x, unsigned long long int y) {
  return y == 0 ? x : gcd(y, x % y);
}

void solve() {
  int n;
  while (cin >> n, n) {
    int size = (n + 1) * n / 2;
    vector<unsigned long long int> Vecodd;
    vector<unsigned long long int> Veceven;
    for (int i = 0; i < size; ++i) {
      int temp;
      cin >> temp;
      if (temp % 2 == 0) {
        Veceven.push_back(temp);
      } else {
        Vecodd.push_back(temp);
      }
    }
    sort(Veceven.begin(), Veceven.end());
    sort(Vecodd.begin(), Vecodd.end());
    unsigned long long int minodd = Vecodd[0];
    unsigned long long int mineven[2] = {Veceven[0], Veceven[1]};
    unsigned long long int g = gcd(mineven[0], minodd);
    unsigned long long int Even = (unsigned long long int)sqrt(
        (double)mineven[0] / g * (mineven[1] / (minodd / g)));
    cout << Even << endl;
    size = Veceven.size();
    for (int i = 0; i < size - 1; ++i) {
      cout << Veceven[i] / Even << " ";
    }
    cout << Veceven[size - 1] / Even << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00654 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;

ll calc(ll x, ll y) {
  if (y == 0) {
    return x;
  } else {
    return calc(y, x % y);
  }
}

void func() {

  vector<ll> GU, KI;
  ll tmp;

  int limit = (N * (N + 1)) / 2;

  for (int i = 0; i < limit; i++) {
    scanf("%lld", &tmp);
    if (tmp % 2 == 0)
      GU.push_back(tmp);
    else {
      KI.push_back(tmp);
    }
  }

  sort(GU.begin(), GU.end());
  sort(KI.begin(), KI.end());

  ll GU_0 = GU[0], GU_1 = GU[1], KI_0 = KI[0];

  ll common;
  if (GU_0 >= KI_0) {
    common = calc(GU_0, KI_0);
  } else {
    common = calc(KI_0, GU_0);
  }

  GU_0 /= common;
  KI_0 /= common;

  if (GU_1 >= KI_0) {
    common = calc(GU_1, KI_0);
  } else {
    common = calc(KI_0, GU_1);
  }

  GU_1 /= common;
  KI_0 /= common;

  ll ans_GU = sqrt((GU_0 * GU_1) / KI_0);

  printf("%lld\\n", ans_GU);
  printf("%lld", GU[0] / ans_GU);
  for (int i = 1; i < GU.size(); i++) {
    printf(" %lld", GU[i] / ans_GU);
  }
  printf("\\n");
}

int main() {

  while (true) {
    scanf("%d", &N);
    if (N == 0)
      break;

    func();
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;

void func() {

  vector<ll> GU, KI;
  ll tmp;

  int limit = (N * (N + 1)) / 2;

  for (int i = 0; i < limit; i++) {
    scanf("%lld", &tmp);
    if (tmp % 2 == 0)
      GU.push_back(tmp);
    else {
      KI.push_back(tmp);
    }
  }

  sort(GU.begin(), GU.end());
  sort(KI.begin(), KI.end());

  ll ans_GU = sqrt((GU[0] * GU[1]) / KI[0]);

  printf("%lld\\n", ans_GU);
  printf("%lld", GU[0] / ans_GU);
  for (int i = 1; i < GU.size(); i++) {
    printf(" %lld", GU[i] / ans_GU);
  }
  printf("\\n");
}

int main() {

  while (true) {
    scanf("%d", &N);
    if (N == 0)
      break;

    func();
  }

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

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

#define int long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for (int i = 0; i < (n); i++)
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int n, N;
vector<int> even_b, odd_b;

bool check(double x) {
  vector<double> a(2);
  Rep(i, 2) a[i] = (double)even_b[i] / x;
  if (a[0] * a[1] > (double)odd_b[0])
    return false;
  else
    return true;
}

bool check_last(int x) {
  vector<int> a(2);
  Rep(i, 2) {
    if (even_b[i] % x)
      return false;
    a[i] = even_b[i] / x;
  }
  if (a[0] * a[1] == odd_b[0])
    return true;
  else
    return false;
}

signed main() {
  while (cin >> n, n) {
    N = n * (n + 1) / 2;
    even_b.clear();
    odd_b.clear();

    Rep(i, N) {
      int b;
      cin >> b;
      if (b % 2)
        odd_b.pb(b);
      else
        even_b.pb(b);
    }

    sort(All(even_b));
    sort(All(odd_b));

    double l = 1.0, r = (1 << 31) - 1;
    int cnt = 100;
    while (cnt--) {
      double mid = (r + l) / 2.0;
      if (check(mid))
        r = mid;
      else
        l = mid;
    }

    // cout << r << endl;
    int ans = (double)r - 1;
    while (1) {
      if (ans % 2)
        ans++;
      if (check_last(ans))
        break;
    }

    cout << ans << endl;
    Rep(i, n) {
      if (i)
        cout << " ";
      cout << even_b[i] / ans;
    }
    cout << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

#define int long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for (int i = 0; i < (n); i++)
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int n, N;
vector<int> even_b, odd_b;

bool check(double x) {
  vector<double> a(2);
  Rep(i, 2) a[i] = (double)even_b[i] / x;
  if (a[0] * a[1] > (double)odd_b[0])
    return false;
  else
    return true;
}

bool check_last(int x) {
  vector<int> a(2);
  Rep(i, 2) {
    if (even_b[i] % x)
      return false;
    a[i] = even_b[i] / x;
  }
  if (a[0] * a[1] == odd_b[0])
    return true;
  else
    return false;
}

signed main() {
  while (cin >> n, n) {
    N = n * (n + 1) / 2;
    even_b.clear();
    odd_b.clear();

    Rep(i, N) {
      int b;
      cin >> b;
      if (b % 2)
        odd_b.pb(b);
      else
        even_b.pb(b);
    }

    sort(All(even_b));
    sort(All(odd_b));

    double l = 1.0, r = (1 << 30) - 1;
    int cnt = 100;
    while (cnt--) {
      double mid = (r + l) / 2.0;
      if (check(mid))
        r = mid;
      else
        l = mid;
    }

    int ans = (double)r - 1;
    while (1) {
      if (ans % 2)
        ans++;
      if (check_last(ans))
        break;
    }

    cout << ans << endl;
    Rep(i, n) {
      if (i)
        cout << " ";
      cout << even_b[i] / ans;
    }
    cout << endl;
  }

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

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

using namespace std;

#define ll long long

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main(void) {
  int n;
  while (cin >> n && n) {
    ll evens[n];
    ll odds[n * (n - 1) / 2];
    ll g, tmp;
    ll oindex = 0, eindex = 0;
    for (int i = 0; i < n * (n + 1) / 2; i++) {
      cin >> tmp;
      tmp % 2 ? odds[oindex++] = tmp : evens[eindex++] = tmp;
    }
    sort(evens, evens + n);
    sort(odds, odds + n * (n - 1) / 2);
    tmp = gcd(evens[0], odds[0]);
    g = (ll)sqrt(evens[0] / tmp * (evens[1] / (odds[0] / tmp)));
    cout << g << endl;
    for (int i = 0; i < n - 1; i++) {
      cout << (ll)round((double)evens[i] / g) << " ";
    }
    cout << (ll)round((double)evens[n - 1] / g) << endl;
  }
}

Error: 0

Fixed submission:

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

using namespace std;

#define ll long long

ll gcd(ll a, ll b) { return b == 0 ? gcd(b, a % b) : a; }

int main(void) {
  int n;
  // ll evens[251];
  // ll odds[251*250/2];
  while (cin >> n && n) {
    ll evens[n];
    ll odds[n * (n - 1) / 2];
    ll g, tmp;
    ll oindex = 0, eindex = 0;
    for (int i = 0; i < n * (n + 1) / 2; i++) {
      cin >> tmp;
      tmp % 2 ? odds[oindex++] = tmp : evens[eindex++] = tmp;
    }
    sort(evens, evens + n);
    sort(odds, odds + n * (n - 1) / 2);
    tmp = gcd(evens[0], odds[0]);
    g = (ll)sqrt(evens[0] / tmp * (evens[1] / (odds[0] / tmp)));
    cout << g << endl;
    for (int i = 0; i < n - 1; i++) {
      cout << (ll)round((double)evens[i] / g) << " ";
    }
    cout << (ll)round((double)evens[n - 1] / g) << endl;
  }
}
Problem p00654 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>

#define MAXX 65555

unsigned long long gcd(const unsigned long long &a,
                       const unsigned long long &b) {
  return b ? gcd(b, a % b) : a;
}

unsigned long long n, i, j, k, m;
unsigned long long num[MAXX], g;
std::vector<unsigned long long> ev, od;

int main() {
  ev.reserve(MAXX);
  od.reserve(MAXX);
  while (scanf("%llu", &n), n) {
    m = n * (n + 1) / 2;
    ev.resize(0);
    od.resize(0);
    for (i = 0; i < m; ++i) {
      scanf("%llu", num + i);
      if (!(num[i] & 1))
        ev.push_back(num[i]);
      else
        od.push_back(num[i]);
    }
    std::sort(ev.begin(), ev.end());
    std::sort(od.begin(), od.end());
    g = ev[0];
    for (i = 1; i < ev.size(); ++i)
      g = gcd(g, ev[i]);
    k = od[0] / (ev[0] / g) / (ev[1] / g);
    g /= sqrt(k);
    printf("%llu\\n%llu", g, ev[0] / g);
    for (i = 1; i < ev.size(); ++i)
      printf(" %llu", ev[i] / g);
    puts("");
  }
  return 0;
}

Error: 0

Fixed submission:

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

#define MAXX 65555

unsigned long long gcd(const unsigned long long &a,
                       const unsigned long long &b) {
  return b ? gcd(b, a % b) : a;
}

unsigned long long n, i, j, k, m;
unsigned long long num[MAXX], g;
std::vector<unsigned long long> ev, od;

int main() {
  ev.reserve(MAXX);
  od.reserve(MAXX);
  while (scanf("%llu", &n), n) {
    m = n * (n + 1) / 2;
    ev.resize(0);
    od.resize(0);
    for (i = 0; i < m; ++i) {
      scanf("%llu", num + i);
      if (!(num[i] & 1))
        ev.push_back(num[i]);
      else
        od.push_back(num[i]);
    }
    std::sort(ev.begin(), ev.end());
    std::sort(od.begin(), od.end());
    g = ev[0];
    for (i = 1; i < ev.size(); ++i)
      g = gcd(g, ev[i]);
    k = (ev[0] / g) * (ev[1] / g) / od[0];
    g /= k;
    printf("%llu\\n%llu", g, ev[0] / g);
    for (i = 1; i < ev.size(); ++i)
      printf(" %llu", ev[i] / g);
    puts("");
  }
  return 0;
}
Problem p00657 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * Author: FreeIdea
 * Created Time:  2011/8/22 12:39:40
 * File Name: k.cpp
 */
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
const int maxint = -1u >> 1;
template <class T> bool get_max(T &a, const T &b) {
  return b > a ? a = b, 1 : 0;
}
template <class T> bool get_min(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}

int r, c;

int main() {
  while (scanf("%d%d", &r, &c) == 2) {
    if (r == 0 && c == 0)
      break;
    if ((r * c) % 2)
      printf("no\\n");
    else
      printf("yes\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxn 30010
#define eps 1e-10
struct Nodes {
  double l, r;
} line[maxn];
struct Point {
  double x, y;
} p[maxn];
int n, m, w, h;
int S;
int sum[maxn], pos[maxn];
double area[maxn];
double cross(Point a, Point b, Point c) {
  double dx1 = b.x - a.x, dx2 = c.x - a.x, dy1 = b.y - a.y, dy2 = c.y - a.y;
  return dx1 * dy2 - dy1 * dx2;
}
int check(int id, int now) {
  Point a, b, c;
  a.x = 0;
  a.y = line[id].l;
  b.x = w;
  b.y = line[id].r;
  c = p[now];
  if (cross(a, c, b) > 0)
    return 1;
  return 0;
}
double Area(int id1, int id2) {
  return (line[id2].l - line[id1].l + line[id2].r - line[id1].r) * w / 2.0;
}
int min(int x, int y) { return x < y ? x : y; }
int main() {
  int i, j, k;
  int L, R, mid;
  int ans;
  while (scanf("%d%d%d%d%d", &n, &m, &w, &h, &S), n || m || w || h || S) {
    for (i = 1; i <= m; i++) {
      scanf("%lf%lf", &line[i].l, &line[i].r);
    }
    for (i = 1; i <= n; i++) {
      scanf("%lf%lf", &p[i].x, &p[i].y);
    }
    memset(sum, 0, sizeof(sum));
    sum[0] = 0;
    line[0].l = line[0].r = 0;
    for (i = 1; i <= n; i++) {
      L = 0;
      R = m;
      while (L <= R) {
        mid = (L + R) / 2;
        if (check(mid, i)) {
          pos[i] = mid;
          R = mid - 1;
        } else
          L = mid + 1;
      }
      sum[pos[i]]++;
    }
    area[0] = 0;
    for (i = 1; i <= m; i++) {
      sum[i] += sum[i - 1];
      area[i] = area[i - 1] + Area(i - 1, i);
    }
    if (S == 0) {
      printf("0\\n");
      continue;
    }
    if (S == w * h) {
      printf("%d\\n", n);
      continue;
    }
    S = w * h - S;
    ans = n;
    for (i = 1; i <= m; i++) {
      // if(area[i]>S-eps){

      k = lower_bound(area, area + m + 1, area[i] - S - eps) - area;
      // printf("%d %lf %d %d %d\\n",i,area[i],k,sum[k-1],sum[i]);
      ans = min(ans, n - sum[i] + sum[k]);
      //}
    }
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p00657 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int r, c;
int main() {
  while (true) {
    cin >> r >> c;
    if (r == 0 && c == 0) {
      break;
    }
    if (r % 2 == 1 && c % 2 == 1) {
      cout << "no" << endl;
    } else {
      cout << "yes" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int r, c;
int main() {
  while (true) {
    cin >> r >> c;
    if (r % 2 == 1 && c % 2 == 1) {
      cout << "no" << endl;
    } else {
      cout << "yes" << endl;
    }
  }
  return 0;
}
Problem p00659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
static inline lint inl() {
  lint x;
  scanf("%lld", &x);
  return x;
}
template <typename T> void show(T &a, char del = '\\n', char last = '\\n') {
  rep(i, a.size() - 1) cout << a[i] << del;
  cout << a[a.size() - 1] << last;
}

int main() {
  int n;
  while (n = in()) {
    vector<string> names;
    int table[64][64] = {};
    int table_size[64] = {};
    rep(i, n) {
      string name;
      cin >> name;
      names.push_back(name);
      rep(j, in()) {
        int v = in();
        table[v][table_size[v]] = i;
        table_size[v]++;
      }
    }
    vector<int> score(n, 0);
    rep(i, 64) {
      rep(j, table_size[i]) { score[table[i][j]] += n + 1 - table_size[i]; }
    }
    vector<pair<int, string>> res;
    rep(i, n) { res.push_back(make_pair(score[i], names[i])); }
    sort(res.begin(), res.end());
    cout << res[0].first << " " << res[0].second << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
static inline lint inl() {
  lint x;
  scanf("%lld", &x);
  return x;
}
template <typename T> void show(T &a, char del = '\\n', char last = '\\n') {
  rep(i, a.size() - 1) cout << a[i] << del;
  cout << a[a.size() - 1] << last;
}

int main() {
  int n;
  while (n = in()) {
    vector<string> names;
    vector<vector<int>> table;
    rep(i, 64) table.push_back(vector<int>());
    rep(i, n) {
      string name;
      cin >> name;
      names.push_back(name);
      rep(j, in()) { table[in() - 1].push_back(i); }
    }
    vector<int> score(n, 0);
    rep(i, 64) {
      rep(j, table[i].size()) { score[table[i][j]] += n + 1 - table[i].size(); }
    }
    vector<pair<int, string>> res;
    rep(i, n) { res.push_back(make_pair(score[i], names[i])); }
    sort(res.begin(), res.end());
    cout << res[0].first << " " << res[0].second << endl;
    vector<vector<int>>().swap(table);
  }
  return 0;
}
Problem p00659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define N 20
#define M 31
using namespace std;
typedef pair<string, int> P;

int n, cnt[M], point[N], k, m, tim, minp;
vector<P> t[N];
string s;

int main() {
  while (1) {
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < M; i++)
      cnt[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      cin >> m;
      t[i].push_back(P(s, -1));
      for (int j = 0; j < m; j++) {
        cin >> tim;
        t[i].push_back(P(s, tim));
        cnt[tim]++;
      }
      point[i] = 0;
    }
    minp = (1e9);
    sort(t, t + n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < t[i].size(); j++) {
        int idx = t[i][j].second;
        if (idx == -1)
          continue;
        point[i] += n - cnt[idx] + 1;
      }
      minp = min(minp, point[i]);
    }
    for (int i = 0; i < n; i++) {
      if (minp == point[i]) {
        cout << minp << ' ' << t[i][0].first << endl;
        break;
      }
    }
    for (int i = 0; i < n; i++)
      t[i].clear();
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define N 20
#define M 31
using namespace std;
typedef pair<string, int> P;

int n, cnt[M], point[N], k, m, tim, minp;
vector<P> t[N];
string s;

int main() {
  while (1) {
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < M; i++)
      cnt[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      cin >> m;
      for (int j = 0; j < m; j++) {
        cin >> tim;
        t[i].push_back(P(s, tim));
        cnt[tim]++;
      }
      point[i] = 0;
    }
    minp = (1e9);
    sort(t, t + n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < t[i].size(); j++) {
        int idx = t[i][j].second;
        point[i] += n - cnt[idx] + 1;
      }
      minp = min(minp, point[i]);
    }
    vector<string> v;
    for (int i = 0; i < n; i++) {
      if (minp == point[i]) {
        v.push_back(t[i][0].first);
        break;
      }
    }
    sort(v.begin(), v.end());
    cout << minp << ' ' << v[0] << endl;
    for (int i = 0; i < n; i++)
      t[i].clear();
  }
  return 0;
}
Problem p00661 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iomanip>
#include <iostream>
using namespace std;
int n, m, p;
int main() {
  while (cin >> n >> m, n) {
    int f = 0;
    for (int i = 0; i < m; i++) {
      cin >> p;
      if (p == 1)
        f = 1;
    }
    long double r = f ? 0 : n / 2.0;
    cout << fixed << setprecision(15) << r << endl;
  }
}

Error: TLE

Fixed submission:

#include <iomanip>
#include <iostream>
using namespace std;
int n, m, p[22];
int main() {
  while (cin >> n >> m, n) {
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int f = 0;
    for (int i = 0; i < m; i++) {
      if (p[i] == 1)
        f = 1;
    }
    long double r = f ? 0 : n / 2.0;
    cout << fixed << setprecision(15) << r << endl;
  }
}