| problem_id
				 stringlengths 6 6 | language
				 stringclasses 2
				values | original_status
				 stringclasses 3
				values | original_src
				 stringlengths 19 243k | changed_src
				 stringlengths 19 243k | change
				 stringclasses 3
				values | i1
				 int64 0 8.44k | i2
				 int64 0 8.44k | j1
				 int64 0 8.44k | j2
				 int64 0 8.44k | error
				 stringclasses 270
				values | stderr
				 stringlengths 0 226k | 
|---|---|---|---|---|---|---|---|---|---|---|---|
| 
	p00128 | 
	C++ | 
	Runtime Error | 
	#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int i, j = 0, n[5];
  string s;
  char x[5], l[2] = {' ', '*'};
  while (cin >> i) {
    if (j)
      cout << endl;
    sprintf(x, "%05d", i);
    for (j = 5; j-- > 0;)
      n[j] = x[j] - '0';
    s = "";
    while (j++ < 1) {
      for (i = 0; i < 5; i++)
        s += l[j + (n[i] < 5) & 1];
      s += "\n";
    }
    for (j = 5; j-- > 0;)
      s += "=";
    s += "\n";
    while (j++ < 4) {
      for (i = 0; i < 5; i++)
        s += l[n[i] % 5 != j];
      s += "\n";
    }
    cout << s;
  }
  return 0;
} | 
	#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int i, j = 0, n[5];
  string s, l[2] = {" ", "*"};
  char x[6];
  while (cin >> i) {
    if (j)
      cout << endl;
    sprintf(x, "%05d", i);
    for (j = 5; j-- > 0;)
      n[j] = x[j] - '0';
    s = "";
    while (j++ < 1) {
      for (i = 0; i < 5; i++)
        s += l[j + (n[i] < 5) & 1];
      s += "\n";
    }
    for (j = 5; j-- > 0;)
      s += "=";
    s += "\n";
    while (j++ < 4) {
      for (i = 0; i < 5; i++)
        s += l[n[i] % 5 != j];
      s += "\n";
    }
    cout << s;
  }
  return 0;
} | 
	replace | 6 | 8 | 6 | 8 | 
	0 | |
| 
	p00129 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, j) FOR(i, 0, j)
#define mp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1001001001;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1},
          dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
struct P {
  P() {}
  P(ll _r, ll _i) : r(_r), i(_i) {}
  void real(const ll &v) { r = v; }
  void imag(const ll &v) { i = v; }
  ll r, i;
};
ll real(const P &p) { return p.r; }
ll imag(const P &p) { return p.i; }
ll norm(const P &p) {
  ll r = real(p), i = imag(p);
  return r * r + i * i;
}
P operator+(const P &lhs, const P &rhs) {
  return P(real(lhs) + real(rhs), imag(lhs) + imag(rhs));
}
P operator-(const P &lhs, const P &rhs) {
  return P(real(lhs) - real(rhs), imag(lhs) - imag(rhs));
}
P operator-(const P &p) { return P(-real(p), -imag(p)); }
ll cross(const P &lhs, const P &rhs) {
  return real(lhs) * imag(rhs) - imag(lhs) * real(rhs);
}
ll dot(const P &lhs, const P &rhs) {
  return real(lhs) * real(rhs) + imag(lhs) * imag(rhs);
}
ll distance(const P &a, const P &b, const P &p) {
  ll c = cross(p - a, b - a);
  return c * c;
}
bool doesLineCrossCircle(const P &a, const P &b, const P &cc,
                         const ll &radius) {
  if (distance(a, b, cc) > radius * radius * norm(b - a)) {
    return false;
  }
  if (norm(a - cc) > radius * radius && norm(b - cc) > radius * radius) {
    return dot(cc - a, b - a) * dot(cc - b, b - a) <= 0;
  }
  return (norm(a - cc) < radius * radius) ^ (norm(b - cc) < radius * radius);
}
int N, M;
P wps[100100];
ll wrs[100100];
int main() {
  while (std::cin >> N, N) {
    assert(N < 100100);
    REP(i, N) {
      ll re, im;
      std::cin >> re >> im >> wrs[i];
      wps[i].real(re);
      wps[i].imag(im);
    }
    std::cin >> M;
    REP(i, M) {
      P taro, oni;
      ll re, im;
      std::cin >> re >> im;
      taro.real(re);
      taro.imag(im);
      std::cin >> re >> im;
      oni.real(re);
      oni.imag(im);
      bool f = false;
      REP(j, N) {
        assert(norm(taro - wps[j]) != wrs[j] * wrs[j] &&
               norm(oni - wps[j]) != wrs[j] * wrs[j]);
        if (real(taro) == real(oni) && imag(taro) == imag(oni)) {
          continue;
        }
        if (doesLineCrossCircle(taro, oni, wps[j], wrs[j])) {
          f = true;
        }
      }
      if (f) {
        puts("Safe");
      } else {
        puts("Danger");
      }
    }
  }
} | 
	#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, j) FOR(i, 0, j)
#define mp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1001001001;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1},
          dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
struct P {
  P() {}
  P(ll _r, ll _i) : r(_r), i(_i) {}
  void real(const ll &v) { r = v; }
  void imag(const ll &v) { i = v; }
  ll r, i;
};
ll real(const P &p) { return p.r; }
ll imag(const P &p) { return p.i; }
ll norm(const P &p) {
  ll r = real(p), i = imag(p);
  return r * r + i * i;
}
P operator+(const P &lhs, const P &rhs) {
  return P(real(lhs) + real(rhs), imag(lhs) + imag(rhs));
}
P operator-(const P &lhs, const P &rhs) {
  return P(real(lhs) - real(rhs), imag(lhs) - imag(rhs));
}
P operator-(const P &p) { return P(-real(p), -imag(p)); }
ll cross(const P &lhs, const P &rhs) {
  return real(lhs) * imag(rhs) - imag(lhs) * real(rhs);
}
ll dot(const P &lhs, const P &rhs) {
  return real(lhs) * real(rhs) + imag(lhs) * imag(rhs);
}
ll distance(const P &a, const P &b, const P &p) {
  ll c = cross(p - a, b - a);
  return c * c;
}
bool doesLineCrossCircle(const P &a, const P &b, const P &cc,
                         const ll &radius) {
  if (distance(a, b, cc) > radius * radius * norm(b - a)) {
    return false;
  }
  if (norm(a - cc) > radius * radius && norm(b - cc) > radius * radius) {
    return dot(cc - a, b - a) * dot(cc - b, b - a) <= 0;
  }
  return (norm(a - cc) < radius * radius) ^ (norm(b - cc) < radius * radius);
}
int N, M;
P wps[100100];
ll wrs[100100];
int main() {
  while (std::cin >> N, N) {
    assert(N < 100100);
    REP(i, N) {
      ll re, im;
      std::cin >> re >> im >> wrs[i];
      wps[i].real(re);
      wps[i].imag(im);
    }
    std::cin >> M;
    REP(i, M) {
      P taro, oni;
      ll re, im;
      std::cin >> re >> im;
      taro.real(re);
      taro.imag(im);
      std::cin >> re >> im;
      oni.real(re);
      oni.imag(im);
      bool f = false;
      REP(j, N) {
        // assert(norm(taro-wps[j]) != wrs[j] * wrs[j] &&
        //       norm(oni-wps[j]) != wrs[j] * wrs[j]);
        if (real(taro) == real(oni) && imag(taro) == imag(oni)) {
          continue;
        }
        if (doesLineCrossCircle(taro, oni, wps[j], wrs[j])) {
          f = true;
        }
      }
      if (f) {
        puts("Safe");
      } else {
        puts("Danger");
      }
    }
  }
} | 
	replace | 100 | 102 | 100 | 102 | 
	0 | |
| 
	p00129 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Wall {
  int x, y, r;
};
bool inside(Wall w, double x, double y) {
  return w.r * w.r >= (w.x - x) * (w.x - x) + (w.y - y) * (w.y - y);
}
int main() {
  int n, wx, wy, r, m, tx, ty, sx, sy;
  while (cin >> n, n) {
    vector<Wall> w;
    for (int i = 0; i < n; ++i) {
      cin >> wx >> wy >> r;
      w.push_back((Wall){wx, wy, r});
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> tx >> ty >> sx >> sy;
      bool safe = false;
      for (int j = 0; j < n && !safe; ++j) {
        int k = inside(w[j], tx, ty) + inside(w[j], sx, sy);
        if (k == 0) {
          double dx, dy, x, y, minx, maxx, miny, maxy;
          dx = (sx - tx) / 100000.0;
          dy = (sy - ty) / 100000.0;
          x = tx;
          y = ty;
          minx = min(sx, tx);
          maxx = max(sx, tx);
          miny = min(sy, ty);
          maxy = max(sy, ty);
          while (!safe && minx <= x && x <= maxx && miny <= y && y <= maxy) {
            if (inside(w[j], x, y)) {
              safe = true;
              break;
            }
            x += dx;
            y += dy;
          }
        } else if (k == 1) {
          safe = true;
        }
      }
      cout << (safe ? "Safe" : "Danger") << endl;
    }
  }
  return 0;
} | 
	#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Wall {
  int x, y, r;
};
bool inside(Wall w, double x, double y) {
  return w.r * w.r >= (w.x - x) * (w.x - x) + (w.y - y) * (w.y - y);
}
int main() {
  int n, wx, wy, r, m, tx, ty, sx, sy;
  while (cin >> n, n) {
    vector<Wall> w;
    for (int i = 0; i < n; ++i) {
      cin >> wx >> wy >> r;
      w.push_back((Wall){wx, wy, r});
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> tx >> ty >> sx >> sy;
      bool safe = false;
      for (int j = 0; j < n && !safe; ++j) {
        int k = inside(w[j], tx, ty) + inside(w[j], sx, sy);
        if (k == 0) {
          double dx, dy, x, y, minx, maxx, miny, maxy;
          dx = (sx - tx) / 10000.0;
          dy = (sy - ty) / 10000.0;
          x = tx;
          y = ty;
          minx = min(sx, tx);
          maxx = max(sx, tx);
          miny = min(sy, ty);
          maxy = max(sy, ty);
          while (!safe && minx <= x && x <= maxx && miny <= y && y <= maxy) {
            if (inside(w[j], x, y)) {
              safe = true;
              break;
            }
            x += dx;
            y += dy;
          }
        } else if (k == 1) {
          safe = true;
        }
      }
      cout << (safe ? "Safe" : "Danger") << endl;
    }
  }
  return 0;
} | 
	replace | 29 | 31 | 29 | 31 | 
	TLE | |
| 
	p00130 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define COUNT(i, n) for (int i = 1; i <= n; i++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for (ITER(c) it = (c).begin(); it != (c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
const int INF = 1 << 24;
int main(void) {
  int n;
  cin >> n;
  while (n--) {
    string in, res;
    cin >> in;
    res = in.at(0);
    COUNT(i, in.size() - 3) {
      i += 2;
      string cur = in.substr(i, 1);
      if (~res.find(cur))
        continue;
      switch (in.at(i - 2)) {
      case '-':
        res = res + cur;
        break;
      case '<':
        res = cur + res;
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define COUNT(i, n) for (int i = 1; i <= n; i++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for (ITER(c) it = (c).begin(); it != (c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
const int INF = 1 << 24;
int main(void) {
  int n;
  cin >> n;
  while (n--) {
    string in, res;
    cin >> in;
    res = in.at(0);
    for (int i = 3; i < in.size(); i += 3) {
      string cur = in.substr(i, 1);
      if (~res.find(cur))
        continue;
      switch (in.at(i - 2)) {
      case '-':
        res = res + cur;
        break;
      case '<':
        res = cur + res;
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
} | 
	replace | 42 | 44 | 42 | 43 | 
	-6 | 
	terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 3) > this->size() (which is 1)
 | 
| 
	p00132 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define inf (1 << 28)
#define MAX 31
using namespace std;
typedef pair<int, int> ii;
typedef vector<string> vs;
typedef vector<vs> vvs;
int h, w, n, p, k;
int t[30];
char G[MAX][MAX];
char piece[MAX][4][60][60];
ii hw[4][MAX]; // ii(h,w)
int GOMAKASHI[MAX];
ii order[MAX];
int total;
bool complete;
bool debug;
void print(int one, int dir) {
  if (one < 0) {
    rep(i, h) {
      rep(j, w) { cout << G[i][j]; }
      cout << endl;
    }
    cout << endl;
    return;
  }
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  rep(i, H) {
    rep(j, W) { cout << piece[one][dir][i][j]; }
    cout << endl;
  }
  cout << endl;
}
void rotate90(int one, int dir) { // verify [ok]
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  hw[(dir + 1) % 4][one] = ii(W, H);
  int pos = 0;
  char tmp[W][H];
  rep(i, W) {
    rep(j, H) { tmp[i][j] = piece[one][dir][(H - 1) - j][i]; }
  }
  swap(H, W);
  rep(i, H) {
    rep(j, W) { piece[one][(dir + 1) % 4][i][j] = tmp[i][j]; }
  }
}
bool check(int x, int y, int one, int dir) { // verify [ok]
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  // cout << "H = " << H << " W = " << W << endl;
  rep(i, H) {
    rep(j, W) {
      if (piece[one][dir][i][j] == '.')
        continue;
      int nx = j + x;
      int ny = i + y;
      if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) {
        if (piece[one][dir][i][j] == '#') {
          return false;
        }
        continue;
      }
      if (G[ny][nx] == piece[one][dir][i][j]) {
        return false;
      }
    }
  }
  return true;
}
void draw(int x, int y, int one, bool flag,
          int dir) // flag == true? draw : erase
{                  // verify [ok]
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  rep(i, H) {
    rep(j, W) {
      int nx = j + x;
      int ny = i + y;
      if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) {
        assert(piece[one][dir][i][j] == '.');
        continue;
      }
      if (piece[one][dir][i][j] == '.')
        continue;
      if (flag)
        assert(G[ny][nx] == '.');
      if (!flag)
        assert(G[ny][nx] == '#');
      G[ny][nx] = (flag ? '#' : '.');
    }
  }
}
bool finish() { // veritfy [ok]
  rep(i, h) rep(j, w) if (G[i][j] == '.') return false;
  return true;
}
void dfs(int x, int y, int used) { // verify [no]
  if (y >= h) {
    // print(-1);
    complete = true;
    rep(i, 10) {
      if (!((used >> i) & 1))
        complete = false;
      break;
    }
    return;
  }
  if (complete)
    return;
  REP(i, y, h) // y
  // rep(i,h)//y
  {
    REP(j, 0, w) // x
    // rep(j,w)//x
    {
      // cout << j << "," << i << endl;
      // rep(l,n)//which one
      int v = 0;
      for (int l = order[v].first; l != -inf; l = order[++v].first) {
        if ((used >> l) & 1)
          continue;
        rep(_, 4) // rotate
        {
          if (!check(j, i, l, _)) {
            continue;
          }
          if (!complete) {
            /*
if(__builtin_popcount(used) == 5 && !((used >> 1) & 1) && ((used >> 6) & 1) && i
== 1 && j > 7)
            */
            draw(j, i, l, true, _);
            dfs(j, i, used | (1 << l));
            draw(j, i, l, false, _);
            if (complete)
              return;
          }
        }
      }
      if (complete)
        return;
      if (G[i][j] == '.')
        return;
      // if(!next || complete)return;
    }
  }
  if (complete)
    return;
  // if(finish())
  //{
  // print(-1);
  complete = true;
  rep(i, 10) {
    if (!((used >> i) & 1)) {
      complete = false;
      break;
    }
  }
  //}
}
void Input() { // verify [ok]
  total = 0;
  rep(i, h) {
    rep(j, w) {
      cin >> G[i][j];
      if (G[i][j] == '.')
        total++;
    }
  }
  rep(i, MAX) GOMAKASHI[i] = 0;
  rep(i, MAX) rep(j, 4) rep(l, 60) rep(m, 60) piece[i][j][l][m] = '.';
  cin >> n;
  rep(i, n) {
    int ph, pw;
    cin >> ph >> pw;
    hw[0][i] = ii(ph, pw);
    rep(j, ph) {
      rep(l, pw) { cin >> piece[i][0][j][l]; }
    }
    rep(j, ph) rep(l, pw) if (piece[i][0][j][l] == '#') GOMAKASHI[i]++;
    rotate90(i, 0);
    rotate90(i, 1);
    rotate90(i, 2);
    // print(i,0);
    // print(i,1);
    // print(i,2);
    // print(i,3);
    // cout << "-----------------" << endl;
  }
}
bool cmp(const ii &a, const ii &b) { return a.second > b.second; }
int main() {
  while (cin >> h >> w, h | w) {
    Input();
    cin >> p;
    while (p--) {
      cin >> k;
      rep(i, 11) t[i] = false;
      int init = 0;
      int gomakashi = 0;
      rep(i, k) {
        int th;
        cin >> th;
        th--;
        order[i] = ii(th, hw[0][th].first * hw[0][th].second);
        t[th] = true;
        gomakashi += GOMAKASHI[th];
      }
      rep(i, 11) if (!t[i]) init |= (1 << i);
      order[k] = ii(-inf, -inf);
      sort(order, order + k, cmp);
      complete = false;
      if (gomakashi == total)
        dfs(0, 0, init);
      cout << (complete ? "YES" : "NO") << endl;
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define inf (1 << 28)
#define MAX 31
using namespace std;
typedef pair<int, int> ii;
typedef vector<string> vs;
typedef vector<vs> vvs;
int h, w, n, p, k;
int t[30];
char G[MAX][MAX];
char piece[MAX][4][60][60];
ii hw[4][MAX]; // ii(h,w)
int GOMAKASHI[MAX];
ii order[MAX];
int total;
bool complete;
bool debug;
void print(int one, int dir) {
  if (one < 0) {
    rep(i, h) {
      rep(j, w) { cout << G[i][j]; }
      cout << endl;
    }
    cout << endl;
    return;
  }
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  rep(i, H) {
    rep(j, W) { cout << piece[one][dir][i][j]; }
    cout << endl;
  }
  cout << endl;
}
void rotate90(int one, int dir) { // verify [ok]
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  hw[(dir + 1) % 4][one] = ii(W, H);
  int pos = 0;
  char tmp[W][H];
  rep(i, W) {
    rep(j, H) { tmp[i][j] = piece[one][dir][(H - 1) - j][i]; }
  }
  swap(H, W);
  rep(i, H) {
    rep(j, W) { piece[one][(dir + 1) % 4][i][j] = tmp[i][j]; }
  }
}
bool check(int x, int y, int one, int dir) { // verify [ok]
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  // cout << "H = " << H << " W = " << W << endl;
  rep(i, H) {
    rep(j, W) {
      if (piece[one][dir][i][j] == '.')
        continue;
      int nx = j + x;
      int ny = i + y;
      if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) {
        if (piece[one][dir][i][j] == '#') {
          return false;
        }
        continue;
      }
      if (G[ny][nx] == piece[one][dir][i][j]) {
        return false;
      }
    }
  }
  return true;
}
void draw(int x, int y, int one, bool flag,
          int dir) // flag == true? draw : erase
{                  // verify [ok]
  int H = hw[dir][one].first;
  int W = hw[dir][one].second;
  rep(i, H) {
    rep(j, W) {
      int nx = j + x;
      int ny = i + y;
      if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) {
        assert(piece[one][dir][i][j] == '.');
        continue;
      }
      if (piece[one][dir][i][j] == '.')
        continue;
      if (flag)
        assert(G[ny][nx] == '.');
      if (!flag)
        assert(G[ny][nx] == '#');
      G[ny][nx] = (flag ? '#' : '.');
    }
  }
}
bool finish() { // veritfy [ok]
  rep(i, h) rep(j, w) if (G[i][j] == '.') return false;
  return true;
}
void dfs(int x, int y, int used) { // verify [no]
  if (y >= h) {
    // print(-1);
    complete = true;
    rep(i, 10) {
      if (!((used >> i) & 1))
        complete = false;
      break;
    }
    return;
  }
  if (complete)
    return;
  // bitset<10> use(used);
  // cout << "use : " << use << endl;
  bool cut[h][w];
  rep(i, h) rep(j, w) cut[i][j] = false;
  rep(i, h) {
    rep(j, w) {
      if (G[i][j] == '#')
        cut[i][j] = true;
      int v = 0;
      for (int l = order[v].first; l != -inf; l = order[++v].first) {
        if ((used >> l) & 1)
          continue;
        rep(m, 4) {
          if (!check(j, i, l, m))
            continue;
          rep(o, hw[m][l].first) {
            rep(p, hw[m][l].second) {
              if (piece[l][m][o][p] == '.')
                continue;
              cut[i + o][j + p] = true;
            }
          }
        }
      }
      if (!cut[i][j]) {
        // cout << "NO WAY!!! " << j << "," << i << endl;
        return;
      }
    }
  }
  REP(i, y, h) // y
  // rep(i,h)//y
  {
    REP(j, 0, w) // x
    // rep(j,w)//x
    {
      // cout << j << "," << i << endl;
      // rep(l,n)//which one
      int v = 0;
      for (int l = order[v].first; l != -inf; l = order[++v].first) {
        if ((used >> l) & 1)
          continue;
        rep(_, 4) // rotate
        {
          if (!check(j, i, l, _)) {
            continue;
          }
          if (!complete) {
            /*
if(__builtin_popcount(used) == 5 && !((used >> 1) & 1) && ((used >> 6) & 1) && i
== 1 && j > 7)
            */
            draw(j, i, l, true, _);
            dfs(j, i, used | (1 << l));
            draw(j, i, l, false, _);
            if (complete)
              return;
          }
        }
      }
      if (complete)
        return;
      if (G[i][j] == '.')
        return;
      // if(!next || complete)return;
    }
  }
  if (complete)
    return;
  // if(finish())
  //{
  // print(-1);
  complete = true;
  rep(i, 10) {
    if (!((used >> i) & 1)) {
      complete = false;
      break;
    }
  }
  //}
}
void Input() { // verify [ok]
  total = 0;
  rep(i, h) {
    rep(j, w) {
      cin >> G[i][j];
      if (G[i][j] == '.')
        total++;
    }
  }
  rep(i, MAX) GOMAKASHI[i] = 0;
  rep(i, MAX) rep(j, 4) rep(l, 60) rep(m, 60) piece[i][j][l][m] = '.';
  cin >> n;
  rep(i, n) {
    int ph, pw;
    cin >> ph >> pw;
    hw[0][i] = ii(ph, pw);
    rep(j, ph) {
      rep(l, pw) { cin >> piece[i][0][j][l]; }
    }
    rep(j, ph) rep(l, pw) if (piece[i][0][j][l] == '#') GOMAKASHI[i]++;
    rotate90(i, 0);
    rotate90(i, 1);
    rotate90(i, 2);
    // print(i,0);
    // print(i,1);
    // print(i,2);
    // print(i,3);
    // cout << "-----------------" << endl;
  }
}
bool cmp(const ii &a, const ii &b) { return a.second > b.second; }
int main() {
  while (cin >> h >> w, h | w) {
    Input();
    cin >> p;
    while (p--) {
      cin >> k;
      rep(i, 11) t[i] = false;
      int init = 0;
      int gomakashi = 0;
      rep(i, k) {
        int th;
        cin >> th;
        th--;
        order[i] = ii(th, hw[0][th].first * hw[0][th].second);
        t[th] = true;
        gomakashi += GOMAKASHI[th];
      }
      rep(i, 11) if (!t[i]) init |= (1 << i);
      order[k] = ii(-inf, -inf);
      sort(order, order + k, cmp);
      complete = false;
      if (gomakashi == total)
        dfs(0, 0, init);
      cout << (complete ? "YES" : "NO") << endl;
    }
  }
  return 0;
} | 
	insert | 137 | 137 | 137 | 170 | 
	TLE | |
| 
	p00134 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
using namespace std;
int main() {
  int n, s[1000], i, j, b;
  long long int av = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    av = s[i] + av;
  }
  cout << av / n << endl;
} | 
	#include <iostream>
using namespace std;
int main() {
  int n, i, b, s[100010];
  long long int av = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    av = s[i] + av;
  }
  cout << av / n << endl;
} | 
	replace | 3 | 4 | 3 | 4 | 
	0 | |
| 
	p00135 | 
	C++ | 
	Runtime Error | 
	#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int a, b, n;
double d, e, f;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d:%d", a, b);
    d = b * 6;
    e = 1.0 * (a * 30 + b) / 2.0;
    f = abs(d - e);
    if (f > 180) {
      f = 360 - f;
    }
    if (f < 30) {
      cout << "alert" << endl;
    } else if (f < 90) {
      cout << "warning" << endl;
    } else {
      cout << "safe" << endl;
    }
  }
} | 
	#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int a, b, n;
double d, e, f;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d:%d", &a, &b);
    f = abs(a * 30 - b * 11.0 / 2.0);
    if (f > 180) {
      f = 360 - f;
    }
    if (f < 30) {
      cout << "alert" << endl;
    } else if (f < 90) {
      cout << "warning" << endl;
    } else {
      cout << "safe" << endl;
    }
  }
} | 
	replace | 9 | 13 | 9 | 11 | 
	-11 | |
| 
	p00137 | 
	C++ | 
	Runtime Error | 
	#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
  long n, m, i, j;
  string s, t;
  stringstream ss;
  string::size_type k;
  char mm[9];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> m;
    cout << "Case " << i + 1 << ":" << endl;
    for (j = 0; j < 10; j++) {
      sprintf(mm, "%08d", m * m);
      s = string(mm);
      t = s.substr(2, 4);
      k = t.find_first_not_of('0');
      cout << t.substr(k) << endl;
      ss.str("");
      ss.clear();
      ss << t;
      ss >> m;
    }
  }
  return 0;
} | 
	#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
  long n, m, i, j;
  string s, t;
  stringstream ss;
  string::size_type k;
  char mm[9];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> m;
    cout << "Case " << i + 1 << ":" << endl;
    for (j = 0; j < 10; j++) {
      sprintf(mm, "%08d", m * m);
      s = string(mm);
      t = s.substr(2, 4);
      k = t.find_first_not_of('0');
      if (k == string::npos)
        cout << '0' << endl;
      else
        cout << t.substr(k) << endl;
      ss.str("");
      ss.clear();
      ss << t;
      ss >> m;
    }
  }
  return 0;
} | 
	replace | 20 | 21 | 20 | 24 | 
	0 | |
| 
	p00138 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const double Eps = 1e-6;
using namespace std;
int main() {
  pair<double, int> runners[24];
  for (int i = 0; i < 24; ++i) {
    int a;
    double b;
    scanf("%d %lf", &a, &b);
    runners[i] = make_pair(b, a);
  }
  for (int i = 0; i < 3; ++i) {
    sort(runners + i * 8, runners + 8 + i * 8);
    printf("%d %.2f\n", runners[0 + i * 8].second, runners[0 + i * 8]);
    printf("%d %.2f\n", runners[1 + i * 8].second, runners[1 + i * 8]);
    runners[0 + i * 8].first = runners[1 + i * 8].first = 1e10;
  }
  sort(runners, runners + 24);
  printf("%d %.2f\n", runners[0].second, runners[0].first);
  printf("%d %.2f\n", runners[1].second, runners[1].first);
  return 0;
} | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const double Eps = 1e-6;
using namespace std;
int main() {
  pair<double, int> runners[24];
  for (int i = 0; i < 24; ++i) {
    int a;
    double b;
    scanf("%d %lf", &a, &b);
    runners[i] = make_pair(b, a);
  }
  for (int i = 0; i < 3; ++i) {
    sort(runners + i * 8, runners + 8 + i * 8);
    printf("%d %.2f\n", runners[0 + i * 8].second, runners[0 + i * 8].first);
    printf("%d %.2f\n", runners[1 + i * 8].second, runners[1 + i * 8].first);
    runners[0 + i * 8].first = runners[1 + i * 8].first = 1e10;
  }
  sort(runners, runners + 24);
  printf("%d %.2f\n", runners[0].second, runners[0].first);
  printf("%d %.2f\n", runners[1].second, runners[1].first);
  return 0;
} | 
	replace | 32 | 34 | 32 | 34 | 
	0 | |
| 
	p00140 | 
	C++ | 
	Runtime Error | 
	#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define PB push_back
#define p(a, b) g.PB(pii(a, b))
#define INF (1 << 29)
typedef pair<int, int> pii;
typedef vector<pii> vp;
int main() {
  vp g; // pos to
  REP(i, 9) p(i, i + 1);
  p(9, 10);
  REP(i, 4) p(5 - i, i + 11);
  p(1, 0);
  int n;
  cin >> n;
  while (n--) {
    int prev[2][10], miner[2], tmp[2];
    int a, b;
    scanf("%d %d", &a, &b);
    tmp[0] = tmp[1] = INF;
    REP(i, g.size()) if (g[i].first == a) {
      if (tmp[0] == INF)
        tmp[0] = i;
      else
        tmp[1] = i;
    }
    miner[0] = miner[1] = INF;
    REP(i, 2) {
      if (tmp[i] == INF)
        break;
      queue<int> que; // pos
      que.push(tmp[i]);
      miner[i] = 0;
      while (true) {
        int pos = g[que.front()].first;
        int to = g[que.front()].second;
        que.pop();
        prev[i][miner[i]++] = pos;
        if (pos == b)
          break;
        que.push(to);
      }
    }
    int ans = miner[0] < miner[1] ? 0 : 1;
    REP(i, miner[ans]) {
      if (i != 0)
        printf(" ");
      printf("%d", prev[ans][i]);
    }
    cout << endl;
  }
  return 0;
} | 
	#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define PB push_back
#define p(a, b) g.PB(pii(a, b))
#define INF (1 << 29)
typedef pair<int, int> pii;
typedef vector<pii> vp;
int main() {
  vp g; // pos to
  REP(i, 9) p(i, i + 1);
  p(9, 10);
  REP(i, 4) p(5 - i, i + 11);
  p(1, 0);
  int n;
  cin >> n;
  while (n--) {
    int prev[2][20], miner[2], tmp[2];
    int a, b;
    scanf("%d %d", &a, &b);
    tmp[0] = tmp[1] = INF;
    REP(i, g.size()) if (g[i].first == a) {
      if (tmp[0] == INF)
        tmp[0] = i;
      else
        tmp[1] = i;
    }
    miner[0] = miner[1] = INF;
    REP(i, 2) {
      if (tmp[i] == INF)
        break;
      queue<int> que; // pos
      que.push(tmp[i]);
      miner[i] = 0;
      while (true) {
        int pos = g[que.front()].first;
        int to = g[que.front()].second;
        que.pop();
        prev[i][miner[i]++] = pos;
        if (pos == b)
          break;
        que.push(to);
      }
    }
    int ans = miner[0] < miner[1] ? 0 : 1;
    REP(i, miner[ans]) {
      if (i != 0)
        printf(" ");
      printf("%d", prev[ans][i]);
    }
    cout << endl;
  }
  return 0;
} | 
	replace | 23 | 24 | 23 | 24 | 
	0 | |
| 
	p00140 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define INF 1000010
using namespace std;
int busstop[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3,
                 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int main() {
  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    int e1, e2;
    bool isFirst = false;
    cin >> e1 >> e2;
    if (e1 > e2)
      isFirst = true;
    for (int i = 0;; i++) {
      if (busstop[i] == e1) {
        if (isFirst) {
          isFirst = !isFirst;
          continue;
        }
        for (int j = i;; j++) {
          if (busstop[j] == e2) {
            cout << " " << busstop[j];
            goto end_state;
          } else {
            if (j == i)
              cout << busstop[j];
            else
              cout << " " << busstop[j];
          }
        }
      }
    }
  end_state:
    cout << endl;
  }
} | 
	#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define INF 1000010
using namespace std;
int busstop[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4,
                 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int main() {
  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    int e1, e2;
    bool isFirst = false;
    cin >> e1 >> e2;
    if (e1 > e2)
      isFirst = true;
    for (int i = 0;; i++) {
      if (busstop[i] == e1) {
        if (isFirst) {
          isFirst = !isFirst;
          continue;
        }
        for (int j = i;; j++) {
          if (busstop[j] == e2) {
            cout << " " << busstop[j];
            goto end_state;
          } else {
            if (j == i)
              cout << busstop[j];
            else
              cout << " " << busstop[j];
          }
        }
      }
    }
  end_state:
    cout << endl;
  }
} | 
	replace | 33 | 35 | 33 | 35 | 
	0 | |
| 
	p00140 | 
	C++ | 
	Runtime Error | 
	#include <climits>
#include <iostream>
#include <memory>
#include <vector>
class Bus_stop {
public:
  Bus_stop(const int &i) : id{i}, mins(10, INT_MAX - 1), prevs(10, nullptr) {
    mins.at(i) = 0;
  };
  //?¬?????????????????¨????
  void set_next(Bus_stop &other) {
    // this ?????? other ????????????????????????
    sub_next(
        other); // other
                // ???????????????????¨???????????£????????????????????????????
  }
  //??¨??????????????¢?´¢
  void search_route() {
    call_sub_search(
        mins); // private???????????????mins???virtual??¢??°?????±??§???????????????????????????
  };
  std::vector<int> get_route(const int &from, const int &to) const {
    return move(to)->sub_route(from);
  }
protected:
  // Bus_stop???ID
  int id;
  //?????????????????´??°??¨????¬??????¢?´¢???????§?????????????
  void sub_search(Bus_stop *next, const std::vector<int> &ms) {
    if (next->renew(ms, this)) { //?????????????????´??°????????£??????
      next->search_route();      //?¬??????¢?´¢???????§?
    }
  }
private:
  //???????????????????°??????????
  std::vector<int> mins;
  //????°???????????????¨???"???????????????"??????????????????
  std::vector<Bus_stop *> prevs;
  // mins??¨prevs?????´??°?????´??°???????????°true???????????°false
  bool renew(const std::vector<int> &prev, Bus_stop *from) {
    bool res = false;
    for (auto i = 0; i < prev.size(); ++i) {
      if (prev.at(i) + 1 < mins.at(i)) {
        mins.at(i) = prev.at(i) + 1;
        prevs.at(i) = from;
        res = true;
      }
    }
    return res;
  }
  //?????????????§????
  const Bus_stop *move(const int &to) const {
    if (to == id) {
      return this;
    } else {
      return prevs.at(to)->move(to);
    }
  }
  std::vector<int> sub_route(const int &from) const {
    if (from == id) {
      return std::vector<int>{from};
    } else {
      auto res = prevs.at(from)->sub_route(from);
      res.push_back(id);
      return res;
    }
  }
  //?¬???????????????????????????¢?´¢
  virtual void call_sub_search(const std::vector<int> &) = 0;
  //?¬?????????????????¨????
  virtual void sub_next(Bus_stop &) = 0;
};
class Loop_stop : public Bus_stop {
public:
  Loop_stop(const int &i) : Bus_stop(i), next{nullptr} {};
private:
  void sub_next(Bus_stop &other) override { next = &other; }
  void call_sub_search(const std::vector<int> &mins) override {
    sub_search(next, mins);
  }
  Bus_stop *next;
};
class Line_stop : public Bus_stop {
public:
  Line_stop(const int &i) : Bus_stop(i), next1{nullptr}, next2{nullptr} {};
private:
  void sub_next(Bus_stop &other) override {
    if (next1) {
      next2 = &other;
    } else {
      next1 = &other;
    }
  }
  void call_sub_search(const std::vector<int> &mins) override {
    sub_search(next1, mins);
    sub_search(next2, mins);
  }
  Bus_stop *next1, *next2;
};
void show(std::vector<int> &route) {
  std::cout << route.at(0);
  for (auto i = 1; i < route.size(); ++i) {
    std::cout << ' ' << route.at(i);
  }
  std::cout << std::endl;
}
int main() {
  std::vector<std::shared_ptr<Bus_stop>> stops(15, nullptr);
  for (auto i = 0; i < 15; ++i) {
    stops.at(i) =
        std::make_shared<Loop_stop>(Loop_stop((i < 10) ? i : (15 - i)));
  }
  for (auto i = 0; i < 15; ++i) {
    stops.at(i)->set_next(*stops.at((i + 1) % 15));
  }
  stops.at(0)->search_route();
  int n;
  std::cin >> n;
  for (auto i = 0; i < n; ++i) {
    int from, to;
    std::cin >> from >> to;
    auto route1 = stops.at(to)->get_route(from, to);
    auto route2 = stops.at(15 - to)->get_route(from, to);
    if (route1.size() < route2.size()) {
      show(route1);
    } else {
      show(route2);
    }
  }
  return 0;
} | 
	#include <climits>
#include <iostream>
#include <memory>
#include <vector>
class Bus_stop {
public:
  Bus_stop(const int &i) : id{i}, mins(10, INT_MAX - 1), prevs(10, nullptr) {
    mins.at(i) = 0;
  };
  //?¬?????????????????¨????
  void set_next(Bus_stop &other) {
    // this ?????? other ????????????????????????
    sub_next(
        other); // other
                // ???????????????????¨???????????£????????????????????????????
  }
  //??¨??????????????¢?´¢
  void search_route() {
    call_sub_search(
        mins); // private???????????????mins???virtual??¢??°?????±??§???????????????????????????
  };
  std::vector<int> get_route(const int &from, const int &to) const {
    return move(to)->sub_route(from);
  }
protected:
  // Bus_stop???ID
  int id;
  //?????????????????´??°??¨????¬??????¢?´¢???????§?????????????
  void sub_search(Bus_stop *next, const std::vector<int> &ms) {
    if (next->renew(ms, this)) { //?????????????????´??°????????£??????
      next->search_route();      //?¬??????¢?´¢???????§?
    }
  }
private:
  //???????????????????°??????????
  std::vector<int> mins;
  //????°???????????????¨???"???????????????"??????????????????
  std::vector<Bus_stop *> prevs;
  // mins??¨prevs?????´??°?????´??°???????????°true???????????°false
  bool renew(const std::vector<int> &prev, Bus_stop *from) {
    bool res = false;
    for (auto i = 0; i < prev.size(); ++i) {
      if (prev.at(i) + 1 < mins.at(i)) {
        mins.at(i) = prev.at(i) + 1;
        prevs.at(i) = from;
        res = true;
      }
    }
    return res;
  }
  //?????????????§????
  const Bus_stop *move(const int &to) const {
    if (to == id) {
      return this;
    } else {
      return prevs.at(to)->move(to);
    }
  }
  std::vector<int> sub_route(const int &from) const {
    if (from == id) {
      return std::vector<int>{from};
    } else {
      auto res = prevs.at(from)->sub_route(from);
      res.push_back(id);
      return res;
    }
  }
  //?¬???????????????????????????¢?´¢
  virtual void call_sub_search(const std::vector<int> &) = 0;
  //?¬?????????????????¨????
  virtual void sub_next(Bus_stop &) = 0;
};
class Loop_stop : public Bus_stop {
public:
  Loop_stop(const int &i) : Bus_stop(i), next{nullptr} {};
private:
  void sub_next(Bus_stop &other) override { next = &other; }
  void call_sub_search(const std::vector<int> &mins) override {
    sub_search(next, mins);
  }
  Bus_stop *next;
};
class Line_stop : public Bus_stop {
public:
  Line_stop(const int &i) : Bus_stop(i), next1{nullptr}, next2{nullptr} {};
private:
  void sub_next(Bus_stop &other) override {
    if (next1) {
      next2 = &other;
    } else {
      next1 = &other;
    }
  }
  void call_sub_search(const std::vector<int> &mins) override {
    sub_search(next1, mins);
    sub_search(next2, mins);
  }
  Bus_stop *next1, *next2;
};
void show(std::vector<int> &route) {
  std::cout << route.at(0);
  for (auto i = 1; i < route.size(); ++i) {
    std::cout << ' ' << route.at(i);
  }
  std::cout << std::endl;
}
int main() {
  std::vector<std::shared_ptr<Bus_stop>> stops(15, nullptr);
  for (auto i = 0; i < 15; ++i) {
    stops.at(i) =
        std::make_shared<Loop_stop>(Loop_stop((i < 10) ? i : (15 - i)));
  }
  for (auto i = 0; i < 15; ++i) {
    stops.at(i)->set_next(*stops.at((i + 1) % 15));
  }
  stops.at(0)->search_route();
  int n;
  std::cin >> n;
  for (auto i = 0; i < n; ++i) {
    int from, to;
    std::cin >> from >> to;
    auto route1 = stops.at(0)->get_route(from, to);
    auto route2 = stops.at(9)->get_route(from, to);
    if (route1.size() < route2.size()) {
      show(route1);
    } else {
      show(route2);
    }
  }
  return 0;
} | 
	replace | 125 | 127 | 125 | 127 | 
	0 | |
| 
	p00140 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  int a, b;
  cin >> n;
  for (int loop = 0; loop < n; loop++) {
    cin >> a >> b;
    if (a == b) {
      printf("%d\n", b);
    } else if (a < b) {
      for (int i = a; i < b; i++) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    } else if (a <= 5) {
      for (int i = a; i > b; i--) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    } else if (b <= 5) {
      for (int i = a; i <= 9; i++) {
        printf("%d ", i);
      }
      for (int i = 5; i > b; i++) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    } else {
      for (int i = a; i <= 9; i++) {
        printf("%d ", i);
      }
      printf("5 4 3 2 1 0 1 2 3 4 5 ");
      for (int i = 6; i < b; i++) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  int a, b;
  cin >> n;
  for (int loop = 0; loop < n; loop++) {
    cin >> a >> b;
    if (a == b) {
      printf("%d\n", b);
    } else if (a < b) {
      for (int i = a; i < b; i++) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    } else if (a <= 5) {
      for (int i = a; i > b; i--) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    } else if (b <= 5) {
      for (int i = a; i <= 9; i++) {
        printf("%d ", i);
      }
      for (int i = 5; i > b; i--) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    } else {
      for (int i = a; i <= 9; i++) {
        printf("%d ", i);
      }
      printf("5 4 3 2 1 0 1 2 3 4 5 ");
      for (int i = 6; i < b; i++) {
        printf("%d ", i);
      }
      printf("%d\n", b);
    }
  }
  return 0;
} | 
	replace | 33 | 34 | 33 | 34 | 
	TLE | |
| 
	p00141 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
using namespace std;
bool vis[30][30], na[30][30];
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
int ex[] = {-1, 1, 0, 0}, ey[] = {0, 0, -1, 1};
int n;
void DFS(int y, int x, int k) {
  vis[y][x] = true;
  na[y][x] = true;
  int xx, yy;
  bool done = false;
  for (int i = 0; i < 4; i++) {
    xx = x + dx[k], yy = y + dy[k];
    bool ok = false;
    if (0 <= xx && xx < n && 0 <= yy && yy < n) {
      if (na[yy][xx] == false) {
        ok = true;
      }
    }
    if (ok) {
      done = true;
      break;
    }
    k = (k + 1) % 4;
  }
  if (!done)
    return;
  for (int i = 0; i < 2; i++) {
    int r = i + (k % 2) * 2;
    int nx = x + ex[r], ny = y + ey[r];
    if (0 <= nx && nx < n && 0 <= ny && ny < n) {
      na[ny][nx] = true;
    }
  }
  DFS(yy, xx, k);
}
int main() {
  int q;
  cin >> q;
  for (int u = 0; u < q; u++) {
    if (u)
      cout << endl;
    cin >> n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        vis[i][j] = false;
        na[i][j] = false;
      }
    }
    DFS(n - 1, 0, 0);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)
        cout << (vis[i][j] ? "#" : " ");
      cout << endl;
    }
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
bool vis[110][110], na[110][110];
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
int ex[] = {-1, 1, 0, 0}, ey[] = {0, 0, -1, 1};
int n;
void DFS(int y, int x, int k) {
  vis[y][x] = true;
  na[y][x] = true;
  int xx, yy;
  bool done = false;
  for (int i = 0; i < 4; i++) {
    xx = x + dx[k], yy = y + dy[k];
    bool ok = false;
    if (0 <= xx && xx < n && 0 <= yy && yy < n) {
      if (na[yy][xx] == false) {
        ok = true;
      }
    }
    if (ok) {
      done = true;
      break;
    }
    k = (k + 1) % 4;
  }
  if (!done)
    return;
  for (int i = 0; i < 2; i++) {
    int r = i + (k % 2) * 2;
    int nx = x + ex[r], ny = y + ey[r];
    if (0 <= nx && nx < n && 0 <= ny && ny < n) {
      na[ny][nx] = true;
    }
  }
  DFS(yy, xx, k);
}
int main() {
  int q;
  cin >> q;
  for (int u = 0; u < q; u++) {
    if (u)
      cout << endl;
    cin >> n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        vis[i][j] = false;
        na[i][j] = false;
      }
    }
    DFS(n - 1, 0, 0);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)
        cout << (vis[i][j] ? "#" : " ");
      cout << endl;
    }
  }
  return 0;
} | 
	replace | 2 | 3 | 2 | 3 | 
	0 | |
| 
	p00141 | 
	C++ | 
	Time Limit Exceeded | 
	#include "bits/stdc++.h"
using namespace std;
// #define int long long
#define DBG 0
#define dump(o)                                                                \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << " ";                                           \
  }
#define dumpl(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << endl;                                          \
  }
#define dumpc(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o;                                                                \
    for (auto &e : (o))                                                        \
      cerr << " " << e;                                                        \
    cerr << endl;                                                              \
  }
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int N;
bool inrange(int i, int j) { return 0 <= i && i < N && 0 <= j && j < N; }
signed main() {
  int d;
  cin >> d;
  int a[120][120] = {};
  int di[] = {-1, 0, 1, 0};
  int dj[] = {0, 1, 0, -1};
  rep(h, 0, d) {
    if (h != 0)
      cout << endl;
    memset(a, 0, sizeof(a));
    cin >> N;
    int ci = N - 1, cj = 0;
    int dir = 0;
    int cnt = 1;
    while (true) {
      a[ci][cj] = cnt;
      int ni = ci + di[dir], nj = cj + dj[dir];
      if (!inrange(ni, nj)) {
        dir = (dir + 1) % 4;
        ni = ci + di[dir], nj = cj + dj[dir];
      } else if (inrange(ni + di[dir], nj + dj[dir]) &&
                 a[ni + di[dir]][nj + dj[dir]] != 0) {
        dir = (dir + 1) % 4;
        ni = ci + di[dir], nj = cj + dj[dir];
      }
      dump(ci) dumpl(cj);
      dump(ni + dj[dir]) dumpl(nj + dj[dir]);
      if (inrange(ni + di[dir], nj + dj[dir]) &&
          (a[ni + di[dir]][nj + dj[dir]] != 0 ||
           a[ni + di[(dir + 1) % 4]][nj + dj[(dir + 1) % 4]] != 0)) {
        break;
      }
      ci += di[dir];
      cj += dj[dir];
    }
    rep(i, 0, N) {
      rep(j, 0, N) { cout << (a[i][j] ? '#' : ' '); }
      cout << endl;
    }
  }
  return 0;
} | 
	#include "bits/stdc++.h"
using namespace std;
// #define int long long
#define DBG 0
#define dump(o)                                                                \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << " ";                                           \
  }
#define dumpl(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << endl;                                          \
  }
#define dumpc(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o;                                                                \
    for (auto &e : (o))                                                        \
      cerr << " " << e;                                                        \
    cerr << endl;                                                              \
  }
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int N;
bool inrange(int i, int j) { return 0 <= i && i < N && 0 <= j && j < N; }
signed main() {
  int d;
  cin >> d;
  int a[120][120] = {};
  int di[] = {-1, 0, 1, 0};
  int dj[] = {0, 1, 0, -1};
  rep(h, 0, d) {
    if (h != 0)
      cout << endl;
    memset(a, 0, sizeof(a));
    cin >> N;
    if (N == 1) {
      cout << "#" << endl;
      continue;
    }
    if (N == 2) {
      cout << "##" << endl << "# " << endl;
      continue;
    }
    int ci = N - 1, cj = 0;
    int dir = 0;
    int cnt = 1;
    while (true) {
      a[ci][cj] = cnt;
      int ni = ci + di[dir], nj = cj + dj[dir];
      if (!inrange(ni, nj)) {
        dir = (dir + 1) % 4;
        ni = ci + di[dir], nj = cj + dj[dir];
      } else if (inrange(ni + di[dir], nj + dj[dir]) &&
                 a[ni + di[dir]][nj + dj[dir]] != 0) {
        dir = (dir + 1) % 4;
        ni = ci + di[dir], nj = cj + dj[dir];
      }
      dump(ci) dumpl(cj);
      dump(ni + dj[dir]) dumpl(nj + dj[dir]);
      if (inrange(ni + di[dir], nj + dj[dir]) &&
          (a[ni + di[dir]][nj + dj[dir]] != 0 ||
           a[ni + di[(dir + 1) % 4]][nj + dj[(dir + 1) % 4]] != 0)) {
        break;
      }
      ci += di[dir];
      cj += dj[dir];
    }
    rep(i, 0, N) {
      rep(j, 0, N) { cout << (a[i][j] ? '#' : ' '); }
      cout << endl;
    }
  }
  return 0;
} | 
	insert | 54 | 54 | 54 | 64 | 
	TLE | |
| 
	p00142 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
int ok(int n) {
  if (n < 2)
    return 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}
int main() {
  int n;
  while (cin >> n, n) {
    set<int> r;
    for (int i = 1; i < n; i++)
      r.insert((i * i) % n);
    vector<int> wow;
    for (set<int>::iterator it = r.begin(); it != r.end(); ++it)
      wow.push_back(*it);
    map<int, int> mp;
    for (int i = 0; i < wow.size(); i++) {
      for (int j = 0; j < wow.size(); j++) {
        if (i == j)
          continue;
        int g = wow[i] - wow[j];
        if (g < 0)
          g += n;
        if (g > (n - 1) / 2)
          g = n - g;
        mp[g]++;
      }
    }
    for (int i = 1; i <= (n - 1) / 2; i++)
      cout << mp[i] << endl;
  }
} | 
	#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
int ok(int n) {
  if (n < 2)
    return 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}
int main() {
  int n;
  while (cin >> n, n) {
    set<int> r;
    for (int i = 1; i < n; i++)
      r.insert((i * i) % n);
    vector<int> wow;
    for (set<int>::iterator it = r.begin(); it != r.end(); ++it)
      wow.push_back(*it);
    int mp[10001] = {0};
    for (int i = 0; i < wow.size(); i++) {
      for (int j = 0; j < wow.size(); j++) {
        if (i == j)
          continue;
        int g = wow[i] - wow[j];
        if (g < 0)
          g += n;
        if (g > (n - 1) / 2)
          g = n - g;
        mp[g]++;
      }
    }
    for (int i = 1; i <= (n - 1) / 2; i++)
      cout << mp[i] << endl;
  }
} | 
	replace | 25 | 26 | 25 | 26 | 
	TLE | |
| 
	p00142 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int ans[5001], m[10001], f[10001], n, i, j, k, c;
  while (cin >> n) {
    if (n == 0)
      break;
    c = 0;
    for (i = 0; i < 10001; i++)
      ans[i] = f[i] = 0;
    for (i = 1; i <= (n - 1) / 2; i++) {
      k = (i * i) % n;
      if (f[k] == 0) {
        f[k] = 1;
        m[c++] = k;
      }
    }
    for (i = 0; i < c - 1; i++)
      for (j = i + 1; j < c; j++) {
        k = m[j] - m[i];
        k = k < 0 ? k + n : k;
        k = k > (n - 1) / 2 ? n - k : k;
        ans[k]++;
      }
    for (i = 1; i <= (n - 1) / 2; i++)
      cout << ans[i] * 2 << endl;
  }
  return 0;
} | 
	#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int ans[10001], m[10001], f[10001], n, i, j, k, c;
  while (cin >> n) {
    if (n == 0)
      break;
    c = 0;
    for (i = 0; i < 10001; i++)
      ans[i] = f[i] = 0;
    for (i = 1; i <= (n - 1) / 2; i++) {
      k = (i * i) % n;
      if (f[k] == 0) {
        f[k] = 1;
        m[c++] = k;
      }
    }
    for (i = 0; i < c - 1; i++)
      for (j = i + 1; j < c; j++) {
        k = m[j] - m[i];
        k = k < 0 ? k + n : k;
        k = k > (n - 1) / 2 ? n - k : k;
        ans[k]++;
      }
    for (i = 1; i <= (n - 1) / 2; i++)
      cout << ans[i] * 2 << endl;
  }
  return 0;
} | 
	replace | 6 | 7 | 6 | 7 | 
	0 | |
| 
	p00142 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
int main() {
  int ans[100000000], n;
  while (cin >> n, n) {
    vector<int> vec;
    rep(i, (int)((n - 1) / 2) + 1) ans[i] = 0;
    REP(i, 1, n) vec.push_back((i * i) % n);
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    rep(i, vec.size()) {
      rep(j, vec.size()) {
        int diff = vec[i] - vec[j];
        if (diff < 0)
          diff += n;
        if (diff > (n - 1) / 2)
          diff = n - diff;
        if (1 <= diff && diff <= (n - 1) / 2)
          ans[diff]++;
      }
    }
    REP(i, 1, (int)((n - 1) / 2) + 1) cout << ans[i] << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
int main() {
  int ans[1000000], n;
  while (cin >> n, n) {
    vector<int> vec;
    rep(i, (int)((n - 1) / 2) + 1) ans[i] = 0;
    REP(i, 1, n) vec.push_back((i * i) % n);
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    rep(i, vec.size()) {
      rep(j, vec.size()) {
        int diff = vec[i] - vec[j];
        if (diff < 0)
          diff += n;
        if (diff > (n - 1) / 2)
          diff = n - diff;
        if (1 <= diff && diff <= (n - 1) / 2)
          ans[diff]++;
      }
    }
    REP(i, 1, (int)((n - 1) / 2) + 1) cout << ans[i] << endl;
  }
  return 0;
} | 
	replace | 8 | 9 | 8 | 9 | 
	-11 | |
| 
	p00142 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main() {
  int n;
  while (cin >> n && n != 0) {
    bool isAppeared[10001];
    int data[10001];
    fill(isAppeared, isAppeared + 10001, false);
    fill(data, data + 10001, 0);
    // memset(isAppeared,0,sizeof(isAppeared));
    // memset(data,0,sizeof(data));
    for (int i = 1; i < n; i++) {
      int r = (i * i) % n;
      isAppeared[r] = true;
    }
    for (int i = 0; i < 10001; i++) {
      for (int j = 0; j < 10001; j++) {
        if (isAppeared[i] && isAppeared[j]) {
          int ret = i - j;
          if (ret < 0)
            ret += n;
          if (((n - 1) / 2) < ret) {
            ret = n - ret;
          }
          data[ret]++;
        }
      }
    }
    for (int i = 1; i <= ((n - 1) / 2); i++) {
      if (data[i] != 0)
        cout << data[i] << endl;
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main() {
  int n;
  while (cin >> n && n != 0) {
    bool isAppeared[10001];
    int data[10001];
    fill(isAppeared, isAppeared + 10001, false);
    fill(data, data + 10001, 0);
    // memset(isAppeared,0,sizeof(isAppeared));
    // memset(data,0,sizeof(data));
    for (int i = 1; i < n; i++) {
      int r = (i * i) % n;
      isAppeared[r] = true;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (isAppeared[i] && isAppeared[j]) {
          int ret = i - j;
          if (ret < 0)
            ret += n;
          if (((n - 1) / 2) < ret) {
            ret = n - ret;
          }
          data[ret]++;
        }
      }
    }
    for (int i = 1; i <= ((n - 1) / 2); i++) {
      if (data[i] != 0)
        cout << data[i] << endl;
    }
  }
  return 0;
} | 
	replace | 22 | 24 | 22 | 24 | 
	TLE | |
| 
	p00142 | 
	C++ | 
	Time Limit Exceeded | 
	#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
//// < "d:\d_download\visual studio
///2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
///studio 2015\projects\programing_contest_c++\debug\b.txt"
int main() {
  while (1) {
    int N;
    cin >> N;
    set<int> aset;
    for (int i = 1; i < N; ++i) {
      int k = (i * i) % N;
      aset.emplace(k);
    }
    vector<int> nums(N);
    for (auto it = aset.begin(); it != aset.end(); ++it) {
      for (auto jt = next(it); jt != aset.end(); ++jt) {
        int sa = *it - *jt;
        if (sa < 0)
          sa += N;
        if (sa > (N - 1) / 2)
          sa = N - sa;
        nums[sa]++;
      }
    }
    for (int i = 1; i <= (N - 1) / 2; ++i) {
      cout << nums[i] * 2 << endl;
    }
  }
  return 0;
} | 
	#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
//// < "d:\d_download\visual studio
///2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
///studio 2015\projects\programing_contest_c++\debug\b.txt"
int main() {
  while (1) {
    int N;
    cin >> N;
    if (!N)
      break;
    set<int> aset;
    for (int i = 1; i < N; ++i) {
      int k = (i * i) % N;
      aset.emplace(k);
    }
    vector<int> nums(N);
    for (auto it = aset.begin(); it != aset.end(); ++it) {
      for (auto jt = next(it); jt != aset.end(); ++jt) {
        int sa = *it - *jt;
        if (sa < 0)
          sa += N;
        if (sa > (N - 1) / 2)
          sa = N - sa;
        nums[sa]++;
      }
    }
    for (int i = 1; i <= (N - 1) / 2; ++i) {
      cout << nums[i] * 2 << endl;
    }
  }
  return 0;
} | 
	insert | 16 | 16 | 16 | 18 | 
	TLE | |
| 
	p00142 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <vector>
int main() {
  int n, arr[5000];
  std::vector<int> v;
  while (std::cin >> n, n) {
    std::fill(arr, arr + 5000, 0);
    v.clear();
    for (int i = 1; i <= (n - 1) / 2; i++) {
      if (std::find(v.begin(), v.end(), i * i % n) == v.end()) { // まだない
        v.push_back(i * i % n);
      }
    }
    for (int i = 0; i < v.size() - 1; i++) {
      for (int j = i + 1; j < v.size(); j++) {
        int value = v[i] - v[j];
        if (value < 0) {
          value += n;
        }
        if (value > (n - 1) / 2) {
          value = n - value;
        }
        arr[value]++;
      }
    }
    for (int i = 1; i <= (n - 1) / 2; i++) {
      std::cout << arr[i] * 2 << std::endl;
    }
  }
} | 
	#include <algorithm>
#include <iostream>
#include <vector>
int main() {
  int n, arr[5000];
  std::vector<int> v;
  while (std::cin >> n, n) {
    std::fill(arr, arr + 5000, 0);
    v.clear();
    for (int i = 1; i <= (n - 1) / 2; i++) {
      if (std::find(v.begin(), v.end(), i * i % n) == v.end()) { // まだない
        v.push_back(i * i % n);
      }
    }
    for (int i = 0; i < v.size(); i++) {
      for (int j = i + 1; j < v.size(); j++) {
        int value = v[i] - v[j];
        if (value < 0) {
          value += n;
        }
        if (value > (n - 1) / 2) {
          value = n - value;
        }
        arr[value]++;
      }
    }
    for (int i = 1; i <= (n - 1) / 2; i++) {
      std::cout << arr[i] * 2 << std::endl;
    }
  }
} | 
	replace | 17 | 18 | 17 | 18 | 
	TLE | |
| 
	p00143 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
#include <math.h>
using namespace std;
double square_calc(double x1, double y1, double x2, double y2, double x3,
                   double y3) {
  double square = 0;
  double a = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  double b = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
  double c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
  double s = (a + b + c) / 2;
  return (sqrt(s * (s - a) * (s - b) * (s - c)));
}
void solve() {
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      double xp1, yp1, xp2, yp2, xp3, yp3, xk, yk, xs, ys;
      cin >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3 >> xk >> yk >> xs >> ys;
      double square = square_calc(xp1, yp1, xp2, yp2, xp3, yp3);
      double square1 = square_calc(xk, yk, xp1, yp1, xp2, yp2) +
                       square_calc(xk, yk, xp1, yp1, xp3, yp3) +
                       square_calc(xk, yk, xp2, yp2, xp3, yp3);
      double square2 = square_calc(xs, ys, xp1, yp1, xp2, yp2) +
                       square_calc(xs, ys, xp1, yp1, xp3, yp3) +
                       square_calc(xs, ys, xp2, yp2, xp3, yp3);
      if (fabs(square - square1) <= 1e-6 && fabs(square - square2) >= 1e-6 ||
          fabs(square - square1) >= 1e-6 && fabs(square - square2) <= 1e-6) {
        cout << "OK" << endl;
      } else {
        cout << "NG" << endl;
      }
    }
  }
}
int main() {
  solve();
  return (0);
} | 
	#include <iostream>
#include <math.h>
using namespace std;
double square_calc(double x1, double y1, double x2, double y2, double x3,
                   double y3) {
  double square = 0;
  double a = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  double b = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
  double c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
  double s = (a + b + c) / 2;
  return (sqrt(s * (s - a) * (s - b) * (s - c)));
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    double xp1, yp1, xp2, yp2, xp3, yp3, xk, yk, xs, ys;
    cin >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3 >> xk >> yk >> xs >> ys;
    double square = square_calc(xp1, yp1, xp2, yp2, xp3, yp3);
    double square1 = square_calc(xk, yk, xp1, yp1, xp2, yp2) +
                     square_calc(xk, yk, xp1, yp1, xp3, yp3) +
                     square_calc(xk, yk, xp2, yp2, xp3, yp3);
    double square2 = square_calc(xs, ys, xp1, yp1, xp2, yp2) +
                     square_calc(xs, ys, xp1, yp1, xp3, yp3) +
                     square_calc(xs, ys, xp2, yp2, xp3, yp3);
    if (fabs(square - square1) <= 1e-6 && fabs(square - square2) >= 1e-6 ||
        fabs(square - square1) >= 1e-6 && fabs(square - square2) <= 1e-6) {
      cout << "OK" << endl;
    } else {
      cout << "NG" << endl;
    }
  }
}
int main() {
  solve();
  return (0);
} | 
	replace | 17 | 34 | 17 | 33 | 
	TLE | |
| 
	p00143 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define FOR(v, c) for (auto &v : c)
#define EACH(it, c) for (auto it = c.begin(); it != c.end(); ++it)
#define ALL(c) (c).begin(), (c).end()
#define DRANGE(c, p) (c).begin(), (c).begin() + p, (c).end()
#define PB(n) push_back(n)
#define MP(a, b) make_pair((a), (b))
#define EXIST(c, e) ((c).find(e) != (c).end())
#define fst first
#define snd second
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x)                                                               \
  cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << (x) << endl
#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;
// 入力ストリームから実数二つをとって Point へ
istream &operator>>(istream &s, Point &a) {
  double r, i;
  s >> r >> i;
  a = Point(r, i);
  return s;
}
// 外積(クロス積)
double cross(const Point &a, const Point &b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
// CCW 関数 a -> b -> c と進むとき、反時計回りなら 1, 直進なら 0, 時計回りなら
// -1 include : cross
int ccw(const Point &a, const Point &b, const Point &c) {
  if (cross((b - a), (c - a)) < -EPS) {
    return -1;
  } else if (EPS < cross((b - a), (c - a))) {
    return 1;
  } else {
    return 0;
  }
}
// 点 p が多角形 qs の内部にあるか ( Winding Number Algorithm) :TODO
// include : ccw
bool point_in_polygon(const Point &p, const vector<Point> &qs) {
  const int N = qs.size();
  int wn = 0;
  for (int i = 0; i < N; ++i) {
    const Point &s = qs[i], &t = qs[(i + 1) % N];
    if (s.imag() - EPS <= t.imag() && s.imag() - EPS < p.imag() &&
        p.imag() + EPS < t.imag()) // 上向きの辺
    {
      wn += ccw(s, p, t) == -1;
    } else if (t.imag() - EPS <= s.imag() && t.imag() - EPS < p.imag() &&
               p.imag() + EPS < s.imag()) {
      wn -= ccw(t, p, s) == -1;
    }
  }
  return wn;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  REP(i, 0, n) {
    vector<Point> tri(3);
    REP(j, 0, 3) { cin >> tri[i]; }
    Point s, t;
    cin >> s >> t;
    cout << (point_in_polygon(s, tri) ^ point_in_polygon(t, tri) ? "OK" : "NG")
         << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define FOR(v, c) for (auto &v : c)
#define EACH(it, c) for (auto it = c.begin(); it != c.end(); ++it)
#define ALL(c) (c).begin(), (c).end()
#define DRANGE(c, p) (c).begin(), (c).begin() + p, (c).end()
#define PB(n) push_back(n)
#define MP(a, b) make_pair((a), (b))
#define EXIST(c, e) ((c).find(e) != (c).end())
#define fst first
#define snd second
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x)                                                               \
  cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << (x) << endl
#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;
// 入力ストリームから実数二つをとって Point へ
istream &operator>>(istream &s, Point &a) {
  double r, i;
  s >> r >> i;
  a = Point(r, i);
  return s;
}
// 外積(クロス積)
double cross(const Point &a, const Point &b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
// CCW 関数 a -> b -> c と進むとき、反時計回りなら 1, 直進なら 0, 時計回りなら
// -1 include : cross
int ccw(const Point &a, const Point &b, const Point &c) {
  if (cross((b - a), (c - a)) < -EPS) {
    return -1;
  } else if (EPS < cross((b - a), (c - a))) {
    return 1;
  } else {
    return 0;
  }
}
// 点 p が多角形 qs の内部にあるか ( Winding Number Algorithm) :TODO
// include : ccw
bool point_in_polygon(const Point &p, const vector<Point> &qs) {
  const int N = qs.size();
  int wn = 0;
  for (int i = 0; i < N; ++i) {
    const Point &s = qs[i], &t = qs[(i + 1) % N];
    if (s.imag() - EPS <= t.imag() && s.imag() - EPS < p.imag() &&
        p.imag() + EPS < t.imag()) // 上向きの辺
    {
      wn += ccw(s, p, t) == -1;
    } else if (t.imag() - EPS <= s.imag() && t.imag() - EPS < p.imag() &&
               p.imag() + EPS < s.imag()) {
      wn -= ccw(t, p, s) == -1;
    }
  }
  return wn;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  REP(i, 0, n) {
    vector<Point> tri(3);
    REP(j, 0, 3) { cin >> tri[j]; }
    Point s, t;
    cin >> s >> t;
    cout << (point_in_polygon(s, tri) ^ point_in_polygon(t, tri) ? "OK" : "NG")
         << endl;
  }
  return 0;
} | 
	replace | 107 | 108 | 107 | 108 | 
	-6 | 
	double free or corruption (out)
 | 
| 
	p00144 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int MAX_NODE = 100;
vector<int> makeInput(string input) {
  vector<int> ret;
  stringstream ss(input);
  while (ss >> input)
    ret.push_back(atoi(input.c_str()));
  return ret;
}
int main() {
  int n;
  while (cin >> n && n) {
    int d[MAX_NODE][MAX_NODE];
    REP(i, MAX_NODE) REP(j, MAX_NODE) d[i][j] = INF;
    REP(i, MAX_NODE) d[i][i] = 0;
    vector<vector<int>> graph(MAX_NODE, vector<int>(MAX_NODE));
    string dust_str;
    getline(cin, dust_str);
    // make graph
    REP(i, n) {
      string input;
      getline(cin, input);
      vector<int> sum_list = makeInput(input);
      // make
      REP(j, sum_list[1]) {
        graph[sum_list[0]].push_back(sum_list[j + 2]);
        d[sum_list[0]][sum_list[j + 2]] = 1;
      }
    }
    // ワーシャルフロイド
    int v = n + 1;
    REP(k, v) {
      REP(i, v) {
        REP(j, v) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
      }
    }
    // cal ans
    int m;
    cin >> m;
    getline(cin, dust_str);
    REP(i, m) {
      string input;
      getline(cin, input);
      vector<int> sum_list = makeInput(input);
      int from = sum_list[0], to = sum_list[1], ttl = sum_list[2];
      if (ttl < (d[from][to] + 1))
        cout << "NA" << endl;
      else
        cout << d[from][to] + 1 << endl;
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int MAX_NODE = 110;
vector<int> makeInput(string input) {
  vector<int> ret;
  stringstream ss(input);
  while (ss >> input)
    ret.push_back(atoi(input.c_str()));
  return ret;
}
int main() {
  int n;
  while (cin >> n && n) {
    int d[MAX_NODE][MAX_NODE];
    REP(i, MAX_NODE) REP(j, MAX_NODE) d[i][j] = INF;
    REP(i, MAX_NODE) d[i][i] = 0;
    vector<vector<int>> graph(MAX_NODE, vector<int>(MAX_NODE));
    string dust_str;
    getline(cin, dust_str);
    // make graph
    REP(i, n) {
      string input;
      getline(cin, input);
      vector<int> sum_list = makeInput(input);
      // make
      REP(j, sum_list[1]) {
        graph[sum_list[0]].push_back(sum_list[j + 2]);
        d[sum_list[0]][sum_list[j + 2]] = 1;
      }
    }
    // ワーシャルフロイド
    int v = n + 1;
    REP(k, v) {
      REP(i, v) {
        REP(j, v) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
      }
    }
    // cal ans
    int m;
    cin >> m;
    getline(cin, dust_str);
    REP(i, m) {
      string input;
      getline(cin, input);
      vector<int> sum_list = makeInput(input);
      int from = sum_list[0], to = sum_list[1], ttl = sum_list[2];
      if (ttl < (d[from][to] + 1))
        cout << "NA" << endl;
      else
        cout << d[from][to] + 1 << endl;
    }
  }
  return 0;
} | 
	replace | 19 | 20 | 19 | 20 | 
	0 | |
| 
	p00146 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const double Eps = 1e-6;
using namespace std;
typedef pair<double, vector<int>> P;
const double Inf = 1e100;
int n, no[15], dis[15], box[15];
int w[1 << 15];
double dp[1 << 15][15];
vector<int> path[1 << 15][15];
double recur(int visited, int current) {
  if (dp[visited][current] != Inf)
    return dp[visited][current];
  double res = Inf;
  int next;
  for (int i = 0; i < n; ++i) {
    if (!(visited & 1 << i)) {
      double t = recur(visited | 1 << i, i) +
                 abs(dis[current] - dis[i]) / (2000.0 / (70.0 + w[visited]));
      if (t < res) {
        res = t;
        next = i;
      }
    }
  }
  path[visited][current] = path[visited | 1 << next][next];
  path[visited][current].push_back(no[current]);
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d %d %d", no + i, dis + i, box + i);
  for (int i = 0; i < 1 << n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i & 1 << j)
        w[i] += 20 * box[j];
      dp[i][j] = Inf;
    }
  }
  for (int i = 0; i < n; ++i) {
    dp[(1 << n) - 1][i] = 0;
    path[(1 << n) - 1][i].push_back(no[i]);
  }
  double ans = Inf;
  int v;
  for (int i = 0; i < n - 1; ++i) {
    double t = recur(1 << i, i);
    if (t < ans) {
      ans = t;
      v = i;
    }
  }
  vector<int> &p = path[1 << v][v];
  for (int i = p.size() - 1; i > 0; --i)
    printf("%d ", p[i]);
  printf("%d\n", p[0]);
  return 0;
} | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const double Eps = 1e-6;
using namespace std;
typedef pair<double, vector<int>> P;
const double Inf = 1e100;
int n, no[15], dis[15], box[15];
int w[1 << 15];
double dp[1 << 15][15];
vector<int> path[1 << 15][15];
double recur(int visited, int current) {
  if (dp[visited][current] != Inf)
    return dp[visited][current];
  double res = Inf;
  int next;
  for (int i = 0; i < n; ++i) {
    if (!(visited & 1 << i)) {
      double t = recur(visited | 1 << i, i) +
                 abs(dis[current] - dis[i]) / (2000.0 / (70.0 + w[visited]));
      if (t < res) {
        res = t;
        next = i;
      }
    }
  }
  path[visited][current] = path[visited | 1 << next][next];
  path[visited][current].push_back(no[current]);
  return dp[visited][current] = res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d %d %d", no + i, dis + i, box + i);
  for (int i = 0; i < 1 << n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i & 1 << j)
        w[i] += 20 * box[j];
      dp[i][j] = Inf;
    }
  }
  for (int i = 0; i < n; ++i) {
    dp[(1 << n) - 1][i] = 0;
    path[(1 << n) - 1][i].push_back(no[i]);
  }
  double ans = Inf;
  int v;
  for (int i = 0; i < n - 1; ++i) {
    double t = recur(1 << i, i);
    if (t < ans) {
      ans = t;
      v = i;
    }
  }
  vector<int> &p = path[1 << v][v];
  for (int i = p.size() - 1; i > 0; --i)
    printf("%d ", p[i]);
  printf("%d\n", p[0]);
  return 0;
} | 
	replace | 49 | 50 | 49 | 50 | 
	TLE | |
| 
	p00146 | 
	C++ | 
	Runtime Error | 
	#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
const int N = 1e2 + 10;
const int MAXN = 1 << 16;
const double INF = 1 << 30;
int abs(int a) { return a > 0 ? a : -a; }
int main() {
  int n, s[N], d[N], v[N], from[MAXN][N], val[MAXN], all, now = 0, top;
  vector<int> ans;
  double dp[MAXN][N], temp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d%d", &s[i], &d[i], &v[i]);
  all = 1 << n;
  for (int i = 0; i < all; i++) {
    val[i] = 0;
    for (int j = 0; j < n; j++) {
      dp[i][j] = INF;
      if (i & (1 << j))
        val[i] += v[j];
    }
    val[i] *= 20;
  }
  for (int i = 0; i < n; i++) {
    from[1 << i][i] = -1;
    dp[1 << i][i] = ((double)70 / 2000) * d[i];
  }
  for (int i = 0; i < all; i++)
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) {
        for (int k = 0; k < n; k++)
          if (k != j && i & (1 << k)) {
            temp = dp[i ^ (1 << j)][k] +
                   ((double)(70 + val[i ^ (1 << j)]) / 2000) * abs(d[j] - d[k]);
            if (dp[i][j] > temp) {
              from[i][j] = k;
              dp[i][j] = temp;
            }
          }
      }
  all--;
  top = dp[all][0];
  for (int i = 1; i < n; i++)
    if (dp[all][i] < top) {
      top = dp[all][i];
      now = i;
    }
  while (all > 0) {
    ans.PB(s[now]);
    top = all;
    all -= 1 << now;
    now = from[top][now];
  }
  printf("%d", ans.back());
  for (int i = static_cast<int>(ans.size() - 2); i >= 0; i--)
    printf(" %d", ans[i]);
  printf("\n");
}
 | 
	#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
const int N = 1e1 + 10;
const int MAXN = 1 << 16;
const double INF = 1 << 30;
int abs(int a) { return a > 0 ? a : -a; }
int main() {
  int n, s[N], d[N], v[N], from[MAXN][N], val[MAXN], all, now = 0, top;
  vector<int> ans;
  double dp[MAXN][N], temp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d%d", &s[i], &d[i], &v[i]);
  all = 1 << n;
  for (int i = 0; i < all; i++) {
    val[i] = 0;
    for (int j = 0; j < n; j++) {
      dp[i][j] = INF;
      if (i & (1 << j))
        val[i] += v[j];
    }
    val[i] *= 20;
  }
  for (int i = 0; i < n; i++) {
    from[1 << i][i] = -1;
    dp[1 << i][i] = ((double)70 / 2000) * d[i];
  }
  for (int i = 0; i < all; i++)
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) {
        for (int k = 0; k < n; k++)
          if (k != j && i & (1 << k)) {
            temp = dp[i ^ (1 << j)][k] +
                   ((double)(70 + val[i ^ (1 << j)]) / 2000) * abs(d[j] - d[k]);
            if (dp[i][j] > temp) {
              from[i][j] = k;
              dp[i][j] = temp;
            }
          }
      }
  all--;
  top = dp[all][0];
  for (int i = 1; i < n; i++)
    if (dp[all][i] < top) {
      top = dp[all][i];
      now = i;
    }
  while (all > 0) {
    ans.PB(s[now]);
    top = all;
    all -= 1 << now;
    now = from[top][now];
  }
  printf("%d", ans.back());
  for (int i = static_cast<int>(ans.size() - 2); i >= 0; i--)
    printf(" %d", ans[i]);
  printf("\n");
}
 | 
	replace | 4 | 5 | 4 | 5 | 
	-11 | |
| 
	p00146 | 
	C++ | 
	Memory Limit Exceeded | 
	#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
#define dump(n) cout << "# " << #n << "=" << (n) << endl
#define debug(n)                                                               \
  cout << __FILE__ << "," << __LINE__ << ": #" << #n << "=" << (n) << endl
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define iter(c) __typeof((c).begin())
#define foreach(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define allof(c) (c).begin(), (c).end()
#define mp make_pair
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<vd> vvd;
int main() {
  int n;
  cin >> n;
  vi id(n), dist(n), box(n);
  rep(i, n) cin >> id[i] >> dist[i] >> box[i];
  vvd dp(1 << n, vd(n, 9999));
  vvi prev(1 << n, vi(n));
  rep(i, n) {
    dp[1 << i][i] = 0;
    prev[1 << i][i] = -1;
  }
  rep(i, 1 << n) {
    int weight = 0;
    rep(j, n) if (1 << j & i) weight += box[j] * 20;
    rep(j, n) rep(k, n) {
      if (!((1 << j) & i) || ((1 << k) & i))
        continue;
      double time =
          dp[i][j] + abs(dist[k] - dist[j]) / (2000.0 / (70 + weight));
      if (dp[i | (1 << k)][k] > time) {
        dp[i | (1 << k)][k] = time;
        prev[i | (1 << k)][k] = j;
      }
    }
  }
  vi res;
  {
    int i = 0;
    rep(j, n) if (dp[(1 << n) - 1][j] < dp[(1 << n) - 1][i]) i = j;
    for (int j = (1 << n) - 1; i != -1;) {
      res.push_back(i);
      int ii = prev[j][i];
      int jj = j ^ (1 << i);
      i = ii;
      j = jj;
    }
  }
  reverse(allof(res));
  rep(i, res.size())
      printf("%d%c", id[res[i]], i == res.size() - 1 ? '\n' : ' ');
  return 0;
} | 
	#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
#define dump(n) cout << "# " << #n << "=" << (n) << endl
#define debug(n)                                                               \
  cout << __FILE__ << "," << __LINE__ << ": #" << #n << "=" << (n) << endl
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define iter(c) __typeof((c).begin())
#define foreach(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define allof(c) (c).begin(), (c).end()
#define mp make_pair
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<vd> vvd;
int main() {
  int n;
  cin >> n;
  vi id(n), dist(n), box(n);
  rep(i, n) cin >> id[i] >> dist[i] >> box[i];
  // vvd dp(1<<n,vd(n,1e10));
  // vvi prev(1<<n,vi(n));
  static double dp[1 << 15][15];
  static int prev[1 << 15][15] = {};
  rep(i, 1 << 15) fill(dp[i], dp[i] + 15, 1e10);
  rep(i, n) {
    dp[1 << i][i] = 0;
    prev[1 << i][i] = -1;
  }
  rep(i, 1 << n) {
    int weight = 0;
    rep(j, n) if (1 << j & i) weight += box[j] * 20;
    rep(j, n) rep(k, n) {
      if (!((1 << j) & i) || ((1 << k) & i))
        continue;
      double time =
          dp[i][j] + abs(dist[k] - dist[j]) / (2000.0 / (70 + weight));
      if (dp[i | (1 << k)][k] > time) {
        dp[i | (1 << k)][k] = time;
        prev[i | (1 << k)][k] = j;
      }
    }
  }
  vi res;
  {
    int i = 0;
    rep(j, n) if (dp[(1 << n) - 1][j] < dp[(1 << n) - 1][i]) i = j;
    for (int j = (1 << n) - 1; i != -1;) {
      res.push_back(i);
      int ii = prev[j][i];
      int jj = j ^ (1 << i);
      i = ii;
      j = jj;
    }
  }
  reverse(allof(res));
  rep(i, res.size())
      printf("%d%c", id[res[i]], i == res.size() - 1 ? '\n' : ' ');
  return 0;
} | 
	replace | 55 | 57 | 55 | 60 | 
	MLE | |
| 
	p00147 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int seat[17] = {0};
  int X = 0;
  int stop[100] = {0};
  int time = 0;
  queue<int> Q;
  while (X < 100) {
    int x;
    if (time % 5 == 0 && time < 500) {
      Q.push(time / 5);
    }
    while (1) {
      if (Q.size())
        x = Q.front();
      else
        x = -1;
      bool f = false;
      if (~x) {
        int people = (x % 5 == 1 ? 5 : 2);
        int use = 19 + 3 * (x % 3) + 17 * (x % 2);
        rep(i, 17 - people + 1) {
          bool flag = true;
          rep(j, people) { flag &= seat[i + j] == 0; }
          if (flag) {
            rep(j, people) { seat[i + j] = use; }
            f = true;
            break;
          }
        }
      }
      if (f) {
        stop[x] = time - x * 5;
        Q.pop();
        X++;
      }
      if (!f)
        break;
    }
    rep(i, 17) { seat[i] = max(0, seat[i] - 1); }
    time++;
  }
  int n, c = 0;
  while (cin >> n) {
    if (n < 50)
      c++;
    cout << stop[n] << endl;
  }
  int a = 0;
  while (c >= 2) {
    cout << a / a << endl;
  };
} | 
	#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int seat[17] = {0};
  int X = 0;
  int stop[100] = {0};
  int time = 0;
  queue<int> Q;
  while (X < 100) {
    int x;
    if (time % 5 == 0 && time < 500) {
      Q.push(time / 5);
    }
    while (1) {
      if (Q.size())
        x = Q.front();
      else
        x = -1;
      bool f = false;
      if (~x) {
        int people = (x % 5 == 1 ? 5 : 2);
        int use = 19 + 3 * (x % 3) + 17 * (x % 2);
        rep(i, 17 - people + 1) {
          bool flag = true;
          rep(j, people) { flag &= seat[i + j] == 0; }
          if (flag) {
            rep(j, people) { seat[i + j] = use; }
            f = true;
            break;
          }
        }
      }
      if (f) {
        stop[x] = time - x * 5;
        Q.pop();
        X++;
      }
      if (!f)
        break;
    }
    rep(i, 17) { seat[i] = max(0, seat[i] - 1); }
    time++;
  }
  int n, c = 0;
  while (cin >> n) {
    if (n <= 5)
      c++;
    cout << stop[n] << endl;
  }
  int a = 0;
  while (c >= 2) {
    cout << a / a << endl;
  };
} | 
	replace | 52 | 53 | 52 | 53 | 
	TLE | |
| 
	p00147 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int seat[17] = {0};
  int X = 0;
  int stop[100] = {0};
  int time = 0;
  queue<int> Q;
  while (X < 100) {
    int x;
    if (time % 5 == 0 && time < 500) {
      Q.push(time / 5);
    }
    while (1) {
      if (Q.size())
        x = Q.front();
      else
        x = -1;
      bool f = false;
      if (~x) {
        int people = (x % 5 == 1 ? 5 : 2);
        int use = 19 + 3 * (x % 3) + 17 * (x % 2);
        rep(i, 17 - people + 1) {
          bool flag = true;
          rep(j, people) { flag &= seat[i + j] == 0; }
          if (flag) {
            rep(j, people) { seat[i + j] = use; }
            f = true;
            break;
          }
        }
      }
      if (f) {
        stop[x] = time - x * 5;
        Q.pop();
        X++;
      }
      if (!f)
        break;
    }
    rep(i, 17) { seat[i] = max(0, seat[i] - 1); }
    time++;
  }
  int n, c = 0;
  while (cin >> n) {
    cout << stop[n] << endl;
    c++;
  }
  while (c >= 9) {
  };
} | 
	#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int seat[17] = {0};
  int X = 0;
  int stop[100] = {0};
  int time = 0;
  queue<int> Q;
  while (X < 100) {
    int x;
    if (time % 5 == 0 && time < 500) {
      Q.push(time / 5);
    }
    while (1) {
      if (Q.size())
        x = Q.front();
      else
        x = -1;
      bool f = false;
      if (~x) {
        int people = (x % 5 == 1 ? 5 : 2);
        int use = 19 + 3 * (x % 3) + 17 * (x % 2);
        rep(i, 17 - people + 1) {
          bool flag = true;
          rep(j, people) { flag &= seat[i + j] == 0; }
          if (flag) {
            rep(j, people) { seat[i + j] = use; }
            f = true;
            break;
          }
        }
      }
      if (f) {
        stop[x] = time - x * 5;
        Q.pop();
        X++;
      }
      if (!f)
        break;
    }
    rep(i, 17) { seat[i] = max(0, seat[i] - 1); }
    time++;
  }
  int n, c = 0;
  while (cin >> n) {
    cout << stop[n] << endl;
    c++;
  }
  while (c < 9) {
  };
} | 
	replace | 54 | 55 | 54 | 55 | 
	TLE | |
| 
	p00148 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int num = (n - 1) % 39 + 1;
    if (num < 10)
      cout << "3C0" << num << endl;
    else
      cout << "3C" << num << endl;
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int num = (n - 1) % 39 + 1;
    if (num < 10)
      cout << "3C0" << num << endl;
    else
      cout << "3C" << num << endl;
  }
  return 0;
} | 
	replace | 4 | 10 | 4 | 6 | 
	TLE | |
| 
	p00148 | 
	C++ | 
	Time Limit Exceeded | 
	#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  for (;;) {
    cin >> n;
    if (n == 0)
      break;
    int ans = n % 39;
    if (n % 39 == 0)
      ans = 39;
    printf("3C%02d\n", ans);
  }
} | 
	#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  for (; cin >> n;) {
    int ans = n % 39;
    if (n % 39 == 0)
      ans = 39;
    printf("3C%02d\n", ans);
  }
} | 
	replace | 8 | 12 | 8 | 9 | 
	TLE | |
| 
	p00148 | 
	C++ | 
	Time Limit Exceeded | 
	#include <stdio.h>
int main(void) {
  int a, b;
  while (scanf("%d", &a) != EOF) {
    while (1) {
      b = a - 39;
      if (a <= 39)
        break;
    }
    printf("3C%02d\n", a);
  }
  return 0;
} | 
	#include <stdio.h>
int main(void) {
  int a, b;
  while (scanf("%d", &a) != EOF) {
    b = a % 39;
    if (b == 0)
      b = 39;
    printf("3C%02d\n", b);
  }
  return 0;
} | 
	replace | 4 | 10 | 4 | 8 | 
	TLE | |
| 
	p00148 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int main(void) {
  int n;
  while (cin >> n, n) {
    printf("3C%02d\n", n % 39 == 0 ? 39 : n % 39);
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
int main(void) {
  int n;
  while (scanf("%d", &n) != EOF) {
    printf("3C%02d\n", n % 39 == 0 ? 39 : n % 39);
  }
  return 0;
} | 
	replace | 5 | 6 | 5 | 6 | 
	TLE | |
| 
	p00148 | 
	C++ | 
	Time Limit Exceeded | 
	#include <cstdio>
using namespace std;
#define rep2(x, from, to) for (int x = (from); x < (to); ++(x))
#define rep(x, to) rep2(x, 0, to)
int main() {
  int n;
  while (scanf("%d", &n)) {
    printf("3C%02d\n", n % 39 == 0 ? 39 : n % 39);
  }
  return 0;
} | 
	#include <cstdio>
using namespace std;
#define rep2(x, from, to) for (int x = (from); x < (to); ++(x))
#define rep(x, to) rep2(x, 0, to)
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    printf("3C%02d\n", n % 39 == 0 ? 39 : n % 39);
  }
  return 0;
} | 
	replace | 6 | 7 | 6 | 7 | 
	TLE | |
| 
	p00149 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
  double lhs, rhs;
  int al = 0;
  int ar = 0;
  int bl = 0;
  int br = 0;
  int cl = 0;
  int cr = 0;
  int dl = 0;
  int dr = 0;
  while (cin >> lhs >> rhs, lhs || rhs) {
    if (lhs >= 1.1)
      al++;
    if (rhs >= 1.1)
      ar++;
    if (1.1 > lhs && lhs >= 0.6)
      bl++;
    if (1.1 > rhs && rhs >= 0.6)
      br++;
    if (0.6 > lhs && lhs >= 0.2)
      cl++;
    if (0.6 > rhs && rhs >= 0.2)
      cr++;
    if (0.2 > lhs && lhs >= 0.1)
      dl++;
    if (0.2 > rhs && rhs >= 0.1)
      dr++;
  }
  cout << al << " " << ar << endl;
  cout << bl << " " << br << endl;
  cout << cl << " " << cr << endl;
  cout << dl << " " << dr << endl;
  return 0;
}
 | 
	#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
  double lhs, rhs;
  int al = 0;
  int ar = 0;
  int bl = 0;
  int br = 0;
  int cl = 0;
  int cr = 0;
  int dl = 0;
  int dr = 0;
  while (cin >> lhs >> rhs) {
    if (lhs >= 1.1)
      al++;
    if (rhs >= 1.1)
      ar++;
    if (1.1 > lhs && lhs >= 0.6)
      bl++;
    if (1.1 > rhs && rhs >= 0.6)
      br++;
    if (0.6 > lhs && lhs >= 0.2)
      cl++;
    if (0.6 > rhs && rhs >= 0.2)
      cr++;
    if (0.2 > lhs && lhs >= 0.1)
      dl++;
    if (0.2 > rhs && rhs >= 0.1)
      dr++;
  }
  cout << al << " " << ar << endl;
  cout << bl << " " << br << endl;
  cout << cl << " " << cr << endl;
  cout << dl << " " << dr << endl;
  return 0;
}
 | 
	replace | 21 | 22 | 21 | 22 | 
	TLE | |
| 
	p00149 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int main() {
  int LA, LB, LC, LD, RA, RB, RC, RD;
  LA = LB = LC = LD = RA = RB = RC = RD = 0;
  while (1) {
    double a, b;
    cin >> a >> b;
    if (cin.fail())
      ;
    if (a < 0.2)
      LD++;
    else if (a < 0.6)
      LC++;
    else if (a < 1.1)
      LB++;
    else
      LA++;
    if (b < 0.2)
      RD++;
    else if (b < 0.6)
      RC++;
    else if (b < 1.1)
      RB++;
    else
      RA++;
  }
  cout << LA << " " << RA << endl
       << LB << " " << RB << endl
       << LC << " " << RC << endl
       << LD << " " << RD << endl;
} | 
	#include <iostream>
using namespace std;
int main() {
  int LA, LB, LC, LD, RA, RB, RC, RD;
  LA = LB = LC = LD = RA = RB = RC = RD = 0;
  while (1) {
    double a, b;
    cin >> a >> b;
    if (cin.fail())
      break;
    if (a < 0.2)
      LD++;
    else if (a < 0.6)
      LC++;
    else if (a < 1.1)
      LB++;
    else
      LA++;
    if (b < 0.2)
      RD++;
    else if (b < 0.6)
      RC++;
    else if (b < 1.1)
      RB++;
    else
      RA++;
  }
  cout << LA << " " << RA << endl
       << LB << " " << RB << endl
       << LC << " " << RC << endl
       << LD << " " << RD << endl;
} | 
	replace | 10 | 11 | 10 | 11 | 
	TLE | |
| 
	p00150 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <vector>
constexpr bool divisible(const std::size_t n, const std::size_t m) {
  return (0 == n % m);
}
std::vector<std::size_t> prime_table = {2};
bool prime(const std::size_t n) {
  const std::size_t found_last_prime = prime_table.back();
  if (found_last_prime < n) {
    std::list<std::size_t> undefined_table;
    for (std::size_t i = found_last_prime + 1; i < n; ++i) {
      undefined_table.push_back(i);
    }
    const std::size_t sn = std::sqrt(n);
    for (std::size_t p = 0; !undefined_table.empty() && p < prime_table.size();
         ++p) {
      for (auto u = undefined_table.begin(); u != undefined_table.end();) {
        if (divisible(*u, prime_table.at(p))) {
          u = undefined_table.erase(u);
        } else {
          ++u;
        }
      }
      if (!undefined_table.empty() && found_last_prime <= prime_table.at(p)) {
        prime_table.push_back(undefined_table.front());
        undefined_table.pop_front();
        if (sn < prime_table.back()) {
          break;
        }
      }
    }
    prime_table.insert(prime_table.end(), undefined_table.begin(),
                       undefined_table.end());
  }
  return std::binary_search(prime_table.begin(), prime_table.end(), n);
}
std::pair<std::size_t, std::size_t>
find_twin_prime(const std::size_t limit, const bool next_skip = false) {
  return prime(limit) ? prime(limit - 2)
                            ? std::make_pair(limit - 2, limit)
                            : find_twin_prime(limit - (next_skip ? 3 : 1), true)
                      : find_twin_prime(limit - (next_skip ? 2 : 1), false);
}
int main() {
  std::size_t n;
  while (std::cin >> n, n != 0) {
    const auto &&t = find_twin_prime(n);
    std::cout << t.first << " " << t.second << std::endl;
  }
} | 
	#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <vector>
constexpr bool divisible(const std::size_t n, const std::size_t m) {
  return (0 == n % m);
}
std::vector<std::size_t> prime_table = {2};
bool prime(const std::size_t n) {
  const std::size_t found_last_prime = prime_table.back();
  if (found_last_prime < n) {
    std::list<std::size_t> undefined_table;
    for (std::size_t i = found_last_prime + 1; i <= n; ++i) {
      undefined_table.push_back(i);
    }
    const std::size_t sn = std::sqrt(n);
    for (std::size_t p = 0; !undefined_table.empty() && p < prime_table.size();
         ++p) {
      for (auto u = undefined_table.begin(); u != undefined_table.end();) {
        if (divisible(*u, prime_table.at(p))) {
          u = undefined_table.erase(u);
        } else {
          ++u;
        }
      }
      if (!undefined_table.empty() && found_last_prime <= prime_table.at(p)) {
        prime_table.push_back(undefined_table.front());
        undefined_table.pop_front();
        if (sn < prime_table.back()) {
          break;
        }
      }
    }
    prime_table.insert(prime_table.end(), undefined_table.begin(),
                       undefined_table.end());
  }
  return std::binary_search(prime_table.begin(), prime_table.end(), n);
}
std::pair<std::size_t, std::size_t>
find_twin_prime(const std::size_t limit, const bool next_skip = false) {
  return prime(limit) ? prime(limit - 2)
                            ? std::make_pair(limit - 2, limit)
                            : find_twin_prime(limit - (next_skip ? 3 : 1), true)
                      : find_twin_prime(limit - (next_skip ? 2 : 1), false);
}
int main() {
  std::size_t n;
  while (std::cin >> n, n != 0) {
    const auto &&t = find_twin_prime(n);
    std::cout << t.first << " " << t.second << std::endl;
  }
} | 
	replace | 17 | 18 | 17 | 18 | 
	0 | |
| 
	p00150 | 
	C++ | 
	Runtime Error | 
	#include <stdio.h>
const int MAX_V = 10000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V + 1];
int main() {
  int k, i, max, min, n; // 1????????f???????C0????????f????????????????????¢
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1; // 2???????£????f????????????°??????¨
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] =
            0; // ???f??????2???{???????£????{?????????f????????????????????¢
      }
    }
  }
  while (scanf("%d", &n)) {
    if (n == 0)
      break;
    max = 0;
    min = 0;
    for (i = n; i > 0; i++) {
      if (prime[i] && prime[i - 2]) {
        max = i;
        min = max - 2;
        // printf("%d %d\n",i-2,i);
        break;
      }
    }
    printf("%d %d\n", min, max);
  }
  return 0;
} | 
	#include <stdio.h>
const int MAX_V = 10000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V + 1];
int main() {
  int k, i, max, min, n; // 1????????f???????C0????????f????????????????????¢
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1; // 2???????£????f????????????°??????¨
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] =
            0; // ???f??????2???{???????£????{?????????f????????????????????¢
      }
    }
  }
  while (scanf("%d", &n)) {
    if (n == 0)
      break;
    max = 0;
    min = 0;
    for (i = n; i > 0; i--) {
      if (prime[i] && prime[i - 2]) {
        max = i;
        min = max - 2;
        // printf("%d %d\n",i-2,i);
        break;
      }
    }
    printf("%d %d\n", min, max);
  }
  return 0;
} | 
	replace | 21 | 22 | 21 | 22 | 
	0 | |
| 
	p00150 | 
	C++ | 
	Time Limit Exceeded | 
	#include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V + 1];    // 1????´???°,0????´???°??§?????????
int main() {
  int i, k, n;
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1; // 2??\???????´???°??¨??????
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
      }
    }
  }
  while (scanf("%d", &n) != 0) {
    int p1 = 0, q1 = 0;
    for (i = n; 3 <= i; i--) {
      if (prime[i] == 1 && prime[i - 2] == 1) { //??????????´???°
        q1 = i;
        p1 = i - 2;
        break;
      }
    }
    printf("%d %d\n", p1, q1); // for?????????????????????
  }
  return 0;
}
//????¨??????¨???????????????????????? | 
	#include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V + 1];    // 1????´???°,0????´???°??§?????????
int main() {
  int i, k, n;
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1; // 2??\???????´???°??¨??????
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
      }
    }
  }
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    //        while(scanf("%d", &n) != 0) {
    int p1 = 0, q1 = 0;
    for (i = n; 3 <= i; i--) {
      if (prime[i] == 1 && prime[i - 2] == 1) { //??????????´???°
        q1 = i;
        p1 = i - 2;
        break;
      }
    }
    printf("%d %d\n", p1, q1); // for?????????????????????
  }
  return 0;
}
//????¨??????¨???????????????????????? | 
	replace | 15 | 16 | 15 | 20 | 
	TLE | |
| 
	p00150 | 
	C++ | 
	Time Limit Exceeded | 
	#include "stdio.h"
// #include "time.h"
//?????§??????????´???°?????????????????????
//  5<= n <= 10000
// p1=?°????????´???°p2=??§???????´???°
int isprime(int n) {
  int i;
  for (i = 2; i < n;
       i++) { //??????????§????????????¨??§??¶??°??§??????????´???°??¨??????
    if (n % i == 0)
      return 0; //????????????????????§?´???°??§?????????
  }
  return 1;
}
int main() {
  int i, n, p1, q1;
  //     clock_t start, now;//??£?¨?
  while (1) {
    scanf("%d", &n);
    //   start = clock(); // ????§???????
    if (n == 0)
      break;
    for (i = n; 3 <= i; i--) {
      if (isprime(i) == 1 && isprime(i - 2) == 1)
        break;
    }
    p1 = i - 2;
    q1 = i;
    // now = clock(); // ????????????
    // printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???
    printf("%d %d\n", p1, q1);
  }
  return 0;
} | 
	#include "stdio.h"
// #include "time.h"
//?????§??????????´???°?????????????????????
//  5<= n <= 10000
// p1=?°????????´???°p2=??§???????´???°
int isprime(int n) {
  int i;
  for (i = 2; i * i <= n;
       i++) { //??????????§????????????¨??§??¶??°??§??????????´???°??¨??????
    if (n % i == 0)
      return 0; //????????????????????§?´???°??§?????????
  }
  return 1;
}
int main() {
  int i, n, p1, q1;
  //     clock_t start, now;//??£?¨?
  while (1) {
    scanf("%d", &n);
    //   start = clock(); // ????§???????
    if (n == 0)
      break;
    for (i = n; 3 <= i; i--) {
      if (isprime(i) == 1 && isprime(i - 2) == 1)
        break;
    }
    p1 = i - 2;
    q1 = i;
    // now = clock(); // ????????????
    // printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???
    printf("%d %d\n", p1, q1);
  }
  return 0;
} | 
	replace | 8 | 9 | 8 | 9 | 
	TLE | |
| 
	p00150 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
bool isPrime(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
int main(void) {
  int n;
  while (scanf("%d", &n), n) {
    for (int i = n; 5 <= i; i--) {
      // cout << i << endl;
      if (isPrime(i) && isPrime(i - 2)) {
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
bool isPrime(int n) {
  if (n % 2 == 0)
    return false;
  for (int i = 3; i < n; i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}
int main(void) {
  int n;
  while (scanf("%d", &n), n) {
    for (int i = n; 5 <= i; i--) {
      // cout << i << endl;
      if (isPrime(i) && isPrime(i - 2)) {
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
  return 0;
} | 
	replace | 7 | 8 | 7 | 10 | 
	TLE | |
| 
	p00150 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int lis[10001];
int main() {
  for (int i = 2; i <= 10000; i++) {
    int flg = 1;
    for (int j = 2; j <= 10000; j++) {
      if (i % j == 0 && i != j)
        flg = 0;
    }
    lis[i] = flg;
  }
  while (1) {
    int a;
    cin >> a;
    for (int i = a;; a--) {
      if (lis[a] && lis[a - 2]) {
        cout << a - 2 << ' ' << a << endl;
        break;
      }
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int lis[10001];
int main() {
  for (int i = 2; i <= 10000; i++) {
    int flg = 1;
    for (int j = 2; j <= 10000; j++) {
      if (i % j == 0 && i != j)
        flg = 0;
    }
    lis[i] = flg;
  }
  while (1) {
    int a;
    cin >> a;
    if (a == 0)
      break;
    for (int i = a;; a--) {
      if (lis[a] && lis[a - 2]) {
        cout << a - 2 << ' ' << a << endl;
        break;
      }
    }
  }
  return 0;
} | 
	insert | 18 | 18 | 18 | 20 | 
	TLE | |
| 
	p00150 | 
	C++ | 
	Time Limit Exceeded | 
	#include <stdio.h>
#include <time.h>
int isprime(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int i, p, q, n;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = n; i >= 2; i--) {
      if (isprime(i) && isprime(i - 2)) {
        break;
      }
    }
    printf("%d %d\n", i - 2, i);
  }
  return 0;
}
// clock_t start, now;
// now = clock();
// printf("%f\n",(double)(now - start) / CLOCKS_PER_SEC); | 
	#include <stdio.h>
#include <time.h>
int isprime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int i, p, q, n;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = n; i >= 2; i--) {
      if (isprime(i) && isprime(i - 2)) {
        break;
      }
    }
    printf("%d %d\n", i - 2, i);
  }
  return 0;
}
// clock_t start, now;
// now = clock();
// printf("%f\n",(double)(now - start) / CLOCKS_PER_SEC); | 
	replace | 3 | 4 | 3 | 4 | 
	TLE | |
| 
	p00151 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int ans;
int n;
char ma[100][100];
void cheak(int px, int dx, int py, int dy) {
  int cnt = 1;
  while (1) {
    px += dx;
    py += dy;
    if (!(0 <= px && px < n && 0 <= py && py < n) || ma[py][px] != '1')
      break;
    cnt++;
  }
  ans = max(ans, cnt);
}
int main() {
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> ma[i][j];
      }
    }
    ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (ma[i][j] == '1') {
          for (int l = 0; l < 8; l++) {
            cheak(j, dx[l], i, dy[l]);
          }
        }
      }
    }
    cout << ans << endl;
  }
} | 
	#include <algorithm>
#include <iostream>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int ans;
int n;
char ma[300][300];
void cheak(int px, int dx, int py, int dy) {
  int cnt = 1;
  while (1) {
    px += dx;
    py += dy;
    if (!(0 <= px && px < n && 0 <= py && py < n) || ma[py][px] != '1')
      break;
    cnt++;
  }
  ans = max(ans, cnt);
}
int main() {
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> ma[i][j];
      }
    }
    ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (ma[i][j] == '1') {
          for (int l = 0; l < 8; l++) {
            cheak(j, dx[l], i, dy[l]);
          }
        }
      }
    }
    cout << ans << endl;
  }
} | 
	replace | 6 | 7 | 6 | 7 | 
	TLE | |
| 
	p00151 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, j) REP((i), 0, (j))
#define REP(i, j, k) for (int i = (j); (i) < (k); ++i)
#define BW(a, x, b) ((a) <= (x) && (x) <= (b))
#define F first
#define S second
#define INF 1 << 30
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
int n;
char grid[256][256];
int solve() {
  int res = 0, c;
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (grid[i][j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(j, n) {
    c = 0;
    rep(i, n) {
      if (grid[i][j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (i - j < 0)
        break;
      if (grid[j][i - j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (n - j < 0)
        break;
      if (grid[n - i + j - 1][n - j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (n - i + j - 1 >= n)
        break;
      if (grid[j][n - i + j - 1] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (i + j >= n)
        break;
      if (grid[i + j][j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  return res;
}
int main() {
  while (scanf("%d", &n) && n) {
    memset(grid, 0, sizeof(grid));
    rep(i, n) scanf("%s", grid[i]);
    printf("%d\n", solve());
  }
  return 0;
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, j) REP((i), 0, (j))
#define REP(i, j, k) for (int i = (j); (i) < (k); ++i)
#define BW(a, x, b) ((a) <= (x) && (x) <= (b))
#define F first
#define S second
#define INF 1 << 30
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
int n;
char grid[256][256];
int solve() {
  int res = 0, c;
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (grid[i][j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(j, n) {
    c = 0;
    rep(i, n) {
      if (grid[i][j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (i - j < 0)
        break;
      if (grid[j][i - j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (n - j < 0 || n - i + j - 1 >= n || n - i + j - 1 < 0)
        break;
      if (grid[n - i + j - 1][n - j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (n - i + j - 1 >= n)
        break;
      if (grid[j][n - i + j - 1] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  rep(i, n) {
    c = 0;
    rep(j, n) {
      if (i + j >= n)
        break;
      if (grid[i + j][j] == '1')
        res = max(res, ++c);
      else
        c = 0;
    }
  }
  return res;
}
int main() {
  while (scanf("%d", &n) && n) {
    memset(grid, 0, sizeof(grid));
    rep(i, n) scanf("%s", grid[i]);
    printf("%d\n", solve());
  }
  return 0;
} | 
	replace | 68 | 69 | 68 | 69 | 
	0 | |
| 
	p00151 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
#include <string>
using namespace std;
string field[256];
void rotate(int n) {
  string tmp[256];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      tmp[i][j] = field[n - j - 1][i];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      field[i][j] = tmp[i][j];
  }
}
int main() {
  int n;
  while (cin >> n, n) {
    int ma = 0;
    for (int i = 0; i < n; i++)
      cin >> field[i];
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if (field[i][j] == '1') {
          cnt++;
          ma = max(ma, cnt);
        } else
          cnt = 0;
      }
      cnt = 0;
      for (int j = 0; j < n; j++) {
        if (field[j][i] == '1') {
          cnt++;
          ma = max(ma, cnt);
        } else
          cnt = 0;
      }
    }
    for (int k = 0; k < 2; k++) {
      if (k)
        rotate(n);
      for (int i = 0; i < 2 * n - 1; i++) {
        int cnt = 0;
        for (int j = 0; j < n; j++) {
          if (i - j >= n || i - j < 0)
            continue;
          if (field[j][i - j] == '1') {
            cnt++;
            ma = max(ma, cnt);
          } else
            cnt = 0;
        }
      }
    }
    cout << ma << endl;
  }
  return 0;
} | 
	#include <iostream>
#include <string>
using namespace std;
string field[256];
void rotate(int n) {
  string tmp[256];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      tmp[i] += field[n - j - 1][i];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      field[i][j] = tmp[i][j];
  }
}
int main() {
  int n;
  while (cin >> n, n) {
    int ma = 0;
    for (int i = 0; i < n; i++)
      cin >> field[i];
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if (field[i][j] == '1') {
          cnt++;
          ma = max(ma, cnt);
        } else
          cnt = 0;
      }
      cnt = 0;
      for (int j = 0; j < n; j++) {
        if (field[j][i] == '1') {
          cnt++;
          ma = max(ma, cnt);
        } else
          cnt = 0;
      }
    }
    for (int k = 0; k < 2; k++) {
      if (k)
        rotate(n);
      for (int i = 0; i < 2 * n - 1; i++) {
        int cnt = 0;
        for (int j = 0; j < n; j++) {
          if (i - j >= n || i - j < 0)
            continue;
          if (field[j][i - j] == '1') {
            cnt++;
            ma = max(ma, cnt);
          } else
            cnt = 0;
        }
      }
    }
    cout << ma << endl;
  }
  return 0;
} | 
	replace | 10 | 11 | 10 | 11 | 
	0 | |
| 
	p00151 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cstdio>
int main() {
  int n;
  while (scanf("%d", &n), n) {
    int m = 0, v[4][2] = {{0, -1}, {-1, 0}, {1, -1}, {-1, -1}},
        map[257][257] = {{0}};
    for (int y = 1; y <= n; y++)
      for (int x = 1; x <= n; x++)
        scanf("%1d", &map[x][y]);
    for (int i = 0; i < 4; i--) {
      int dp[257][257] = {{0}};
      for (int k = 1; k <= n; k++)
        for (int j = 1; j <= n; j++)
          m = std::max(
              m, dp[j][k] =
                     map[j][k] ? map[j][k] + dp[j + v[i][0]][k + v[i][1]] : 0);
    }
    printf("%d\n", m);
  }
} | 
	#include <algorithm>
#include <cstdio>
int main() {
  int n;
  while (scanf("%d", &n), n) {
    int m = 0, v[4][2] = {{0, -1}, {-1, 0}, {1, -1}, {-1, -1}},
        map[257][257] = {{0}};
    for (int y = 1; y <= n; y++)
      for (int x = 1; x <= n; x++)
        scanf("%1d", &map[x][y]);
    for (int i = 0; i < 4; i++) {
      int dp[257][257] = {{0}};
      for (int k = 1; k <= n; k++)
        for (int j = 1; j <= n; j++)
          m = std::max(
              m, dp[j][k] =
                     map[j][k] ? map[j][k] + dp[j + v[i][0]][k + v[i][1]] : 0);
    }
    printf("%d\n", m);
  }
} | 
	replace | 11 | 12 | 11 | 12 | 
	TLE | |
| 
	p00151 | 
	C++ | 
	Runtime Error | 
	#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
  int i, j, k, n, max, cnt, x, y, dx[] = {1, 1, 0, -1}, dy[] = {0, 1, 1, 1};
  char xy[225][226];
  while (1) {
    max = 0;
    cin >> n;
    if (n == 0)
      break;
    for (i = 0; i < n; i++)
      cin >> xy[i];
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (xy[i][j] == '1') {
          for (k = 0; k < 4; k++) {
            cnt = 1;
            y = i;
            x = j;
            while (1) {
              y = y + dy[k];
              x = x + dx[k];
              if (y >= n || x >= n || y < 0 || x < 0)
                break;
              if (xy[y][x] != '1')
                break;
              cnt++;
            }
            if (max < cnt)
              max = cnt;
          }
        }
      }
    }
    cout << max << endl;
  }
  return 0;
} | 
	#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
  int i, j, k, n, max, cnt, x, y, dx[] = {1, 1, 0, -1}, dy[] = {0, 1, 1, 1};
  char xy[255][256];
  while (1) {
    max = 0;
    cin >> n;
    if (n == 0)
      break;
    for (i = 0; i < n; i++)
      cin >> xy[i];
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (xy[i][j] == '1') {
          for (k = 0; k < 4; k++) {
            cnt = 1;
            y = i;
            x = j;
            while (1) {
              y = y + dy[k];
              x = x + dx[k];
              if (y >= n || x >= n || y < 0 || x < 0)
                break;
              if (xy[y][x] != '1')
                break;
              cnt++;
            }
            if (max < cnt)
              max = cnt;
          }
        }
      }
    }
    cout << max << endl;
  }
  return 0;
} | 
	replace | 5 | 6 | 5 | 6 | 
	0 | |
| 
	p00154 | 
	C++ | 
	Memory Limit Exceeded | 
	#include <cstring>
#include <iostream>
using namespace std;
#define MAX_N 150000
#define MAX_CARD 120
long long dp[MAX_CARD][MAX_N];
long long card[MAX_CARD][2];
int n, m, a, b, cnt, sum;
int main() {
  while (true) {
    memset(dp, 0, sizeof(dp));
    memset(card, 0, sizeof(card));
    // cin.
    cin >> n;
    if (n == 0) {
      break;
    }
    cnt = 0;
    sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      card[i][0] = a;
      card[i][1] = b;
      for (int j = 0; j < b; j++) {
        sum += a;
      }
    }
    // dp.
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= sum; j++) {
        if (dp[i - 1][j] != 0) {
          for (int k = 0; k <= card[i - 1][1]; k++) {
            dp[i][j + k * card[i - 1][0]] += dp[i - 1][j];
          }
        }
      }
    }
    // cin2.
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> a;
      cout << dp[n][a] << endl;
    }
  }
  return 0;
} | 
	#include <cstring>
#include <iostream>
using namespace std;
#define MAX_N 82000
#define MAX_CARD 100
long long dp[MAX_CARD][MAX_N];
long long card[MAX_CARD][2];
int n, m, a, b, cnt, sum;
int main() {
  while (true) {
    memset(dp, 0, sizeof(dp));
    memset(card, 0, sizeof(card));
    // cin.
    cin >> n;
    if (n == 0) {
      break;
    }
    cnt = 0;
    sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      card[i][0] = a;
      card[i][1] = b;
      for (int j = 0; j < b; j++) {
        sum += a;
      }
    }
    // dp.
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= sum; j++) {
        if (dp[i - 1][j] != 0) {
          for (int k = 0; k <= card[i - 1][1]; k++) {
            dp[i][j + k * card[i - 1][0]] += dp[i - 1][j];
          }
        }
      }
    }
    // cin2.
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> a;
      cout << dp[n][a] << endl;
    }
  }
  return 0;
} | 
	replace | 4 | 6 | 4 | 6 | 
	MLE | |
| 
	p00154 | 
	C++ | 
	Runtime Error | 
	#include <bits/stdc++.h>
using namespace std;
int a[8][1000];
int main() {
  int b;
  while (cin >> b, b) {
    memset(a, 0, sizeof(a));
    for (int c = 0; c < b; c++) {
      a[c][0] = 1;
      int d, e;
      cin >> d >> e;
      for (int f = 0; f <= e; f++) {
        for (int g = max(f * d, 1); g <= 1000; g++) {
          a[c + 1][g] += a[c][g - f * d];
        }
      }
    }
    int s;
    cin >> s;
    for (int n = 0; n < s; n++) {
      int w;
      cin >> w;
      cout << a[b][w] << endl;
    }
  }
} | 
	#include <bits/stdc++.h>
using namespace std;
int a[8][1001];
int main() {
  int b;
  while (cin >> b, b) {
    memset(a, 0, sizeof(a));
    for (int c = 0; c < b; c++) {
      a[c][0] = 1;
      int d, e;
      cin >> d >> e;
      for (int f = 0; f <= e; f++) {
        for (int g = max(f * d, 1); g <= 1000; g++) {
          a[c + 1][g] += a[c][g - f * d];
        }
      }
    }
    int s;
    cin >> s;
    for (int n = 0; n < s; n++) {
      int w;
      cin >> w;
      cout << a[b][w] << endl;
    }
  }
} | 
	replace | 3 | 4 | 3 | 4 | 
	0 | |
| 
	p00154 | 
	C++ | 
	Runtime Error | 
	#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define RFOR(i, a) for (int i = (a); i >= 0; --i)
#define FOE(i, a) for (auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef long long LL;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = std::vector<std::vector<T>>;
template <typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template <class T> inline void print(T x) { std::cout << x << std::endl; }
template <class T> inline bool inside(T y, T x, T H, T W) {
  return 0 <= y and y < H and 0 <= x and x < W;
}
inline double distance(double y1, double x1, double y2, double x2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = {0, 1, 0, -1},
                       dx = {1, 0, -1, 0}; // 4近傍(右, 下, 左, 上)
using namespace std;
void solve(vector<pair<int, int>> v, vector<int> q) {
  VV<LL> dp(v.size() + 1, V<LL>(1001, 0));
  dp[0][0] = 1;
  FOR(i, 0, v.size()) {
    FOR(j, 0, dp[0].size()) {
      if (dp[i][j] == 0) {
        continue;
      }
      FOR(k, 0, v[i].second + 1) {
        int x = v[i].first * k;
        if (x < dp[0].size()) {
          dp[i + 1][j + x] += dp[i][j];
        }
      }
    }
  }
  FOE(n, q) { print(dp[dp.size() - 1][n]); }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (true) {
    int M;
    cin >> M;
    if (M == 0) {
      break;
    }
    vector<pair<int, int>> v;
    FOR(_, 0, M) {
      int a, b;
      cin >> a >> b;
      v.emplace_back(make_pair(a, b));
    }
    vector<int> q;
    int G;
    cin >> G;
    FOR(_, 0, G) {
      int n;
      cin >> n;
      q.emplace_back(n);
    }
    solve(v, q);
  }
  return 0;
}
 | 
	#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define RFOR(i, a) for (int i = (a); i >= 0; --i)
#define FOE(i, a) for (auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef long long LL;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = std::vector<std::vector<T>>;
template <typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template <class T> inline void print(T x) { std::cout << x << std::endl; }
template <class T> inline bool inside(T y, T x, T H, T W) {
  return 0 <= y and y < H and 0 <= x and x < W;
}
inline double distance(double y1, double x1, double y2, double x2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = {0, 1, 0, -1},
                       dx = {1, 0, -1, 0}; // 4近傍(右, 下, 左, 上)
using namespace std;
void solve(vector<pair<int, int>> v, vector<int> q) {
  VV<LL> dp(v.size() + 1, V<LL>(1001, 0));
  dp[0][0] = 1;
  FOR(i, 0, v.size()) {
    FOR(j, 0, dp[0].size()) {
      if (dp[i][j] == 0) {
        continue;
      }
      FOR(k, 0, v[i].second + 1) {
        int x = v[i].first * k;
        if (j + x < dp[0].size()) {
          dp[i + 1][j + x] += dp[i][j];
        }
      }
    }
  }
  FOE(n, q) { print(dp[dp.size() - 1][n]); }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (true) {
    int M;
    cin >> M;
    if (M == 0) {
      break;
    }
    vector<pair<int, int>> v;
    FOR(_, 0, M) {
      int a, b;
      cin >> a >> b;
      v.emplace_back(make_pair(a, b));
    }
    vector<int> q;
    int G;
    cin >> G;
    FOR(_, 0, G) {
      int n;
      cin >> n;
      q.emplace_back(n);
    }
    solve(v, q);
  }
  return 0;
}
 | 
	replace | 48 | 49 | 48 | 49 | 
	-6 | 
	corrupted size vs. prev_size
 | 
| 
	p00155 | 
	C++ | 
	Runtime Error | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    double g[n][n];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        g[i][j] = 100000000;
    int b[n], x[n], y[n];
    for (int i = 0; i < n; i++) {
      int b, _x, _y;
      cin >> b >> _x >> _y;
      x[b - 1] = _x;
      x[b - 1] = _y;
      // cin >> b[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        int xx = x[i] - x[j], yy = y[i] - y[j];
        if (pow(xx, 2) + pow(yy, 2) <= 2500 && i != j)
          g[i][j] = g[j][i] = sqrt(pow(xx, 2) + pow(yy, 2));
      }
    int m;
    cin >> m;
    int s, go;
    for (int i = 0; i < m; i++) {
      cin >> s >> go;
      s--;
      go--;
      vector<int> used(n, false);
      vector<int> gone(n, false);
      vector<double> dist(n, 100000000);
      dist[s] = 0;
      gone[s] = 0;
      while (1) {
        int va = -1;
        for (int j = 0; j < n; j++)
          if (used[j] == false && (va == -1 || dist[va] > dist[j]))
            va = j;
        if (va == -1)
          break;
        used[va] = true;
        for (int j = 0; j < n; j++) {
          if (dist[j] >= dist[va] + g[va][j])
            gone[j] = va;
          dist[j] = min(dist[j], dist[va] + g[va][j]);
        }
      }
      if (s == go)
        cout << s + 1 << " " << go + 1 << endl;
      else if (dist[go] == 100000000)
        cout << "NA" << endl;
      else {
        int kari = go;
        stack<int> out;
        while (1) {
          out.push(gone[kari] + 1);
          kari = gone[kari];
          if (kari == s)
            break;
        }
        while (!out.empty()) {
          cout << out.top() << " ";
          out.pop();
        }
        cout << go + 1 << endl;
      }
    }
  }
} | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    double g[n][n];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        g[i][j] = 100000000;
    int b[n], x[n], y[n];
    for (int i = 0; i < n; i++) {
      int b, _x, _y;
      cin >> b >> _x >> _y;
      x[b - 1] = _x;
      y[b - 1] = _y;
      // cin >> b[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        int xx = x[i] - x[j], yy = y[i] - y[j];
        if (pow(xx, 2) + pow(yy, 2) <= 2500 && i != j)
          g[i][j] = g[j][i] = sqrt(pow(xx, 2) + pow(yy, 2));
      }
    int m;
    cin >> m;
    int s, go;
    for (int i = 0; i < m; i++) {
      cin >> s >> go;
      s--;
      go--;
      vector<int> used(n, false);
      vector<int> gone(n, false);
      vector<double> dist(n, 100000000);
      dist[s] = 0;
      gone[s] = 0;
      while (1) {
        int va = -1;
        for (int j = 0; j < n; j++)
          if (used[j] == false && (va == -1 || dist[va] > dist[j]))
            va = j;
        if (va == -1)
          break;
        used[va] = true;
        for (int j = 0; j < n; j++) {
          if (dist[j] >= dist[va] + g[va][j])
            gone[j] = va;
          dist[j] = min(dist[j], dist[va] + g[va][j]);
        }
      }
      if (s == go)
        cout << s + 1 << " " << go + 1 << endl;
      else if (dist[go] == 100000000)
        cout << "NA" << endl;
      else {
        int kari = go;
        stack<int> out;
        while (1) {
          out.push(gone[kari] + 1);
          kari = gone[kari];
          if (kari == s)
            break;
        }
        while (!out.empty()) {
          cout << out.top() << " ";
          out.pop();
        }
        cout << go + 1 << endl;
      }
    }
  }
} | 
	replace | 14 | 15 | 14 | 15 | 
	TLE | |
| 
	p00155 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
const double EPS = 1e-6;
struct Building {
  int x, y;
  Building() {
    x = -1;
    y = -1;
  }
};
struct Edge {
  int to;
  double cost;
  Edge() {}
  Edge(const int &_to, const double &_cost) {
    to = _to;
    cost = _cost;
  }
};
struct Data {
  int n;
  double cost;
  Data() {}
  Data(const int &_n, const double &_cost) {
    n = _n;
    cost = _cost;
  }
  bool operator<(const Data &a) const { return cost > a.cost; }
};
double GetDistance(const Building &b1, const Building &b2) {
  double dx = b1.x - b2.x, dy = b1.y - b2.y;
  return sqrt(dx * dx + dy * dy);
}
vector<Edge> e[1000];
Building v[1000];
priority_queue<Data> pq;
int main() {
  int N, M, B, S, G;
  while (cin >> N, N) {
    for (int i = 0; i < 1000; i++)
      e[i].clear();
    for (int i = 0; i < N; i++) {
      cin >> B;
      B--;
      cin >> v[B].x >> v[B].y;
    }
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (v[i].x == -1 || v[j].x == -1 || i == j)
          continue;
        double dist = GetDistance(v[i], v[j]);
        if (dist <= 50) {
          e[i].push_back(Edge(j, dist));
          e[j].push_back(Edge(i, dist));
        }
      }
    }
    cin >> M;
    for (int j = 0; j < M; j++) {
      cin >> S >> G;
      S--;
      G--;
      Data pq_top;
      pq.push(Data(S, 0));
      double memo[1000];
      fill_n(memo, 1000, -1);
      bool na = true;
      while (!pq.empty()) {
        pq_top = pq.top();
        pq.pop();
        if (memo[pq_top.n] > -0.5)
          continue;
        memo[pq_top.n] = pq_top.cost;
        if (pq_top.n == G) {
          na = false;
          break;
        }
        for (int i = 0; i < e[pq_top.n].size(); i++) {
          pq.push(Data(e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost));
        }
      }
      while (!pq.empty())
        pq.pop();
      if (na) {
        puts("NA");
        break;
      }
      stack<int> ans;
      while (true) {
        ans.push(G);
        if (G == S)
          break;
        for (int i = 0; i < e[G].size(); i++) {
          if (abs(memo[G] - memo[e[G][i].to] - e[G][i].cost) < EPS) {
            G = e[G][i].to;
            break;
          }
        }
      }
      printf("%d", ans.top() + 1);
      ans.pop();
      while (!ans.empty()) {
        printf(" %d", ans.top() + 1);
        ans.pop();
      }
      puts("");
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
const double EPS = 1e-6;
struct Building {
  int x, y;
  Building() {
    x = -1;
    y = -1;
  }
};
struct Edge {
  int to;
  double cost;
  Edge() {}
  Edge(const int &_to, const double &_cost) {
    to = _to;
    cost = _cost;
  }
};
struct Data {
  int n;
  double cost;
  Data() {}
  Data(const int &_n, const double &_cost) {
    n = _n;
    cost = _cost;
  }
  bool operator<(const Data &a) const { return cost > a.cost; }
};
double GetDistance(const Building &b1, const Building &b2) {
  double dx = b1.x - b2.x, dy = b1.y - b2.y;
  return sqrt(dx * dx + dy * dy);
}
vector<Edge> e[1000];
Building v[1000];
priority_queue<Data> pq;
int main() {
  int N, M, B, S, G;
  while (cin >> N, N) {
    for (int i = 0; i < 1000; i++)
      e[i].clear();
    for (int i = 0; i < N; i++) {
      cin >> B;
      B--;
      cin >> v[B].x >> v[B].y;
    }
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (v[i].x == -1 || v[j].x == -1 || i == j)
          continue;
        double dist = GetDistance(v[i], v[j]);
        if (dist <= 50) {
          e[i].push_back(Edge(j, dist));
          e[j].push_back(Edge(i, dist));
        }
      }
    }
    cin >> M;
    for (int j = 0; j < M; j++) {
      cin >> S >> G;
      S--;
      G--;
      Data pq_top;
      pq.push(Data(S, 0));
      double memo[1000];
      fill_n(memo, 1000, -1);
      bool na = true;
      while (!pq.empty()) {
        pq_top = pq.top();
        pq.pop();
        if (memo[pq_top.n] > -0.5)
          continue;
        memo[pq_top.n] = pq_top.cost;
        if (pq_top.n == G) {
          na = false;
          break;
        }
        for (int i = 0; i < e[pq_top.n].size(); i++) {
          pq.push(Data(e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost));
        }
      }
      while (!pq.empty())
        pq.pop();
      if (na) {
        puts("NA");
        continue;
      }
      stack<int> ans;
      while (true) {
        ans.push(G);
        if (G == S)
          break;
        for (int i = 0; i < e[G].size(); i++) {
          if (abs(memo[G] - memo[e[G][i].to] - e[G][i].cost) < EPS) {
            G = e[G][i].to;
            break;
          }
        }
      }
      printf("%d", ans.top() + 1);
      ans.pop();
      while (!ans.empty()) {
        printf(" %d", ans.top() + 1);
        ans.pop();
      }
      puts("");
    }
  }
  return 0;
} | 
	replace | 107 | 108 | 107 | 108 | 
	TLE | |
| 
	p00155 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
const int MAX = 1000;
struct int2 {
  int x;
  int y;
};
class Node {
public:
  int id;
  double cost;
  int parent;
  bool visited;
  vector<int> edge_to;
  vector<double> edge_cost;
  Node() {}
  Node(int id) : id(id), cost(-1.0), parent(-1), visited(false) {}
  bool operator<(const Node &n) const { return cost > n.cost; }
};
int n, m;
Node nodes[MAX];
int2 pos[MAX];
int sid, gid;
void solve() {
  priority_queue<Node> q;
  nodes[sid].cost = 0.0;
  q.push(nodes[sid]);
  while (!q.empty()) {
    Node nn = q.top();
    q.pop();
    if (nn.visited)
      continue;
    if (nn.id == gid)
      return;
    nn.visited = true;
    for (int i = 0; i < nn.edge_to.size(); i++) {
      int to = nn.edge_to[i];
      double cost = nn.cost + nn.edge_cost[i];
      if (nodes[to].cost > cost || nodes[to].cost < 0.0) {
        if (nodes[to].visited)
          continue;
        nodes[to].cost = cost;
        nodes[to].parent = nn.id;
        q.push(nodes[to]);
      }
    }
  }
}
void reset() {
  for (int i = 0; i < n; i++) {
    nodes[i].cost = -1;
    nodes[i].parent = -1;
    nodes[i].visited = false;
  }
}
int main(int argc, char **argv) {
  int b, x, y;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> b >> x >> y;
      int2 tmp = {x, y};
      pos[b - 1] = tmp;
      nodes[i] = Node(i);
    }
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < i; j++) {
        int dx = pos[i].x - pos[j].x;
        int dy = pos[i].y - pos[j].y;
        double dist = sqrt((double)(dx * dx + dy * dy));
        if (dist <= 50.0) {
          nodes[i].edge_to.push_back(j);
          nodes[i].edge_cost.push_back(dist);
          nodes[j].edge_to.push_back(i);
          nodes[j].edge_cost.push_back(dist);
        }
      }
    }
    cin >> m;
    for (int k = 0; k < m; k++) {
      cin >> sid >> gid;
      sid = sid - 1;
      gid = gid - 1;
      solve();
      vector<int> way;
      way.push_back(gid);
      Node nn = nodes[gid];
      while (nn.parent != -1) {
        way.push_back(nn.parent);
        nn = nodes[nn.parent];
      }
      if (way.size() > 1) {
        for (int i = 0; i < way.size(); i++) {
          if (i != 0)
            cout << " ";
          cout << way[way.size() - i - 1] + 1;
        }
      } else {
        cout << "NA";
      }
      cout << endl;
    }
  }
} | 
	#include <iostream>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
const int MAX = 1000;
struct int2 {
  int x;
  int y;
};
class Node {
public:
  int id;
  double cost;
  int parent;
  bool visited;
  vector<int> edge_to;
  vector<double> edge_cost;
  Node() {}
  Node(int id) : id(id), cost(-1.0), parent(-1), visited(false) {}
  bool operator<(const Node &n) const { return cost > n.cost; }
};
int n, m;
Node nodes[MAX];
int2 pos[MAX];
int sid, gid;
void solve() {
  priority_queue<Node> q;
  nodes[sid].cost = 0.0;
  q.push(nodes[sid]);
  while (!q.empty()) {
    Node nn = q.top();
    q.pop();
    if (nn.visited)
      continue;
    if (nn.id == gid)
      return;
    nn.visited = true;
    for (int i = 0; i < nn.edge_to.size(); i++) {
      int to = nn.edge_to[i];
      double cost = nn.cost + nn.edge_cost[i];
      if (nodes[to].cost > cost || nodes[to].cost < 0.0) {
        if (nodes[to].visited)
          continue;
        nodes[to].cost = cost;
        nodes[to].parent = nn.id;
        q.push(nodes[to]);
      }
    }
  }
}
void reset() {
  for (int i = 0; i < n; i++) {
    nodes[i].cost = -1;
    nodes[i].parent = -1;
    nodes[i].visited = false;
  }
}
int main(int argc, char **argv) {
  int b, x, y;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> b >> x >> y;
      int2 tmp = {x, y};
      pos[b - 1] = tmp;
      nodes[i] = Node(i);
    }
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < i; j++) {
        int dx = pos[i].x - pos[j].x;
        int dy = pos[i].y - pos[j].y;
        double dist = sqrt((double)(dx * dx + dy * dy));
        if (dist <= 50.0) {
          nodes[i].edge_to.push_back(j);
          nodes[i].edge_cost.push_back(dist);
          nodes[j].edge_to.push_back(i);
          nodes[j].edge_cost.push_back(dist);
        }
      }
    }
    cin >> m;
    for (int k = 0; k < m; k++) {
      if (k)
        reset();
      cin >> sid >> gid;
      sid = sid - 1;
      gid = gid - 1;
      solve();
      vector<int> way;
      way.push_back(gid);
      Node nn = nodes[gid];
      while (nn.parent != -1) {
        way.push_back(nn.parent);
        nn = nodes[nn.parent];
      }
      if (way.size() > 1) {
        for (int i = 0; i < way.size(); i++) {
          if (i != 0)
            cout << " ";
          cout << way[way.size() - i - 1] + 1;
        }
      } else {
        cout << "NA";
      }
      cout << endl;
    }
  }
} | 
	insert | 97 | 97 | 97 | 99 | 
	TLE | |
| 
	p00155 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(), (r).end()
#define rall(r) (r).rbegin(), (r).rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const double INF_D = 1e18;
const double PI = acos(-1);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
struct Edge {
  int t;
  double c;
  Edge(){};
  Edge(int t, double c) : t(t), c(c){};
};
int n;
int b[1010], x[1010], y[1010];
vector<Edge> edge[1010];
pdi d[1010];
bool used[1010];
vi ans;
void dijkstra(int s) {
  rep(i, 1010) {
    d[i] = mp(INF_D, -1);
    used[i] = false;
  }
  d[s].fi = 0.0;
  priority_queue<pdi, vector<pdi>, greater<pdi>> q;
  pdi p;
  q.push(mp(0.0, s));
  int from, to;
  double cost;
  while (!q.empty()) {
    p = q.top();
    q.pop();
    from = p.se;
    // cost = p.fi;
    if (d[from].fi < p.fi)
      continue;
    cost = p.fi;
    used[from] = true;
    auto e = edge[from];
    for (int i = 0; i < e.size(); i++) {
      to = e[i].t;
      // if(used[to]) continue;
      if (d[to].fi > cost + e[i].c) {
        // if(to == 11) cout<<"  "<<from<<" "<< cost+e[i].c<<endl;
        d[to].fi = cost + e[i].c;
        d[to].se = from;
        q.push(mp(d[to].fi, to));
      }
    }
  }
}
double getDist2(int x1, int y1, int x2, int y2) {
  int dx = x1 - x2, dy = y1 - y2;
  return sqrt(dx * dx + dy * dy);
}
int main() {
  int m, dx, dy;
  while (cin >> n && n) {
    // cout<<n<<endl;
    rep(i, 1010) {
      b[i] = x[i] = y[i] = -1;
      d[i] = mp(INF_D, -1);
      used[i] = false;
      edge[i].clear();
    }
    rep(i, n) cin >> b[i] >> x[i] >> y[i];
    for (int i = 0; i < 1010; i++) {
      if (b[i] == -1 || x[i] == -1 || y[i] == -1)
        continue;
      for (int j = i + 1; j < 1010; j++) {
        if (b[j] == -1 || x[j] == -1 || y[j] == -1)
          continue;
        dx = x[i] - x[j];
        dy = y[i] - y[j];
        if (dx * dx + dy * dy > 2500)
          continue;
        edge[b[i]].push_back(Edge(b[j], sqrt(dx * dx + dy * dy)));
        edge[b[j]].push_back(Edge(b[i], sqrt(dx * dx + dy * dy)));
      }
    }
    // cout<<edge[1][0].t<<" "<<edge[1][0].c<<endl;
    // cout<<edge[2][0].t<<" "<<edge[2][0].c<<endl;
    cin >> m;
    rep(i, m) {
      int s, g;
      cin >> s >> g;
      // cout<<s<<" "<<g<<endl;
      dijkstra(s);
      if (d[g].fi == INF) {
        cout << "NA" << endl;
        continue;
      }
      ans.clear();
      // bool usedG[1010]={};
      while (1) {
        ans.pb(g);
        if (g == s /*|| g == -1*/)
          break;
        // usedG[g] = true;
        g = d[g].se;
        // if(usedG[g]) break;
        // cout<<"  "<<g<<endl;
      }
      // while(ans.size()> 0 && ans.back()==-1) ans.pop_back();
      reverse(all(ans));
      rep(j, ans.size()) {
        if (j != 0)
          cout << " ";
        cout << ans[j];
      }
      cout << endl;
      // for(int i = 1; i <= 22; i++){
      // 	cout<<" "<<i<<" "<<d[i].fi<<" "<<d[i].se<<endl;
      // }
      // for(int i = 0; i < edge[11].size(); i++){
      // 	if(edge[11][i].t == 6){
      // 		cout<<edge[11][i].c<<endl;
      // 	}
      // }
    }
  }
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(), (r).end()
#define rall(r) (r).rbegin(), (r).rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const double INF_D = 1e18;
const double PI = acos(-1);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
struct Edge {
  int t;
  double c;
  Edge(){};
  Edge(int t, double c) : t(t), c(c){};
};
int n;
int b[1010], x[1010], y[1010];
vector<Edge> edge[1010];
pdi d[1010];
bool used[1010];
vi ans;
void dijkstra(int s) {
  rep(i, 1010) {
    d[i] = mp(INF_D, -1);
    used[i] = false;
  }
  d[s].fi = 0.0;
  priority_queue<pdi, vector<pdi>, greater<pdi>> q;
  pdi p;
  q.push(mp(0.0, s));
  int from, to;
  double cost;
  while (!q.empty()) {
    p = q.top();
    q.pop();
    from = p.se;
    // cost = p.fi;
    if (d[from].fi < p.fi)
      continue;
    cost = p.fi;
    used[from] = true;
    auto e = edge[from];
    for (int i = 0; i < e.size(); i++) {
      to = e[i].t;
      // if(used[to]) continue;
      if (d[to].fi > cost + e[i].c) {
        // if(to == 11) cout<<"  "<<from<<" "<< cost+e[i].c<<endl;
        d[to].fi = cost + e[i].c;
        d[to].se = from;
        q.push(mp(d[to].fi, to));
      }
    }
  }
}
double getDist2(int x1, int y1, int x2, int y2) {
  int dx = x1 - x2, dy = y1 - y2;
  return sqrt(dx * dx + dy * dy);
}
int main() {
  int m, dx, dy;
  while (cin >> n && n) {
    // cout<<n<<endl;
    rep(i, 1010) {
      b[i] = x[i] = y[i] = -1;
      d[i] = mp(INF_D, -1);
      used[i] = false;
      edge[i].clear();
    }
    rep(i, n) cin >> b[i] >> x[i] >> y[i];
    for (int i = 0; i < 1010; i++) {
      if (b[i] == -1 || x[i] == -1 || y[i] == -1)
        continue;
      for (int j = i + 1; j < 1010; j++) {
        if (b[j] == -1 || x[j] == -1 || y[j] == -1)
          continue;
        dx = x[i] - x[j];
        dy = y[i] - y[j];
        if (dx * dx + dy * dy > 2500)
          continue;
        edge[b[i]].push_back(Edge(b[j], sqrt(dx * dx + dy * dy)));
        edge[b[j]].push_back(Edge(b[i], sqrt(dx * dx + dy * dy)));
      }
    }
    // cout<<edge[1][0].t<<" "<<edge[1][0].c<<endl;
    // cout<<edge[2][0].t<<" "<<edge[2][0].c<<endl;
    cin >> m;
    rep(i, m) {
      int s, g;
      cin >> s >> g;
      // cout<<s<<" "<<g<<endl;
      dijkstra(s);
      if (d[g].fi == INF_D) {
        cout << "NA" << endl;
        continue;
      }
      ans.clear();
      // bool usedG[1010]={};
      while (1) {
        ans.pb(g);
        if (g == s /*|| g == -1*/)
          break;
        // usedG[g] = true;
        g = d[g].se;
        // if(usedG[g]) break;
        // cout<<"  "<<g<<endl;
      }
      // while(ans.size()> 0 && ans.back()==-1) ans.pop_back();
      reverse(all(ans));
      rep(j, ans.size()) {
        if (j != 0)
          cout << " ";
        cout << ans[j];
      }
      cout << endl;
      // for(int i = 1; i <= 22; i++){
      // 	cout<<" "<<i<<" "<<d[i].fi<<" "<<d[i].se<<endl;
      // }
      // for(int i = 0; i < edge[11].size(); i++){
      // 	if(edge[11][i].t == 6){
      // 		cout<<edge[11][i].c<<endl;
      // 	}
      // }
    }
  }
} | 
	replace | 135 | 136 | 135 | 136 | 
	-6 | 
	terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
 | 
| 
	p00156 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
#define MAX_N 1000
int X[MAX_N][MAX_N], dist[MAX_N][MAX_N], W, H, gx, gy;
char c;
int main() {
  while (true) {
    for (int i = 0; i < MAX_N; i++) {
      for (int j = 0; j < MAX_N; j++) {
        X[i][j] = 1000000000;
        dist[i][j] = 1000000000;
      }
    }
    cin >> W >> H;
    queue<pair<int, int>> Q;
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> c;
        if (c == '&') {
          gx = i;
          gy = j;
        }
        if (c == '#') {
          X[i][j] = 1;
        } else {
          X[i][j] = 0;
        }
        if (i == 1 || i == H || j == 1 || j == W) {
          Q.push(make_pair(i, j));
          dist[i][j] = X[i][j];
        }
      }
    }
    while (!Q.empty()) {
      pair<int, int> pa = Q.front();
      Q.pop();
      int cx = pa.first, cy = pa.second;
      int dx[4] = {1, 0, -1, 0};
      int dy[4] = {0, 1, 0, -1};
      for (int i = 0; i < 4; i++) {
        int ex = cx + dx[i], ey = cy + dy[i];
        if (X[ex][ey] >= 2) {
          continue;
        }
        int dis = dist[cx][cy];
        if (X[cx][cy] == 0 && X[ex][ey] == 1) {
          dis += 1;
        }
        if (dist[ex][ey] > dis) {
          dist[ex][ey] = dis;
          Q.push(make_pair(ex, ey));
        }
      }
    }
    cout << dist[gx][gy] << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
#define MAX_N 1000
int X[MAX_N][MAX_N], dist[MAX_N][MAX_N], W, H, gx, gy;
char c;
int main() {
  while (true) {
    for (int i = 0; i < MAX_N; i++) {
      for (int j = 0; j < MAX_N; j++) {
        X[i][j] = 1000000000;
        dist[i][j] = 1000000000;
      }
    }
    cin >> W >> H;
    queue<pair<int, int>> Q;
    if (W == 0 && H == 0) {
      break;
    }
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> c;
        if (c == '&') {
          gx = i;
          gy = j;
        }
        if (c == '#') {
          X[i][j] = 1;
        } else {
          X[i][j] = 0;
        }
        if (i == 1 || i == H || j == 1 || j == W) {
          Q.push(make_pair(i, j));
          dist[i][j] = X[i][j];
        }
      }
    }
    while (!Q.empty()) {
      pair<int, int> pa = Q.front();
      Q.pop();
      int cx = pa.first, cy = pa.second;
      int dx[4] = {1, 0, -1, 0};
      int dy[4] = {0, 1, 0, -1};
      for (int i = 0; i < 4; i++) {
        int ex = cx + dx[i], ey = cy + dy[i];
        if (X[ex][ey] >= 2) {
          continue;
        }
        int dis = dist[cx][cy];
        if (X[cx][cy] == 0 && X[ex][ey] == 1) {
          dis += 1;
        }
        if (dist[ex][ey] > dis) {
          dist[ex][ey] = dis;
          Q.push(make_pair(ex, ey));
        }
      }
    }
    cout << dist[gx][gy] << endl;
  }
  return 0;
} | 
	insert | 17 | 17 | 17 | 20 | 
	TLE | |
| 
	p00157 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> MAT;
#define h first
#define r second
#define rep(i, n) for (int i = 0; i < n; i++)
int dp[1000][1000];
MAT info[200];
int n, m;
int dfs(int a, int b) {
  if (~dp[a][b])
    return dp[a][b];
  int hoge = 0;
  rep(i, n) {
    if (info[i].first < a && info[i].second < b) {
      hoge = max(hoge, dfs(info[i].first, info[i].second) + 1);
    }
  }
  return hoge;
}
int main() {
  while (cin >> n, n) {
    rep(i, 1000) rep(j, 1000) dp[i][j] = -1;
    int ret = 0;
    rep(i, n) cin >> info[i].h >> info[i].r;
    cin >> m;
    rep(i, m) cin >> info[n + i].h >> info[n + i].r;
    n = n + m;
    rep(i, n) { ret = max(ret, dfs(info[i].first, info[i].second) + 1); }
    cout << ret << endl;
  }
} | 
	#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> MAT;
#define h first
#define r second
#define rep(i, n) for (int i = 0; i < n; i++)
int dp[1000][1000];
MAT info[200];
int n, m;
int dfs(int a, int b) {
  if (~dp[a][b])
    return dp[a][b];
  int hoge = 0;
  rep(i, n) {
    if (info[i].first < a && info[i].second < b) {
      hoge = max(hoge, dfs(info[i].first, info[i].second) + 1);
    }
  }
  return dp[a][b] = hoge;
}
int main() {
  while (cin >> n, n) {
    rep(i, 1000) rep(j, 1000) dp[i][j] = -1;
    int ret = 0;
    rep(i, n) cin >> info[i].h >> info[i].r;
    cin >> m;
    rep(i, m) cin >> info[n + i].h >> info[n + i].r;
    n = n + m;
    rep(i, n) { ret = max(ret, dfs(info[i].first, info[i].second) + 1); }
    cout << ret << endl;
  }
} | 
	replace | 22 | 23 | 22 | 23 | 
	TLE | |
| 
	p00157 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
  int n;
  while (cin >> n, n) {
    vector<pii> in;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    cin >> n;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    sort(all(in));
    n = in.size();
    vi dp(110, 1);
    loop(i, 1, n) {
      int ma = 0;
      rep(j, i) if (in[j].first < in[i].first && in[j].second < in[i].second)
          ma = max(ma, dp[j]);
      dp[i] += ma;
    }
    int ma = 0;
    rep(i, n) ma = max(ma, dp[i]);
    cout << ma << endl;
  }
} | 
	#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
  int n;
  while (cin >> n, n) {
    vector<pii> in;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    cin >> n;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    sort(all(in));
    n = in.size();
    vi dp(210, 1);
    loop(i, 1, n) {
      int ma = 0;
      rep(j, i) if (in[j].first < in[i].first && in[j].second < in[i].second)
          ma = max(ma, dp[j]);
      dp[i] += ma;
    }
    int ma = 0;
    rep(i, n) ma = max(ma, dp[i]);
    cout << ma << endl;
  }
} | 
	replace | 41 | 42 | 41 | 42 | 
	0 | |
| 
	p00157 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  int n[2], c[2];
  while (cin >> n[0], n[0]) {
    int h[2][110], r[2][110], mx[2][110];
    rep(q, 2) {
      rep(i, n[q]) mx[q][i] = 0, cin >> h[q][i] >> r[q][i];
      if (!q)
        cin >> n[1];
    }
    mx[0][0] = (h[0][0] > h[1][0] && r[0][0] > r[1][0]) + 1;
    mx[1][0] = (h[0][0] < h[1][0] && r[0][0] < r[1][0]) + 1;
    int p;
    c[0] = c[1] = p = 0;
    while (c[0] < n[0] || c[1] < n[1]) {
      int tmax = 0, f;
      rep(k, 2) {
        rep(i, n[k]) {
          f = h[k][i] < h[p][c[p]] && r[k][i] < r[p][c[p]];
          if (f && tmax < mx[k][i])
            tmax = mx[k][i];
          if (f && mx[k][i] == 0) {
            p ^= 1;
            goto NEXT;
          }
        }
      }
      mx[p][c[p]++] = tmax + 1;
    NEXT:;
    }
    cout << max(mx[0][n[0] - 1], mx[1][n[1] - 1]) << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  int n[2], c[2];
  while (cin >> n[0], n[0]) {
    int h[2][110], r[2][110], mx[2][110];
    rep(q, 2) {
      rep(i, n[q]) mx[q][i] = 0, cin >> h[q][i] >> r[q][i];
      if (!q)
        cin >> n[1];
    }
    mx[0][0] = (h[0][0] > h[1][0] && r[0][0] > r[1][0]) + 1;
    mx[1][0] = (h[0][0] < h[1][0] && r[0][0] < r[1][0]) + 1;
    int p;
    c[0] = c[1] = p = 0;
    while (c[0] < n[0] || c[1] < n[1]) {
      int tmax = 0, f;
      if (c[p] == n[p]) {
        p ^= 1;
        goto NEXT;
      }
      rep(k, 2) {
        rep(i, n[k]) {
          f = h[k][i] < h[p][c[p]] && r[k][i] < r[p][c[p]];
          if (f && tmax < mx[k][i])
            tmax = mx[k][i];
          if (f && mx[k][i] == 0) {
            p ^= 1;
            goto NEXT;
          }
        }
      }
      mx[p][c[p]++] = tmax + 1;
    NEXT:;
    }
    cout << max(mx[0][n[0] - 1], mx[1][n[1] - 1]) << endl;
  }
  return 0;
} | 
	insert | 20 | 20 | 20 | 24 | 
	0 | |
| 
	p00157 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, m, h, r;
  while (cin >> n, n) {
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
      cin >> h >> r;
      v.push_back(make_pair(h, r));
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> h >> r;
      v.push_back(make_pair(h, r));
    }
    sort(v.begin(), v.end());
    int mx = 0, dp[100];
    for (int i = 0; i < n + m; ++i) {
      dp[i] = 1;
      for (int j = 0; j < i; ++j) {
        if (v[j].first < v[i].first && v[j].second < v[i].second) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
      }
      mx = max(mx, dp[i]);
    }
    cout << mx << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, m, h, r;
  while (cin >> n, n) {
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
      cin >> h >> r;
      v.push_back(make_pair(h, r));
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> h >> r;
      v.push_back(make_pair(h, r));
    }
    sort(v.begin(), v.end());
    int mx = 0, dp[200];
    for (int i = 0; i < n + m; ++i) {
      dp[i] = 1;
      for (int j = 0; j < i; ++j) {
        if (v[j].first < v[i].first && v[j].second < v[i].second) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
      }
      mx = max(mx, dp[i]);
    }
    cout << mx << endl;
  }
  return 0;
} | 
	replace | 20 | 21 | 20 | 21 | 
	0 | |
| 
	p00157 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define INF 1e8
#define EPS 1e-9
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) rep2(i, 0, n)
#define ll long long
#define P pair<int, int>
#define pb push_back
int n, m, h[200], r[200], d[200][200];
int main() {
  while (cin >> n && n) {
    rep(i, n) cin >> h[i] >> r[i];
    cin >> m;
    rep(i, m) cin >> h[i + n] >> r[i + n];
    n += m;
    rep(i, n + m) fill(d[i], d[i] + n + m, INF);
    rep(i, n) rep(j, n) {
      if (i == j)
        d[i][j] = 0;
      if (h[i] > h[j] && r[i] > r[j])
        d[i][j] = -1;
    }
    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int ans = 0;
    rep(i, n) rep(j, n) ans = max(ans, -d[i][j] + 1);
    cout << ans << endl;
  }
} | 
	#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define INF 1e8
#define EPS 1e-9
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) rep2(i, 0, n)
#define ll long long
#define P pair<int, int>
#define pb push_back
int n, m, h[200], r[200], d[200][200];
int main() {
  while (cin >> n && n) {
    rep(i, n) cin >> h[i] >> r[i];
    cin >> m;
    rep(i, m) cin >> h[i + n] >> r[i + n];
    n += m;
    rep(i, n) fill(d[i], d[i] + n, INF);
    rep(i, n) rep(j, n) {
      if (i == j)
        d[i][j] = 0;
      if (h[i] > h[j] && r[i] > r[j])
        d[i][j] = -1;
    }
    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int ans = 0;
    rep(i, n) rep(j, n) ans = max(ans, -d[i][j] + 1);
    cout << ans << endl;
  }
} | 
	replace | 36 | 37 | 36 | 37 | 
	0 | |
| 
	p00157 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 101;
typedef pair<int, int> P;
int main() {
  int n, m, h, r;
  while (cin >> n, n) {
    vector<P> v;
    int dp[MAX] = {0};
    for (int i = 0; i < n; i++) {
      cin >> h >> r;
      v.push_back(P(h, r));
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h >> r;
      v.push_back(P(h, r));
    }
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < n + m; i++) {
      dp[i] = 1;
      for (int j = 0; j < i; j++) {
        if (v[j].first < v[i].first && v[j].second < v[i].second) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
        res = max(res, dp[i]);
      }
    }
    cout << res << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 1001;
typedef pair<int, int> P;
int main() {
  int n, m, h, r;
  while (cin >> n, n) {
    vector<P> v;
    int dp[MAX] = {0};
    for (int i = 0; i < n; i++) {
      cin >> h >> r;
      v.push_back(P(h, r));
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h >> r;
      v.push_back(P(h, r));
    }
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < n + m; i++) {
      dp[i] = 1;
      for (int j = 0; j < i; j++) {
        if (v[j].first < v[i].first && v[j].second < v[i].second) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
        res = max(res, dp[i]);
      }
    }
    cout << res << endl;
  }
  return 0;
} | 
	replace | 5 | 6 | 5 | 6 | 
	0 | |
| 
	p00158 | 
	C++ | 
	Time Limit Exceeded | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int cnt = 0;
    while (n != 0) {
      if (n % 2 == 0)
        n /= 2;
      else
        n = n * 3 + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
  return (0);
} | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int cnt = 0;
    while (n != 1) {
      if (n % 2 == 0)
        n /= 2;
      else
        n = n * 3 + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
  return (0);
} | 
	replace | 7 | 8 | 7 | 8 | 
	TLE | |
| 
	p00158 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main(void) {
  for (;;) {
    int cnt = 0, buf;
    cin >> buf;
    if (!buf)
      return 0;
    for (; buf != 1;) {
      buf = buf % 2 ? buf / 2 : buf * 3 + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
} | 
	#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main(void) {
  for (;;) {
    int cnt = 0, buf;
    cin >> buf;
    if (!buf)
      return 0;
    for (; buf != 1;) {
      buf = buf % 2 ? buf * 3 + 1 : buf / 2;
      cnt++;
    }
    cout << cnt << endl;
  }
} | 
	replace | 12 | 13 | 12 | 13 | 
	TLE | |
| 
	p00158 | 
	C++ | 
	Time Limit Exceeded | 
	#include <bits/stdc++.h>
using namespace std;
// template {{{
/* vim: set foldmethod=marker: */
// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14
// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
// input
inline int inputi() {
  int x;
  scanf("%d", &x);
  return x;
}
inline double inputd() {
  double x;
  scanf("%lf", &x);
  return x;
}
inline string inputs() {
  string x;
  cin >> x;
  return x;
}
// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define REPit(type, i, obj)                                                    \
  for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj)                                                   \
  for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)
// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) ((int)(obj).size())
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define clear(array) memset((array), 0, sizeof(array))
// print util
#define print(x) cout << (x) << endl
template <class T> inline void printall(vector<T> v) {
  REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1];
}
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl
// template }}}
int main() {
  int n;
  while (cin >> n) {
    int cnt = 0;
    while (n != 1) {
      n = n % 2 ? n * 3 + 1 : n / 2;
      cnt++;
    }
    print(cnt);
  }
  return 0;
} | 
	#include <bits/stdc++.h>
using namespace std;
// template {{{
/* vim: set foldmethod=marker: */
// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14
// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
// input
inline int inputi() {
  int x;
  scanf("%d", &x);
  return x;
}
inline double inputd() {
  double x;
  scanf("%lf", &x);
  return x;
}
inline string inputs() {
  string x;
  cin >> x;
  return x;
}
// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define REPit(type, i, obj)                                                    \
  for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj)                                                   \
  for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)
// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) ((int)(obj).size())
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define clear(array) memset((array), 0, sizeof(array))
// print util
#define print(x) cout << (x) << endl
template <class T> inline void printall(vector<T> v) {
  REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1];
}
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl
// template }}}
int main() {
  int n;
  while (n = inputi(), n) {
    int cnt = 0;
    while (n != 1) {
      n = n % 2 ? n * 3 + 1 : n / 2;
      cnt++;
    }
    print(cnt);
  }
  return 0;
} | 
	replace | 72 | 73 | 72 | 73 | 
	TLE | |
| 
	p00158 | 
	C++ | 
	Time Limit Exceeded | 
	#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
int main() {
  int n;
  while (cin >> n) {
    int c = 0;
    while (1) {
      if (n == 1)
        break;
      if (n % 2)
        n = 3 * n + 1;
      else
        n /= 2;
      c++;
    }
    o(c);
  }
} | 
	#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    int c = 0;
    while (1) {
      if (n == 1)
        break;
      if (n % 2)
        n = 3 * n + 1;
      else
        n /= 2;
      c++;
    }
    o(c);
  }
} | 
	replace | 14 | 15 | 14 | 18 | 
	TLE | |
| 
	p00159 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    vector<pair<double, int>> data;
    REP(i, n) {
      int num;
      double h, w;
      cin >> num >> h >> w;
      data.push_back(pair<double, int>(w * 10000 / (h * h), num));
    }
    sort(data.begin(), data.end());
    vector<pair<double, int>>::iterator itl, itu;
    itl = lower_bound(data.begin(), data.end(), pair<double, int>(22, 0));
    itu = itl - 1;
    if (abs(22 - (*itl).first) > abs(22 - (*itu).first)) {
      cout << (*itu).second << endl;
    } else {
      cout << (*itl).second << endl;
    }
  }
  return 0;
} | 
	#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    vector<pair<double, int>> data;
    REP(i, n) {
      int num;
      double h, w;
      cin >> num >> h >> w;
      data.push_back(pair<double, int>(w * 10000 / (h * h), num));
    }
    sort(data.begin(), data.end());
    vector<pair<double, int>>::iterator itl, itu;
    itl = lower_bound(data.begin(), data.end(), pair<double, int>(22, 0));
    itu = (itl != data.begin()) ? itl - 1 : itl;
    if (abs(22 - (*itl).first) > abs(22 - (*itu).first)) {
      cout << (*itu).second << endl;
    } else {
      cout << (*itl).second << endl;
    }
  }
  return 0;
} | 
	replace | 44 | 45 | 44 | 45 | 
	0 | |
| 
	p00159 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define ABS(X) ((X) < 0 ? -(X) : (X))
typedef pair<double, int> Subj;
int main(void) {
  int n;
  while (cin >> n) {
    vector<Subj> v;
    for (int i = 0; i < n; i++) {
      int id;
      double h, w, bmi;
      cin >> id >> h >> w;
      h /= 100;
      bmi = w / (h * h);
      v.push_back(make_pair(ABS(bmi - 22), id));
    }
    sort(v.begin(), v.end());
    cout << v[0].second << endl;
  }
  return 0;
}
 | 
	#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define ABS(X) ((X) < 0 ? -(X) : (X))
typedef pair<double, int> Subj;
int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    vector<Subj> v;
    for (int i = 0; i < n; i++) {
      int id;
      double h, w, bmi;
      cin >> id >> h >> w;
      h /= 100;
      bmi = w / (h * h);
      v.push_back(make_pair(ABS(bmi - 22), id));
    }
    sort(v.begin(), v.end());
    cout << v[0].second << endl;
  }
  return 0;
}
 | 
	insert | 13 | 13 | 13 | 15 | 
	-11 | |
| 
	p00160 | 
	C++ | 
	Time Limit Exceeded | 
	#include <stdio.h>
int main(void) {
  int x, y, z, w, n, i;
  int sum, l;
  while (scanf("%d", &n) != 0) {
    sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d %d", &x, &y, &z, &w);
      l = x + y + z;
      if (l <= 60 && w <= 2)
        sum += 600;
      else if (l <= 80 && w <= 5)
        sum += 800;
      else if (l <= 100 && w <= 10)
        sum += 1000;
      else if (l <= 120 && w <= 15)
        sum += 1200;
      else if (l <= 140 && w <= 20)
        sum += 1400;
      else if (l <= 160 && w <= 25)
        sum += 1600;
    }
    printf("%d\n", sum);
  }
  return 0;
} | 
	#include <stdio.h>
int main(void) {
  int x, y, z, w, n, i;
  int sum, l;
  while (0 == 0) {
    scanf("%d", &n);
    if (n == 0)
      break;
    sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d %d", &x, &y, &z, &w);
      l = x + y + z;
      if (l <= 60 && w <= 2)
        sum += 600;
      else if (l <= 80 && w <= 5)
        sum += 800;
      else if (l <= 100 && w <= 10)
        sum += 1000;
      else if (l <= 120 && w <= 15)
        sum += 1200;
      else if (l <= 140 && w <= 20)
        sum += 1400;
      else if (l <= 160 && w <= 25)
        sum += 1600;
    }
    printf("%d\n", sum);
  }
  return 0;
} | 
	replace | 6 | 7 | 6 | 10 | 
	TLE | |
| 
	p00161 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
class Score {
public:
  int num;
  int time;
  Score() {
    this->num = 0;
    this->time = 0;
  }
  Score(int num, int time) {
    this->num = num;
    this->time = time;
  }
};
int main(int argc, const char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    Score max, pre, biri, boobie;
    for (int i = 0; i < n; i++) {
      int c1;
      cin >> c1;
      int sum = 0;
      for (int i = 0; i < 4; i++) {
        int m, s;
        cin >> m >> s;
        sum += 60 * m + s;
      }
      if (max.time == 0 || max.time > sum) {
        pre = max;
        max = Score(c1, sum);
      } else if (pre.time == 0 || pre.time > sum) {
        if (biri.time == 0) {
          biri = pre;
        } else if (boobie.time == 0) {
          boobie = pre;
        }
        pre = Score(c1, sum);
      } else if (biri.time < sum) {
        boobie = biri;
        biri = Score(c1, sum);
      } else if (boobie.time < sum) {
        boobie = Score(c1, sum);
      }
    }
    cout << max.num << endl;
    cout << pre.num << endl;
    cout << boobie.num << endl;
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
class Score {
public:
  int num;
  int time;
  Score() {
    this->num = 0;
    this->time = 0;
  }
  Score(int num, int time) {
    this->num = num;
    this->time = time;
  }
};
int main(int argc, const char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    Score max, pre, biri, boobie;
    for (int i = 0; i < n; i++) {
      int c1;
      cin >> c1;
      int sum = 0;
      for (int i = 0; i < 4; i++) {
        int m, s;
        cin >> m >> s;
        sum += 60 * m + s;
      }
      if (max.time == 0 || max.time > sum) {
        pre = max;
        max = Score(c1, sum);
      } else if (pre.time == 0 || pre.time > sum) {
        if (biri.time == 0) {
          biri = pre;
        } else if (boobie.time == 0) {
          boobie = pre;
        }
        pre = Score(c1, sum);
      } else if (biri.time < sum) {
        boobie = biri;
        biri = Score(c1, sum);
      } else if (boobie.time < sum) {
        boobie = Score(c1, sum);
      }
    }
    cout << max.num << endl;
    cout << pre.num << endl;
    cout << boobie.num << endl;
  }
  return 0;
} | 
	insert | 24 | 24 | 24 | 28 | 
	TLE | |
| 
	p00161 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <iostream>
using namespace std;
struct hoge {
  int num, timem, times;
};
int main() {
  int n, c, m1, s1, m2, s2, m3, s3, m4, s4;
  hoge set[100];
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> c >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
      set[i].num = c;
      set[i].timem = m1 + m2 + m3 + m4;
      set[i].times = s1 + s2 + s3 + s4;
      if (set[i].times >= 60) {
        set[i].timem += set[i].times / 60;
        set[i].times %= 60;
      }
    }
    for (int i = 0; i < (n - 1); i++) {
      for (int j = (i + 1); j < n; j++) {
        if (set[j].timem < set[i].timem) {
          swap(set[i].num, set[j].num);
          swap(set[i].timem, set[j].timem);
          swap(set[i].times, set[j].times);
        } else if (set[j].timem == set[i].timem) {
          if (set[j].times < set[i].times) {
            swap(set[i].num, set[j].num);
            swap(set[i].timem, set[j].timem);
            swap(set[i].times, set[j].times);
          }
        }
      }
    }
    cout << set[0].num << endl << set[1].num << endl << set[n - 2].num << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <iostream>
using namespace std;
struct hoge {
  int num, timem, times;
};
int main() {
  int n, c, m1, s1, m2, s2, m3, s3, m4, s4;
  hoge set[1000000];
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> c >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
      set[i].num = c;
      set[i].timem = m1 + m2 + m3 + m4;
      set[i].times = s1 + s2 + s3 + s4;
      if (set[i].times >= 60) {
        set[i].timem += set[i].times / 60;
        set[i].times %= 60;
      }
    }
    for (int i = 0; i < (n - 1); i++) {
      for (int j = (i + 1); j < n; j++) {
        if (set[j].timem < set[i].timem) {
          swap(set[i].num, set[j].num);
          swap(set[i].timem, set[j].timem);
          swap(set[i].times, set[j].times);
        } else if (set[j].timem == set[i].timem) {
          if (set[j].times < set[i].times) {
            swap(set[i].num, set[j].num);
            swap(set[i].timem, set[j].timem);
            swap(set[i].times, set[j].times);
          }
        }
      }
    }
    cout << set[0].num << endl << set[1].num << endl << set[n - 2].num << endl;
  }
  return 0;
} | 
	replace | 10 | 11 | 10 | 11 | 
	0 | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <cmath>
#include <iostream>
using namespace std;
const int MAX_NUM = 1000;
int main() {
  bool list[MAX_NUM + 1] = {0};
  for (int two = 0; two <= 20; two++) {
    for (int three = 0; three <= 13; three++) {
      for (int five = 0; five <= 9; five++) {
        int num = pow(2, two) * pow(3, three) * pow(5, five);
        if (1 <= num && num <= MAX_NUM)
          list[num] = true;
      }
    }
  }
  int m, n;
  while (1) {
    cin >> m;
    if (m == 0)
      break;
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; i++) {
      if (list[i])
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
} | 
	#include <cmath>
#include <iostream>
using namespace std;
const int MAX_NUM = 1000000;
int main() {
  bool list[MAX_NUM + 1] = {0};
  for (int two = 0; two <= 20; two++) {
    for (int three = 0; three <= 13; three++) {
      for (int five = 0; five <= 9; five++) {
        int num = pow(2, two) * pow(3, three) * pow(5, five);
        if (1 <= num && num <= MAX_NUM)
          list[num] = true;
      }
    }
  }
  int m, n;
  while (1) {
    cin >> m;
    if (m == 0)
      break;
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; i++) {
      if (list[i])
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
} | 
	replace | 4 | 5 | 4 | 5 | 
	0 | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <cstring>
#include <iostream>
using namespace std;
const int HAMMING_MAX = 100001;
int main() {
  bool hamming[HAMMING_MAX];
  memset(hamming, 0, sizeof(hamming));
  for (int x = 1; x < HAMMING_MAX; x *= 2) {
    for (int y = 1; x * y < HAMMING_MAX; y *= 3) {
      for (int z = 1; x * y * z < HAMMING_MAX; z *= 5) {
        int h = x * y * z;
        hamming[h] = true;
      }
    }
  }
  int n, m;
  while (cin >> n && n) {
    cin >> m;
    int count = 0;
    for (int i = n; i <= m; ++i) {
      if (hamming[i]) {
        ++count;
      }
    }
    cout << count << endl;
  }
  return 0;
} | 
	#include <cstring>
#include <iostream>
using namespace std;
const int HAMMING_MAX = 1000001;
int main() {
  bool hamming[HAMMING_MAX];
  memset(hamming, 0, sizeof(hamming));
  for (int x = 1; x < HAMMING_MAX; x *= 2) {
    for (int y = 1; x * y < HAMMING_MAX; y *= 3) {
      for (int z = 1; x * y * z < HAMMING_MAX; z *= 5) {
        int h = x * y * z;
        hamming[h] = true;
      }
    }
  }
  int n, m;
  while (cin >> n && n) {
    cin >> m;
    int count = 0;
    for (int i = n; i <= m; ++i) {
      if (hamming[i]) {
        ++count;
      }
    }
    cout << count << endl;
  }
  return 0;
} | 
	replace | 4 | 5 | 4 | 5 | 
	0 | |
| 
	p00162 | 
	C++ | 
	Time Limit Exceeded | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  while (cin >> m >> n, m || n) {
    int count = 0;
    for (int i = m; i <= n; ++i) {
      int result = i;
      while (1) {
        if (result % 2 == 0)
          result = result / 2;
        else if (result % 3 == 0)
          result = result / 3;
        else if (result % 5 == 0)
          result = result / 5;
        else
          break;
      }
      if (result == 1)
        count++;
    }
    cout << count << endl;
  }
}
 | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  while (1) {
    cin >> m;
    if (m == 0)
      break;
    cin >> n;
    int count = 0;
    for (int i = m; i <= n; ++i) {
      int result = i;
      while (1) {
        if (result % 2 == 0)
          result = result / 2;
        else if (result % 3 == 0)
          result = result / 3;
        else if (result % 5 == 0)
          result = result / 5;
        else
          break;
      }
      if (result == 1)
        count++;
    }
    cout << count << endl;
  }
}
 | 
	replace | 8 | 9 | 8 | 16 | 
	TLE | |
| 
	p00162 | 
	C++ | 
	Memory Limit Exceeded | 
	#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int m;
  vector<int> count;
  for (int i = 0; i < 6; i++)
    count.push_back(i);
  for (int i = 6; i < 10000001; i++) {
    if ((i % 2 == 0 && count[i / 2] - count[(i / 2) - 1] != 0) ||
        (i % 3 == 0 && count[i / 3] - count[(i / 3) - 1] != 0) ||
        (i % 5 == 0 && count[i / 5] - count[(i / 5) - 1] != 0))
      count.push_back(count[i - 1] + 1);
    else
      count.push_back(count[i - 1]);
  }
  for (; cin >> m, m;) {
    int n;
    cin >> n;
    cout << count[n] - count[m - 1] << endl;
  }
} | 
	#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int m;
  vector<unsigned short> count;
  for (int i = 0; i < 6; i++)
    count.push_back(i);
  for (int i = 6; i < 10000001; i++) {
    if ((i % 2 == 0 && count[i / 2] - count[(i / 2) - 1] != 0) ||
        (i % 3 == 0 && count[i / 3] - count[(i / 3) - 1] != 0) ||
        (i % 5 == 0 && count[i / 5] - count[(i / 5) - 1] != 0))
      count.push_back(count[i - 1] + 1);
    else
      count.push_back(count[i - 1]);
  }
  for (; cin >> m, m;) {
    int n;
    cin >> n;
    cout << count[n] - count[m - 1] << endl;
  }
} | 
	replace | 8 | 9 | 8 | 9 | 
	MLE | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <cmath>
#include <iostream>
using namespace std;
int x[2000000];
long long p;
int a, b, sum;
int main() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 13; j++) {
      for (int k = 0; k < 9; k++) {
        p = (int)pow(2, i) * (int)pow(3, j) * (int)pow(5, k);
        if (p < 2000000) {
          x[p] = 1;
        }
      }
    }
  }
  while (true) {
    sum = 0;
    cin >> a;
    if (a == 0) {
      break;
    }
    cin >> b;
    for (int i = a; i <= b; i++) {
      sum += x[i];
    }
    cout << sum << endl;
  }
} | 
	#include <cmath>
#include <iostream>
using namespace std;
int x[2000000];
long long p;
int a, b, sum;
int main() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 13; j++) {
      for (int k = 0; k < 9; k++) {
        p = (long long)pow(2, i) * (long long)pow(3, j) * (long long)pow(5, k);
        if (p < 2000000) {
          x[p] = 1;
        }
      }
    }
  }
  while (true) {
    sum = 0;
    cin >> a;
    if (a == 0) {
      break;
    }
    cin >> b;
    for (int i = a; i <= b; i++) {
      sum += x[i];
    }
    cout << sum << endl;
  }
} | 
	replace | 12 | 13 | 12 | 13 | 
	-11 | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
#define D 100
using namespace std;
bool flg[D];
int ans[D];
int main() {
  int m, n;
  flg[1] = true;
  for (int i = 0; i <= D; i++) {
    if (flg[i]) {
      if (2 * i <= D)
        flg[2 * i] = true;
      if (3 * i <= D)
        flg[3 * i] = true;
      if (5 * i <= D)
        flg[5 * i] = true;
      // cout<<i<<endl;
    }
  }
  int cnt = 0;
  for (int i = 0; i <= D; i++) {
    if (flg[i])
      cnt++;
    ans[i] = cnt;
    // cout<<ans[i]<<endl;
  }
  while (cin >> m, m) {
    cin >> n;
    cout << ans[n] - ans[m - 1] << endl;
  }
} | 
	#include <iostream>
#define D 1000000
using namespace std;
bool flg[D];
int ans[D];
int main() {
  int m, n;
  flg[1] = true;
  for (int i = 0; i <= D; i++) {
    if (flg[i]) {
      if (2 * i <= D)
        flg[2 * i] = true;
      if (3 * i <= D)
        flg[3 * i] = true;
      if (5 * i <= D)
        flg[5 * i] = true;
      // cout<<i<<endl;
    }
  }
  int cnt = 0;
  for (int i = 0; i <= D; i++) {
    if (flg[i])
      cnt++;
    ans[i] = cnt;
    // cout<<ans[i]<<endl;
  }
  while (cin >> m, m) {
    cin >> n;
    cout << ans[n] - ans[m - 1] << endl;
  }
} | 
	replace | 1 | 2 | 1 | 2 | 
	0 | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()
const int MAXN = 100 * 1000 + 10;
bool ham[MAXN];
int main() {
  ham[1] = 1;
  REP(MAXN) if (ham[i]) {
    for (int j = i * 2; j < MAXN; j *= 2)
      ham[j] = 1;
    for (int j = i * 3; j < MAXN; j *= 3)
      ham[j] = 1;
    for (int j = i * 5; j < MAXN; j *= 5)
      ham[j] = 1;
  }
  int m, n;
  while (cin >> m && m) {
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; i++)
      if (ham[i])
        ans++;
    cout << ans << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()
const int MAXN = 1000000 + 10;
bool ham[MAXN];
int main() {
  ham[1] = 1;
  REP(MAXN) if (ham[i]) {
    for (int j = i * 2; j < MAXN; j *= 2)
      ham[j] = 1;
    for (int j = i * 3; j < MAXN; j *= 3)
      ham[j] = 1;
    for (int j = i * 5; j < MAXN; j *= 5)
      ham[j] = 1;
  }
  int m, n;
  while (cin >> m && m) {
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; i++)
      if (ham[i])
        ans++;
    cout << ans << endl;
  }
  return 0;
} | 
	replace | 12 | 13 | 12 | 13 | 
	0 | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
using namespace std;
int dp[1000001] = {0};
int main() {
  int k, m, n;
  dp[1] = 1;
  for (int i = 1; i <= 500000; i++) {
    dp[i * 2] |= 1;
    dp[i * 3] |= 1;
    dp[i * 5] |= 1;
  }
  for (int i = 1; i <= 1000000; i++) {
    dp[i] += dp[i - 1];
  }
  while (cin >> m && m) {
    cin >> n;
    cout << dp[n] - dp[m - 1] << endl;
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
int dp[1000001] = {0};
int main() {
  int a = 1, n, m;
  for (int i = 0; a <= 1000000; i++) {
    int b = 1;
    for (int j = 0; a * b <= 1000000; j++) {
      int c = 1;
      for (int k = 0; a * b * c <= 1000000; k++) {
        dp[a * b * c] = true;
        c *= 5;
      }
      b *= 3;
    }
    a *= 2;
  }
  for (int i = 1; i <= 1000000; i++) {
    dp[i] += dp[i - 1];
  }
  while (cin >> m && m) {
    cin >> n;
    cout << dp[n] - dp[m - 1] << endl;
  }
  return 0;
} | 
	replace | 5 | 11 | 5 | 17 | 
	-11 | |
| 
	p00162 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
using namespace std;
/*
bool sw[1000001];
int i;
void sws(int k){
        if(k==1){
                sw[i]=true;
                return;
        }
        if(k%2==0) sws(k/2);
        else if(k%3==0) sws(k/3);
        else if(k%5==0) sws(k/5);
        return;
}
*/
// korenisuru
int dp[1000001];
int f(int n) {
  if (~dp[n])
    return dp[n];
  int ans = 0;
  if (n % 2 == 0)
    ans |= f(n / 2);
  else if (n % 3 == 0)
    ans |= f(n / 3);
  else if (n % 5 == 0)
    ans |= f(n / 5);
  return dp[n] = ans;
}
int main() {
  int m, n;
  for (int i = 0; i <= 1000000; i++)
    dp[i] = -1;
  dp[1] = 1;
  for (int i = 1000000; i >= 1; i++)
    f(i);
  while (cin >> m && m) {
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; i++)
      ans += dp[i];
    cout << ans << endl;
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
/*
bool sw[1000001];
int i;
void sws(int k){
        if(k==1){
                sw[i]=true;
                return;
        }
        if(k%2==0) sws(k/2);
        else if(k%3==0) sws(k/3);
        else if(k%5==0) sws(k/5);
        return;
}
*/
// korenisuru
int dp[1000001];
int f(int n) {
  if (~dp[n])
    return dp[n];
  int ans = 0;
  if (n % 2 == 0)
    ans |= f(n / 2);
  else if (n % 3 == 0)
    ans |= f(n / 3);
  else if (n % 5 == 0)
    ans |= f(n / 5);
  return dp[n] = ans;
}
int main() {
  int m, n;
  for (int i = 0; i <= 1000000; i++)
    dp[i] = -1;
  dp[1] = 1;
  for (int i = 1000000; i >= 1; i--)
    f(i);
  while (cin >> m && m) {
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; i++)
      ans += dp[i];
    cout << ans << endl;
  }
  return 0;
} | 
	replace | 37 | 38 | 37 | 38 | 
	-11 | |
| 
	p00163 | 
	C++ | 
	Runtime Error | 
	#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
vector<vector<int>> money{
    {0, 300, 500, 600, 700, 1350, 1650},
    {0, 0, 350, 450, 600, 1150, 1500},
    {0, 0, 0, 250, 400, 1000, 1350},
    {0, 0, 0, 0, 250, 850, 1300},
    {0, 0, 0, 0, 0, 600, 1150},
    {0, 0, 0, 0, 0, 0, 500},
    {0, 0, 0, 0, 0, 0, 0},
};
vector<int> dis{6, 7, 5, 5, 20, 15};
int main() {
  while (1) {
    int d;
    cin >> d;
    int start, goal;
    {
      int h, m;
      cin >> h >> m;
      start = h * 60 + m;
    }
    int a;
    cin >> a;
    {
      int h, m;
      cin >> h >> m;
      goal = h * 60 + m;
    }
    d--;
    a--;
    if (d < a)
      swap(d, a);
    int cost = money[a][d];
    cost /= 50;
    int distance = 0;
    for (int i = a; i < d; ++i) {
      distance += dis[i];
    }
    bool flag = false;
    if ((start <= 1170 || 1050 <= goal) && !(start < 1050 && 1170 < goal))
      flag = true;
    if (distance <= 40 && flag)
      cost = (cost + 1) / 2;
    cost *= 50;
    cout << cost << endl;
  }
  return 0;
} | 
	#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
vector<vector<int>> money{
    {0, 300, 500, 600, 700, 1350, 1650},
    {0, 0, 350, 450, 600, 1150, 1500},
    {0, 0, 0, 250, 400, 1000, 1350},
    {0, 0, 0, 0, 250, 850, 1300},
    {0, 0, 0, 0, 0, 600, 1150},
    {0, 0, 0, 0, 0, 0, 500},
    {0, 0, 0, 0, 0, 0, 0},
};
vector<int> dis{6, 7, 5, 5, 20, 15};
int main() {
  while (1) {
    int d;
    cin >> d;
    if (!d)
      break;
    int start, goal;
    {
      int h, m;
      cin >> h >> m;
      start = h * 60 + m;
    }
    int a;
    cin >> a;
    {
      int h, m;
      cin >> h >> m;
      goal = h * 60 + m;
    }
    d--;
    a--;
    if (d < a)
      swap(d, a);
    int cost = money[a][d];
    cost /= 50;
    int distance = 0;
    for (int i = a; i < d; ++i) {
      distance += dis[i];
    }
    bool flag = false;
    if ((start <= 1170 || 1050 <= goal) && !(start < 1050 && 1170 < goal))
      flag = true;
    if (distance <= 40 && flag)
      cost = (cost + 1) / 2;
    cost *= 50;
    cout << cost << endl;
  }
  return 0;
} | 
	insert | 24 | 24 | 24 | 26 | 
	-11 | |
| 
	p00164 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int main() {
  int n, a[4], s, t, p;
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    s = 32;
    p = 0;
    while (s > 0) {
      t = (s - 1) % 5;
      s -= t;
      cout << s << endl;
      s -= a[p % n];
      p++;
      if (s < 0) {
        s = 0;
      }
      cout << s << endl;
    }
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
int main() {
  int n, a[26], s, t, p;
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    s = 32;
    p = 0;
    while (s > 0) {
      t = (s - 1) % 5;
      s -= t;
      cout << s << endl;
      s -= a[p % n];
      p++;
      if (s < 0) {
        s = 0;
      }
      cout << s << endl;
    }
  }
  return 0;
} | 
	replace | 5 | 6 | 5 | 6 | 
	TLE | |
| 
	p00164 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
#include <string>
using namespace std;
int main() {
  int m, n[100];
  while (true) {
    cin >> m;
    if (m == 0)
      break;
    for (int i = 0; i < m; i++)
      cin >> n[i];
    int ans = 31;
    int count = 0;
    cout << "31" << endl;
    while (true) {
      if (ans < n[count]) {
        cout << "0" << endl;
        break;
      }
      ans -= n[count];
      cout << ans << endl;
      ans -= (ans - 1) % 5;
      cout << ans << endl;
      count++;
      count %= m;
    }
  }
  return 0;
} | 
	#include <iostream>
#include <string>
using namespace std;
int main() {
  int m, n[100];
  while (true) {
    cin >> m;
    if (m == 0)
      break;
    for (int i = 0; i < m; i++)
      cin >> n[i];
    int ans = 31;
    int count = 0;
    cout << "31" << endl;
    while (true) {
      if (ans <= n[count]) {
        cout << "0" << endl;
        break;
      }
      ans -= n[count];
      cout << ans << endl;
      ans -= (ans - 1) % 5;
      cout << ans << endl;
      count++;
      count %= m;
    }
  }
  return 0;
} | 
	replace | 15 | 16 | 15 | 16 | 
	TLE | |
| 
	p00164 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
void loop(int remain, int *jiro_rule, int rule_size, int cur) {
  remain -= (remain - 1) % 5;
  cout << remain << endl;
  if (remain == 0)
    return;
  if (remain < *(jiro_rule + cur)) {
    cout << 0 << endl;
    return;
  }
  remain -= *(jiro_rule + cur);
  cout << remain << endl;
  cur++;
  if (cur == rule_size)
    cur = 0;
  loop(remain, jiro_rule, rule_size, cur);
}
int main() {
  int i;
  while (cin >> i) {
    if (i == 0)
      break;
    int a[i];
    for (int p = 0; p < i; p++) {
      cin >> a[p];
    }
    loop(32, a, i, 0);
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
void loop(int remain, int *jiro_rule, int rule_size, int cur) {
  remain -= (remain - 1) % 5;
  cout << remain << endl;
  if (remain == 0)
    return;
  if (remain <= *(jiro_rule + cur)) {
    cout << 0 << endl;
    return;
  }
  remain -= *(jiro_rule + cur);
  cout << remain << endl;
  cur++;
  if (cur == rule_size)
    cur = 0;
  loop(remain, jiro_rule, rule_size, cur);
}
int main() {
  int i;
  while (cin >> i) {
    if (i == 0)
      break;
    int a[i];
    for (int p = 0; p < i; p++) {
      cin >> a[p];
    }
    loop(32, a, i, 0);
  }
  return 0;
} | 
	replace | 9 | 10 | 9 | 10 | 
	TLE | |
| 
	p00164 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
using namespace std;
int main() {
  int k;
  while (cin >> k) {
    int n = 32, a[30];
    for (int i = 0; i < k; i++)
      cin >> a[i];
    for (int i = 0; n; i++) {
      int p;
      p = (n - 1) % 5;
      n -= p;
      cout << n << endl;
      p = a[i % k];
      n -= p;
      if (n < 0)
        n = 0;
      cout << n << endl;
    }
  }
} | 
	#include <iostream>
using namespace std;
int main() {
  int k;
  while (cin >> k, k) {
    int n = 32, a[30];
    for (int i = 0; i < k; i++)
      cin >> a[i];
    for (int i = 0; n; i++) {
      int p;
      p = (n - 1) % 5;
      n -= p;
      cout << n << endl;
      p = a[i % k];
      n -= p;
      if (n < 0)
        n = 0;
      cout << n << endl;
    }
  }
} | 
	replace | 4 | 5 | 4 | 5 | 
	-8 | |
| 
	p00164 | 
	C++ | 
	Time Limit Exceeded | 
	#include <stdio.h>
int main() {
  int n[5] = {};
  int N;
  int r = 0;
  while (1) {
    scanf("%d", &N);
    if (N == 0)
      break;
    for (int i = 0; i < N; i++)
      scanf("%d", &n[i]);
    int P = 32;
    int j = 0;
    while (1) {
      if (P <= 0)
        break;
      P -= (P - 1) % 5;
      printf("%d\n", P);
      if (P == 1)
        break;
      P -= n[j];
      printf("%d\n", P);
      j++;
      j = j % N;
    }
    P = 0;
    printf("%d\n", P);
  }
  return 0;
} | 
	#include <stdio.h>
int main() {
  int n[30] = {};
  int N;
  int r = 0;
  while (1) {
    scanf("%d", &N);
    if (N == 0)
      break;
    for (int i = 0; i < N; i++)
      scanf("%d", &n[i]);
    int P = 32;
    int j = 0;
    while (1) {
      if (P <= 0)
        break;
      P -= (P - 1) % 5;
      printf("%d\n", P);
      if (P == 1)
        break;
      P -= n[j];
      printf("%d\n", P);
      j++;
      j = j % N;
    }
    P = 0;
    printf("%d\n", P);
  }
  return 0;
} | 
	replace | 4 | 5 | 4 | 5 | 
	TLE | |
| 
	p00164 | 
	C++ | 
	Runtime Error | 
	#include <iostream>
using namespace std;
int main() {
  int n, v[26];
  int w[7] = {31, 26, 21, 16, 11, 6, 1};
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    cout << 31 << endl;
    for (int i = 0; i < 6; i++) {
      cout << w[i] - v[i % n] << endl;
      cout << w[i + 1] << endl;
    }
    cout << 0 << endl;
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
int main() {
  int n, v[26];
  int w[7] = {31, 26, 21, 16, 11, 6, 1};
  while (cin >> n) {
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    cout << 31 << endl;
    for (int i = 0; i < 6; i++) {
      cout << w[i] - v[i % n] << endl;
      cout << w[i + 1] << endl;
    }
    cout << 0 << endl;
  }
  return 0;
} | 
	insert | 9 | 9 | 9 | 11 | 
	-8 | |
| 
	p00164 | 
	C++ | 
	Time Limit Exceeded | 
	#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int len;
  while (scanf("%d", &len), len) {
    int a[4];
    for (int i = 0; i < len; i++) {
      scanf("%d", &a[i]);
    }
    int n = 32;
    for (int i = 0, j = 0;; i++) {
      if (i % 2 == 0) {
        n -= (n - 1) % 5;
      } else {
        n -= a[j % len];
        j++;
      }
      if (n <= 0) {
        n = 0;
        printf("%d\n", n);
        break;
      }
      printf("%d\n", n);
    }
  }
  return (0);
} | 
	#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int len;
  while (scanf("%d", &len), len) {
    int a[25];
    for (int i = 0; i < len; i++) {
      scanf("%d", &a[i]);
    }
    int n = 32;
    for (int i = 0, j = 0;; i++) {
      if (i % 2 == 0) {
        n -= (n - 1) % 5;
      } else {
        n -= a[j % len];
        j++;
      }
      if (n <= 0) {
        n = 0;
        printf("%d\n", n);
        break;
      }
      printf("%d\n", n);
    }
  }
  return (0);
} | 
	replace | 8 | 9 | 8 | 9 | 
	TLE | |
| 
	p00165 | 
	C++ | 
	Time Limit Exceeded | 
	#include <algorithm>
#include <iostream>
using namespace std;
const int MAX = 999984;
bool isPrime[MAX];
void createIsPrime() {
  fill_n(isPrime, MAX, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 4; i < MAX; i += 2) {
    isPrime[i] = false;
  }
  for (int i = 3; i * i <= MAX; i += 2) {
    if (isPrime[i]) {
      for (int j = i * 2; j < MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
}
int main() {
  createIsPrime();
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    int bill = 0;
    while (n--) {
      int p, m;
      cin >> p >> m;
      int prime = 0;
      for (int i = max(p - m, 2), end = min(p + m, MAX - 1); i <= end; i++) {
        if (isPrime[i]) {
          prime++;
        }
      }
      if (prime > 0) {
        bill += prime - 1;
      } else {
        bill--;
      }
    }
    cout << bill << endl;
  }
} | 
	#include <algorithm>
#include <iostream>
using namespace std;
const int MAX = 999984;
bool isPrime[MAX];
void createIsPrime() {
  fill_n(isPrime, MAX, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 4; i < MAX; i += 2) {
    isPrime[i] = false;
  }
  for (int i = 3; i * i <= MAX; i += 2) {
    if (isPrime[i]) {
      for (int j = i * 2; j < MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
}
int main() {
  createIsPrime();
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    int bill = 0;
    while (n--) {
      int p, m;
      cin >> p >> m;
      int prime = 0, start = p - m;
      if ((p - m) % 2 == 0) {
        start++;
      }
      if (p - m <= 2) {
        bill++;
      }
      for (int i = max(start, 3), end = min(p + m, MAX - 1); i <= end; i += 2) {
        if (isPrime[i]) {
          prime++;
        }
      }
      if (prime > 0) {
        bill += prime - 1;
      } else {
        bill--;
      }
    }
    cout << bill << endl;
  }
} | 
	replace | 35 | 37 | 35 | 43 | 
	TLE | |
| 
	p00166 | 
	C++ | 
	Time Limit Exceeded | 
	#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP((i), 0, (n))
#define RREP(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define rrep(i, n) RREP(i, n, 0)
#define each(it, X)                                                            \
  for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define all(v) ((v).begin(), (v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> pr;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
const int INF = 1070000000ll;
const int mod = 1000000007ll;
const double EPS = 1e-9;
const double PI = 3.14159265;
double getS(int x) {
  int d = 360;
  double S = 0;
  rep(i, x - 1) {
    int z;
    cin >> z;
    d -= z;
    S += fabs(sin(1.0 * z / 180 * PI));
  }
  S += fabs(sin(1.0 * d / 180 * PI));
  return S;
}
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  double S[2];
  int x;
  while (cin >> x, x) {
    S[0] = getS(x);
    scanf("%d", &x);
    S[1] = getS(x);
    if (fabs(S[0] - S[1]) < EPS)
      cout << 0 << endl;
    else if (S[0] > S[1])
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
} | 
	#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP((i), 0, (n))
#define RREP(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define rrep(i, n) RREP(i, n, 0)
#define each(it, X)                                                            \
  for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define all(v) ((v).begin(), (v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> pr;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
const int INF = 1070000000ll;
const int mod = 1000000007ll;
const double EPS = 1e-9;
const double PI = 3.14159265;
double getS(int x) {
  int d = 360;
  double S = 0;
  rep(i, x - 1) {
    int z;
    cin >> z;
    d -= z;
    S += fabs(sin(1.0 * z / 180 * PI));
  }
  S += fabs(sin(1.0 * d / 180 * PI));
  return S;
}
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  double S[2];
  int x;
  while (cin >> x, x) {
    S[0] = getS(x);
    cin >> x;
    S[1] = getS(x);
    if (fabs(S[0] - S[1]) < EPS)
      cout << 0 << endl;
    else if (S[0] > S[1])
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
} | 
	replace | 41 | 42 | 41 | 42 | 
	TLE | |
| 
	p00167 | 
	C++ | 
	Time Limit Exceeded | 
	#include <cstring>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int N = 100;
int bit[N + 10];
int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i <= N) {
    bit[i] += x;
    i += i & -i;
  }
}
vector<int> compress(vector<int> v) {
  map<int, int> mp;
  for (int i = 0; i < v.size(); i++)
    mp[i] = 0;
  int id = 1;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    it->second = id++;
  }
  for (int i = 0; i < v.size(); i++)
    v[i] = mp[v[i]];
  return v;
}
int main() {
  int n;
  while (cin >> n && n) {
    memset(bit, 0, sizeof(bit));
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    v = compress(v);
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      ans += sum(v[i] - 1);
      add(v[i], 1);
    }
    cout << ans << endl;
  }
  return 0;
} | 
	#include <cstring>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int N = 100;
int bit[N + 10];
int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i <= N) {
    bit[i] += x;
    i += i & -i;
  }
}
vector<int> compress(vector<int> v) {
  map<int, int> mp;
  for (int i = 0; i < v.size(); i++)
    mp[v[i]] = 0;
  int id = 1;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    it->second = id++;
  }
  for (int i = 0; i < v.size(); i++)
    v[i] = mp[v[i]];
  return v;
}
int main() {
  int n;
  while (cin >> n && n) {
    memset(bit, 0, sizeof(bit));
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    v = compress(v);
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      ans += sum(v[i] - 1);
      add(v[i], 1);
    }
    cout << ans << endl;
  }
  return 0;
} | 
	replace | 28 | 29 | 28 | 29 | 
	TLE | |
| 
	p00167 | 
	C++ | 
	Runtime Error | 
	#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX 10000010
int main() {
  int n;
  int list[MAX];
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> list[i];
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - i - 1; j++) {
        if (list[j] > list[j + 1]) {
          swap(list[j], list[j + 1]);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
} | 
	#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX 110
int main() {
  int n;
  int list[MAX];
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> list[i];
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - i - 1; j++) {
        if (list[j] > list[j + 1]) {
          swap(list[j], list[j + 1]);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
} | 
	replace | 4 | 5 | 4 | 5 | 
	-11 | |
| 
	p00167 | 
	C++ | 
	Time Limit Exceeded | 
	#include <stdio.h>
int n[1000001] = {};
int main() {
  int N;
  int c = 0;
  while (1) {
    scanf("%d", &N);
    int c = 0;
    for (int i = 0; i < N; i++) {
      scanf("%d", &n[i]);
    }
    for (int i = 0; i < N; i++)
      for (int j = N - 1; j > i; j--) {
        if (n[j] < n[j - 1]) {
          int T = n[j];
          n[j] = n[j - 1];
          n[j - 1] = T;
          c++;
        }
      }
    printf("%d\n", c);
    for (int i = 0; i < N; i++)
      n[i] = 0;
  }
  return 0;
} | 
	#include <stdio.h>
int n[1000001] = {};
int main() {
  int N;
  int c = 0;
  while (1) {
    scanf("%d", &N);
    if (N == 0)
      break;
    int c = 0;
    for (int i = 0; i < N; i++) {
      scanf("%d", &n[i]);
    }
    for (int i = 0; i < N; i++)
      for (int j = N - 1; j > i; j--) {
        if (n[j] < n[j - 1]) {
          int T = n[j];
          n[j] = n[j - 1];
          n[j - 1] = T;
          c++;
        }
      }
    printf("%d\n", c);
    for (int i = 0; i < N; i++)
      n[i] = 0;
  }
  return 0;
} | 
	replace | 9 | 10 | 9 | 11 | 
	TLE | |
| 
	p00168 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int main() {
  while (1) {
    int dp[31] = {1, 1, 2, 4};
    int n;
    cin >> n;
    for (int i = 4; i <= n; ++i) {
      dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    }
    cout << ((dp[n] - 1) / 3650) + 1 << endl;
  }
} | 
	#include <iostream>
using namespace std;
int main() {
  while (1) {
    int dp[31] = {1, 1, 2, 4};
    int n;
    cin >> n;
    if (!n)
      return 0;
    for (int i = 4; i <= n; ++i) {
      dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    }
    cout << ((dp[n] - 1) / 3650) + 1 << endl;
  }
} | 
	insert | 7 | 7 | 7 | 9 | 
	TLE | |
| 
	p00168 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int n;
int memo[31];
int dfs(int num) {
  int sum = 0;
  if (memo[num] != -1) {
    return memo[num];
  }
  if (num == n) {
    return 1;
  }
  if (num < n)
    sum += dfs(num + 1);
  if (num < n)
    sum += dfs(num + 2);
  if (num < n)
    sum += dfs(num + 3);
  memo[num] = sum;
  return sum;
}
int main() {
  while (1) {
    cin >> n;
    for (int i = 0; i <= 31; i++) {
      memo[i] = -1;
    }
    if (n == 0) {
      break;
    }
    cout << dfs(0) / 10 / 365 + 1 << endl;
  }
} | 
	#include <iostream>
using namespace std;
int n;
int memo[366];
int dfs(int num) {
  int sum = 0;
  if (memo[num] != -1) {
    return memo[num];
  }
  if (num == n) {
    return 1;
  }
  if (num < n)
    sum += dfs(num + 1);
  if (num < n)
    sum += dfs(num + 2);
  if (num < n)
    sum += dfs(num + 3);
  memo[num] = sum;
  return sum;
}
int main() {
  while (1) {
    cin >> n;
    for (int i = 0; i <= 31; i++) {
      memo[i] = -1;
    }
    if (n == 0) {
      break;
    }
    cout << dfs(0) / 10 / 365 + 1 << endl;
  }
} | 
	replace | 5 | 6 | 5 | 6 | 
	TLE | |
| 
	p00169 | 
	C++ | 
	Runtime Error | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (getline(cin, s), s != "0") {
    stringstream ss(s);
    int x = 0, i, ans, k;
    int si = 0;
    vector<int> v;
    v.clear();
    v.push_back(0);
    while (ss >> x) {
      si = v.size();
      vector<int> n;
      for (i = 0; i < si; i++) {
        if (x == 1) {
          k = v[i];
          n.push_back(k + 11);
          v[i]++;
        } else if (x > 10) {
          v[i] += 10;
        } else {
          v[i] += x;
        }
      }
      for (i = 0; i < n.size(); i++)
        v.push_back(n[i]);
      n.clear();
    }
    sort(v.begin(), v.end());
    ans = 0;
    for (i = 0; i < v.size(); i++) {
      if (v[i] <= 21)
        ans = v[i];
    }
    cout << ans << endl;
    s = "";
  }
  return 0;
} | 
	#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (getline(cin, s), s != "0") {
    stringstream ss(s);
    int x = 0, i, ans, k;
    int si = 0;
    vector<int> v;
    v.clear();
    v.push_back(0);
    while (ss >> x) {
      si = v.size();
      vector<int> n;
      for (i = 0; i < si; i++) {
        if (x == 1) {
          k = v[i];
          n.push_back(k + 11);
          v[i]++;
        } else if (x > 10) {
          v[i] += 10;
        } else {
          v[i] += x;
        }
      }
      for (i = 0; i < n.size(); i++)
        v.push_back(n[i]);
      n.clear();
      sort(v.begin(), v.end());
      v.erase(unique(v.begin(), v.end()), v.end());
      v.erase(lower_bound(v.begin(), v.end(), 22), v.end());
    }
    sort(v.begin(), v.end());
    ans = 0;
    for (i = 0; i < v.size(); i++) {
      if (v[i] <= 21)
        ans = v[i];
    }
    cout << ans << endl;
    s = "";
  }
  return 0;
} | 
	insert | 30 | 30 | 30 | 34 | 
	0 | |
| 
	p00169 | 
	C++ | 
	Time Limit Exceeded | 
	#include <iostream>
using namespace std;
int rec(int sum, int one) {
  if (one == 0 && sum > 21)
    return -1;
  else if (one == 0 && sum <= 21)
    return sum;
  int res = rec(sum + 1, one - 1);
  res = max(res, rec(sum + 11, one - 1));
  return res;
}
bool solve(string &s) {
  int sum = 0, one = 0;
  int index = 0;
  s += " ";
  while (index < s.size()) {
    int num = 0;
    while (index < s.size()) {
      if ('0' <= s[index] && s[index] <= '9') {
        num *= 10;
        num += (int)(s[index] - '0');
        index++;
      } else
        break;
    }
    if (num == 1)
      one++;
    else if (num / 10 == 1)
      sum += 10;
    else
      sum += num;
    index++;
  }
  if (sum == 0 && one == 0)
    return false;
  if (sum > 21) {
    cout << 0 << endl;
    return true;
  } else if (one == 0) {
    cout << sum << endl;
    return true;
  } else {
    int ans = rec(sum, one);
    if (ans >= 0)
      cout << ans << endl;
    else
      cout << 0 << endl;
    return true;
  }
}
int main() {
  string s;
  while (true) {
    getline(cin, s);
    if (!solve(s))
      break;
  }
  return 0;
} | 
	#include <iostream>
using namespace std;
int rec(int sum, int one) {
  if (sum > 21)
    return -1;
  else if (one == 0 && sum > 21)
    return -1;
  else if (one == 0 && sum <= 21)
    return sum;
  int res = rec(sum + 1, one - 1);
  res = max(res, rec(sum + 11, one - 1));
  return res;
}
bool solve(string &s) {
  int sum = 0, one = 0;
  int index = 0;
  s += " ";
  while (index < s.size()) {
    int num = 0;
    while (index < s.size()) {
      if ('0' <= s[index] && s[index] <= '9') {
        num *= 10;
        num += (int)(s[index] - '0');
        index++;
      } else
        break;
    }
    if (num == 1)
      one++;
    else if (num / 10 == 1)
      sum += 10;
    else
      sum += num;
    index++;
  }
  if (sum == 0 && one == 0)
    return false;
  if (sum > 21) {
    cout << 0 << endl;
    return true;
  } else if (one == 0) {
    cout << sum << endl;
    return true;
  } else {
    int ans = rec(sum, one);
    if (ans >= 0)
      cout << ans << endl;
    else
      cout << 0 << endl;
    return true;
  }
}
int main() {
  string s;
  while (true) {
    getline(cin, s);
    if (!solve(s))
      break;
  }
  return 0;
} | 
	replace | 5 | 6 | 5 | 8 | 
	TLE | |
| 
	p00169 | 
	C++ | 
	Time Limit Exceeded | 
	#include <bits/stdc++.h>
using namespace std;
int rec(int sum, const vector<int> &v, int k) {
  if (k == v.size())
    return sum <= 21 ? sum : 0;
  if (v[k] == 1)
    return max(rec(sum + 1, v, k + 1), rec(sum + 11, v, k + 1));
  else
    return rec(sum + v[k], v, k + 1);
}
int main() {
  string s;
  while (getline(cin, s) && s != "0") {
    stringstream ss(s);
    int a;
    vector<int> v;
    while (ss >> a) {
      v.push_back(min(a, 10));
    }
    cout << rec(0, v, 0) << endl;
  }
  return 0;
} | 
	#include <bits/stdc++.h>
using namespace std;
int rec(int sum, const vector<int> &v, int k) {
  if (v.size() > 21)
    return 0;
  if (k == v.size())
    return sum <= 21 ? sum : 0;
  if (v[k] == 1)
    return max(rec(sum + 1, v, k + 1), rec(sum + 11, v, k + 1));
  else
    return rec(sum + v[k], v, k + 1);
}
int main() {
  string s;
  while (getline(cin, s) && s != "0") {
    stringstream ss(s);
    int a;
    vector<int> v;
    while (ss >> a) {
      v.push_back(min(a, 10));
    }
    cout << rec(0, v, 0) << endl;
  }
  return 0;
} | 
	insert | 4 | 4 | 4 | 6 | 
	TLE | |
| 
	p00169 | 
	C++ | 
	Memory Limit Exceeded | 
	#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
  string S;
  while (getline(cin, S)) {
    priority_queue<int, vector<int>, greater<int>> pq[2];
    pq[0].push(0);
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
      if (i == 0 || S[i] == ' ') {
        int n = stoi(&S[i]);
        if (n == 0)
          return 0;
        while (!pq[cnt & 1].empty()) {
          int pq_c = pq[cnt & 1].top();
          pq[cnt & 1].pop();
          if (n == 1)
            pq[(cnt + 1) & 1].push(pq_c + 1), pq[(cnt + 1) & 1].push(pq_c + 11);
          else if (n < 10)
            pq[(cnt + 1) & 1].push(pq_c + n);
          else
            pq[(cnt + 1) & 1].push(pq_c + 10);
        }
        cnt++;
      }
    }
    int ans = 0;
    while (!pq[cnt & 1].empty()) {
      if (pq[cnt & 1].top() <= 21)
        ans = max(ans, pq[cnt & 1].top());
      pq[cnt & 1].pop();
    }
    printf("%d\n", ans);
  }
  return 0;
} | 
	#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
  string S;
  while (getline(cin, S)) {
    priority_queue<int, vector<int>, greater<int>> pq[2];
    pq[0].push(0);
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
      if (i == 0 || S[i] == ' ') {
        int n = stoi(&S[i]);
        if (n == 0)
          return 0;
        while (!pq[cnt & 1].empty()) {
          int pq_c = pq[cnt & 1].top();
          pq[cnt & 1].pop();
          if (pq_c > 21)
            continue;
          if (n == 1)
            pq[(cnt + 1) & 1].push(pq_c + 1), pq[(cnt + 1) & 1].push(pq_c + 11);
          else if (n < 10)
            pq[(cnt + 1) & 1].push(pq_c + n);
          else
            pq[(cnt + 1) & 1].push(pq_c + 10);
        }
        cnt++;
      }
    }
    int ans = 0;
    while (!pq[cnt & 1].empty()) {
      if (pq[cnt & 1].top() <= 21)
        ans = max(ans, pq[cnt & 1].top());
      pq[cnt & 1].pop();
    }
    printf("%d\n", ans);
  }
  return 0;
} | 
	insert | 30 | 30 | 30 | 32 | 
	MLE | |
| 
	p00169 | 
	C++ | 
	Runtime Error | 
	#include <bits/stdc++.h>
using namespace std;
int power(int n) {
  int num = 1;
  for (int i = 0; i < n; i++)
    num *= 10;
  return num;
}
int serch(int sum, int n) {
  if (sum > 21)
    return 0;
  else if (n == 0)
    return sum;
  else
    return max(serch(sum + 11, n - 1), serch(sum + 1, n - 1));
}
int main() {
  string str;
  while (getline(cin, str)) {
    if (str[0] == '0')
      break;
    int card[20] = {}, co = 0, point = 0;
    for (int i = 0;; i++) {
      if (str[i] == ' ' || str[i] == '\0') {
        for (int j = point; j < i; j++)
          card[co] += (str[j] - '0') * power(i - 1 - j);
        co++;
        point = i + 1;
      }
      if (str[i] == '\0')
        break;
    }
    int cou = 0, sum = 0;
    for (int i = 0; i < co; i++) {
      if (card[i] == 1)
        cou++;
      else if (card[i] < 10)
        sum += card[i];
      else
        sum += 10;
    }
    cout << serch(sum, cou) << endl;
  }
} | 
	#include <bits/stdc++.h>
using namespace std;
int power(int n) {
  int num = 1;
  for (int i = 0; i < n; i++)
    num *= 10;
  return num;
}
int serch(int sum, int n) {
  if (sum > 21)
    return 0;
  else if (n == 0)
    return sum;
  else
    return max(serch(sum + 11, n - 1), serch(sum + 1, n - 1));
}
int main() {
  string str;
  while (getline(cin, str)) {
    if (str[0] == '0')
      break;
    int card[1000] = {}, co = 0, point = 0;
    for (int i = 0;; i++) {
      if (str[i] == ' ' || str[i] == '\0') {
        for (int j = point; j < i; j++)
          card[co] += (str[j] - '0') * power(i - 1 - j);
        co++;
        point = i + 1;
      }
      if (str[i] == '\0')
        break;
    }
    int cou = 0, sum = 0;
    for (int i = 0; i < co; i++) {
      if (card[i] == 1)
        cou++;
      else if (card[i] < 10)
        sum += card[i];
      else
        sum += 10;
    }
    cout << serch(sum, cou) << endl;
  }
} | 
	replace | 21 | 22 | 21 | 22 | 
	0 | 
			Subsets and Splits
				
	
				
			
				
No community queries yet
The top public SQL queries from the community will appear here once available.
