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

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

int main() {
  int n;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    vector<int> t, h;
    for (int i = 0; i < n; i++) {
      int tmp;
      scanf("%d", &tmp);
      t.push_back(tmp);
    }
    for (int i = 0; i < 2 * n; i++) {
      bool find = false;
      for (int j = 0; j < n; j++) {
        if (t[j] == i + 1) {
          find = true;
        }
      }
      if (find == false) {
        h.push_back(i + 1);
      }
      find = false;
    }
    sort(t.begin(), t.end());
    sort(h.begin(), h.end());
    int b = 0;
    bool td = false;
    bool hd = false;
    while (1) {
      for (int i = 0; i < t.size(); i++) {
        if (t[i] > b) {
          b = t[i];
          t.erase(t.begin() + i);
          td = true;
          break;
        }
      }
      if (td == false) {
        b = 0;
      }
      td = false;
      if (t.size() == 0)
        break;
      for (int i = 0; i < h.size(); i++) {
        if (h[i] > b) {
          b = h[i];
          h.erase(h.begin() + i);
          hd = true;
          break;
        }
      }
      if (hd == false) {
        b = 0;
      }
      hd = false;
      if (h.size() == 0)
        break;
    }
    int ts = h.size();
    int hs = t.size();
    printf("%d\\n%d\\n", ts, hs);
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  while (scanf("%d", &n) != 0) {
    vector<int> t, h;
    for (int i = 0; i < n; i++) {
      int tmp;
      scanf("%d", &tmp);
      t.push_back(tmp);
    }
    for (int i = 0; i < 2 * n; i++) {
      bool find = false;
      for (int j = 0; j < n; j++) {
        if (t[j] == i + 1) {
          find = true;
        }
      }
      if (find == false) {
        h.push_back(i + 1);
      }
      find = false;
    }
    sort(t.begin(), t.end());
    sort(h.begin(), h.end());
    int b = 0;
    bool td = false;
    bool hd = false;
    while (1) {
      for (int i = 0; i < t.size(); i++) {
        if (t[i] > b) {
          b = t[i];
          t.erase(t.begin() + i);
          td = true;
          break;
        }
      }
      if (td == false) {
        b = 0;
      }
      td = false;
      if (t.size() == 0)
        break;
      for (int i = 0; i < h.size(); i++) {
        if (h[i] > b) {
          b = h[i];
          h.erase(h.begin() + i);
          hd = true;
          break;
        }
      }
      if (hd == false) {
        b = 0;
      }
      hd = false;
      if (h.size() == 0)
        break;
    }
    int ts = h.size();
    int hs = t.size();
    printf("%d\\n%d\\n", ts, hs);
  }

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

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

int main() {
  int n;
  while (true) {
    cin >> n;
    if (!n)
      break;
    vector<int> taro, hanako;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      taro.push_back(a);
    }
    sort(taro.begin(), taro.end());
    for (int j = 1; j < taro[0]; j++) {
      hanako.push_back(j);
    }
    for (int i = 0; i < n - 1; i++) {
      for (int j = taro[i] + 1; j < taro[i + 1]; j++) {
        hanako.push_back(j);
      }
    }
    for (int j = taro[n - 1] + 1; j <= 2 * n; j++) {
      hanako.push_back(j);
    }
    int top = 0;
    vector<int>::iterator min;
    while (true) {
      min = lower_bound(taro.begin(), taro.end(), top);
      if (min == taro.end()) {
        top = 0;
      } else {
        top = *min;
        taro.erase(min);
      }
      if (taro.empty())
        break;
      min = lower_bound(hanako.begin(), hanako.end(), top);
      if (min == hanako.end()) {
        top = 0;
      } else {
        top = *min;
        hanako.erase(min);
      }
      if (hanako.empty())
        break;
    }
    cout << hanako.size() << '\\n' << taro.size() << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int n;
  while (true) {
    cin >> n;
    vector<int> taro, hanako;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      taro.push_back(a);
    }
    sort(taro.begin(), taro.end());
    for (int j = 1; j < taro[0]; j++) {
      hanako.push_back(j);
    }
    for (int i = 0; i < n - 1; i++) {
      for (int j = taro[i] + 1; j < taro[i + 1]; j++) {
        hanako.push_back(j);
      }
    }
    for (int j = taro[n - 1] + 1; j <= 2 * n; j++) {
      hanako.push_back(j);
    }
    int top = 0;
    vector<int>::iterator min;
    while (true) {
      min = lower_bound(taro.begin(), taro.end(), top);
      if (min == taro.end()) {
        top = 0;
      } else {
        top = *min;
        taro.erase(min);
      }
      if (taro.empty())
        break;
      min = lower_bound(hanako.begin(), hanako.end(), top);
      if (min == hanako.end()) {
        top = 0;
      } else {
        top = *min;
        hanako.erase(min);
      }
      if (hanako.empty())
        break;
    }
    cout << hanako.size() << '\\n' << taro.size() << endl;
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>

using namespace std;
int main(void) {
  int n, i, j, c, ct, ch, max, flg, flg2;
  int t[201], h[201], x[201];
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 1; i <= n * 2; i++)
      x[i] = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &t[i]);
      x[t[i]] = 1;
    }
    sort(t + 1, t + n + 1);
    c = 1;
    for (i = 1; i <= n * 2; i++) {
      if (x[i] == 0) {
        h[c] = i;
        c++;
      }
    }
    ct = n;
    ch = n;
    flg = 0;
    flg2 = 0;
    max = 0;
    while (1) {
      if (ct == 0 || ch == 0)
        break;
      if (flg == 0) {
        for (j = 1; j <= n; j++) {
          if (max < t[j]) {
            max = t[j];
            flg = 1;
            ct--;
            t[j] = -1;
            flg2 = 1;
            break;
          }
        }
        if (flg == 0 && flg2 == 0) {
          max = 0;
          flg = 1;
        }
      } else if (flg == 1) {
        for (j = 1; j <= n; j++) {
          if (max < h[j]) {
            max = h[j];
            flg = 0;
            ch--;
            h[j] = -1;
            flg2 = 0;
            break;
          }
        }
        if (flg == 1 && flg2 == 1) {
          max = 0;
          flg = 0;
        }
      }
    }
    printf("%d\\n", ch);
    printf("%d\\n", ct);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

int main() {
  int n, taro[3][10000], hanako[3][10000], c, d, e, taro2, hanako2, ba;
  while (true) {
    memset(taro, 1, sizeof(taro));
    memset(hanako, 1, sizeof(taro));
    c = 0;
    d = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> taro[0][i];
    }
    for (int i = 1; i <= 2 * n; i++) {
      e = 0;
      for (int j = 0; j < n; j++) {
        if (taro[0][j] == i) {
          e++;
        }
      }
      if (e == 0) {
        hanako[1][d] = i;
        d++;
      } else {
        taro[1][c] = i;
        c++;
      }
    }
    taro2 = n;
    hanako2 = n;
    ba = 0;
    while (true) {

      for (int i = 0; i < n; i++) {
        if (taro[1][i] > ba && taro[2][i] != 0) {
          taro[2][i] = 0;
          taro2 -= 1;
          ba = taro[1][i];
          if (taro2 == 0) {
            goto Exit;
          }
          break;
        }
        if (i == n - 1) {
          ba = 0;
        }
      }

      for (int i = 0; i < n; i++) {
        if (hanako[1][i] > ba && hanako[2][i] != 0) {
          hanako[2][i] = 0;
          hanako2 -= 1;
          ba = hanako[1][i];
          if (hanako2 == 0) {
            goto Exit;
          }
          break;
        }
        if (i == n - 1) {
          ba = 0;
        }
      }
    }
  Exit:
    cout << hanako2 << endl;
    cout << taro2 << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n, taro[3][10000], hanako[3][10000], c, d, e, taro2, hanako2, ba;
  memset(taro, 1, sizeof(taro));
  while (true) {
    c = 0;
    d = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> taro[0][i];
    }
    for (int i = 1; i <= 2 * n; i++) {
      e = 0;
      for (int j = 0; j < n; j++) {
        if (taro[0][j] == i) {
          e++;
        }
      }
      if (e == 0) {
        hanako[1][d] = i;
        d++;
      } else {
        taro[1][c] = i;
        c++;
      }
    }
    taro2 = n;
    hanako2 = n;
    ba = 0;
    while (true) {
    taro3:
      for (int i = 0; i < n; i++) {
        if (taro[1][i] > ba && taro[2][i] != 0) {
          taro[2][i] = 0;
          taro2 -= 1;
          ba = taro[1][i];
          if (taro2 == 0) {
            goto Exit;
          }
          goto hanako3;
        }
      }
      ba = 0;
    hanako3:
      for (int i = 0; i < n; i++) {
        if (hanako[1][i] > ba && hanako[2][i] != 0) {
          hanako[2][i] = 0;
          hanako2 -= 1;
          ba = hanako[1][i];
          if (hanako2 == 0) {
            goto Exit;
          }
          goto taro3;
        }
      }
      ba = 0;
    }
  Exit:
    cout << hanako2 << endl;
    cout << taro2 << endl;
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    bool t[2 * n + 1], h[2 * n + 1];
    int taro = n, hana = n;

    for (int i = 0; i <= 2 * n; i++)
      t[i] = false;

    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      t[x] = true;
    }
    for (int i = 1; i <= 2 * n; i++)
      h[i] = !t[i];

    bool turn = true;
    int ba = 0;
    while (taro != 0 && hana != 0) {
      if (turn) {
        int next;
        for (next = ba + 1; next <= 2 * n; next++) {
          if (t[next]) {
            t[next] = false;
            break;
          }
        }
        if (next <= 2 * n) {
          ba = next;
          taro--;
        } else {
          ba = 0;
        }
      } else {
        int next;
        for (next = ba + 1; next <= 2 * n; next++) {
          if (h[next]) {
            h[next] = false;
            break;
          }
        }
        if (next <= 2 * n) {
          ba = next;
          hana--;
        } else {
          ba = 0;
        }
      }
      turn = !turn;
    }

    cout << hana << endl << taro << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    bool t[n + 1], h[n + 1];
    int taro = n, hana = n;

    for (int i = 0; i < n + 1; i++)
      t[i] = false;

    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      t[x] = true;
    }
    for (int i = 1; i <= n; i++)
      h[i] = !t[i];

    bool turn = true;
    int ba = 0;
    while (taro != 0 && hana != 0) {
      if (turn) {
        int next;
        for (next = ba + 1; next <= n; next++) {
          if (t[next]) {
            t[next] = false;
            break;
          }
        }
        if (next <= n) {
          ba = next;
          taro--;
        } else {
          ba = 0;
        }
      } else {
        int next;
        for (next = ba + 1; next <= n; next++) {
          if (h[next]) {
            h[next] = false;
            break;
          }
        }
        if (next <= n) {
          ba = next;
          hana--;
        } else {
          ba = 0;
        }
      }
      turn = !turn;
    }

    int sum = 0;
    if (taro == 0) {
      for (int i = 1; i <= n; i++)
        if (h[i])
          sum += i;
    } else if (hana == 0) {
      for (int i = 1; i <= n; i++)
        if (t[i])
          sum += i;
    }

    cout << sum << endl;
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <list>
#include <vector>

using namespace std;

#define TARO 0
#define HANAKO 1

int search(list<int> &target, int num) {
  list<int>::iterator it = target.begin();

  while (1) {
    if (it == target.end())
      return 0;
    if (*it > num) {
      int ret = *it;
      target.erase(it);
      return ret;
    }
    it++;
  }
}

int main() {
  while (1) {
    int i;
    int n;
    vector<bool> flag(200);
    list<int> Taro;
    list<int> Hanako;
    int save;
    bool turn;

    scanf("%d", &n);
    if (n == 0)
      return 0;

    for (i = 0; i < n; i++) {
      int k;

      scanf("%d", &k);
      Taro.push_back(k);
      flag[k - 1] = 1;
    }

    for (i = 0; i < 2 * n; i++) {
      if (!flag[i]) {
        Hanako.push_back(i + 1);
      }
    }

    Taro.sort();
    Hanako.sort();

    list<int>::iterator it = Hanako.begin();

    turn = TARO;
    save = 0;
    while (1) {
      if (turn == TARO) {
        save = search(Taro, save);
        turn = HANAKO;
      } else {
        save = search(Hanako, save);
        turn = TARO;
      }

      if (Taro.empty() || Hanako.empty())
        break;
    }

    printf("%d\\n", Hanako.size());
    printf("%d\\n", Taro.size());
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <list>
#include <vector>

using namespace std;

#define TARO 0
#define HANAKO 1

char search(list<char> &target, char num) {
  list<char>::iterator it = target.begin();

  while (1) {
    if (it == target.end())
      return 0;
    if (*it > num) {
      char ret = *it;
      target.erase(it);
      return ret;
    }
    it++;
  }
}

int main() {
  while (1) {
    int i;
    int n;
    vector<bool> flag(200);
    list<char> Taro;
    list<char> Hanako;
    char save;
    bool turn;

    scanf("%d", &n);
    if (n == 0)
      return 0;

    for (i = 0; i < n; i++) {
      int k;

      scanf("%d", &k);
      Taro.push_back(k);
      flag[k - 1] = 1;
    }

    for (i = 0; i < 2 * n; i++) {
      if (!flag[i]) {
        Hanako.push_back(i);
      }
    }

    Taro.sort();
    Hanako.sort();

    turn = TARO;
    save = 0;
    while (1) {
      if (turn == TARO) {
        save = search(Taro, save);
        turn = HANAKO;
      } else {
        save = search(Hanako, save);
        turn = TARO;
      }

      if (Taro.empty() || Hanako.empty())
        break;
    }

    printf("%d\\n", Hanako.size());
    printf("%d\\n", Taro.size());
  }
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int main() {

  int n, i, j, k, a, b;
  int card[300];

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

    for (i = 0; i < 2 * n; i++)
      card[i] = 1;
    for (i = 0; i < n; i++) {
      scanf("%d", &j);
      card[j - 1] = -1;
    }

    int t = -1, c = 0, d = 0;

    // puts("");
    // for(i=0;i<2*n;i++){
    //	printf("%2d:%2d ",i+1,card[i]);
    // }
    // puts("");
    a = b = n;
    k = n * 4;
    while (k-- > 0) {
      d = c;
      for (i = c; i < 2 * n; i++) {
        if (card[i] == t) {
          c = i + 1;
          card[i] = 0;
          if (t == -1)
            b--;
          else
            a--;
          t = -t;
          break;
        }
      }
      /*
      puts("");
      for(i=0;i<2*n;i++){
              printf("%2d:%2d ",i+1,card[i]);
      }
      puts("");
      */

      if (a == 0)
        break;
      if (b == 0)
        break;

      if (d == c) {
        if (c == 0)
          break;

        c = 2 * n;
      }
      if (c == 2 * n) {
        c = 0;
        t = -t;
      }
    }
    /*
    a=0;b=0;

    for(i=0;i<2*n;i++){
            if(card[i]==1)a++;
            if(card[i]==-1)b++;
    }
    */
    printf("%d\\n%d\\n", a, b);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

int main() {

  int n, i, j, k, a, b;
  int card[20];

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

    for (i = 0; i < 2 * n; i++)
      card[i] = 1;
    for (i = 0; i < n; i++) {
      scanf("%d", &j);
      card[j - 1] = -1;
    }

    int t = -1, c = 0, d = 0;

    // puts("");
    // for(i=0;i<2*n;i++){
    //	printf("%2d:%2d ",i+1,card[i]);
    // }
    // puts("");
    a = b = n;
    k = n * 4;
    while (k-- > 0) {
      d = c;
      for (i = c; i < 2 * n; i++) {
        if (card[i] == t) {
          c = i + 1;
          card[i] = 0;
          if (t == -1)
            b--;
          else
            a--;
          t = -t;
          break;
        }
      }
      /*
      puts("");
      for(i=0;i<2*n;i++){
              printf("%2d:%2d ",i+1,card[i]);
      }
      puts("");
      */

      if (a == 0)
        break;
      if (b == 0)
        break;

      if (d == c) {
        if (c == 0)
          break;

        c = 2 * n;
      }
      if (c == 2 * n) {
        c = 0;
        t = -t;
      }
    }
    /*
    a=0;b=0;

    for(i=0;i<2*n;i++){
            if(card[i]==1)a++;
            if(card[i]==-1)b++;
    }
    */
    printf("%d\\n%d\\n", a, b);
  }

  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

int main() {
  int n, i, j, a, suu1, suu2, ba, t;
  int tarou[100];
  int hanako[100];
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;

    for (i = 0; i < n; i++)
      tarou[i] = 0, hanako[i] = 0;
    for (i = 0; i < n; i++)
      scanf("%d", &tarou[i]);
    for (i = 0; i < n; i++) {
      for (j = 0; j < n - 1; j++) {
        if (tarou[j] > tarou[j + 1]) {
          a = tarou[j];
          tarou[j] = tarou[j + 1];
          tarou[j + 1] = a;
        }
      }
    }
    j = 0;
    a = 0;
    for (i = 1; i <= n * 2; i++) {
      if (tarou[j] != i) {
        hanako[a] = i;
        a++;
      } else if (tarou[j] == i)
        j++;
    }
    suu1 = n;
    suu2 = n;
    t = 0;
    ba = 0;
    while (suu2 != 0 && suu1 != 0) {
      if (t == 0) {
        for (i = 0; i < n; i++) {
          if (ba < tarou[i] && tarou[i] != 0) {
            ba = tarou[i];
            tarou[i] = 0;
            t = 1;
            suu2--;
            break;
          }
          if (i == n - 1) {
            t = 1;
            ba = 0;
          }
        }
      } else if (t == 1) {
        for (i = 0; i < n; i++) {
          if (ba < hanako[i] && hanako[i] != 0) {
            ba = hanako[i];
            hanako[i] = 0;
            t = 0;
            suu1--;
            break;
          }
          if (i == n - 1) {
            t = 0;
            ba = 0;
          }
        }
      }
    }
    printf("%d\\n%d\\n", suu1, suu2);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

int main() {
  int n, i, j, a, suu1, suu2, ba, t;
  int tarou[100];
  int hanako[100];
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;

    for (i = 0; i < n; i++)
      tarou[i] = 0;
    hanako[i] = 0;
    for (i = 0; i < n; i++)
      scanf("%d", &tarou[i]);
    for (i = 0; i < n; i++) {
      for (j = 0; j < n - 1; j++) {
        if (tarou[j] > tarou[j + 1]) {
          a = tarou[j];
          tarou[j] = tarou[j + 1];
          tarou[j + 1] = a;
        }
      }
    }
    j = 0;
    a = 0;
    for (i = 0; i < n * 2; i++) {
      if (tarou[j] != i) {
        hanako[a] = i;
        a++;
      } else if (tarou[j] == i)
        j++;
    }
    suu1 = n;
    suu2 = n;
    t = 0;
    ba = 0;
    while (suu2 != 0 && suu1 != 0) {
      if (t == 0) {
        for (i = 0; i < n; i++) {
          if (ba < tarou[i] && tarou[i] != 0) {
            ba = tarou[i];
            tarou[i] = 0;
            t = 1;
            suu2--;
            break;
          }
          if (i == n - 1) {
            t = 1;
            ba = 0;
          }
        }
      } else if (t == 1) {
        for (i = 0; i < n; i++) {
          if (ba < hanako[i] && hanako[i] != 0) {
            ba = hanako[i];
            hanako[i] = 0;
            t = 0;
            suu1--;
            break;
          }
        }
      }
    }
    printf("%d\\n%d\\n", suu1, suu2);
  }
  return 0;
}
Problem p00446 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main(void) {
  int a;
  cin >> a;
  while (a != 0) {
    int b[10000] = {0}, c[10000] = {0}, d, e = 0, f[10000] = {0}, g = 0, h = 0,
        i, k = 0, n = 0;
    h = 2 * a;
    for (i = 1; i <= a; i++) {
      cin >> d;
      f[d] = 1;
    }
    for (i = 1; i <= h; i++) {
      if (f[i] == 1) {
        b[e] = i;
        e++;
      } else {
        c[g] = i;
        g++;
      }
    }
    k = 0;
    g = 0;
    e = 0;
    int count = 0, j = 0, o = 0, p = 0, s = 0, l = 0, x = 0, z = 0;
    x = a;
    z = a;
    while (1) {
      if (k == 0) {
        for (i = 0; i < a; i++) {
          if (n < b[i]) {
            n = b[i];
            b[i] = 0;
            l = 1;
            x--;
            break;
          }
        }
        if (l == 0) {
          n = 0;
        }
        l = 0;
      }
      if (x == 0) {
        break;
      }
      k = 1;
      if (k == 1) {
        for (g = 0; g < a; g++) {
          if (n < c[g]) {
            n = c[g];
            c[g] = 0;
            s = 1;
            z--;
            break;
          }
        }
        if (s == 0) {
          n = 0;
        }
        s = 0;
      }
      k = 0;
      if (z == 0) {
        break;
      }
    }
    cout << z << endl << x << endl;
    cin >> a;
  }
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int a;
  cin >> a;
  while (a != 0) {
    int b[100] = {0}, c[100] = {0}, d, e = 0, f[101] = {0}, g = 0, h = 0, i,
        k = 0, n = 0;
    h = 2 * a;
    for (i = 1; i <= a; i++) {
      cin >> d;
      f[d] = 1;
    }
    for (i = 1; i <= h; i++) {
      if (f[i] == 1) {
        b[e] = i;
        e++;
      } else {
        c[g] = i;
        g++;
      }
    }
    k = 0;
    g = 0;
    e = 0;
    int count = 0, j = 0, o = 0, p = 0, s = 0, l = 0, x = 0, z = 0;
    x = a;
    z = a;
    while (1) {
      if (k == 0) {
        for (i = 0; i < a; i++) {
          if (n < b[i]) {
            n = b[i];
            b[i] = 0;
            l = 1;
            x--;
            break;
          }
        }
        if (l == 0) {
          n = 0;
        }
        l = 0;
      }
      if (x == 0) {
        break;
      }
      k = 1;
      if (k == 1) {
        for (g = 0; g < a; g++) {
          if (n < c[g]) {
            n = c[g];
            c[g] = 0;
            s = 1;
            z--;
            break;
          }
        }
        if (s == 0) {
          n = 0;
        }
        s = 0;
      }
      k = 0;
      if (z == 0) {
        break;
      }
    }
    cout << z << endl << x << endl;
    cin >> a;
  }
}