prithivMLmods/Coder-Stat huggingface dataset:
Problem p00024 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>

using namespace std;

void solve() {
  double v;
  while (cin >> v, v) {
    int N = 2;
    while (true) {
      double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
      if (velocity >= v) {
        cout << N << endl;
        break;
      }
      ++N;
    }
  }
}

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

Fixed submission:
#include <cmath>
#include <iostream>

using namespace std;

void solve() {
  double v;
  while (cin >> v) {
    int N = 2;
    while (true) {
      double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
      if (velocity >= v) {
        cout << N << endl;
        break;
      }
      ++N;
    }
  }
}

int main() {
  solve();
  return (0);
}
Problem p00024 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  int c, n;
  double v, y;
  while (cin >> v, v != '\0') {
    y = 4.9 * ((v * v) / (9.8 * 9.8));
    n = 1;
    while (1) {
      if (y < 5 * n - 5)
        break;
      n++;
    }
    cout << n << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int c, n;
  double v, y;
  while (cin >> v) {
    y = 4.9 * ((v * v) / (9.8 * 9.8));
    n = 1;
    while (1) {
      if (y < 5 * n - 5)
        break;
      n++;
    }
    cout << n << endl;
  }
}
Problem p00024 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  while (1) {
    double v, t, h;
    int ans;
    cin >> v;
    t = v / 9.8;
    h = 4.9 * t * t;
    for (int i = 1; i < 100000; i++) {
      if (h < 5 * i - 5) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  double v, t, h;
  int ans;
  while (cin >> v) {
    t = v / 9.8;
    h = 4.9 * t * t;
    for (int i = 1; i < 100000; i++) {
      if (h < 5 * i - 5) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00024 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  double a;
  while (cin >> a, a) {
    double t = a / 9.8;
    double y = 4.9 * t * t;
    int y_c = ceil(y);
    int N = y_c / 5 + (y_c % 5 > 0);
    cout << N + 1 << endl;
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  double a;
  while (cin >> a) {
    double t = a / 9.8;
    double y = 4.9 * t * t;
    int y_c = ceil(y);
    int N = y_c / 5 + (y_c % 5 > 0);
    cout << N + 1 << endl;
  }

  return 0;
}
Problem p00024 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
int main() {
  double v;
  while (cin >> v, v) {
    int N = 0;
    double V = 0;
    do {
      N++;
      double h = 5 * N - 5;
      V = 9.8 * pow(h / 4.9, 0.5);
    } while (V < v);
    cout << N << endl;
  }
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
int main() {
  double v;
  while (cin >> v) {
    int N = 0;
    double V = 0;
    do {
      N++;
      double h = 5 * N - 5;
      V = 9.8 * pow(h / 4.9, 0.5);
    } while (V < v);
    cout << N << endl;
  }
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int a[4], b[4];
  while (1) {
    rep(i, 4) cin >> a[i];
    rep(i, 4) cin >> b[i];

    int blow = 0, hit = 0;

    rep(i, 4) {
      if (a[i] == b[i])
        hit++;
    }
    rep(i, 4) for (int j = 0; j < 4; j++) {
      if (a[i] == b[j] && i != j)
        blow++;
    }
    cout << hit << " " << blow << endl;
  }
}

Fixed submission:
#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int a[4], b[4];
  while (1) {
    rep(i, 4) cin >> a[i];
    rep(i, 4) cin >> b[i];
    if (cin.eof())
      break;

    int blow = 0, hit = 0;

    rep(i, 4) {
      if (a[i] == b[i])
        hit++;
    }
    rep(i, 4) for (int j = 0; j < 4; j++) {
      if (a[i] == b[j] && i != j)
        blow++;
    }
    cout << hit << " " << blow << endl;
  }
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

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

  while (1) {
    for (int i = 0; i < 4; i++)
      cin >> a[i];
    for (int i = 0; i < 4; i++)
      cin >> b[i];

    // hit
    int hit = 0;
    for (int i = 0; i < 4; i++)
      hit += (a[i] == b[i]);

    // blow
    int blow = 0;
    for (int i = 0; i < 4; i++)
      blow += ((a[i] == b[0]) || (a[i] == b[1]) || (a[i] == b[2]) ||
               (a[i] == b[3]));

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

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    // hit
    int hit = 0;
    for (int i = 0; i < 4; i++)
      hit += (a[i] == b[i]);

    // blow
    int blow = 0;
    for (int i = 0; i < 4; i++)
      blow += ((a[i] == b[0]) || (a[i] == b[1]) || (a[i] == b[2]) ||
               (a[i] == b[3]));

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

  return 0;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
int main() {
  while (1) {
    vector<int> a(4);
    vector<int> b(4);
    rep(i, 4) cin >> a[i];
    rep(i, 4) cin >> b[i];
    int hit = 0, blow = 0;
    rep(i, 4) {
      if (a[i] == b[i])
        hit++;
      else {
        rep(j, 4) if (a[j] == b[i]) blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
int main() {
  vector<int> a(4);
  vector<int> b(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    rep(i, 4) cin >> b[i];
    int hit = 0, blow = 0;
    rep(i, 4) {
      if (a[i] == b[i])
        hit++;
      else {
        rep(j, 4) if (a[j] == b[i]) blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  while (true) {
    vector<int> a(4);
    for (int i = 0; i < 4; i++)
      cin >> a[i];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      int b;
      cin >> b;
      for (int j = 0; j < 4; j++) {
        if (a[j] == b) {
          if (i == j)
            hit++;
          else
            blow++;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> a(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      int b;
      cin >> b;
      for (int j = 0; j < 4; j++) {
        if (a[j] == b) {
          if (i == j)
            hit++;
          else
            blow++;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

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

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int a[4], b[4];
  int hit, blow;
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    hit = blow = 0;
    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]) {
          blow++;
        }
      }
    }
    blow -= hit;
    cout << hit << " " << blow << endl;
  }

  return 0;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <array>
#include <iostream>

/*This function is a counter for "hit" and "blow".*/
void counter(int *n_a, int *n_b, int *hit, int *blow) {

  *hit = 0;
  *blow = 0;

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      // the case of factor and place are same
      if (n_a[i] == n_b[j] && i == j) {
        *hit = *hit + 1;
      }
      // the case of only factor is same
      else if (n_a[i] == n_b[j]) {
        *blow = *blow + 1;
      }
    }
  }
}

int main() {

  std::array<int, 4> n_a; // selection of "A"
  std::array<int, 4> n_b; // selection of "B"

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

    int hit = 0;  // factor and place are same
    int blow = 0; // only factor is same

    counter(n_a.data(), n_b.data(), &hit, &blow);

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

  return 0;
}

Fixed submission:
#include <array>
#include <iostream>

/*This function is a counter for "hit" and "blow".*/
void counter(int *n_a, int *n_b, int *hit, int *blow) {

  *hit = 0;
  *blow = 0;

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      // the case of factor and place are same
      if (n_a[i] == n_b[j] && i == j) {
        *hit = *hit + 1;
      }
      // the case of only factor is same
      else if (n_a[i] == n_b[j]) {
        *blow = *blow + 1;
      }
    }
  }
}

int main() {

  std::array<int, 4> n_a; // selection of "A"
  std::array<int, 4> n_b; // selection of "B"

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

    int hit = 0;  // factor and place are same
    int blow = 0; // only factor is same

    counter(n_a.data(), n_b.data(), &hit, &blow);

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

  return 0;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[4], b[4];
  while (scanf("%d %d %d %d %d %d %d %d", &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 < 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;
}

Fixed submission:
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[4], b[4];
  while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0],
               &b[1], &b[2], &b[3]) != EOF) {
    int hit = 0;
    int 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;
}
Problem p00025 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  for (;;) {
    vector<int> a(4), b(4);
    for (int i = 0; i < 4; i++) {
      cin >> a.at(i);
    }
    for (int i = 0; i < 4; i++) {
      cin >> b.at(i);
    }
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a.at(i) == b.at(j)) {
          if (i == j) {
            hit++;
          } else {
            blow++;
          }
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
}


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

int main() {
  vector<int> a(4), b(4);

  while (cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> b.at(0) >>
         b.at(1) >> b.at(2) >> b.at(3)) {
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a.at(i) == b.at(j)) {
          if (i == j) {
            hit++;
          } else {
            blow++;
          }
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
}
Problem p00026 (C++)

Buggy submission (status: Runtime Error):
#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;
}

Fixed submission:
#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;
}
Problem p00026 (C++)

Buggy submission (status: 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)) {
    ++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);
}

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) != 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);
}
Problem p00026 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>

int paper[10][10] = {};

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

void ink(int x, int y, int s) {
  switch (s) {
  case 3:
    drop(x + 2, y);
    drop(x - 2, y);
    drop(x, y + 2);
    drop(x, y - 2);
  case 2:
    drop(x + 1, y + 1);
    drop(x - 1, y + 1);
    drop(x - 1, y - 1);
    drop(x + 1, y - 1);
  case 1:
    drop(x, y);
    drop(x + 1, y);
    drop(x - 1, y);
    drop(x, y + 1);
    drop(x, y - 1);
  }
}

int main() {
  int x, y, s;

  // drop(9,9);

  /*for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      std::cout << paper[i][j] << std::endl;
    }
  }*/

  while (std::scanf(" %d,%d,%d", &x, &y, &s)) {
    // std::cout << x << y << s;
    ink(x, y, s);
  }

  int spase = 0, max = 0;

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

  std::cout << spase << std::endl;
  std::cout << max << std::endl;
}

Fixed submission:
#include <cstdio>
#include <iostream>

int paper[10][10] = {};

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

void ink(int x, int y, int s) {
  switch (s) {
  case 3:
    drop(x + 2, y);
    drop(x - 2, y);
    drop(x, y + 2);
    drop(x, y - 2);
  case 2:
    drop(x + 1, y + 1);
    drop(x - 1, y + 1);
    drop(x - 1, y - 1);
    drop(x + 1, y - 1);
  case 1:
    drop(x, y);
    drop(x + 1, y);
    drop(x - 1, y);
    drop(x, y + 1);
    drop(x, y - 1);
  }
}

int main() {
  int x, y, s;

  // drop(9,9);

  /*for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      std::cout << paper[i][j] << std::endl;
    }
  }*/

  while (std::scanf(" %d,%d,%d", &x, &y, &s) + 1) {
    // std::cout << x << y << s;
    ink(x, y, s);
  }

  int spase = 0, max = 0;

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

  std::cout << spase << std::endl;
  std::cout << max << std::endl;
}
Problem p00026 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstring>
#include <iostream>

using namespace std;

int small_x[4] = {-1, 0, 0, 1};
int small_y[4] = {0, -1, 1, 0};

int medium_x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int medium_y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int large_x[12] = {-2, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 2};
int large_y[12] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0};

void solve() {
  int Field[14][14];
  memset(Field, 0, sizeof(Field));
  int a, b, c;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    ++Field[b + 2][a + 2];
    if (c == 1) {
      for (int i = 0; i < 4; ++i) {
        ++Field[b + 2 + small_y[i]][a + 2 + small_x[i]];
      }
    } else if (c == 2) {
      for (int i = 0; i < 8; ++i) {
        ++Field[b + 2 + medium_y[i]][a + 2 + medium_x[i]];
      }
    } else if (c == 3) {
      for (int i = 0; i < 12; ++i) {
        ++Field[b + 2 + large_y[i]][a + 2 + large_x[i]];
      }
    }
  }
  int count = 0;
  int Max = 0;
  for (int i = 2; i < 12; ++i) {
    for (int j = 2; j < 12; ++j) {
      if (Field[i][j] == 0) {
        ++count;
      }
      if (Max < Field[i][j]) {
        Max = Field[i][j];
      }
    }
  }
  cout << count << endl;
  cout << Max << endl;
}

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

Fixed submission:
#include <cstring>
#include <iostream>

using namespace std;

int small_x[4] = {-1, 0, 0, 1};
int small_y[4] = {0, -1, 1, 0};

int medium_x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int medium_y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int large_x[12] = {-2, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 2};
int large_y[12] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0};

void solve() {
  int Field[14][14];
  memset(Field, 0, sizeof(Field));
  int a, b, c;
  while (~scanf("%d,%d,%d", &a, &b, &c)) {
    ++Field[b + 2][a + 2];
    if (c == 1) {
      for (int i = 0; i < 4; ++i) {
        ++Field[b + 2 + small_y[i]][a + 2 + small_x[i]];
      }
    } else if (c == 2) {
      for (int i = 0; i < 8; ++i) {
        ++Field[b + 2 + medium_y[i]][a + 2 + medium_x[i]];
      }
    } else if (c == 3) {
      for (int i = 0; i < 12; ++i) {
        ++Field[b + 2 + large_y[i]][a + 2 + large_x[i]];
      }
    }
  }
  int count = 0;
  int Max = 0;
  for (int i = 2; i < 12; ++i) {
    for (int j = 2; j < 12; ++j) {
      if (Field[i][j] == 0) {
        ++count;
      }
      if (Max < Field[i][j]) {
        Max = Field[i][j];
      }
    }
  }
  cout << count << endl;
  cout << Max << endl;
}

int main() {
  solve();
  return (0);
}
Problem p00026 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;
int m[10][10];
void small(int x, int y, int r) {
  if (y - r >= 0)
    m[x][y - r]++;
  if (x - r >= 0)
    m[x - r][y]++;
  if (x + r <= 9)
    m[x + r][y]++;
  if (y + r <= 9)
    m[x][y + r]++;
  m[x][y]++;
}
void middle(int x, int y) {
  for (int i = -1; i < 2; i++)
    for (int j = -1; j < 2; j++)
      if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9)
        m[x + i][y + j]++;
}
void large(int x, int y) {
  middle(x, y);
  small(x, y, 2);
  m[x][y]--;
}

int main() {
  int x, y, n, i, j, h, k;
  while (scanf("%d,%d,%d", &x, &y, &n)) {
    if (n == 1)
      small(x, y, 1);
    if (n == 2)
      middle(x, y);
    if (n == 3)
      large(x, y);
  }
  n = 0;
  h = 0;
  k = 0;
  for (i = 0; i < 10; i++)
    for (j = 0; j < 10; j++) {
      if (m[i][j] == 0)
        k++;
      else
        h = h < m[i][j] ? m[i][j] : h;
    }
  cout << k << endl << h << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;
int m[10][10];
void small(int x, int y, int r) {
  if (y - r >= 0)
    m[x][y - r]++;
  if (x - r >= 0)
    m[x - r][y]++;
  if (x + r <= 9)
    m[x + r][y]++;
  if (y + r <= 9)
    m[x][y + r]++;
  m[x][y]++;
}
void middle(int x, int y) {
  for (int i = -1; i < 2; i++)
    for (int j = -1; j < 2; j++)
      if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9)
        m[x + i][y + j]++;
}
void large(int x, int y) {
  middle(x, y);
  small(x, y, 2);
  m[x][y]--;
}

int main() {
  int x, y, n, i, j, h, k;
  while (scanf("%d,%d,%d", &x, &y, &n) != EOF) {
    if (n == 1)
      small(x, y, 1);
    if (n == 2)
      middle(x, y);
    if (n == 3)
      large(x, y);
  }
  n = 0;
  h = 0;
  k = 0;
  for (i = 0; i < 10; i++)
    for (j = 0; j < 10; j++) {
      if (m[i][j] == 0)
        k++;
      else
        h = h < m[i][j] ? m[i][j] : h;
    }
  cout << k << endl << h << endl;
  return 0;
}
Problem p00026 (C++)

Buggy submission (status: 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};
  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;
}

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};
  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;
}
Problem p00026 (C++)

Buggy submission (status: 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)) {
    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;
}

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) != -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;
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = {"Monday",   "Tuesday",  "Wednesday",
                 "Thursday", // <- 2004/1/1
                 "Friday",   "Saturday", "Sunday"};

int main() {
  int m, d;

  cin >> m >> d;

  while (m != 0 && d != 0) {
    int daySum = 0;

    for (int i = 0; i < m - 1; i++) {
      daySum += dayNum[i];
    }

    daySum += d;

    cout << day[daySum % 7 + 2] << endl;

    cin >> m >> d;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = {"Monday",   "Tuesday",  "Wednesday",
                 "Thursday", // <- 2004/1/1
                 "Friday",   "Saturday", "Sunday"};

int main() {
  int m, d;

  cin >> m >> d;

  while (m != 0 && d != 0) {
    int daySum = 0;

    for (int i = 0; i < m - 1; i++) {
      daySum += dayNum[i];
    }

    daySum += d;

    cout << day[(daySum + 2) % 7] << endl;

    cin >> m >> d;
  }

  return 0;
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a, b) (fabs((a) - (b)) < EPS)

int main() {
  int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string youbi[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                     "Friday", "Saturday", "Sunday"};
  int m, d;
  while (cin >> m >> d) {
    if (m == 0)
      break;
    int sum = 0;
    for (int i = 1; i < m; ++i) {
      sum += dn[i];
    }
    sum += d;
    cout << youbi[sum % 7 + 2] << endl;
  }
  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a, b) (fabs((a) - (b)) < EPS)

int main() {
  int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string youbi[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                     "Friday", "Saturday", "Sunday"};
  int m, d;
  while (cin >> m >> d) {
    if (m == 0)
      break;
    int sum = 0;
    for (int i = 1; i < m; ++i) {
      sum += dn[i];
    }
    sum += d;
    cout << youbi[(sum + 2) % 7] << endl;
  }
  return 0;
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e+9 * 2;
double eps = 1e-10;

string days[] = {"Thursday", "Friday",  "Saturday", "Sunday",
                 "Monday",   "Tuesday", "Wednesday"};
int main() {
  int m, d;
  while (cin >> m >> d && (m || d)) {
    int cnt = 0;
    for (int i = 1; i <= 12; ++i) {
      for (int j = 1; j <= 31; ++j) {
        if (m == i && j == d) {
          cout << days[cnt % 8] << endl;
          goto end;
        }
        cnt++;
        if (i == 2 && j == 29)
          break;
        else if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30)
          break;
      }
    }
  end:;
  }
  return 0;
}

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

const int INF = 1e+9 * 2;
double eps = 1e-10;

string days[] = {"Thursday", "Friday",  "Saturday", "Sunday",
                 "Monday",   "Tuesday", "Wednesday"};
int main() {
  int m, d;
  while (cin >> m >> d && (m || d)) {
    int cnt = 0;
    for (int i = 1; i <= 12; ++i) {
      for (int j = 1; j <= 31; ++j) {
        if (m == i && j == d) {
          cout << days[cnt % 7] << endl;
          goto end;
        }
        cnt++;
        if (i == 2 && j == 29)
          break;
        else if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30)
          break;
      }
    }
  end:;
  }
  return 0;
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int getDay(int y, int m, int d) {
  if (m < 3)
    m += 12, y--;
  int J = y / 100, K = y % 100;
  return (d + ((m + 1) * 26) / 10 + K + K / 4 + J / 4 - 2 * J) % 7;
}
int main() {
  string table[] = {"Saturday",  "Sunday",   "Monday", "Tuesday",
                    "Wednesday", "Thursday", "Friday"};
  int m, d;
  while (cin >> m >> d, m) {
    cout << table[getDay(2004, m, d)] << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;

int getDay(int y, int m, int d) {
  if (m < 3)
    m += 12, y--;
  int J = y / 100, K = y % 100;
  return (d + (((m + 1) * 26) / 10) + K + (K / 4) + (J / 4) + 5 * J) % 7;
}
int main() {
  string table[] = {"Saturday",  "Sunday",   "Monday", "Tuesday",
                    "Wednesday", "Thursday", "Friday"};
  int m, d;
  while (cin >> m >> d, m) {
    cout << table[getDay(2004, m, d)] << endl;
  }
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
  ifstream cin("../test.txt");

  int year[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string day[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                   "Friday", "Saturday", "Sunday"};
  int first = 3;

  int m, d;
  while (true) {
    cin >> m >> d;
    if (!(m | d))
      break;
    int n = first;
    for (int i = 0; i < m - 1; i++) {
      n += year[i];
    }
    n += d - 1;

    n %= 7;
    cout << day[n] << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int year[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string day[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                   "Friday", "Saturday", "Sunday"};
  int first = 3;

  int m, d;
  while (true) {
    cin >> m >> d;
    if (!(m | d))
      break;
    int n = first;
    for (int i = 0; i < m - 1; i++) {
      n += year[i];
    }
    n += d - 1;

    n %= 7;
    cout << day[n] << endl;
  }
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

string a[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
               "Friday", "Saturday", "Sunday"};

int b[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  for (int m, d; cin >> m >> d && m;) {
    while (m)
      d += b[--m];
    cout << a[d % 7 - 1 + 3] << endl;
  }
  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

string a[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
               "Friday", "Saturday", "Sunday"};

int b[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  for (int m, d; cin >> m >> d && m;) {
    while (m)
      d += b[--m];
    cout << a[(d - 1 + 3) % 7] << endl;
  }
  return 0;
}
Problem p00027 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int m, d;
  string week[] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                   "Friday", "Saturday", "Sunday"};
  int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  while (cin >> m >> d) {
    if (m == 0)
      break;
    bool flag = false;
    int mc = 1;
    int cnt = 3;
    while (1) {
      for (int i = 1; i < day[mc - 1]; ++i, cnt++) {
        if (mc == m && d == i) {
          cout << week[cnt % 7] << endl;
          flag = true;
          break;
        }
      }
      if (flag)
        break;
      mc++;
    }
  }
  return 0;
}

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

int main() {
  int m, d;
  string week[] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                   "Friday", "Saturday", "Sunday"};
  int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  while (cin >> m >> d) {
    if (m == 0)
      break;
    bool flag = false;
    int mc = 1;
    int cnt = 3;
    while (1) {
      for (int i = 1; i <= day[mc - 1]; ++i, cnt++) {
        if (mc == m && d == i) {
          cout << week[cnt % 7] << endl;
          flag = true;
          break;
        }
      }
      if (flag)
        break;
      mc++;
    }
  }
  return 0;
}
Problem p00027 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int k, m, d;
  string today[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                     "Friday", "Saturday", "Sunday"};
  int mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  while (cin >> m >> d) {
    if (m == 0)
      break;

    for (int i = 0; m - 1 > i; i++)
      d += mon[i];

    k = d % 7 + 2;
    cout << today[k] << endl;
  }
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  int k, m, d;
  string today[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                     "Friday", "Saturday", "Sunday"};
  int mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  while (cin >> m >> d) {
    if (m == 0)
      break;

    for (int i = 0; m - 1 > i; i++)
      d += mon[i];

    k = d % 7 + 2;
    cout << today[k % 7] << endl;
  }
}
Problem p00027 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday",
                 "Sunday",    "Monday",   "Tuesday"};

  int m, d;
  while (cin >> m >> d) {
    if (m == 0 || d == 0)
      break;

    int tmp = d;
    for (int i = 0; i < m; i++)
      tmp += M[i];

    cerr << tmp << endl;
    cout << w[tmp % 7] << endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday",
                 "Sunday",    "Monday",   "Tuesday"};

  int m, d;
  while (cin >> m >> d) {
    if (m == 0 || d == 0)
      break;

    int tmp = d;
    for (int i = 0; i < m; i++)
      tmp += M[i];

    cout << w[tmp % 7] << endl;
  }

  return 0;
}
Problem p00028 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <map>

using namespace std;

void solve() {
  map<int, int> Map;
  int n;
  while (cin >> n, n) {
    ++Map[n];
  }
  int Max = 0;
  for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
    if (Max < Ite->second) {
      Max = Ite->second;
    }
  }
  for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
    if (Ite->second == Max) {
      cout << Ite->first << endl;
    }
  }
}

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

Fixed submission:
#include <iostream>
#include <map>

using namespace std;

void solve() {
  map<int, int> Map;
  int n;
  while (~scanf("%d", &n)) {
    ++Map[n];
  }
  int Max = 0;
  for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
    if (Max < Ite->second) {
      Max = Ite->second;
    }
  }
  for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
    if (Ite->second == Max) {
      cout << Ite->first << endl;
    }
  }
}

int main() {
  solve();
  return (0);
}
Problem p00028 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main(void) {
  int n = 0, i, a[100], b[100] = {};
  while (cin >> i)
    a[n++] = i;
  for (int i = 0; i < n; ++i)
    ++b[a[i]];
  int max = 0;
  for (int i = 1; i <= 100; ++i)
    if (b[i] > max)
      max = b[i];

  for (int i = 1; i <= 100; ++i)
    if (max == b[i])
      cout << i << endl;

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main(void) {
  int n = 0, i, a[100], b[101] = {};
  while (cin >> i)
    a[n++] = i;
  for (int i = 0; i < n; ++i)
    ++b[a[i]];
  int max = 0;
  for (int i = 1; i <= 100; ++i)
    if (b[i] > max)
      max = b[i];

  for (int i = 1; i <= 100; ++i)
    if (max == b[i])
      cout << i << endl;

  return 0;
}
Problem p00028 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  int a[100] = {0};
  int n;
  while (cin >> n, n)
    a[n - 1]++;

  int ma = 0;
  REP(i, 100) { ma = max(ma, a[i]); }
  REP(i, 100) {
    if (a[i] == ma)
      cout << (i + 1) << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  int a[100] = {0};
  int n;
  while (cin >> n)
    a[n - 1]++;

  int ma = 0;
  REP(i, 100) { ma = max(ma, a[i]); }
  REP(i, 100) {
    if (a[i] == ma)
      cout << (i + 1) << endl;
  }
  return 0;
}
Problem p00028 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {

  int n, max = 0, x[100] = {0};
  int x_max;

  while (scanf("%d", &n)) {
    if (n == 0) {
      break;
    }
    x[n - 1]++;
  }

  for (int i = 0; i < 100; i++) {
    if (max < x[i]) {
      max = x[i];
      x_max = i;
    }
  }
  cout << x_max + 1 << endl;

  for (int i = x_max + 1; i < 100; i++) {
    if (x[x_max] == x[i]) {
      cout << i + 1 << endl;
    }
  }

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {

  int n, max = 0, x[100] = {0};
  int x_max;

  while (scanf("%d", &n) != EOF) {
    x[n - 1]++;
  }

  for (int i = 0; i < 100; i++) {
    if (max < x[i]) {
      max = x[i];
      x_max = i;
    }
  }
  cout << x_max + 1 << endl;

  for (int i = x_max + 1; i < 100; i++) {
    if (x[x_max] == x[i]) {
      cout << i + 1 << endl;
    }
  }

  return 0;
}
Problem p00028 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[100];
  int b;
  b = 0;
  while (b < 100) {
    a[b] = 0;
  }
  int n;
  while (cin >> n) {
    a[n] = a[n] + 1;
  }
  int c;
  c = 0;
  b = 0;
  while (b < 100) {
    if (a[b] > c) {
      c = a[b];
    }
    b = b + 1;
  }
  b = 0;
  while (b < 100) {
    if (c == a[b]) {
      cout << b << endl;
    }
    b = b + 1;
  }
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[100];
  int b;
  b = 0;
  while (b < 100) {
    a[b] = 0;
    b = b + 1;
  }
  int n;
  while (cin >> n) {
    a[n] = a[n] + 1;
  }
  int c;
  c = 0;
  b = 0;
  while (b < 100) {
    if (a[b] > c) {
      c = a[b];
    }
    b = b + 1;
  }
  b = 0;
  while (b < 100) {
    if (c == a[b]) {
      cout << b << endl;
    }
    b = b + 1;
  }
}
Problem p00028 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int n, max = 0;
  int in[100] = {0};
  while (cin >> n) {
    in[n]++;
    if (max < in[n])
      max = in[n];
  }
  for (int i = 1; i <= 100; i++) {

    if (max == in[i])
      cout << i << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, max = 0;
  int in[100] = {0};
  while (cin >> n) {
    in[n]++;
    if (max < in[n])
      max = in[n];
  }
  for (int i = 0; i < 100; i++) {

    if (max == in[i])
      cout << i << endl;
  }
  return 0;
}
Problem p00028 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char *argv[]) {
  int x;
  vector<int> freq;
  int X[100] = {0};
  while (cin >> x) {
    freq.push_back(x);
  }
  int maxf = 0;
  for (int i = 0; i < freq.size(); i++) {
    X[freq[i]]++;
    maxf = max(maxf, X[freq[i]]);
  }
  for (int j = 0; j < 100; j++) {
    if (X[j] == maxf) {
      cout << j << endl;
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char *argv[]) {
  int x;
  vector<int> freq;
  int X[120] = {0};
  while (cin >> x) {
    freq.push_back(x);
  }
  int maxf = 0;
  for (int i = 0; i < freq.size(); i++) {
    X[freq[i]]++;
    maxf = max(maxf, X[freq[i]]);
  }
  for (int j = 0; j < 100; j++) {
    if (X[j] == maxf) {
      cout << j << endl;
    }
  }

  return 0;
}