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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> s(100001, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    s[a] += b;
  }
  int ans = 0;
  for (int i = 1; i < 100001; i++) {
    if (k <= s[i]) {
      ans = i;
      break;
    }
    k -= s[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> s(100001, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    s[a] += b;
  }
  int ans = 0;
  for (int i = 1; i < 100001; i++) {
    if (k <= s[i]) {
      ans = i;
      break;
    }
    k -= s[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p03721 (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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> l(N + 1);
  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    l[a] += b;
  }
  ll cnt = 0;
  int tmp = 0;
  while (cnt < K) {
    tmp++;
    cnt += l[tmp];
  }
  cout << tmp << endl;
}


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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> l(100000 + 1);
  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    l[a] += b;
  }
  ll cnt = 0;
  int tmp = 0;
  while (cnt < K) {
    tmp++;
    cnt += l[tmp];
  }
  cout << tmp << 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<int> v;
  for(int i=0; i<N; i++){
      int a,b;
      cin >> a >> b;
      for(int j=0; j<b; j++){
          v.push_back(a);
      }
  }
  sort(v.begin(), v.end());
  cout << v.at(K-1) << endl;
  */
  vector<int64_t> v(100001, 0);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    v.at(a) += b;
  }
  for (int i = 0; i < 100001; i++) {
    if (K <= v.at(i)) {
      cout << i << endl;
      break;
    }
    K -= v.at(i);
  }
}

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

int main() {
  int N;
  int64_t K;
  cin >> N >> K;
  /*
  vector<int> v;
  for(int i=0; i<N; i++){
      int a,b;
      cin >> a >> b;
      for(int j=0; j<b; j++){
          v.push_back(a);
      }
  }
  sort(v.begin(), v.end());
  cout << v.at(K-1) << endl;
  */
  vector<int64_t> v(100001, 0);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    v.at(a) += b;
  }
  for (int i = 0; i < 100001; i++) {
    if (K <= v.at(i)) {
      cout << i << endl;
      break;
    }
    K -= v.at(i);
  }
}
Problem p03721 (C++)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF = 1e13 + 7;
const int INF = 1e9 + 7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class Y> T GCD(T a, Y b) {
  if (a < b) {
    int c = a;
    a = b;
    b = c;
  }
  if (a % b == 0) {
    return b;
  }
  return GCD(b, a % b);
}
void clear(queue<pair<int, int>> &q) {
  queue<pair<int, int>> empty;
  swap(q, empty);
} // queueの中身の型は適時変更を忘れない

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(), (a).end()

int main() {
  int N, K;
  ll sum = 0, ANS;
  cin >> N >> K;
  vector<ll> mp(100010, 0);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  REP(i, 1, 100001) {
    if (K <= mp[i]) {
      cout << i << endl;
      return 0;
    }
    K -= mp[i];
  }

  return 0;
}

// a=97,z=122

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF = 1e13 + 7;
const int INF = 1e9 + 7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class Y> T GCD(T a, Y b) {
  if (a < b) {
    int c = a;
    a = b;
    b = c;
  }
  if (a % b == 0) {
    return b;
  }
  return GCD(b, a % b);
}
void clear(queue<pair<int, int>> &q) {
  queue<pair<int, int>> empty;
  swap(q, empty);
} // queueの中身の型は適時変更を忘れない

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(), (a).end()

int main() {
  ll N, K;
  ll sum = 0, ANS;
  cin >> N >> K;
  vector<ll> mp(100010, 0);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  REP(i, 1, 100001) {
    if (K <= mp[i]) {
      cout << i << endl;
      return 0;
    }
    K -= mp[i];
  }

  return 0;
}

// a=97,z=122
Problem p03721 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> num(100001, 0);
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    num[a] += b;
  }
  for (int i = 1; i < 100001; i++) {
    k -= num[i];
    if (k <= 0) {
      cout << i << endl;
      break;
    }
  }
}

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int>> n;
  int a, b, c = 0;
  int ai, bi;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    cin >> ai >> bi;
    n.push_back(make_pair(ai, bi));
  }

  sort(n.begin(), n.end());
  while (b > 0) {
    b = b - n[c].second;
    c++;
  }
  cout << n[c - 1].first << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int>> n;
  long long int a, b, c = 0;
  int ai, bi;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    cin >> ai >> bi;
    n.push_back(make_pair(ai, bi));
  }

  sort(n.begin(), n.end());
  while (b > 0) {
    b = b - n[c].second;
    c++;
  }
  cout << n[c - 1].first << endl;
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 55;
int n, k;
struct array {
  int a, b;
  bool friend operator<(array pa, array pb) { return pa.a < pb.a; }
} Arr[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> Arr[i].a >> Arr[i].b;
  }
  sort(Arr, Arr + n);
  int cnt = -1;
  while (k > 0) {
    k = k - Arr[++cnt].b;
  }
  cout << Arr[cnt].a << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 55;
int n;
ll k;
struct array {
  int a, b;
  bool friend operator<(array pa, array pb) { return pa.a < pb.a; }
} Arr[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> Arr[i].a >> Arr[i].b;
  }
  sort(Arr, Arr + n);
  int cnt = -1;
  while (k > 0) {
    k = k - Arr[++cnt].b;
  }
  cout << Arr[cnt].a << endl;
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector<pair<int, int>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
  cin.sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m;
  cin >> n >> m;
  vi v(111111);
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v[a] += b;
  }
  REP(i, 111111) {
    sum += v[i];
    if (sum >= m) {
      cout << i << endl;
      break;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector<pair<int, int>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
  cin.sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ll n, m;
  cin >> n >> m;
  vi v(111111);
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v[a] += b;
  }
  REP(i, 111111) {
    sum += v[i];
    if (sum >= m) {
      cout << i << endl;
      break;
    }
  }
}
Problem p03721 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <map>
using namespace std;
map<int, int> mp;
long long n, k, a, b, num;
int main(void) {
  // Your code here!
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    mp[a] += b;
  }
  for (int i = 1;; i++) {
    num += mp[i];
    if (num >= k) {
      cout << i << endl;
      break;
    }
  }
}


Fixed submission:
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
map<ll, ll> mp;
ll n, k, a, b, num;
int main(void) {
  // Your code here!
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    mp[a] += b;
  }
  for (int i = 1;; i++) {
    num += mp[i];
    if (num >= k) {
      cout << i << endl;
      break;
    }
  }
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
// char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
  ll N, K;
  cin >> N >> K;
  vp ab(N);
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  sort(ab.begin(), ab.end(), [&](P &l, P &r) { return l.first < r.second; });
  REP(i, N) {
    ans += ab[i].second;
    if (ans >= K) {
      cout << ab[i].first << endl;
      break;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
// char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
  ll N, K;
  cin >> N >> K;
  vp ab(N);
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  sort(ab.begin(), ab.end(), [&](P &l, P &r) { return l.first < r.first; });
  REP(i, N) {
    ans += ab[i].second;
    if (ans >= K) {
      cout << ab[i].first << endl;
      break;
    }
  }
  return 0;
}
Problem p03721 (C++)

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

int main() {
  int n, k, i, j;
  cin >> n >> k;
  vector<pair<int, int>> ary(n);
  for (i = 0; i < n; i++) {
    cin >> ary.at(i).first >> ary.at(i).second;
  }
  sort(ary.begin(), ary.end());
  int cnt = 0;
  while (k > 0) {
    if (k > ary.at(cnt).second) {
      k -= ary.at(cnt).second;
      cnt++;
    } else {
      k = 0;
    }
  }
  cout << ary.at(cnt).first << endl;
}

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

int main() {
  long n, k, i;
  cin >> n >> k;
  vector<pair<int, int>> ary(n);
  for (i = 0; i < n; i++) {
    cin >> ary.at(i).first >> ary.at(i).second;
  }
  sort(ary.begin(), ary.end());
  int cnt = 0;
  while (k > 0) {
    if (k > ary.at(cnt).second) {
      k -= ary.at(cnt).second;
      cnt++;
    } else {
      k = 0;
    }
  }
  cout << ary.at(cnt).first << endl;
}
Problem p03721 (C++)

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<vector<int>> v(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  sort(v.begin(), v.end());
  int index = 0;
  int i = 0;
  while (1) {
    index += v[i][1];
    if (index >= k)
      break;
    i++;
  }
  cout << v[i][0] << endl;
}

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<vector<int>> v(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  sort(v.begin(), v.end());
  ll index = 0;
  int i = 0;
  while (1) {
    index += v[i][1];
    if (index >= k)
      break;
    i++;
  }
  cout << v[i][0] << 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<int> a(n);
  vector<long> b(n), c(100000);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
    int d = a.at(i);
    c.at(d - 1) += b.at(i);
  }
  long count = 0, ans;
  for (int i = 0; i < 100000; i++) {
    count += c.at(i);
    if (count >= k) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  long k;
  cin >> n >> k;
  vector<int> a(n);
  vector<long> b(n), c(100000);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
    int d = a.at(i);
    c.at(d - 1) += b.at(i);
  }
  long count = 0, ans;
  for (int i = 0; i < 100000; i++) {
    count += c.at(i);
    if (count >= k) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI = 3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y)-1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  vs64 num(1e5 + 1, 0);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    num[a] += b;
  }

  rep(i, 1e5) { num[i + 1] += num[i]; }

  cout << lower_bound(num.begin(), num.end(), k) - num.begin() << "\n";
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI = 3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y)-1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  s64 n, k;
  cin >> n >> k;

  vs64 num(1e5 + 1, 0);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    num[a] += b;
  }

  rep(i, 1e5) { num[i + 1] += num[i]; }

  cout << lower_bound(num.begin(), num.end(), k) - num.begin() << "\n";
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int main() {
  int N, K;
  int64 count[100002];
  fill(count, count + 100002, 0);
  cin >> N >> K;
  for (int j = 0; j < N; ++j) {
    int a, b;
    cin >> a >> b;
    count[a] += b;
  }

  int64 acc = 0;
  for (int j = 0; j <= 100000; ++j) {
    acc += count[j];
    if (acc >= K) {
      cout << j << endl;
      return 0;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int main() {
  int N;
  int64 K;
  int64 count[100002];
  fill(count, count + 100002, 0);
  cin >> N >> K;
  for (int j = 0; j < N; ++j) {
    int a, b;
    cin >> a >> b;
    count[a] += b;
  }

  int64 acc = 0;
  for (int j = 0; j <= 100000; ++j) {
    acc += count[j];
    if (acc >= K) {
      cout << j << endl;
      return 0;
    }
  }
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> count(101000);
  rep(i, (int)count.size()) count[i] = 0;
  int a, b;
  rep(i, N) {
    cin >> a >> b;
    count[a] += b;
  }
  ll sum = 0;
  int ans = 1;
  rep(i, (int)count.size()) {
    sum += count[i];
    if (sum >= K) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> count(101000);
  rep(i, (int)count.size()) count[i] = 0;
  int a, b;
  rep(i, N) {
    cin >> a >> b;
    count[a] += b;
  }
  ll sum = 0;
  int ans = 1;
  rep(i, (int)count.size()) {
    sum += count[i];
    if (sum >= K) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 100'000
int cnt[N] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  ll k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  ll seen = 0;
  for (int i = 1; i <= N; i++) {
    seen += cnt[i];
    if (seen >= k) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 100'000
ll cnt[N + 1] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  ll k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  ll seen = 0;
  for (int i = 1; i <= N; i++) {
    seen += cnt[i];
    if (seen >= k) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define co(x) cout << x << endl
#define cs(x) cout << x << " "
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(100010, 0);
  rep(i, N) {
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    a[tmp1] += tmp2;
  }

  ll ind = 0;
  for (int i = 1; i <= 100000; i++) {
    K -= a[i];
    ind = i;
    if (K <= 0) {
      co(i);
      return 0;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define co(x) cout << x << endl
#define cs(x) cout << x << " "
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> a(100010, 0);
  rep(i, N) {
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    a[tmp1] += tmp2;
  }

  ll ind = 0;
  for (int i = 1; i <= 100000; i++) {
    K -= a[i];
    ind = i;
    if (K <= 0) {
      co(i);
      return 0;
    }
  }
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define MAXN 100000
#define MAXA 100000
#define MAXB 100000
int main(int argc, char const *argv[]) {
  int n, k, i, ans, a, b;
  long int calc = 0;
  vector<long long int> buckets(MAXA + 1, 0);
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    buckets[a] += b;
  }
  for (ans = 1; ans <= MAXA; ans++) {
    calc += buckets[ans];
    if (calc >= k) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define MAXN 100000
#define MAXA 100000
#define MAXB 100000
int main(int argc, char const *argv[]) {
  int n, i, ans, a, b;
  long long int calc = 0, k;
  vector<long long int> buckets(MAXA + 1, 0);
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    buckets[a] += b;
  }
  for (ans = 1; ans <= MAXA; ans++) {
    calc += buckets[ans];
    if (calc >= k) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03721 (C++)

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> C(100005);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    C[a] += b;
  }
  long long cnt = 0;
  for (int i = 1; i <= 100000; i++) {
    cnt += C[i];
    if (cnt >= K) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}
/* vim:set fdm=marker: */


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

using namespace std;

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<long long> C(100005);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    C[a] += b;
  }
  long long cnt = 0;
  for (int i = 1; i <= 100000; i++) {
    cnt += C[i];
    if (cnt >= K) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}
/* vim:set fdm=marker: */
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k, a, b, i;
  vector<int> table(100001, 0);

  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    table[a] += b;
  }
  for (i = 0; i < 100001; i++) {
    k -= table[i];
    if (k <= 0) {
      cout << i;
      break;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, a, i;
  long long b, k;
  vector<long long> table(100001, 0);

  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    table[a] += b;
  }
  for (i = 0; i < 100001; i++) {
    k -= table[i];
    if (k <= 0) {
      cout << i;
      break;
    }
  }
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
using vch = vector<char>;
using vvch = vector<vector<char>>;
using vbo = vector<bool>;
using vvbo = vector<vector<bool>>;
using vpii = vector<pair<int, int>>;
using pqsin = priority_queue<int, vector<int>, greater<int>>;
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define decp(n) cout << fixed << setprecision((int)n)
const int inf = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int n, k;
  cin >> n >> k;
  vll num(100050);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    num[a] += (ll)b;
  }
  ll sum = 0;
  rep(i, 100050) {
    if (sum + num[i] >= (ll)k) {
      cout << i << endl;
      return 0;
    } else
      sum += (ll)num[i];
  }
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
using vch = vector<char>;
using vvch = vector<vector<char>>;
using vbo = vector<bool>;
using vvbo = vector<vector<bool>>;
using vpii = vector<pair<int, int>>;
using pqsin = priority_queue<int, vector<int>, greater<int>>;
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define decp(n) cout << fixed << setprecision((int)n)
const int inf = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vll num(100050);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    num[a] += (ll)b;
  }
  ll sum = 0;
  rep(i, 100050) {
    if (sum + num[i] >= (ll)k) {
      cout << i << endl;
      return 0;
    } else
      sum += (ll)num[i];
  }
}
Problem p03721 (C++)

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

#define ll long long

using namespace std;

int main() {
  int n, k;
  int a, b, j;

  cin >> n >> k;
  vector<ll> v(100001);

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

  j = 0;
  while (1) {
    if (v[j] != 0)
      k -= v[j];
    if (k <= 0)
      break;
    j++;
  }

  cout << j;
}

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

#define ll long long

using namespace std;

int main() {
  int n, a, b, j;
  ll k;

  cin >> n >> k;
  vector<ll> v(100001);

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

  j = 0;
  while (1) {
    if (v[j] != 0)
      k -= v[j];
    if (k <= 0)
      break;
    j++;
  }

  cout << j;
}
Problem p03721 (C++)

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

const int NUM = std::pow(10, 5);

int main() {
  int n;
  long long k;
  std::cin >> n >> k;

  std::vector<int> counts(NUM, 0);
  for (int i = 0; i < n; ++i) {
    int a, b;
    std::cin >> a >> b;
    counts.at(a - 1) += b;
  }

  int i = 0;
  long long sum = 0;
  while (sum < k) {
    sum += counts.at(i++);
  }

  std::cout << i << std::endl;

  return 0;
}

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

const int NUM = std::pow(10, 5);

int main() {
  int n;
  long long k;
  std::cin >> n >> k;

  std::vector<long long> counts(NUM, 0);
  for (int i = 0; i < n; ++i) {
    int a, b;
    std::cin >> a >> b;
    counts.at(a - 1) += b;
  }

  int i = 0;
  long long sum = 0;
  while (sum < k) {
    sum += counts.at(i++);
  }

  std::cout << i << std::endl;

  return 0;
}
Problem p03721 (C++)

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}
template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

ll d[100001];

signed main() {
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

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

  rep(i, n) {
    int a, b;
    cin >> a >> b;
    d[a] += b;
  }

  ll now = 0;
  rep2(i, 1, 100000) {
    now += d[i];

    if (now >= k) {
      cout << i << endl;
      return (0);
    }
  }

  return (0);
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}
template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

ll d[100001];

signed main() {
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

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

  rep(i, n) {
    int a, b;
    cin >> a >> b;
    d[a] += b;
  }

  ll now = 0;
  rep2(i, 1, 100000) {
    now += d[i];

    if (now >= k) {
      cout << i << endl;
      return (0);
    }
  }

  return (0);
}
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> nums(110000, 0);
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    nums[a] += b;
  }

  long long res = 0;
  for (int i = 0; i < 110000; ++i) {
    res += nums[i];
    if (res >= K) {
      cout << i << endl;
      break;
    }
  }
}


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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> nums(110000, 0);
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    nums[a] += b;
  }

  long long res = 0;
  for (int i = 0; i < 110000; ++i) {
    res += nums[i];
    if (res >= K) {
      cout << i << endl;
      break;
    }
  }
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main() {
  ll n, k;
  cin >> n >> k;
  V dic(100010, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    dic[a] += b;
  }
  ll i = 0, acu = 0;
  while (acu < k) {
    acu += dic[i];
    i++;
  }
  OUT(i - 1);
}


Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> dic(100010, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    dic[a] += b;
  }
  ll i = 0, acu = 0;
  while (acu < k) {
    acu += dic[i];
    i++;
  }
  OUT(i - 1);
}
Problem p03721 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

//----------------------------------------------------------------

int main() {
  long long n, k;
  cin >> n >> k;
  ll a, b;
  map<ll, ll> rensou;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    for (int i = 0; i < b; i++) {
      rensou[a]++;
    }
  }
  ll cnt = 0, i = 0;
  while (cnt < k) {
    i++;
    cnt += rensou[i];
  }
  cout << i << endl;
}


Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

//----------------------------------------------------------------

int main() {
  long long n, k;
  cin >> n >> k;
  ll a, b;
  map<ll, ll> rensou;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    rensou[a] += b;
  }
  ll cnt = 0, i = 0;
  while (cnt < k) {
    i++;
    cnt += rensou[i];
  }
  cout << i << endl;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long int n, k;
  pair<long long int, long long int> a[10001];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + n);
  long long int i = 0, c = 0;
  while (c < k) {
    c += a[i].second;
    i++;
  }
  cout << a[i - 1].first << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long int n, k;
  pair<long long int, long long int> a[100001];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + n);
  long long int i = 0, c = 0;
  while (c < k) {
    c += a[i].second;
    i++;
  }
  cout << a[i - 1].first << endl;
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
int C[100001];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  vector<P> q;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    C[a] += b;
  }
  for (int i = 1; i <= 100000; i++) {
    K -= C[i];
    if (K <= 0) {
      cout << i << "\n";
      return 0;
    }
  }
  return 1;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long N, K;
long long C[100001];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  vector<P> q;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    C[a] += b;
  }
  for (int i = 1; i <= 100000; i++) {
    K -= C[i];
    if (K <= 0) {
      cout << i << "\n";
      return 0;
    }
  }
  return 1;
}
Problem p03721 (C++)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  uint64_t k;
  cin >> n >> k;
  vector<pair<int, int>> ins(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    ins[i] = make_pair(a, b);
  }
  sort(ins.begin(), ins.end(),
       [](const pair<int, int> &l, const pair<int, int> &r) {
         return l.first < r.second;
       });

  for (int i = 0; i < n; ++i) {
    if (k <= (uint64_t)ins[i].second) {
      cout << ins[i].first << "\n";
      break;
    }
    k -= ins[i].second;
  }
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  uint64_t k;
  cin >> n >> k;
  vector<pair<int, int>> ins(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    ins[i] = make_pair(a, b);
  }
  sort(ins.begin(), ins.end(),
       [](const pair<int, int> &l, const pair<int, int> &r) {
         return l.first < r.first;
       });

  for (int i = 0; i < n; ++i) {
    if (k <= (uint64_t)ins[i].second) {
      cout << ins[i].first << "\n";
      break;
    }
    k -= ins[i].second;
  }
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
  int n, k;
  cin >> n >> k;

  vector<ll> cnt(1e5 + 1, 0);
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  int ans = 0;
  for (int i = 1; i <= 1e5; ++i) {
    if (cnt[i] >= k) {
      ans = i;
      break;
    }

    k -= cnt[i];
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
  int n;
  ll k;
  cin >> n >> k;

  vector<ll> cnt(1e5 + 1, 0);
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  int ans = 0;
  for (int i = 1; i <= 1e5; ++i) {
    if (cnt[i] >= k) {
      ans = i;
      break;
    }

    k -= cnt[i];
  }

  cout << ans << endl;

  return 0;
}
Problem p03721 (C++)

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

#define lint long long

const lint INF = 1E9;
#define P pair<int, int>

signed main() {
  int N, K;

  cin >> N >> K;

  vector<P> lis;

  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    lis.push_back(make_pair(a, b));
  }

  sort(lis.begin(), lis.end());

  int pos = 0;
  while (K > 0) {
    if (lis[pos].second < K) {
      K -= lis[pos].second;
      pos++;
    } else {
      cout << lis[pos].first << endl;
      return 0;
    }
  }
}


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

#define int long long
#define P pair<int, int>

signed main() {
  int N, K;

  cin >> N >> K;

  vector<P> lis;

  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    lis.push_back(make_pair(a, b));
  }

  sort(lis.begin(), lis.end());

  int pos = 0;
  while (K > 0) {
    if (lis[pos].second < K) {
      K -= lis[pos].second;
      pos++;
    } else {
      cout << lis[pos].first << endl;
      return 0;
    }
  }
}
Problem p03721 (C++)

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

int64_t datas[1223 * 1234];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  // memset(datas, 0, sizeof(datas));
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    datas[a] += b;
  }

  int64_t cnt = 0;
  int j = 0;
  while (1) {
    ++j;
    cnt += datas[j];
    if (k <= cnt)
      break;
  }
  printf("%d\n", j);
  return 0;
}

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

int64_t datas[1223 * 1234];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int64_t n, k;
  cin >> n >> k;
  // memset(datas, 0, sizeof(datas));
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    datas[a] += b;
  }

  int64_t cnt = 0;
  int j = 0;
  while (1) {
    ++j;
    cnt += datas[j];
    if (k <= cnt)
      break;
  }
  printf("%d\n", j);
  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Runtime Error):
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define all(x) (x).begin(), (x).end()

void solve() {}
int main() {
  int n, k;
  vector<pair<int, int>> a;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a.push_back(make_pair(x, y));
  }
  sort(all(a));
  ll sum = 0;
  int i = 0;
  while (sum < k) {
    sum += a[i].second;
    i++;
  }
  cout << a[i - 1].first << endl;
  return 0;
}


Fixed submission:
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define all(x) (x).begin(), (x).end()

void solve() {}
int main() {
  int n;
  ll k;
  vector<pair<int, int>> a;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a.push_back(make_pair(x, y));
  }
  sort(all(a));
  ll sum = 0;
  int i = 0;
  while (sum < k) {
    sum += a[i].second;
    i++;
  }
  cout << a[i - 1].first << endl;
  return 0;
}
Problem p03721 (C++)

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

int main() {
  // 整数の入力
  int N, K, i, a, b;
  int MAXSIZE = 1000000;
  cin >> N >> K;
  long long *numCounts = new long long[MAXSIZE + 1];
  long long totalCount = 0;
  for (i = 0; i < MAXSIZE + 1; i++) {
    numCounts[i] = 0;
  }

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

  for (i = 1; i < MAXSIZE + 1; i++) {
    totalCount += numCounts[i];
    if (totalCount >= K) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

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

int main() {
  // 整数の入力
  long long N, K, i, a, b;
  int MAXSIZE = 100000;
  cin >> N >> K;
  long long *numCounts = new long long[MAXSIZE + 1];
  long long totalCount = 0;
  for (i = 0; i < MAXSIZE + 1; i++) {
    numCounts[i] = 0;
  }

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

  for (i = 1; i < MAXSIZE + 1; i++) {
    totalCount += numCounts[i];
    if (totalCount >= K) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}
Problem p03721 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T> bool PN(T x) {
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

const long long MOD = 1e9 + 7;

void solve() {
  ll n, k;
  scanf("%d %d", &n, &k);
  map<int, ll> mp;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  ll cnt = 0;
  for (auto mm : mp) {
    cnt += mm.second;
    if (k <= cnt) {
      cout << mm.first << endl;
      return;
    }
  }
}

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T> bool PN(T x) {
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

const long long MOD = 1e9 + 7;

void solve() {
  ll n, k;
  scanf("%lld %lld", &n, &k);
  map<int, ll> mp;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  ll cnt = 0;
  for (auto mm : mp) {
    cnt += mm.second;
    if (k <= cnt) {
      cout << mm.first << endl;
      return;
    }
  }
}

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