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

#include <iostream>

int data[10][10];

int main() {
  int count = 0, max = 0;
  int x, y, size;
  char c;

  int dx_1[4] = {0, -1, 1, 0}, dy_1[4] = {-1, 0, 0, 1};
  int dx_2[8] = {0, -1, 1, -1, 1, 0, -1, 1},
      dy_2[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  int dx_3[12] = {0, -1, 1, -1, 1, -2, 2, 0, -1, 1, 0, 0},
      dy_3[12] = {-1, -1, -1, 0, 0, 0, 0, 1, 1, 1, -2, 2};

  while (std::cin >> x >> c >> y >> c >> size) {
    data[y][x]++;
    if (size == 1) {
      for (int i = 0; i < 4; i++) {
        int nx = x + dx_1[i], ny = y + dy_1[i];
        if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10)
          data[ny][nx]++;
      }
    } else if (size == 2) {
      for (int i = 0; i < 8; i++) {
        int nx = x + dx_2[i], ny = y + dy_2[i];
        if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10)
          data[ny][nx]++;
      };
    } else if (size == 3) {
      for (int i = 0; i < 12; i++) {
        int nx = x + dx_3[i], ny = y + dy_3[i];
        if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10)
          data[ny][nx]++;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      max = std::max(max, data[i][j]);
      if (data[i][j] == 0)
        count++;
    }
  }
  std::cout << count << std::endl;
  std::cout << max << std::endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

int data[10][10];

int main() {
  int count = 0, max = 0;
  int x, y, size;
  char c;
  while (std::cin >> x >> c >> y >> c >> size) {
    if (size == 1) {
      data[y - 1][x]++;
      data[y][x]++;
      data[y][x - 1]++;
      data[y][x + 1]++;
      data[y + 1][x]++;
    } else if (size == 2) {
      data[y - 1][x]++;
      data[y - 1][x - 1]++;
      data[y - 1][x + 1]++;
      data[y][x]++;
      data[y][x - 1]++;
      data[y][x + 1]++;
      data[y + 1][x]++;
      data[y + 1][x - 1]++;
      data[y + 1][x + 1]++;
    } else if (size == 3) {
      data[y - 1][x]++;
      data[y - 1][x - 1]++;
      data[y - 1][x + 1]++;
      data[y][x]++;
      data[y][x - 1]++;
      data[y][x + 1]++;
      data[y][x - 2]++;
      data[y][x + 2]++;
      data[y + 1][x]++;
      data[y + 1][x - 1]++;
      data[y + 1][x + 1]++;
      data[y - 2][x]++;
      data[y + 2][x]++;
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      max = std::max(max, data[i][j]);
      if (data[i][j] == 0)
        count++;
    }
  }
  std::cout << count << std::endl;
  std::cout << max << std::endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
#define W 10 + 2 + 2
#define H 10 + 2 + 2

int main() {
  int field[W][H] = {0}, x, y, size, max, cnt, i, j;
  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    x += 2;
    y += 2;
    if (size == 1) {
      field[x][y]++;
      field[x - 1][y]++;
      field[x + 1][y]++;
      field[x][y - 1]++;
      field[x][y + 1]++;
    } else if (size == 2) {
      field[x][y]++;
      field[x - 1][y]++;
      field[x + 1][y]++;
      field[x][y - 1]++;
      field[x][y + 1]++;
      field[x - 1][y - 1]++;
      field[x - 1][y + 1]++;
      field[x + 1][y - 1]++;
      field[x + 1][y + 1]++;
    } else {
      field[x][y]++;
      field[x - 1][y]++;
      field[x + 1][y]++;
      field[x][y - 1]++;
      field[x][y + 1]++;
      field[x - 1][y - 1]++;
      field[x - 1][y + 1]++;
      field[x + 1][y - 1]++;
      field[x + 1][y + 1]++;
      field[x - 2][y]++;
      field[x + 2][y]++;
      field[x][y - 2]++;
      field[x][y + 2]++;
    }
  }
  max = 0;
  cnt = 0;
  for (i = 2; i < 12; i++)
    for (j = 2; j < 12; j++) {
      cnt += field[i][j] == 0;
      if (max < field[i][j])
        max = field[i][j];
    }
  cout << cnt << endl << max << endl;
}

Error: 0

Fixed submission:

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

#define W 10
#define H 10

int main() {
  vector<vector<int>> paper(W, vector<int>(H, 0));
  int x, y, size;
  int i, j;
  int blank, max;

  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    switch (size) {
    case 3:
      if (x - 2 >= 0)
        paper[x - 2][y]++;
      if (x + 2 < W)
        paper[x + 2][y]++;
      if (y - 2 >= 0)
        paper[x][y - 2]++;
      if (y + 2 < H)
        paper[x][y + 2]++;
    case 2:
      if (x - 1 >= 0 && y - 1 >= 0)
        paper[x - 1][y - 1]++;
      if (x - 1 >= 0 && y + 1 <= H)
        paper[x - 1][y + 1]++;
      if (x + 1 <= W && y - 1 >= 0)
        paper[x + 1][y - 1]++;
      if (x + 1 <= W && y + 1 <= H)
        paper[x + 1][y + 1]++;
    case 1:
      if (x - 1 >= 0)
        paper[x - 1][y]++;
      if (x + 1 < W)
        paper[x + 1][y]++;
      if (y - 1 >= 0)
        paper[x][y - 1]++;
      if (y + 1 < H)
        paper[x][y + 1]++;
      paper[x][y]++;
      break;
    }
  }

  blank = 0;
  max = 0;
  for (i = 0; i < W; i++) {
    for (j = 0; j < H; j++) {
      if (paper[i][j] == 0)
        blank++;
      else if (paper[i][j] > max)
        max = paper[i][j];
    }
  }

  cout << blank << endl;
  cout << max << endl;

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

#include <algorithm>
#include <cstdio>

void ink(int, int, int);
void change(int, int, int);

char paper[10][10] = {0};

int main(void) {
  int white = 0, max_ink = 0;

  for (int x, y, size; scanf("%d,%d,%d", &x, &y, &size) != EOF;)
    ink(x, y, size);

  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      if (!paper[i][j])
        white++;
      else
        max_ink = std::max(max_ink, int(paper[i][j]));

  printf("%d\\n%d\\n", white, max_ink);
  return 0;
}

void ink(int x, int y, int size) {
  switch (size) {
  case 1:
    ink(x, y, 2);
    for (int i = -1; i <= 1; i += 2)
      for (int j = -1; j <= 1; j += 2)
        change(x + i, y + j, -1);
    break;
  case 2:
    for (int i = -1; i <= 1; i++)
      for (int j = -1; j <= 1; j++)
        change(x + i, y + j, 1);
    break;
  case 3:
    ink(x, y, 2);
    change(x - 2, y, 1);
    change(x + 2, y, 1);
    change(x, y - 2, 1);
    change(x, y + 2, 1);
    break;
  }
}

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

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int val;
  while (cin >> val)
    cerr << val << endl;

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

#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int masu[10][10] = {};
int x, y;
void sho(int i, int j) {
  if (abs(i) + abs(j) < 2)
    masu[i + y][j + x]++;
}
void chu(int i, int j) {
  if (abs(i) < 2 && abs(j) < 2)
    masu[i + y][j + x]++;
}
void dai(int i, int j) {
  if (abs(i) + abs(j) <= 2)
    masu[i + y][j + x]++;
}
int main() {
  int s;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        if (i + y < 0 || j + x < 0 || i + y >= 10 || j + x >= 10)
          continue;
        if (s == 1)
          sho(i, j);
        if (s == 2)
          chu(i, j);
        if (s == 3)
          dai(i, j);
      }
    }
  }
  int a = 0, b = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      a += masu[i][j] == 0;
      b = max(b, masu[i][j]);
    }
  }
  printf("%d\\n%d\\n", a, b);
  return (0);
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
using namespace std;
int main() {

  int ink[10][10] = {};
  int dx3[4] = {-2, 2, 0, 0};
  int dy3[4] = {0, 0, -2, 2};
  int dx2[4] = {-1, -1, 1, 1};
  int dy2[4] = {-1, 1, -1, 1};
  int dx1[4] = {-1, 1, 0, 0};
  int dy1[4] = {0, 0, -1, 1};

  int x, y, s, p = 100, ma = 0;

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

    if (s == 3) {
      for (int i = 0; i < 4; i++) {
        if (ink[dy3[i] + y][dx3[i] + x] == 0)
          p--;
        ink[dy3[i] + y][dx3[i] + x]++;
        ma = max(ma, ink[dy3[i] + y][dx3[i] + x]);
      }
    }
    if (s >= 2) {
      for (int i = 0; i < 4; i++) {
        if (ink[dy2[i] + y][dx2[i] + x] == 0)
          p--;
        ink[dy2[i] + y][dx2[i] + x]++;
        ma = max(ma, ink[dy2[i] + y][dx2[i] + x]);
      }
    }
    if (s >= 1) {
      for (int i = 0; i < 4; i++) {
        if (ink[dy1[i] + y][dx1[i] + x] == 0)
          p--;
        ink[dy1[i] + y][dx1[i] + x]++;
        ma = max(ma, ink[dy1[i] + y][dx1[i] + x]);
      }
    }
  }
  printf("%d\\n%d\\n", p, ma);
  return (0);
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;
int data[15][15] = {0};
int main() {

  int x, y, s;
  char c;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {

    while (1) {
      data[x][y]++;
      if (y - 1 >= 0)
        data[x][y - 1]++;
      if (x + 1 < 10)
        data[x + 1][y]++;
      if (y + 1 < 10)
        data[x][y + 1]++;
      if (x - 1 >= 0)
        data[x - 1][y]++;
      if (s == 1)
        break;
      if (x + 1 < 10 && y + 1 < 10)
        data[x + 1][y + 1]++;
      if (x + 1 < 10 && y - 1 >= 0)
        data[x + 1][y - 1]++;
      if (x - 1 >= 0 && y - 1 >= 0)
        data[x - 1][y - 1]++;
      if (x - 1 >= 0 && y + 1 < 10)
        data[x - 1][y + 1]++;
      if (s == 2)
        break;
      if (x + 2 < 10)
        data[x + 2][y]++;
      if (y - 2 >= 0)
        data[x][y - 2]++;
      if (y + 2 < 10)
        data[x][y + 2]++;
      if (x - 2 >= 0)
        data[x - 2][y]++;
      break;
    }
  }
  int white = 0, ma = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (data[i][j] == 0)
        white++;
      ma = max(ma, data[i][j]);
    }
  }

  cout << white << endl << ma << endl;
}


Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int data[15][15] = {0};
int main() {

  int x, y, s;
  char c;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {

    while (1) {
      data[x][y]++;
      if (y - 1 >= 0)
        data[x][y - 1]++;
      if (x + 1 < 10)
        data[x + 1][y]++;
      if (y + 1 < 10)
        data[x][y + 1]++;
      if (x - 1 >= 0)
        data[x - 1][y]++;
      if (s == 1)
        break;
      if (x + 1 < 10 && y + 1 < 10)
        data[x + 1][y + 1]++;
      if (x + 1 < 10 && y - 1 >= 0)
        data[x + 1][y - 1]++;
      if (x - 1 >= 0 && y - 1 >= 0)
        data[x - 1][y - 1]++;
      if (x - 1 >= 0 && y + 1 < 10)
        data[x - 1][y + 1]++;
      if (s == 2)
        break;
      if (x + 2 < 10)
        data[x + 2][y]++;
      if (y - 2 >= 0)
        data[x][y - 2]++;
      if (y + 2 < 10)
        data[x][y + 2]++;
      if (x - 2 >= 0)
        data[x - 2][y]++;
      break;
    }
  }
  int white = 0, ma = 0;
  for (int i = 0; i < i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (data[i][j] == 0)
        white++;
      ma = max(ma, data[i][j]);
    }
  }

  cout << white << " " << ma << endl;
}
Problem p00027 (C++) — buggy submission, verdict: 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 % 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;
}

Error: 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 % 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;
}
Problem p00027 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string youbi[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                     "Friday", "Saturday", "Sunday"};
  while (1) {
    int mon, day;
    cin >> mon >> day;
    if (mon == 0)
      break;

    int sum = 0;
    for (int i = 0; i < mon - 1; i++) {
      sum += days[i];
    }
    sum += day;

    cout << youbi[(sum + 2) % 7] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string youbi[7] = {"Monsay", "Tuesday",  "Wednesday", "Thursday",
                     "Friday", "Saturday", "Sunday"};
  while (1) {
    int mon, day;
    cin >> mon >> day;
    if (mon == 0)
      break;

    int sum = 0;
    for (int i = 0; i < mon - 1; i++) {
      sum += days[i];
    }
    sum += day;

    cout << youbi[sum % 7 + 2] << endl;
  }
  return 0;
}
Problem p00027 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  //	cut here before submit
  //	freopen("testcase.wdt", "r", stdin);
  // 2004/01/01 is Thursday
  const string week[] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                         "Friday", "Saturday", "Sunday"};
  const int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string str = "";

  while (1) {
    int month = 0;
    int day = 0;
    cin >> month >> day;
    if (month == 0 && day == 0) {
      break;
    } // end if
    int num = 0;
    for (int i = 0; i < month; ++i) {
      num += days[i];
    } // end for
    num += day;
    cout << week[(num - 1 + 3) % 7] << endl;
  } // end while

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  //	cut here before submit
  freopen("testcase.wdt", "r", stdin);
  // 2004/01/01 is Thursday
  const string week[] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                         "Friday", "Saturday", "Sunday"};
  const int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string str = "";

  while (1) {
    int month, day;
    cin >> month >> day;
    if (month == 0 && day == 0) {
      break;
    } // end if
    int num = 0;
    int i;
    for (i = 0; i < month; ++i) {
      num += days[i];
    } // end for
    num += day;
    cout << week[(num - 1 + 3) % 7] << endl;
  } // end while

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

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

using namespace std;
string a[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
               "Friday", "Saturday", "Sunday"};
int main(void) {
  int aa, b;
  int mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  while (cin >> aa >> b, aa + b) {
    int d = b;
    for (int i = 0; i < aa - 1; i++) {
      d += mon[i];
      // cout<<d<<endl;
    }

    cout << a[(d + 2) % 7] << endl;
  }
  //*/
}

Error: TLE

Fixed submission:

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

using namespace std;
string a[7] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
               "Friday", "Saturday", "Sunday"};
int main(void) {
  int aa, b;
  int mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  while (cin >> aa >> b, a + b) {
    int d = b;
    for (int i = 0; i < aa - 1; i++) {
      d += mon[i];
      cout << d << endl;
    }

    cout << a[(d + 2) % 7] << endl;
  }
  //*/
}
Problem p00027 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {

  int year = 2004, month, day;

  while (cin >> month >> day) {

    if (month == 0) {
      return 0;
    }

    if (month == 1 || month == 2) {
      year--;
      month += 12;
    }

    int tmp = (year + year / 4 - year / 100 + year / 400 +
               (13 * month + 8) / 5 + day) %
              7;

    cout << date[tmp] << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

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

int main(void) {

  vector<string> day(7);
  day[0] = "Saturday";
  day[1] = "Sunday";
  day[2] = "Monday";
  day[3] = "Tuesday";
  day[4] = "Wednesday";
  day[5] = "Thursday";
  day[6] = "Friday";
  int x, y;

  while (1) {
    cin >> x >> y;
    int h = 20;
    int n = 4;
    if (x == 0) {
      break;
    }
    if (x == 1 || x == 2) {
      n--;
      x += 12;
    }

    int w = n + n / 4 + h / 4 - 2 * h + 13 * (x + 1) / 5 + y;
    // cout << w << endl;

    // cout << w%7 << endl;

    string ans = day[w % 7];

    cout << ans << endl;
  }
  return 0;
}
Problem p00027 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <string>
using namespace std;

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

  int month, date, day, p;

  // 前月までの延べ日数に変換
  for (int i = 1; i < 13; i++) {
    days[i] += days[i - 1];
  }

  while (1) {
    cin >> month >> date;
    if (month == 0)
      break;

    day = days[month - 1] + date + 3;
    p = day % 7;

    cout << ans[p] << endl;
  }
  return 0;
}

Error: 255

Fixed submission:

#include <iostream>
#include <math.h>
#include <string>
using namespace std;

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

  int month, date;

  // 前月までの延べ日数に変換
  for (int i = 1; i < 13; i++) {
    days[i] += days[i - 1];
  }

  while (1) {
    cin >> month >> date;
    if (month == 0)
      return -1;

    int day = days[month - 1] + date + 3;
    int p = day % 7;

    cout << ans[p] << endl;
  }
  return 0;
}
Problem p00027 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  std::vector<std::string> day_of_week{"Thursday", "Friday", "Saturday",
                                       "Sunday",   "Monday", "Tuesday",
                                       "Wednesday"};

  std::vector<int> day_num_of_month{31, 29, 31, 30, 31, 30,
                                    31, 31, 30, 31, 30, 31};

  int month = 0;
  int day = 0;

  while (std::cin >> month >> day) {
    if (0 == month) {
      break;
    }

    int days_elapsed = 0;
    for (int m = 1; m < month; ++m) {
      days_elapsed += day_num_of_month[m - 1];
    }
    days_elapsed += day;

    std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  std::vector<std::string> day_of_week{"Thursday", "Friday", "Suterday",
                                       "Sunday",   "Monday", "Tuesday",
                                       "Wednesday"};

  std::vector<int> day_num_of_month{31, 29, 31, 30, 31, 30,
                                    31, 31, 30, 31, 30, 31};

  int month = 0;
  int day = 0;

  while (std::cin >> month >> day) {
    if (0 == month) {
      break;
    }

    int days_elapsed = 0;
    for (int m = 1; m < month; ++m) {
      days_elapsed += day_num_of_month[m - 1];
    }
    days_elapsed += day;

    std::cout << day_of_week[days_elapsed % 7 - 1] << std::endl;
  }

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

#include <stdio.h>

int main() {
  int y, d, m;
  int h;
  char *date[] = {"Saturday",  "Sunday",   "Monday", "Tuesday",
                  "Wednesday", "Thursday", "Friday"};

  for (;;) {
    int Y, C, G;
    y = 2004;
    scanf("%d %d", &m, &d);

    if (d == 0 || m == 0)
      break;
    if (m == 1 || m == 2) {
      m += 12;
      y--;
    }

    Y = y % 100;
    C = y / 100;
    G = 5 * C + C / 4;

    h = (d + (26 * (m + 1) / 10) + Y + Y / 4 + G) % 7;
    printf("%s\\n", date[h]);
  }

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main() {
  int y, d, m;
  int h;
  char *date[] = {"Saturday",  "Sunday",   "Monday", "Tuesday",
                  "Wednesday", "Thursday", "Friday"};

  for (;;) {
    int Y, C, G;
    y = 2004;

    scanf("%d %d", &m, &d);

    if (d == 0 || m == 0)
      break;
    if (m == 1 || m == 2) {
      m += 12;
      y--;
    }

    Y = y % 100;
    C = y / 100;
    G = (-2 * C) + (C / 4);

    h = (d + (26 * (m + 1) / 10) + Y + Y / 4 + G) % 7;

    printf("%s\\n", date[h]);
  }

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

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

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string week[] = {"Wednesday", "Thursday", "Friday", "Saturday",
                 "Sunday",    "Monday",   "Tuesday"};

int main() {
  int m, d;
  while (cin >> m >> d && m && d) {
    int sum = 0;
    rep(i, m) { sum += days[i]; }
    sum += d;
    cout << week[(sum) % 7] << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int month, day;
  int months[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string days[7] = {"Thursday", "Friday",  "Saturday",  "Sunday",
                    "Monday",   "Tuesday", "Wndnessday"};
  while (cin >> month >> day) {
    if (month == 0)
      break;
    else {
      int sum = 0;
      for (int i = 0; i < month - 1; i++) {
        sum += months[i];
      }
      sum += day;
      cout << days[sum % 7 - 1] << endl;
    }
  }
  return 0;
}