TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
N = int(input())
ans = 0
for i in range(1,N+1,2):
    cnt = 0
    for n in range(1,N+1,2):
        if n%i == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)

,w=input().split()
a=[list(input()) for i in range(int(h))]

l1=[i for i in a if '#' in i]
l2=[i for i in zip(*l1) if '#' in i]
for i in zip(*l2):
    print(''.join(i))

h,w=map(int,input().split())
for i in zip(*[i for i in zip(*[i for i in [input() for i in range(h)] if '#' in i]) if '#' in i]):
  print(''.join(i))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
import numpy as np

H, W=map(int, input().split())
matrix=np.zeros((H, W))

for i in range(H):
  s=input()
  for j in range(W):
    if s[j]=='#':
      matrix[i, j]=1
      
for i in range(H):
  if np.sum(matrix[i, :]==0)==W:
    matrix[i, :]=-1
    
for i in range(W):
  if np.sum(matrix[:, i]==0)==H:
    matrix[:, i]=-1
    
i=0
for i in range(H):
  if np.sum(matrix[i, :]==-1)==W:
    pass
  else:
    for j in range(W):
      if matrix[i, j]==0:
        print('.', end='')
      elif matrix[i, j]==1:
        print('#', end='')
      else:
        pass
    print('\n', end='')

import numpy as np
 
H, W=map(int, input().split())
matrix=np.zeros((H, W))
 
for i in range(H):
  s=input()
  for j in range(W):
    if s[j]=='#':
      matrix[i, j]=1
      
for i in range(H):
  if np.sum(matrix[i, :]==0)==W:
    matrix[i, :]=-1
    
for i in range(W):
  if np.sum(matrix[:, i]<=0)==H:
    matrix[:, i]=-1
    
i=0
for i in range(H):
  if np.sum(matrix[i, :]==-1)==W:
    pass
  else:
    for j in range(W):
      if matrix[i, j]==0:
        print('.', end='')
      elif matrix[i, j]==1:
        print('#', end='')
      else:
        pass
    print()

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H, W = map(int, input().split())

a = [input() for i in range(H)]

row = [False] * H
col = [False] * W

for i in range(H):
  for j in range(W):
    if a[i][j] == '#':
      row[i] = True
      col[j] = True

      
for i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        print(a[i][j], end='')
 

H, W = map(int, input().split())

a = [input() for i in range(H)]

row = [False] * H
col = [False] * W

for i in range(H):
  for j in range(W):
    if a[i][j] == '#':
      row[i] = True
      col[j] = True

      
for i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        print(a[i][j], end='')
    print()
 

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H, W = [int(x) for x in input().split()]
A = [input().strip() for _ in range(H)]

B = []
for i in range(H):
    if "#" in A[i]:
        B.append(A[i])

ans = []
for j in range(W):
    for i in range(len(B)):
        if "#" ==  B[i][j]:
            ans.append(j)
            break

for i in range(len(B)):
    for j in range(len(ans)):
        print(B[i][j], end="")
    print()






H, W = [int(x) for x in input().split()]
A = [input().strip() for _ in range(H)]

B = []
for i in range(H):
    if "#" in A[i]:
        B.append(A[i])

ans = []
for j in range(W):
    for i in range(len(B)):
        if "#" ==  B[i][j]:
            ans.append(j)
            break

for i in range(len(B)):
    for j in ans:
        print(B[i][j], end="")
    print()






Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h,w = map(int,input().split())
maze = []
for _ in range(h):
  s = input()
  if s != '.'*w:
    maze.append(s)
h = len(maze)
skip = []
for j in range(w):
  for i in raneg(h):
    if maze[i][j] == '#':
      break
  else:
    skip.append(j)

for i in range(h):
  for j in range(w):
    if j not in skip:
      print(maze[i][j],end= '')
  print()

h,w = map(int,input().split())
maze = []
for _ in range(h):
  s = input()
  if s != '.'*w:
    maze.append(s)
h = len(maze)
skip = []
for j in range(w):
  for i in range(h):
    if maze[i][j] == '#':
      break
  else:
    skip.append(j)

for i in range(h):
  for j in range(w):
    if j not in skip:
      print(maze[i][j],end= '')
  print()



Verdicts: Runtime Error

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
import numpy as np

h, w = map(int,input().split())
grid = np.array([list(input()) for _ in range(h)], dtype="U1") 

row = []
col = []

for i in range(h):
    if (grid[i] != ".").any():
        row.append(i)

trans_grid = np.transpose(grid)

for i in range(w):
    if (trans_grid != ".").any():
        col.append(i)

G = grid[row][:,col] 

for g in G:
    print("".join(g))

import numpy as np

h, w = map(int,input().split())
grid = np.array([list(input()) for _ in range(h)], dtype="U1") 

row = []
col = []

for i in range(h):
    if (grid[i] != ".").any():
        row.append(i)

trans_grid = np.transpose(grid)

for i in range(w):
    if (trans_grid[i] != ".").any():
        col.append(i)

G = grid[row][:,col] 

for g in G:
    print("".join(g))

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
import numpy as np
import math


H, W = map(int, input().split())

A = np.zeros((H, W), dtype=int)

for h in range(H):
    ah = input()
    for w in range(W):
        if ah[w] == '.':
            A[h][w] = 0
        else:
            A[h][w] = 1

# print(A)
remH = []
remW = []
            
for h in range(H):
    if all(A[h] == 0):
        remH.append(h)
for w in range(W):
    if all(A[:,w] == 0):
        remW.append(w)

# print(remH, remW)
        
ret = []

for h in range(H):
    if h in remH:
        continue
    hlist = []
    for w in range(W):
        if w in remW:
            continue
        # print(h)
        # print(w)
        # print(A[h][w])
        hlist.append(A[h][w])
    ret.append(hlist)

# print(ret)

retH = H - len(remH)
retW = W - len(remW)

print(retH, retW)
for x in range(retH):
    for y in range(retW):
        if ret[x][y] == 0:
            print('.', end='')
        else:
            print('#', end='')            
    print()


import numpy as np
import math


H, W = map(int, input().split())

A = np.zeros((H, W), dtype=int)

for h in range(H):
    ah = input()
    for w in range(W):
        if ah[w] == '.':
            A[h][w] = 0
        else:
            A[h][w] = 1

# print(A)
remH = []
remW = []
            
for h in range(H):
    if all(A[h] == 0):
        remH.append(h)
for w in range(W):
    if all(A[:,w] == 0):
        remW.append(w)

# print(remH, remW)
        
ret = []

for h in range(H):
    if h in remH:
        continue
    hlist = []
    for w in range(W):
        if w in remW:
            continue
        # print(h)
        # print(w)
        # print(A[h][w])
        hlist.append(A[h][w])
    ret.append(hlist)

# print(ret)

retH = H - len(remH)
retW = W - len(remW)

# print(retH, retW)
for x in range(retH):
    for y in range(retW):
        if ret[x][y] == 0:
            print('.', end='')
        else:
            print('#', end='')            
    print()


Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H,W = map(int, input().split())
map =[]
for _ in range(H):
     a = list(input())
     map.append([int(x !='.') for x in a ])
memo = []
for i in range(H):
    if sum(map[i]) == 0:
        memo.append(i)
while memo:
    del map[memo[-1]]
    del memo[-1]
    H -= 1
for j in range(W):
    color = [map[x][j] for x in range(H)]
    if sum(color) == 0:
        memo.append(j)
while memo:
    for k in range(H):
        del map[k][memo[-1]]
    del memo[-1]
    W = -1
for j in map:
    a = ["." if ab == 0 else "#" for ab in j]
    print(*a)

H,W = map(int, input().split())
map =[]
for _ in range(H):
     a = list(input())
     map.append([int(x !='.') for x in a ])
memo = []
for i in range(H):
    if sum(map[i]) == 0:
        memo.append(i)
while memo:
    del map[memo[-1]]
    del memo[-1]
    H -= 1
for j in range(W):
    color = [map[x][j] for x in range(H)]
    if sum(color) == 0:
        memo.append(j)
while memo:
    for k in range(H):
        del map[k][memo[-1]]
    del memo[-1]
    W = -1
for j in map:
    a = ["." if ab == 0 else "#" for ab in j]
    print("".join(a))

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h,w= map(int,input().split())
l = list()
m = 0
for i in range(h):
  c = input()
  if "#" in c:
    b = [ w for w in range(len(c)) if c[w] == "#" ]
    l.append(b)
    if m < max(b) : m = max(b)
p = list()
for i in range(m) :
  for j in l:
    if i in j: break
  else:
    p.append(i)
for j in range(len(l)):
  for e in range(len(l[j])):
    cnt = 0
    for q in p:
      if l[j][e] > q : cnt += 1
    l[j][e]  = l[j][e]  - cnt
print(l)
m = 0
for i in l:
  if m < max(i) : m = max(i)
for i in l:
  t = ""
  for j in range(m+1):
    if j in i : t = t + "#"
    else: t = t + "."
  print(t)

h,w= map(int,input().split())
l = list()
m = 0
for i in range(h):
  c = input()
  if "#" in c:
    b = [ w for w in range(len(c)) if c[w] == "#" ]
    l.append(b)
    if m < max(b) : m = max(b)
p = list()
for i in range(m) :
  for j in l:
    if i in j: break
  else:
    p.append(i)
for j in range(len(l)):
  for e in range(len(l[j])):
    cnt = 0
    for q in p:
      if l[j][e] > q : cnt += 1
    l[j][e]  = l[j][e]  - cnt
m = 0
for i in l:
  if m < max(i) : m = max(i)
for i in l:
  t = ""
  for j in range(m+1):
    if j in i : t = t + "#"
    else: t = t + "."
  print(t)

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
import numpy as np
H, W = map(int, input().split())
a = []
for i in range(H):
    a_l = input()
    a.append([c for c in a_l])


for i in range(H):
    for j in range(W):
        if a[i][j] == '.':
            a[i][j] = 1
        elif a[i][j] == '#':
            a[i][j] = 0
        else:
            pass
a = np.array(a)
v = []
h = []
for i in range(H):
    if np.sum(a[i,:]) == 0 or np.sum(a[i,:]) == W:
        h.append(i)
for j in range(W):
    if np.sum(a[:,j]) == 0 or np.sum(a[:,j]) == H:
        v.append(j)

a_del = np.delete(np.delete(a, v, 1), h, 0)
a_del = list(a_del)

for i in range(len(a_del)):
    for j in range(len(a_del[i])):
        if a_del[i][j] == 1:
            print('.', end='')
        elif a_del[i][j] == 0:
            print('#', end='')
    print('\n')


import numpy as np
H, W = map(int, input().split())
a = []
for i in range(H):
    a_l = input()
    a.append([c for c in a_l])


for i in range(H):
    for j in range(W):
        if a[i][j] == '.':
            a[i][j] = 1
        elif a[i][j] == '#':
            a[i][j] = 0
        else:
            pass
a = np.array(a)
v = []
h = []
for i in range(H):
    if np.sum(a[i,:]) == W:
        h.append(i)
for j in range(W):
    if np.sum(a[:,j]) == H:
        v.append(j)

a_del = np.delete(np.delete(a, v, 1), h, 0)
a_del = list(a_del)

for i in range(len(a_del)):
    for j in range(len(a_del[i])):
        if a_del[i][j] == 1:
            print('.', end='')
        elif a_del[i][j] == 0:
            print('#', end='')
    print('')

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
import numpy as np
h, w = map(int, input().split())
field = []
for _ in range(h):
    row = list(input())
    field.append(row)
field = np.array(field)


deleterow = []
deleteline = []
for i in range(field.shape[0]):
    if len(set(field[i,:]))==1:
        deleterow.append(i)
for j in range(field.shape[1]):
    if len(set(field[:,j]))==1:
        deleteline.append(j)

for i, row in enumerate(field):
    if i in deleterow:
        continue
    for j, val in enumerate(row):
        if j in deleteline:
            continue
        print(val, end='')
    print('\n')

import numpy as np
h, w = map(int, input().split())
field = []
for _ in range(h):
    row = list(input())
    field.append(row)
field = np.array(field)


deleterow = []
deleteline = []
for i in range(field.shape[0]):
    if set(field[i,:])=={'.'}:
        deleterow.append(i)
for j in range(field.shape[1]):
    if set(field[:,j])=={'.'}:
        deleteline.append(j)

for i, row in enumerate(field):
    if i in deleterow:
        continue
    for j, val in enumerate(row):
        if j in deleteline:
            continue
        print(val, end='')
    print('')

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]
for i in range(H):
    for j in range(W):
        print(a[i][j], end='')
    print('')
cntH = 0
for i in range(H-1, 0, -1):
    flag = True
    for j in range(W):
        if a[i][j] == '#':
            flag = False
            break
    if flag:
        a.pop(i)
        cntH+=1

for j in range(W-1, 0, -1):
    flag = True
    for i in range(H-cntH):
        if a[i][j] == '#':
            flag = False
    if(flag):
        for i in range(H-cntH):
            a[i].pop(j)

for i in range(H-cntH):
    for j in range(len(a[i])):
        print(a[i][j], end='')
    print('')

H, W = map(int, input().split())
a = [list(input()) for i in range(H)]

cntH = 0
for i in range(H-1, -1, -1):
    flag = True
    for j in range(W):
        if a[i][j] == '#':
            flag = False
            break
    if flag:
        a.pop(i)
        cntH+=1

for j in range(W-1, -1, -1):
    flag = True
    for i in range(H-cntH):
        if a[i][j] == '#':
            flag = False
    if(flag):
        for i in range(H-cntH):
            a[i].pop(j)

for i in range(H-cntH):
    for j in range(len(a[i])):
        print(a[i][j], end='')
    print('')

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h,w = map(int,input().split())
a = [[i for i in input()] for _ in range(h)]
b = [x for in a if "#" in x]
c = zip(*[x for x in zip(*b) if "#"in x])
for d in c:
    print("".join(d))

h,w = map(int,input().split())
a = [[i for i in input()] for _ in range(h)]
b = [x for x in a if "#" in x]
c = zip(*[x for x in zip(*b) if "#"in x])
for d in c:
    print("".join(d))

Verdicts: Runtime Error

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h,w=map(int,input().split())
a=[]
for i in range(h):
  tmp=input()
  if len(tmp)!=tmp.count('.'):
    a.append(tmp)
  else:
    h-=1
    
a=list(zip(*a))
for i in range(w):
  if len(a[i])==a[i].count('.'):
    del a[i]
    w-=1
    i-=1
    
a=list(zip(*a))
for i in range(h):
  print(a[i])
      


h,w=map(int,input().split())
a=[]
for i in range(h):
  tmp=input()
  if len(tmp)!=tmp.count('.'):
    a.append(tmp)
  else:
    h-=1

b=[]
for i in range(w):
  cnt=0
  for j in range(h):
    if a[j][i]=='.':
      cnt+=1
  if cnt==h:
    b.append(0)
  else:
    b.append(1)

for i in range(h):
  for j in range(w):
    if b[j]:
      print(a[i][j], end='')
  print()
      

Verdicts: Runtime Error

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h, w = map(int, input().split())
a = ['']*h
for i in range(h):
    a[i] = input()
    
row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = ' ')

h, w = map(int, input().split())
l = []
for i in range(h):
  a = str(input())
  if a == '.'*w:
    continue
  l.append(a)

skip = []
for i in range(w):
  for j in range(len(l)):
    if l[j][i] == '#':
      break
  else:
    skip.append(i)

skip = set(skip)
l_ = [0]*len(l)
for i in range(len(l)):
  temp = ''
  for j in range(w):
    if j not in skip:
      temp += l[i][j]
  l_[i] = temp
  
for i in range(len(l_)):
  print(l_[i])

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            raw[i]=True
            col[j]=True;

for i in range(h):
    if raw[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()


h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            raw[i]=true
            col[j]=true;

for i in range(h):
    if raw[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()


h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            raw[i]=True
            col[j]=True;

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()


h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=True
            col[j]=True;

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h,w = [int(i) for i in input().split(' ')]
a = [list(input()) for i in range(h)]


b = [i for i in a if not i.count('.') == w]
for i in b:
    print(''.join(i))

h2 = len(b)
w2 = len(b[0])
ret = []
for i in range(w2):
    for x in range(h2):
        if b[x][i] == '#':
            ax = [b[xx][i] for xx in range(h2)]
            ret += [ax]
            break
    else:
        continue

for i in range(len(ret[0])):
    print(''.join([ret[x][i] for x in range(len(ret))]))


h,w = [int(i) for i in input().split(' ')]
a = [list(input()) for i in range(h)]


b = [i for i in a if not i.count('.') == w]

h2 = len(b)
w2 = len(b[0])
ret = []
for i in range(w2):
    for x in range(h2):
        if b[x][i] == '#':
            ax = [b[xx][i] for xx in range(h2)]
            ret += [ax]
            break
    else:
        continue

for i in range(len(ret[0])):
    print(''.join([ret[x][i] for x in range(len(ret))]))


Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
l = [int(i) for i in input().split()]
print(l[0]-l[1]+1)

h,w = map(int,input().split())

m = []

for i in range(h):
    m.append(list(input()))



dl = []

for i in range(h):
    if all(j =='_' for j in m[i]):
        dl.append(int(i))

for i in dl:
    del m[i]



m = list(zip(*m)) 

dl = []
for i in range(w):
    if all(j =='_' for j in m[i]):
        dl.append(int(i))

for i in dl:
    del m[i]



m = list(zip(*m))



for i in range(len(m)):
    m[i] = ''.join(m[i])
    print(m[i])

h,w = map(int,input().split())

m = []

for i in range(h):
    m.append(list(input()))



dl = []

for i in range(h):
    if all(j =='_' for j in m[i]):
        dl.append(int(i))

if dl:
    for i in range(len(dl)):
        del m[dl[len(dl)-i-1]]



m = list(zip(*m)) 
if m:
    dl = []
    for i in range(w):
        if all(j =='_' for j in m[i]):
            dl.append(int(i))

    if dl:
        for i in range(len(dl)):
            del m[dl[len(dl)-i-1]]
            



m = list(zip(*m))



for i in range(len(m)):
    m[i] = ''.join(m[i])
    print(m[i])

h,w = map(int,input().split())
m = []

for i in range(h):
    m.append(list(input()))



dl = []

for i in range(h):
    if all(j =='.' for j in m[i]):
        dl.append(int(i))
# print(dl)
if dl:
    for i in dl:
        del m[i-dl.index(i)]
h = len(m)
# print(m)

dl = []
for i in range(w):
    s = ''
    for j in range(h):
        s = s + m[j][i]
    if all(j == '.' for j in list(s)):
        dl.append(int(i))
# print(dl)
if dl:
    for i in range(h):
        for j in dl:
            del m[i][j-dl.index(j)]

# print(m)
for i in range(h):
    print(''.join(m[i]))


# m = list(zip(*m)) 
# if m:
#     dl = []

#         if all(j =='.' for j in m[i]):
#             dl.append(int(i))




            



# m = list(zip(*m))




#     m[i] = ''.join(m[i])
#     print(m[i])

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H,W=map(int,input().split())
A=[list(input())for i in range(H)]
ww=set()
hh=set()
for h in range(H):
  for w in range(W):
    if A[h][w]=='#':
      ww.add(w)
      hh.add(h)
print(ww,hh)
ww=sorted(list(ww))
for h in sorted(list(hh)):
  _=''
  for w in ww:
    _+=A[h][w]
  print(_)

H,W=map(int,input().split())
A=[list(input())for i in range(H)]
ww=set()
hh=set()
for h in range(H):
  for w in range(W):
    if A[h][w]=='#':
      ww.add(w)
      hh.add(h)
ww=sorted(list(ww))
for h in sorted(list(hh)):
  _=''
  for w in ww:
    _+=A[h][w]
  print(_)

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
import math


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
print(a)
for i in range(h):
    a[i] = str(input())
print(a)
x = [None]*h
y = [None]*w
print(x)
print(y)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            x[i] = True
            y[j] = True
print(x)
print(y)
for i in range(h):
    if x[i] == True:
        for j in range(w):
            if y[j] == True:
                print(a[i][j], end="")
        print()


import math


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
print(a)
for i in range(h):
    a[i] = input()
print(a)
x = [None]*h
y = [None]*w
print(x)
print(y)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            x[i] = True
            y[j] = True
print(x)
print(y)
for i in range(h):
    if x[i] == True:
        for j in range(w):
            if y[j] == True:
                print(a[i][j], end="")
        print()


import math


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
# print(a)
for i in range(h):
    a[i] = input()
# print(a)
x = [None]*h
y = [None]*w
# print(x)
# print(y)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            x[i] = True
            y[j] = True
# print(x)
# print(y)
for i in range(h):
    if x[i] == True:
        for j in range(w):
            if y[j] == True:
                print(a[i][j], end="")
        print()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
HW = input()
masu = "none"
hw = HW.split()

Adata = []
for lop in range(int(hw[0])):
    A = input()
    Adata.append(A)

x = []
y = []
buf = ""
for lop in range(int(hw[0])):
    if str(Adata[lop]).find(".") == -1 or str(Adata[lop]).find("#") == -1:
      x.append(lop)
      
for lop in range(int(hw[1])):
    for lop2 in range(int(hw[0])):
        buf = buf + str(Adata[lop2][lop])
    if str(buf).find(".") == -1:
        y.append(lop)
    buf = ""

for lop in range(len(x)-1,-1,-1):
    Adata.pop(x[lop])


ans = []
for lop in range(len(Adata)):
    buf = list(Adata[lop])
    for lop2 in range(len(y)-1,-1,-1):
        buf.pop(y[lop2])
    ans.append(buf)

for lop in range(len(ans)):
    ANS = ""
    for lop2 in range(len(ans[0])):
        ANS += ans[lop][lop2]
    print(ANS)


HW = input()
masu = "none"
hw = HW.split()

Adata = []
for lop in range(int(hw[0])):
    A = input()
    Adata.append(A)

x = []
y = []
buf = ""
for lop in range(int(hw[0])):
    if str(Adata[lop]).find("#") == -1:
      x.append(lop)
      
for lop in range(int(hw[1])):
    for lop2 in range(int(hw[0])):
        buf = buf + str(Adata[lop2][lop])
    if str(buf).find("#") == -1:
        y.append(lop)
    buf = ""

for lop in range(len(x)-1,-1,-1):
    Adata.pop(x[lop])


ans = []
for lop in range(len(Adata)):
    buf = list(Adata[lop])
    for lop2 in range(len(y)-1,-1,-1):
        buf.pop(y[lop2])
    ans.append(buf)

for lop in range(len(ans)):
    ANS = ""
    for lop2 in range(len(ans[0])):
        ANS += ans[lop][lop2]
    print(ANS)


Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
ans_w = []
ans_h = []
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      break
  else:
    ans_h.append(i)
for j in range(w):
  for i in range(h):
    if a[i][j] == "#":
      break
  else:
    ans_w.append(j)

for i in ans_h:
  print(*[a[i][j] for j in ans_w], sep="")

h, w = map(int, input().split())
a = [input() for _ in range(h)]
ans_w = []
ans_h = []
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      ans_h.append(i)
      break
for j in range(w):
  for i in range(h):
    if a[i][j] == "#":
      ans_w.append(j)
      break
for i in ans_h:
  print(*[a[i][j] for j in ans_w], sep="")

Verdicts: Wrong Answer

Accepted
Problem: There is a grid of squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Each square is black or white. The color of the square is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j) is white; if a_{i, j} is `#`, the square (i, j) is black.  Snuke is compressing this grid. He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.  It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation. Find the final state of the grid.

Submission attempts (in order):
H,W=map(int,input().split())
a=[list(map(str, input())) for _ in range(H)]

c=[]
for li in a:
    print(li)
    if li!=['.']*len(li):
        c.append(li)

b=[]
for lc in zip(*c):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))






H,W=map(int,input().split())
a=[list(map(str, input())) for _ in range(H)]

c=[]
for li in a:
    if li!=['.']*len(li):
        c.append(li)

b=[]
for lc in zip(*c):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))






Verdicts: Wrong Answer

Accepted