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

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, i, max, min;
  long long sum = 0;
  int a[100];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, i, max, min;
  long long sum = 0;
  int a[10000];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, i, a[1000], b, c, d, min = 1000000, max = -1000000, sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < min) {
      min = a[i];
    }
    if (a[i] > max) {
      max = a[i];
    }
    sum += a[i];
  }
  cout << min << " " << max << " " << sum << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long long n, i, a[10000], min = 1000000, max = -1000000, sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < min) {
      min = a[i];
    }
    if (a[i] > max) {
      max = a[i];
    }
    sum += a[i];
  }
  cout << min << " " << max << " " << sum << endl;
}
Problem p02402 (C++)

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

int main() {
  long a, b[100000000];
  long max, min, sum = 0;

  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> b[i];
    if (i == 0) {
      min = b[i];
      max = b[i];
    }

    if (b[i] < min) {
      min = b[i];
    } else if (max < b[i]) {
      max = b[i];
    }

    sum += b[i];
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}


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

int main() {
  int a, b[10001];
  long long int max, min, sum = 0;

  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> b[i];
    if (i == 0) {
      min = b[i];
      max = b[i];
    }

    if (b[i] < min) {
      min = b[i];
    } else if (max < b[i]) {
      max = b[i];
    }

    sum += b[i];
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}
Problem p02402 (C++)

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

int main() {
  long sum = 0;
  long fra[10000];
  int n;

  // 上限'n'の入力
  cin >> n;

  // 配列fra[]に値を代入、合計値sumに加算
  for (int i = 0; i < n; i++) {
    cin >> fra[i];
    sum = sum + fra[i];
  }

  while (1) {
    int flag = 0;
    // ソート本体
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] > fra[i] && i > 0 && i < n) {
        swap(fra[i - 1], fra[i]);
      }
    }
    // ソート判定
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] < fra[i] && i > 0) {
        count++;
      }
      if (count == n - 1) {
        flag = 1;
      }
    }

    if (flag == 1)
      break;
  }

  cout << fra[0] << " " << fra[n - 1] << " " << sum << endl;

  return 0;
}

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

int main() {
  long sum = 0;
  long fra[10000];
  int n;

  // 上限'n'の入力
  cin >> n;

  // 配列fra[]に値を代入、合計値sumに加算
  for (int i = 0; i < n; i++) {
    cin >> fra[i];
    sum = sum + fra[i];
  }

  while (1) {
    int flag = 0;
    // ソート本体
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] > fra[i] && i > 0 && i < n) {
        swap(fra[i - 1], fra[i]);
      }
    }
    // ソート判定
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] <= fra[i] && i > 0) {
        count++;
      }
      if (count == n - 1) {
        flag = 1;
      }
    }

    if (flag == 1)
      break;
  }

  cout << fra[0] << " " << fra[n - 1] << " " << sum << endl;

  return 0;
}
Problem p02402 (C++)

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

int main() {

  int n;
  cin >> n;

  int a[10000];
  for (int i = 0; 1 < n; i++)
    cin >> a[i];

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout << mn << " " << mx << " " << sum << endl;

  return 0;
}


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

int main() {

  int n;
  cin >> n;

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

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout << mn << " " << mx << " " << sum << endl;

  return 0;
}
Problem p02402 (C++)

Buggy submission (status: Time Limit Exceeded):

#include <iomanip>
#include <iostream>

using namespace std;

long long a, n, smallest, biggest, sum;
char op;

int main() {

  cin >> n;

  smallest = 0;
  biggest = 0;
  sum = 0;

  for (int i = 0; i + 1 <= n; i++) {

    cin >> a;

    if (i == 0 || a < smallest) {
      smallest = a;
    }
    if (i = 0 || a > biggest) {
      biggest = a;
    }

    sum += a;
  }

  cout << smallest << " " << biggest << " " << sum << endl;

  return 0;
}


Fixed submission:

#include <iomanip>
#include <iostream>

using namespace std;

long long a, n, smallest, biggest, sum;
char op;

int main() {

  cin >> n;

  smallest = 0;
  biggest = 0;
  sum = 0;

  for (int i = 0; i + 1 <= n; i++) {

    cin >> a;

    if (i == 0 || a < smallest) {
      smallest = a;
    }
    if (i == 0 || a > biggest) {
      biggest = a;
    }

    sum += a;
  }

  cout << smallest << " " << biggest << " " << sum << endl;

  return 0;
}
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, a[100], i, x, sum = 0, max = 0, min = 10000;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] > max) {
      max = a[i];
    }
    if (a[i] < min) {
      min = a[i];
    }
  }
  cout << min << " " << max << " " << sum << endl;
  // What Japanese people!?

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, a[10000], i, x;
  long long sum = 0, max = -1000000, min = 1000000;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] > max) {
      max = a[i];
    }
    if (a[i] < min) {
      min = a[i];
    }
  }
  cout << min << " " << max << " " << sum << endl;
  // What Japanese people!?

  return 0;
}
Problem p02402 (Python)

Buggy submission (status: Runtime Error):
input()

a = list(map(int, input().split()))

s = 0

for i in len(a):
    s = s + i

print(min(a), max(a), s)


Fixed submission:
input()

a = list(map(int, input().split()))

s = 0

for i in a:
    s = s + i

print(min(a), max(a), s)
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  long long a[1000] = {0};
  int n;
  long long min;
  long long max;
  int i;
  long long sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  min = a[0];
  for (i = 0; i < n; i++) {
    if (min > a[i])
      min = a[i];
  }
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  max = a[0];
  for (i = 0; i < n; i++) {
    if (max < a[i])
      max = a[i];
  }
  for (i = 0; i < n; i++)
    sum = sum + a[i];
  cout << min;
  cout << " ";
  cout << max;
  cout << " ";
  cout << sum;
  cout << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  long long a[10001] = {0};
  int n;
  long long min;
  long long max;
  int i;
  long long sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  min = a[0];
  for (i = 0; i < n; i++) {
    if (min > a[i])
      min = a[i];
  }
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  max = a[0];
  for (i = 0; i < n; i++) {
    if (max < a[i])
      max = a[i];
  }
  for (i = 0; i < n; i++)
    sum = sum + a[i];
  cout << min;
  cout << " ";
  cout << max;
  cout << " ";
  cout << sum;
  cout << endl;
}
Problem p02402 (C++)

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

int main(void) {
  int n, i, a[1000], max, min, sum;

  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sum = a[1];
  min = a[1];
  max = a[1];
  for (i = 2; i <= n; i++) {
    sum = sum + a[i];
    if (a[i] < min)
      min = a[i];
    if (a[i] > max)
      max = a[i];
  };
  cout << min << " " << max << " " << sum << endl;

  return 0;
}

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

int main(void) {
  long n, i, a[10001], max, min, sum;

  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sum = a[1];
  min = a[1];
  max = a[1];
  for (i = 2; i <= n; i++) {
    sum = sum + a[i];
    if (a[i] < min)
      min = a[i];
    if (a[i] > max)
      max = a[i];
  };
  cout << min << " " << max << " " << sum << endl;

  return 0;
}
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int n, sum = 0, a[100000000];
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  cout << a[0] << ' ' << a[n - 1] << ' ' << sum << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  long long n, sum = 0, a[10000];
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  cout << a[0] << ' ' << a[n - 1] << ' ' << sum << endl;
  return 0;
}
Problem p02402 (C++)

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

int main() {
  int n;
  cin >> n;
  int a[1000];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int mn = a[0];
  int mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }
  cout << mn << " " << mx << " " << sum << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[10000];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int mn = a[0];
  int mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }
  cout << mn << " " << mx << " " << sum << endl;
  return 0;
}
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, max, min;
  long long sum = 0;
  int a[1000];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, max, min;
  long long sum = 0;
  int a[10001];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
}
Problem p02403 (C++)

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

int main() {
  int h;
  int w;
  int a;
  while (true) {
    h = 3;
    w = 4;
    if (h == 0 && w == 0)
      break;
    while (h > 0) {
      a = w;
      while (a > 0) {
        cout << "#";
        a--;
      }
      cout << endl;
      h--;
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  int h;
  int w;
  int a;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    while (h > 0) {
      a = w;
      while (a > 0) {
        cout << "#";
        a--;
      }
      cout << endl;
      h--;
    }
    cout << endl;
  }
  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int a, b, j;
  while (cin >> a >> b, a || b) {
    for (; a; a--) {
      for (j = b; j; j++)
        cout << "#";
      cout << endl;
    }
    cout << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a, b, j;
  while (cin >> a >> b, a || b) {
    for (; a; a--) {
      for (j = b; j; j--)
        cout << "#";
      cout << endl;
    }
    cout << endl;
  }
}
Problem p02403 (C++)

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

int main(int argc, char const *argv[]) {
  int h, w;
  std::cin >> h >> w;
  while (!(h == 0 && h == w)) {
    for (int i = 0; i < h; i++) {
      for (int i = 0; i < w; i++) {
        std::cout << "#";
      }
      std::cout << std::endl;
    }
  }

  return 0;
}

Fixed submission:
#include <iostream>

int main(int argc, char const *argv[]) {
  int h, w;
  std::cin >> h >> w;
  while (!(h == 0 && h == w)) {
    for (int i = 0; i < h; i++) {
      for (int i = 0; i < w; i++) {
        std::cout << "#";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
    std::cin >> h >> w;
  }

  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main(void) {
  int H, W, i, j;
  while (1) {
    scanf("%d %d\n", H, W);
    if (H == 0 && W == 0) {
      break;
    }
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}


Fixed submission:
#include <stdio.h>

int main(void) {
  int H, W, i, j;
  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) {
      break;
    }
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}
Problem p02403 (C++)

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

int main() {
  while (1) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;

    for (int i = 0; i = H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


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

int main() {
  while (1) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
long long a[10005];
int main() {
  int H, W, i, j;
  cin >> H >> W;
  i = 0;
  j = 0;
  while (H != 0 || W != 0) {
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
long long a[10005];
int main() {
  int H, W, i = 0, j = 0;
  bool b = false;
  while (cin >> H >> W) {
    if (H == 0 && W == 0) {
      cout << endl;
      break;
    }
    if (b == true)
      cout << endl;
    b = true;
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
  }
}
Problem p02403 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  int i, j;
  int h, w;

  while (1) {
    scanf("%d %d", h, w);
    if (!(h || w))
      break;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++)
        printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  int i, j;
  int h, w;

  while (1) {
    scanf("%d %d", &h, &w);
    if (!(h || w))
      break;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++)
        printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02403 (C++)

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

int main() {
  int w, h;

  while (true) {
    cin >> w >> h;

    for (int hh = 0; hh < h; hh++) {
      for (int ww = 0; ww < w; ww++) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;

int main() {
  int w, h;

  while (true) {
    cin >> h >> w;
    if (w == 0 && h == 0) {
      break;
    }

    for (int hh = 0; hh < h; hh++) {
      for (int ww = 0; ww < w; ww++) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

typedef long long ll;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if ((H != 0) || (W != 0)) {
      REP(i, H) {
        REP(j, W) { cout << "#"; }
        cout << endl;
      }
      cout << endl;
    }
  }

  return 0;
}


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

typedef long long ll;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if ((H != 0) || (W != 0)) {
      REP(i, H) {
        REP(j, W) { cout << "#"; }
        cout << endl;
      }
      cout << endl;
    } else
      break;
  }

  return 0;
}
Problem p02403 (C++)

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

using namespace std;

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; i < W; ++j) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  int h, w;
  while (scanf("%d %d", h, w) && (h != 0 || w != 0)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Fixed submission:
#include <stdio.h>

int main() {
  int h, w;
  while (scanf("%d %d", &h, &w) && (h != 0 || w != 0)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main(void) {
  int x, y;
  int i, j;
  while (1) {
    scanf("%d %d\n", &x, &y);
    for (i = 0; i < x; i++) {
      for (j = 0; j < y; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Fixed submission:
#include <stdio.h>

int main(void) {
  int x, y;
  int i, j;
  while (1) {
    scanf("%d %d\n", &x, &y);
    if (x == 0 && y == 0)
      break;
    for (i = 0; i < x; i++) {
      for (j = 0; j < y; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02403 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  while ((H != 0) || (W != 0)) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  while ((H != 0) || (W != 0)) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> H >> W;
  }
  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    if (H == 0 || W == 0) {
      H = W = -1;
      if (H == 0 && W == 0) {
        break;
      }
    }
    for (int i = 0; i < H; i++) {
      for (int ii = 0; ii < W; ii++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int H, W;
  while (1) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }
    for (int i = 0; i < H; i++) {
      for (int ii = 0; ii < W; ii++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; i++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02403 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int h, w, i, j;
  for (;;) {
    cin >> h >> w;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int h, w, i, j;
  for (;;) {
    cin >> h >> w;
    if (h == 0 && w == 0) {
      break;
    }
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <cstring>
int main() {
  char ss[101];
  int h, w, i, j;
  while (true) {
    scanf("%d %d", &h, &w);
    if ((h == 0) && (w == 0))
      break;
    strcpy(ss, "#");
    for (i = 0; i < w - 2; i++)
      strcat(ss, ".");
    strcat(ss, "#\n");
    for (i = 0; i < w; i++)
      printf("#");
    printf("\n");
    for (i = 0; i < h - 2; i++)
      printf(ss);
    for (i = 0; i < w; i++)
      printf("#");
    printf("\n\n");
  }
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstring>
int main() {
  char ss[301];
  int h, w, i, j;
  while (true) {
    scanf("%d %d", &h, &w);
    if ((h == 0) && (w == 0))
      break;
    strcpy(ss, "#");
    for (i = 0; i < w - 2; i++)
      strcat(ss, ".");
    strcat(ss, "#\n");
    for (i = 0; i < w; i++)
      printf("#");
    printf("\n");
    for (i = 0; i < h - 2; i++)
      printf(ss);
    for (i = 0; i < w; i++)
      printf("#");
    printf("\n\n");
  }
  return 0;
}
Problem p02404 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

int main() {
  std::ifstream in("input.txt");
  std::cin.rdbuf(in.rdbuf());

  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 and w == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 or i == h - 1) {
          cout << "#";
        } else if (j == 0 or j == w - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


Fixed submission:
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

int main() {

  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 and w == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 or i == h - 1) {
          cout << "#";
        } else if (j == 0 or j == w - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}
Problem p02404 (C++)

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

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    for (int i = 0; i < W; i++)
      cout << "#";
    cout << endl;
    for (int i = 1; i < H - 1; i++) {
      cout << "#";
      for (int i = 1; i < W - 1; i++)
        cout << ".";
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++)
      cout << "#";
    cout << endl << endl;
  }
}

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

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    if (W == 0 && H == 0)
      break;
    for (int i = 0; i < W; i++)
      cout << "#";
    cout << endl;
    for (int i = 1; i < H - 1; i++) {
      cout << "#";
      for (int i = 1; i < W - 1; i++)
        cout << ".";
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++)
      cout << "#";
    cout << endl << endl;
  }
}
Problem p02404 (C++)

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

int main() {
  int a, b;
  while (1) {
    cin >> a >> b;
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (i == 1 || j == 1 || i == a || j == b) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  int a, b;
  while (1) {
    cin >> a >> b;
    if (a == 0 && b == 0) {
      break;
    }
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (i == 1 || j == 1 || i == a || j == b) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++)

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  while (h || w) {
    for (int i = 0; i < w; ++i) {
      cout << "#";
    }
    cout << endl;
    for (int i = 1; i < h - 1; ++i) {
      cout << "#";
      for (int j = 1; j < w - 1; ++j) {
        cout << ".";
      }
      cout << "#" << endl;
    }
    for (int i = 0; i < w; ++i) {
      cout << "#";
    }
    cout << endl << endl;
  }
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  while (h || w) {
    for (int i = 0; i < w; ++i) {
      cout << "#";
    }
    cout << endl;
    for (int i = 1; i < h - 1; ++i) {
      cout << "#";
      for (int j = 1; j < w - 1; ++j) {
        cout << ".";
      }
      cout << "#" << endl;
    }
    for (int i = 0; i < w; ++i) {
      cout << "#";
    }
    cout << endl << endl;
    cin >> h >> w;
  }
}
Problem p02404 (C++)

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

int main() {
  int H, W;
  int i, j;
  while (1) {
    char fig1[101] = {0};
    char fig2[101] = {0};
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (i = 0; i < W; i++) {
      fig1[i] = '#';
    }
    fig2[0] = '#';
    fig2[W - 1] = '#';
    for (i = 1; i < W - 1; i++) {
      fig2[i] = '.';
    }
    cout << fig1 << endl;
    for (i = 0; i < H - 2; i++) {
      cout << fig2 << endl;
    }
    cout << fig1 << endl;
    cout << endl;
  }
  return 0;
}

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

int main() {
  int H, W;
  int i, j;
  while (1) {
    char fig1[301] = {0};
    char fig2[301] = {0};
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (i = 0; i < W; i++) {
      fig1[i] = '#';
    }
    fig2[0] = '#';
    fig2[W - 1] = '#';
    for (i = 1; i < W - 1; i++) {
      fig2[i] = '.';
    }
    cout << fig1 << endl;
    for (i = 0; i < H - 2; i++) {
      cout << fig2 << endl;
    }
    cout << fig1 << endl;
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++)

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

int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1)
          cout << "#";
        else {
          if (j == 0 || j == w - 1)
            cout << "#";
          else
            cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
  int h, w;
  while (true) {
    cin >> h >> w;

    if (h == 0 && w == 0)
      break;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1)
          cout << "#";
        else {
          if (j == 0 || j == w - 1)
            cout << "#";
          else
            cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < w; i++)
      cout << '#';
    cout << endl;
    for (int i = 2; i < h; i++) {
      cout << '#';
      for (int j = 2; j < w; j++)
        cout << '.';
      cout << '#' << endl;
    }
    for (int i = 0; i < w; i++)
      cout << '#';
    cout << endl;
    cout << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    for (int i = 0; i < w; i++)
      cout << '#';
    cout << endl;
    for (int i = 2; i < h; i++) {
      cout << '#';
      for (int j = 2; j < w; j++)
        cout << '.';
      cout << '#' << endl;
    }
    for (int i = 0; i < w; i++)
      cout << '#';
    cout << endl;
    cout << endl;
  }
}
Problem p02404 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main() {
  int h, w;
  while (scanf("%d %d", &h, &w) && (h != 0 || w != 0)) {
    for (int i = 0; i < h; i++) {
      printf("#");
      for (int j = 0; i < h - 2; j++) {
        printf(".");
      }
      printf("#\n");
    }
    printf("\n");
  }
  return 0;
}


Fixed submission:
#include <stdio.h>

int main() {
  int h, w;
  while (scanf("%d %d", &h, &w) && (h != 0 || w != 0)) {
    for (int i = 0; i < h; i++) {
      printf("#");
      for (int j = 0; j < w - 2; j++) {
        if (i == 0 || i == h - 1) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("#\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02404 (C++)

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

int main(int argc, char const *argv[]) {
  int h, w;
  std::cin >> h >> w;
  while (!(h == 0 && h == w)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; i++) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
          std::cout << "#";
        } else {
          std::cout << ".";
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
    std::cin >> h >> w;
  }

  return 0;
}

Fixed submission:
#include <iostream>

int main(int argc, char const *argv[]) {
  int h, w;
  std::cin >> h >> w;
  while (!(h == 0 && h == w)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
          std::cout << "#";
        } else {
          std::cout << ".";
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
    std::cin >> h >> w;
  }

  return 0;
}
Problem p02404 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int H, W;
  while (1) {
    scanf("%d %d", H, W);
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i == 0 || i == H - 1) {
          printf("#");
        } else {
          if (j == 0 || j == W - 1) {
            printf("#");
          } else {
            printf(".");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int H, W;
  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i == 0 || i == H - 1) {
          printf("#");
        } else {
          if (j == 0 || j == W - 1) {
            printf("#");
          } else {
            printf(".");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02404 (C++)

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

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H - 2; i++) {
      cout << "#";
      for (int i = 0; i < W - 2; i++) {
        cout << ".";
      }
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl << endl;
  }
  return 0;
}

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

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      return 0;
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H - 2; i++) {
      cout << "#";
      for (int i = 0; i < W - 2; i++) {
        cout << ".";
      }
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl << endl;
  }
  return 0;
}
Problem p02405 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  int H, W;
  while (1) {
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == 0) {
          if (j % 2 == 0) {
            printf("#");
          } else {
            printf(".");
          }
        } else {
          if (j % 2 == 0) {
            printf(".");
          } else {
            printf("#");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int H, W;
  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == 0) {
          if (j % 2 == 0) {
            printf("#");
          } else {
            printf(".");
          }
        } else {
          if (j % 2 == 0) {
            printf(".");
          } else {
            printf("#");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02405 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  while (h != 0 || w != 0) {
    int i, j, k;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        k = i + j;
        if (k % 2 == 0)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  while (h != 0 || w != 0) {
    int i, j, k;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        k = i + j;
        if (k % 2 == 0)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}
Problem p02405 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main() {
  int a, b;
  while (1) {
    scanf("%d %d", &a, &b);
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < b; j++) {
        if (i % 2 == 0) {
          if (j % 2 == 0)
            printf("#");
          else
            printf(".");
        } else {
          if (j % 2 == 0)
            printf(".");
          else
            printf("#");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Fixed submission:
#include <stdio.h>

int main() {
  int a, b;
  while (1) {
    scanf("%d %d", &a, &b);
    if (a == 0 || b == 0)
      break;
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < b; j++) {
        if (i % 2 == 0) {
          if (j % 2 == 0)
            printf("#");
          else
            printf(".");
        } else {
          if (j % 2 == 0)
            printf(".");
          else
            printf("#");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
Problem p02405 (C++)

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

int main() {
  int h, w;
  cin >> h >> w;
  while (h != 0 || w != 0) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

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

int main() {
  int h, w;
  cin >> h >> w;
  while (h != 0 || w != 0) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
}
Problem p02405 (C++)

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

int main() {
  int H = 0, W = 0;
  while (1) {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == 0 && j % 2 == 0)
          cout << "#";
        if (i % 2 == 0 && j % 2 != 0)
          cout << ".";
        if (i % 2 != 0 && j % 2 == 0)
          cout << ".";
        if (i % 2 != 0 && j % 2 != 0)
          cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
  int H = 0, W = 0;
  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == 0 && j % 2 == 0)
          cout << "#";
        if (i % 2 == 0 && j % 2 != 0)
          cout << ".";
        if (i % 2 != 0 && j % 2 == 0)
          cout << ".";
        if (i % 2 != 0 && j % 2 != 0)
          cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02405 (C++)

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

int main() {
  int W, H = 0;
  char c = '#';
  cin >> H >> W;
  do {
    for (int i = 0; i < H; i++) {
      if (i % 2 == 0) {
        c = '#';
      } else {
        c = '.';
      }
      for (int j = 0; j < W; j++) {
        cout << c;
        if (c == '#') {
          c = '.';
        } else {
          c = '#';
        }
      }
      cout << endl;
    }
  } while ((H != 0) || (W != 0)); //?¶??¶??????¶
  return 0;
}

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

int main() {
  int W, H = 0;
  char c = '#';
  cin >> H >> W;
  do {
    for (int i = 0; i < H; i++) {
      if (i % 2 == 0) {
        c = '#';
      } else {
        c = '.';
      }
      for (int j = 0; j < W; j++) {
        cout << c;
        if (c == '#') {
          c = '.';
        } else {
          c = '#';
        }
      }
      cout << endl;
    }
    cout << endl;
    cin >> H >> W;
  } while ((H != 0) || (W != 0)); //?¶??¶??????¶
  return 0;
}
Problem p02405 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}
Problem p02405 (C++)

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

int main() {

  for (int x = 0; true; x++) {
    int h, w;
    cin >> h >> w;

    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }

        if (j == w) {
          cout << endl;
        }
      }
      if (i == h) {
        cout << endl;
      }
    }
  }

  return 0;
}

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

int main() {

  for (int x = 0; true; x++) {
    int h, w;
    cin >> h >> w;

    if (h == 0 && w == 0)
      break;

    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }

        if (j == w) {
          cout << endl;
        }
      }
      if (i == h) {
        cout << endl;
      }
    }
  }

  return 0;
}
Problem p02406 (C++)

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

using namespace std;

int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          continue;
        }
        x /= 10;
      }
    }
  }

  cout << endl;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }

  cout << endl;
}
Problem p02406 (C++)

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

using namespace std;

int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      while (x >= 0) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x = x / 10;
      }
    }
  }
  cout << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      while (x > 0) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x = x / 10;
      }
    }
  }
  cout << endl;
}
Problem p02406 (C++)

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

int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      do {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      } while (1);
    }
  }
  cout << endl;
  return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      do {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      } while (x);
    }
  }
  cout << endl;
  return 0;
}
Problem p02406 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) {
      cout << " " << i;
    } else {
      int x = i;
      while ((x % 10) != 3 || x != 0) {
        x /= 10;
      }
      if (x != 0) {
        cout << " " << i;
      }
    }
  }
  cout << endl;

  return 0;
}

Fixed submission:
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) {
      cout << " " << i;
    } else {
      int x = i;
      while ((x % 10) != 3 && x != 0) {
        x /= 10;
      }
      if (x != 0) {
        cout << " " << i;
      }
    }
  }
  cout << endl;

  return 0;
}
Problem p02406 (C++)

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    while (x > 0) {
      if (x % 3 == 0 || x % 10 == 3) {
        cout << " " << i;
      } else {
        x /= 10;
      }
    }
  }
  cout << endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) {
      cout << " " << i;
    } else {
      for (int x = i; x != 0; x /= 10) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;

  return 0;
}
Problem p02406 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  long n, q[1000];

  cin >> n;

  for (long i = 1; i < n + 1; i++) {
    if (i % 3 == 0) {
      cout << " " << i;
      q[i] = -1;
    } else if (i % 10 == 3) {
      cout << " " << i;
      q[i] = -1;
    }

    ostringstream p;
    p << i;
    string pp;
    pp = p.str();
    int k = 0;
    k = pp.size();
    for (int j = 0; j < k; j++) {
      if (pp.substr(j, 1) == "3" && q[i] != -1) {
        cout << " " << i;
        break;
      }
    }
  }
  cout << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  long n, q[10000];

  cin >> n;

  for (long i = 1; i < n + 1; i++) {
    if (i % 3 == 0) {
      cout << " " << i;
      q[i] = -1;
    } else if (i % 10 == 3) {
      cout << " " << i;
      q[i] = -1;
    }

    ostringstream p;
    p << i;
    string pp;
    pp = p.str();
    int k = 0;
    k = pp.size();
    for (int j = 0; j < k; j++) {
      if (pp.substr(j, 1) == "3" && q[i] != -1) {
        cout << " " << i;
        break;
      }
    }
  }
  cout << endl;
}