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

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

int main() {
  int h, w;
  cin >> h >> w;
  char a[h + 2][w + 2];
  fill(a[0], a[w + 2], '#');

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }

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


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

int main() {
  int h, w;
  cin >> h >> w;
  char a[h + 2][w + 2];
  fill(a[0], a[h + 2], '#');

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  char field[101][102];

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> field[i][j];
    }
  }

  for (int i = 0; i < H + 2; i++)
    field[i][0] = '#';
  for (int i = 0; i < H + 2; i++)
    field[i][W + 1] = '#';
  for (int i = 0; i < W + 2; i++)
    field[0][i] = '#';
  for (int i = 0; i < W + 2; i++)
    field[H + 1][i] = '#';

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << field[i][j];
    }
    cout << endl;
  }

  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  char field[110][110];

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> field[i][j];
    }
  }

  for (int i = 0; i < H + 2; i++)
    field[i][0] = '#';
  for (int i = 0; i < H + 2; i++)
    field[i][W + 1] = '#';
  for (int i = 0; i < W + 2; i++)
    field[0][i] = '#';
  for (int i = 0; i < W + 2; i++)
    field[H + 1][i] = '#';

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << field[i][j];
    }
    cout << endl;
  }

  return 0;
}
Problem p03712 (C++)

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> ans(h + 2, vector<char>(w + 2));
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++)
      ans[i][j] = '#';
  }
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      ans[i + 1][j + 1] = a[i][j];
    }
  }
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << a[i][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>> ans(h + 2, vector<char>(w + 2));
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++)
      ans[i][j] = '#';
  }
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      ans[i + 1][j + 1] = a[i][j];
    }
  }
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << ans[i][j];
      if (j == w + 1)
        cout << endl;
    }
  }
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    vector<char> vec(W);
    cout << '#';
    for (int j = 0; j < H; j++) {
      cin >> vec.at(j);
      cout << vec.at(j);
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    vector<char> vec(W);
    cout << '#';
    for (int j = 0; j < W; j++) {
      cin >> vec.at(j);
      cout << vec.at(j);
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}
Problem p03712 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);

  for (int i = 0; i < n; i++)
    cin >> a.at(i);

  for (int i = 0; i < m + 2; i++)
    cout << "#";
  cout << endl;

  for (int i = 0; i < m; i++)
    cout << "#" << a.at(i) << "#" << endl;

  for (int i = 0; i < m + 2; i++)
    cout << "#";
  cout << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);

  for (int i = 0; i < n; i++)
    cin >> a.at(i);

  for (int i = 0; i < m + 2; i++)
    cout << "#";
  cout << endl;

  for (int i = 0; i < n; i++)
    cout << "#" << a.at(i) << "#" << endl;

  for (int i = 0; i < m + 2; i++)
    cout << "#";
  cout << endl;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  string s[w];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << '#' << s[i] << '#' << endl;
  }
  for (int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << '#' << s[i] << '#' << endl;
  }
  for (int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  return 0;
}
Problem p03712 (C++)

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

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

  string a[50];
  for (int i = 0; i < H; i++)
    cin >> a[i];

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if (i == 0)
        cout << '#';
      else if (i == H + 1)
        cout << '#';
      else if (j == 0)
        cout << '#';
      else if (j == W + 1)
        cout << '#';
      else
        cout << a[i - 1][j - 1];
    }
    cout << endl;
  }
}

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

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

  string a[100];
  for (int i = 0; i < H; i++)
    cin >> a[i];

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if (i == 0)
        cout << '#';
      else if (i == H + 1)
        cout << '#';
      else if (j == 0)
        cout << '#';
      else if (j == W + 1)
        cout << '#';
      else
        cout << a[i - 1][j - 1];
    }
    cout << endl;
  }
}
Problem p03712 (C++)

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

int int_len(int n) {
  int s = 0;
  while (n != 0)
    s++, n /= 10;
  return s;
}

int int_sum(int n) {
  int m = 0, s = 0, a = n;
  while (a != 0)
    s++, a /= 10;
  for (int i = s - 1; i >= 0; i--)
    m += n / ((int)pow(10, i)) - (n / ((int)pow(10, i + 1))) * 10;
  return m;
}

int gcd(int a, int b) {

  int r, tmp;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int fac(int n) {
  int m = 1;
  while (n >= 1)
    m *= n, n--;
  return m;
}

int vec_sum(vector<int> v) {
  int n = 0;
  for (int i = 0; i < v.size(); i++)
    n += v[i];
  return n;
}
///////////////////////////
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i, h) cin >> v[i];
  rep(i, w + 2) cout << '#';
  cout << endl;
  rep(i, w) { cout << '#' << v[i] << '#' << endl; }
  rep(i, w + 2) cout << '#';
  cout << endl;
}
///////////////////////////


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

int int_len(int n) {
  int s = 0;
  while (n != 0)
    s++, n /= 10;
  return s;
}

int int_sum(int n) {
  int m = 0, s = 0, a = n;
  while (a != 0)
    s++, a /= 10;
  for (int i = s - 1; i >= 0; i--)
    m += n / ((int)pow(10, i)) - (n / ((int)pow(10, i + 1))) * 10;
  return m;
}

int gcd(int a, int b) {

  int r, tmp;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int fac(int n) {
  int m = 1;
  while (n >= 1)
    m *= n, n--;
  return m;
}

int vec_sum(vector<int> v) {
  int n = 0;
  for (int i = 0; i < v.size(); i++)
    n += v[i];
  return n;
}
///////////////////////////
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i, h) cin >> v[i];
  rep(i, w + 2) cout << '#';
  cout << endl;
  rep(i, h) { cout << '#' << v[i] << '#' << endl; }
  rep(i, w + 2) cout << '#';
  cout << endl;
}
///////////////////////////
Problem p03712 (C++)

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

int main() {
  int h, w;
  string a[50];

  cin >> h >> w;
  for (int i = 0; i < h; i++)
    cin >> a[i];

  for (int i = 0; i < h + 2; i++) {
    if (i == 0 || i == h + 1) {
      for (int j = 0; j < w + 2; j++)
        cout << "#";
      cout << endl;
    } else
      cout << "#" << a[i - 1] << "#" << endl;
  }
}

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

int main() {
  int h, w;
  string a[100];

  cin >> h >> w;
  for (int i = 0; i < h; i++)
    cin >> a[i];

  for (int i = 0; i < h + 2; i++) {
    if (i == 0 || i == h + 1) {
      for (int j = 0; j < w + 2; j++)
        cout << "#";
      cout << endl;
    } else
      cout << "#" << a[i - 1] << "#" << endl;
  }
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  char R[100][100];
  cin >> H >> W;
  for (int y = 0; y < H + 2; y++) {
    for (int x = 0; x < W + 2; x++) {
      if (x == 0 || y == 0 || x == W + 1 || y == H + 1)
        R[x][y] = '#';
      else
        cin >> R[x][y];
    }
  }

  for (int y = 0; y < H + 2; y++) {
    for (int x = 0; x < W + 2; x++) {
      cout << R[x][y];
    }
    cout << "\n";
  }
  return 0;
}

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

int main() {
  int H, W;
  char R[102][102];
  cin >> H >> W;
  for (int y = 0; y < H + 2; y++) {
    for (int x = 0; x < W + 2; x++) {
      if (x == 0 || y == 0 || x == W + 1 || y == H + 1)
        R[x][y] = '#';
      else
        cin >> R[x][y];
    }
  }

  for (int y = 0; y < H + 2; y++) {
    for (int x = 0; x < W + 2; x++) {
      cout << R[x][y];
    }
    cout << "\n";
  }
  return 0;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int H, W;
int main(int argc, char const *argv[]) {
  cin >> H >> W;
  vector<string> S(W);
  for (size_t i = 0; i < H; i++) {
    cin >> S[i];
  }
  string sharp(W + 2, '#');
  cout << sharp << endl;
  for (size_t i = 0; i < H; i++) {
    cout << '#' << S[i] << '#' << endl;
  }
  cout << sharp << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int H, W;
int main(int argc, char const *argv[]) {
  cin >> H >> W;
  vector<string> S(H);
  for (size_t i = 0; i < H; i++) {
    cin >> S[i];
  }
  string sharp(W + 2, '#');
  cout << sharp << endl;
  for (size_t i = 0; i < H; i++) {
    cout << '#' << S[i] << '#' << endl;
  }
  cout << sharp << endl;
  return 0;
}
Problem p03712 (C++)

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

void print_horizontal_frame(int w) {
  for (int i = 0; i < i + 2; i++) {
    cout << '#';
  }
  cout << endl;
}
int main() {
  int h, w;
  cin >> h >> w;
  string a[h];
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  print_horizontal_frame(w);
  for (string s : a) {
    cout << '#' << s << '#' << endl;
  }
  print_horizontal_frame(w);
  return 0;
}

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

void print_horizontal_frame(int w) {
  for (int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  cout << endl;
}
int main() {
  int h, w;
  cin >> h >> w;
  string a[h];
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  print_horizontal_frame(w);
  for (string s : a) {
    cout << '#' << s << '#' << endl;
  }
  print_horizontal_frame(w);
  return 0;
}
Problem p03712 (C++)

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

using namespace std;

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

  char str[100][100], frame[100][100];

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

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      frame[i][j] = '#';
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      frame[i + 1][j + 1] = str[i][j];
    }
  }

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << frame[i][j];
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;

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

  char str[100][101], frame[102][102];

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

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      frame[i][j] = '#';
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      frame[i + 1][j + 1] = str[i][j];
    }
  }

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << frame[i][j];
    }
    cout << endl;
  }

  return 0;
}
Problem p03712 (C++)

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

int main() {

  int H, W;
  cin >> H >> W;
  string a[H];

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

  string s = "";

  for (int i = 0; i < W + 2; i++) {
    s += "#";
  }

  cout << s << endl;

  for (int i = 0; i < W; i++) {
    cout << "#" << a[i] << "#" << endl;
  }

  cout << s << endl;
}

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

int main() {

  int H, W;
  cin >> H >> W;
  string a[H];

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

  string s = "";

  for (int i = 0; i < W + 2; i++) {
    s += "#";
  }

  cout << s << endl;

  for (int i = 0; i < H; i++) {
    cout << "#" << a[i] << "#" << endl;
  }

  cout << s << endl;
}
Problem p03712 (C++)

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

int main() {
  int h, w;
  string s[101];
  s[0] = "", s[h + 1] = "";
  cin >> h >> w;
  for (int i = 0; i < h; ++i)
    cin >> s[i + 1];
  for (int j = 0; j < w; ++j) {
    s[0] += "#";
    s[h + 1] += "#";
  }
  for (int i = 0; i <= h + 1; ++i) {
    s[i] = "#" + s[i] + "#";
    cout << s[i] << endl;
  }
}

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

int main() {
  int h, w;
  string s[102];
  s[0] = "", s[h + 1] = "";
  cin >> h >> w;
  for (int i = 0; i < h; ++i)
    cin >> s[i + 1];
  for (int j = 0; j < w; ++j) {
    s[0] += "#";
    s[h + 1] += "#";
  }
  for (int i = 0; i <= h + 1; ++i) {
    s[i] = "#" + s[i] + "#";
    cout << s[i] << endl;
  }
}
Problem p03712 (C++)

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

using namespace std;
int main() {
  int H, W;
  string a[100];
  cin >> H >> W;
  a[0] = a[H + 1] = string(W, '#');

  for (int i = 1; i < H + 1; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < H + 2; i++) {
    cout << '#' << a[i] << '#' << endl;
  }

  return 0;
}

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

using namespace std;
int main() {
  int H, W;
  string a[102];
  cin >> H >> W;
  a[0] = a[H + 1] = string(W, '#');

  for (int i = 1; i < H + 1; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < H + 2; i++) {
    cout << '#' << a[i] << '#' << endl;
  }

  return 0;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using namespace std;

int main() {
  string s[100];
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++)
    cin >> s[i];
  for (int i = 0; i <= h + 1; i++) {
    if (i == 0 || i == h + 1) {
      for (int j = 0; j <= w + 1; j++)
        cout << '#';
      cout << endl;
    } else
      cout << "#" << s[i] << "#" << endl;
  }
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using namespace std;

int main() {
  string s[110];
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++)
    cin >> s[i];
  for (int i = 0; i <= h + 1; i++) {
    if (i == 0 || i == h + 1) {
      for (int j = 0; j <= w + 1; j++)
        cout << '#';
      cout << endl;
    } else
      cout << "#" << s[i] << "#" << endl;
  }
}
Problem p03712 (C++)

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

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

  vector<string> A(W);
  vector<string> B(W + 2, "#");

  // 最上のシャープ
  for (int i = 0; i < B.size(); ++i) {
    cout << B[i];
  }
  cout << endl;

  // 真ん中のシャープとstring
  for (int i = 0; i < H; ++i) {
    cin >> A[i];
    cout << '#' << A[i] << '#' << endl;
  }

  // 一番下のシャープ
  for (int i = 0; i < B.size(); ++i) {
    cout << B[i];
  }
  cout << endl;
}

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

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

  vector<string> A(H);
  vector<string> B(W + 2, "#");

  // 最上のシャープ
  for (int i = 0; i < B.size(); ++i) {
    cout << B[i];
  }
  cout << endl;

  // 真ん中のシャープとstring
  for (int i = 0; i < H; ++i) {
    cin >> A[i];
    cout << '#' << A[i] << '#' << endl;
  }

  // 一番下のシャープ
  for (int i = 0; i < B.size(); ++i) {
    cout << B[i];
  }
  cout << endl;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> F(W + 2, '#');
  vector<char> T(W);
  for (int i = 0; i < W + 2; i++) {
    cout << F.at(i);
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int u = 0; u < W; u++) {
      cin >> T.at(i);
      cout << T.at(i);
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << F.at(i);
  }
  cout << endl;
}


Fixed submission:

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> F(W + 2, '#');
  vector<char> T(W);
  for (int i = 0; i < W + 2; i++) {
    cout << F.at(i);
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int u = 0; u < W; u++) {
      cin >> T.at(u);
      cout << T.at(u);
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << F.at(i);
  }
  cout << endl;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> M(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i <= H; i++) {
    string S;
    cin >> S;
    for (int j = 1; j <= W; j++) {
      M.at(i).at(j) = S.at(j + 1);
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 1; j++) {
      cout << M.at(i).at(j);
    }
    cout << M.at(i).at(W + 1) << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> M(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i <= H; i++) {
    string S;
    cin >> S;
    for (int j = 1; j <= W; j++) {
      M.at(i).at(j) = S.at(j - 1);
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 1; j++) {
      cout << M.at(i).at(j);
    }
    cout << M.at(i).at(W + 1) << endl;
  }

  return 0;
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> out(H * W);
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {

      if (i == 0 || i == H + 1) {
        cout << "#";
      }

      else if (j == 0 || j == W + 1) {
        cout << "#";
      } else {
        cin >> out.at(j);
        cout << out.at(j);
      }
    }
    cout << endl;
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> out(H * W + 10);
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {

      if (i == 0 || i == H + 1) {
        cout << "#";
      }

      else if (j == 0 || j == W + 1) {
        cout << "#";
      } else {
        cin >> out.at(j);
        cout << out.at(j);
      }
    }
    cout << endl;
  }
}
Problem p03712 (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 < H; i++) {
    cin >> s.at(i);
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' << s.at(i) << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(100);
  for (int i = 0; i < H; i++) {
    cin >> s.at(i);
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' << s.at(i) << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
int main() {
  char a[100][100];
  int H, W;
  while (scanf("%d %d", &H, &W) == 2) {
    for (int i = 1; i <= H; i++) {
      getchar();
      for (int j = 1; j <= W; j++)
        a[i][j] = getchar();
    }
    getchar();
    for (int i = 0; i <= H + 1; i++) {
      for (int j = 0; j <= W + 1; j++) {
        if (i == 0 || j == 0 || i == H + 1 || j == W + 1)
          printf("#");
        else
          printf("%c", a[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}


Fixed submission:
#include <cstdio>
int main() {
  char a[105][105];
  int H, W;
  while (scanf("%d %d", &H, &W) == 2) {
    for (int i = 1; i <= H; i++) {
      getchar();
      for (int j = 1; j <= W; j++)
        a[i][j] = getchar();
    }
    getchar();
    for (int i = 0; i <= H + 1; i++) {
      for (int j = 0; j <= W + 1; j++) {
        if (i == 0 || j == 0 || i == H + 1 || j == W + 1)
          printf("#");
        else
          printf("%c", a[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
Problem p03712 (C++)

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

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

  // N要素の配列

  // 入力処理
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }

  cout << "" << endl;

  for (int i = 0; i < H; i++) {
    cout << "#";
    vector<string> A(W);
    cin >> A.at(i);
    cout << A.at(i);
    cout << "#" << endl;
  }

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

  cout << "" << endl;
}


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

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

  // N要素の配列

  // 入力処理
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }

  cout << "" << endl;

  for (int i = 0; i < H; i++) {
    cout << "#";
    for (int j = 0; j < W; j++) {
      vector<char> A(W);
      cin >> A.at(j);
      cout << A.at(j);
    }
    cout << "#" << endl;
  }

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

  cout << "" << endl;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int h, w;
  cin >> h >> w;
  char a[h + h][w + w];
  rep(i, h) {
    rep(j, w) { cin >> a[i + 1][j + 1]; }
  }
  rep(i, w + 2) a[0][i] = '#';
  rep(i, w + 2) a[h + 1][i] = '#';
  rep(i, h + 2) a[i][0] = '#';
  rep(i, h + 2) a[i][w + 1] = '#';
  rep(i, h + 2) {
    rep(j, w + 2) { cout << a[i][j]; }
    cout << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int h, w;
  cin >> h >> w;
  char a[h + 2][w + 2];
  rep(i, h) {
    rep(j, w) { cin >> a[i + 1][j + 1]; }
  }
  rep(i, w + 2) a[0][i] = '#';
  rep(i, w + 2) a[h + 1][i] = '#';
  rep(i, h + 2) a[i][0] = '#';
  rep(i, h + 2) a[i][w + 1] = '#';
  rep(i, h + 2) {
    rep(j, w + 2) { cout << a[i][j]; }
    cout << endl;
  }
}
Problem p03712 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  vector<string> d;
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      cin >> d[i][j];
    }
  }
  for (int k = 0; k < a + 2; k++) {
    for (int l = 0; l < b + 2; l++) {
      if (k == 0 || k == a + 1 || l == 0 || l == b + 1) {
        cout << "#";
      } else {
        cout << d[k - 1][l - 1];
      }
    }
    cout << endl;
  }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  char d[100][100];
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      cin >> d[i][j];
    }
  }
  for (int k = 0; k < a + 2; k++) {
    for (int l = 0; l < b + 2; l++) {
      if (k == 0 || k == a + 1 || l == 0 || l == b + 1) {
        cout << "#";
      } else {
        cout << d[k - 1][l - 1];
      }
    }
    cout << endl;
  }
}
Problem p03712 (C++)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll h, w;
  cin >> h >> w;
  char pf[w + 2][h + 2];
  rep(i, 0, h + 2) {
    rep(j, 0, w + 2) {
      if (i == 0 or j == 0 or i == h + 1 or j == w + 1)
        pf[i][j] = '#';
      else
        cin >> pf[i][j];
    }
  }
  rep(i, 0, h + 2) {
    rep(j, 0, w + 2) { cout << pf[i][j]; }
    cout << "\n";
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll h, w;
  cin >> h >> w;
  vector<vector<char>> pf(h + 2, vector<char>(w + 2));
  rep(i, 0, h + 2) {
    rep(j, 0, w + 2) {
      if (i == 0 or j == 0 or i == h + 1 or j == w + 1)
        pf[i][j] = '#';
      else
        cin >> pf[i][j];
    }
  }
  rep(i, 0, h + 2) {
    rep(j, 0, w + 2) { cout << pf[i][j]; }
    cout << "\n";
  }
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  char a[101][101];

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      a[i][j] = '#';
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  char a[1000][1000];

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      a[i][j] = '#';
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}
Problem p03712 (C++)

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

int main() {
  int h, w;
  string tmp;
  cin >> h >> w;
  vector<string> a(w + 2, "#");
  vector<string> b(w);
  for (int i = 0; i < h; i++) {
    cin >> b[i];
  }

  // 最初の囲い
  for (int i = 0; i < w + 2; i++) {
    cout << a[i];
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << "#" << b[i] << "#" << endl;
  }
  // 最後の囲い
  for (int i = 0; i < w + 2; i++) {
    cout << a[i];
  }
  cout << endl;
}


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

int main() {
  int h, w;
  string tmp;
  cin >> h >> w;
  vector<string> a(w + 2, "#");
  vector<string> b(h);
  for (int i = 0; i < h; i++) {
    cin >> b[i];
  }

  // 最初の囲い
  for (int i = 0; i < w + 2; i++) {
    cout << a[i];
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << "#" << b[i] << "#" << endl;
  }
  // 最後の囲い
  for (int i = 0; i < w + 2; i++) {
    cout << a[i];
  }
  cout << endl;
}
Problem p03712 (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>(w));
  vector<vector<char>> b(h + 2, vector<char>(w + 2));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < h + 2; i++) {
    if (i == 0 || i == h + 1) {
      for (int j = 0; j < w + 2; j++) {
        b.at(i).at(j) = '#';
      }
    } else {
      for (int j = 1; j < w + 1; j++) {
        b.at(i).at(j) = a.at(i).at(j - 1);
      }
      b.at(i).at(0) = '#';
      b.at(i).at(w + 1) = '#';
    }
  }

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << b.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>> a(h, vector<char>(w));
  vector<vector<char>> b(h + 2, vector<char>(w + 2));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < h + 2; i++) {
    if (i == 0 || i == h + 1) {
      for (int j = 0; j < w + 2; j++) {
        b.at(i).at(j) = '#';
      }
    } else {
      for (int j = 1; j < w + 1; j++) {
        b.at(i).at(j) = a.at(i - 1).at(j - 1);
      }
      b.at(i).at(0) = '#';
      b.at(i).at(w + 1) = '#';
    }
  }

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << b.at(i).at(j);
    }
    cout << endl;
  }
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(W);
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
    cout << "#" << a.at(i) << "#" << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  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 < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
    cout << "#" << a.at(i) << "#" << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}
Problem p03712 (C++)

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

using namespace std;

int main(void) {
  int h, w;
  char a[101][101];
  cin >> h >> w;
  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      if ((i == 0) || (i == h + 1)) {
        a[i][j] = '#';
      } else {
        if ((j == 0) || (j == w + 1)) {
          a[i][j] = '#';
        } else {
          cin >> a[i][j];
        }
      }
    }
  }
  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main(void) {
  int h, w;
  char a[110][110];
  cin >> h >> w;
  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      if ((i == 0) || (i == h + 1)) {
        a[i][j] = '#';
      } else {
        if ((j == 0) || (j == w + 1)) {
          a[i][j] = '#';
        } else {
          cin >> a[i][j];
        }
      }
    }
  }
  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> str(W);

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

  for (int i = 0; i < H; i++) {
    cout << '#';

    /*for (int i = 0; i < 1; i++){*/
    cin >> str.at(i);
    cout << str.at(i);
    /*}*/
    cout << '#' << endl;
  }

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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> str(W);

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

  for (int i = 0; i < H; i++) {
    cout << '#';

    for (int i = 0; i < 1; i++) {
      cin >> str.at(i);
      cout << str.at(i);
    }
    cout << '#' << endl;
  }

  for (int i = 0; i <= W + 1; i++) {
    cout << "#";
  }
}
Problem p03712 (C++)

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

int main() {
  int h, w;
  cin >> h >> w;
  char a[w][h], b[w + 2][h + 2];

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      b[i][j] = '#';
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      b[i + 1][j + 1] = a[i][j];
    }
  }
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; 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 a[100][100], b[102][102];

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      b[i][j] = '#';
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      b[i + 1][j + 1] = a[i][j];
    }
  }
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << b[i][j];
    }
    cout << endl;
  }
}
Problem p03712 (C++)

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

int main() {
  int h, w;
  cin >> h >> w;
  for (int k = 0; k < w + 2; k++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    vector<string> a(w);
    cout << "#";
    cin >> a.at(i);
    cout << a.at(i);
    cout << "#" << endl;
  }
  for (int l = 0; l < w + 2; l++) {
    cout << "#";
  }
  cout << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  for (int k = 0; k < w + 2; k++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    vector<string> a(100);
    cout << "#";
    cin >> a.at(i);
    cout << a.at(i);
    cout << "#" << endl;
  }
  for (int l = 0; l < w + 2; l++) {
    cout << "#";
  }
  cout << endl;
}
Problem p03712 (C++)

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

int main() {
  vector<string> strVec;
  int H, W;
  cin >> H >> W;
  string A;
  int I, i, S, j, k;
  for (I = 0; I < H; I++) {
    string A;
    cin >> A;
    strVec.push_back(A);
  }
  for (j = 0; j < W + 1; j++) {
    cout << "#";
  }
  cout << "#" << endl;
  for (i = 0; i < W - 1; i++) {
    cout << "#" + strVec[i] + "#" << endl;
  }
  for (k = 0; k < W + 1; k++) {
    cout << "#";
  }
  cout << "#" << endl;
  return 0;
}

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

int main() {
  vector<string> strVec;
  int H, W;
  cin >> H >> W;
  string A;
  int I, i, S, j, k;
  for (I = 0; I < H; I++) {
    string A;
    cin >> A;
    strVec.push_back(A);
  }
  for (j = 0; j < W + 1; j++) {
    cout << "#";
  }
  cout << "#" << endl;
  for (i = 0; i < H; i++) {
    cout << "#" + strVec[i] + "#" << endl;
  }
  for (k = 0; k < W + 1; k++) {
    cout << "#";
  }
  cout << "#" << endl;
  return 0;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
int main(void) {
  int H, W;
  std::cin >> H >> W;
  std::string space[(H + 2) * (W + 2)];
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      std::cin >> space[i][j];
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
        space[i][j] = '#';
      }
    }
  }
  std::cout << std::endl;
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      std::cout << space[i][j];
    }
    std::cout << std::endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
int main(void) {
  int H, W;
  std::cin >> H >> W;
  char space[H + 2][W + 2];
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      std::cin >> space[i][j];
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
        space[i][j] = '#';
      }
    }
  }
  std::cout << std::endl;
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      std::cout << space[i][j];
    }
    std::cout << std::endl;
  }
  return 0;
}
Problem p03712 (C++)

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

using namespace std;
#define int long long

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

  char a[H + 1][W + 1];
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> a[i][j];
      a[0][j] = '#';
      a[H + 1][j] = '#';
    }
    a[i][0] = '#';
    a[i][W + 1] = '#';
  }

  a[0][0] = '#';
  a[0][W + 1] = '#';
  a[H + 1][0] = '#';
  a[H + 1][W + 1] = '#';

  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      cout << a[i][j];
    }
    cout << "" << endl;
  }
  return 0;
}


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

using namespace std;
#define int long long

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

  char a[H + 2][W + 2];
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> a[i][j];
      a[0][j] = '#';
      a[H + 1][j] = '#';
    }
    a[i][0] = '#';
    a[i][W + 1] = '#';
  }

  a[0][0] = '#';
  a[0][W + 1] = '#';
  a[H + 1][0] = '#';
  a[H + 1][W + 1] = '#';

  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      cout << a[i][j];
    }
    cout << "" << endl;
  }
  return 0;
}
Problem p03712 (C++)

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> line(w);

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

  string sharp = "#";
  for (int i = 0; i < w; i++) {
    sharp += "#";
  }
  sharp += "#";
  cout << sharp << endl;

  for (int i = 0; i < h; i++) {
    cout << "#" + line.at(i) + "#" << endl;
  }

  cout << sharp << endl;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> line(h);

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

  string sharp = "#";
  for (int i = 0; i < w; i++) {
    sharp += "#";
  }
  sharp += "#";
  cout << sharp << endl;

  for (int i = 0; i < h; i++) {
    cout << "#" + line.at(i) + "#" << endl;
  }

  cout << sharp << endl;
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  string S;
  vector<char> A(W + 2, '#');
  for (int i = 0; i < (W + 2); i++) {
    cout << A.at(i);
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cin >> S;
    for (int j = 0; j < (W + 2); j++) {
      if (j == 0 || j == W + 1) {
      } else {
        A.at(i) = S.at(j - 1);
      }
    }
    for (int l = 0; l < (W + 2); l++) {
      cout << A.at(l);
    }
    cout << endl;
    for (int k = 0; k < (W + 2); k++) {
      A.at(k) = '#';
    }
  }
  for (int i = 0; i < (W + 2); i++) {
    cout << A.at(i);
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string S;
  vector<char> A(W + 2, '#');
  for (int i = 0; i < (W + 2); i++) {
    cout << A.at(i);
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cin >> S;
    for (int j = 0; j < (W + 2); j++) {
      if (j == 0 || j == W + 1) {
      } else {
        A.at(j) = S.at(j - 1);
      }
    }
    for (int l = 0; l < (W + 2); l++) {
      cout << A.at(l);
    }
    cout << endl;
    for (int k = 0; k < (W + 2); k++) {
      A.at(k) = '#';
    }
  }
  for (int i = 0; i < (W + 2); i++) {
    cout << A.at(i);
  }
}
Problem p03712 (C++)

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

int main() {
  int height;
  int width;
  cin >> height >> width;
  vector<string> str(width);
  for (int i = 0; i < width; ++i) {
    cin >> str.at(i);
  }

  for (int i = 0; i < width + 2; ++i) {
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < height; ++i) {
    cout << "#" << str.at(i) << "#" << endl;
  }

  for (int i = 0; i < width + 2; ++i) {
    cout << "#";
  }
}

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

int main() {
  int height;
  int width;
  cin >> height >> width;
  vector<string> str(height);
  for (int i = 0; i < height; ++i) {
    cin >> str.at(i);
  }

  for (int i = 0; i < width + 2; ++i) {
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < height; ++i) {
    cout << "#" << str.at(i) << "#" << endl;
  }

  for (int i = 0; i < width + 2; ++i) {
    cout << "#";
  }
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  char a[55][55];
  int i, j, m, n, k, l;
  cin >> m >> n;
  k = m + 2;
  l = n + 2;
  for (i = 0; i < k; i++) {
    for (j = 0; j < l; j++) {
      a[i][j] = '#';
    }
  }

  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < k; i++) {
    for (j = 0; j < l; j++) {
      cout << a[i][j];
    }
    puts(" ");
  }
  puts(" ");
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  char a[200][200];
  int i, j, m, n, k, l;
  cin >> m >> n;
  k = m + 2;
  l = n + 2;
  for (i = 0; i < k; i++) {
    for (j = 0; j < l; j++) {
      a[i][j] = '#';
    }
  }

  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < k; i++) {
    for (j = 0; j < l; j++) {
      cout << a[i][j];
    }
    puts(" ");
  }
  puts(" ");
}
Problem p03712 (C++)

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

int main() {
  int H, W;
  cin >> H >> W;
  string S = "";

  vector<char> vec(W + 2, '#');

  for (int i = 0; i < W + 2; i++) {
    S += vec.at(i);
  }
  cout << S << endl;
  S = "";

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(j + 1);
    }
    for (int k = 0; k < W + 2; k++) {
      S += vec.at(i);
    }
    cout << S << endl;
    S = "";
  }

  for (int i = 0; i < W + 2; i++) {
    vec.at(i) = '#';
  }
  for (int i = 0; i < W + 2; i++) {
    S += vec.at(i);
  }
  cout << S << endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  string S = "";

  vector<char> vec(W + 2, '#');

  for (int i = 0; i < W + 2; i++) {
    S += vec.at(i);
  }
  cout << S << endl;
  S = "";

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(j + 1);
    }
    for (int k = 0; k < W + 2; k++) {
      S += vec.at(k);
    }
    cout << S << endl;
    S = "";
  }

  for (int i = 0; i < W + 2; i++) {
    vec.at(i) = '#';
  }
  for (int i = 0; i < W + 2; i++) {
    S += vec.at(i);
  }
  cout << S << endl;
}
Problem p03712 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
using namespace std;
// 桁
int kt(int a) {
  double b = a;
  b = log10(b);
  int c = b;
  return c + 1;
}
int lcm(int a, int b) {
  int d = a, e = b, f;
  if (a < b)
    swap(a, b);
  int c, m = 1;
  while (m) {
    c = a % b;
    if (c == 0) {
      f = b;
      m--;
    } else {
      a = b;
      b = c;
    }
  }
  return d * e / f;
}
int gcm(int a, int b) {
  int d = a, e = b, f;
  if (a < b)
    swap(a, b);
  int c, m = 1;
  while (m) {
    c = a % b;
    if (c == 0) {
      f = b;
      m--;
    } else {
      a = b;
      b = c;
    }
  }
  return f;
}
signed main() {
  int a, b;
  cin >> a >> b;
  vector<string> c(b);
  rep(i, a) { cin >> c.at(i); }
  rep(i, b + 2) {
    cout << '#';
    if (i == b + 1)
      cout << endl;
  }
  rep(i, a) cout << '#' << c.at(i) << '#' << endl;
  rep(i, b + 2) cout << '#';
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
using namespace std;
// 桁
int kt(int a) {
  double b = a;
  b = log10(b);
  int c = b;
  return c + 1;
}
int lcm(int a, int b) {
  int d = a, e = b, f;
  if (a < b)
    swap(a, b);
  int c, m = 1;
  while (m) {
    c = a % b;
    if (c == 0) {
      f = b;
      m--;
    } else {
      a = b;
      b = c;
    }
  }
  return d * e / f;
}
int gcm(int a, int b) {
  int d = a, e = b, f;
  if (a < b)
    swap(a, b);
  int c, m = 1;
  while (m) {
    c = a % b;
    if (c == 0) {
      f = b;
      m--;
    } else {
      a = b;
      b = c;
    }
  }
  return f;
}
signed main() {
  int a, b;
  cin >> a >> b;
  vector<string> c(a);
  rep(i, a) { cin >> c.at(i); }
  rep(i, b + 2) {
    cout << '#';
    if (i == b + 1)
      cout << endl;
  }
  rep(i, a) cout << '#' << c.at(i) << '#' << endl;
  rep(i, b + 2) cout << '#';
}