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

Submission status: Runtime Error

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

new_list = []

H_del = []
W_del = []

#削除する行列の探索
for i in range(W):
    if list[i] == '.'*W:
        W_del.append(i)
    H_stock = ''
    for j in range(H):
        H_stock += list[j][i]
        if H_stock == '.'*H:
            H_del.append(i)

#削除する行列を除いた行列を再作成
for i in range(W):
    if i not in W_del:
        W_list = ''
        for j in range(H):
            if j not in H_del:
                W_list += list[i][j]
        new_list.append(W_list)

#答えを表示
for i in range(len(new_list)):
    print(new_list[i])

Submission status: Runtime Error

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

r = [False] * h
c = [False] * w

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

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

Submission status: Runtime Error

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

r = [False] * h
c = [False] * w

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

for i in range(h):
  if r[i]:
    for j in range(w):
      if c[j]:
        print("{}".format(a[i][j]), end="")
    print()

Submission status: Runtime Error

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

dellist=[]
for i in range(H):
    if "#" not in a[i]:
        dellist.append(i)

for i in dellist:
    del a[i]
dellist_w=[]
for j in range(W):
    s=[]
    for i in range(len(a)):
        s.append(a[i][j])
    if "#" not in s:
        dellist_w.append(j)

for j in dellist_w:
    for i in range(len(a)):
        del a[i][j]

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

Submission status: Runtime Error

Solution code:
"""
B - Grid Compression
ex in )
4 4
##.#
....
##.#
.#.#

ex out)
###
###
.##
"""

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

matrix = []
for h in range(H):
    line = list(input())
    
    line_num = []
    for part in line:
        line_num.append(part)
    
    matrix.append(line_num)

#print(matrix)

cat = 0
for h in range(H):

    leave = False
    for w in range(W):
        
        # 黒ならのこす
        if matrix[h - cat][w] != ".":
            leave = True
            break
    
    if leave is False:
        matrix.pop(h - cat)
        cat += 1
    else:
        pass
        #print(h, "leave")

#print(matrix)

cat = 0
for w in range(W):

    leave = False
    for h in range(len(matrix)):
        
        # 黒ならのこす
        if matrix[h][w - cat] != ".":
            leave = True
            break
    
    if leave is False:
        cat += 1
        for h in range(len(matrix)):
            matrix[h].pop(w)
    else:
        pass
        #print(w, "leave")


for h in range(len(matrix)):
    line = ""
    for w in range(len(matrix[0])):
        line += matrix[h][w]
    print(line)

Submission status: Runtime Error

Solution code:

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

M = []
for i in range(H):
	M.append(raw_input().split())
	
flag_list_H = []
for i in range(H):
	if '#' in M[i]:
		flag_list_H.append(True)
	else:
		flag_list_H.append(False)

flag_list_W = []
for i in range(W):
	flag = False
	for j in range(H):
		if M[j][i]=='#':
			flag=True
	flag_list_W.append(flag)

for i in range(H):
	answer = ""
	for j in range(W):
		if flag_list_H[i] and flag_list_W[j]:
			answer+=M[i][j] + " "
	print answer[:-1]

Submission status: Runtime Error

Solution code:
H,W= map(int,raw_input().split())

M = []
for i in range(H):
	M.append(raw_input().split())
	
flag_list_H = []
for i in range(H):
	if '#' in M[i]:
		flag_list_H.append(True)
	else:
		flag_list_H.append(False)

flag_list_W = []
for i in range(W):
	flag = False
	for j in range(H):
		if M[j][i]=='#':
			flag=True
	flag_list_W.append(flag)

for i in range(H):
	answer = ""
	for j in range(W):
		if flag_list_H[i] and flag_list_W[j]:
		answer+=M[i][j] + " "
	print answer[:-1]

Submission status: Runtime Error

Solution code:
n=int(input())
if n<105:
	print('0')
else:
	if n<135:
		print('1')
	else:
		if n<165:
			print('2')
		else:
			if n<189:
				print('3')
			else:
				print('4')

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

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

Submission status: Runtime Error

Solution code:
H,W=map(int,input().split())
grids = [input() for _ in range(H)]
top,bottom,left,right = -1,-1,-1,-1

for i in range(H):
  for j in range(W):
    if grids[i][j] == '#':
      if top = -1:
        top,bottom = i,i
        left,right = j,j
      else:
        bottom = max(bottom,i)
        left = min(j,left)
        right = max(j,right)
        
for x in range(top,bottom+1):
  print((grids[x])[left:right+1])

Submission status: Runtime Error

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

goodx = [False] * w
goody = [False] * h

for i in range(w):
  for j in range(h):
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(w):
  if goodx[i]:
    for j in range(h):
      if goody[j]:
        print(board[i][j], end='')
    print("")

Submission status: Runtime Error

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

goodx = [False] * w
goody = [False] * h

for i in range(w):
  for j in range(h):
    print("i ={}, j ={}".format(i,j))
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(w):
  if goodx[i]:
    for j in range(h):
      if goody[j]:
        print(board[i][j], end='')
    print("")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
a = [[input().split()] 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()

Submission status: Runtime Error

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

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

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

count = 0
check = []
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            count = 1
            break
    if count == 0:
        check.append(i)
    count = 0

for i in check:
    del a[i]

ck = []
for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '#':
            count = 1
            break
    if count == 0:
        ck.append(i)
    count = 0

for i in ck:
    for j in range(len(a)):
        del a[j][i]

ans = ''
for i in range(len(a)):
    for j in a[i]:
        ans += j
    print(ans)
    ans = ''

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
t=[[j for j in input()] for h in range(H)]
h = [False for i in range(H)]
w = [False for i in range(H)]
for i,v in enumerate(t):
    h[i] = v.count('#') != 0
for i, v in enumerate(list(map(list, zip(*t)))):
    w[i] = v.count('#') != 0

for i,x in enumerate(h):
    end=''
    for j,y in enumerate(w):
        if x and y:
            print(t[i][j],end='')
            end='\n'
    print(end=end)

Submission status: Runtime Error

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

for x in range(W):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)
W = len(mas)
for y in range(H):
    deltag = False
    for x in range(W):
        if mas[x][y] == "#":
            break
        if x == W-1:
            deltag = True
    deltags.append(deltag)

for x in range(W):
    for y in range(H):
      if deltags[y]:
        mas[x][y] = "A"

for x in range(W):
    for y in range(H):
      while "A" in mas[x]:
        mas[x].remove("A")
    print("".join(mas[x]))

Submission status: Runtime Error

Solution code:
# splitで分割
# stripで空白56す
H,W = map(int, input().split())
grid = []
for j in range(H):
  grid.append(input())  # grid = [ [...], ... , [...] ]
 
for i in range(W):
  flag = 0
  for j in range(H):
    if grid[i][j] == "#":
      flag == 1
  if flag == 0:
     for j in range(H):
       del grid[i][j]
 
for j in range(H):
  flag = 0
  for i in range(W):
    if grid[i][j] == "#":
      flag == 1
    if flag == 0:
      for i in range(W):
        del grid[i][j]
 
print(grid)

Submission status: Runtime Error

Solution code:
# splitで分割
# stripで空白56す
H,W = map(int, input().split())
grid = []
for j in range(H):
    array = list(map(str, input().split()))
    grid.append(array)  # grid = [ [...], ... , [...] ]

for i in range(W):
  flag = 0
  for j in range(H):
    if grid[j][i] == "#":
      flag == 1
  if flag == 0:
     for j in range(H):
       del grid[j][i]

for j in range(H):
  flag = 0
  for i in range(W):
    if grid[j][i] == "#":
      flag == 1
    if flag == 0:
      for i in range(W):
        del grid[j][i]

print(grid)

Submission status: Runtime Error

Solution code:
H, W = input().split()
H = int(H)
W = int(W)

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

a = [i for i in a if "#" in i]
b = ["".join([for a[i]]) for i in range(H) for j in a]
b = [i for i in b if "#" in i]

a = ["".join([for a[i]]) for i in range(len(b)) for j in b]

for i in a:
  print(i)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split(" "))

tate = []
for tatezero in range(W):
  tate.append(0)
  
count = 0  
result = []

for i in range(H):
  yoko = input()
  flag1 = 0
  flag2 = 0
  yokoid = 0
  while(flag2 == 0):
    if yoko[yokoid] == "#":
      flag1 = 1
      tate[yokoid] = 2
    elif yoko[yokoid] == ".":
      if tate[yokoid] == 0:
        tate[yokoid] = 1      
    yokoid += 1
    if yokoid == W:
      flag2 = 1
  if flag1 == 1:
    result.append(list(yoko))
    count += 1

tatedel = []
for check in range(len(tate)):
  if tate[check] == 1:
    tatedel.append(check)

if count != 1:
  for del1 in range(len(tatedel)):
    for del2 in range(count):
      del result[del2][tatedel[del1]]
  for z in range(count):
    pri = "".join(result[z])
    print(pri)
else:
  delcount = 0
  pri = ""
  for er in range(W):
    if er != tatedel[delcount]:
      pri += result[0][er]
    else:
      delcount += 1
  print(pri)

Submission status: Runtime Error

Solution code:
row_num, col_num = (int(i) for i in input().split())
matrix = [ list(input()) for i in range(row_num)]
transpose_matrix = []
for i in range(row_num):
    transpose_matrix.append([])
    for j in range(col_num):
        transpose_matrix[i].append(matrix[j][i])

empty_rows = []
# row check
for i,line in enumerate(matrix):
    if '#' in line:
        continue
    empty_rows.append(i)
empty_cols = []
# col check
for i,line in enumerate(transpose_matrix):
    if '#' in line:
        continue
    empty_cols.append(i)

for i in range(row_num):
    if i in empty_rows:
        continue
    for j in range(col_num):
        if j in empty_cols:
            continue
        print(matrix[i][j],end="")
    print()

Submission status: Runtime Error

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


for index, i in enumerate(a):
    if i == '.'*W:
        a.remove('.'*W)


aa = list(map(list, zip(*a)))


for index, i in enumerate(aa):
    if i == ['.']*len(aa[0]):
        aa.remove(tamesi)

aaa = list(map(list, zip(*aa)))

for i in aaa:
    print(''.join(i))

Submission status: Runtime Error

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

input_list = []

del_list1 = []
del_list2 = []

for i in range(0,H):
    input_list.append(list(input()))
for i in range(len(input_list)):
    if input_list[i][0] == input_list[i][1]:
        count = 0
        for j in range(len(input_list[0])):
            if input_list[i][0] == input_list[i][j]:
                count += 1
        if count == len(input_list[i]):
            del_list1.append(i)

for i in range(len(input_list[0])):
    if input_list[0][i] == input_list[1][i]:
        count = 0
        for j in range(len(input_list)):
            if input_list[0][i] == input_list[j][i]:
                count += 1
        if count == len(input_list):
            del_list2.append(i)


for i in del_list1:
    input_list.pop(i)


for i in reversed(del_list2):
    for tmp in input_list:
        tmp.pop(i)

for i in input_list:
    for j in i:
        print(j, end="")
    print()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

if H == 1 and W == 1:
    print(S)
    exit()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

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

Submission status: Runtime Error

Solution code:
import numpy as np
H,W = list(map(int,input().split()))

bw_str = []
for i in range(H):
    bw_str.append(input())

del_v = np.zeros(H)

for i in range(H):
    tmp = []
    for j in range(W):
        tmp.append(bw_str[j][i])
    if  (tmp.count('.') == 0) or \
        (tmp.count('#') == 0):
        del_v[i] = 1
    
del_h = np.zeros(W)
for i in range(W):
    if  (bw_str[i].count('.') == 0) or \
        (bw_str[i].count('#') == 0):
        del_h[i] = 1

list_ap_row = [i for i, a in enumerate(del_v) if a == 0]
list_ap_col = [i for i, a in enumerate(del_h) if a == 0]


for i in range(len(list_ap_col)):
    tmp_ans = []
    for j in range(len(list_ap_row)):
        tmp_ans.append(bw_str[i][j])
    print(''.join(tmp_ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

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

Submission status: Runtime Error

Solution code:
\import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
if(w!=1):
    for i in range(h):
        if(len(set(tmp[i]))==1 and tmp[i][0]!="#"):
            ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
if(h!=1):
    for i in range(w):
        if(len(set(tmp[i]))==1 and tmp[i][0]!="#"):
            ans2.append(i)
# print(ans1,ans2)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Submission status: Runtime Error

Solution code:
import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
if(w!=1):
    for i in range(h):
        if(len(set(tmp[i]))==1):
            ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
if(h!=1)
    for i in range(w):
        if(len(set(tmp[i]))==1):
            ans2.append(i)
# print(ans1,ans2)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Submission status: Runtime Error

Solution code:
import math



H,W=(int(i) for i in input().split())
li=[]
for i in range(0,H):
    li2=[]
    S1=input()
    for j in range(0,W):
        li2.append(S1[j])
        #print(li2)

    li.append(li2)
    
#print(li)
Flag=False
#横探索
for i in range(0,H):
    
    for j in range(0,W):
        if (li[i][j]=="." or li[i][j]=="Remove"):
            Flag=True
        else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,W):
            li[i][j]="Remove"
          


    
#横探索
for i in range(0,W):
    
    for j in range(0,H):
         if (li[j][i]=="." or li[j][i]=="Remove"):
            Flag=True
         else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,H):
            li[j][i]="Remove"
       
for i in range(0,H):
    for j in range(0,W):
        if (li[i][j]=="Remove"):
            li[i][j]=""

#print("ans")
for i in range(0,H):
    for j in range(0,W):
        if (li[j][i]=="."):
            Flag=True
        else:
            Flag=False
        print(str(li[i][j]),end="")

    if Flag==False:
        print("")

Submission status: Runtime Error

Solution code:
#include <iostream>
#define MAX 111
using namespace std;

int main() {
    static int m, n;
    static char a[MAX][MAX];
    static bool row[MAX], col[MAX];
    cin >> m >> n;
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
            if (a[i][j] == '#')
                row[i] = true, col[j] = true;
        }
    for (int i = 0; i < m; ++i) {
        if (row[i]) {
            for (int j = 0; j < n; ++j)
                if (col[j])
                    cout << a[i][j];
            cout << endl;
        }
    }
    
    return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
for i in range(w):
    if(len(set(tmp[i]))==1):
        ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
for i in range(w):
    if(len(set(tmp[i]))==1):
        ans2.append(i)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
aw = []
for H in range(H):
    a = input()
    a = [x for x in a]
    aw.append(a)
aa = []
for i in range(H):
    aa.append('.')
bb = []
for i in range(W):
    bb.append('.')
gyou_hyoka = []
for i in range(H):
    if aw[i:i+1] == [bb]:
        gyou_hyoka.append(i)
    else:
        pass
retu_hyoka = []
for i in range(W):
    if [l[:i+1] for l in aw] == [aa]:
        retu_hyoka.append(i)
    else:
        pass
for i in gyou_hyoka:
    del aw[i]
for i in retu_hyoka:
    for j in range(len(aw)):
        del aw[j][i]
for i in range(len(aw)):
    print(''.join(aw[i]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys
h,w=map(int,input().split())

b=[]
d=[]
for i in range(w):
    d.append(i)

for i in range(h):
    a=input()
    if a!="."*w:
        b.append(a)
    else:
        h-=1
        
for i in range(w):
    c=0
    for j in range(h):
        if b[j][i]=="#":
            c+=1
    if c==0:
        del(d[i])
            
for i in range(h):
    for j in d:
       sys.stdout.write(b[i][j]) 
    print("")

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
#S = input()

def show(array):
    for row in array:
        print(row)

a = []
for _ in range(H):
    a.append(input())


tmp_a = []
for row in a:
    if len(set(row)) != 1:
        tmp_a.append(row)

if len(tmp_a) == 1:
    for col in tmp_a:
        if col == "#":
            print(col, end="")
    exit()

#show(tmp_a)
skip = []
for j in range(W):
    for i in range(len(tmp_a)-1):
        if tmp_a[i][j] != tmp_a[i+1][j]:
            break
    else:
        if tmp_a[0][j] == ".":
            skip.append(j)

#print(skip)

for i in range(len(tmp_a)):
    for j in range(W):
        if j not in skip:
            print(tmp_a[i][j], end="")
    print()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
l = []
m = []
for i in range(h):
    l.append(list(input()))
for i in l:
    if i.count('#') >= 1:
        m.append(i)
c = [0] * w
for i in range(w):
    for j,k in enumerate(m):
        if m[j][i] == "#":
            c[i] += 1
for i,j in enumerate(m):
    for k in range(w):
        if c[k] == 0:
            del m[i][k]
for i in m:
    print(*i,sep='')

Submission status: Runtime Error

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


matrix_1 = []
for i in range(H):
    if matrix[i] != "." * W:
        matrix_1.append(matrix[i])


matrix_2 = []
for i in range(W):
    a = ""
    for l in range(len(matrix_1)):
        a += matrix_1[l][i]
    matrix_2.append(a)


ans = []
k = len(matrix_1)
for i in range(W):
    if matrix_2[i] != "." * k:
        ans.append(matrix_2[i])


ans_2 = []
for i in range(len(ans)):
    a = ""
    for l in range(len(ans[0])):
        a += ans[l][i]
    ans_2.append(a)


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

Submission status: Runtime Error

Solution code:
ip = input().split()
data = []
for i in ip:
    data.append(int(i))

H = data[0]
W = data[1]

array = []

for i in range(H):
    ip = input()
    data = []
    for j in ip:
        data.append(j)
    array.append(data)

#array is completed#
count = 0

# 縦
# convert
carray = []
for q in range(W):
    carray.append([])

for p in array:
    for q in range(len(p)):
        carray[q].append(p[q])

# judge
for p in carray:
    if len([i for i in p if i == "."]) == len(p):
        for r in range(H):
            del array[r][count]
    count += 1

#横
count = 0
for p in array:
    if len([i for i in p if i == "."]) == len(p):
        del array[count]
    count += 1

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

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
#S = input()

def show(array):
    for row in array:
        print(row)

a = []
for _ in range(H):
    a.append(input())


tmp_a = []
for row in a:
    if len(set(row)) != 1:
        tmp_a.append(row)


#show(tmp_a)
skip = []
for j in range(W):
    for i in range(len(tmp_a)-1):
        if tmp_a[i][j] != tmp_a[i+1][j]:
            break
    else:
        if tmp_a[0][j] == ".":
            skip.append(j)

#print(skip)

for i in range(len(tmp_a)):
    for j in range(W):
        if j not in skip:
            print(tmp_a[i][j], end="")
    print()

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
x = []
p = []
for _ in range(a):
    y = list((input()))
    x.append(y)

for i in range(b):
    z = 0
    for j in x:
        if j[i] == "#":
            z = 1
            continue
    if z == 0:
        p.append(i)

for i in p:
    for k in x:
        del k[i]       


for i in x:
    if "#" not in i:
        continue
    else:
        print("".join(i))

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
li = [input() for i in range(H)]
num_lists = []
for i in range(H):
    if "#" in li[i]:
    else :
        num_lists.append(i)
for i in reversed(num_lists):
    li.pop(i)
print(li)

Submission status: Runtime Error

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

for _ in range(b):
    y = list((input()))
    if y == ["."]*b:
        a -= 1
        continue
    else:
        x.append(y)

for i in range(a):
    z = 0
    for j in x:
        if j[i] == "#":
            z = 1
            continue
    if z == 0:
        for k in x:
            del k[i]


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

Submission status: Runtime Error

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

for _ in range(a):
    y = list((input()))
    if y == ["."]*b:
        a -= 1
        continue
    else:
        x.append(y)

for i in range(a):
    z = 0
    for j in x:
        if j[i] == "#":
            z = 1
            continue
    if z == 0:
        for k in x:
            del k[i]


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

Submission status: Runtime Error

Solution code:
#include<iostream>
#define MAX_H 101
#define MAX_W 101
using namespace std;

char grid[MAX_H][MAX_W];
bool tate[MAX_W], yoko[MAX_H];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    for (int i = 0; i < H; i++) yoko[i] = false;
    for (int i = 0; i < W; i++) tate[i] = false;
    for (int i = 0; i < H; i++) {
        bool flag = true;
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') flag = false;
        }
        if (flag) yoko[i] = true;
    }
    for (int i = 0; i < W; i++) {
        bool flag = true;
        for (int j = 0; j < H; j++) {
            if (grid[j][i] == '#') flag = false;
        }
        if (flag) tate[i] = true;
    }
    for (int i = 0; i < H; i++) {
        if (yoko[i]) continue;
        for (int j = 0; j < W; j++) {
            if (tate[j]) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}