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

l = [int(input()) for i in range(H)]

y = [False] * H
x = [False] * W

for i in range(H):
    flg = True
    for j in range(W):
        if l[i][j] != '.':
            flg = False
            break
    if flg:
        y[i] = True

for i in range(W):
    flg = True
    for j in range(H):
        if l[j][i] != '.':
            flg = False
            break
    if flg:
        x[i] = True

for i in range(H):
    if y[i]:
        continue
    for j in range(W):
        if x[j]:
            continue
        print(l[i][j], end='')
    print()


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

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

y = [False] * H
x = [False] * W

for i in range(H):
    flg = True
    for j in range(W):
        if l[i][j] != '.':
            flg = False
            break
    if flg:
        y[i] = True

for i in range(W):
    flg = True
    for j in range(H):
        if l[j][i] != '.':
            flg = False
            break
    if flg:
        x[i] = True

for i in range(H):
    if y[i]:
        continue
    for j in range(W):
        if x[j]:
            continue
        print(l[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())
li = []
for i in range(h):
    a = list(input())
    
    if "#" in a:
      li.append(a)
print(li)
for j in range(w):
    #if all([li[k][j] == "." for k in range(len(li))]):
    if all(li[k][j] == "." for k in range(len(li))):
        for k in range(len(li)):
            #li[k][j] == ""
            li[k][j] = ""
for m in range(len(li)):
    print("".join(li[m]))


h,w = map(int, input().split())
li = []
for i in range(h):
    a = list(input())
    
    if "#" in a:
      li.append(a)
for j in range(w):
    #if all([li[k][j] == "." for k in range(len(li))]):
    if all(li[k][j] == "." for k in range(len(li))):
        for k in range(len(li)):
            #li[k][j] == ""
            li[k][j] = ""
for m in range(len(li)):
    print("".join(li[m]))

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
column=[False]*w
for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      row[i]=True
      column[j]=True
for i in range(h):
  if row[i]:
    for j in range(w):
      if column[j]:
        print(a[i][j]+" ")
    print()

h,w=map(int, input().split())
a=[" "]*h
for i in range(h):
  a[i]=input()
row=[False]*h
column=[False]*w
for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      row[i]=True
      column[j]=True
for i in range(h):
  if row[i]:
    for j in range(w):
      if column[j]:
        print(a[i][j]+" ")
    print()

h,w=map(int, input().split())
a=[""]*h
for i in range(h):
  a[i]=input()
row=[False]*h
column=[False]*w
for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      row[i]=True
      column[j]=True
for i in range(h):
  if row[i]:
    for j in range(w):
      if column[j]:
        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):
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
        

h,w=map(int,input().split())
a=[input() for i in range(h)]
row=[0]*h
col=[0]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=1
            col[j]=1
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()]

temp_list = []
l = w
r = -1
for _ in range(h):
    a = input()
    temp_l = a.find("#")
    if temp_l == -1:
        continue
    l = min(temp_l, l)
    r = max(a.rfind("#"), r)
    temp_list.append(a)

for temp in temp_list:
    print(temp[l:r+1])

h, w = [int(x) for x in input().split()]
 
temp_list = []
flag = [False] * w
for _ in range(h):
    a = input()
    if "#" not in a:
        continue
    temp_list.append(a)
    for i in range(w):
        flag[i] = flag[i] or a[i] == "#"

for temp in temp_list:
    print("".join([temp[i] for i in range(w) if flag[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):

def compression(init, matrix):
	
	mir = []
	
	for row in matrix:
		if "#"in row:
			mir.append(row)
	matrix = []
	
	mir = list(map(list, zip(*mir)))
	
	for row in mir:
		if "#"in row:
			matrix.append(row)
		
	matrix = list(map(list, zip(*matrix)))	
			
	
	return matrix


init = input().split(" ")
init = [int(c) for c in init]

matrix = [[] for j in range(init[0])]
j = 0

for j in range(init[1]+1):
	matrix[j] = input()

result = compression(init, matrix)
for row in result:
	print("".join(row))


def compression(init, matrix):
	
	mir = []
	
	for row in matrix:
		if "#"in row:
			mir.append(row)
	matrix = []
	
	mir = list(map(list, zip(*mir)))
	
	for row in mir:
		if "#"in row:
			matrix.append(row)
		
	matrix = list(map(list, zip(*matrix)))	
			
	
	return matrix


init = input().split(" ")
init = [int(c) for c in init]

matrix = [[] for j in range(init[0])]

for j in range(init[0]):
	matrix[j] = input()

result = compression(init, matrix)
for row in result:
	print("".join(row))

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 sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

h, w = rm()
li = np.array([np.array(rl()) for _ in range(h)])
li2 = np.array([])
li3 = np.array([])
for i in li:
  if '#' not in i:
    li2.append(i)
li2 = li2.T
for i in li2:
  if '#' not in i:
    li3.append(i)
for i in li3.T:
  print(''.join(i))

import sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rr = lambda: sys.stdin.readline().rstrip()

h, w = rm()
li = np.array([np.array(list(rr())) for _ in range(h)])
li2 = []
li3 = []
for i in li:
  if '#' in i:
    li2.append(i)
li2 = np.array(li2).T
for i in li2:
  if '#' in i:
    li3.append(i)
li3 = np.array(li3).T
for i in li3:
  print(''.join(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):
import numpy as np

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

for _ in range(h):
    a = input()
    if '#' in a:
        A.append(a)

AA = []
count = 0
for j in range(w):
    retu = []
    for i in range(len(A)):
        retu.append(A[i][j])
    if '#' not in retu:
        continue
    else:
        AA.append(retu)

AA = np.array(AA)
AA = AA.T
AA = AA.tolist()

for aa in AA:
    print(*aa)

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

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

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

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

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):
A,B=[],[]
h,w=map(int,input().split())
for i in range(h):
    a=input()
    if "#" in a:
        A.append(a)
b=""
for i in range(w):
    if "#" not in b:
        B.append(i-1)
    b=""
    for j in range(len(A)):
        b+=A[j][i]
b=""
b+=A[len(A)-1]
if "#" not in b:
    B.append(w-1)
B.pop(0)
o=0
print(B)
for i in range(len(A)):
    o=0
    A[i]=list(A[i])
    for j in B:
        A[i].pop(j-o)
        if o==len(B)-1:
            print("".join(A[i]))
        o+=1
if len(B)==0:
    for i in A:
        print("".join(i))

A,B=[],[]
h,w=map(int,input().split())
for i in range(h):
    a=input()
    if "#" in a:
        A.append(a)
b=""
for i in range(w):
    if "#" not in b:
        B.append(i-1)
    b=""
    for j in range(len(A)):
        b+=A[j][i]
if "#" not in b:
    B.append(w-1)
B.pop(0)
o=0
for i in range(len(A)):
    o=0
    A[i]=list(A[i])
    for j in B:
        A[i].pop(j-o)
        if o==len(B)-1:
            print("".join(A[i]))
        o+=1
if len(B)==0:
    for i in A:
        print("".join(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 = [list(input()) for i in range(h)]
 
for i in range(h):
  if "#" not in a[i]:
    del a[i]
 
aT = zip(*a)
 
for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]
 
a = zip(*aT)
 
for i in a:
  print(i)

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

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

for i in range(h):
  if "#" not in a[i]:
    del a[i]

aT = zip(*a)

for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]

a = zip(*aT)

for i in a:
  print(i)

h, w = map(int, input().split())
 
a = [list(input()) for i in range(h)]
 
for i in range(h):
  if "#" not in a[i]:
    del a[i]
 
aT = list(zip(*a))
 
for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]
 
a = list(zip(*aT))

for i in a:
  print(i)


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

a = [x for x in a if "#" in x]
aT = list(zip(*a))
aT = [x for x in aT if "#" in x]
a = list(zip(*aT))

for i in a:
    print("".join(i))


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=map(int,input().split())
a=[[c for c in input()] for _ in range(h)]
b=[]
flag=0
for s in a:
  if ("#" in s) and ("." in s):
    b.append(s)
for i in range(w):
  flag=0
  for j in range(len(b)):
    if b[j][i]!=b[0][i]:
      flag=1
      break
  if flag==0:
    for j in range(len(b)):
      b[j][i]=""
for s in b:
  print("".join(s))

h,w=map(int,input().split())
a=[[c for c in input()] for _ in range(h)]
b=[]
flag=0
for s in a:
  if "#" in s:
    b.append(s)
for i in range(w):
  flag=0
  for j in range(len(b)):
    if b[j][i]=="#":
      flag=1
      break
  if flag==0:
    for j in range(len(b)):
      b[j][i]=""
for s in b:
  print("".join(s))

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(i) for i in input().split(' '))
grid=[]
for h in range(H):
  tmp = input()
  if tmp.count('#')!=0:
 	grid[h]=tmp
  else:
    H -= 1
pop_count=0
for w in range(W):
  check = 0
  for h in range(h):
    if grid[h][w-pop_count]='#':
      check = 1
  if check == 0:
    for h in range(H):
		grid[h].pop(w-pop_count)
    pop_count+=1
for h in range(H):
  print(grid[h])

H,W=(int(i) for i in input().split(' '))
grid=[]
delete_count= 0
pop_count=0
for h in range(H):
  tmp = [char for char in input()]
  if tmp.count('#')!=0:
    grid.append(tmp)
  else:
    delete_count += 1
for w in range(W):
  check = 0
  for h in range(H-delete_count):
    if grid[h][w-pop_count]=='#':
      check = 1
  if check == 0:
    for h in range(H-delete_count):
      del grid[h][w-pop_count]
    pop_count+=1
for h in range(H-delete_count):
  grid[h]=''.join(grid[h])
  print(grid[h])

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())
h1=[0 for i in range(h)]
w1=[0 for i in range(w)]
for i in range(h):
  a=input()
  m+=[a]
  if not "#" in a:
    h1[i]=1
    
for i in range(w):
  k=1
  for j in range(len(m)):
    if m[j][i]=="#":
      k=0
      break
  if k==1:
    w1[i]=1
    
for i in range(h):
  if h1[i]==1:
    continue
  ans=""
  for j in range(w):
    if w1[j]==1:
      continue
    ans+=m[i][j]
  print(ans)
  

h,w=map(int,input().split())
h1=[0 for i in range(h)]
w1=[0 for i in range(w)]
m=[]
for i in range(h):
  a=input()
  m+=[a]
  if not "#" in a:
    h1[i]=1
    
for i in range(w):
  k=1
  for j in range(len(m)):
    if m[j][i]=="#":
      k=0
      break
  if k==1:
    w1[i]=1
    
for i in range(h):
  if h1[i]==1:
    continue
  ans=""
  for j in range(w):
    if w1[j]==1:
      continue
    ans+=m[i][j]
  print(ans)
  

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()
    A.append ([c  for c in tmp])
    
print (A)

h=H
w=W
for i in range(H):
    cnt = 0    
    for j in range(W):
        if A[i][j] == ".":
            cnt += 1
            
            
    if cnt == W:
        h -= 1
        for ii in range(i, H-1):
            for jj in range(W):
                A[ii][jj] = A[ii+1][jj]

for j in range(W):
    cnt = 0    
    for i in range(H):
        if A[i][j] == ".":
            cnt += 1
            
            
    if cnt == H:
        w -= 1
        for jj in range(j, W-1):
            for ii in range(H):
                A[ii][jj] = A[ii][jj+1]

print ("h={0} w={1}\n".format(h, w))
B = []
for i in range(h):
    B.append([])
    for j in range(w):
        B[i].append (A[i][j])
        
        
print (B)

H, W = map(int, input().split(" "))
A=[]
for i in range(H):
    tmp = input()
    A.append ([c  for c in tmp])
    
# print (A)

h=H
w=W
for i in range(H-1,-1,-1):
    cnt = 0    
    for j in range(W):
        if A[i][j] == ".":
            cnt += 1


    if cnt == W:
        h -= 1
        for ii in range(i, H-1):
            for jj in range(W):
                A[ii][jj] = A[ii+1][jj]

for j in range(W-1,-1,-1):
    cnt = 0    
    for i in range(h):
        if A[i][j] == ".":
            cnt += 1


    if cnt == h:
        w -= 1
        for jj in range(j, W-1):
            for ii in range(h):
                A[ii][jj] = A[ii][jj+1]

def printA(A, h, w):
    for i in range(h):
        st = ""
        for j in range(w):
            st += (A[i][j])

        print (st)    

printA(A, h, w)

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=[np.array(input().split()) for i in range(h)]
a=np.array(a)

h_score=[0]*h
w_score=[0]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=='.':
            h_score[j]+=1
            w_score[i]+=1

for i in range(h):
    if h_score[i]==h:
        a=np.delete(a,i,1)
for i in range(w):
    if w_score[i]==w:
        a=np.delete(a,i,0)

for i in a:
    print(*i)

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

import numpy as np
change_h=0
change_w=w
ans=[]
for i in range(h):
    if l[i].count('.')!=w:
        ans+=[l[i][:]]
        change_h+=1
l_count=[]
for i in range(w):
    count=0
    for j in range(h):
        if l[j][i]=='.':
            count+=1
    
    if count==h:
        l_count+=[i]
    
l_count=sorted(l_count,reverse=True)
for i in l_count:
    ans=np.delete(ans,i,axis=1)
    


for i in range(change_h):
    print(*ans[i],sep='')

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())
L = [input() for i in range(H)]
X = [False for i in range(W)]
Y = [False for i in range(H)]

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" :
            X[x] = True
            Y[y] = True
print(X,Y)

for y in range(H) :
    if Y[y] == True :
        ANS = []
        for x in range(W) :
            if X[x] == True :
                ANS.append(L[y][x])
        print("".join(ANS))
        

H,W = map(int,input().split())
L = [input() for i in range(H)]
X = [False for i in range(W)]
Y = [False for i in range(H)]

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" :
            X[x] = True
            Y[y] = True

for y in range(H) :
    if Y[y] == True :
        ANS = []
        for x in range(W) :
            if X[x] == True :
                ANS.append(L[y][x])
        print("".join(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 = [int(hw) for hw in input().split()]
A = []
for h in range(H):
  a = [a for a in input()]
  if a.count("#") > 0:
    A.append(a)
for w in range(W):
  cnt = 0
  for h in range(len(A)):
    if A[h][w] == ".":
      cnt += 1
  if cnt == len(A):
    for h in range(len(A)):
      del A[h][w]
for h in range(len(A)):
  print(A[h])

H, W = [int(hw) for hw in input().split()]
A = []
for h in range(H):
  a = [a for a in input()]
  if a.count("#") > 0:
    A.append(a)

for w in reversed(range(W)):
  cnt = 0
  for h in range(len(A)):
    if A[h][w] == ".":
      cnt += 1
  if cnt == len(A):
    for h in range(len(A)):
      del A[h][w]

for h in range(len(A)):
  ans = "".join(A[h])
  print(ans)

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

data = input().split()

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

count = 0
# creating math
i = 0
math = []
while i < h:
    x = input()
    x = list(x)
    math.append(x)
    i += 1
math = np.array(math).reshape(h,w)


# row check

i = 0 # row
j = 0 # colum
while i < h:
    while j < w:
        if math[i][j] == ".":
            
            j += 1
            if j == w:
                math = np.delete(math,i,0)
                h = h-1
                
                
        else:
            break
    j = 0
    i += 1
i = 0
j = 0

# colum check

while j < w:
    while i < h:
        if math[i][j] == ".":
            
            i += 1
            if i == h:
                math = np.delete(math,j,1)
                w = w-1
                
                
        else:
            break
    i = 0
    j += 1

print(math)

    
    


import numpy as np

data = input().split()

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

count = 0
# creating math
i = 0
math = []
while i < h:
    x = input()
    x = list(x)
    math.append(x)
    i += 1
math = np.array(math).reshape(h,w)


# row check

i = 0 # row
j = 0 # colum
while i < h:
    while j < w:
        if math[i][j] == ".":
            
            j += 1
            if j == w:
                math = np.delete(math,i,0)
                h = h-1
                i -=1
                
                
                
        else:
            break
    j = 0
    i += 1
i = 0
j = 0

# colum check

while j < w:
    while i < h:
        if math[i][j] == ".":
            
            i += 1
            if i == h:
                math = np.delete(math,j,1)
                w = w-1
                j -= 1
                
                
        else:
            break
    i = 0
    j += 1
i = 0
j = 0
while i < h:
    while j < w:
        print(*math[i][j],end = "")
        j += 1
    i += 1
    j = 0
    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())
field = [[i for i in input()] for j in range(H)]

b_rows = []
for row in range(H):
    if field[row].count(".") != W:
        b_rows.append(row)

b_columns = []
for column in range(W):
    memo = []
    for row in range(H):
        memo.append(field[column][row])
    if memo.count(".") != H:
        b_columns.append(column)

for i in b_rows:
    for j in b_columns:
        print(field[i][j], end="")
    print()

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

b_rows = []
for row in range(H):
    if field[row].count(".") != W:
        b_rows.append(row)

b_columns = []
for column in range(W):
    memo = []
    for row in range(H):
        memo.append(field[row][column])
    if memo.count(".") != H:
        b_columns.append(column)

for i in b_rows:
    for j in b_columns:
        print(field[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 _ in range(N)]

tmp = []
for a in zip(*A):
  if(a.count("#") > 0):
    tmp.append("".join(a))
tmp2 = []
for t in zip(*tmp):
  if(t.count("#") > 0):
    tmp2.append("".join(t))
print("\n".join(tmp2))

import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  h, w = na()
  a = [ns() for _ in range(h)]
  a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0]
  a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0]
  print("\n".join(a))

main()

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 i in range(h)]
b=[]
c=[]
for i in a:
  if "#" in i:
    b.append(i)
for i in range(w):
  for j in range(len(b)):
    if b[j][i] == "#":
      break
    elif j = h-1:
      for k in b:
        del k[j]
print(b)

a=[input() for i in range(h)]
b=[]
for i in a:
  if "#" in i:
    b.append(i)
for i in range(w):
  for j in range(len(b)):
    if b[j][i] == "#":
      break
    elif j == len(b)-1:
      for k in range(len(b)):
        print(b[k][:i],b[k][i+1:],sep="")

h,w = map(int,input().split())
a=[list(input()) for i in range(h)]
b=[]
dl=[]
for i in a:
  if "#" in i:
    b.append(i)
for j in range(w):
  for i in range(len(b)):
    if b[i][j] == "#":
      break
    elif i == len(b)-1:
      dl.append(j)
dl.sort(reverse=True)
for i in dl:
  for j in range(len(b)):
    del b[j][i]
for c in b:
  print(*c,sep="")

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 = list(map(int, input().split()))

mat = np.zeros((H, W))
original_mat = []

removed_line = []
removed_column = []

for i in range(H):
    row = input()
    line = []
    for j, c in enumerate(row):
        if c == "#":
            mat[i, j] = 1

    # print(mat[i,:])
    if np.sum(mat[i,:]) == 0:
        removed_line.append(i)
    else:
        original_mat.append(row)

for i in range(W):
    print(mat[:,i])
    if np.sum(mat[:,i]) == 0:
        removed_column.append(i)

print(removed_line)
print(removed_column)

for row in original_mat:
    for i, c in enumerate(row):
        if i not in removed_column:
            print(c, end="")
    print("\n", end="")


import numpy as np

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

mat = np.zeros((H, W))
original_mat = []

removed_line = []
removed_column = []

for i in range(H):
    row = input()
    line = []
    for j, c in enumerate(row):
        if c == "#":
            mat[i, j] = 1

    # print(mat[i,:])
    if np.sum(mat[i,:]) == 0:
        removed_line.append(i)
    else:
        original_mat.append(row)

for i in range(W):
    # print(mat[:,i])
    if np.sum(mat[:,i]) == 0:
        removed_column.append(i)

# print(removed_line)
# print(removed_column)

for row in original_mat:
    for i, c in enumerate(row):
        if i not in removed_column:
            print(c, end="")
    print("\n", end="")


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):
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]


for h in range(H):
    if '#' in a[h]:
        for w in range(W):
            a[h][w] = ''
for w in range(W):
    if '#' in [p[w] for p in a]:
        for h in range(H):
            a[h][w] = ''

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]

compressed = True
while compressed:
    compressed = False
    for h in range(H):
        if '#' not in a[h]:
            for w in range(W):
                a[h][w] = ''
                compressed = True
    for w in range(W):
        if '#' not in [p[w] for p in a]:
            for h in range(H):
                a[h][w] = ''
                compressed = True

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]

compressed = False
while compressed:
    compressed = False
    for h in range(H):
        if '#' not in a[h]:
            for w in range(W):
                a[h][w] = ''
                compressed = True
    for w in range(W):
        if '#' not in [p[w] for p in a]:
            for h in range(H):
                a[h][w] = ''
                compressed = True

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]


for h in range(H):
    if '#' not in a[h]:
        for w in range(W):
            a[h][w] = ''
for w in range(W):
    if '#' not in [p[w] for p in a]:
        for h in range(H):
            a[h][w] = ''

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Verdicts: Wrong Answer

Time Limit Exceeded

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 main():
    H, W = list(map(int, input().split(" ")))
    a = []
    for r in range(H):
        a += [input()]
    output = solve(H, W, a)
    for s in output:
        print(s)
    return

#________________________________________
#  Solve
#________________________________________
def solve(H, W, a):
    
    index_list = []
    for _r in range(H):
        for _c in range(W):
            if a[_r][_c] is not ".":
                break
            if _c == W-1:
                index_list += [_r]
    for i in index_list:
        del a[i]

    for _c in range(len(a[0])):
        for _r in range(len(a)):
            if a[_r][_c] is not ".":
                break
            if _r == len(a)-1:
                index_list += [_c]
    a = list(map(list, zip(*a)))
    for i in index_list:
        del a[i]
    a = list(map(list, zip(*a)))
    a = [ "".join(a[i]) for i in range(len(a))]
    return a
#________________________________________


if __name__ == "__main__":
    main()

def main():
    H, W = list(map(int, input().split(" ")))
    a = []
    for r in range(H):
        a += [input()]
    output = solve(H, W, a)
    for s in output:
        print(s)
    return

#________________________________________
#  Solve
#________________________________________
def solve(H, W, a):
    
    index_list = []
    for _r in range(H):
        for _c in range(W):
            if a[_r][_c] is not ".":
                break
            if _c == W-1:
                index_list += [_r]
    j = 0
    for i in index_list:
        del a[i-j]
        j += 1

    index_list = []
    a = list(map(list, zip(*a)))
    for _r in range(len(a)):
        for _c in range(len(a[0])):
            if a[_r][_c] is not ".":
                break
            if _c == len(a[0])-1:
                index_list += [_r]
    j = 0
    for i in index_list:
        del a[i-j]
        j += 1
    a = list(map(list, zip(*a)))
    a = [ "".join(a[i]) for i in range(len(a))]
    return a
#________________________________________


if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted