prithivMLmods/Coder-Stat huggingface dataset:
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }

  vector<int> h(n, 0);
  for (int i = 0; i < m; i++) {
    h[a[i]]++;
    h[b[i]]++;
  }

  for (int i = 1; i <= n; i++) {
    cout << h[i] << endl;
  }

  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }

  vector<int> h(n + 1, 0);
  for (int i = 0; i < m; i++) {
    h[a[i]]++;
    h[b[i]]++;
  }

  for (int i = 1; i <= n; i++) {
    cout << h[i] << endl;
  }

  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;

int main() {

  int ci, ro;
  cin >> ci >> ro;

  vector<int> counter(ci);

  for (int r = 0; r < ro; r++) {
    int c1, c2;
    cin >> c1 >> c2;
    counter.at(c1)++;
    counter.at(c2)++;
  }

  for (int i = 0; i < ci; i++) {
    cout << counter.at(i) << endl;
  }
}

Fixed submission:
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;

int main() {

  int ci, ro;
  cin >> ci >> ro;

  vector<int> counter(ci);

  for (int r = 0; r < ro; r++) {
    int c1, c2;
    cin >> c1 >> c2;
    counter.at(c1 - 1) += 1;
    counter.at(c2 - 1) += 1;
  }

  for (int i = 0; i < ci; i++) {
    cout << counter.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int t, s;
  for (int i = 0; i < m; i++) {
    cin >> t >> s;
    a[t]++;
    a[s]++;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int t, s;
  for (int i = 0; i < m; i++) {
    cin >> t >> s;
    t--;
    s--;
    a[t]++;
    a[s]++;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  const int nmmax = 50;
  int a[nmmax], b[nmmax];

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

  int road[nmmax];
  for (int i = 0; i < n; i++) {
    road[i] = 0;
  }

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

  for (int i = 0; i < n; i++) {
    cout << road[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  const int nmmax = 50;
  int a[nmmax], b[nmmax];

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

  int road[nmmax];
  for (int i = 0; i < n; i++) {
    road[i] = 0;
  }

  for (int i = 0; i < m; i++) {
    road[a[i] - 1]++;
    road[b[i] - 1]++;
  }

  for (int i = 0; i < n; i++) {
    cout << road[i] << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> a(m), b(m), road(n, 0);
  for (int i = 0; i < m; i++) {
    std::cin >> a[m] >> b[m];
    road[a[m] - 1] += 1;
    road[b[m] - 1] += 1;
  }
  for (int i = 0; i < n; i++) {
    std::cout << road[i] << '\n';
  }
}


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

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> a(m), b(m), road(n, 0);
  for (int i = 0; i < m; i++) {
    std::cin >> a[i] >> b[i];
    road[a[i] - 1] += 1;
    road[b[i] - 1] += 1;
  }
  for (int i = 0; i < n; i++) {
    std::cout << road[i] << '\n';
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int m, n, a, b;
  cin >> m >> n;
  vector<int> x(n, 0);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    x[a - 1]++, x[b - 1]++;
  }
  for (auto i : x) {
    cout << i << endl;
  }
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int m, n, a, b;
  cin >> n >> m;
  vector<int> x(n, 0);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    x[a - 1]++, x[b - 1]++;
  }
  for (auto i : x) {
    cout << i << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;

int main() {
  vector<int> a(100);
  vector<int> b(50);
  int N, M, i;

  cin >> N >> M;

  for (i = 0; i < M * 2; i++) {
    cin >> a.at(i);
  }
  for (i = 0; i < M * 2; i++) {
    if (b.at(a.at(i)) == 0) {
      for (int j = 0; j < M * 2; j++) {
        if (a.at(i) == a.at(j)) {
          b.at(a.at(i))++;
        }
      }
    }
  }

  for (i = 1; i <= N; i++) {
    cout << b.at(i) << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;

int main() {
  vector<int> a(101);
  vector<int> b(51);
  int N, M, i;

  cin >> N >> M;

  for (i = 0; i < M * 2; i++) {
    cin >> a.at(i);
  }
  for (i = 0; i < M * 2; i++) {
    if (b.at(a.at(i)) == 0) {
      for (int j = 0; j < M * 2; j++) {
        if (a.at(i) == a.at(j)) {
          b.at(a.at(i))++;
        }
      }
    }
  }

  for (i = 1; i <= N; i++) {
    cout << b.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> ab[50];

  rep(i, m) {
    int t, s;
    cin >> s >> t;
    ab[s].push_back(t);
    ab[t].push_back(s);
  }

  for (int i = 1; i <= n; i++) {
    cout << ab[i].size() << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> ab[51];

  rep(i, m) {
    int t, s;
    cin >> s >> t;
    ab[s].push_back(t);
    ab[t].push_back(s);
  }

  for (int i = 1; i <= n; i++) {
    cout << ab[i].size() << endl;
  }

  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> town(n + 1, 0);

  rep(i, m) {
    cin >> a >> b;
    if (a == b)
      town.at(a)++;
    else {
      town.at(a)++;
      town.at(b)++;
    }
  }
  rep(i, n + 1) { cout << town.at(i + 1) << endl; }
}


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

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> town(n + 1, 0);

  rep(i, m) {
    cin >> a >> b;
    if (a == b)
      town.at(a)++;
    else {
      town.at(a)++;
      town.at(b)++;
    }
  }
  rep(i, n) { cout << town.at(i + 1) << endl; }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    road.at(a)++;
    road.at(b)++;
  }
  for (int i = 0; i < N; i++)
    cout << road.at(i) << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    road.at(a - 1)++;
    road.at(b - 1)++;
  }
  for (int i = 0; i < N; i++)
    cout << road.at(i) << endl;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> a(N);
  vector<int> b(N);

  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (a.at(j) == i + 1)
        cnt++;
      if (b.at(j) == i + 1)
        cnt++;
    }
    cout << cnt << endl;
    cnt = 0;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> a(M);
  vector<int> b(M);

  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (a.at(j) == i + 1)
        cnt++;
      if (b.at(j) == i + 1)
        cnt++;
    }
    cout << cnt << endl;
    cnt = 0;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> vec1(0);
  vector<int> vec2(n);
  for (int i = 0; i < m * 2; i++) {
    cin >> a;
    vec1.push_back(a);
  }
  for (int i = 0; i < m * 2; i++) {
    b = vec1.at(i);
    vec2.at(b)++;
  }
  for (int i = 0; i < n; i++) {
    cout << vec2.at(i) << endl;
  }
}


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

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> vec1(0);
  vector<int> vec2(n);
  for (int i = 0; i < m * 2; i++) {
    cin >> a;
    vec1.push_back(a);
  }
  for (int i = 0; i < m * 2; i++) {
    b = vec1.at(i);
    vec2.at(b - 1) = vec2.at(b - 1) + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << vec2.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;

int n, m;
vector<int> sum(50);

int main() {
  cin >> n >> m;
  int a, b;
  rep(i, m) {
    cin >> a >> b;
    sum[a]++;
    sum[b]++;
  }
  rrep(i, n) cout << sum[i] << endl;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;

int n, m;
vector<int> sum(55);

int main() {
  cin >> n >> m;
  int a, b;
  rep(i, m) {
    cin >> a >> b;
    sum[a]++;
    sum[b]++;
  }
  rrep(i, n) cout << sum[i] << endl;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> R(N, 0);
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    R[a]++;
    R[b]++;
  }
  for (int i = 0; i < N; i++) {
    cout << R[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> R(N, 0);
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    R[a - 1]++;
    R[b - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << R[i] << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, a, b;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    vec.at(a)++;
    vec.at(b)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
  return 0;
}


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

int main() {
  int N, M, a, b;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    vec.at(a - 1)++;
    vec.at(b - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    vec.at(a) += 1;
    vec.at(b) += 1;
  }

  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    vec.at(a - 1) += 1;
    vec.at(b - 1) += 1;
  }

  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define INF (1 << 31) // INT_MAX/2
#define MOD 1000000007

using ll = long long;
using ull = unsigned long long;

int main(int argc, char *argv[]) {
  int N, M;
  std::cin >> N >> M;

  std::vector<int> a(M);
  std::vector<int> b(M);
  for (int i = 0; i < M; i++) {
    std::cin >> a[i] >> b[i];
  }

  std::vector<int> num(50, 0);
  for (int i = 0; i < M; i++) {
    num[a[i]]++;
    num[b[i]]++;
  }

  for (int i = 1; i <= N; i++) {
    std::cout << num[i] << std::endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define INF (1 << 31) // INT_MAX/2
#define MOD 1000000007

using ll = long long;
using ull = unsigned long long;

int main(int argc, char *argv[]) {
  int N, M;
  std::cin >> N >> M;

  std::vector<int> a(M);
  std::vector<int> b(M);
  for (int i = 0; i < M; i++) {
    std::cin >> a[i] >> b[i];
  }

  std::vector<int> num(51, 0);
  for (int i = 0; i < M; i++) {
    num[a[i]]++;
    num[b[i]]++;
  }

  for (int i = 1; i <= N; i++) {
    std::cout << num[i] << std::endl;
  }

  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }

  int count;
  for (int i = 0; i < N; i++) {
    count = 0;
    for (int j = 0; j < M; j++) {

      if (A.at(j) == i + 1 || B.at(j) == i + 1) {
        count++;
      }
    }
    cout << count << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
  }

  int count;
  for (int i = 0; i < N; i++) {
    count = 0;
    for (int j = 0; j < M; j++) {

      if (A.at(j) == i + 1 || B.at(j) == i + 1) {
        count++;
      }
    }
    cout << count << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> sum(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    sum[a]++;
    sum[b]++;
  }
  REP(i, N) cout << sum[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> sum(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    sum[a - 1]++;
    sum[b - 1]++;
  }
  REP(i, N) cout << sum[i] << endl;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> a(M);
  vector<int> b(M);
  vector<int> n(N);

  for (int i = 0; i < M; i++)
    cin >> a.at(i) >> b.at(i);
  for (int i = 0; i < N; i++) {
    n.at(i) = 0;
    for (int j = 0; j < N; j++) {
      if (a.at(j) == i + 1)
        n.at(i)++;
      if (b.at(j) == i + 1)
        n.at(i)++;
    }
    cout << n.at(i) << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> a(M);
  vector<int> b(M);
  vector<int> n(N);

  for (int i = 0; i < M; i++)
    cin >> a.at(i) >> b.at(i);
  for (int i = 0; i < N; i++) {
    n.at(i) = 0;
    for (int j = 0; j < M; j++) {
      if (a.at(j) == i + 1)
        n.at(i)++;
      if (b.at(j) == i + 1)
        n.at(i)++;
    }
    cout << n.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    vec.at(a) += 1;
    vec.at(b) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    vec.at(a - 1) += 1;
    vec.at(b - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main(void) {
  int N, M;

  std::cin >> N >> M;
  std::vector<int> town(N, 0);
  for (int i = 0; i < M; ++i) {
    int t1, t2;
    std::cin >> t1 >> t2;
    town[t1]++;
    town[t2]++;
  }

  for (int i = 0; i < N; ++i) {
    std::cout << town[i] << std::endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main(void) {
  int N, M;

  std::cin >> N >> M;
  std::vector<int> town(N, 0);
  for (int i = 0; i < M; ++i) {
    int t1, t2;
    std::cin >> t1 >> t2;
    town[t1 - 1]++;
    town[t2 - 1]++;
  }

  for (int i = 0; i < N; ++i) {
    std::cout << town[i] << std::endl;
  }

  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, a, b;
  cin >> N >> M;
  vector<int> count(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    count.at(a - 1) += 1;
    count.at(b - 1) += 1;
  }
  for (int i = 0; i < M; i++) {
    cout << count.at(i) << endl;
  }
}

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

int main() {
  int N, M, a, b;
  cin >> N >> M;
  vector<int> count(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    count.at(a - 1) += 1;
    count.at(b - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll oo = 1e18;
const ll mod = 998244353, maxn = 3030;
const double PI = acos(-1);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, a, b;

  cin >> n >> m;

  vector<int> ans(n, 0);

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

  for (auto x : ans)
    cout << x << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll oo = 1e18;
const ll mod = 998244353, maxn = 3030;
const double PI = acos(-1);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, a, b;

  cin >> n >> m;

  vector<int> ans(n, 0);

  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    ans[--a]++;
    ans[--b]++;
  }

  for (auto x : ans)
    cout << x << endl;
  return 0;
}
Problem p03720 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

cnt = [0] * n

for i in range(m):
    cnt[ab[i][0] - 1] += 1
    cnt[ab[i][1] - 1] += 1

for i in range(n):
    print(cnt(i))


Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

cnt = [0] * n

for i in range(m):
    cnt[ab[i][0] - 1] += 1
    cnt[ab[i][1] - 1] += 1

for i in range(n):
    print(cnt[i])
Problem p03720 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())
Es = [[] for _ in range(N)]
for n in range(N):
    a, b = map(int, input().split())
    Es[a - 1].append(b - 1)
    Es[b - 1].append(a - 1)

for e in Es:
    print(len(e))


Fixed submission:
N, M = map(int, input().split())
Es = [[] for _ in range(N)]
for n in range(M):
    a, b = map(int, input().split())
    Es[a - 1].append(b - 1)
    Es[b - 1].append(a - 1)

for e in Es:
    print(len(e))
Problem p03720 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())
road = [0] * N

for _ in range(N):
    a, b = [int(i) for i in input().split()]
    road[a - 1] += 1
    road[b - 1] += 1
for r in road:
    print(r)


Fixed submission:
N, M = map(int, input().split())
road = [0] * N

for _ in range(M):
    a, b = [int(i) for i in input().split()]
    road[a - 1] += 1
    road[b - 1] += 1
for r in road:
    print(r)
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> toshi(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    toshi.at(a)++;
    toshi.at(b)++;
  }
  rep(i, N) { cout << toshi.at(i) << endl; }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> toshi(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    toshi.at(a - 1)++;
    toshi.at(b - 1)++;
  }
  rep(i, N) { cout << toshi.at(i) << endl; }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define RFOR(i, a, b) for (long long i = (b - 1); i >= a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cout << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<P> Graph;

int main() {
  int N, M;
  int a, b;
  cin >> N >> M;
  vector<int> nod(M, 0);
  REP(i, M) {
    cin >> a >> b;
    nod[a - 1]++;
    nod[b - 1]++;
  }
  REP(i, N) cout << nod[i] << endl;
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define RFOR(i, a, b) for (long long i = (b - 1); i >= a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cout << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<P> Graph;

int main() {
  int N, M;
  int a, b;
  cin >> N >> M;
  vector<int> nod(N, 0);
  REP(i, M) {
    cin >> a >> b;
    nod[a - 1]++;
    nod[b - 1]++;
  }
  REP(i, N) cout << nod[i] << endl;
  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int j = 0; j < N; j++) {
    int count = 0;
    if (a.at(j) == j + 1) {
      count++;
    } else if (b.at(j) == j + 1) {
      count++;
    }
    cout << count << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int j = 0; j < N; j++) {
    int count = 0;
    for (int k = 0; k < M; k++) {
      if (a.at(k) == j + 1) {
        count++;
      } else if (b.at(k) == j + 1) {
        count++;
      }
    }
    cout << count << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> out(N);
  // 入力部
  for (int j = 0; j < M; j++) {
    int x, y;
    cin >> x >> y;
    out.at(x)++;
    out.at(y)++;
  }
  // 出力部
  for (int i = 0; i < N; i++) {
    cout << out.at(i) << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> out(N);
  // 入力部
  for (int j = 0; j < M; j++) {
    int x, y;
    cin >> x >> y;
    out.at(x - 1)++;
    out.at(y - 1)++;
  }
  // 出力部
  for (int i = 0; i < N; i++) {
    cout << out.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> result(N);
  for (int i = 0; i < 2 * M; i++) {
    int a;
    cin >> a;
    result.at(a)++;
  }
  for (int i = 0; i < N; i++) {
    cout << result.at(i) << endl;
  }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> result(N);
  for (int i = 0; i < 2 * M; i++) {
    int a;
    cin >> a;
    result.at(a - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << result.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, a, b, i, j;
  cin >> N >> M;
  vector<int> t(M);

  for (i = 0; i < M; i++) {
    cin >> a >> b;
    t.at(a - 1)++;
    t.at(b - 1)++;
  }

  for (i = 0; i < N; i++) {
    cout << t.at(i) << endl;
  }
}


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

int main() {
  int N, M, a, b, i, j;
  cin >> N >> M;
  vector<int> t(N);

  for (i = 0; i < M; i++) {
    cin >> a >> b;
    t.at(a - 1)++;
    t.at(b - 1)++;
  }

  for (i = 0; i < N; i++) {
    cout << t.at(i) << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm = 1000000000;
ll MM = mm + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.141592653589793

int main() {
  int n, m;
  cin >> n >> m;
  VI a(m);
  VI b(m);
  rep(i, m) { cin >> a[i] >> b[i]; }
  map<int, int> cnt;
  rep(i, m) {
    if (cnt.count(a[i])) {
      cnt.at(a[i])++;
    } else {
      cnt[a[i]] = 1;
    }
    if (cnt.count(b[i])) {
      cnt.at(b[i])++;
    } else {
      cnt[b[i]] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << cnt.at(i) << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm = 1000000000;
ll MM = mm + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.141592653589793

int main() {
  int n, m;
  cin >> n >> m;
  VI a(m);
  VI b(m);
  rep(i, m) { cin >> a[i] >> b[i]; }
  map<int, int> cnt;
  rep(i, m) {
    if (cnt.count(a[i])) {
      cnt.at(a[i])++;
    } else {
      cnt[a[i]] = 1;
    }
    if (cnt.count(b[i])) {
      cnt.at(b[i])++;
    } else {
      cnt[b[i]] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (cnt.count(i)) {
      cout << cnt.at(i) << endl;
    } else
      cout << 0 << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int N, M;
  int a[60], b[60];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
  }

  int count[60];
  for (int i = 0; i < N; i++) {
    count[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    count[a[i] - 1]++;
    count[b[i] - 1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << count[i] << endl;
  }
}

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

int main(void) {
  int N, M;
  int a[60], b[60];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
  }

  int count[60];
  for (int i = 0; i < N; i++) {
    count[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    count[a[i] - 1]++;
    count[b[i] - 1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << count[i] << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int N, M;
int a[50], b[50];

void solve() {
  int res[50] = {0};
  for (int i = 0; i < M; ++i) {
    res[a[i]]++;
    res[b[i]]++;
  }
  for (int i = 1; i <= N; ++i) {
    printf("%d\n", res[i]);
  }
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i];
  }
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int N, M;
int a[50], b[50];

void solve() {
  int res[51] = {0};
  for (int i = 0; i < M; ++i) {
    res[a[i]]++;
    res[b[i]]++;
  }
  for (int i = 1; i <= N; ++i) {
    printf("%d\n", res[i]);
  }
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i];
  }
  solve();
  return 0;
}
Problem p03720 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, S;
  cin >> N >> M;
  M = M * 2;
  vector<int> vec(M);
  for (int i = 0; i < M; i++)
    cin >> vec.at(i);

  for (int i = 0; i < N; i++) {
    S = 0;
    for (int n = 0; n < M; i++) {
      if (vec.at(n) == i + 1)
        S = S + 1;
    }
    cout << S << endl;
  }
}


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

int main() {
  int N, M, S;
  cin >> N >> M;
  M = M * 2;
  vector<int> vec(M);
  for (int i = 0; i < M; i++)
    cin >> vec.at(i);

  for (int i = 0; i < N; i++) {
    S = 0;
    for (int n = 0; n < M; n++) {
      if (vec.at(n) == i + 1)
        S = S + 1;
    }
    cout << S << endl;
  }
}
Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> count(50);

  for (int i = 0; i < N; i++) {
    count.at(i + 1) = 0;
  }

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    count.at(a)++;
    count.at(b)++;
  }

  for (int i = 0; i < N; i++) {
    cout << count.at(i + 1) << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> count(100);

  for (int i = 0; i < N; i++) {
    count.at(i + 1) = 0;
  }

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    count.at(a)++;
    count.at(b)++;
  }

  for (int i = 0; i < N; i++) {
    cout << count.at(i + 1) << endl;
  }
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> p(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    p.at(i) = {a, b};
  }

  sort(p.begin(), p.end());
  int i = 0;
  long long sum = 0;
  while (sum < K) {
    sum += p.at(i).second;
    i++;
  }

  cout << p.at(i - 1).first << endl;
}

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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<pair<int, int>> p(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    p.at(i) = {a, b};
  }

  sort(p.begin(), p.end());
  int i = 0;
  long long sum = 0;
  while (sum < K) {
    sum += p.at(i).second;
    i++;
  }

  cout << p.at(i - 1).first << endl;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(100001, 0);
  int c, d;

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

  c = 0;

  while (k - a[c] > 0) {
    k -= a[c];
    c++;
  }
  cout << c << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(100001, 0);
  int c, d;

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

  c = 0;

  while (k - a[c] > 0) {
    k -= a[c];
    c++;
  }
  cout << c << endl;

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10005;
struct node {
  int ai, bi;
} ss[MAX];
bool cmp(node a, node b) { return a.ai < b.ai; }
int main() {
  int n;
  long long k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &ss[i].ai, &ss[i].bi);
  }
  sort(ss, ss + n, cmp);
  int i;
  for (i = 0; i < n; ++i) {
    k -= ss[i].bi;
    if (k <= 0)
      break;
  }
  cout << ss[i].ai << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
struct node {
  int ai, bi;
} ss[MAX];
bool cmp(node a, node b) { return a.ai < b.ai; }
int main() {
  int n;
  long long k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &ss[i].ai, &ss[i].bi);
  }
  sort(ss, ss + n, cmp);
  int i;
  for (i = 0; i < n; ++i) {
    k -= ss[i].bi;
    if (k <= 0)
      break;
  }
  cout << ss[i].ai << endl;
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

const int N = 101010;
int ct[N] = {};

int main() {
  int n;
  ll k;
  scanf(" %d %lld", &n, &k);

  rep(i, n) {
    int a, b;
    scanf(" %d %d", &a, &b);
    ct[a] += b;
  }

  int ans = 1;
  ll s = 0;
  while (1) {
    if (s + ct[ans] >= k)
      break;
    s += ct[ans];
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

const int N = 101010;
ll ct[N] = {};

int main() {
  int n;
  ll k;
  scanf(" %d %lld", &n, &k);

  rep(i, n) {
    int a, b;
    scanf(" %d %d", &a, &b);
    ct[a] += b;
  }

  int ans = 1;
  ll s = 0;
  while (1) {
    if (s + ct[ans] >= k)
      break;
    s += ct[ans];
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 1; i <= (n); i++)
#define rep0(i, n) for (int i = 0; i < (n); i++)

const ll INF = 1e9 + 7;
struct hhh {
  int num, pri;
} a[100001];
bool cmp(hhh a, hhh b) {
  if (a.pri < b.pri) {
    return 1;
  } else {
    return 0;
  }
}
int n, m, g, k;
int main() {
  /*freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);*/
  cin >> n >> m;
  rep(i, n) { cin >> a[i].pri >> a[i].num; }
  sort(a + 1, a + n + 1, cmp);
  while (g < m) {
    k++;
    g += a[k].num;
  }
  cout << a[k].pri;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 1; i <= (n); i++)
#define rep0(i, n) for (int i = 0; i < (n); i++)

const ll INF = 1e9 + 7;
struct hhh {
  int num, pri;
} a[100001];
bool cmp(hhh a, hhh b) {
  if (a.pri < b.pri) {
    return 1;
  } else {
    return 0;
  }
}
ll n, m, g, k;
int main() {
  /*freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);*/
  cin >> n >> m;
  rep(i, n) { cin >> a[i].pri >> a[i].num; }
  sort(a + 1, a + n + 1, cmp);
  while (g < m) {
    k++;
    g += a[k].num;
  }
  cout << a[k].pri;
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2> void amin(T &a, T2 b) {
  if (a > b)
    a = b;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;

  VL sk(100010);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    sk[a] += b;
  }
  rep(i, 100001) {
    if (sk[i] >= k) {
      cout << i << "\n";
      return 0;
    }
    k -= sk[i];
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2> void amin(T &a, T2 b) {
  if (a > b)
    a = b;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  ll k;
  cin >> n >> k;

  VL sk(100010);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    sk[a] += b;
  }
  rep(i, 100001) {
    if (sk[i] >= k) {
      cout << i << "\n";
      return 0;
    }
    k -= sk[i];
  }
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define sz(a) int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0, 1, 1, -1, -1};
const int dw[8] = {0, 0, 1, -1, 1, -1, 1, -1};
typedef long long ll;
typedef pair<double, double> p;
typedef vector<int> VI;
typedef vector<string> VS;

int main() {

  int n, k;
  cin >> n;
  cin >> k;

  vector<ll> ans(100001, 0);

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

  for (int i = 1; i < 100001; i++) {
    k -= ans[i];
    if (k <= 0) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define sz(a) int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0, 1, 1, -1, -1};
const int dw[8] = {0, 0, 1, -1, 1, -1, 1, -1};
typedef long long ll;
typedef pair<double, double> p;
typedef vector<int> VI;
typedef vector<string> VS;

int main() {

  int n;
  ll k;
  cin >> n;
  cin >> k;

  vector<ll> ans(100001, 0);

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

  for (int i = 1; i < 100001; i++) {
    k -= ans[i];
    if (k <= 0) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):

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

const int MAX_N = 100000;
int iTbl[MAX_N + 5];

int main(int argc, char *argv[]) {
  int i;
  int N;
  long long K;
  int a;
  int b;
  long long c;

  cin >> N;
  cin >> K;
  for (i = 0; i < N; i++) {
    cin >> a;
    cin >> b;
    iTbl[a] += b;
  }

  i = 0;
  c = K;
  while (c > 0) {
    i++;
    c -= iTbl[i];
  }

  cout << i << endl;

  return 0;
}


Fixed submission:

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

const int MAX_N = 100000;
long long iTbl[MAX_N + 5];

int main(int argc, char *argv[]) {
  int i;
  int N;
  long long K;
  int a;
  int b;
  long long c;

  cin >> N;
  cin >> K;
  for (i = 0; i < N; i++) {
    cin >> a;
    cin >> b;
    iTbl[a] += b;
  }

  i = 0;
  c = K;
  while (c > 0) {
    i++;
    c -= iTbl[i];
  }

  cout << i << endl;

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <map>
#include <stdio.h>
using namespace std;
#define r(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define rn(i, n) for (int i = 1; i <= n; i++)

int main() {
  vector<ll> v(100001, 0);
  int n, k;
  cin >> n >> k;
  int a, b;
  r(i, n) {
    cin >> a >> b;
    v.at(a) += b;
  }

  for (int i = 1; i <= 100000; i++) {
    if (k <= v.at(i)) {
      cout << i << endl;
      break;
    } else
      k -= v.at(i);
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <map>
#include <stdio.h>
using namespace std;
#define r(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define rn(i, n) for (int i = 1; i <= n; i++)

int main() {
  vector<ll> v(100001, 0);
  ll n, k;
  cin >> n >> k;
  int a, b;
  r(i, n) {
    cin >> a >> b;
    v.at(a) += b;
  }

  for (int i = 1; i <= 100000; i++) {
    if (k <= v.at(i)) {
      cout << i << endl;
      break;
    } else
      k -= v.at(i);
  }

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll x[100010];

int main() {
  int n, k;
  cin >> n >> k;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    x[a] += b;
  }
  ll cnt = 0;
  rep(i, 100010) {
    cnt += x[i];
    if (cnt >= k) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll x[100010];

int main() {
  int n;
  ll k;
  cin >> n >> k;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    x[a] += b;
  }
  ll cnt = 0;
  rep(i, 100010) {
    cnt += x[i];
    if (cnt >= k) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

// 最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y) {
    tmp = x;
    x = y;
    y = tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

// 最大公倍数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

// 階乗
ll kaijo(ll k) {
  ll sum = 1;
  for (ll i = 1; i <= k; ++i) {
    sum *= i;
    sum %= 1000000000 + 7;
  }
  return sum;
}

// for(int i = ; i < ; i++){}

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> v(100001, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[a - 1] += b;
  }
  int j = 0;
  int tmp = 0;
  while (k > 0) {
    k -= v[j];
    tmp = j + 1;
    j++;
  }
  cout << tmp << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

// 最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y) {
    tmp = x;
    x = y;
    y = tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

// 最大公倍数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

// 階乗
ll kaijo(ll k) {
  ll sum = 1;
  for (ll i = 1; i <= k; ++i) {
    sum *= i;
    sum %= 1000000000 + 7;
  }
  return sum;
}

// for(int i = ; i < ; i++){}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(100001, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[a - 1] += b;
  }
  int j = 0;
  int tmp = 0;
  while (k > 0) {
    k -= v[j];
    tmp = j + 1;
    j++;
  }
  cout << tmp << endl;
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {

  vector<long long> frq(pow(10, 5) + 1, 0);
  int N, K, a, b;
  cin >> N >> K;

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

  for (int i = 1; i < frq.size(); ++i) {
    K -= frq[i];
    if (K <= 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {

  vector<long long> frq(pow(10, 5) + 1, 0);
  long long N, K, a, b;
  cin >> N >> K;

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

  for (int i = 1; i < frq.size(); ++i) {
    K -= frq[i];
    if (K <= 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int AMAX = 100000;
ll bucket[AMAX + 1];

int main() {
  int N;
  ll K;
  cin >> N, K;

  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    bucket[a] += b;
  }

  for (int i = 1; i <= AMAX; i++) {
    if (K <= bucket[i]) {
      cout << i << endl;
      break;
    }
    K -= bucket[i];
  }
  return 0;
}


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

using ll = long long;
const int AMAX = 100000;
ll bucket[AMAX + 1];

int main() {
  int N;
  ll K;
  cin >> N >> K;

  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    bucket[a] += b;
  }

  for (int i = 1; i <= AMAX; i++) {
    if (K <= bucket[i]) {
      cout << i << endl;
      break;
    }
    K -= bucket[i];
  }
  return 0;
}