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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> data(H);
  vector<bool> row(H, false);
  vector<bool> col(H, false);

  REP(i, H) {
    cin >> data.at(i);

    REP(j, W) {
      if (data.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  REP(i, H) {
    if (row.at(i) == true) {
      REP(j, W) {
        if (col.at(j) == true) {
          cout << data.at(i).at(j);
        }
      }

      cout << endl;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> data(H);
  vector<bool> row(H, false);
  vector<bool> col(W, false);

  REP(i, H) {
    cin >> data.at(i);

    REP(j, W) {
      if (data.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  REP(i, H) {
    if (row.at(i) == true) {
      REP(j, W) {
        if (col.at(j) == true) {
          cout << data.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>> hyo(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> hyo.at(i).at(j);
    }
  }
  int count = 0;
  for (int i = 0; i < W; i++) {
    bool tate_check = true;
    for (int j = 0; j < H; j++) {
      if (hyo.at(j).at(i - count) != '.') {
        tate_check = false;
        break;
      }
    }
    if (tate_check == true) {
      for (int k = 0; k < H; k++) {
        for (int l = i - count; l < W - 1; l++) {
          hyo.at(k).at(l) = hyo.at(k).at(l + 1);
        }
      }
      count++;
    }
  }
  for (int i = 0; i < W; i++) {
    bool yoko_check = true;
    for (int j = 0; j < W; j++) {
      if (hyo.at(i).at(j) != '.') {
        yoko_check = false;
        break;
      }
    }
    if (yoko_check == false) {
      for (int j = 0; j < W - count; j++) {
        cout << hyo.at(i).at(j);
      }
      cout << endl;
    }
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> hyo(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> hyo.at(i).at(j);
    }
  }
  int count = 0;
  for (int i = 0; i < W; i++) {
    bool tate_check = true;
    for (int j = 0; j < H; j++) {
      if (hyo.at(j).at(i - count) != '.') {
        tate_check = false;
        break;
      }
    }
    if (tate_check == true) {
      for (int k = 0; k < H; k++) {
        for (int l = i - count; l < W - 1; l++) {
          hyo.at(k).at(l) = hyo.at(k).at(l + 1);
        }
      }
      count++;
    }
  }
  for (int i = 0; i < H; i++) {
    bool yoko_check = true;
    for (int j = 0; j < W; j++) {
      if (hyo.at(i).at(j) != '.') {
        yoko_check = false;
        break;
      }
    }
    if (yoko_check == false) {
      for (int j = 0; j < W - count; j++) {
        cout << hyo.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<char> vec(H * W);

  for (int i = 0; i < H * W; i++) {
    char a;
    cin >> a;
    vec.at(i) = a;
  }
  int h = 0, w = 0;
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      if (vec.at(i * W + j) == '#')
        break;
      else if (vec.at(i * W + j) == '.' && j > 0)
        continue;
      for (int k = 0; k < W; k++)
        vec.erase(vec.begin() + i * W + (W - k - 1));
      h++;
    }
  }

  for (int j = W - 1; j >= 0; j--) {
    for (int i = H - h - 1; i >= 0; i--) {
      if (vec.at(j + i * (W - w)) == '#')
        break;
      else if (vec.at(j + i * (W - w)) == '.' && i > 0)
        continue;
      for (int k = 0; k < H - h; k++)
        vec.erase(vec.begin() + j + (H - h - k) * (W - w));
      w++;
    }
  }

  for (int i = 0; i < H - h; i++) {
    for (int j = 0; j < W - w; j++) {
      if (j != W - w - 1)
        cout << vec.at(j + i * (W - w));
      else if (j == W - w - 1)
        cout << vec.at(j + i * (W - w)) << endl;
    }
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> vec(H * W);

  for (int i = 0; i < H * W; i++) {
    char a;
    cin >> a;
    vec.at(i) = a;
  }
  int h = 0, w = 0;
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      if (vec.at(i * W + j) == '#')
        break;
      else if (vec.at(i * W + j) == '.' && j > 0)
        continue;
      for (int k = 0; k < W; k++)
        vec.erase(vec.begin() + i * W + (W - k - 1));
      h++;
    }
  }

  for (int j = W - 1; j >= 0; j--) {
    for (int i = H - h - 1; i >= 0; i--) {
      if (vec.at(j + i * (W - w)) == '#')
        break;
      else if (vec.at(j + i * (W - w)) == '.' && i > 0)
        continue;
      for (int k = 0; k < H - h; k++)
        vec.erase(vec.begin() + j + (H - h - 1 - k) * (W - w));
      w++;
    }
  }

  for (int i = 0; i < H - h; i++) {
    for (int j = 0; j < W - w; j++) {
      if (j != W - w - 1)
        cout << vec.at(j + i * (W - w));
      else if (j == W - w - 1)
        cout << vec.at(j + i * (W - w)) << endl;
    }
  }
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  bool flag;
  char A[100][100];
  int h = 0, w = 0;
  for (int i = 0; i < H - h; i++) {
    flag = true;
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      if (A[i][j] == '#')
        flag = false;
    }
    if (flag == true) {
      i--;
      h++;
    }
  }

  bool pass[100];
  for (int i = 0; i < 100; i++) {
    pass[i] = false;
  }
  for (int i = 0; i < W - w; i++) {
    flag = true;
    for (int j = 0; j < H - h; j++) {
      if (A[j][i] == '#')
        flag = false;
    }
    if (flag == true) {
      w--;
      pass[i] = true;
    }
  }
  for (int i = 0; i < H - h; i++) {
    for (int j = 0; j < W; j++) {
      if (pass[j] == false)
        cout << A[i][j];
    }
    cout << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  bool flag;
  char A[100][100];
  int h = 0, w = 0;
  for (int i = 0; i < H - h; i++) {
    flag = true;
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      if (A[i][j] == '#')
        flag = false;
    }
    if (flag == true) {
      i--;
      h++;
    }
  }

  bool pass[100];
  for (int i = 0; i < 100; i++) {
    pass[i] = false;
  }
  for (int i = 0; i < W; i++) {
    flag = true;
    for (int j = 0; j < H - h; j++) {
      if (A[j][i] == '#')
        flag = false;
    }
    if (flag == true) {
      w--;
      pass[i] = true;
    }
  }
  for (int i = 0; i < H - h; i++) {
    for (int j = 0; j < W; j++) {
      if (pass[j] == false)
        cout << A[i][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 chmin(x, y) x = min(x, y)
using namespace std;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> matrix(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> matrix.at(i).at(j);

  vector<vector<char>> ans(h, vector<char>(w));
  vector<vector<char>> ans1(h, vector<char>(w));

  int ans_h = 0;
  int ans_w = 0;
  rep(i, h) {
    bool judge = true;
    rep(j, w) if (matrix.at(i).at(j) == '#') judge = false;
    if (!judge) {
      rep(j, w) ans.at(ans_h).at(j) = matrix.at(i).at(j);
      ans_h++;
    }
  }
  rep(j, w) {
    bool judge = true;
    rep(i, h) if (ans.at(i).at(j) == '#') judge = false;
    if (!judge) {
      rep(i, h) ans1.at(i).at(ans_w) = ans.at(i).at(j);
      ans_w++;
    }
  }
  rep(i, ans_h + 1) {
    rep(j, ans_w + 1) cout << ans1.at(i).at(j);
    cout << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
using namespace std;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> matrix(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> matrix.at(i).at(j);

  vector<vector<char>> ans(h, vector<char>(w));
  vector<vector<char>> ans1(h, vector<char>(w));

  int ans_h = 0;
  int ans_w = 0;
  rep(i, h) {
    bool judge = true;
    rep(j, w) if (matrix.at(i).at(j) == '#') judge = false;
    if (!judge) {
      rep(j, w) ans.at(ans_h).at(j) = matrix.at(i).at(j);
      ans_h++;
    }
  }
  rep(j, w) {
    bool judge = true;
    rep(i, h) if (ans.at(i).at(j) == '#') judge = false;
    if (!judge) {
      rep(i, h) ans1.at(i).at(ans_w) = ans.at(i).at(j);
      ans_w++;
    }
  }
  rep(i, ans_h) {
    rep(j, ans_w) cout << ans1.at(i).at(j);
    cout << endl;
  }
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int H, W, p = 0;
  cin >> H >> W;
  string s;

  vector<string> a(H * W);
  for (int i = 0; i < H; ++i) {
    cin >> s;
    if (s.find('#') != -1) {
      a[p] = s;
      p++;
    }
  }

  for (int i = 0; i < W; ++i) {
    bool flag = false;
    if (a[0][i] == '.') {
      flag = true;
      for (string j : a) {
        if (j[i] == '#') {
          flag = false;
          break;
        }
      }
    }
    if (flag) {
      for (int k = 0; k < a.size(); ++k) {
        a[k][i] = '_';
      }
    }
  }

  for (string i : a) {
    for (char j : i) {
      if (j == '_') {
        continue;
      }
      cout << j;
    }
    cout << endl;
  }
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int H, W, p = 0;
  cin >> H >> W;
  string s;

  vector<string> a(H);
  for (int i = 0; i < H; ++i) {
    cin >> s;
    if (s.find('#') != -1) {
      a[p] = s;
      p++;
    }
  }

  for (int i = 0; i < W; ++i) {
    bool flag = false;
    if (a[0][i] == '.') {
      flag = true;
      for (string j : a) {
        if (j[i] == '#') {
          flag = false;
          break;
        }
      }
    }
    if (flag) {
      for (int k = 0; k < a.size(); ++k) {
        a[k][i] = '_';
      }
    }
  }

  for (string i : a) {
    for (char j : i) {
      if (j == '_') {
        continue;
      }
      cout << j;
    }
    cout << endl;
  }
}
Problem p03273 (C++)

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

void del(vector<vector<char>> &a, vector<int> &b, vector<int> &c) {
  int h = a.size();
  int w = a.at(0).size();
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') {
        b.at(i) = 1;
        continue;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(j).at(i) == '#') {
        c.at(i) = 1;
        continue;
      }
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  vector<int> h(H);
  vector<int> w(W);
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      cin >> a.at(i).at(j);
  del(a, h, w);
  for (int i = 0; i < H; i++) {
    if (h.at(i) == 0)
      continue;
    for (int j = 0; j < W; j++) {
      if (w.at(j) == 0) {
        if (j == W - 1)
          cout << endl;
        continue;
      }
      cout << a.at(i).at(j);
      if (j == W - 1)
        cout << endl;
    }
  }
}


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

void del(vector<vector<char>> &a, vector<int> &b, vector<int> &c) {
  int h = a.size();
  int w = a.at(0).size();
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') {
        b.at(i) = 1;
        continue;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (a.at(j).at(i) == '#') {
        c.at(i) = 1;
        continue;
      }
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  vector<int> h(H);
  vector<int> w(W);
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      cin >> a.at(i).at(j);
  del(a, h, w);
  for (int i = 0; i < H; i++) {
    if (h.at(i) == 0)
      continue;
    for (int j = 0; j < W; j++) {
      if (w.at(j) == 0) {
        if (j == W - 1)
          cout << endl;
        continue;
      }
      cout << a.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;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ll long long
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  REP(i, H) {
    REP(j, W) { cin >> a.at(i).at(j); }
  }

  bool row[H];
  bool column[W];
  REP(i, H) {
    row[i] = true;
    REP(j, W) {
      if (a.at(i).at(j) == '#')
        row[i] = false;
    }
  }

  REP(i, W) {
    column[i] = true;
    REP(j, H) {
      if (a.at(i).at(j) == '#')
        column[i] = false;
    }
  }

  REP(i, H) {
    if (row[i])
      continue;
    REP(j, W) {
      if (!column[j])
        cout << a.at(i).at(j);
    }
    cout << endl;
  }
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ll long long
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  REP(i, H) {
    REP(j, W) { cin >> a.at(i).at(j); }
  }

  bool row[H];
  bool column[W];
  REP(i, H) {
    row[i] = true;
    REP(j, W) {
      if (a.at(i).at(j) == '#')
        row[i] = false;
    }
  }

  REP(i, W) {
    column[i] = true;
    REP(j, H) {
      if (a.at(j).at(i) == '#')
        column[i] = false;
    }
  }

  REP(i, H) {
    if (row[i])
      continue;
    REP(j, W) {
      if (!column[j])
        cout << a.at(i).at(j);
    }
    cout << endl;
  }
}
Problem p03273 (C++)

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

int main() {
  int h, w;
  cin >> h;
  cin >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; i++) {
      if (a[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  int h, w;
  cin >> h;
  cin >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[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[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

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

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int h, w;
  int a[100], b[100];
  char s[100][100];
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> s[i][j];
      if (s[i][j] == '#')
        a[i] = 1, b[j] = 1;
    }
  }
  for (int i = 1; i <= h; i++) {
    if (a[i] == 1) {
      for (int j = 1; j <= w; j++)
        if (b[j] == 1)
          cout << s[i][j];
      cout << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int h, w;
  int a[110], b[110];
  char s[110][110];
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> s[i][j];
      if (s[i][j] == '#')
        a[i] = 1, b[j] = 1;
    }
  }
  for (int i = 1; i <= h; i++) {
    if (a[i] == 1) {
      for (int j = 1; j <= w; j++)
        if (b[j] == 1)
          cout << s[i][j];
      cout << endl;
    }
  }
  return 0;
}
Problem p03273 (C++)

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

using namespace std;

int main(void) {
  int h, w;
  string a[100];
  int flagh[100] = {0};
  int flagw[100] = {0};
  int dh = 0, dw = 0;
  cin >> h >> w;
  int i, j;
  for (i = 0; i < h; i++)
    cin >> a[i];
  // 行ごとに見ていく
  int count;
  for (i = 0; i < h; i++) {
    count = 0;
    for (j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        count = 1;
        break;
      }
    }
    if (count == 0) {
      flagh[i] = 1; // i行目は全部白
      dh++;
    }
  }
  // 列ごとに見ていく
  for (j = 0; j < w; j++) {
    count = 0;
    for (i = 0; i < h; i++) {
      if (a[i][j] == '#') {
        count = 1;
        break;
      }
    }
    if (count == 0) {
      flagw[i] = 1; // i行目は全部白
      dw++;
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (flagh[i] == 0 && flagw[j] == 0)
        cout << a[i][j];
    }
    cout << endl;
  }
  cout << endl;

  return 0;
}

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

using namespace std;

int main(void) {
  int h, w;
  string a[100];
  int flagh[100] = {0};
  int flagw[100] = {0};
  int dh = 0, dw = 0;
  cin >> h >> w;
  int i, j;
  for (i = 0; i < h; i++)
    cin >> a[i];
  // 行ごとに見ていく
  int count;
  for (i = 0; i < h; i++) {
    count = 0;
    for (j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        count = 1;
        break;
      }
    }
    if (count == 0) {
      flagh[i] = 1; // i行目は全部白
      dh++;
    }
  }
  // 列ごとに見ていく
  for (j = 0; j < w; j++) {
    count = 0;
    for (i = 0; i < h; i++) {
      if (a[i][j] == '#') {
        count = 1;
        break;
      }
    }
    if (count == 0) {
      flagw[j] = 1; // i行目は全部白
      dw++;
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (flagh[i] == 0 && flagw[j] == 0)
        cout << a[i][j];
    }
    cout << endl;
  }
  cout << endl;

  return 0;
}
Problem p03273 (C++)

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

bool IsW(string s, int W) {
  bool flg = true;
  for (int i = 0; i < W; i++) {
    if (s[i] == '#')
      flg = false;
  }
  return flg;
}

bool IsH(string s[], int H, int k) {
  bool flg = true;
  for (int i = 0; i < H; i++) {
    if (s[i][k] == '#')
      flg = false;
  }
  return flg;
}

int main() {
  string S[100];
  int H, W;

  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  // cout << endl;

  for (int i = 0; i < H; i++) {
    if (IsW(S[i], W)) {
      string tmp = S[i];
      int j = i;
      for (; j < H; j++) {
        S[j] = S[j + 1];
      }
      S[j] = tmp;
      H--;
      i--;
    }
  }

  for (int i = 0; i < W; i++) {
    // cout << IsH(S, H, i) << endl;
    if (IsH(S, H, i)) {
      for (int j = 0; j < H; j++) {
        int k = i;
        char tmp = S[j][k];
        for (; k < W; k++) {
          S[j][k] = S[j][k + 1];
        }
        S[j][k] = tmp;
      }
      i--;
      W--;
    }
  }

  // 結果
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << S[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

bool IsW(string s, int W) {
  bool flg = true;
  for (int i = 0; i < W; i++) {
    if (s[i] == '#')
      flg = false;
  }
  return flg;
}

bool IsH(string s[], int H, int k) {
  bool flg = true;
  for (int i = 0; i < H; i++) {
    if (s[i][k] == '#')
      flg = false;
  }
  return flg;
}

int main() {
  string S[110];
  int H, W;

  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  // cout << endl;

  for (int i = 0; i < H; i++) {
    if (IsW(S[i], W)) {
      string tmp = S[i];
      int j = i;
      for (; j < H; j++) {
        S[j] = S[j + 1];
      }
      S[j] = tmp;
      H--;
      i--;
    }
  }

  for (int i = 0; i < W; i++) {
    // cout << IsH(S, H, i) << endl;
    if (IsH(S, H, i)) {
      for (int j = 0; j < H; j++) {
        int k = i;
        char tmp = S[j][k];
        for (; k < W; k++) {
          S[j][k] = S[j][k + 1];
        }
        S[j][k] = tmp;
      }
      i--;
      W--;
    }
  }

  // 結果
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << S[i][j];
    }
    cout << endl;
  }

  return 0;
}
Problem p03273 (C++)

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

int main(void) {
  int h, w, i, j, k;
  scanf("%d%d", &h, &w);
  char s[h][w + 10];
  for (i = 0; i < h; ++i)
    scanf("%s", s[i]);
  for (i = 0; i < h; ++i) {
    bool b = true;
    for (j = 0; j < w; ++j)
      if (s[i][j] == '#')
        b = false;
    if (b) {
      h--;
      for (j = i; j < h; ++j)
        for (k = 0; k < w; ++k)
          s[j][k] = s[j + 1][k];
      i--;
    }
  }
  for (i = 0; i < w; ++i) {
    bool b = true;
    for (j = 0; j < h; ++j)
      if (s[j][i] == '#')
        b = false;
    if (b) {
      w--;
      for (j = i; j < w; ++j)
        for (k = 0; k < w; ++k)
          s[k][j] = s[k][j + 1];
      i--;
    }
  }
  for (i = 0; i < h; ++i) {
    for (j = 0; j < w; ++j)
      printf("%c", s[i][j]);
    printf("\n");
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
#include <string.h>

int main(void) {
  int h, w, i, j, k;
  scanf("%d%d", &h, &w);
  char s[h][w + 10];
  for (i = 0; i < h; ++i)
    scanf("%s", s[i]);
  for (i = 0; i < h; ++i) {
    bool b = true;
    for (j = 0; j < w; ++j)
      if (s[i][j] == '#')
        b = false;
    if (b) {
      h--;
      for (j = i; j < h; ++j)
        for (k = 0; k < w; ++k)
          s[j][k] = s[j + 1][k];
      i--;
    }
  }
  for (i = 0; i < w; ++i) {
    bool b = true;
    for (j = 0; j < h; ++j)
      if (s[j][i] == '#')
        b = false;
    if (b) {
      w--;
      for (j = i; j < w; ++j)
        for (k = 0; k < h; ++k)
          s[k][j] = s[k][j + 1];
      i--;
    }
  }
  for (i = 0; i < h; ++i) {
    for (j = 0; j < w; ++j)
      printf("%c", s[i][j]);
    printf("\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>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data[i][j];
    }
  }
  vector<int> h(H);
  int x = -1;
  vector<int> w(W);
  int y = -1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data[i][j] == '#') {
        x++;
        h[x] = i;
        break;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data[j][i] == '#') {
        y++;
        w[y] = i;
        break;
      }
    }
  }
  vector<vector<char>> z(x + 1, vector<char>(y + 1));
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      z[i][j] = data[h[i]][w[j]];
    }
  }
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      cout << z[i][j];
    }
    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[i][j];
    }
  }
  vector<int> h(H);
  int x = -1;
  vector<int> w(W);
  int y = -1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data[i][j] == '#') {
        x++;
        h[x] = i;
        break;
      }
    }
  }
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (data[j][i] == '#') {
        y++;
        w[y] = i;
        break;
      }
    }
  }
  vector<vector<char>> z(x + 1, vector<char>(y + 1));
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      z[i][j] = data[h[i]][w[j]];
    }
  }
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      cout << z[i][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 rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int, int> P;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) {
    bool as = true;
    rep(j, w) {
      if (a[i][j] == '#')
        as = false;
    }
    if (as)
      rep(j, w) a[i][j] = 's';
  }
  rep(j, w) {
    bool as = true;
    rep(i, h) {
      if (a[i][j] == '#')
        as = false;
    }
    if (as)
      rep(i, w) a[i][j] = 's';
  }
  rep(i, h) {
    bool chk = false;
    rep(j, w) {
      if (a[i][j] == 's') {
        continue;
      } else {
        chk = true;
      }
      cout << a[i][j];
    }
    if (chk)
      cout << endl;
    else
      continue;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int, int> P;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) {
    bool as = true;
    rep(j, w) {
      if (a[i][j] == '#')
        as = false;
    }
    if (as)
      rep(j, w) a[i][j] = 's';
  }
  rep(j, w) {
    bool as = true;
    rep(i, h) {
      if (a[i][j] == '#')
        as = false;
    }
    if (as)
      rep(i, h) a[i][j] = 's';
  }
  rep(i, h) {
    bool chk = false;
    rep(j, w) {
      if (a[i][j] == 's') {
        continue;
      } else {
        chk = true;
      }
      cout << a[i][j];
    }
    if (chk)
      cout << endl;
    else
      continue;
  }
  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>> vec(H, vector<char>(H));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  vector<int> tate(H, 0);
  vector<int> yoko(W, 0);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (vec.at(i).at(j) == '#')
        tate.at(i) = 1;
    }
  }
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (vec.at(j).at(i) == '#')
        yoko.at(i) = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    if (tate.at(i) == 1) {
      for (int j = 0; j < W; j++) {
        if (yoko.at(j) == 1)
          cout << vec.at(i).at(j);
      }
      cout << endl;
    }
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  vector<int> tate(H, 0);
  vector<int> yoko(W, 0);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (vec.at(i).at(j) == '#')
        tate.at(i) = 1;
    }
  }
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (vec.at(j).at(i) == '#')
        yoko.at(i) = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    if (tate.at(i) == 1) {
      for (int j = 0; j < W; j++) {
        if (yoko.at(j) == 1)
          cout << vec.at(i).at(j);
      }
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

#define INF ((1 << 31) - 1) // int32_t
#define MOD 1000000007
#define MOD2

#define all(a) (a).begin(), (a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  bool flag = true;
  ll ans = 0, sum = 0;
  int h, w;
  cin >> h >> w;

  vector<string> grid(h);
  vector<vector<bool>> pri(h, vector<bool>(w));

  for (int i = 0; i < h; i++) {
    cin >> grid[i];
    for (int j = 0; j < w; j++) {
      pri[i][j] = true;
    }
  }

  for (int i = 0; i < h; i++) {
    bool same = true;
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '#')
        same = false;
    }

    if (!same)
      continue;
    // cout << "row" <<i+1<<endl;
    for (int k = 0; k < w; k++) {
      pri[i][k] = false;
    }
  }

  for (int i = 0; i < w; i++) {
    bool same = true;
    for (int j = 0; j < h; j++) {
      if (grid[i][j] == '#')
        same = false;
    }

    if (!same)
      continue;

    // cout << "col" <<i+1<<endl;
    for (int k = 0; k < h; k++) {
      pri[k][i] = false;
    }
  }

  for (int i = 0; i < h; i++) {
    bool printed = false;
    for (int j = 0; j < w; j++) {
      if (!pri[i][j])
        continue;
      cout << grid[i][j];
      printed = true;
    }
    if (printed)
      cout << endl;
  }

  // cout <<fixed<<setprecision(16)<< << endl;
  // cout << ans << endl;

  // if(flag)cout << "Yes" <<endl;
  // else cout << "No" <<endl;

  return 0;
}


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

#define INF ((1 << 31) - 1) // int32_t
#define MOD 1000000007
#define MOD2

#define all(a) (a).begin(), (a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  bool flag = true;
  ll ans = 0, sum = 0;
  int h, w;
  cin >> h >> w;

  vector<string> grid(h);
  vector<vector<bool>> pri(h, vector<bool>(w));

  for (int i = 0; i < h; i++) {
    cin >> grid[i];
    for (int j = 0; j < w; j++) {
      pri[i][j] = true;
    }
  }

  for (int i = 0; i < h; i++) {
    bool same = true;
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '#')
        same = false;
    }

    if (!same)
      continue;
    // cout << "row" <<i+1<<endl;
    for (int k = 0; k < w; k++) {
      pri[i][k] = false;
    }
  }

  for (int i = 0; i < w; i++) {
    bool same = true;
    for (int j = 0; j < h; j++) {
      if (grid[j][i] == '#')
        same = false;
    }

    if (!same)
      continue;

    // cout << "col" <<i+1<<endl;
    for (int k = 0; k < h; k++) {
      pri[k][i] = false;
    }
  }

  for (int i = 0; i < h; i++) {
    bool printed = false;
    for (int j = 0; j < w; j++) {
      if (!pri[i][j])
        continue;
      cout << grid[i][j];
      printed = true;
    }
    if (printed)
      cout << endl;
  }

  // cout <<fixed<<setprecision(16)<< << endl;
  // cout << ans << endl;

  // if(flag)cout << "Yes" <<endl;
  // else cout << "No" <<endl;

  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  int i, j, k = 0, l = 0, h, w;
  cin >> h >> w;
  string s[h];
  vector<int> x, y;
  for (i = 0; i < h; i++)
    cin >> s[i];
  for (i = 0; i < h; i++) {
    int f = 1;
    for (j = 0; j < w; j++) {
      if (s[i][j] == '#')
        f = 0;
    }
    if (f)
      x.push_back(i);
  }
  for (j = 0; j < w; j++) {
    int f = 1;
    for (i = 0; i < h; i++) {
      if (s[i][j] == '#')
        f = 0;
    }
    if (f)
      y.push_back(j);
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (x[k] != i && y[l] != j)
        cout << s[i][j];
      if (y[l] == j && l < y.size() - 1)
        l++;
    }
    if (x[k] == i && k < x.size() - 1)
      k++;
    else
      cout << endl;
    l = 0;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  int i, j, k = 0, l = 0, h, w;
  cin >> h >> w;
  string s[h];
  vector<int> x, y;
  for (i = 0; i < h; i++)
    cin >> s[i];
  for (i = 0; i < h; i++) {
    int f = 1;
    for (j = 0; j < w; j++) {
      if (s[i][j] == '#')
        f = 0;
    }
    if (f)
      x.push_back(i);
  }
  for (j = 0; j < w; j++) {
    int f = 1;
    for (i = 0; i < h; i++) {
      if (s[i][j] == '#')
        f = 0;
    }
    if (f)
      y.push_back(j);
  }
  x.push_back(100);
  y.push_back(100);
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (x[k] != i && y[l] != j)
        cout << s[i][j];
      if (y[l] == j && l < y.size() - 1)
        l++;
    }
    if (x[k] == i && k < x.size() - 1)
      k++;
    else
      cout << endl;
    l = 0;
  }
  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, (vector<char>(w)));
  rep(i, h) { rep(j, w) cin >> a[i][j]; }
  vector<bool> flag_h(h);
  vector<bool> flag_w(w);
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#')
        flag_h[i] = true;
    }
  }
  rep(i, w) {
    rep(j, h) {
      if (a[i][j] == '#')
        flag_w[j] = true;
    }
  }
  rep(i, h) {
    rep(j, w) {
      if (flag_h[i] && flag_w[j])
        cout << a[i][j];
    }
    if (flag_h[i])
      cout << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, (vector<char>(w)));
  rep(i, h) { rep(j, w) cin >> a[i][j]; }
  vector<bool> flag_h(h);
  vector<bool> flag_w(w);
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#')
        flag_h[i] = true;
    }
  }
  rep(j, w) {
    rep(i, h) {
      if (a[i][j] == '#')
        flag_w[j] = true;
    }
  }
  rep(i, h) {
    rep(j, w) {
      if (flag_h[i] && flag_w[j])
        cout << a[i][j];
    }
    if (flag_h[i])
      cout << endl;
  }
  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<string> s(w);
  for (int i = 0; i < w; i++) {
    cin >> s[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 (s[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if (col[j]) {
          cout << s[i][j];
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[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 (s[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if (col[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 h, w;
  cin >> h >> w;
  char b[100][100];
  vector<int> col(h, 0), row(w, 0);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> b[i][j];
      if (b[i][j] == '#') {
        row[i] = 1;
        col[j] = 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if (col[j])
          cout << b[i][j];
      }
      cout << endl;
    }
  }
}


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

int main() {
  int h, w;
  cin >> h >> w;
  char b[100][100];
  vector<bool> col(h, false), row(w, false);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> b[i][j];
      if (b[i][j] == '#') {
        row[i] = 1;
        col[j] = 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if (col[j])
          cout << b[i][j];
      }
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9 + 7
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define Yes(hoge) cout << ((hoge) ? "Yes" : "No") << endl;
#define YES(hoge) cout << ((hoge) ? "YES" : "NO") << endl;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> vs;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (s[j] == '#')
        flag = false;
    }
    if (flag == false)
      vs.pb(s);
  }
  vector<string> ans;
  for (int i = 0; i < m; i++) {
    bool flag = true;
    string s = "";
    for (int j = 0; j < vs.size(); j++) {
      if (vs[j][i] == '#')
        flag = false;
      s += vs[j][i];
    }
    if (flag == false)
      ans.pb(s);
  }
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 0; j < ans[i].size(); j++) {
      cout << ans[j][i];
    }
    cout << endl;
  }
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9 + 7
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define Yes(hoge) cout << ((hoge) ? "Yes" : "No") << endl;
#define YES(hoge) cout << ((hoge) ? "YES" : "NO") << endl;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> vs;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (s[j] == '#')
        flag = false;
    }
    if (flag == false)
      vs.pb(s);
  }
  vector<string> ans;
  for (int i = 0; i < m; i++) {
    bool flag = true;
    string s = "";
    for (int j = 0; j < vs.size(); j++) {
      if (vs[j][i] == '#')
        flag = false;
      s += vs[j][i];
    }
    if (flag == false)
      ans.pb(s);
  }
  for (int i = 0; i < ans[0].size(); i++) {
    for (int j = 0; j < ans.size(); j++) {
      cout << ans[j][i];
    }
    cout << endl;
  }
  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> masu(H, vector<char>(W));

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

  vector<bool> h_w(H, true);
  vector<bool> w_w(W, true);

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

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

  for (int i = 0; i < H; i++) {
    if (h_w.at(i) == false) {
      for (int j = 0; j < W; j++) {
        if (w_w.at(j) == false)
          cout << masu.at(i).at(j);
      }
      cout << endl;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> masu(H, vector<char>(W));

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

  vector<bool> h_w(H, true);
  vector<bool> w_w(W, true);

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

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

  for (int i = 0; i < H; i++) {
    if (h_w.at(i) == false) {
      for (int j = 0; j < W; j++) {
        if (w_w.at(j) == false)
          cout << masu.at(i).at(j);
      }
      cout << endl;
    }
  }
}
Problem p03273 (C++)

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

using namespace std;

int n, m, k, p;
char a[102][102];
int b[102];

int main() {
  for (int i = 0; i < 10000; i++)
    b[i] = 100;
  cin >> n >> m;
  p = 0;

  for (int i = 0; i < n; i++) {
    k = 0;
    cin >> a[p];
    for (int j = 0; j < m; j++) {
      if (a[p][j] == '.')
        k++;
    }
    if (k == m)
      p--;
    p++;
  }
  n = p;

  p = 0;
  for (int j = 0; j < m; j++) {
    k = 0;
    for (int i = 0; i < n; i++) {
      if (a[i][j] == '.')
        k++;
    }
    if (k == n) {
      b[p] = j;
      p++;
    }
  }
  for (int i = 0; i < n; i++) {
    p = 0;
    for (int j = 0; j < m; j++) {
      if (b[p] != j) {
        cout << a[i][j];
      } else {
        p++;
      }
    }
    cout << '\n';
  }
  cin >> n;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int n, m, k, p;
char a[102][102];
int b[102];

int main() {
  for (int i = 0; i < 102; i++)
    b[i] = 100;
  cin >> n >> m;
  p = 0;

  for (int i = 0; i < n; i++) {
    k = 0;
    cin >> a[p];
    for (int j = 0; j < m; j++) {
      if (a[p][j] == '.')
        k++;
    }
    if (k == m)
      p--;
    p++;
  }
  n = p;

  p = 0;
  for (int j = 0; j < m; j++) {
    k = 0;
    for (int i = 0; i < n; i++) {
      if (a[i][j] == '.')
        k++;
    }
    if (k == n) {
      b[p] = j;
      p++;
    }
  }
  for (int i = 0; i < n; i++) {
    p = 0;
    for (int j = 0; j < m; j++) {
      if (b[p] != j) {
        cout << a[i][j];
      } else {
        p++;
      }
    }
    cout << '\n';
  }
  cin >> n;
  return 0;
}
Problem p03273 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define _rep(i, m, n) for (long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B) {
  if (B == 0)
    return A;
  return gcd(B, A % B);
}
ll lcm(ll A, ll B) { return A * B / gcd(A, B); }

/*------------------------------------------------------------------*/

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  vector<bool> flag_h(h, false);
  vector<bool> flag_w(w, false);

  rep(i, h) rep(j, w) if (a[i][j] == '#') flag_h[i] = true;
  rep(i, h) rep(j, w) if (a[j][i] == '#') flag_w[i] = true;

  rep(i, h) {
    if (!flag_h[i])
      continue;
    rep(j, w) {
      if (flag_w[j])
        cout << a[i][j];
    }
    cout << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define _rep(i, m, n) for (long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B) {
  if (B == 0)
    return A;
  return gcd(B, A % B);
}
ll lcm(ll A, ll B) { return A * B / gcd(A, B); }

/*------------------------------------------------------------------*/

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  vector<bool> flag_h(h, false);
  vector<bool> flag_w(w, false);

  rep(i, h) rep(j, w) if (a[i][j] == '#') flag_h[i] = true;
  rep(i, w) rep(j, h) if (a[j][i] == '#') flag_w[i] = true;

  rep(i, h) {
    if (!flag_h[i])
      continue;
    rep(j, w) {
      if (flag_w[j])
        cout << a[i][j];
    }
    cout << endl;
  }
}
Problem p03273 (C++)

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  char a[200][200];

  bool ux[200], uy[200];
  memset(a, 0, sizeof(a));
  memset(ux, 0, sizeof(a));
  memset(uy, 0, sizeof(a));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      if (a[i][j] == '#') {
        ux[j] = 1;
        uy[i] = 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (uy[i]) {
      for (int j = 0; j < w; j++) {
        if (ux[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <string.h>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  char a[200][200];

  bool ux[200], uy[200];
  memset(a, 0, sizeof(a));
  memset(ux, 0, sizeof(ux));
  memset(uy, 0, sizeof(uy));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      if (a[i][j] == '#') {
        ux[j] = 1;
        uy[i] = 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (uy[i]) {
      for (int j = 0; j < w; j++) {
        if (ux[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}
Problem p03273 (C++)

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

int h, w;
char a;
bool x[100], y[100];
map<pair<int, int>, char> arr;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> h >> w;
  memset(x, true, h + 1);
  memset(y, true, w + 1);

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a;
      arr[make_pair(i, j)] = a;
      if (a == '#') {
        x[i] = false;
        y[j] = false;
      }
    }
  }

  for (int i = 1; i <= w; i++) {
    if (y[i]) {
      for (int j = 1; j <= h; j++) {
        arr[make_pair(j, i)] = 'x';
      }
    }
  }

  for (int i = 1; i <= h; i++) {
    if (x[i]) {
      for (int j = 1; j <= w; j++) {
        arr[make_pair(i, j)] = 'x';
      }
    }
  }

  bool enter = false;
  for (int i = 1; i <= h; i++) {
    enter = false;
    for (int j = 1; j <= w; j++) {
      if (arr[make_pair(i, j)] != 'x') {
        cout << arr[make_pair(i, j)];
        enter = true;
      }
    }
    if (enter)
      cout << endl;
  }
  return 0;
}

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

int h, w;
char a;
bool x[101], y[101];
map<pair<int, int>, char> arr;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> h >> w;
  memset(x, true, h + 1);
  memset(y, true, w + 1);

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a;
      arr[make_pair(i, j)] = a;
      if (a == '#') {
        x[i] = false;
        y[j] = false;
      }
    }
  }

  for (int i = 1; i <= w; i++) {
    if (y[i]) {
      for (int j = 1; j <= h; j++) {
        arr[make_pair(j, i)] = 'x';
      }
    }
  }

  for (int i = 1; i <= h; i++) {
    if (x[i]) {
      for (int j = 1; j <= w; j++) {
        arr[make_pair(i, j)] = 'x';
      }
    }
  }

  bool enter = false;
  for (int i = 1; i <= h; i++) {
    enter = false;
    for (int j = 1; j <= w; j++) {
      if (arr[make_pair(i, j)] != 'x') {
        cout << arr[make_pair(i, j)];
        enter = true;
      }
    }
    if (enter)
      cout << endl;
  }
  return 0;
}