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

// 12
#include <iostream>
#include <vector>

using namespace std;

int main() {
  for (int n; cin >> n, n;) {
    vector<int> up;
    while (n--) {
      int p;
      cin >> p;
      up.push_back(p);
    }
    for (int i = 0; i < up.size() - 1; i++) {
      if (i == 0 || up[i] - up[i - 1] != 1) {
        cout << up[i] << ((up[i + 1] - up[i] == 1) ? '-' : ' ');
      } else if (up[i + 1] - up[i] != 1) {
        cout << up[i] << ' ';
      }
    }
    cout << up.end()[-1] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

// 12
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main() {
  for (int n; cin >> n, n;) {
    bool u[52] = {};
    while (n--) {
      int p;
      cin >> p;
      u[p] = true;
    }
    stringstream ss;
    for (int i = 1; i <= 50; i++) {
      if (!u[i - 1] && u[i]) {
        ss << i << ((u[i + 1]) ? '-' : ' ');
      } else if (u[i] && !u[i + 1]) {
        ss << i << ' ';
      }
    }
    string s = ss.str();
    s.erase(s.end() - 1);
    cout << s << endl;
  }
  return 0;
}
Problem p00637 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int up; //??????
  bool b[1000][1000];
  int c = -1;
  int i2;
  int itizi;
  int i;
  int con; //?¶??????????
  int saisyo[1000];
  for (i = 0; c == -1; i++) {
    scanf("%d", &up);
    if (up == 0) {
      c = i;
      break;
    }
    scanf("%d", &itizi);
    saisyo[i] = itizi;
    b[i][itizi] = true;
    for (i2 = 1; i2 < up; i2++) {
      scanf("%d", &itizi);
      b[i][itizi] = true;
    }
  }

  for (i = 0; i < c; i++) {
    con = -1;
    for (i2 = 1; i2 <= 1000; i2++) {
      if (con == -1 && b[i][i2] == true) {
        con = i2;
      } else if (b[i][i2] == true) {
      } else if (con != -1 && b[i][i2] != true) {
        if (con == saisyo[i]) {
          if (con == i2 - 1) {
            printf("%d", con);
          } else {
            printf("%d-%d", con, i2 - 1);
          }
        } else {
          if (con == i2 - 1) {
            printf(" %d", con);
          } else {
            printf(" %d-%d", con, i2 - 1);
          }
        }
        con = -1;
      }
    }
    printf("\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int up; //??????
  bool b[10000][1000];
  int c = -1;
  int i2;
  int itizi;
  int i;
  int con; //?¶??????????
  int saisyo[10000];
  for (i = 0; c == -1; i++) {
    scanf("%d", &up);
    if (up == 0) {
      c = i;
      break;
    }
    scanf("%d", &itizi);
    saisyo[i] = itizi;
    b[i][itizi] = true;
    for (i2 = 1; i2 < up; i2++) {
      scanf("%d", &itizi);
      b[i][itizi] = true;
    }
  }

  for (i = 0; i < c; i++) {
    con = -1;
    for (i2 = 1; i2 <= 1000; i2++) {
      if (con == -1 && b[i][i2] == true) {
        con = i2;
      } else if (b[i][i2] == true) {
      } else if (con != -1 && b[i][i2] != true) {
        if (con == saisyo[i]) {
          if (con == i2 - 1) {
            printf("%d", con);
          } else {
            printf("%d-%d", con, i2 - 1);
          }
        } else {
          if (con == i2 - 1) {
            printf(" %d", con);
          } else {
            printf(" %d-%d", con, i2 - 1);
          }
        }
        con = -1;
      }
    }
    printf("\\n");
  }
  return 0;
}
Problem p00637 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
// #include <algorithm>

int main(void) {
  int n, start, startpoint;
  int reference[60];
  bool head;

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

    // テ・ツ?・テ・ツ環崚」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
    for (int i = 0; i < n; i++) {
      scanf("%d", &reference[i]);
    }
    reference[n] = reference[n - 1] + 2;

    // テ」ツつステ」ツδシテ」ツδ暗」ツ?凖」ツつ?
    // std::sort(&reference[0], &reference[n]);

    // テ・ツ?コテ・ツ環崚」ツ?凖」ツつ?
    // テ、ツセツ凝・ツ、ツ姪・ツ?ヲテァツ青?
    if (n == 1) {
      printf("%d\\n", reference[0]);
      continue;
    }
    // テヲツ卍ョテゥツ?堙」ツ?ョテ・ツ?エテ・ツ青?
    start = reference[0];
    startpoint = 0;
    head = true;
    for (int i = 1; i <= n; i++) {
      if (reference[i] != reference[i - 1] + 1) {
        if (head) {
          head = false;
        } else {
          printf(" ");
        }

        if (startpoint == i - 1) {
          printf("%d", reference[startpoint]);
        } else {
          printf("%d-%d", reference[startpoint], reference[i - 1]);
        }
        start = reference[i];
        startpoint = i;
      }
    }
    printf("\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int n, tmp, start;
  bool reference[60];
  bool head;

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

    // テ・ツ按敕ヲツ慊淌・ツ個?
    start = -1;
    head = true;
    for (int i = 0; i < 55; i++) {
      reference[i] = false;
    }

    // テ・ツ?・テ・ツ環崚」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
    for (int i = 0; i < n; i++) {
      scanf("%d", &tmp);
      reference[tmp] = true;
    }

    // テ・ツ?コテ・ツ環崚」ツ?凖」ツつ?
    for (int i = 0; i < 52; i++) {
      // テ・ツ渉づィツ?εゥツ鳴凝・ツァツ?
      if (reference[i] && (start == -1)) {
        start = i;
      }
      // テ・ツ渉づィツ?εァツオツづ、ツコツ?
      else if (!reference[i] && (start != -1)) {
        if (head) {
          head = false;
        } else {
          printf(" ");
        }

        // 1テ」ツδ堙」ツδシテ」ツつクテ」ツ??」ツ?妥」ツ??」ツ?」テ」ツ?淌・ツ?エテ・ツ青?
        if (i == start + 1) {
          printf("%d", start);
        }
        // ティツ、ツ?ヲツ閉ーテ」ツδ堙」ツδシテ」ツつクテ」ツ?ォテヲツクツ。テ」ツ?」テ」ツ?ヲテ」ツ??」ツ?淌・ツ?エテ・ツ青?
        else {
          printf("%d-%d", start, i - 1);
        }
        start = -1;
      }
    }
    printf("\\n");
  }
  return 0;
}
Problem p00637 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string.h>

using namespace std;

void solve() {
  int n;
  while (cin >> n, n) {
    bool flag[1000001];
    memset(flag, 0, sizeof(flag));
    int temp;
    for (int i = 0; i < n; ++i) {
      cin >> temp;
      flag[temp] = true;
    }
    bool first = true;
    for (int i = 1; i < 1000001; ++i) {
      if (flag[i]) {
        if (!first) {
          cout << " ";
        }
        if (i + 1 < 1000001 && flag[i + 1] == true) {
          cout << i << "-";
          while (flag[i] == true) {
            ++i;
          }
          cout << i - 1;
        } else {
          cout << i;
        }
        first = false;
      }
    }
    cout << endl;
  }
}

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

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

void solve() {
  int n;
  while (cin >> n, n) {
    bool flag[51];
    for (int i = 0; i < 51; ++i) {
      flag[i] = false;
    }
    int temp;
    for (int i = 0; i < n; ++i) {
      cin >> temp;
      flag[temp] = true;
    }
    bool first = true;
    for (int i = 1; i < 51; ++i) {
      if (flag[i]) {
        if (!first) {
          cout << " ";
        }
        if (i + 1 < 51 && flag[i + 1] == true) {
          cout << i << "-";
          while (flag[i] == true) {
            ++i;
          }
          cout << i - 1;
        } else {
          cout << i;
        }
        first = false;
      }
    }
    cout << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef pair<int, int> P;

int main() {
  int n;
  while (cin >> n, n) {
    vector<P> vec;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      vec.push_back(P(b, a));
    }
    sort(vec.begin(), vec.end());
    bool flag = true;
    int now = 0;
    for (int i = 0; i < n; i++) {
      now += vec[i].second;
      if (now > vec[i].first)
        flag = false;
    }
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

bool dp[1 << 25];

int main() {
  int n;
  while (cin >> n, n) {
    int a[25], b[25];
    for (int i = 0; i < 1 << n; i++)
      dp[i] = false;
    dp[0] = true;
    for (int i = 0; i < n; i++)
      cin >> a[i] >> b[i];
    for (int i = 1; i < 1 << n; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++)
        if (i >> j & 1)
          sum += a[j];
      for (int j = 0; j < n; j++)
        if (i >> j & 1 && dp[i & ~(1 << j)] && b[j] >= sum)
          dp[i] = true;
    }
    if (dp[(1 << n) - 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <utility>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;
typedef pair<int, int> p;

int main() {
  int n;
  while (cin >> n, n) {
    p island[n];
    rep(i, n) cin >> island[i].second >> island[i].first;
    sort(island, island + n);
    int w = 0;
    bool check = true;
    rep(i, n) {
      if ((w + island[i].second) <= island[i].first) {
        w += island[i].second;
      } else {
        check = false;
        break;
      }
    }
    cout << ((check) ? "Yes" : "No") << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <utility>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;
typedef pair<int, int> p;

p island[26];
int n, sum;

bool check(int visit, int w) {
  if (w == sum)
    return true;
  int res = visit;
  bool alt = false;
  rep(i, n) {
    visit = res;
    if (visit & (1 << (i + 1)))
      continue;
    visit |= (1 << (i + 1));
    if (island[i + 1].second < w + island[i + 1].first)
      continue;
    alt |= check(visit, w + island[i + 1].first);
  }
  return alt;
}

int main() {
  while (cin >> n, n) {
    sum = 0;
    rep(i, n + 1) island[i] = p(0, 0);
    rep(i, n) {
      cin >> island[i + 1].first >> island[i + 1].second;
      sum += island[i + 1].first;
    }
    cout << ((check(0, 0)) ? "Yes" : "No") << endl;
  }
  return 0;
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      return 0;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(b, a));
    }
    sort(begin(v), end(v));
    int w = 0;
    for (int i = 0; i < n; i++) {
      w += v[i].second;
      if (w > v[i].first) {
        cout << "No" << endl;
        goto next;
      }
    }
    cout << "Yes" << endl;
  next:;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  int a[30];
  int b[30];
  int sum = 0;
  while (cin >> n) {
    if (n == 0)
      return 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
      sum += a[i];
    }
    int MAXb = 0;
    int MAXbi = 0;
    while (true) {
      for (int i = 0; i < n; i++) {
        if (MAXb < b[i]) {
          MAXbi = i;
          MAXb = b[i];
        }
      }
      if (MAXb >= sum) {
        b[MAXbi] = 0;
        sum -= a[MAXbi];
      } else {
        cout << "No" << endl;
        break;
      }
      if (sum == 0) {
        cout << "Yes" << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES
#define INF 100000000
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

static const double EPS = 1e-8;

struct Land {
  short treasure;
  short bridge;
} island[25];

class mycmp {
public:
  bool operator()(struct Land L1, struct Land L2) {
    return L1.bridge < L2.bridge;
  }
};

int main() {
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    for (int i = 0; i < n; i++) {
      int w, bridge;
      scanf("%d %d", &w, &bridge);
      island[i].bridge = bridge;
      island[i].treasure = w;
    }

    sort(island, island + n, mycmp());

    int sum = 0;
    bool isok = true;
    for (int i = 0; i < n; i++) {
      sum += island[i].treasure;
      if (sum > island[i].bridge)
        isok = false;
    }

    printf("%s\\n", isok ? "Yes" : "No");
  }
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#define INF 100000000
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

static const double EPS = 1e-8;

class Edge {
public:
  int visited;
  short load;
  Edge(int v, int l) {
    visited = v;
    load = l;
  }
  Edge() : load(0), visited(0) {}
};

struct Land {
  short treasure;
  short bridge;
} island[25];

bool gVisited[1 << 25];

int calcT(int visited, int n) {
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (visited & (1 << i))
      res += island[i].treasure;
  }
  return res;
}

void dfs(int s, int visited, int n) {
  for (int i = 0; i < n; i++) {
    if (!gVisited[visited | (1 << i)] &&
        (calcT(visited, n) + island[i].treasure <= island[i].bridge)) {
      gVisited[visited | (1 << i)] = true;
      dfs(s, visited | (1 << i), n);
    }
  }
}

int main() {
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    memset(gVisited, 0, sizeof(gVisited));
    queue<Edge> que;

    for (int i = 0; i < n; i++) {
      int w, bridge;
      scanf("%d %d", &w, &bridge);
      island[i].bridge = bridge;
      island[i].treasure = w;
    }

    for (int i = 0; i < n; i++) {
      dfs(i, (1 << i), n);
    }

    printf("%s\\n", gVisited[(1 << n) - 1] ? "Yes" : "No");
  }
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

struct bridge {
  int qual;
  int max_w;
  bool operator<(const bridge &br) const { return max_w < br.max_w; }
};

int main() {
  while (true) {
    int n;
    bool visi[26] = {
        false,
    };
    vector<bridge> brs;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; ++i) {
      bridge br;
      cin >> br.qual >> br.max_w;
      brs.push_back(br);
    }
    int nowW = 0;
    bool bSucceeded = true;
    sort(brs.begin(), brs.end());
    for (int i = 0; i < brs.size(); ++i) {
      if (nowW + brs[i].qual <= brs[i].max_w)
        nowW += brs[i].qual;
      else {
        bSucceeded = false;
        break;
      }
    }
    cout << ((bSucceeded) ? "Yes" : "No") << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

struct bridge {
  int qual;
  int max_w;
};

bool bf(int nowW, bool vis[], const vector<bridge> &br) {
  int nVisitable = 0;

  for (int i = 0; i < br.size(); ++i) {
    if (!vis[i]) {
      nVisitable++;
      if (nowW > br[i].max_w) {
        return false;
      }
    }
  }

  if (nVisitable == 0)
    return true;

  for (int i = 0; i < br.size(); ++i) {
    if (!vis[i] && nowW <= br[i].max_w && nowW + br[i].qual <= br[i].max_w) {
      vis[i] = true;
      if (bf(nowW + br[i].qual, vis, br))
        return true;
      vis[i] = false;
    }
  }

  return false;
}

int main() {
  while (true) {
    int n;
    bool visi[26] = {
        false,
    };
    vector<bridge> brs;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; ++i) {
      bridge br;
      cin >> br.qual >> br.max_w;
      brs.push_back(br);
    }
    cout << (bf(0, visi, brs) ? "Yes" : "No") << endl;
  }
  return 0;
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>

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

using namespace std;

typedef pair<int, int> P;

int n;
P x[25];

int main() {
  while (true) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    rep(i, n) {
      int a, b;
      scanf("%d%d", &a, &b);
      x[i] = P(b, a);
    }
    sort(x, x + n);
    int w = 0;
    bool ans = true;
    rep(i, n) {
      w += x[i].second;
      if (w > x[i].first) {
        ans = false;
        break;
      }
    }
    printf("%s\\n", ans ? "Yes" : "No");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>

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

using namespace std;

int n;
int x[25];
int c[25];
char z[1 << 25];

int weight(int p) {
  int s = 0;
  rep(i, n) {
    if (p & (1 << i)) {
      s += x[i];
    }
  }
  return s;
}

bool dfs(int p) {
  if (z[p] != -1) {
    return z[p];
  }

  rep(i, n) {
    if (p & (1 << i) && weight((1 << n) - (p - (1 << i))) < c[i] &&
        dfs((p - (1 << i)))) {
      return z[p] = 1;
    }
  }
  return z[p] = 0;
}

int main() {
  while (true) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }

    rep(i, n) { scanf("%d%d", &x[i], &c[i]); }

    fill_n(z, 1 << n, -1);

    z[0] = 1;

    printf("%s\\n", dfs((1 << n) - 1) ? "Yes" : "No");
  }
  return 0;
}
Problem p00638 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
  for (int N; cin >> N, N;) {
    vector<P> v;
    for (int i = 0; i < N; i++) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());

    vector<int> w1, w2;
    for (int i = 0; i < N; i++) {
      w1.push_back(v[i].first);
      w2.push_back(v[i].second);
    }
    partial_sum(w2.begin(), w2.end(), w2.begin());

    bool f = true;
    for (int i = 0; i < N; i++)
      if (w1[i] < w2[i])
        f = false;
    cout << (f ? "Yes" : "No") << endl;
  }
}

Error: 0
-----
1
3
6
-----
-----
1
3
6
-----


Fixed submission:

#include <algorithm>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
  for (int N; cin >> N, N;) {
    vector<P> v;
    for (int i = 0; i < N; i++) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());

    vector<int> w1, w2;
    for (int i = 0; i < N; i++) {
      w1.push_back(v[i].first);
      w2.push_back(v[i].second);
    }
    partial_sum(w2.begin(), w2.end(), w2.begin());

    cerr << "-----" << endl;
    for (int i : w2)
      cerr << i << endl;
    cerr << "-----" << endl;

    bool f = true;
    for (int i = 0; i < N; i++)
      if (w1[i] < w2[i])
        f = false;
    cout << (f ? "Yes" : "No") << endl;
  }
}
Problem p00638 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

using namespace std;
typedef pair<int, int> P;
const int MAX = 25;
P data[MAX + 1];
int in;

bool solve() {
  sort(data, data + in);
  int sum = 0;
  for (int i = 0; i < in; i++) {
    sum += data[i].second;
    if (sum > data[i].first)
      return false;
  }
  return true;
}
int main() {

  while (cin >> in && in) {
    for (int i = 0; i < in; i++)
      cin >> data[i].second >> data[i].first;
    if (solve())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

const int MAX = 25;
int data[MAX + 1];
int tre[MAX + 1];
int in;

bool solve(int sum, int rev, int come, int now) {
  if (rev == in && sum <= data[now])
    return true;
  for (int i = 1; i <= in; i++)
    if (!(come & (1 << i)) && (sum <= data[now] || !now))
      if (solve(sum + tre[i], rev + 1, come + (1 << i), i))
        return true;
  return false;
}

int main() {

  while (cin >> in && in) {
    for (int i = 1; i <= in; i++)
      cin >> tre[i] >> data[i];
    if (solve(0, 0, 0, 0))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
Problem p00638 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int n;
  while (1) {
    vector<pair<int, int>> v;
    cin >> n;
    if (n == 0)
      break;
    v.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end());

    int ans = 0;
    int judge = 0;
    for (int i = 0; i < n; i++) {
      ans += v[i].second;
      if (ans > v[i].first) {
        judge = 1;
        break;
      }
    }

    if (judge == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Error: -11

Fixed submission:

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

int main() {

  int n;
  while (1) {
    vector<pair<int, int>> v;
    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i < n; i++) {
      cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end());

    int ans = 0;
    int judge = 0;
    for (int i = 0; i < n; i++) {
      ans += v[i].second;
      if (ans > v[i].first) {
        judge = 1;
        break;
      }
    }

    if (judge == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}