alexjercan/bugnet huggingface dataset:
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int xy[15][15] = {};
int main() {
  int x, y, s, i, j, num = 0;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    if (s == 1) {
      xy[x][y]++;
      xy[x - 1][y]++;
      xy[x + 1][y]++;
      xy[x][y - 1]++;
      xy[x][y + 1]++;
    } else if (s == 2) {
      xy[x - 1][y - 1]++;
      xy[x - 1][y]++;
      xy[x - 1][y + 1]++;
      xy[x][y - 1]++;
      xy[x][y]++;
      xy[x][y + 1]++;
      xy[x + 1][y - 1]++;
      xy[x + 1][y]++;
      xy[x + 1][y + 1]++;
    } else if (s == 3) {
      xy[x - 2][y]++;
      xy[x - 1][y - 1]++;
      xy[x - 1][y]++;
      xy[x - 1][y + 1]++;
      xy[x][y - 2]++;
      xy[x][y - 1]++;
      xy[x][y]++;
      xy[x][y + 1]++;
      xy[x][y + 2]++;
      xy[x + 1][y - 1]++;
      xy[x + 1][y]++;
      xy[x + 1][y + 1]++;
      xy[x + 2][y]++;
    }
  }
  int max = xy[0][0];
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      if (xy[i][j] == 0)
        num++;
      if (xy[i][j] > max)
        max = xy[i][j];
    }
  }
  printf("%d\\n%d\\n", num, max);
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

void big(int a[10][10], int x, int y);
void mid(int a[10][10], int x, int y);
void sma(int a[10][10], int x, int y);

int main() {
  int a[10][10] = {0};
  int s, x, y;
  char c;
  while (cin >> x >> c >> y >> c >> s) {
    if (s == 1) {
      sma(a, x, y);
    }
    if (s == 2) {
      mid(a, x, y);
    }
    if (s == 3) {
      big(a, x, y);
    }
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        //		cout<<a[i][j];
      }
      //		cout<<endl;
    }
    //	cout<<endl<<x<<y<<s<<endl;
    //	cout<<endl;
  }
  int max = 0;
  int cnt = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (a[i][j] == 0)
        cnt++;
      if (a[i][j] > max)
        max = a[i][j];
    }
  }
  cout << cnt << endl;
  cout << max << endl;
}

void big(int a[10][10], int x, int y) {
  mid(a, x, y);
  a[x + 2][y]++;
  a[x - 2][y]++;
  a[x][y + 2]++;
  a[x][y - 2]++;
}
void mid(int a[10][10], int x, int y) {
  sma(a, x, y);
  a[x + 1][y + 1]++;
  a[x + 1][y - 1]++;
  a[x - 1][y + 1]++;
  a[x - 1][y - 1]++;
}
void sma(int a[10][10], int x, int y) {
  a[x][y]++;
  a[x + 1][y]++;
  a[x - 1][y]++;
  a[x][y + 1]++;
  a[x][y - 1]++;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int x, y, size;
  int canvas[10][10];
  int emp, max;
  char comma;
  int i, j;

  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++)
      canvas[i][j] = 0;
  }
  while (cin >> x >> comma >> y >> comma >> size) {
    canvas[x][y]++;
    if (x > 0)
      canvas[x - 1][y]++;
    if (x < 9)
      canvas[x + 1][y]++;
    if (y > 0)
      canvas[x][y - 1]++;
    if (y < 9)
      canvas[x][y + 1]++;
    if (size > 1) {
      for (i = -1; i <= 1; i += 2) {
        for (j = -1; j <= 1; j += 2) {
          if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9)
            canvas[x + i][y + j]++;
        }
      }
    }
    if (size > 2) {
      if (x > 1)
        canvas[x - 2][y]++;
      if (x < 8)
        canvas[x + 2][y]++;
      if (y > 1)
        canvas[x][y - 2]++;
      if (y < 8)
        canvas[x][y + 2]++;
    }
  }
  emp = 0;
  max = 0;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      if (canvas[i][j] == 0)
        emp++;
      if (max < canvas[i][j])
        max = canvas[i][j];
    }
  }
  printf("%d\\n%d\\n", emp, max);

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, y, size;
  int canvas[10][10];
  int emp, max;
  int i, j;

  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++)
      canvas[i][j] = 0;
  }
  while (cin >> x) {
    cin >> y;
    cin >> size;

    if (x > 0)
      canvas[x - 1][y]++;
    if (x < 9)
      canvas[x + 1][y]++;
    if (y > 0)
      canvas[x][y - 1]++;
    if (y < 9)
      canvas[x][y + 1]++;
    if (size > 1) {
      for (i = -1; i <= 1; i += 2) {
        for (j = -1; j <= 1; j += 2) {
          if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9)
            canvas[x + i][y + j]++;
        }
      }
    }
    if (size > 2) {
      if (x > 1)
        canvas[x - 2][y]++;
      if (x < 8)
        canvas[x + 2][y]++;
      if (y > 1)
        canvas[x][y - 2]++;
      if (y < 8)
        canvas[x][y + 2]++;
    }
  }
  emp = 0;
  max = 0;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      if (canvas[i][j] == 0)
        emp++;
      if (max < canvas[i][j])
        max = canvas[i][j];
    }
  }
  printf("%d\\n%d\\n", emp, max);

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

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

int main() {
  int area[14][14] = {0};
  int x, nx, ny, y, size;
  int count = 0;
  int max = 0;
  char ch1, ch2;
  while (cin >> x >> ch1 >> y >> ch2 >> size) {
    nx = x + 2;
    ny = y + 2;
    switch (size) {
    case 3:
      area[nx - 2][ny]++;
      area[nx + 2][ny]++;
      area[nx][ny - 2]++;
      area[nx][ny + 2]++;
    case 2:
      area[nx - 1][ny - 1]++;
      area[nx + 1][ny - 1]++;
      area[nx - 1][ny + 1]++;
      area[nx + 1][ny + 1]++;
    case 1:
      area[nx - 1][ny]++;
      area[nx + 1][ny]++;
      area[nx][ny - 1]++;
      area[nx][ny + 1]++;
    }
    area[nx][ny]++;
  }

  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      if (area[i][j] == 0) {
        count++;
      }
      if (max < area[i][j]) {
        max = area[i][j];
      }
    }
  }

  cout << count << endl;
  cout << max << endl;

  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int area[10][10] = {0};
  int x, nx, ny, y, size;
  int count = 0;
  int max = 0;
  char ch1, ch2;
  while (cin >> x >> ch1 >> y >> ch2 >> size) {
    nx = x + 2;
    ny = y + 2;
    switch (size) {
    case 3:
      area[nx - 2][ny]++;
      area[nx + 2][ny]++;
      area[nx][ny - 2]++;
      area[nx][ny + 2]++;
    case 2:
      area[nx - 1][ny - 1]++;
      area[nx + 1][ny - 1]++;
      area[nx - 1][ny + 1]++;
      area[nx + 1][ny + 1]++;
    case 1:
      area[nx - 1][ny]++;
      area[nx + 1][ny]++;
      area[nx][ny - 1]++;
      area[nx][ny + 1]++;
    }
    area[nx][ny]++;
  }

  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      if (area[i][j] == 0) {
        count++;
      }
      if (max < area[i][j]) {
        max = area[i][j];
      }
    }
  }

  cout << count << endl;
  cout << max << endl;

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

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)

int f[10][10];

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

int main() {
  int x, y, size;
  while (scanf("%d,%d,%d", &x, &y, &size) != -1) {
    int x2, y2;
    switch (size) {
    case 1:
      f[y][x]++;
      REP(i, 4) {
        x2 = x + dx[i];
        y2 = y + dy[i];
        if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
          f[y2][x2]++;
        }
      }
      break;
    case 2:
      FOR(i, -1, 2) {
        FOR(j, -1, 2) {
          x2 = x + i;
          y2 = y + j;
          if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
            f[y2][x2]++;
          }
        }
      }
      break;
    case 3:
      FOR(i, -1, 2) {
        FOR(j, -1, 2) {
          x2 = x + i;
          y2 = y + j;
          if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
            f[y2][x2]++;
          }
        }
      }
      REP(i, 4) {
        x2 = x + dx[i] * 2;
        y2 = y + dy[i] * 2;
        if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
          f[y2][x2]++;
        }
      }
      break;
    }
  }
  int e = 0;
  int m = 0;
  REP(i, 10) {
    REP(j, 10) { m = max(m, f[i][j]); }
  }
  REP(i, 10) {
    REP(j, 10) {
      if (f[i][j] == 0) {
        e++;
      }
    }
  }
  printf("%d\\n%d\\n", e, m);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)

int f[10][10];

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

int main() {
  int x, y, size;
  while (scanf("%d,%d,%d", &x, &y, &size)) {
    int x2, y2;
    switch (size) {
    case 1:
      f[y][x]++;
      REP(i, 4) {
        x2 = x + dx[i];
        y2 = y + dy[i];
        if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
          f[y2][x2]++;
        }
      }
      break;
    case 2:
      FOR(i, -1, 2) {
        FOR(j, -1, 2) {
          x2 = x + i;
          y2 = y + j;
          if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
            f[y2][x2]++;
          }
        }
      }
      break;
    case 3:
      FOR(i, -1, 2) {
        FOR(j, -1, 2) {
          x2 = x + i;
          y2 = y + j;
          if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
            f[y2][x2]++;
          }
        }
      }
      REP(i, 4) {
        x2 = x + dx[i] * 2;
        y2 = y + dy[i] * 2;
        if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
          f[y2][x2]++;
        }
      }
      break;
    }
  }
  int e = 0;
  int m = 0;
  REP(i, 10) {
    REP(j, 10) { m = max(m, f[i][j]); }
  }
  REP(i, 10) {
    REP(j, 10) {
      if (f[i][j] == 0) {
        e++;
      }
    }
  }
  printf("%d\\n%d\\n", e, m);
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int x, y, s;
  char c;
  vector<vector<int>> v(14, vector<int>(14, 0));
  while (cin >> x >> c >> y >> c >> s) {
    x += 2;
    y += 2;
    switch (s) {
    case 3:
      v[x][y - 2]++;
      v[x][y + 2]++;
      v[x - 2][y]++;
      v[x + 2][y]++;
    case 2:
      v[x - 1][y - 1]++;
      v[x - 1][y + 1]++;
      v[x + 1][y - 1]++;
      v[x + 1][y + 1]++;
    case 1:
      v[x + 1][y]++;
      v[x - 1][y]++;
      v[x][y - 1]++;
      v[x][y + 1]++;
      v[x][y]++;
      break;
    }
  }

  int mx = 0, cnt = 0;
  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      mx = max(mx, v[i][j]);
      if (v[i][j] == 0)
        cnt++;
    }
  }
  cout << cnt << "\\n" << mx << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int x, y, s;
  char c;
  vector<vector<int>> v(13, vector<int>(13, 0));
  while (cin >> x >> c >> y >> c >> s) {
    x += 2;
    y += 2;
    switch (s) {
    case 3:
      v[x][y - 2]++;
      v[x][y + 2]++;
      v[x - 2][y]++;
      v[x + 2][y]++;
    case 2:
      v[x - 1][y - 1]++;
      v[x - 1][y + 1]++;
      v[x + 1][y - 1]++;
      v[x + 1][y + 1]++;
    case 1:
      v[x + 1][y]++;
      v[x - 1][y]++;
      v[x][y - 1]++;
      v[x][y + 1]++;
      break;
    }
  }

  int mx = 0, cnt = 0;
  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      mx = max(mx, v[i][j]);
      if (v[i][j] == 0)
        cnt++;
    }
  }
  cout << cnt << "\\n" << mx << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<vector<int>> a(15, vector<int>(15, 0));
  int c, d, size, o = 0;
  char s1, s2;
  while (cin >> c >> s1 >> d >> s2 >> size) {
    c += 3;
    d += 3;
    if (size == 1) {
      a[c][d]++;
      a[c][d - 1]++;
      a[c - 1][d]++;
      a[c + 1][d]++;
      a[c][d + 1]++;
    }
    if (size == 2) {
      a[c][d]++;
      a[c][d - 1]++;
      a[c - 1][d]++;
      a[c + 1][d]++;
      a[c][d + 1]++;
      a[c - 1][d - 1]++;
      a[c + 1][d + 1]++;
      a[c - 1][d + 1]++;
      a[c + 1][d - 1]++;
    }
    if (size == 3) {
      a[c][d]++;
      a[c][d - 1]++;
      a[c - 1][d]++;
      a[c + 1][d]++;
      a[c][d + 1]++;
      a[c - 1][d - 1]++;
      a[c + 1][d + 1]++;
      a[c - 1][d + 1]++;
      a[c + 1][d - 1]++;
      a[c + 2][d]++;
      a[c - 2][d]++;
      a[c][d + 2]++;
      a[c][d - 2]++;
    }
  }
  int maxi = 0;
  for (int i = 3; i < 13; i++) {
    int d = *max_element(a[i].begin(), a[i].end());
    maxi = max(maxi, d);
    for (int j = 3; j < 13; j++) {
      if (a[j][i] == 0)
        o++;
    }
  }
  cout << o << endl << maxi << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<vector<int>> a(13, vector<int>(13, 0));
  int c, d, size, o = 0;
  char s1, s2;
  while (cin >> c >> s1 >> d >> s2 >> size) {
    c += 2;
    d += 2;
    if (size == 1) {
      a[c][d]++;
      a[c][d - 1]++;
      a[c - 1][d]++;
      a[c + 1][d]++;
      a[c][d + 1]++;
    }
    if (size == 2) {
      a[c][d]++;
      a[c][d - 1]++;
      a[c - 1][d]++;
      a[c + 1][d]++;
      a[c][d + 1]++;
      a[c - 1][d - 1]++;
      a[c + 1][d + 1]++;
      a[c - 1][d + 1]++;
      a[c + 1][d - 1]++;
    }
    if (size == 3) {
      a[c][d]++;
      a[c][d - 1]++;
      a[c - 1][d]++;
      a[c + 1][d]++;
      a[c][d + 1]++;
      a[c - 1][d - 1]++;
      a[c + 1][d + 1]++;
      a[c - 1][d + 1]++;
      a[c + 1][d - 1]++;
      a[c + 2][d]++;
      a[c - 2][d]++;
      a[c][d + 2]++;
      a[c][d - 2]++;
    }
  }
  int maxi = 0;
  for (int i = 2; i < 12; i++) {
    int d = *max_element(a[i].begin(), a[i].end());
    maxi = max(maxi, d);
    for (int j = 2; j < 12; j++) {
      if (a[j][i] == 0)
        o++;
    }
  }
  cout << o << endl << maxi << endl;
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

void drop1(int s[][14], int x, int y) {
  s[x][y]++;
  s[x - 1][y]++;
  s[x][y - 1]++;
  s[x + 1][y]++;
  s[x][y + 1]++;
}

void drop2(int s[][14], int x, int y) {
  drop1(s, x, y);
  s[x - 1][y - 1]++;
  s[x + 1][y - 1]++;
  s[x - 1][y + 1]++;
  s[x + 1][y + 1]++;
}

void drop3(int s[][14], int x, int y) {
  drop2(s, x, y);
  s[x - 2][y]++;
  s[x][y - 2]++;
  s[x + 2][y]++;
  s[x][y + 2]++;
}

int main() {
  int square[14][14] = {0};
  int x, y, s, mx = 0, cnt = 0;
  char c;
  while (cin >> x >> c >> y >> c >> s) {
    switch (s) {
    case 1:
      drop1(square, x + 2, y + 2);
      break;
    case 2:
      drop2(square, x + 2, y + 2);
      break;
    case 3:
      drop3(square, x + 2, y + 2);
    }
  }
  for (int i = 2; i < 12; ++i) {
    for (int j = 2; j < 12; ++j) {
      if (square[i][j] == 0)
        cnt++;
      mx = max(mx, square[i][j]);
    }
  }
  cout << cnt << endl << mx << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

void drop1(int s[][14], int x, int y) {
  s[x][y]++;
  s[x - 1][y]++;
  s[x][y - 1]++;
  s[x + 1][y]++;
  s[x][y + 1]++;
}

void drop2(int s[][14], int x, int y) {
  drop1(s, x, y);
  s[x - 1][y - 1]++;
  s[x + 1][y - 1]++;
  s[x - 1][y + 1]++;
  s[x + 1][y + 1]++;
}

void drop3(int s[][14], int x, int y) {
  drop2(s, x, y);
  s[x - 2][y]++;
  s[x][y - 2]++;
  s[x + 2][y]++;
  s[x][y + 2]++;
}

int main() {
  int square[14][14] = {0};
  int x, y, s, mx = 0, cnt = 0;
  while (scanf("%d,%d,%d", &x, &y, &s)) {
    switch (s) {
    case 1:
      drop1(square, x + 2, y + 2);
      break;
    case 2:
      drop2(square, x + 2, y + 2);
      break;
    case 3:
      drop3(square, x + 2, y + 2);
    }
  }
  for (int i = 2; i < 12; ++i) {
    for (int j = 2; j < 12; ++j) {
      if (square[i][j] == 0)
        cnt++;
      mx = max(mx, square[i][j]);
    }
  }
  cout << cnt << endl << mx << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int paper[10][10];

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

void drop_small(int x, int y) {
  paper[y][x]++;
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] >= 10 || x + dx[i] >= 10)
      continue;
    if (y + dy[i] < 0 || x + dx[i] < 0)
      continue;
    paper[y + dy[i]][x + dx[i]]++;
  }
}

void drop_middle(int x, int y) {
  drop_small(x, y);
  int dx[4] = {1, 1, -1, -1}, dy[4] = {1, -1, 1, -1};
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] >= 10 || x + dx[i] >= 10)
      continue;
    if (y + dy[i] < 0 || x + dx[i] < 0)
      continue;
    paper[y + dy[i]][x + dx[i]]++;
  }
}

void drop_large(int x, int y) {
  drop_middle(x, y);
  int dx[4] = {2, 0, -2, 0}, dy[4] = {0, 2, 0, -2};
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] >= 10 || x + dx[i] >= 10)
      continue;
    if (y + dy[i] < 0 || x + dx[i] < 0)
      continue;
    paper[y + dy[i]][x + dx[i]]++;
  }
}

int main() {
  init();
  int x, y, s;
  char d;
  while (cin >> x >> d >> y >> d >> s) {
    switch (s) {
    case 1:
      drop_small(x, y);
      break;
    case 2:
      drop_middle(x, y);
      break;
    case 3:
      drop_large(x, y);
      break;
    }
  }

  int most = 0;
  int clean = 0;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (paper[i][j] == 0)
        clean++;
      if (paper[i][j] > most)
        most = paper[i][j];
    }
  }

  cout << clean << endl;
  cout << most << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int paper[10][10];

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

void drop_small(int x, int y) {
  paper[y][x]++;
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] == 10 || x + dx[i] == 10)
      continue;
    paper[y + dy[i]][x + dx[i]]++;
  }
}

void drop_middle(int x, int y) {
  drop_small(x, y);
  int dx[4] = {1, 1, -1, -1}, dy[4] = {1, -1, 1, -1};
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] == 10 || x + dx[i] == 10)
      continue;
    paper[y + dy[i]][x + dx[i]]++;
  }
}

void drop_large(int x, int y) {
  drop_middle(x, y);
  int dx[4] = {2, 0, -2, 0}, dy[4] = {0, 2, 0, -2};
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] == 10 || x + dx[i] == 10)
      continue;
    paper[y + dy[i]][x + dx[i]]++;
  }
}

int main() {
  init();
  int x, y, s;
  char d;
  while (cin >> x >> d >> y >> d >> s) {
    switch (s) {
    case 1:
      drop_small(x, y);
      break;
    case 2:
      drop_middle(x, y);
      break;
    case 3:
      drop_large(x, y);
      break;
    }
  }

  int most = 0;
  int clean = 0;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (paper[i][j] == 0)
        clean++;
      if (paper[i][j] > most)
        most = paper[i][j];
    }
  }

  cout << clean << endl;
  cout << most << endl;

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

#include <stdio.h>

int field[15][15];

int main(void) {
  int x, y;
  int size;
  int sum = 0, max = 0;

  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    y += 2;
    x += 2;

    if (size > 0) {
      field[y][x]++;
      field[y - 1][x]++;
      field[y + 1][x]++;
      field[y][x + 1]++;
      field[y][x - 1]++;
    }
    if (size > 1) {
      field[y - 1][x - 1]++;
      field[y + 1][x + 1]++;
      field[y - 1][x + 1]++;
      field[y + 1][x - 1]++;
    }
    if (size > 2) {
      field[y - 2][x]++;
      field[y + 2][x]++;
      field[y][x - 2]++;
      field[y][x + 2]++;
    }
  }

  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {

      if (field[i][j] == 0) {
        sum++;
      }
      if (field[i][j] > max) {
        max = field[i][j];
      }
    }
  }

  printf("%d\\n%d\\n", sum, max);

  return (0);
}

Error: TLE

Fixed submission:

#include <stdio.h>

int field[15][15];

int main(void) {
  int x, y;
  int size;
  int sum = 0, max = 0;

  while (scanf("%d %d %d", &x, &y, &size) != EOF) {

    if (size > 0) {
      field[y + 2][x + 2]++;
      field[y + 3][x + 2]++;
      field[y + 2][x + 3]++;
      field[y + 2][x + 1]++;
      field[y + 2][x + 2]++;
    }
    if (size > 1) {
      field[y + 1][x + 1]++;
      field[y + 3][x + 3]++;
      field[y + 1][x + 3]++;
      field[y + 3][x + 1]++;
    }
    if (size > 2) {
      field[y][x + 2]++;
      field[y + 4][x + 2]++;
      field[y + 2][x]++;
      field[y + 2][x + 4]++;
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (field[i][j] == 0) {
        sum++;
      }
      if (field[i][j] > max) {
        max = field[i][j];
      }
    }
  }
  return (0);
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

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

int main() {
  int xy[10][10] = {0};
  int x, y, size;

  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    if (size < 4) {
      for (int d = 0; d < 1 + size * 4; d++) {
        int nx, ny;
        nx = x + dx[d];
        ny = y + dy[d];
        if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) {
          xy[nx][ny] += 1;
        }
      }
    }
  }
  int w = 0, con = 0;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (xy[i][j] == 0)
        w++;
      if (con < xy[i][j])
        con = xy[i][j];
    }
  }

  printf("%d\\n%d\\n", w, con);

  return (0);
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int xy[10][10] = {'0'};
  int x, y, size;
  xy[0][0] = 0;

  while (scanf("%d,%d,%d", &x, &y, &size), x != EOF) {

    xy[y - 1][x]++;
    xy[y][x - 1]++;
    xy[y][x]++;
    xy[y][x + 1]++;
    xy[y + 1][x]++;

    if (size >= 2) {
      xy[y - 1][x - 1]++;
      xy[y - 1][x + 1]++;
      xy[y + 1][x - 1]++;
      xy[y + 1][x + 1]++;
    }
    if (size == 3) {
      xy[y - 2][x]++;
      xy[y][x - 2]++;
      xy[y][x + 2]++;
      xy[y + 2][x]++;
    }
  }

  int w = 0, con = 0;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (xy[i][j] == 0)
        w++;
      if (con < xy[i][j])
        con = xy[i][j];
    }
  }

  printf("%d\\n%d\\n", w, con);

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

const double eps = 1e-10;

int main() {
  int x, y, s, c[14][14] = {0};
  char dummy;
  while (cin >> x >> dummy >> y >> dummy >> s) {
    x += 2;
    y += 2;

    c[y][x]++;
    c[y + 1][x]++;
    c[y - 1][x]++;
    c[y][x + 1]++;
    c[y][x - 1]++;

    if (s >= 2) {
      c[y - 1][x - 1]++;
      c[y - 1][x + 1]++;
      c[y + 1][x - 1]++;
      c[y + 1][x + 1]++;
    }

    if (s == 3) {
      c[y - 2][x]++;
      c[y + 2][x]++;
      c[y][x - 2]++;
      c[y][x + 2]++;
    }
  }

  int w = 0, d = 0;
  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      if (c[i][j] == 0)
        w++;
      d = max(d, c[i][j]);
    }
  }

  cout << w << endl << d << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

const double eps = 1e-10;

int main() {
  int x, y, s, c[14][14] = {0};
  while (scanf("%d,%d,%d", &x, &y, &s)) {
    x += 2;
    y += 2;

    c[y][x]++;
    c[y + 1][x]++;
    c[y - 1][x]++;
    c[y][x + 1]++;
    c[y][x - 1]++;

    if (s >= 2) {
      c[y - 1][x - 1]++;
      c[y - 1][x + 1]++;
      c[y + 1][x - 1]++;
      c[y + 1][x + 1]++;
    }

    if (s == 3) {
      c[y - 2][x]++;
      c[y + 2][x]++;
      c[y][x - 2]++;
      c[y][x + 2]++;
    }
  }

  int w = 0, d = 0;
  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      if (c[i][j] == 0)
        w++;
      d = max(d, c[i][j]);
    }
  }

  cout << w << endl << d << endl;

  return 0;
}