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

#include <iostream>
using namespace std;

int main() {

  char qwe[6], ans[6];

  int hit, blow, count;

  count = 0;

  while (1) {
    cin >> qwe >> ans;
    if (qwe[0] == '0' && ans[0] == '0' && qwe[1] == '\\0' && ans[1] == '\\0')
      break;
    hit = 0;
    blow = 0;

    for (int i = 0; i < 4; i++) {

      for (int g = 0; g < 4; g++) {

        if (qwe[i] == ans[g]) {

          if (i == g)
            hit++;
          else
            blow++;
        }
      }
    }

    cout << hit << " " << blow << endl;
    count++;
  }

  /* hit = 0 ;
   blow = 0;

   while(hit != 4){
     if(count == 0){
       break;
     }
     cin >> qwe >> ans;
     hit = 0 ;
     blow = 0;

    for(int i=0; i<4; i++){

        for(int g=0; g<4; g++){

            if(qwe[i] == ans[g]){

                 if(i == g)
                       hit++;
                 else
                       blow++;
             }
        }
     }

    cout << hit << " " << blow << endl;

    count--;
  }*/

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  char qwe[6], ans[6];

  int hit, blow, count;

  count = 0;

  while (hit != 4) {
    cin >> qwe >> ans;
    hit = 0;
    blow = 0;

    for (int i = 0; i < 4; i++) {

      for (int g = 0; g < 4; g++) {

        if (qwe[i] == ans[g]) {

          if (i == g)
            hit++;
          else
            blow++;
        }
      }
    }

    cout << hit << " " << blow << endl;
    count++;
  }

  while (hit != 4 || count != 0) {
    cin >> qwe >> ans;
    hit = 0;
    blow = 0;

    for (int i = 0; i < 4; i++) {

      for (int g = 0; g < 4; g++) {

        if (qwe[i] == ans[g]) {

          if (i == g)
            hit++;
          else
            blow++;
        }
      }
    }

    cout << hit << " " << blow << endl;

    count--;
  }

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

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

int main(void) {
  string strH, strB;
  int hNum, bNum;

  while (1) {
    cin >> strH >> strB;
    if (strH == "0" && strB == "0")
      break;

    hNum = bNum = 0;

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (strH[i] == strB[j]) {
          if (i == j)
            hNum++;
          else
            bNum++;
        }
      }
    }

    cout << hNum << " " << bNum << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int n, m;
  int res;

  while (1) {
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;

    res = 0;

    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];

    stable_sort(p, p + n);

    for (int i = n - 1; i >= 0;) {
      for (int j = 0; j < m - 1; j++) {
        if (i < 0)
          break;
        res += p[i];
        i--;
      }
      i--;
    }

    cout << res << endl;
  }

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

#include <iostream>
#include <string>

using namespace std;

int main() {
  while (1) {
    string r;
    string a;
    cin >> r >> a;
    if ((r == "0") && (a == "0")) {
      break;
    }
    int h = 0, b = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (r[i] == a[j]) {
          if (i == j) {
            h++;
          } else {
            b++;
          }
        }
      }
    }
    cout << h << ' ' << b << '\\n';
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  while (1) {
    string r;
    string a;
    cin >> r >> a;
    if ((r == "0") && (a == "0")) {
      break;
    } else {
      int h = 0, b = 0;
      for (int i; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
          if (r[i] == a[j]) {
            if (i == j) {
              h++;
            } else {
              b++;
            }
          }
        }
      }
      cout << h << ' ' << b << endl;
    }
  }
  return 0;
}
Problem p00226 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
string S, T, U;
int a[4], b[4], h, v;
int main() {
  while (cin >> S >> T) {
    h = 0;
    v = 0;
    if (S == "0") {
      break;
    }
    for (int i = 0; i < 4; i++) {
      U = S[i];
      U += "0";
      a[i] = stoi(U) / 10;
    }
    for (int i = 0; i < 4; i++) {
      U = T[i];
      U += "0";
      b[i] = stoi(U) / 10;
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j]) {
          if (i == j) {
            h++;
          } else {
            v++;
          }
        }
      }
    }
    cout << h << ' ' << v << endl;
  }
}

Error: -6
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
string S, T, U;
int a[4], b[4], h, v;
int main() {
  while (cin >> S >> T) {
    h = 0;
    v = 0;
    if (S == "0") {
      break;
    }
    for (int i = 0; i < 4; i++) {
      U = S[i] + '0';
      a[i] = stoi(U) / 10;
    }
    for (int i = 0; i < 4; i++) {
      U = T[i] + '0';
      b[i] = stoi(U) / 10;
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j]) {
          if (i == j) {
            h++;
          } else {
            v++;
          }
        }
      }
    }
    cout << h << ' ' << v << endl;
  }
}
Problem p00227 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>

int main() {
  int n, m, x;

  while (std::cin >> n >> m) {

    if (n == 0 && m == 0)
      break;

    int flag = 0;
    int num = 0;
    std::vector<int> v;
    std::string line;

    std::getline(std::cin, line);

    if (std::getline(std::cin, line)) {
      std::istringstream ss(line);
      while (ss >> x) {
        v.push_back(x);
      }
    }

    sort(v.rbegin(), v.rend());

    for (int y = 0; y < n; ++y) {
      ++flag;
      if (flag != m) {
        num += v[y];
      } else
        flag = 0;
    }
    std::cout << num << std::endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>
#include <vector>

inline void swap(int *s, int *t) {
  int tmp;
  tmp = *s;
  *s = *t;
  *t = tmp;
}

int main() {
  int n, m, x;
  int flag = 0;
  int num = 0;
  std::vector<int> v;

  std::cin >> n >> m;

  while (std::cin >> x) {
    v.emplace_back(x);
  }

  // std::sort(v.rbegin(),v.rend());が使えなかった

  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      if (v[i] < v[j]) {
        swap(&v[i], &v[j]);
      }
    }
  }

  for (int y = 0; y < n; y++) {
    flag++;
    if (flag != m) {
      num += v[y];
    } else
      flag = 0;
  }
  std::cout << num << std::endl;
}
Problem p00227 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>

int main() {
  std::priority_queue<u_int> prices;
  u_int num_of_item, size_of_bag, price;

  while (1) {
    std::cin >> num_of_item >> size_of_bag;
    if (num_of_item == 0 && size_of_bag == 0)
      break;

    for (u_int i = 0; i < num_of_item; ++i) {
      std::cin >> price;
      prices.push(price);
    }

    u_int sum = 0;
    while (!prices.empty()) {
      for (u_int i = 0; i < size_of_bag; ++i) {
        if (i != size_of_bag - 1) {
          sum += prices.top();
        }
        prices.pop();
        if (prices.empty())
          break;
      }
    }
    std::cout << sum << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <queue>

int main() {
  std::priority_queue<u_int> prices;
  u_int num_of_item, size_of_bag, price;

  while (1) {
    std::cin >> num_of_item >> size_of_bag;
    if (num_of_item == 0 && size_of_bag == 0)
      break;

    for (u_int i = 0; i < num_of_item; ++i) {
      std::cin >> price;
      prices.push(price);
    }

    u_int sum;
    while (!prices.empty()) {
      for (u_int i = 0; i < size_of_bag; ++i) {
        if (i != size_of_bag - 1) {
          sum += prices.top();
        }
        prices.pop();
      }
    }
    std::cout << sum << std::endl;
  }

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

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

int main() {

  int n, m; // 問題文のn,m

  while (std::cin >> n >> m) {
    if (n == 0 && m == 0)
      break;
    std::vector<int> p(n); // 野菜価格一覧
    for (int i = 0; i < n; ++i) {
      std::cin >> p[i];
    }
    sort(p.begin(), p.end());

    reverse(p.begin(), p.end()); // 降順ソート

    for (int i = m - 1; i <= n - 1; i += m) {
      p[i] = 0;
    }
    std::cout << accumulate(p.begin(), p.end(), 0) << std::endl;
  }

  return 0;
}


Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

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

int main() {

  int n, m; // 問題文のn,m

  while (std::cin >> n >> m) {
    if (n == 0 && m == 0)
      break;
    std::vector<int> p(n); // 野菜価格一覧
    for (int i = 0; i < n; ++i) {
      std::cin >> p[i];
    }
    sort(p.begin(), p.end());

    reverse(p.begin(), p.end()); // 降順ソート

    for (int i = m - 1; i < n; i += m) {
      p.erase(p.begin() + i);
    }
    std::cout << accumulate(p.begin(), p.end(), 0) << std::endl;
  }

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

#include <stdio.h>
int main() {

  int N, M;
  int n[1001] = {};

  while (1) {
    int s = 0;
    scanf("%d %d", &N, &M);
    if (N == 0 && M == 0)
      break;

    for (int i = 1; i <= N; i++)
      scanf("%d", &n[i]);

    for (int i = 1; i <= N; i++)
      for (int j = N; j > i; j--)
        if (n[j] > n[j - 1]) {
          int t = n[j - 1];
          n[j - 1] = n[j];
          n[j] = t;
        }

    for (int i = 1; i <= N; i++) {
      if (i % M != 0)
        s += n[i];
    }

    printf("%d\\n", s);
  }

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {

  int N, M;
  int n[1001] = {};

  while (1) {
    int s = 0;
    scanf("%d %d", &N, M);
    if (N == 0 && M == 0)
      break;

    for (int i = 1; i <= N; i++)
      scanf("%d", &n[i]);

    for (int i = 1; i <= N; i++)
      for (int j = N; j > i; j--)
        if (n[j] > n[j - 1]) {
          int t = n[j - 1];
          n[j - 1] = n[j];
          n[j] = t;
        }

    for (int i = 1; i <= N; i++) {
      if (i % M != 0)
        s += n[i];
    }

    printf("%d\\n", s);
  }

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

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

int main() {
  int a, b, i, sum = 0;
  int c[10000];
  while (1) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    for (i = 0; i < a; i++) {
      cin >> c[i];
      sum += c[i];
    }
    sort(c, c + a);
    reverse(c, c + a);
    for (i = b - 1; i < a; i += b) {
      sum -= c[i];
    }
    cout << sum << endl;
    sum = 0;
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int a, b, i, sum = 0;
  int c[a];
  while (1) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    for (i = 0; i < a; i++) {
      cin >> c[i];
      sum += c[i];
    }
    sort(c, c + a);
    reverse(c, c + a);
    for (i = b - 1; i < a; i += b) {
      sum -= c[i];
    }
    cout << sum << endl;
    sum = 0;
  }

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

#include <algorithm>
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>

int main() {

  int purchase_num;
  int max_cap;

  while (std::cin >> purchase_num >> max_cap) {
    if (purchase_num == 0 && max_cap == 0)
      break;
    std::vector<int> price;
    std::string str;
    int input_data;
    int min_price = 0;
    std::cin.ignore();
    std::getline(std::cin, str);
    std::istringstream iss(str);
    while (!iss.eof()) {
      iss >> input_data;
      price.push_back(input_data);
    }
    std::sort(price.begin(), price.end(), std::greater<int>());
    for (int i = 0; i < price.size(); ++i) {
      if ((i + 1) % max_cap != 0) {
        min_price += price[i];
      }
    }
    std::cout << min_price << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>

bool canPurchase(std::bitset<100> bit, int max_cap, int num) {
  int bitcnt = 0;
  for (int i = 0; i < num; ++i) {
    if (bit[i] == 1) {
      ++bitcnt;
      if (!(i >= bitcnt * max_cap - 1)) {
        return false;
      }
    }
  }
  return true;
}

int main() {

  int purchase_num;
  int max_cap;

  while (std::cin >> purchase_num >> max_cap) {
    int max = 0;
    std::string str;
    int input_data;
    std::vector<int> price;
    if (purchase_num == 0 && max_cap == 0)
      break;
    std::cin.ignore();
    std::getline(std::cin, str);
    std::istringstream iss(str);
    while (!iss.eof()) {
      iss >> input_data;
      price.push_back(input_data);
    }
    std::sort(price.begin(), price.end(), std::greater<int>());
    std::bitset<100> select;
    int counter = pow(2.0, price.size() - 2);
    int cnt = purchase_num / max_cap;

    while (counter--) {
      int sum = 0;
      select = static_cast<std::bitset<100>>(counter);
      if (select.count() == cnt) {
        if (canPurchase(select, max_cap, purchase_num)) {
          std::cout << select << std::endl;
          for (int i = 0; i < price.size(); ++i) {
            if (select[i] == 1) {
              // std::cout << sum << std::endl;
              sum += price[i];
            }
          }
          if (max < sum)
            std::swap(max, sum);
        }
      }
    }

    int sum = 0;
    for (int i = 0; i < price.size(); ++i) {
      sum += price[i];
    }
    std::cout << sum - max << std::endl;
  }
  return 0;
}
Problem p00227 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void) {
  while (cin >> n >> m && n && m) {
    vege.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> vege[i];
    }

    sort(vege.begin(), vege.end(), greater<int>());
    int sum = accumulate(vege.begin(), vege.end(), 0);
    for (int i = 1; i - 1 < n / m; i++) {
      sum -= vege[i * m - 1];
    }
    cout << sum << endl;
  }
  return 0;
}

Error: -8

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void) {
  while (cin >> n >> m) {
    vege.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> vege[i];
    }

    sort(vege.begin(), vege.end(), greater<int>());
    int sum = accumulate(vege.begin(), vege.end(), 0);
    for (int i = 1; i - 1 < n / m; i++) {
      sum -= vege[i * m - 1];
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p00227 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, m, fig[1001];
  while (cin >> n >> m, n || m) {
    int ans = 0;
    for (int i = 0; i < n; i++)
      cin >> fig[i];
    sort(fig, fig + n, greater<int>());
    for (int i = 0; i < (n / m) * m; i++) {
      if ((i + 1) % m)
        ans += fig[i];
    }
    for (int i = n - 1, j = 0; j < (n % m); i--, j++)
      ans += fig[i];
    fill(fig, fig + 1001, 0);
    cout << ans << endl;
  }
}

Error: -8

Fixed submission:

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

int main() {
  int n, m, fig[1001];
  while (cin >> n >> m) {
    int ans = 0;
    for (int i = 0; i < n; i++)
      cin >> fig[i];
    sort(fig, fig + n, greater<int>());
    for (int i = 0; i < (n / m) * m; i++) {
      if ((i + 1) % m)
        ans += fig[i];
    }
    for (int i = n - 1, j = 0; j < (n % m); i--, j++)
      ans += fig[i];
    fill(fig, fig + 1001, 0);
    cout << ans << endl;
  }
}
Problem p00227 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  while (1) {
    int sina[1000], n, m, sum = 0;
    scanf("%d%d", &n, &m);
    if (n == 0 && m == 0)
      return 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &sina[i]);
      sum += sina[i];
    }
    sort(sina, sina + n);
    for (int i = n - m; i >= 0; i -= m) {
      sum -= sina[i];
    }
    printf("%d\\n", sum);
  }
}

Error: -11

Fixed submission:

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

int main() {
  while (1) {
    int sina[1000], n, m, sum = 0;
    scanf("%d%d", &n, &m);
    if (n == 0 && m == 0)
      return 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", sina[i]);
      sum += sina[i];
    }
    sort(sina, sina + n);
    for (int i = n; i >= 0; i -= m) {
      sum -= sina[i];
    }
    printf("%d\\n", sum);
  }
}
Problem p00227 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>

#define MAX_NM 1000

int n, m, ans;
int p[MAX_NM];

void solve();

int main() {
  while (true) {
    std::cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; ++i)
      std::cin >> p[i];
    solve();
    std::cout << ans << std::endl;
  }
  return 0;
}

void solve() {
  ans = 0;
  std::sort(p, p + n, std::greater<int>());
  for (int i = 1; i <= n; ++i) {
    if (i % m == 0)
      continue;
    ans += p[i - 1];
  }
  return;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>

#define MAX_NM 1000

int n, m, all;
int p[MAX_NM];

void solve();

int main() {
  while (true) {
    all = 0;
    std::cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; ++i) {
      std::cin >> p[i];
      all += p[i];
    }
    solve();
    std::cout << all << std::endl;
  }
  return 0;
}

void solve() {
  std::sort(p, p + n, std::greater<int>());
  for (int i = 1; i <= n; ++i)
    all -= p[i * m - 1];
  return;
}
Problem p00227 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0, d;
  int p[1100];
  while (1) {
    sum = 0;
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      // sum += p[i];
    }
    sort(p, p + n);
    reverse(p, p + n);
    for (int i = 1; i <= n / m; i++)
      p[i * m - 1] = 0;
    for (int i = 0; i < n; i++)
      sum += p[i];
    /*for(int i=1; i<n+m; i++){
      d = m*i-1;
      sum -= p[d];
    }
    cout << sum << endl;*/
    cout << sum << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0, d;
  int p[3010] = {};
  while (1) {
    sum = 0;
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      sum += p[i];
    }
    sort(p, p + n);
    reverse(p, p + n);
    for (int i = 1; i < n + m; i++) {
      d = m * i - 1;
      sum -= p[d];
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p00228 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  string table[] = {"0111111", "0000110", "1011011", "1001111", "1100110",
                    "1101101", "1111101", "0100111", "1111111", "1101111"};
  int n;
  while (cin >> n, ~n) {
    string cur = "0000000";
    rep(i, n) {
      int number;
      cin >> number;
      rep(i, 7) cout << (cur[i] != table[number][i]);
      cout << endl;
      cur = table[number];
    }
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  string table[] = {"0111111", "0000110", "1011011", "1001111", "1100110",
                    "1101101", "1111101", "1111111", "1101111"};
  int n;
  while (cin >> n, ~n) {
    string cur = "0000000";
    rep(i, n) {
      int number;
      cin >> number;
      rep(i, 7) cout << (cur[i] != table[number][i]);
      cout << endl;
      cur = table[number];
    }
  }
}
Problem p00228 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#pragma warning(disable : 4996)
int n, a[101];
const char c[11][8] = {"0000000", "0111111", "0000110", "1011011",
                       "1001111", "1100110", "1101101", "1111101",
                       "0100111", "1111111", "1101111"};
int main() {
  a[0] = -1;
  while (true) {
    scanf("%d", &n);
    if (n == -1)
      break;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      for (int j = 0; j < 7; j++) {
        if (c[a[i - 1] + 1][j] != c[a[i] + 1][j]) {
          printf("1");
        } else {
          printf("0");
        }
      }
      printf("\\n");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int n, a[101];
const char c[11][8] = {"0000000", "0111111", "0000110", "1011011",
                       "1001111", "1100110", "1101101", "1111101",
                       "0100111", "1111111", "1101111"};
int main() {
  a[0] = -1;
  while (true) {
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      for (int j = 0; j < 7; j++) {
        if (c[a[i - 1] + 1][j] != c[a[i] + 1][j]) {
          printf("1");
        } else {
          printf("0");
        }
      }
      printf("\\n");
    }
  }
  return 0;
}