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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a[3], b[3], dat = 1;

  while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) {
    int h = 0, n = 0;

    for (int j = 0; j < 4; j++) {
      cin >> dat;
      b[j] = dat;
    }
    for (int k = 0; k < 4; k++) {
      if (a[k] == b[k]) {
        h++;
      }

      for (int o = 0; o < 4; o++) {
        if (a[k] != b[k] && a[k] == b[o]) {
          n++;
        }
      }
    }
    cout << h << " " << n << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
  int h = 0, n = 0;
  while (1) {
    int a[3], b[3], dat = 1;
    for (int i = 0; i < 4; i++) {
      cin >> dat;
      a[i] = dat;
    }
    for (int j = 0; j < 4; j++) {
      cin >> dat;
      b[j] = dat;
    }
    if (dat == EOF) {
      break;
    }
    for (int k = 0; k < 4; k++) {
      for (int o = 0; o < 4; o++) {
        if (a[k] == b[k]) {
          h++;
        }
        if (a[k] != b[k] && a[k] == b[o]) {
          n++;
        }
      }
    }
  }
  cout << h << endl;
  cout << n << endl;
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main() {
  int a_num[4];
  int b_num[4];

  while (true) {

    // input a's number.
    for (int i = 0; i < 4; ++i) {
      if (!(std::cin >> a_num[i])) {
        return 0;
      }
    }
    // input b's number.
    for (int i = 0; i < 4; ++i) {
      if (!(std::cin >> b_num[i])) {
        return 0;
      }
    }

    // count hit.
    int hit = 0;
    for (int i = 0; i < 4; ++i) {
      if (a_num[i] == b_num[i]) {
        ++hit;
      }
    }
    std::cout << hit << " ";

    // count blow.
    int blow = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (i != j && b_num[i] == a_num[j]) {
          ++blow;
        }
      }
    }
    std::cout << blow << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:


#include <iostream>

int main() {
  int a_num[4];
  int b_num[4];

  while (true) {

    // input a's number.
    for (int i = 0; i < 4; ++i) {
      std::cin >> a_num[i];
    }
    // input b's number.
    for (int i = 0; i < 4; ++i) {
      std::cin >> b_num[i];
    }

    // count hit.
    int hit = 0;
    for (int i = 0; i < 4; ++i) {
      if (a_num[i] == b_num[i]) {
        ++hit;
      }
    }
    std::cout << hit << " ";

    // count blow.
    int blow = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (b_num[i] == a_num[j]) {
          ++blow;
          break;
        }
      }
    }
    std::cout << blow << std::endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> a(4, 0), b(4, 0);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {

    int hit = 0;
    int blow = 0;
    for (int i = 0; i < a.size(); i++) {
      for (int j = 0; j < b.size(); j++) {
        if (a[i] == b[j]) {
          if (i == j) {
            hit++;
          } else {
            blow++;
          }
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    vector<int> a, b;
    for (int i = 0; i < 4; i++) {
      int tmp;
      cin >> tmp;
      a.push_back(tmp);
    }
    for (int i = 0; i < 4; i++) {
      int tmp;
      cin >> tmp;
      b.push_back(tmp);
    }

    int hit = 0;
    int blow = 0;
    for (int i = 0; i < a.size(); i++) {
      for (int j = 0; j < b.size(); j++) {
        if (a[i] == b[j]) {
          if (i == j) {
            hit++;
          } else {
            blow++;
          }
        }
      }
    }

    cout << hit << " " << blow << endl;
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a[4];
  int b[4];

  int hit;
  int blow;

  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    hit = 0;
    blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j]) {
          if (i == j)
            hit++;
          else
            blow++;
        }
      }
    }
    printf("%d %d\\n", hit, blow);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[4];
  int b[4];

  int hit;
  int blow;

  while (1) {
    hit = 0;
    blow = 0;

    cin >> a[0] >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j]) {
          if (i == j)
            hit++;
          else
            blow++;
        }
      }
    }
  }

  printf("%d %d\\n", hit, blow);

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

#include <iostream>

using namespace std;

int main() {

  int A[5];
  int B[5];

  while (cin >> A[0] >> A[1] >> A[2] >> A[3] >> B[0] >> B[1] >> B[2] >> B[3]) {

    int hit = 0, blow = 0;

    if (A[0] == 0 || A[1] == 0 || A[2] == 0 || A[3] == 0 || B[0] == 0 ||
        B[1] == 0 || B[2] == 0 || B[3] == 0)
      break;

    for (int i = 0; i < 4; i++) {
      if (A[i] == B[i]) {
        hit++;
      }
      for (int j = 0; j < 4; j++) {

        if (A[i] == B[j] && A[i] != B[i]) {
          blow++;
        }
      }
    }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int A[5];
  int B[5];
  int k = 1;

  while (1) {

    int hit = 0, blow = 0;

    for (int i = 0; i < 4; i++) {
      cin >> A[i];
    }

    for (int i = 0; i < 4; i++) {
      cin >> B[i];
    }

    if (A[0] == 0 || A[1] == 0 || A[2] == 0 || A[3] == 0 || B[0] == 0 ||
        B[1] == 0 || B[2] == 0 || B[3] == 0)
      break;

    for (int i = 0; i < 4; i++) {
      if (A[i] == B[i]) {
        hit++;
      }
      for (int j = 0; j < 4; j++) {

        if (A[i] == B[j] && A[i] != B[i]) {
          blow++;
        }
      }
    }

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

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

#include <iostream>

int main(int argc, char **argv) {
  int a[4];
  int b[4];
  while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    std::cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) {
        hit++;
      } else {
        for (int j = 0; j < 4; j++) {
          if (a[i] == b[j]) {
            blow++;
          }
        }
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int main(int argc, char **argv) {
  while (true) {
    int a[4];
    int b[4];
    std::cin >> a[0] >> a[1] >> a[2] >> a[3];
    std::cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) {
        hit++;
      } else {
        for (int j = 0; j < 4; j++) {
          if (a[i] == b[j]) {
            blow++;
          }
        }
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int num[4], tmp[4], hit, blow;

  while (1) {
    hit = 0;
    blow = 0;

    cin >> num[0] >> num[1] >> num[2] >> num[3];
    cin >> tmp[0] >> tmp[1] >> tmp[2] >> tmp[3];
    if (cin.eof())
      break;

    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (num[i] == tmp[j]) {
          if (i == j)
            hit++;
          else
            blow++;
        }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int numA[4], numB[4], tmpA[4], tmpB[4], hit = 0, blow = 0;

  cin >> numA[0] >> numA[1] >> numA[2] >> numA[3];
  cin >> numB[0] >> numB[1] >> numB[2] >> numB[3];

  while (1) {
    hit = 0;
    blow = 0;
    cin >> tmpA[0] >> tmpA[1] >> tmpA[2] >> tmpA[3];
    for (int i = 0; i < 4; i++)
      if (tmpA[i] == numB[i])
        hit++;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (i != j && tmpA[i] == numB[j])
          blow++;
    cout << hit << " " << blow << endl;

    hit = 0;
    blow = 0;
    cin >> tmpB[0] >> tmpB[1] >> tmpB[2] >> tmpB[3];
    for (int i = 0; i < 4; i++)
      if (tmpB[i] == numA[i])
        hit++;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (i != j && tmpB[i] == numA[j])
          blow++;

    cout << hit << " " << blow << endl;
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

bool d[12];

int a[4];
int b[4];

int main() {
  while (1 == scanf("%d", a)) {
    for (int i = 1; i < 4; i++) {
      scanf("%d", a + i);
    }
    for (int i = 0; i < 4; i++) {
      scanf("%d", b + i);
    }
    for (auto &i : d) {
      i = false;
    }
    for (auto i : a) {
      d[i] = true;
    }
    int hi = 0;
    int bu = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) {
        hi++;
      } else if (d[b[i]]) {
        bu++;
      }
    }
    printf("%d %d\\n", hi, bu);
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>

bool d[12];

int a[4];
int b[4];

int main() {
  while (0 != scanf("%d", a)) {
    for (int i = 1; i < 4; i++) {
      scanf("%d", a + i);
    }
    for (int i = 0; i < 4; i++) {
      scanf("%d", b + i);
    }
    for (auto &i : d) {
      i = false;
    }
    for (auto i : a) {
      d[i] = true;
    }
    int hi = 0;
    int bu = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) {
        hi++;
      } else if (d[b[i]]) {
        bu++;
      }
    }
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
// #include <bits/stdc++.h>

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\\n");
#define mod 1000000007

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(4, 0), b(4, 0);

  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int hit = 0, blow = 0;
    rep(i, 4) { cin >> b[i]; }
    rep(i, 4) {
      if (a[i] == b[i]) {
        hit += 1;
      }
    }
    rep(i, 4) { blow += count(all(b), a[i]); }
    printf("%d %d\\n", hit, blow - hit);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
// #include <bits/stdc++.h>

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\\n");
#define mod 1000000007

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (1) {
    vector<int> a(4, 0), b(4, 0);
    int hit = 0, blow = 0;
    rep(i, 4) { cin >> a[i]; }
    rep(i, 4) { cin >> b[i]; }
    rep(i, 4) {
      if (a[i] == b[i]) {
        hit += 1;
      }
    }
    rep(i, 4) { blow += count(all(b), a[i]); }
    printf("%d %d\\n", hit, blow - hit);
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
int main() {
  int n;
  while (std::cin >> n) {
    int input[4];
    input[0] = n;
    for (int i = 1; i < 4; ++i) {
      std::cin >> input[i];
    }
    int answer[4];
    for (int i = 0; i < 4; ++i) {
      std::cin >> answer[i];
    }
    int e = 0, b = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (input[i] == answer[j]) {
          if (i == j)
            ++e;
          else
            ++b;
          break;
        }
      }
    }
    std::cout << e << " " << b << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
int main() {
  while (1) {
    int input[4];
    for (int i = 0; i < 4; ++i) {
      std::cin >> input[i];
    }
    int answer[4];
    for (int i = 0; i < 4; ++i) {
      std::cin >> answer[i];
    }
    int e = 0, b = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (input[i] == answer[j]) {
          if (i == j)
            ++e;
          else
            ++b;
          break;
        }
      }
    }
    std::cout << e << " " << b << std::endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <array>
#include <iostream>

int main() {
  std::array<int, 4> a;
  std::array<int, 4> b;
  int hit = 0;
  int blow = 0;

  while (std::cin >> a[0] >> a[1] >> a[2] >> a[3] &&
         std::cin >> b[0] >> b[1] >> b[2] >> b[3]) {
    // std::cin >> a[0] >> a[1] >> a[2] >> a[3];
    // std::cin >> b[0] >> b[1] >> b[2] >> b[3];

    for (int i = 0; i < 4; ++i) {
      if (a[i] == b[i]) {
        ++hit;
      } else {
        for (int j = 0; j < 4; ++j) {
          if (a[i] == b[j] && i != j) {
            ++blow;
          }
        }
      }
    }

    std::cout << hit << " " << blow << std::endl;

    hit = 0;
    blow = 0;
  }
}

Error: TLE

Fixed submission:

#include <array>
#include <iostream>

int main() {
  std::array<int, 4> a;
  std::array<int, 4> b;
  int hit = 0;
  int blow = 0;

  while (true) {
    std::cin >> a[0] >> a[1] >> a[2] >> a[3];
    std::cin >> b[0] >> b[1] >> b[2] >> b[3];

    for (int i = 0; i < 4; ++i) {
      if (a[i] == b[i]) {
        ++hit;
      } else {
        for (int j = 0; j < 4; ++j) {
          if (a[i] == b[j] && i != j) {
            ++blow;
          }
        }
      }
    }

    std::cout << hit << " " << blow << std::endl;
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main() {
  int a[4], b[4];
  while (std::cin >> a[0]) {
    int hit = 0, blow = 0;
    for (int i = 1; i < 4; i++)
      std::cin >> a[i];
    for (int i = 0; i < 4; i++)
      std::cin >> b[i];
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j]) {
          if (i == j)
            hit++;
          else
            blow++;
        }
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int main() {
  while (true) {
    int hit = 0, blow = 0, data[2][4];
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 4; j++) {
        std::cin >> data[i][j];
      }
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (data[0][i] == data[1][j]) {
          if (i == j)
            hit++;
          else
            blow++;
        }
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

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

int dx[] = {0, 1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0};
int dy[] = {0, 0, 1, 0, -1, -1, 1, 1, -1, 0, 2, 0, -2};

int main() {
  int map[10][10];
  memset(map, 0, sizeof(map));
  int x, y, d;
  char c;

  while (cin >> x >> c >> y >> c >> d) {
    for (int i = 0; i <= 4 * d; i++) {
      int tx = x + dx[i];
      int ty = y + dy[i];
      if (0 <= tx && tx < 10 && 0 <= ty && ty <= 10)
        map[ty][tx]++;
    }
  }

  int cnt = 0;
  int MAX = 0;
  for (int i = 0; i < 10; i++)
    for (int k = 0; k < 10; k++)
      if (map[i][k] == 0)
        cnt++;
      else if (map[i][k] > MAX)
        MAX = map[i][k];

  cout << cnt << endl;
  cout << MAX << endl;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int dx[12] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0};
int dy[12] = {0, 1, 0, -1, -1, 1, 1, -1, 0, 2, 0, -2};
int map[10][10];

inline bool out_of_range(int x, int y) {
  if (x < 0 || x > 9 || y < 0 || y > 9)
    return false;
  return true;
}

inline void drop(int x, int y, int s) {
  for (int i = 0; i < 4 * s; i++)
    map[y + dy[i]][x + dx[i]]++;
}

int main() {
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      map[i][j] = 0;
  int x, y, s;
  char c;
  while (cin >> x >> c >> y >> c >> s) {
    drop(x, y, s);
  }

  int cnt = 0, dep = 0;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) {
      if (map[j][i] == 0)
        cnt++;
      if (map[j][i] > dep)
        dep = map[j][i];
    }
  cout << cnt << endl << dep << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int paper[10][10];

void drop(int x, int y) {
  if (x >= 0 && x < 10 && y >= 0 && y < 10) {
    paper[x][y]++;
  }
}

int main() {
  int x1, y1, size;
  char temp;
  int zeroDensity = 0, maxDensity = 0;

  for (int i = 0; i != 10; ++i) {
    for (int j = 0; j != 10; ++j) {
      paper[i][j] = 0;
    }
  }

  while (cin >> x1 >> temp >> y1 >> temp >> size) {
    switch (size) {
    case 1:
      drop(x1, y1);     // center
      drop(x1, y1 - 1); // top
      drop(x1 + 1, y1); // right
      drop(x1, y1 + 1); // bottom
      drop(x1 - 1, y1); // left
      break;
    case 2:
      for (int i = -1; i != 2; ++i) {
        drop(x1 + i, y1 - 1);
      }
      for (int i = -1; i != 2; ++i) {
        drop(x1 + i, y1);
      }
      for (int i = -1; i != 2; ++i) {
        drop(x1 + i, y1 + 1);
      }
      break;
    case 3:
      for (int i = -1; i != 2; ++i) {
        drop(x1 + i, y1 - 1);
      }
      for (int i = -1; i != 2; ++i) {
        drop(x1 + i, y1);
      }
      for (int i = -1; i != 2; ++i) {
        drop(x1 + i, y1 + 1);
      }
      drop(x1, y1 - 2); // top
      drop(x1 + 2, y1); // right
      drop(x1, y1 + 2); // bottom
      drop(x1 - 2, y1); // left
      break;
    }
  }

  for (int i = 0; i != 10; ++i) {
    for (int j = 0; j != 10; ++j) {
      if (paper[i][j] == 0) {
        ++zeroDensity;
      }
      if (paper[i][j] > maxDensity) {
        maxDensity = paper[i][j];
      }
    }
  }
  cout << zeroDensity << endl;
  cout << maxDensity << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x1, y1, size;
  char temp;
  int zeroDensity = 0, maxDensity = 0;
  int paper[10][10];

  for (int i = 0; i != 10; ++i) {
    for (int j = 0; j != 10; ++j) {
      paper[i][j] = 0;
    }
  }

  while (cin >> x1 >> temp >> y1 >> temp >> size) {
    switch (size) {
    case 1:
      paper[x1][y1]++;     // center
      paper[x1][y1 - 1]++; // top
      paper[x1 + 1][y1]++; // right
      paper[x1][y1 + 1]++; // bottom
      paper[x1 - 1][y1]++; // left
      break;
    case 2:
      for (int i = -1; i != 2; ++i) {
        paper[x1 + i][y1 - 1]++;
      }
      for (int i = -1; i != 2; ++i) {
        paper[x1 + i][y1]++;
      }
      for (int i = -1; i != 2; ++i) {
        paper[x1 + i][y1 + 1]++;
      }
      break;
    case 3:
      for (int i = -1; i != 2; ++i) {
        paper[x1 + i][y1 - 1]++;
      }
      for (int i = -1; i != 2; ++i) {
        paper[x1 + i][y1]++;
      }
      for (int i = -1; i != 2; ++i) {
        paper[x1 + i][y1 + 1]++;
      }
      paper[x1][y1 - 2]++; // top
      paper[x1 + 2][y1]++; // right
      paper[x1][y1 + 2]++; // bottom
      paper[x1 - 2][y1]++; // left
      break;
    }
  }

  for (int i = 0; i != 10; ++i) {
    for (int j = 0; j != 10; ++j) {
      if (paper[i][j] == 0) {
        ++zeroDensity;
      }
      if (paper[i][j] > maxDensity) {
        maxDensity = paper[i][j];
      }
    }
  }
  cout << zeroDensity << endl;
  cout << maxDensity << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;

void solve() {
  int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0};
  int dy[] = {0, -1, 0, 1, 1, -1, 1, -1, 0, -2, 0, 2};
  int field[10][10] = {0};
  int x, y, size;
  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    ++field[x][y];
    int n = 4 * size;
    for (int i = 0; i < n; ++i) {
      if ((0 <= x + dx[i] && x + dx[i] < 10) &&
          (0 <= y + dy[i] && y + dy[i] < 10)) {
        ++field[x + dx[i]][y + dy[i]];
      }
    }
  }
  int count = 0;
  int max = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      if (field[i][j] >= 1) {
        ++count;
      }
      if (field[i][j] > max) {
        max = field[i][j];
      }
    }
  }
  cout << 100 - count << endl;
  cout << max << endl;
}

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

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

void solve() {
  int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0};
  int dy[] = {0, -1, 0, 1, 1, -1, 1, -1, 0, -2, 0, 2};
  int field[10][10] = {0};
  int x, y, size;
  while (scanf("%d,%d,%d", &x, &y, &size)) {
    ++field[x][y];
    int n = 4 * size;
    for (int i = 0; i < n; ++i) {
      if ((0 <= x + dx[i] && x + dx[i] < 10) &&
          (0 <= y + dy[i] && y + dy[i] < 10)) {
        ++field[x + dx[i]][y + dy[i]];
      }
    }
  }
  int count = 0;
  int max = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      if (field[i][j] >= 1) {
        ++count;
      }
      if (field[i][j] > max) {
        max = field[i][j];
      }
    }
  }
  cout << 100 - count << endl;
  cout << max << endl;
}

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