alexjercan/bugnet huggingface dataset:
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

#define loop(i, n) for (int i = 1; i <= n; i++)
int n;
int taro[202];
int hana[202];

int has(int *a) {
  loop(i, n * 2) if (a[i]) return 1;
  return 0;
}
int count(int *a) {
  int c = 0;
  loop(i, n * 2) if (a[i]) c++;
  return c;
}

int solve() {
  int temp;
  loop(i, n * 2) taro[i] = 0, hana[i] = 1;
  loop(i, n) cin >> temp, taro[temp] = 1, hana[temp] = 0;
  int taro_turn = 0;
  while (has(taro) && has(hana)) {
    taro_turn ^= 1;
    for (int i = 1; i <= n * 2; i++) {
      if (taro_turn) {
        while (i <= n * 2 && !taro[i])
          i++;
        if (i <= n * 2) {
          taro[i] = 0;
          taro_turn = 0;
        } else
          break;
      } else {
        while (i <= n * 2 && !hana[i])
          i++;
        if (i <= n * 2) {
          hana[i] = 0;
          taro_turn = 1;
        } else
          break;
      }
    }
  }
  cout << count(hana) << endl;
  cout << count(taro) << endl;
  return 0;
}

int main() {
  cin >> n;
  while (n) {
    solve();
    cin >> n;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

#define loop(i, n) for (int i = 1; i <= n; i++)
int n;
int taro[202];
int hana[202];

int has(int *a) {
  loop(i, n * 2) if (a[i] != 0) return 1;
  return 0;
}
int count(int *a) {
  int c = 0;
  loop(i, n * 2) if (a[i] != 0) c++;
  return c;
}

int solve() {
  int temp;
  loop(i, n * 2) taro[i] = 0, hana[i] = 1;
  loop(i, n) cin >> temp, taro[temp] = 1, hana[temp] = 0;
  while (has(taro) && has(hana)) {
    for (int i = 1; i < n * 2; i++) {
      if (!taro[i])
        continue;
      taro[i] = 0;
      for (int j = i + 1; j < n * 2; j++) {
        if (!hana[j])
          continue;
        hana[j] = 0;
        i = j;
        break;
      }
    }
  }
  cout << count(hana) << endl;
  cout << count(taro) << endl;
}

int main() {
  while (cin >> n) {
    solve();
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

bool cards[2][201];
int N, field, rest[2];
int main() {
  while (true) {
    cin >> N;
    if (!N)
      break;
    for (int i = 0; i <= N * 2; i++)
      cards[0][i] = 0;
    for (int i = 0; i < N; i++) {
      int tmp;
      cin >> tmp;
      cards[0][tmp] = 1;
    }
    for (int i = 0; i <= N * 2; i++) {
      if (!cards[0][i])
        cards[1][i] = 1;
      else
        cards[1][i] = 0;
    }
    rest[0] = rest[1] = N;

    field = 0;
    int turn = 0;
    while (rest[0] > 0 && rest[1] > 0) {
      bool b = true;
      for (int i = 1; i <= 2 * N; i++) {
        if (cards[turn][i] && i > field) {
          cards[turn][i] = 0;
          rest[turn]--;
          field = i;
          b = false;
          break;
        }
      }
      if (b)
        field = 0;
      turn = (turn + 1) % 2;
    }
    cout << rest[1] << endl << rest[0] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

const int TARO = 1;
const int HANAKO = 0;

int main(void) {
  while (true) {
    int m, n, k, f = 0;
    int pn[2];
    int pm[2];
    int card[100] = {0};
    scanf("%d", &n);
    if (!n)
      break;
    pn[TARO] = pn[HANAKO] = n;
    for (int i = 0; i < n; i++) {
      int j;
      scanf("%d", &j);
      card[j] = TARO;
      if (i == n - 1)
        pm[TARO] = j;
    }
    for (int i = n * 2; i >= 0; i--) {
      if (card[i] != TARO) {
        pm[HANAKO] = i;
        break;
      }
    }

    while (true) {
      for (int player = 1; player >= 0; player--) {
        if (!pn[0] || !pn[1])
          goto gameend;
        /*
          cout << "Player:" << player << " field:" << f << endl;
          cout << "These cards that is held by player" << endl;
          for(int j = 1; j <= 2 * n; j++){
          if(card[j] == player)
          cout << j << endl;
          }
        */
        if (f >= pm[player]) {
          f = 0;
          continue;
        }
        bool flag = true;
        for (int j = f + 1; j <= 2 * n; j++) {
          if (card[j] == player) {
            card[j] = -1;
            // cout << "put:" << j << endl;
            f = j;
            if (j == pm[player]) {
              for (int i = j; i >= 0; i--) {
                if (card[i] == HANAKO) {
                  pm[HANAKO] = i;
                  break;
                }
              }
            }
            pn[player]--;
            flag = false;
            break;
          }
        }
        if (flag)
          f = 0;
      }
    }
  gameend:
    printf("%d\\n%d\\n", pn[HANAKO], pn[TARO]);
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int c[201] = {0}, ba = 0, n, i, a, t = 0, o;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 1; i <= n * 2; i++) {
      c[i] = 0;
    }
    ba = 0;
    t = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a);
      c[a] = 1;
    }
    while (1) {
      if (ba == 0) {
        for (i = 1; i <= n * 2; i++) {
          if (c[i] == (t + 1) % 2) {
            ba = i;
            c[i] = 2;
            break;
          }
        }
      } else {
        o = 0;
        for (i = 1; i <= n * 2; i++) {
          if (c[i] == (t + 1) % 2 && ba < i) {
            o = 1;
            ba = i;
            c[i] = 2;
            break;
          }
        }
        if (o == 0) {
          ba = 0;
        }
      }
      o = 0;
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == 1) {
          o = 2;
        }
      }
      if (o == 0) {
        break;
      }
      o = 1;
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == 0) {
          o = 2;
        }
      }
      if (o == 1) {
        break;
      }
      t++;
    }
    int cnt = 0;
    if (o == 0) {
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == o) {
          cnt++;
        }
      }
      printf("%d\\n", cnt);
      printf("0\\n");
    } else {
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == o) {
          cnt++;
        }
      }
      printf("0\\n");
      printf("%d\\n", cnt);
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
int main() {
  int c[101] = {0}, ba = 0, n, i, a, t = 0, o;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 1; i <= n * 2; i++) {
      c[i] = 0;
    }
    ba = 0;
    t = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a);
      c[a] = 1;
    }
    while (1) {
      if (ba == 0) {
        for (i = 1; i <= n * 2; i++) {
          if (c[i] == (t + 1) % 2) {
            ba = i;
            c[i] = 2;
            break;
          }
        }
      } else {
        o = 0;
        for (i = 1; i <= n * 2; i++) {
          if (c[i] == (t + 1) % 2 && ba < i) {
            o = 1;
            ba = i;
            c[i] = 2;
            break;
          }
        }
        if (o == 0) {
          ba = 0;
        }
      }
      o = 0;
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == 1) {
          o = 2;
        }
      }
      if (o == 0) {
        break;
      }
      o = 1;
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == 0) {
          o = 2;
        }
      }
      if (o == 1) {
        break;
      }
      t++;
    }
    int cnt = 0;
    if (o == 0) {
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == o) {
          cnt++;
        }
      }
      printf("%d\\n", cnt);
      printf("0\\n");
    } else {
      for (i = 1; i <= n * 2; i++) {
        if (c[i] == o) {
          cnt++;
        }
      }
      printf("0\\n");
      printf("%d\\n", cnt);
    }
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int card = 0;
  bool myCard[5][201] = {0};
  int cardLeft[5] = {0};
  bool turn = true;
  int stage = 0;
  bool flg = false;

  while (1) {
    memset(myCard[0], false, sizeof(myCard[0]));
    memset(myCard[1], false, sizeof(myCard[1]));
    stage = 0;
    turn = true;

    cin >> card;
    if (!card)
      break;
    cardLeft[0] = cardLeft[1] = card;
    for (int i = 1; i <= card; i++) {
      int cmp = 0;
      cin >> cmp;
      myCard[0][cmp - 1] = true;
    }
    for (int i = 1; i <= card * 2; i++) {
      myCard[1][i - 1] = 1 ^ myCard[0][i - 1];
    }
    // printf("%d\\n",card);

    for (int i = 0; i < card * 2; i++) {
      // printf("[debug]myCard:%d:[0]=%d
      // ,[1]=%d\\n",i,myCard[0][i],myCard[1][i]);
    }
    // printf("a\\n");

    while (1) {
      turn = turn ^ 1;
      flg = false;
      for (int i = stage + 1; i <= card * 2; i++) {
        if (myCard[turn][i - 1] == true) {
          stage = i;
          myCard[turn][i - 1] = false;
          cardLeft[turn]--;
          flg = true;
          break;
        }
      }
      if (!flg)
        stage = 0;
      // printf("[debug]card=%d ,turn=%d ,stage=%d ,cardLeft:[0]=%d ,[1]=%d
      // ,flg=%d\\n",card,turn,stage,cardLeft[0],cardLeft[1],flg);
      if (!cardLeft[turn])
        break;
    }
    cout << cardLeft[1] << endl << cardLeft[0] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int card = 0;
  bool myCard[2][101] = {0};
  int cardLeft[2] = {0};
  bool turn = true;
  int stage = 0;
  bool flg = false;

  while (1) {
    memset(myCard[0], false, sizeof(myCard[0]));
    memset(myCard[1], false, sizeof(myCard[1]));
    stage = 0;
    turn = true;

    cin >> card;
    if (!card)
      break;
    cardLeft[0] = cardLeft[1] = card;
    for (int i = 1; i <= card; i++) {
      int cmp = 0;
      cin >> cmp;
      myCard[0][cmp - 1] = true;
    }
    for (int i = 1; i <= card * 2; i++) {
      myCard[1][i - 1] = 1 ^ myCard[0][i - 1];
    }

    /*for ( int i = 0 ; i < card*2 ; i++ )
    {
        printf("[debug]myCard:%d:[0]=%d ,[1]=%d\\n",i,myCard[0][i],myCard[1][i]);
    }*/

    while (1) {
      turn = turn ^ 1;
      flg = false;
      for (int i = stage + 1; i <= card * 2; i++) {
        if (myCard[turn][i - 1] == true) {
          stage = i;
          myCard[turn][i - 1] = false;
          cardLeft[turn]--;
          flg = true;
          break;
        }
      }
      if (!flg)
        stage = 0;
      // printf("[debug]card=%d ,turn=%d ,stage=%d ,cardLeft:[0]=%d ,[1]=%d
      // ,flg=%d\\n",card,turn,stage,cardLeft[0],cardLeft[1],flg);
      if (!cardLeft[turn])
        break;
    }
    cout << cardLeft[1] << endl << cardLeft[0] << endl;
  }

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

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define REP(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1 << 30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> a, b;
    bool used[205];
    memset(used, 0, sizeof(used));

    int x;
    rep(i, n) {
      cin >> x;
      used[x] = true;
      a.push_back(x);
    }

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

    REP(i, 1, 2 * n + 1) {
      if (used[i])
        continue;
      b.push_back(i);
    }

    int res = 0, i = 0;
    while (true) {
      if (a.size() == 0 || b.size() == 0)
        break;

      if (i % 2 == 0) {
        vector<int>::iterator ite = upper_bound(a.begin(), a.end(), res);
        if (ite == a.end()) {
          res = 0;
        } else {
          res = *ite;
          a.erase(ite);
        }
      } else {
        vector<int>::iterator ite = upper_bound(b.begin(), b.end(), res);
        if (ite == b.end()) {
          res = 0;
        } else {
          res = *ite;
          b.erase(ite);
        }
      }

      i++;
    }

    cout << b.size() << endl;
    cout << a.size() << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define REP(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1 << 30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> a, b;
    bool used[105];
    memset(used, 0, sizeof(used));

    int x;
    rep(i, n) {
      cin >> x;
      used[x] = true;
      a.push_back(x);
    }

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

    REP(i, 1, 2 * n + 1) {
      if (used[i])
        continue;
      b.push_back(i);
    }

    int res = 0, i = 0;
    while (true) {
      if (a.size() == 0 || b.size() == 0)
        break;

      if (i % 2 == 0) {
        vector<int>::iterator ite = upper_bound(a.begin(), a.end(), res);
        if (ite == a.end()) {
          res = 0;
        } else {
          res = *ite;
          a.erase(ite);
        }
      } else {
        vector<int>::iterator ite = upper_bound(b.begin(), b.end(), res);
        if (ite == b.end()) {
          res = 0;
        } else {
          res = *ite;
          b.erase(ite);
        }
      }

      i++;
    }

    cout << b.size() << endl;
    cout << a.size() << endl;
  }

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

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    int t[100] = {0}, h[100] = {0}, c[200] = {0};
    for (int i = 0; i < n; ++i) {
      int idx;
      cin >> idx;
      c[idx - 1] = 1;
    }

    for (int i = 0, idx[2] = {0}; i < n * 2; ++i) {
      if (c[i])
        t[idx[0]++] = i + 1;
      else
        h[idx[1]++] = i + 1;
    }

    int tn, hn, mx = 0;
    tn = hn = n;

    while (tn && hn) {
      bool flag = true;

      for (int i = 0; i < n; ++i) {
        if (t[i] && mx < t[i]) {
          mx = t[i];
          --tn;
          t[i] = 0;
          flag = false;
          break;
        }
      }

      if (!tn || !hn)
        break;
      if (flag)
        mx = 0;

      flag = true;

      for (int i = 0; i < n; ++i) {
        if (h[i] && mx < h[i]) {
          mx = h[i];
          --hn;
          h[i] = 0;
          flag = false;
          break;
        }
      }

      if (flag)
        mx = 0;
    }

    printf("%d\\n%d\\n", hn, tn);
  }

  return 0;
}

Error: -6
double free or corruption (out)


Fixed submission:

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

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> t, h;
    int c[200] = {};

    for (int i = 0, idx; i < n * 2; ++i) {
      cin >> idx;
      ++c[idx - 1];
    }

    for (int i = 0; i < n * 2; ++i) {
      if (c[i])
        t.push_back(i + 1);
      else
        h.push_back(i + 1);
    }

    int tn, hn, mx = 0;
    tn = hn = n;

    while (tn && hn) {
      bool flag = true;

      for (int i = 0; i < tn; ++i) {
        if (t[i] && mx < t[i]) {
          mx = t[i];
          --tn;
          flag = false;
          t.erase(t.begin() + i);
          break;
        }
      }

      if (!tn || !hn)
        break;
      if (flag)
        mx = 0;

      flag = true;

      for (int i = 0; i < hn; ++i) {
        if (h[i] && mx < h[i]) {
          mx = h[i];
          --hn;
          flag = false;
          h.erase(h.begin() + i);
          break;
        }
      }

      if (flag)
        mx = 0;
    }

    printf("%d\\n%d\\n", hn, tn);
  }

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

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int n, a, t[1000], h[1000], b[1000] = {};
    int c = 0, d = 0, ba = 0, ta = 0, ha = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> a;
      b[a]++;
    }
    for (int i = 1; i <= n * 2; i++) {
      if (b[i] == 0) {
        h[c] = i;
        c++;
      } else {
        t[d] = i;
        d++;
      }
    }
    while (1) {
      int f = 0;
      for (int i = 0; i < n; i++) {
        if (t[i] > ba) {
          ba = t[i];
          t[i] = 0;
          f++;
          ta++;
          break;
        }
      }
      if (f == 0)
        ba = 0;
      if (ta == n)
        break;
      f = 0;
      for (int i = 0; i < n; i++) {
        if (h[i] > ba) {
          ba = h[i];
          h[i] = 0;
          f++;
          ha++;
          break;
        }
      }
      if (f == 0)
        ba = 0;
      if (ha == n)
        break;
    }
    printf("%d\\n%d\\n", n - ha, n - ta);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int n, a, t[100], h[100], b[101] = {};
    int c = 0, d = 0, e = 0, ba = 0, ta = 0, ha = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> a;
      b[a]++;
    }
    for (int i = 1; i <= n * 2; i++) {
      if (b[i] == 0) {
        h[c] = i;
        c++;
      } else {
        t[d] = i;
        d++;
      }
    }
    while (1) {
      int f = 0;
      for (int i = 0; i < n; i++) {
        if (t[i] > ba) {
          ba = t[i];
          t[i] = 0;
          f++;
          ta++;
          break;
        }
      }
      if (f == 0)
        ba = 0;
      if (ta == n)
        break;
      f = 0;
      for (int i = 0; i < n; i++) {
        if (h[i] > ba) {
          ba = h[i];
          h[i] = 0;
          f++;
          ha++;
          break;
        }
      }
      if (f == 0)
        ba = 0;
      if (ha == n)
        break;
    }
    printf("%d\\n%d\\n", n - ha, n - ta);
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  int N;
  while (cin >> N, N) {
    vector<int> card[2];
    int ba = -1, in;
    bool latte[201] = {}, turn = 0;
    for (int i = 0; i < N; i++) {
      cin >> in;
      latte[in] = true;
    }
    for (int i = 1; i <= 2 * N; i++) {
      card[!latte[i]].push_back(i);
    }
    sort(card[0].begin(), card[0].end());
    sort(card[1].begin(), card[1].end());
    while (card[0].size() && card[1].size()) {
      vector<int>::iterator itr =
          upper_bound(card[turn].begin(), card[turn].end(), ba);
      if (itr == card[turn].end())
        ba = -1;
      else {
        ba = *itr;
        card[turn].erase(itr);
      }
      turn = !turn;
    }
    printf("%d\\n%d\\n", card[1].size(), card[0].size());
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  int N;
  while (cin >> N, N) {
    vector<int> card[2];
    int ba = -1, in;
    bool latte[101] = {}, turn = 0;
    for (int i = 0; i < N; i++) {
      cin >> in;
      latte[in] = true;
    }
    for (int i = 1; i <= 2 * N; i++) {
      card[!latte[i]].push_back(i);
    }
    sort(card[0].begin(), card[0].end());
    sort(card[1].begin(), card[1].end());
    while (card[0].size() && card[1].size()) {
      vector<int>::iterator itr =
          upper_bound(card[turn].begin(), card[turn].end(), ba);
      if (itr == card[turn].end())
        ba = -1;
      else {
        ba = *itr;
        card[turn].erase(itr);
      }
      turn = !turn;
    }
    printf("%d\\n%d\\n", card[1].size(), card[0].size());
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std;
int main() {
  while (1) {
    int n, x;
    int i, j;
    int tarou[300] = {0}, hanako[300] = {0};
    int field = 0;
    int flg1 = 0, flg2 = 0;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      tarou[x - 1] = x;
    }
    for (i = 0; i < n * 2; i++) {
      if (tarou[i] == 0)
        hanako[i] = i + 1;
    }

    sort(tarou, tarou + n * 2, greater<int>());
    sort(hanako, hanako + n * 2, greater<int>());
    sort(tarou, tarou + n);
    sort(hanako, hanako + n);

    while (1) {
      // 太郎の番
      for (j = 0; j < n; j++) {
        if (field < tarou[j]) {
          field = tarou[j];
          tarou[j] = -1;
          flg1++;
          goto next;
        }
      }
      field = 0;
    next:
      if (flg1 == n || flg2 == n)
        break;
      for (j = 0; j < n; j++) {
        if (field < hanako[j]) {
          field = hanako[j];
          hanako[j] = -1;
          flg2++;
          goto next2;
        }
      }
      field = 0;
    next2:
      if (flg1 == n || flg2 == n)
        break;
    }
    printf("%d\\n%d\\n", n - flg2, n - flg1);
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std;
int main() {
  while (1) {
    int n, x;
    int i, j;
    int tarou[110] = {0}, hanako[110] = {0};
    int field = 0;
    int flg1 = 0, flg2 = 0;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      tarou[x - 1] = x;
    }
    for (i = 0; i < n * 2; i++) {
      if (tarou[i] == 0)
        hanako[i] = i + 1;
    }

    sort(tarou, tarou + n * 2, greater<int>());
    sort(hanako, hanako + n * 2, greater<int>());
    sort(tarou, tarou + n);
    sort(hanako, hanako + n);

    while (1) {
      // 太郎の番
      for (j = 0; j < n; j++) {
        if (field < tarou[j]) {
          field = tarou[j];
          tarou[j] = -1;
          flg1++;
          goto next;
        }
      }
      field = 0;
    next:
      if (flg1 == n || flg2 == n)
        break;
      for (j = 0; j < n; j++) {
        if (field < hanako[j]) {
          field = hanako[j];
          hanako[j] = -1;
          flg2++;
          goto next2;
        }
      }
      field = 0;
    next2:
      if (flg1 == n || flg2 == n)
        break;
    }
    printf("%d\\n%d\\n", n - flg2, n - flg1);
  }

  return 0;
}