alexjercan/bugnet huggingface dataset:
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  int H, W, i, j;
  while (1) {
    scanf("%d%d", &H, &W);
    if (H == 0 && W == 0)
      break;

    for (i = 1; i <= H; i++) {
      for (j = 1; j <= W; j++) {

        if (i == 1 || j == 1 || j == W || i == H) {

          printf("#");

        } else {

          printf(".");
        }
      }

      printf("\\n");
    }
    printf("\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {

  int H, W, i, j;
  while (1) {
    scanf("%d%d", &H, &W);
    for (i = 1; i <= H; i++) {
      for (j = 1; j <= W; j++) {
        if (i == 1 || j == 1 || j == W || i == H) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\\n");
    }
  }
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!

  int W, H, a = 0, b = 0;
  char s = '#', d = '.';
  while (1) {
    cin >> H >> W;
    if (W == 0 || H == 0)
      break;
    for (a = 0; a < H; a++) {
      for (b = 0; b < W; b++) {
        if (a == 0) {
          cout << s;
        } else if (a > 0 && a < H - 1) {
          if (b == 0)
            cout << s;
          else if (b == W - 1)
            cout << s;
          else
            cout << d;
        } else if (a < H) {
          cout << s;
        }
      }

      cout << endl;
    }
    cout << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!

  int W, H, a = 0, b = 0;
  char s = '#', d = '.';
  while (1) {
    cin >> H >> W;
    for (a = 0; a < H; a++) {
      for (b = 0; b < W; b++) {
        if (a == 0) {
          cout << s;
        } else if (a > 0 && a < H - 1) {
          if (b == 0)
            cout << s;
          else if (b == W - 1)
            cout << s;
          else
            cout << d;
        } else if (a < H) {
          cout << s;
        }
      }
      if (W == 0 || H == 0)
        break;
      cout << endl;
    }
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

void printFrame(int x, int y) {
  int i, j;
  for (i = 0; i < y; i++)
    printf("#");
  printf("\\n");
  for (i = 2; i < x; i++) {
    printf("#");
    for (j = 2; j < y; j++)
      printf(".");
    printf("#\\n");
  }
  for (i = 0; i < y; i++)
    printf("#");
  printf("\\n\\n");
}

int main() {
  int x = -1, y = -1;
  for (;;) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0)
      break;
    printFrame(x, y);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>

void printFrame(int x, int y) {
  int i, j;
  for (i = 0; i < y; i++)
    printf("#");
  printf("\\n");
  for (i = 2; i < x; i++) {
    printf("#");
    for (i = 2; i < y; i++)
      printf(".");
    printf("#\\n");
  }
  for (i = 0; i < y; i++)
    printf("#");
  printf("\\n");
}

int main() {
  int x = -1, y = -1;
  while (x != 0 && y != 0)
    printFrame(x, y);
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

int main() {

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


Error: TLE

Fixed submission:

#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

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

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

#include <iostream>

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

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

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

#include <iostream>

using namespace std;

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

    } else {
      break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  int w, h;
  while (cin >> h >> w, h || w) {
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x, w; ++x) {
        if (x == 0 || y == 0 || x == w - 1 || y == h - 1) {
          cout << '#';

        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

void PrintWallLine(int length) {
  using namespace std;
  for (int i = 0; i < length; ++i) {
    cout << '#';
  }
  cout << endl;
}

void PrintRoomLine(int length) {
  using namespace std;

  for (int i = 0; i < length; ++i) {
    if (i == 0 || i == length - 1) {
      cout << '#';
    } else {
      cout << '.';
    }
  }
  cout << endl;
}

void PrintArea(int H, int W) {
  using namespace std;

  for (int i = 0; i < H; ++i) {
    if (i == 0 || i == H - 1) {
      PrintWallLine(W);
    } else {
      PrintRoomLine(W);
    }
  }
  cout << endl;
}

int main() {
  using namespace std;

  while (true) {
    int H = 0;
    int W = 0;
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    PrintArea(H, W);
  }
  return 0;
}

Error: TLE

Fixed submission:

#import <iostream>
using namespace std;

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

  while (true) {
    if (h == 0 && w == 0)
      break;
    int i, j;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        if (i == 0 || i == h - 1) {
          cout << '#' << endl;
        } else {
          cout << '.' << endl;
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

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

  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

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

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

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

  int H, W, j, i;
  for (;;) {
    int x = 0;
    cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    }
    for (j = 1; j <= H; j++) {
      for (i = 1; i <= W; i++) {
        if (j == 1 || i == 1 || j == H || i == W) {
          cout << "#";
        } else {
          cout << ".";
        }
        if (j == H && i == W) {
          cout << endl;
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

  int H, W;
  for (;;) {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
      if (H == 0 && W == 0) {
        break;
      }
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    for (int i = 0; i < W; i++)
      cout << "#";
    cout << endl;
    for (int i = 1; i < H - 1; i++) {
      cout << "#";
      for (int i = 1; i < W - 1; i++)
        cout << ".";
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++)
      cout << "#";
    cout << endl << endl;
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
int main() {
  int H, W, i, j;

  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (i = 0; i < H; i++) {

      for (j = 0; j < W; j++) {
        if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
          cout << '#';
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;
int main() {
  int H, W, i, j;

  while (1) {
    cin >> H >> W;
    for (i = 0; i < H; i++) {
      if (H == 0 && W == 0)
        break;
      for (j = 0; j < W; j++) {
        if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
          cout << '#';
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int H, W;

  while (true) {

    cin >> H >> W;

    if (H == 0 && W == 0)
      break;

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

      if (i == 0 || i == H - 1) {

        for (int k = 0; k < W; ++k)
          cout << "#";
      } else {

        for (int k = 0; k < W; ++k) {

          if (k == 0 || k == W - 1) {

            cout << "#";
          } else {

            cout << ".";
          }
        }
      }

      cout << endl;
    }

    cout << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  int H, W;

  while (true) {

    cin >> H >> W;

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

      for (int k = 0; k < W; ++k) {

        if (i == 0 || i == H - 1) {

          cout << "#";
        } else if (k == 0 || k == W - 1) {

          cout << "#";
        } else {

          cout << ".";
        }
        cout << endl;
      }
      cout << endl;
    }
  }

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

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a = 1, b = 1, i = 1;
  while ((a != 0) || (b != 0)) {
    if (i != 1)
      cout << endl;
    i++;
    cin >> a >> b;
    if ((a != 0) || (b != 0))
      for (int i = 1; i <= a; i++) {
        for (int j = 1; j <= b; j++)
          if ((i == 1) || (i == a) || (j == 1) || (j == b))
            cout << '#';
          else
            cout << '.';
        cout << endl;
      }
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  while (!((a == 0) && (b == 0))) {
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if ((i == 1) || (j == 1))
          cout << '#';
        else
          cout << '.';
      }
      cout << ' ' << endl;
    }
    cout << endl;
  }
}
Problem p02404 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int H[10000], W[10000];
  int ct = 0;
  while (true) {
    cin >> H[ct] >> W[ct];
    if (H[ct] == 0 && W[ct] == 0)
      break;
    ct++;
  }
  for (int h = 0; h <= ct; h++) {
    if (h != 0)
      cout << endl;
    for (int i = 0; i < H[h]; i++) {
      if (i == 0 || i == H[h] - 1) {
        for (int j = 0; j < W[h]; j++) {
          cout << '#';
        }
      } else {
        cout << '#';
        for (int j = 1; j < W[h] - 1; j++) {
          cout << '.';
        }
        cout << '#';
      }
      cout << endl;
    }
  }
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int H[10000], W[10000];
  int ct;
  while (true) {
    cin >> H[ct] >> W[ct];
    if (H[ct] == 0 && W[ct] == 0)
      break;
    ct++;
  }
  for (int h = 0; h <= ct; h++) {
    for (int i = 0; i < H[h]; i++) {
      if (i == 0 || i == H[h] - 1) {
        for (int j = 0; j < W[h]; j++) {
          cout << '#';
        }
      } else {
        cout << '#';
        for (int j = 1; j < W[h] - 1; j++) {
          cout << '.';
        }
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int H, W;
  int i, j;
  int h, w;
  for (;;) {
    scanf("%d %d", &H, &W);
    h = H - 2;
    w = W - 2;
    if (H != 0 && W != 0) {
      for (i = 1; i <= H; i++) {
        if (i == 1 || i == H) {
          for (j = 1; j <= W; j++) {
            printf("#");
          }
          printf("\\n");
        } else if (i != 1 && i != H) {
          printf("#");
          for (j = 1; j <= w; j++) {
            printf(".");
          }
          printf("#\\n");
        }
      }
      printf("\\n");
    } else {
      break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int H, W;
  int i, j;
  int h, w;
  for (;;) {
    scanf("%d %d", &H, &W);
    if (H < 2) {
      h = H - 2;
    }
    if (W < 2) {
      w = W - 2;
    }
    for (i = 1; i <= H; i++) {
      if (i == 1) {
        for (j = 1; j <= 1; j++) {
          printf("#");
        }
        printf("\\n");
      }
      if (i != 1 && i != H) {
        printf("#");
        for (j = 1; j <= w; j++) {
          printf(".");
        }
        printf("#\\n");
      }
      if (i == H) {
        for (j = 1; j <= 1; j++) {
          printf("#");
        }
        printf("\\n");
      }
      printf("\\n");
    }
  }
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int i, j, k, count = 0, W, H;
  while (1 == 1) {
    scanf("%d%d", &H, &W);
    if (W == 0 && H == 0) {
      return 0;
    }
    for (j = 0; j < H; j++) {
      for (k = 0; k < W; k++) {
        if (j == 0 || j == H - 1) {
          printf("#");
        } else {
          (k == 0 || k == W - 1) ? printf("#") : printf(".");
        }
      }
      printf("\\n");
    }
    printf("\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int i, j, k, count = 0, W[1000], H[1000];
  while (1 == 1) {
    scanf("%d%d", &H, &W);
    if (W == 0 && H == 0) {
      break;
    }
  }
  for (j = 0; j < H[i]; j++) {
    for (k = 0; k < W[i]; k++) {
      if (j == 0 || j == H[i] - 1) {
        printf("#");
      } else {
        (k == 0 || k == W[i] - 1) ? printf("#") : printf(".");
      }
    }
    printf("\\n");
  }
  printf("\\n");
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <numeric>
#include <stdio.h>
using namespace std;
int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) {
      return 0;
    }
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <numeric>
#include <stdio.h>
using namespace std;
int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h = 0 && w == 0) {
      break;
    }
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

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

    {
      cout << "#";
      for (int j = 0; j < (W - 2); j++) {
        cout << ".";
      }
      cout << "#";
      cout << endl;
    }

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

    {
      cout << "#";
      for (int j = 0; j < (W - 2); j++) {
        cout << ".";
      }
      cout << "#";
    }
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
  }
  return 0;
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

void frm(int H, int W) {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
        cout << '#';
      } else {
        cout << '.';
      }
    }
    cout << endl;
  }
}

int main() {
  int H, W;

  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      return 0;

    frm(H, W);
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

void frm(int W, int H) {
  for (int i = 0; i < H; i++) {
    if (i == 0 || i == H - 1) {
      for (int j = 0; j < W; j++)
        cout << "#";
      cout << endl;
    } else {
      cout << "#";
      for (int j = 1; j < W - 1; j++)
        cout << " ";
      cout << "#" << endl;
    }
  }
  cout << endl;
}

int main() {
  int H, W;

  while (1) {
    cin >> H >> W;
    frm(H, W);
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int a[100], b[100], i = 0;
  do {
    scanf("%d %d", &a[i], &b[i]);
    i++;
  } while (a[i - 1] != 0 || b[i - 1] != 0);
  for (int x = 0; x < i - 1; x++) {
    for (int y = 0; y < a[x]; y++) {
      if (y == 0 || y == a[x] - 1) {
        for (int z = 0; z < b[x]; z++) {
          printf("#");
        }
      } else {
        for (int z = 0; z < b[x]; z++) {
          if (z == 0 || z == b[x] - 1)
            printf("#");
          else
            printf(".");
        }
      }
      printf("\\n");
    }
    printf("\\n");
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a[100], b[100], i = 0;
  do {
    scanf("%d %d", &a[i], &b[i]);
    i++;
  } while (a[i] != 0 || b[i] != 0);
  for (int x = 0; x < i; x++) {
    for (int y = 0; y < a[x]; y++) {
      if (y == 0 || y == a[x] - 1) {
        for (int z = 0; z < b[x]; z++) {
          printf("#");
        }
      } else {
        for (int z = 0; z < b[x]; z++) {
          if (z == 0 || z == b[x] - 1)
            printf("#");
        }
      }
      printf("\\n");
    }
    printf("\\n");
  }
}
Problem p02404 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H - 2; i++) {
      cout << "#";
      for (int i = 0; i < W - 2; i++) {
        cout << ".";
      }
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl << endl;
  }
  return 0;
}
Problem p02405 (C++) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int h, w;
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    for (int i = 1; i <= h; h++) {
      if (i % 2 == 0) {
        for (int j = 1; j <= w; j++) {
          if (j % 2 == 0) {
            cout << "#";
          } else {
            cout << ".";
          }
        }
      } else {
        for (int j = 1; j <= w; j++) {
          if (j % 3 == 0) {
            cout << "#";
          } else {
            cout << ".";
          }
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}