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

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

typedef long long ll;
const int maxn = 2e3 + 10, mod = 998244353;
int n, k;
ll cc[maxn][maxn];

inline ll c(int n, int m) {
  if (n < 0 || m < 0)
    return 0;
  return cc[n][m];
}
inline ll f(int n, int k) { return c(n + k - 1, n); }
inline ll calc(int sum) {
  ll res = 0;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 1; i <= k && i < sum - i; ++i)
    if (sum - i <= k)
      ++cnt1;
  cnt2 = k - cnt1 * 2;
  if (sum & 1)
    for (int i = 0, x = 1; i <= cnt1; ++i, x = x * 2 % mod)
      (res += c(cnt1, i) * x % mod * f(n - i, i + cnt2)) %= mod;
  else {
    --cnt2;
    for (int i = 0, x = 1; i <= cnt1; ++i, x = x * 2 % mod) {
      (res += c(cnt1, i) * x % mod * f(n - i, i + cnt2)) %= mod;
      (res += c(cnt1, i) * x % mod * f(n - 1 - i, i + cnt2)) %= mod;
    }
  }
  return res;
}

int main() {
  for (int i = 0; i < maxn; ++i) {
    cc[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      cc[i][j] = (cc[i - 1][j - 1] + cc[i - 1][j]) % mod;
  }
  cin >> k >> n;
  for (int i = 2; i <= 2 * k; ++i)
    cout << calc(i) << endl;
  return 0;
}

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

typedef long long ll;
const int maxn = 4e3 + 10, mod = 998244353;
int n, k;
ll cc[maxn][maxn];

inline ll c(int n, int m) {
  if (n < 0 || m < 0)
    return 0;
  return cc[n][m];
}
inline ll f(int n, int k) { return c(n + k - 1, n); }
inline ll calc(int sum) {
  ll res = 0;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 1; i <= k && i < sum - i; ++i)
    if (sum - i <= k)
      ++cnt1;
  cnt2 = k - cnt1 * 2;
  if (sum & 1)
    for (int i = 0, x = 1; i <= cnt1; ++i, x = x * 2 % mod)
      (res += c(cnt1, i) * x % mod * f(n - i, i + cnt2)) %= mod;
  else {
    --cnt2;
    for (int i = 0, x = 1; i <= cnt1; ++i, x = x * 2 % mod) {
      (res += c(cnt1, i) * x % mod * f(n - i, i + cnt2)) %= mod;
      (res += c(cnt1, i) * x % mod * f(n - 1 - i, i + cnt2)) %= mod;
    }
  }
  return res;
}

int main() {
  for (int i = 0; i < maxn; ++i) {
    cc[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      cc[i][j] = (cc[i - 1][j - 1] + cc[i - 1][j]) % mod;
  }
  cin >> k >> n;
  for (int i = 2; i <= 2 * k; ++i)
    cout << calc(i) << endl;
  return 0;
}
Problem p03270 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;
const long long M = 998244353;

long long c[5001][5001];
long long ch(int n, int k) {
  if (0 > n || k > n)
    return 0;
  return c[n][k];
}

int main() {
  int k, n;
  cin >> k >> n;
  for (int a = 0; a <= 5000; a++) {
    c[a][0] = 1;
    c[a][a] = 1;
    for (int b = 1; b < a; b++) {
      c[a][b] = (c[a - 1][b] + c[a - 1][b - 1]) % M;
    }
  }
  for (int i0 = 2; i0 <= 2 * k; i0++) {
    int i = (i0 > k + 1) ? 2 * k - i0 + 2 : i0;
    long long ans = 0;
    int u = min(k, i / 2), l = max(1, i - k);
    for (int m = 0; m <= u - l + 1; m++) {
      ans += (ch(u - l + 1, m) * ch(n + k - 1 - 2 * m, n - 2 * m) *
              (m % 2 == 0 ? 1 : -1)) %
             M;
      ans %= M;
    }
    cout << (ans % M + M) % M << endl;
  }
}


Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;
const long long M = 998244353;

long long c[5001][5001];
long long ch(int n, int k) {
  if (0 > n || k > n)
    return 0;
  if (k < 0)
    return 0;
  return c[n][k];
}

int main() {
  int k, n;
  cin >> k >> n;
  for (int a = 0; a <= 5000; a++) {
    c[a][0] = 1;
    c[a][a] = 1;
    for (int b = 1; b < a; b++) {
      c[a][b] = (c[a - 1][b] + c[a - 1][b - 1]) % M;
    }
  }
  for (int i0 = 2; i0 <= 2 * k; i0++) {
    int i = (i0 > k + 1) ? 2 * k - i0 + 2 : i0;
    long long ans = 0;
    int u = min(k, i / 2), l = max(1, i - k);
    for (int m = 0; m <= u - l + 1; m++) {
      ans += (ch(u - l + 1, m) * ch(n + k - 1 - 2 * m, n - 2 * m) *
              (m % 2 == 0 ? 1 : -1)) %
             M;
      ans %= M;
    }
    cout << (ans % M + M) % M << endl;
  }
}
Problem p03270 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const int MAXN = 2100;

int K, N;
ll pascal[MAXN][MAXN];

int main() {
  ios_base::sync_with_stdio(0);
  pascal[0][0] = 1;
  for (int i = 1; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++) {
      pascal[i][j] = pascal[i - 1][j];
      if (j)
        pascal[i][j] = (pascal[i][j] + pascal[i - 1][j - 1]) % MOD;
    }

  cin >> K >> N;
  for (int i = 2; i <= 2 * K; i++) {
    int n2 = 0, n1 = 0;
    for (int j = 1; j <= K; j++) {
      if (j * 2 == i)
        continue;
      if ((i - j) <= K && (i - j) >= 1)
        n2++;
      else
        n1++;
    }
    n2 /= 2;
    // cout << n2 << " " << n1 << "\n";

    ll res = 0;
    ll p2 = 1;
    for (int j = 0; j <= n2; j++) {
      if (j)
        p2 = (p2 * 2) % MOD;
      if (j > N)
        continue;
      if (j == 0 && n1 == 0)
        continue;
      res =
          (res + pascal[n2][j] * (p2 * pascal[N + n1 - 1][j + n1 - 1] % MOD)) %
          MOD;
      if (i % 2 == 0)
        res = (res +
               pascal[n2][j] * (p2 * pascal[N + n1 - 2][j + n1 - 1] % MOD)) %
              MOD;
    }
    cout << res << "\n";
  }
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const int MAXN = 4100;

int K, N;
ll pascal[MAXN][MAXN];

int main() {
  ios_base::sync_with_stdio(0);
  pascal[0][0] = 1;
  for (int i = 1; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++) {
      pascal[i][j] = pascal[i - 1][j];
      if (j)
        pascal[i][j] = (pascal[i][j] + pascal[i - 1][j - 1]) % MOD;
    }

  cin >> K >> N;
  for (int i = 2; i <= 2 * K; i++) {
    int n2 = 0, n1 = 0;
    for (int j = 1; j <= K; j++) {
      if (j * 2 == i)
        continue;
      if ((i - j) <= K && (i - j) >= 1)
        n2++;
      else
        n1++;
    }
    n2 /= 2;
    // cout << n2 << " " << n1 << "\n";

    ll res = 0;
    ll p2 = 1;
    for (int j = 0; j <= n2; j++) {
      if (j)
        p2 = (p2 * 2) % MOD;
      if (j > N)
        continue;
      if (j == 0 && n1 == 0)
        continue;
      res =
          (res + pascal[n2][j] * (p2 * pascal[N + n1 - 1][j + n1 - 1] % MOD)) %
          MOD;
      if (i % 2 == 0)
        res = (res +
               pascal[n2][j] * (p2 * pascal[N + n1 - 2][j + n1 - 1] % MOD)) %
              MOD;
    }
    cout << res << "\n";
  }
}
Problem p03271 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005, p = 1000000007;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    g = g * 10 + ch - '0';
  return f * g;
}
int n, a[N], h[N];
bool check(int l, int r) {
  int x = 0, y = 0;
  for (int i = l; i <= r; i++) {
    if ((a[i] < l) || (a[i] > r))
      return false;
    if (a[i] < i) {
      if (x > a[i])
        return false;
      x = a[i];
    } else if (a[i] > i) {
      if (y > a[i])
        return false;
      y = a[i];
    }
  }
  return true;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++)
    a[i] = read(), h[i] = (a[i] == i);
  for (int i = 2; i < n; i++)
    if (h[i - 1] + h[i] + h[i + 1] == 0) {
      puts("No");
      return 0;
    }
  int l = 1, r;
  while (l <= n) {
    if (h[l]) {
      l++;
      continue;
    }
    for (r = l + 1; (r <= n) && (h[r] ^ h[r - 1]); r++)
      ;
    if (h[r - 1])
      r--;
    if (!check(l, r - 1)) {
      puts("No");
      return 0;
    }
    l = r;
  }
  puts("Yes");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300005, p = 1000000007;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    g = g * 10 + ch - '0';
  return f * g;
}
int n, a[N], h[N];
bool check(int l, int r) {
  int x = 0, y = 0;
  for (int i = l; i <= r; i++) {
    if ((a[i] < l) || (a[i] > r))
      return false;
    if (a[i] < i) {
      if (x > a[i])
        return false;
      x = a[i];
    } else if (a[i] > i) {
      if (y > a[i])
        return false;
      y = a[i];
    }
  }
  return true;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++)
    a[i] = read(), h[i] = (a[i] == i);
  for (int i = 2; i < n; i++)
    if (h[i - 1] + h[i] + h[i + 1] == 0) {
      puts("No");
      return 0;
    }
  int l = 1, r;
  while (l <= n) {
    if (h[l]) {
      l++;
      continue;
    }
    for (r = l + 1; (r <= n) && (h[r] ^ h[r - 1]); r++)
      ;
    if (h[r - 1])
      r--;
    if (!check(l, r - 1)) {
      puts("No");
      return 0;
    }
    l = r;
  }
  puts("Yes");
  return 0;
}
Problem p03271 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int sum[maxn];
int n, val[maxn], stk[maxn], t;
void update(int x, int v) {
  for (; x <= n; x += x & -x)
    sum[x] += v;
}
int query(int x) {
  int ret = 0;
  for (; x >= 1; x -= x & -x)
    ret += sum[x];
  return ret;
}
long long calc(int *a, int m) {
  memset(sum, 0, sizeof(sum));
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    ans += query(n) - query(a[i]);
    update(a[i], 1);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &val[i]);
  for (int i = 1; i <= n; i++)
    if ((val[i] & 1) != (i & 1)) {
      printf("No\n");
      return 0;
    }
  long long all = calc(val, n);
  if (all % 3) {
    printf("No\n");
    return 0;
  }
  long long t1, t2;
  t = 0;
  for (int i = 1; i <= n; i++)
    if (i & 1)
      stk[++t] = val[i];
  t1 = calc(stk, t);
  t = 0;
  for (int i = 1; i <= n; i++)
    if (i % 2 == 0)
      stk[++t] = val[i];
  t2 = calc(stk, t);
  if (all / 3 == t1 + t2)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int sum[maxn];
int n, val[maxn], stk[maxn], t;
void update(int x, int v) {
  for (; x <= n; x += x & -x)
    sum[x] += v;
}
int query(int x) {
  int ret = 0;
  for (; x >= 1; x -= x & -x)
    ret += sum[x];
  return ret;
}
long long calc(int *a, int m) {
  memset(sum, 0, sizeof(sum));
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    ans += query(n) - query(a[i]);
    update(a[i], 1);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &val[i]);
  for (int i = 1; i <= n; i++)
    if ((val[i] & 1) != (i & 1)) {
      printf("No\n");
      return 0;
    }
  long long all = calc(val, n);
  if (all % 3) {
    printf("No\n");
    return 0;
  }
  long long t1, t2;
  t = 0;
  for (int i = 1; i <= n; i++)
    if (i & 1)
      stk[++t] = val[i];
  t1 = calc(stk, t);
  t = 0;
  for (int i = 1; i <= n; i++)
    if (i % 2 == 0)
      stk[++t] = val[i];
  t2 = calc(stk, t);
  if (all / 3 == t1 + t2)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
Problem p03271 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#define rep(i, x, y) for (int i = x; i <= y; ++i)

using namespace std;
const int N = 100005;
int n, a[N];

bool check(int l, int r) {
  int mn = n + 1, mx = 0;
  rep(i, l, r) mn = min(mn, a[i]), mx = max(mx, a[i]);
  if (mn != l || mx != r)
    return 0;
  int x = 0, y = 0;
  for (int i = l; i <= r; i += 2)
    if (x < a[i] && y < a[i])
      y = a[i];
    else if (x < a[i])
      x = a[i];
    else
      return 0;
  return 1;
}

int main() {
  scanf("%d", &n);
  rep(i, 1, n) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == i)
      continue;
    int p = i;
    while (p <= n - 2) {
      if (a[p + 1] != p + 1)
        break;
      if (a[p + 2] == p + 2)
        break;
      p += 2;
    }
    if (!check(i, p))
      return puts("No"), 0;
    i = p;
  }
  puts("Yes");
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#define rep(i, x, y) for (int i = x; i <= y; ++i)

using namespace std;
const int N = 300005;
int n, a[N];

bool check(int l, int r) {
  int mn = n + 1, mx = 0;
  rep(i, l, r) mn = min(mn, a[i]), mx = max(mx, a[i]);
  if (mn != l || mx != r)
    return 0;
  int x = 0, y = 0;
  for (int i = l; i <= r; i += 2)
    if (x < a[i] && y < a[i])
      y = a[i];
    else if (x < a[i])
      x = a[i];
    else
      return 0;
  return 1;
}

int main() {
  scanf("%d", &n);
  rep(i, 1, n) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == i)
      continue;
    int p = i;
    while (p <= n - 2) {
      if (a[p + 1] != p + 1)
        break;
      if (a[p + 2] == p + 2)
        break;
      p += 2;
    }
    if (!check(i, p))
      return puts("No"), 0;
    i = p;
  }
  puts("Yes");
  return 0;
}
Problem p03271 (C++)

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

#define ll long long
#define fornum(A, B, C) for (A = B; A < C; A++)

using namespace std;

int i, j, k, l, m, n;
/////////////////////////////////////////////////////
#define MOD 998244353
#define NMax 303030
int N;
int p[NMax];

void no() {
  printf("No");
  exit(1);
}

int main() {
  scanf("%d", &N);

  for (i = 1; i <= N; i++) {
    scanf("%d", &p[i]);
    p[i] = p[i] - i;
    if (p[i] % 2)
      no();
  }

  int check[2] = {0, 0};
  int v1 = 0;
  for (i = 1; i <= N; i++) {
    if (check[i & 1] != 0 && p[i] == 0)
      no();
    check[i & 1] += p[i];
    if (check[0] * check[1] != 0)
      no();
    if (p[i] < 0) {
      if (p[i] + i < v1)
        no();
      v1 = p[i] + i;
    }
    if (check[0] + check[1] == 0)
      v1 = 0;
  }
  v1 = N + 1;
  for (i = N; i >= 1; i--) {
    if (p[i] > 0) {
      if (p[i] + i > v1)
        no();
      v1 = p[i] + i;
    }
  }
  printf("Yes");
  return 0;
}

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

#define ll long long
#define fornum(A, B, C) for (A = B; A < C; A++)

using namespace std;

int i, j, k, l, m, n;
/////////////////////////////////////////////////////
#define MOD 998244353
#define NMax 303030
int N;
int p[NMax];

void no() {
  printf("No");
  exit(0);
}

int main() {
  scanf("%d", &N);

  for (i = 1; i <= N; i++) {
    scanf("%d", &p[i]);
    p[i] = p[i] - i;
    if (p[i] % 2)
      no();
  }

  int check[2] = {0, 0};
  int v1 = 0;
  for (i = 1; i <= N; i++) {
    if (check[i & 1] != 0 && p[i] == 0)
      no();
    check[i & 1] += p[i];
    if (check[0] * check[1] != 0)
      no();
    if (p[i] < 0) {
      if (p[i] + i < v1)
        no();
      v1 = p[i] + i;
    }
    if (check[0] + check[1] == 0)
      v1 = 0;
  }
  v1 = N + 1;
  for (i = N; i >= 1; i--) {
    if (p[i] > 0) {
      if (p[i] + i > v1)
        no();
      v1 = p[i] + i;
    }
  }
  printf("Yes");
  return 0;
}
Problem p03272 (Python)

Buggy submission (status: Runtime Error):
x = int(input())
y = int(input())
if x == y:
    print(y)
else:
    print(y - x + 1)


Fixed submission:
a, b = map(int, input().split())
print(a + 1 - b)
# Source code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 characters
Problem p03272 (Python)

Buggy submission (status: Runtime Error):
"""A - Train
https://atcoder.jp/contests/abc107/tasks/abc107_a

>>> main(4, 2)
3
>>> main(1, 1)
1
>>> main(15, 11)
5"""


def main(n, i):
    print(n - i + 1)


if __name__ == "__main__":
    main(map(int, input().split(" ")))


Fixed submission:
"""A - Train
https://atcoder.jp/contests/abc107/tasks/abc107_a

>>> main(4, 2)
3
>>> main(1, 1)
1
>>> main(15, 11)
5"""


def main(n, i):
    print(n - i + 1)


if __name__ == "__main__":
    n, i = map(int, input().split(" "))
    main(n, i)
Problem p03272 (Python)

Buggy submission (status: Runtime Error):
n, i = map(int, input())
print(n - i + 1)


Fixed submission:
n, i = map(int, input().split())
print(n - i + 1)
Problem p03272 (Python)

Buggy submission (status: Runtime Error):
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, i = map(int, readline())
print(N - i + 1)


Fixed submission:
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, i = map(int, readline().split())
print(N - i + 1)
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (i = 0; i < n; i++)
#define REPR(i, n) for (i = n; i >= 0; i--)
#define FOR(i, m, n) for (i = m; i < n; i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

int main(void) {
  ll H, W;
  cin >> H >> W;
  char c[100][100];
  bool R[4], C[4];
  ll i, j;

  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      cin >> c[i][j];
    }
  }

  for (i = 0; i < H; i++) {
    R[i] = false;
    for (j = 0; j < W; j++) {
      if (c[i][j] == '#')
        R[i] = true;
    }
  }
  for (j = 0; j < W; j++) {
    C[j] = false;
    for (i = 0; i < H; i++) {
      if (c[i][j] == '#')
        C[j] = true;
    }
  }

  for (i = 0; i < H; i++) {
    if (R[i]) {
      for (j = 0; j < W; j++) {
        if (C[j]) {
          cout << c[i][j];
        }
      }
      cout << endl;
    }
  }
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (i = 0; i < n; i++)
#define REPR(i, n) for (i = n; i >= 0; i--)
#define FOR(i, m, n) for (i = m; i < n; i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

int main(void) {
  ll H, W;
  cin >> H >> W;
  char c[100][100];
  bool R[100], C[100];
  ll i, j;

  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      cin >> c[i][j];
    }
  }

  for (i = 0; i < H; i++) {
    R[i] = false;
    for (j = 0; j < W; j++) {
      if (c[i][j] == '#')
        R[i] = true;
    }
  }
  for (j = 0; j < W; j++) {
    C[j] = false;
    for (i = 0; i < H; i++) {
      if (c[i][j] == '#')
        C[j] = true;
    }
  }

  for (i = 0; i < H; i++) {
    if (R[i]) {
      for (j = 0; j < W; j++) {
        if (C[j]) {
          cout << c[i][j];
        }
      }
      cout << endl;
    }
  }
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ((n) ? "Yes" : "No") << endl;
#define CFYN(n) cout << ((n) ? "YES" : "NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void) {
  IOS int h, w;
  cin >> h >> w;

  vector<string> v(h);
  REP(i, h) cin >> v[i];

  for (int i = h - 1; i >= 0; i--) {
    auto it = find(ALL(v[i]), '#');
    if (it == v[i].end())
      v.erase(v.begin() + i);
  }
  for (auto i = w - 1; i >= 0; i--) {
    bool erase = true;
    REP(j, v.size()) {
      if (v[j][i] == '#') {
        erase = false;
        break;
      }
    }
    if (erase) {
      REP(j, v.size()) v[j].erase(v[i].begin() + i);
    }
  }

  REP(i, v.size()) { cout << v[i] << endl; }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ((n) ? "Yes" : "No") << endl;
#define CFYN(n) cout << ((n) ? "YES" : "NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void) {
  IOS int h, w;
  cin >> h >> w;

  vector<string> v(h);
  REP(i, h) cin >> v[i];

  for (int i = h - 1; i >= 0; i--) {
    auto it = find(ALL(v[i]), '#');
    if (it == v[i].end())
      v.erase(v.begin() + i);
  }
  for (auto i = w - 1; i >= 0; i--) {
    bool erase = true;
    REP(j, v.size()) {
      if (v[j][i] == '#') {
        erase = false;
        break;
      }
    }
    if (erase) {
      REP(j, v.size()) v[j].erase(v[j].begin() + i);
    }
  }

  REP(i, v.size()) { cout << v[i] << endl; }

  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> map(h);
  for (int i = 0; i < h; i++) {
    cin >> map[i];
  }
  string chk(w, '.');
  vector<int> check1(h, 0);
  for (auto itr = map.begin(); itr != map.end(); itr++) {
    if (chk == *itr) {
      check1[itr - map.begin()] = 1;
    }
  }
  vector<int> check(h, 0);
  for (int i = 0; i < w; i++) {
    int j = 0;
    while (j < h && map[j][i] == '.')
      j++;
    if (j == h) {
      check[i] = 1;
    }
  }
  for (int i = 0; i < h; i++) {
    if (check1[i] == 1)
      continue;
    for (int j = 0; j < w; j++) {
      if (check[j] == 1) {
        continue;
      } else
        cout << map[i][j];
    }
    cout << "\n";
  }

  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> map(h);
  for (int i = 0; i < h; i++) {
    cin >> map[i];
  }
  string chk(w, '.');
  vector<int> check1(h, 0);
  for (auto itr = map.begin(); itr != map.end(); itr++) {
    if (chk == *itr) {
      check1[itr - map.begin()] = 1;
    }
  }
  vector<int> check(w, 0);
  for (int i = 0; i < w; i++) {
    int j = 0;
    while (j < h && map[j][i] == '.')
      j++;
    if (j == h) {
      check[i] = 1;
    }
  }
  for (int i = 0; i < h; i++) {
    if (check1[i] == 1)
      continue;
    for (int j = 0; j < w; j++) {
      if (check[j] == 1) {
        continue;
      } else
        cout << map[i][j];
    }
    cout << "\n";
  }

  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;

// int arr[N]
////sort(arr,arr +N)

// vector <int> hoge
////sort(hoge.begin(),hoge.end());

int main() {
  int h, w, tmp = 0;

  string ans;
  cin >> h >> w;
  vi flag_y(h, 0), flag_x(w, 0);
  vs a(h);
  rep(i, h) { cin >> a[i]; }

  rep(i, h) {
    tmp = 0;
    rep(k, w) {
      if (a[i][k] == '.')
        tmp++;
    }
    if (tmp == w) {
      flag_x[i] = 1;
    }
  }
  rep(i, w) {
    tmp = 0;
    rep(k, h) {
      if (a[k][i] == '.')
        tmp++;
    }
    if (tmp == h) {
      flag_y[i] = 1;
    }
  }

  rep(i, h) {
    if (flag_x[i])
      continue;
    rep(k, w) {
      if (!flag_y[k]) {
        cout << a[i][k];
      }
    }
    cout << endl;
  }

  /*
  rep(i,w) {
          rep(k, h) {
                  cout << flag_x[i] + flag_y[k];
          }
          cout << "\n";
  }
   */
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;

// int arr[N]
////sort(arr,arr +N)

// vector <int> hoge
////sort(hoge.begin(),hoge.end());

int main() {
  int h, w, tmp = 0;

  string ans;
  cin >> h >> w;
  vi flag_y(w, 0), flag_x(h, 0);
  vs a(h);
  rep(i, h) { cin >> a[i]; }

  rep(i, h) {
    tmp = 0;
    rep(k, w) {
      if (a[i][k] == '.')
        tmp++;
    }
    if (tmp == w) {
      flag_x[i] = 1;
    }
  }
  rep(i, w) {
    tmp = 0;
    rep(k, h) {
      if (a[k][i] == '.')
        tmp++;
    }
    if (tmp == h) {
      flag_y[i] = 1;
    }
  }

  rep(i, h) {
    if (flag_x[i])
      continue;
    rep(k, w) {
      if (!flag_y[k]) {
        cout << a[i][k];
      }
    }
    cout << endl;
  }

  /*
  rep(i,w) {
          rep(k, h) {
                  cout << flag_x[i] + flag_y[k];
          }
          cout << "\n";
  }
   */
  return 0;
}
Problem p03273 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(4));
  vector<vector<int>> B(H, vector<int>(4));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
      B.at(i).at(j) = (A.at(i).at(j) == '#' ? 1 : 0);
    }
  }
  for (int i = 0; i < H; i++) {
    int Sum = 0;
    for (int j = 0; j < W; j++) {
      Sum += B.at(i).at(j);
    }
    if (Sum == 0) {
      for (int j = 0; j < W; j++) {
        A.at(i).at(j) = '%';
      }
    }
  }
  for (int i = 0; i < W; i++) {
    int Sum = 0;
    for (int j = 0; j < H; j++) {
      Sum += B.at(j).at(i);
    }
    if (Sum == 0) {
      for (int j = 0; j < H; j++) {
        A.at(j).at(i) = '%';
      }
    }
  }

  for (int i = 0; i < H; i++) {
    bool Check = false;
    for (int j = 0; j < W; j++) {
      if (!(A.at(i).at(j) == '%')) {
        cout << A.at(i).at(j);
        Check = true;
      }
    }
    if (Check) {
      cout << endl;
    }
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  vector<vector<int>> B(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
      B.at(i).at(j) = (A.at(i).at(j) == '#' ? 1 : 0);
    }
  }
  for (int i = 0; i < H; i++) {
    int Sum = 0;
    for (int j = 0; j < W; j++) {
      Sum += B.at(i).at(j);
    }
    if (Sum == 0) {
      for (int j = 0; j < W; j++) {
        A.at(i).at(j) = '%';
      }
    }
  }
  for (int i = 0; i < W; i++) {
    int Sum = 0;
    for (int j = 0; j < H; j++) {
      Sum += B.at(j).at(i);
    }
    if (Sum == 0) {
      for (int j = 0; j < H; j++) {
        A.at(j).at(i) = '%';
      }
    }
  }

  for (int i = 0; i < H; i++) {
    bool Check = false;
    for (int j = 0; j < W; j++) {
      if (!(A.at(i).at(j) == '%')) {
        cout << A.at(i).at(j);
        Check = true;
      }
    }
    if (Check) {
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

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

  vector<vector<char>> itbl(h, vector<char>(w));
  vector<bool> outputRows(h, false);
  vector<bool> outputCols(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> itbl.at(i).at(j);
      if (itbl.at(i).at(j) == '#') {
        outputRows.at(i) = true;
        outputCols.at(j) = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < h; j++) {
      if (outputRows.at(i) && outputCols.at(j)) {
        cout << itbl.at(i).at(j);
      }
    }
    if (outputRows.at(i)) {
      cout << "\n";
    }
  }
  return 0;
}


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

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

  vector<vector<char>> itbl(h, vector<char>(w));
  vector<bool> outputRows(h, false);
  vector<bool> outputCols(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> itbl.at(i).at(j);
      if (itbl.at(i).at(j) == '#') {
        outputRows.at(i) = true;
        outputCols.at(j) = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (outputRows.at(i) && outputCols.at(j)) {
        cout << itbl.at(i).at(j);
      }
    }
    if (outputRows.at(i)) {
      cout << "\n";
    }
  }
  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
int main() {
  int H, W;
  cin >> H >> W;
  string a[100][100];
  rep(i, 0, H) {
    string s;
    cin >> s;
    rep(r, 0, W) { a[i][r] = s[r]; }
  }

  rep(i, 0, H) {
    bool all = true;
    rep(r, 0, W) {
      if (a[i][r] == "#") {
        all = false;
      }
    }
    if (all) {
      rep(r, 0, W) { a[i][r] = ""; }
      a[i][W] = "no";
    }
  }
  rep(r, 0, W) {
    bool all = true;
    rep(i, 0, H) {
      if (a[i][r] == "#") {
        all = false;
      }
    }
    if (all) {
      rep(i, 0, H) { a[i][r] = ""; }
    }
  }
  rep(i, 0, H) {
    rep(r, 0, W) { cout << a[i][r]; }
    if (a[i][W] != "no") {
      cout << endl;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
int main() {
  int H, W;
  cin >> H >> W;
  string a[110][110];
  rep(i, 0, H) {
    string s;
    cin >> s;
    rep(r, 0, W) { a[i][r] = s[r]; }
  }

  rep(i, 0, H) {
    bool all = true;
    rep(r, 0, W) {
      if (a[i][r] == "#") {
        all = false;
      }
    }
    if (all) {
      rep(r, 0, W) { a[i][r] = ""; }
      a[i][W] = "no";
    }
  }
  rep(r, 0, W) {
    bool all = true;
    rep(i, 0, H) {
      if (a[i][r] == "#") {
        all = false;
      }
    }
    if (all) {
      rep(i, 0, H) { a[i][r] = ""; }
    }
  }
  rep(i, 0, H) {
    rep(r, 0, W) { cout << a[i][r]; }
    if (a[i][W] != "no") {
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

bool isnot_allwhite(string str) {
  bool check = false;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '#') {
      check = true;
      break;
    }
  }
  return check;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(0);
  string tmp;
  for (int i = 0; i < H; i++) {
    cin >> tmp;
    if (isnot_allwhite(tmp))
      vec.push_back(tmp);
  }
  H = vec.size();
  vector<int> del(0);
  int count = 0;
  for (int j = 0; j < W; j++) {
    bool all_white = true;
    for (int i = 0; i < H; i++) {
      if (vec.at(i).at(j - count) == '#') {
        all_white = false;
        break;
      }
    }
    if (all_white) {
      for (int k = 0; k < H; k++)
        vec.at(k).erase(j - count, 1);
      count++;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++)
      cout << vec.at(i).at(j);
    cout << endl;
  }
}


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

bool isnot_allwhite(string str) {
  bool check = false;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '#') {
      check = true;
      break;
    }
  }
  return check;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(0);
  string tmp;
  for (int i = 0; i < H; i++) {
    cin >> tmp;
    if (isnot_allwhite(tmp))
      vec.push_back(tmp);
  }
  H = vec.size();
  vector<int> del(0);
  int count = 0;
  for (int j = 0; j < W; j++) {
    bool all_white = true;
    for (int i = 0; i < H; i++) {
      if (vec.at(i).at(j - count) == '#') {
        all_white = false;
        break;
      }
    }
    if (all_white) {
      for (int k = 0; k < H; k++)
        vec.at(k).erase(j - count, 1);
      count++;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W - count; j++)
      cout << vec.at(i).at(j);
    cout << endl;
  }
}
Problem p03273 (C++)

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

int main(void) {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < h; i++) {
    int tmp = 0;
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '.')
        tmp++;
    }
    if (tmp == w) {
      for (int k = i; k < h - 1; k++) {
        a[k] = a[k + i];
      }
      a.erase(a.begin() + i);
      i--;
      h--;
    }
  }
  for (int i = 0; i < w; i++) {
    int tmp = 0;
    for (int j = 0; j < h; j++) {
      if (a[j][i] == '.') {
        tmp++;
      }
    }
    if (tmp == h) {
      for (int k = 0; k < h; k++) {
        for (int l = i; l < w - 1; l++) {
          a[k][l] = a[k][l + 1];
        }
        a[k].pop_back();
      }
      w--;
      i--;
    }
  }
  // cout << endl;
  for (int i = 0; i < h; i++) {
    cout << a[i] << endl;
  }
  return 0;
}


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

int main(void) {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < h; i++) {
    int tmp = 0;
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '.')
        tmp++;
    }
    if (tmp == w) {
      /*
                  for (int k = i; k < h - 1; k++) {
                          a[k] = a[k + i];
                  }
      */
      a.erase(a.begin() + i);
      i--;
      h--;
    }
  }
  for (int i = 0; i < w; i++) {
    int tmp = 0;
    for (int j = 0; j < h; j++) {
      if (a[j][i] == '.') {
        tmp++;
      }
    }
    if (tmp == h) {
      for (int k = 0; k < h; k++) {
        for (int l = i; l < w - 1; l++) {
          a[k][l] = a[k][l + 1];
        }
        a[k].pop_back();
      }
      w--;
      i--;
    }
  }
  // cout << endl;
  for (int i = 0; i < h; i++) {
    cout << a[i] << endl;
  }
  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vc> g(h + 2, vc(w + 2));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) cin >> g[i][j];
  vb hc(h + 2, false), wc(w + 2, false);
  rep2(i, 1, h + 1) {
    bool ok = true;
    rep2(j, 1, w + 1) if (g[i][j] == '#') ok = false;
    hc[i] = ok;
  }
  rep2(j, 1, w + 1) {
    bool ok = true;
    rep2(i, 1, w + 1) if (g[i][j] == '#') ok = false;
    wc[j] = ok;
  }
  rep2(i, 1, h + 1) {
    bool ok = false;
    rep2(j, 1, w + 1) {
      if (!hc[i] && !wc[j]) {
        cout << g[i][j];
        ok = true;
      }
    }
    if (ok)
      cout << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vc> g(h + 2, vc(w + 2));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) cin >> g[i][j];
  vb hc(h + 2, false), wc(w + 2, false);
  rep2(i, 1, h + 1) {
    bool ok = true;
    rep2(j, 1, w + 1) if (g[i][j] == '#') ok = false;
    hc[i] = ok;
  }
  rep2(j, 1, w + 1) {
    bool ok = true;
    rep2(i, 1, h + 1) if (g[i][j] == '#') ok = false;
    wc[j] = ok;
  }
  rep2(i, 1, h + 1) {
    bool ok = false;
    rep2(j, 1, w + 1) {
      if (!hc[i] && !wc[j]) {
        cout << g[i][j];
        ok = true;
      }
    }
    if (ok)
      cout << endl;
  }
}
Problem p03273 (C++)

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

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

  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a.at(i);
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; h < w; j++) {
      if (a.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row.at(i)) {
      for (int j = 0; j < w; j++) {
        if (col.at(j)) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

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

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

  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a.at(i);
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row.at(i)) {
      for (int j = 0; j < w; j++) {
        if (col.at(j)) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  vector<string> s;
  rep(i, h) {
    string t;
    cin >> t;
    if (count(t.begin(), t.end(), '.') == w)
      continue;
    s.push_back(t);
  }

  bool enable_columns[s.size()];
  rep(i, w) {
    enable_columns[i] = false;
    rep(j, s.size()) {
      if (s[j][i] == '#') {
        enable_columns[i] = true;
        break;
      }
    }
  }

  rep(i, s.size()) {
    rep(j, w) {
      if (enable_columns[j])
        cout << s[i][j];
    }
    cout << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  vector<string> s;
  rep(i, h) {
    string t;
    cin >> t;
    if (count(t.begin(), t.end(), '.') == w)
      continue;
    s.push_back(t);
  }

  bool enable_columns[w];
  rep(i, w) {
    enable_columns[i] = false;
    rep(j, s.size()) {
      if (s[j][i] == '#') {
        enable_columns[i] = true;
        break;
      }
    }
  }

  rep(i, s.size()) {
    rep(j, w) {
      if (enable_columns[j])
        cout << s[i][j];
    }
    cout << endl;
  }

  return 0;
}
Problem p03273 (C++)

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

int main() {
  int y, x;
  cin >> y >> x;
  int flag = 0;

  vector<vector<char>> a(y, vector<char>(x));

  for (int i = 0; i < y; i++) {
    for (int j = 0; j < x; j++) {
      cin >> a.at(i).at(j);
    }
  }

  vector<int> y_flag(y), x_flag(x);

  // 横列の出力フラグ
  for (int i = 0; i < y; i++) {
    int flag = 0;

    for (int j = 0; j < x; j++) {
      if (a.at(i).at(j) == '#') {
        flag++;
        break;
      }
    }

    if (flag == 1) {
      y_flag.at(i)++;
    }
  }

  // 縦列の出力フラグ
  for (int j = 0; j < x; j++) {
    int flag = 0;

    for (int i = 0; i < y; i++) {
      if (a.at(i).at(j) == '#') {
        flag++;
        break;
      }
    }

    if (flag == 1) {
      x_flag.at(j)++;
    }
  }

  // 出力
  for (int i = 0; i < y; i++) {
    for (int j = 0; j < y; j++) {
      if (x_flag.at(j) == 1 && y_flag.at(i) == 1) {
        cout << a.at(i).at(j);
      }
    }

    if (y_flag.at(i) == 1) {
      cout << endl;
    }
  }
}

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

int main() {
  int y, x;
  cin >> y >> x;
  int flag = 0;

  vector<vector<char>> a(y, vector<char>(x));

  for (int i = 0; i < y; i++) {
    for (int j = 0; j < x; j++) {
      cin >> a.at(i).at(j);
    }
  }

  vector<int> y_flag(y), x_flag(x);

  // 横列の出力フラグ
  for (int i = 0; i < y; i++) {
    int flag = 0;

    for (int j = 0; j < x; j++) {
      if (a.at(i).at(j) == '#') {
        flag++;
        break;
      }
    }

    if (flag == 1) {
      y_flag.at(i)++;
    }
  }

  // 縦列の出力フラグ
  for (int j = 0; j < x; j++) {
    int flag = 0;

    for (int i = 0; i < y; i++) {
      if (a.at(i).at(j) == '#') {
        flag++;
        break;
      }
    }

    if (flag == 1) {
      x_flag.at(j)++;
    }
  }

  // 出力
  for (int i = 0; i < y; i++) {
    for (int j = 0; j < x; j++) {
      if (x_flag.at(j) == 1 && y_flag.at(i) == 1) {
        cout << a.at(i).at(j);
      }
    }

    if (y_flag.at(i) == 1) {
      cout << endl;
    }
  }
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, i, j;
  cin >> h >> w;
  vector<string> a(h);
  vector<int> r, c;
  for (i = 0; i < h; i++) {
    cin >> a.at(i);
    for (j = 0; j < w; j++)
      if (a.at(i).at(j) == '#')
        break;
    if (j == w)
      r.push_back(i);
  }
  r.push_back(h);
  for (j = 0; j < w; j++) {
    for (i = 0; i < h; i++)
      if (a.at(i).at(j) == '#')
        break;
    if (i == h)
      c.push_back(j);
  }
  c.push_back(w);
  for (i = 0; i < h; i++) {
    if (*lower_bound(r.begin(), r.end(), i) != i) {
      for (j = 0; j < h; j++)
        if (*lower_bound(c.begin(), c.end(), j) != j)
          cout << a.at(i).at(j);
      cout << endl;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, i, j;
  cin >> h >> w;
  vector<string> a(h);
  vector<int> r, c;
  for (i = 0; i < h; i++) {
    cin >> a.at(i);
    for (j = 0; j < w; j++)
      if (a.at(i).at(j) == '#')
        break;
    if (j == w)
      r.push_back(i);
  }
  r.push_back(h);
  for (j = 0; j < w; j++) {
    for (i = 0; i < h; i++)
      if (a.at(i).at(j) == '#')
        break;
    if (i == h)
      c.push_back(j);
  }
  c.push_back(w);
  for (i = 0; i < h; i++) {
    if (*lower_bound(r.begin(), r.end(), i) != i) {
      for (j = 0; j < w; j++)
        if (*lower_bound(c.begin(), c.end(), j) != j)
          cout << a.at(i).at(j);
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  vector<bool> rflg(H, 0);
  vector<bool> cflg(W, 0);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < H; j++) {
      if (data.at(i).at(j) == '#') {
        rflg.at(i) = 1;
        cflg.at(j) = 1;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (rflg.at(i) == 1) {
      for (int j = 0; j < W; j++) {
        if (cflg.at(j) == 1) {
          cout << data.at(i).at(j);
        }
        if (j == W - 1) {
          cout << endl; // 末尾なら改行
        }
      }
    }
  }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  vector<bool> rflg(H, 0);
  vector<bool> cflg(W, 0);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#') {
        rflg.at(i) = 1;
        cflg.at(j) = 1;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (rflg.at(i) == 1) {
      for (int j = 0; j < W; j++) {
        if (cflg.at(j) == 1) {
          cout << data.at(i).at(j);
        }
        if (j == W - 1) {
          cout << endl; // 末尾なら改行
        }
      }
    }
  }
}
Problem p03273 (C++)

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

int main() {
  int W, H;
  int flg;
  cin >> W >> H;
  vector<vector<char>> A(W, vector<char>(H));
  vector<int> I(H, 1);
  vector<int> J(W, 1);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }

  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (A.at(i).at(j) == '#') {
        J.at(j) = 0;
        break;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') {
        I.at(i) = 0;
        break;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    flg = 0;
    for (int j = 0; j < W; j++) {
      if (I.at(i) == 0) {
        if (J.at(j) == 0) {
          cout << A.at(i).at(j);
          flg = 1;
        }
      }
      if (j == (W - 1)) {
        if (flg == 1) {
          cout << endl;
        }
      }
    }
  }
}

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

int main() {
  int W, H;
  int flg;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  vector<int> I(H, 1);
  vector<int> J(W, 1);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }

  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (A.at(i).at(j) == '#') {
        J.at(j) = 0;
        break;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') {
        I.at(i) = 0;
        break;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    flg = 0;
    for (int j = 0; j < W; j++) {
      if (I.at(i) == 0) {
        if (J.at(j) == 0) {
          cout << A.at(i).at(j);
          flg = 1;
        }
      }
      if (j == (W - 1)) {
        if (flg == 1) {
          cout << endl;
        }
      }
    }
  }
}