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):
h,w=map(int,input().split())
a=[input() for i in range(h)]

print(a)

for j in a:
  if '#' not in j:
    a.remove(j)
    h-=1
    
print(a)
   
b=[]

for k in range(w):
  c=''
  for l in range(h):
    c+=a[l][k]
  b.append(c)

for m in b:
  if '#' not in m:
    b.remove(m)
    w-=1
    
print(b)

for o in range(h):
  d=''
  for p in range(w):
    d+=b[p][o]
    print(d)

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

print(a)
print(h)
print(w)

for j in a:
  if '#' not in j:
    a.remove(j)
    h-=1
    
print(a)
print(h)
print(w)
   
b=[]

for k in range(w):
  c=''
  for l in range(h):
    c+=a[l][k]
  b.append(c)

print(b)
print(h)
print(w)
  
for m in b:
  if '#' not in m:
    b.remove(m)
    w-=1
    
print(b)
print(h)
print(w)

for o in range(h):
  d=''
  for p in range(w):
    d+=b[p][o]
  print(d)

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

for j in a:
  if '#' not in a:
    a.pop(j)
    h-=1
    
b=[]
c=''

for k in range(w):
  for l in range(h):
    c+=a[l][k]
  b.append(c)

for m in range(w):
  if '#' not in b:
    b.pop(m)
    w-=1
    
d=''

for o in range(h):
  for p in range(w):
    d+=b[p][o]
    print(d)
   

H, W = map(int, input().split())
a = []
for _ in range(H):
    i = list(input())
    if '#' in i:
        a.append(i)
ans = zip(*[i for i in zip(*a) if '#' in i])
for s in ans:
    print(*s, sep='')
#copy code

Verdicts: Wrong Answer

Wrong Answer

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())
s=[list(input())for i in range(h)]
l=[x for x in s if '#' in x]
ans=[]
for i in zip(*l):
  if '#' in i:ans.append(i)
for x in ans:
  print(''.join(x))

h,w=map(int,input().split())
s=[list(input())for i in range(h)]
l=[x for x in s if '#' in x]
ans=[]
for i in zip(*l):
  if '#' in i:ans.append(i)
an=zip(*ans)
for x in an:
  print(''.join(x))

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=[[0 for _ in range(h)] for _ in range(w)]
ans=[]
print(a)
for i in range(h):
    b=list(input())
    if '#'  in b:
        for j in range(w):
            a[j][i]=b[j]

    #print(a[i])
c=0
for i in range(0-c,w-c):
    if '#' not in a[i]:
        for j in range(h):
            a[i][j]=0
for i in range(h):
    for j in range(w):
        if a[j][i]!=0:
            print(a[j][i],end="")
            c+=1
    if c!=0:
        print()
    c=0



h,w=map(int,input().split())
a=[[0 for _ in range(h)] for _ in range(w)]
ans=[]
#print(a)
for i in range(h):
    b=list(input())
    if '#'  in b:
        for j in range(w):
            a[j][i]=b[j]

    #print(a[i])
c=0
for i in range(0-c,w-c):
    if '#' not in a[i]:
        for j in range(h):
            a[i][j]=0
for i in range(h):
    for j in range(w):
        if a[j][i]!=0:
            print(a[j][i],end="")
            c+=1
    if c!=0:
        print()
    c=0


                
        

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)]
row = [False] * H
col = [False] * W
for i in range(len(row)):
  for j in range(len(col)):
    if a[i][j] == '#':
      row[i] = col[j] = True

for i in range(len(row)):
  if row[i]:
    for j in range(len(col)):
      if col[j]:
        print(a[i][j], '')
    print()

H, W = map(int, input().split())
a = [input() for _ in range(H)]
row = [False] * H
col = [False] * W
for i in range(len(row)):
  for j in range(len(col)):
    if a[i][j] == '#':
      row[i] = col[j] = True

for i in range(len(row)):
  if row[i]:
    for j in range(len(col)):
      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 = map(int,input().split())
Data1 = []

for _ in range(H):
    Data1.append(s)

hdata = {}
wdata = {}

for h in range(H):
    for w in range(W):
        if Data1[h][w] == '#':
            hdata.add(h)
            wdata.add(w)

for h in range(H):
    for w in range(W):
        if h in hdata or w in wdata:
            print(Data[h][w],end='')

H,W = map(int,input().split())
Data = []

for _ in range(H):
    Data.append(input())

hdata = set()
wdata = set()

for h in range(H):
    for w in range(W):
        if Data[h][w] == '#':
            hdata.add(h)
            wdata.add(w)

for h in range(H):
    output = False
    for w in range(W):
        if h in hdata and w in wdata:
            print(Data[h][w],end='')
            output = True
    if output:
        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())
f = [input() for _ in range(H)]
while True:
  flag = False
  for y in range(H):
    if '#' not in f[y]:
      del f[y]
      H -= 1
      flag = True
      break
  for x in range(W):
    for y in range(H):
      if f[y][x] == '#':
        break
    for y in range(H):
      del f[x][y]
    flag = True
    break
  if not flag:
    break

for i in range(H):
  print(f[i])
	

H, W = map(int, input().split())
f = [list(input()) for _ in range(H)]
Y, X = [False for _ in range(H)], [False for _ in range(W)]
for y in range(H):
    for x in range(W):
        Y[y] |= f[y][x] == '#'
        X[x] |= f[y][x] == '#'
for y in range(H):
    flag = False
    for x in range(W):
        if Y[y] and X[x]:
            print(f[y][x], end = "")
            flag = True
    if flag:
        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())
a=np.zeros((H,W))
for i in range(H):
    tmp = input()
    for j in range(W):
        if tmp[j] == "#":
            a[i][j]=1

tmp=[]
for i in range(H):
    if np.sum(a[i])==0:
        tmp.append(i)
a = np.delete(a,tmp,0)

h=len(tmp)

a = a.T

tmp=[]
for i in range(W):
    if np.sum(a[i])==0:
        tmp.append(i)
a = np.delete(a,tmp,0)
               
a = a.T

w = len(tmp)

ans = list(a)

print(a)
for i in range(H-h):
    tmp=a[i]
    for j in range(W-w):
        if tmp[j] == 1:
            print("#", end="")
        else:
            print(".", end="")
    print()


import numpy as np

H,W=map(int,input().split())
a=np.zeros((H,W))
for i in range(H):
    tmp = input()
    for j in range(W):
        if tmp[j] == "#":
            a[i][j]=1

tmp=[]
for i in range(H):
    if np.sum(a[i])==0:
        tmp.append(i)
a = np.delete(a,tmp,0)

h=len(tmp)

a = a.T

tmp=[]
for i in range(W):
    if np.sum(a[i])==0:
        tmp.append(i)
a = np.delete(a,tmp,0)
               
a = a.T

w = len(tmp)

ans = list(a)

for i in range(H-h):
    tmp=a[i]
    for j in range(W-w):
        if tmp[j] == 1:
            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())

matrix = []

for i in range(h):
  row = list(input())
  if '#' not in row:
    continue
  else:
    matrix.append(row)

print(matrix)
removed_index = []

for i in range(len(matrix[0])):
  col = [row[i] for row in matrix]
  if '#' not in col:
    removed_index.append(i)

removed_index.reverse()

for n in removed_index:
  for row in matrix:
  	del row[n]

for row in matrix:
  print(''.join(row))


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

matrix = []

for i in range(h):
  row = list(input())
  if '#' not in row:
    continue
  else:
    matrix.append(row)

print(matrix)
removed_index = []

for i in range(len(matrix[0])):
  col = [row[i] for row in matrix]
  if '#' not in col:
    removed_index.append(i)

removed_index.reverse()

for n in removed_index:
  for row in matrix:
  	del row[n]

for row in matrix:
  print(' '.join(row))


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

matrix = []

for i in range(h):
  row = list(input())
  if '#' not in row:
    continue
  else:
    matrix.append(row)

removed_index = []

for i in range(len(matrix[0])):
  col = [row[i] for row in matrix]
  if '#' not in col:
    removed_index.append(i)

removed_index.reverse()

for n in removed_index:
  for row in matrix:
  	del row[n]

for row in matrix:
  print(''.join(row))


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):
h,w = map(int, input().split())
a = [(_ for _ in input()) for i in range(h)]
b = [x for x in a if '#' in x]
c = zip(*[y for y in zip(*b) if '#' in y])

for d in c:
  print(''.join(d))

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

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)]
res = [0 for i in range(W)]
for i in range(W):
  for j in range(H):
    if a[j][i] != ".":
      break
    res[i] += 1
for i in range(H):
  for j in range(W):
    if res[j] != H:
      print(a[i][j],end="")
  print("")

H, W = map(int, input().split())
a = [input() for i in range(H)]
res = [0 for i in range(W)]
for i in range(W):
  for j in range(H):
    if a[j][i] != ".":
      break
    res[i] += 1
for i in range(H):
  if a[i][0:].count("#") >0:
    for j in range(W):
      if res[j] != H:
        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=[]
for i in range(h):
  aa=list(input())
  if "#" not in aa:
    continue
  else:
    a.append(aa)
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=="#":
      c+=1
  if c==0:
    for j in range(len(a)):
      del a[j][i]
for i in range(len(a)):
  print("".join(a[i]))

h,w=map(int,input().split())
a=[]
for i in range(h):
  aa=list(input())
  if "#" not in aa:
    continue
  else:
    a.append(aa)
aa=[]
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=="#":
      c+=1
  if c==0:
    aa.append(i)
aa.reverse()
for i in aa:
  for j in range(len(a)):
    del a[j][i]
for i in range(len(a)):
  print("".join(a[i]))


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())
grid = []
for i in range(H):
  line = input()
  for i in range(len(line)):
    if line[i] == '#':
      grid.append(line)
      break
gridans = [[''] for i in range(len(grid))]
for i in range(W):
  flag = 0
  for j in range(len(grid)):
    if grid[j][i] == '#':
      flag = 1
  if flag == 1:
    for j in range(len(grid)):
      gridans[j] += grid[j][i]
for i in range(len(gridans)):
  print(gridans[i])


H, W = map(int, input().split())
grid = []
for i in range(H):
  line = input()
  for i in range(len(line)):
    if line[i] == '#':
      grid.append(line)
      break
gridans = [[''] for i in range(len(grid))]
for i in range(W):
  flag = 0
  for j in range(len(grid)):
    if grid[j][i] == '#':
      flag = 1
  if flag == 1:
    for j in range(len(grid)):
      gridans[j][0] += grid[j][i]
for i in range(len(gridans)):
  print(gridans[i][0])


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(" "))

def whitel(gyo):
    ans=0
    for i in range(len(gyo)):
        if gyo[i]=="#":
            ans=1
            break
    return ans

A=[]
for i in range(H):
    gyo=input()
    if whitel(gyo)==1:
        A.append(gyo)

for i in range(len(A)):
    print(A[i])

import numpy as np
H,W=map(int,input().split(" "))

def white(a):
    ans=0
    for i in range(len(a)):
        if a[i]=="#":
            ans=1
    return ans

A=[]
for i in range(H):
    gyo=list(input())
    if white(gyo)==1:
        A.append(gyo)

Anum=np.array(A)
ash=Anum.shape[1]
for i in range(ash):
    j=ash-i-1
    if white(Anum[:,j])==0:
        Anum=np.delete(Anum,j,1)

for i in range(Anum.shape[0]):
    moji=""
    for j in range(Anum.shape[1]):
        moji+=Anum[i,j]        
    print(moji)


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=mamp(int,input().split())
bd=[]

for i in range(H):
        bd.append(input())

x=set()
y=set()

for i in range(H):
        for j in range(W):
                if bd[i][j]=="#":
                        x.add(j)
                        y.add(i)
for i in y:
        for j in x:
                print(bd[i][j],end="")
        print()

H,W=map(int,input().split())
bd=[]

for i in range(H):
        bd.append(input())

x=set()
y=set()

for i in range(H):
        for j in range(W):
                if bd[i][j]=="#":
                        x.add(j)
                        y.add(i)
for i in y:
        for j in x:
                print(bd[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):
s = input().split()

h = int(s[0])
w = int(s[1])

for i in range(h):
    check = False
    v = input()
    x = list(v)
    for j in range(w):
        if x[j] == '#':
            check = True
            break
    if check:
        print(v)


s = input().split()

h = int(s[0])
w = int(s[1])

line = []
row = []

a = [''] * h

for i in range(h):
    a[i] = input()

for i in range(h):
    line.append(False)
for i in range(w):
    row.append(False)

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

for i in range(h):
    if line[i]:
        for j in range(w):
            if row[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 = map(int, input().split())

Hcnt = [0] * H
Wcnt = [0] * W

L = [list(input()) for _ in range(H)]

for i, s in enumerate(L):
  for j, c in enumerate(s):
    if c == "#":
      Hcnt[i] += 1
      Wcnt[j] += 1

for i, s in enumerate(L):
  p = ""
  for j, c in enumerate(s):
    if Hcnt[i] > 0 and Wcnt[j] > 0:
      p += " {}".format(c)
  if p:
    print(p[1:])


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

Hcnt = [0] * H
Wcnt = [0] * W

L = [list(input()) for _ in range(H)]

for i, s in enumerate(L):
  for j, c in enumerate(s):
    if c == "#":
      Hcnt[i] += 1
      Wcnt[j] += 1

for i, s in enumerate(L):
  if Hcnt[i] <= 0:
    continue
  for j, c in enumerate(s):
    if Wcnt[j] > 0:
      print(c, 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 = []
    for _ in range(h):
        l = input()
        if l != '.'*w:
            a.append(l)
    col = []
    h = len(a)
    for i in range(w):
        if a[0][i] == '.':
            for j in range(1,h):
                if a[j][i] != '.':
                    col.append(i)
                    break
        else:
            col.append(i)
    for l in a:
        ll = ''
        for i in col:
            ll += l[i]
        print(ll)

h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

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 = [int(x) for x in input().split()]
ans = []
for i in range(H):
  cnt= 0
  S = list(input())
  for j in range(W):
    if S[j]==".":
      cnt +=1
  if cnt!=W:
    ans.append(S)
ans1 = []
for j in range(len(ans[0])):
  cnt = 0
  for i in range(len(ans)):
    if ans[i][j]==".":
      cnt+=1
  if cnt ==len(ans):
    ans1.append(j)
for i in range(len(ans)):
  for j in ans1:
    ans[i][j]=0
for i in range(len(ans)):
  for j in range(len(ans[0])):
    if ans[i][j] !=0:
    	print(ans[i][j],end"")
  print()

H,W = [int(x) for x in input().split()]
ans = []
for i in range(H):
  cnt= 0
  S = list(input())
  for j in range(W):
    if S[j]==".":
      cnt +=1
  if cnt!=W:
    ans.append(S)
ans1 = []
for j in range(len(ans[0])):
  cnt = 0
  for i in range(len(ans)):
    if ans[i][j]==".":
      cnt+=1
  if cnt ==len(ans):
    ans1.append(j)
for i in range(len(ans)):
  for j in ans1:
    ans[i][j]=0
for i in range(len(ans)):
  for j in range(len(ans[0])):
    if ans[i][j] !=0:
    	print(ans[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):
def abc():
    h, w = map(int, input().split())
    lines = []
    for i in range(h):
        line = list(input().rstrip())
        if '#' in line:
            lines.append(line)

    for x in reversed(range(w)):
        if len([l for l in lines if l[x] == '#']) == 0:
            for l in lines:
                l.pop(x)
    for line in lines:
        print(''.join(line))

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: 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())
grid=[]
for _ in range(h):
    grid.append(list(input()))

row=[]
col=[]

for i in range(h):
    flg=0
    for j in range(w):
        if grid[i][j]=='#':
            flg=1

    if flg==0:
        row.append(i)


for j in range(w):
    flg=0
    for i in range(h):
        if grid[i][j]=='#':
            flg=1

    if flg==0:
        col.append(j)

ans=[]
for i in range(h):
    arr=[]
    for j in range(w):
        if i in row or j in col:
            continue
        else:
            arr.append(grid[i][j])
    if len(arr)!=0:
        ans.append(arr)

for k in ans:
    print(*k)


h,w=map(int,input().split())
grid=[]
for _ in range(h):
    grid.append(list(input()))

row=[]
col=[]

for i in range(h):
    flg=0
    for j in range(w):
        if grid[i][j]=='#':
            flg=1

    if flg==0:
        row.append(i)


for j in range(w):
    flg=0
    for i in range(h):
        if grid[i][j]=='#':
            flg=1

    if flg==0:
        col.append(j)

ans=[]
for i in range(h):
    arr=[]
    for j in range(w):
        if i in row or j in col:
            continue
        else:
            arr.append(grid[i][j])
    if len(arr)!=0:
        ans.append(arr)

for k in ans:
    t=''.join(k)
    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):
h, w = map(int, input().split())
a = [input() for _ 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[i] = 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 = [input() for _ 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: 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 = [input() for h in range(H)]
A = [list(a) for a in A if '#' in a]
print(A)
w = 0
while w < W:
    for a in A:
        if a[w]=='#':
            break
    else:
        for a in A:
            a.pop(w)
        W -= 1
        w -= 1
    w += 1
for a in A:
    print(''.join(a))

H,W = map(int,input().split())
A = []
for h in range(H):
    a = input()
    if '#' in a:
        A.append(a)
A = [a for a in zip(*A) if '#' in a]
A = [a for a in zip(*A)]
for a in A:
    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):
def str_del(string,index):
    string = string[:index]+string[index+1:]
    return string


H,W=map(int,input().split())
lines=[]
for i in range(H):
    get=input()
    flag=True
    for s in get:
        if s=='#':
            flag=False
            break
    if not flag:
        lines.append(get)
    else:
        H-=1



for i in range(W):
    same_flag = True

    for s in range(len(lines)):
        #print(lines)
        try:
            if(lines[s][i]=='#'):
                same_flag=False
                break
        except:
            same_flag = False
            break

    if same_flag:
        for s in range(len(lines)):
            lines[s]=str_del(lines[s],i)
            #print(lines[s])
        print('deleted')


for i in range(len(lines)):
    print(lines[i])



def str_del(string,index):
    string = string[:index]+string[index+1:]
    return string




H,W=map(int,input().split())
lines=[]
for i in range(H):
    get=input()
    flag=True
    for s in get:
        if s=='#':
            flag=False
            break
    if not flag:
        lines.append(get)
    else:
        H-=1


i=0
while(i<W):
    same_flag = True

    for s in range(len(lines)):
        #print(lines)
        if(lines[s][i]=='#'):
                same_flag=False
                break


    if same_flag:
        for s in range(len(lines)):
            lines[s]=str_del(lines[s],i)

        i-=1
        W-=1
            #print(lines[s])
        #print('deleted')

    i+=1


for i in range(len(lines)):
    print(lines[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())
l=[]
for i in range(h):
    l.append(list(map(str,input())))
print(l)

row=[False]*h
col=[False]*w
for i in range(h):
    for k in range(w):
        if l[i][k]=="#":
            row[i]=True
            col[k]=True
for i in range(h):
    if row[i]:
        for k in range(w):
            if col[k]:
                print(l[i][k], end="")
        print("")


h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(map(str,input())))

row=[False]*h
col=[False]*w
for i in range(h):
    for k in range(w):
        if l[i][k]=="#":
            row[i]=True
            col[k]=True
for i in range(h):
    if row[i]:
        for k in range(w):
            if col[k]:
                print(l[i][k], 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 = [input() for _ in range(H)]

index_h = []
index_w = []

for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            break
        if j == W - 1:
            index_h.append(i)

for j in range(W):
    for i in range(H):
        if maze[i][j] == '#':
            break
        if i == H - 1:
            index_w.append(j)

for i in range(H):
    for j in range(W):
        if i in index_h:
            continue
        if j in index_w:
            continue
        print(maze[i][j], end='')

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

index_h = []
index_w = []

for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            break
        if j == W - 1:
            index_h.append(i)

for j in range(W):
    for i in range(H):
        if maze[i][j] == '#':
            break
        if i == H - 1:
            index_w.append(j)


for i in range(H):
    flag = True
    for j in range(W):
        if i in index_h:
            flag = False
            break
        if j in index_w:
            continue
        print(maze[i][j], end='')
    if flag:
        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 sys
import numpy as np

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def kk(al):
	for i in range(len(al)-1, -1, -1):
		if list(al[i]) == ['.']*len(al[i]):
			al = np.delete(al, i, 0)
	return al

def main():
	#a = int(input())
	h, w = tin()
	#s = input()
	al=[]
	for _ in range(h):
		s=list(input())
		al.append(s)
	al = np.array(al)
	al = kk(al)
	al = kk(al.T)
	al=al.T
	for v in al:
		print(*v)
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

import sys
import numpy as np

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def kk(al):
	for i in range(len(al)-1, -1, -1):
		if list(al[i]) == ['.']*len(al[i]):
			al = np.delete(al, i, 0)
	return al

def main():
	#a = int(input())
	h, w = tin()
	#s = input()
	al=[]
	for _ in range(h):
		s=list(input())
		al.append(s)
	al = np.array(al)
	al = kk(al)
	al = kk(al.T)
	al=al.T
	for v in al:
		print(''.join(v))
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Verdicts: Wrong Answer

Accepted