Problem:


Score : 200 points

Problem Statement

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.

Constraints

1 \leq H, W \leq 100

a_{i, j} is . or #.

There is at least one black square in the whole grid.

Input

Input is given from Standard Input in the following format:

H W
a_{1, 1}...a_{1, W}
:
a_{H, 1}...a_{H, W}

Output

Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.

Sample Input 1

4 4
##.#
....
##.#
.#.#

Sample Output 1

###
###
.##

The second row and the third column in the original grid will be removed.

Sample Input 2

3 3
#..
.#.
..#

Sample Output 2

#..
.#.
..#

As there is no row or column that consists only of white squares, no operation will be performed.

Sample Input 3

4 5
.....
.....
..#..
.....

Sample Output 3

#

Sample Input 4

7 6
......
....#.
.#....
..#...
..#...
......
.#..#.

Sample Output 4

..#
#..
.#.
.#.
#.#



Sample input:
4 4
##.#
....
##.#
.#.#


Sample output:
###
###
.##

Submission status: Runtime Error

Solution code:
H,W=map(int,input().split())
st=set()
list=list()
for i in range(H):
    S=input()
    if S.count('.') != W:
        list.append(S)
    tmp=[*S]
    tmp=[int(i) for i,x in enumerate(tmp) if x == '.']
    if not st:
        tmp_set = set(tmp)
        st=st.union(tmp_set)
    else:
        tmp_set = set(tmp)
        st &=tmp_set
for x in list:
    str=''
    if not st:
        for i in range(W):
            str+=x[i]
    else:
        for i in range(W):
            if i not in st:
                str+=x[i]
    print(str)
    str=''

Submission status: Runtime Error

Solution code:
H,W=map(int,input().split())
set1=set()
list=list()
for i in range(H):
    S=input()
    if S.count('.') != W:
        list.append(S)
    tmp=[*S]
    tmp=[int(i) for i,x in enumerate(tmp) if x == '.']
    if not set1:
        tmp_set = set(tmp)
        set1=set1.union(tmp_set)
    else:
        tmp_set = set(tmp)
        set1 &=tmp_set
for x in list:
    str=''
    if not set1:
        for i in range(W):
            str+=x[i]
    else:
        for i in range(W):
            if i not in set1:
                str+=x[i]
    print(str)
    str=''

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
list = []
for i in range(H):
    if not '#' in A[i]:
        list.append(i)
for i in list:
    A.remove(A[i])
H = len(A)
list = []
for j in range(W):
    flag = True
    for i in range(H):
        if A[i][j] == '#':
            flag = False
    if flag:
        list.append(j)
for j in list:
    for i in range(H):
        A[i].remove(A[i][j])

for i in range(H):
    print(''.join(A[i]))

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
for i in range(h):
  if a[i].count('.')==w:
    a[i]=[]
while [] in a:
  a.remove([])
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=='.':
      c+=1
  if c==len(a):
    for j in range(len(a)):
      a[j][i]='!'
for i in range(len(a)):
  while '!' in a[i]:a
    a[i].remove('!')
for i in a:
  print(*i,sep='')

Submission status: Runtime Error

Solution code:
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])

Submission status: Runtime Error

Solution code:

lst_1 = input().split()

H = int(lst_1[0])
W = int(lst_1[1])
lst_A = [list(input()) for i in range(W)]
i = 0
while 1:
    zen_bu_ten = True
    for j in range(W):
        if lst_A[i][j] == "#":
            zen_bu_ten = False
    if zen_bu_ten == True:
        del(lst_A[i])
        H -= 1
    else:
        i += 1
    if i >= H:
        break

j = 0
while 1:
    zen_bu_ten = True
    for i in range(H):
        if lst_A[i][j] == "#":
            zen_bu_ten = False
    if zen_bu_ten == True:
        for i in range(H):
            del(lst_A[i][j])
        W -= 1
    else:
        j += 1
    if j >= W:
        break

print(lst_A)

Submission status: Runtime Error

Solution code:
from sys import stdin

H, W = [int(x) for x in stdin.readline().rstrip().split()]

A = [list(stdin.readline().rstrip()) for _ in range(H)]
result = A

delete_column = []
delete_row = []

for k in range(W):
    cnt = 0
    for l in A[k]:
        if l == '.':
            cnt += 1
    if cnt == len(A[k]):
        delete_row.append(k)

for k in range(W):
    cnt = 0
    for l in range(H):
        if A[l][k] == '.':
            cnt += 1
    if cnt == H:
        delete_column.append(k)

for x in delete_row:
    del result[x]

for x in delete_column:
    for y in range(len(A)):
        del result[y][x]

for x in result:
    print(''.join(x))

Submission status: Runtime Error

Solution code:
from sys import stdin

H, W = [int(x) for x in stdin.readline().rstrip().split()]

A = [list(stdin.readline().rstrip()) for _ in range(H)]

delete_column = []
delete_row = []

for k in range(W):
    cnt = 0
    for l in A[k]:
        if l == '.':
            cnt += 1
    if cnt == len(A[k]):
        delete_row.append(k)

for k in range(W):
    cnt = 0
    for l in range(H):
        if A[l][k] == '.':
            cnt += 1
    if cnt == H:
        delete_column.append(k)

for x in delete_row:
    del A[x]

for x in delete_column:
    for y in range(len(A)):
        del A[y][x]

for x in A:
    print(''.join(x))

Submission status: Runtime Error

Solution code:
from sys import stdin

H, W = [int(x) for x in stdin.readline().rstrip().split()]

A = [list(stdin.readline().rstrip()) for _ in range(H)]

delete_column = []
delete_row = []

for k in range(H):
    cnt = 0
    for l in A[k]:
        if l == '.':
            cnt += 1
    if cnt == len(A[k]):
        delete_row.append(k)

for k in range(H):
    cnt = 0
    for l in range(H):
        if A[l][k] == '.':
            cnt += 1
    if cnt == H:
        delete_column.append(k)

for x in delete_row:
    del A[x]

for x in delete_column:
    for y in range(len(A)):
        del A[y][x]

for x in A:
    print(''.join(x))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split()) 
A = [list(input().split())   for i in range(b)]

lines =[]
for j in A:
  for k in j:
    if "#" in k:
      lines.append(k)
lines_t = ["".join(list(i)) for i in zip(*lines)]
B=[]
for g in lines_t:
    if "#" in g:
      B.append(g)
C=[]
C= ["".join(list(i)) for i in zip(*B)]
for v in C:
  print(v)

Submission status: Runtime Error

Solution code:
h, w = [int(i) for i in input().split()]
a = []
d = []
h_new = 0
for i in range(h):
  b = input()
  if "#" in b:
    a.append(list(b))
    h_new += 1
for i in range(w):
  c = []
  for j in range(h_new):
    c.append(a[j][i])
  if "#" not in c:
    d.append(i)
e = ""
for i in d:
  for j in range(h_new):
    del a[j][i]
for i in range(h_new-1):
  e += "".join(a[i]) +"\n"
e += "".join(a[h_new-1])
print(e)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a = [list(input()) for _ in range(w)]

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

Submission status: Runtime Error

Solution code:
import sys
h,w = list(map(int, input().split()))
imap = []
for i in range(h):
    tmp = input()
    if not tmp == "."*w:
        tmp2 = list(tmp)
        imap.append(tmp2)
h = len(imap)
#print(w,h,imap)
for i in range(w):
    if all(imap[j][i] == "." for j in range(h)):
        for k in range(h):
            imap[k].pop(i)
#print(imap)
for i in range(h):
    for j in range(w):
        print(imap[i][j], end = "")
        if j == w-1:
            print("")

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
a = []
for hs in range(h):
  a.append(map(int,input().split()))
for hh is range(h):
  ais = true
  for hhh is a[hh]:
    if hhh == "#":
      ais = false
      continue
  if ais:
    for wwww in range(w):
      a[hh][wwww] = " "
for ww is range(w):
  wis = true
  for www is a[0:][ww]:
    if www == "#":
      wis = false
      continue
  if ais:
    for hhhh in range(h):
      a[hhhh][ww] = " "

Submission status: Runtime Error

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

int main() {
  int h, w; cin >> h >> w;
  vector<string> board(h);
  for (auto& e: board) cin >> e;

  vector<bool> rowIncludeSharp(h), colIncludeSharp(w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (board[i][j] == '#') {
        rowIncludeSharp[i] = true;
        colIncludeSharp[j] = true;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    if (rowIncludeSharp[i]) {
      for (int j = 0; j < w; j++) {
        if (colIncludeSharp[j]) {
          cout << board[i][j];
        }
      }
      cout << endl;;
    }
  }
}

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
tmp = True
A = []
B = []
for i in range(H):
    a = list(input())
    if a != ['.']*W:
        A.appned(a)
for i in range(W):
    cnt = 0
    for j in range(len(A)):
        if A[j][i] != '.':
            cnt += 1
    if cnt == 0:
        B.insert(0,i)
for i in range(len(A)):
    for j in range(len(B)):
        del A[i][B[j]]
for i in range(len(A)):
    ans = "".join(A[i])
    print(ans)

Submission status: Runtime Error

Solution code:
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()

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
l=[]
n=0
m=0
cou=0
for i in range(h):
    x=input()
    if x==("."*w):
        cou+=1
        continue
    l.append(list(x))
for i in range(w-1):
    k=0
    for j in range(h-cou):
        if l[j][i]==".":
            k+=1
    if k==h-cou:
        for d in range(h-cou):
            del l[d][i]
for i in range(h-cou):
    l[i]="".join(l[i])
    print(l[i])

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
from numpy import *
a,b=map(int,input().split())
c=array([list(input())for i in range(a)])
bl=[]
for i in c:
    if any(i=="#"):
        bl.append(True)
    else:
        bl.append(False)
c=c[bl]
bl2=[]
for i in range(b):
    if any(c[:,i]=="#"):
        bl2.append(True)
    else:
        bl2.append(False)
for i in c[:,bl2]:
    print("".join(i))

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin
N,K=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(N):
    data.append([ 1 if x == "#" else 0 for x in list(input())])
data=np.array(data)
index_col=[]
for j in range(N):
    if sum(data[:,j]) == 0:
        index_col.append(j)
data=np.delete(data, index_col, 1)

index_row=[]
for k in range(K):
    if sum(data[k]) == 0:
        index_row.append(k)
data=np.delete(data,index_row,0)
for l in data:
    tmp=""
    for m in l:
        if m == 1:
            tmp=tmp+"#"
        else:
            tmp=tmp+"."
    print(tmp)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
grid=[]
for i in range(h):
  grid.append(list(map(int,input().split())))
for i in range(grid):
  if grid[i].count('.')==len(grid[i]):
    grid.pop(i)
for j in range(grid[0]):
  for i in range(len(grid)):
    if grid[i][j]!='#':
      break
  for i in range(len(grid)):
    grid[i].pop(j)
for i in grid:
  print(' '.join(map(str,i)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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])

Submission status: Runtime Error

Solution code:
H, W = (int(i) for i in input().split())
e = [input() for i in range(H)] 

new_e = []
for row in e:
    if row.count("#") > 0:
        new_e.append(row)

not_use_col = list(range(W))
use_col = []
for row in new_e:
    for col in not_use_col:
        if row[col] == "#":
            use_col.append(not_use_col.pop(col))
            break

for row in new_e:
    x=""
    for col in use_col:
        x += row[col]
    print(x)

Submission status: Runtime Error

Solution code:
h,w=map (int,input().split())
s=[]
for i in range(h):
  t=input()
  s.append(t)
while j<len(s[0]):
  if i<len(h):
    if all(s[i][k]=='.' for k in range(len(s))):
      s.pop(i)
      i=0
      continue
    else:
      i+=1
  else:
    if all(s[k][j]=='.' for k in range(len(s[0]))):
      for k in range(s[0]):
        s[k]=s[k][::j]+s[k][j::]
      i,j=0,0
    else:
      j+=1
for k in range(len(s)):
  print(s[k])

Submission status: Runtime Error

Solution code:
h, w = map(int, input())
a = [list(input()) for i in range(h)]

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

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

for i in range(h):
    if row[i]:
        ans = ""
        for j in range(w):
            if col[j]:
                ans.join(a[i][j])
        print(ans)

Submission status: Runtime Error

Solution code:
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[i] = True
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end = "")
        print()

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

Solution code:
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()

Submission status: Runtime Error

Solution code:
f=lambda s:zip(*[t for t in s if'#'in t]);for r in f(f(open(0).readlines())):print(*r,sep='')

Submission status: Runtime Error

Solution code:
import numpy as np
H,W = map(int,input().split())
matrix = np.array([])

for i in range(H):
    temp = list(input())
    matrix = np.append(matrix,temp)

count = []
row = 0
index = 0

for i in range(0,H*(W-1)+1,W):
    if matrix[i] == "." and matrix[i+1] == "." and matrix[i+2] == ".":
        count = np.append(count,i)
        count = np.append(count,i+1)
        count = np.append(count,i+2)
        row += 1

for i in range(0,W):
    if matrix[i] == "." and matrix[i+3] == "." and matrix[i+6] == ".":
        count = np.append(count,i)
        count = np.append(count,i+3)
        count = np.append(count,i+6)
        index += 1


count = [int(s) for s in list(set(count))]
count = sorted(count,reverse=True)

for i in count:
    matrix = np.delete(matrix,[i],None)

matrix = matrix.reshape(H-row,W-index)

for i in range(H-row):
    print()
    for s in matrix[i]:
        print(s,end="")

Submission status: Runtime Error

Solution code:
import numpy as np
H,W = map(int,input().split())
matrix = np.array([])

for i in range(H):
    temp = list(input())
    matrix = np.append(matrix,temp)

count = []
row = 0
index = 0

for i in range(0,H*(W-1)+1,W):
    if matrix[i] == "." and matrix[i+1] == "." and matrix[i+2] == ".":
        print("hello")
        count = np.append(count,i)
        count = np.append(count,i+1)
        count = np.append(count,i+2)
        row += 1

for i in range(0,W):
    if matrix[i] == "." and matrix[i+3] == "." and matrix[i+6] == ".":
        count = np.append(count,i)
        count = np.append(count,i+3)
        count = np.append(count,i+6)
        index += 1


count = [int(s) for s in list(set(count))]
count = sorted(count,reverse=True)

for i in count:
    matrix = np.delete(matrix,[i],None)

matrix = matrix.reshape(H-row,W-index)

for i in range(H-row):
    print()
    for s in matrix[i]:
        print(s,end="")

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

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

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

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

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
ahw = [strlist for strlist in [[s for s in input()] for i in range(H)] if "#" in strlist]
tenti = []
for h in range(H-1):
   m =  [ah for ah in ahw[h]]
   if "#" in m:
       tenti.append(m)
for ahwnum in range(len(ahw)):
    print("".join([num for num in tenti[ahwnum]]))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())

l = [[]for _ in range(a)]
m = [[]for _ in range(b)]

for i in range(a):
    l[i] = list(input())
    for j in range(b):
        m[j].append(l[i][j])

p = []
for i in range(a):
    if l[i].count('.') == b:
        p.append(i)

q = []
for i in range(b):
    if m[i].count('.') == a:
        q.append(i)

count=0
for i in p:
    l.pop(i-count)
    count+=1

count=0
for i in q:
    for j in range(len(l)):
        l[j].pop(i-count)
        count+=1

for i in range(len(l)):
    for j in l[i]:
        print(j,end='')
    print()

Submission status: Runtime Error

Solution code:
input = get_input(INPUT)

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

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

n = []
for j in range(w):
    m = ["".join(t[j] for t in a)]
    if "#" in m[0]:
        n += m

for k in range(h):
    print("".join(u[k] for u in n))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
H, W = map(int, input().split(' '));

board = []
flags = [ True for x in range(W)]
for i in range(H):
    line = list(input())
    if ( '#' in line ):
        board.append(line)
        flags = [ f and s == '.' for s,f in zip(line, flags) ]

j = 0
for i, flag in enumerate(flags):
    if flag:
        for b in board:
            b.pop(i-j)
            j += 1
for b in board:
    print(''.join(b))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
H, W = map(int, input().split(' '));

board = []
flags = [ True for x in range(W)]
for i in range(H):
    line = list(input())
    if ( '#' in line ):
        board.append(line)
        flags = [ f and s == '.' for s,f in zip(line, flags) ]

for i, flag in enumerate(flags):
    if flag:
        for b in board:
            b.pop(i)
for b in board:
    print(''.join(b))

Submission status: Runtime Error

Solution code:
import numpy as np
h,w=map(int,input().split())
s=[]
for _ in range(w):
    a = input() 
    if "#" in a:
        s.append(a)
d = []
for i in zip(*s):
    if "#" in i:
        d.append(i)
for j in zip(*d):
    print(*j,sep="")

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
L = []


for _ in range(H):
    s=input()
    l=[]
    for x in s:
        l.append(x)
    for x in l:
        if x == ".":
            pass
        else:
            L.append(l)
            break
delete=[]
for i in range(W):
    cnt = 0
    for j in range(len(L)):
        if L[j][i]  == '.':
            cnt += 1
        else:
            cnt = 0
    if cnt == len(L):
        delete.append(i)
for i in delete:
    for j in range(len(L)):
        del L[j][i]
for x in L:
    for y in x:
        print(y,end="")
    print()

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void Debug(auto a);

signed main(){
    int h,w;
    cin >> h >> w;
    Vec(a,h);
    vector<string> b;
    REP(i,h){
        cin >> a[i];
    }
    bool er=false;
    REP(i,h){
        er=false;
        REP(j,w){
            if(a[i][j]=='#'){
                er = true;
            }
        }
        if(er){
            b.push_back(a[i]);
        }
        
    }
    h = b.size();
    Vec(c,h);
    copy(b.begin(),b.end(),c.begin());
    int tmp=0;
    REP(i,w){
        er=true;
        REP(j,h){
            if(b[j][i] == '#'){
                er=false;
            }
        }
        if(er){
            REP(j,h){
                c[j].erase(c[j].begin()+i-tmp);
                
            }
          tmp++;
        }
    }
    for(auto d: c){
        cout << d << endl;
    }
    
    
    return 0;
}
void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
import numpy as np
WH='.'
BK='#'
x=input()
x=x.split()
H=int(x[0])
W=int(x[1])
a=[[] for i in range(H)]
num=[]
numnum=0
for i in range(H):
    x=input()
    for j in range(W):
        a[i].append(x[j])
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==W:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a.pop(num[i])
H=H-numnum
a_n=np.array(a)
tr=a_n.T
num=[]
numnum=0
for i in range(W):
    flag=0
    for j in range(H):
        if tr[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==H:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a=np.delete(tr,num[i],0)
a_n=np.array(a)
a=a_n.T
for i in range(H):
    ans=''
    for j in range(W):
        ans=ans+a[i][j]
    print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
WH='.'
BK='#'
x=input()
x=x.split()
H=int(x[0])
W=int(x[1])
a=[[] for i in range(H)]
num=[]
numnum=0
for i in range(H):
    x=input()
    for j in range(W):
        a[i].append(x[j])
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==W:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a.pop(num[i])
H=H-numnum
a_n=np.array(a)
tr=a_n.T
num=[]
numnum=0
for i in range(W):
    flag=0
    for j in range(H):
        if tr[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==H:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a=np.delete(tr,num[i],0)
a_n=np.array(a)
a=a_n.T
print(a)

Submission status: Runtime Error

Solution code:
import numpy as np
WH='.'
BK='#'
x=input()
x=x.split()
H=int(x[0])
W=int(x[1])
a=[[] for i in range(H)]
num=[]
numnum=0
for i in range(H):
    x=input()
    for j in range(W):
        a[i].append(x[j])
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==W:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a.pop(num[i])
H=H-numnum
a_n=np.array(a)
tr=a_n.T
num=[]
numnum=0
for i in range(W):
    flag=0
    for j in range(H):
        if tr[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==H:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a=np.delete(tr,num[i],0)
a=a.T
print(a)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
n_h=h
for i in range(len(lst)):
    if "#" not in lst[h-i-1]:
        n_h-=1
        lst.pop(h-i-1)
n_w=w
lst=list(map(list,lst))
for i in range(w):
    T=True
    for b in range(n_h):
        if lst[b][w-i-1]=="#":
            T=False
            break
    if T:
        for b in range(h):
            lst[b].pop(w-i-1)
            n_w-=1
for b in range(h):
    print("".join(lst[b]))

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
n_h=h
for i in range(len(lst)):
    if "#" not in lst[h-i-1]:
        n_h-=1
        lst.pop(h-i-1)
lst=list(map(list,lst))
for i in range(w):
    T=True
    for b in range(n_h):
        if lst[b][w-i-1]=="#":
            T=False
            break
    if T:
        for b in range(h):
            lst[b].pop(w-i-1)
for b in range(h):
    print("".join(lst[b]))

Submission status: Runtime Error

Solution code:
import numpy as np
h,w=map(int,input().split())
lst=list(list(input()) for i in range(h))
for i in range(len(lst)):
    if "#" not in lst[h-i-1]:
        lst.pop(h-i-1)
lst=np.array(lst)
lst=np.rot90(lst,k=-1).tolist()
for i in range(len(lst)):
    if "#" not in lst[w-i-1]:
        lst.pop(w-i-1)
lst=np.array(lst)
lst=np.rot90(lst,k=1).tolist()
for b in range(h):
    print("".join(lst[b]))

Submission status: Runtime Error

Solution code:
import numpy
h,w=map(int,input().split())
lst=list(input() for i in range(h))
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
lst=numpy.rot90(lst,k=1)
for a in lst:
    if a=="."*h:
        lst.remove(a)
lst=numpy.rot90(lst,k=-1)
for b in range(h):
    print(lst[b])

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
lst=list(map(list,lst))
for i in range(w):
    T=True
    if i>w:
        break
    for b in range(h):
        if lst[b][i]!="." :
            T=False
            break
    if T:
        for b in range(h):
            lst[b].pop(i)
        w-=1
for b in range(h):
    print("".join(lst[b]))

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
for i in range(w):
    T=True
    if i>w:
        break
    for b in range(h):
        if lst[b][i]!="." :
            T=False
            break
    if T==True:
        for b in range(h):
            lst[b]="".join(list(lst[b]).pop(i))
            w-=1
for b in range(h):
    print(lst[b])