Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02678 (python)

Fixed submission:
N, M = list(map(int, input().split()))

room_dict = {i+1:[] for i in range(N)}
for _ in range(M):
  _a, _b = list(map(int, input().split()))
  room_dict[_a].append(_b)
  room_dict[_b].append(_a)

rooms = set(room_dict.keys())
s_dict = {i+1:None for i in range(1, N)}
traversed_rooms = set([1])

now_rooms = [1]
from operator import add
while now_rooms:
    next_rooms = set()
    for _room in now_rooms:
        traversed_rooms.add(_room) # 訪問済みを保存
        _n_rooms  = [i for i in room_dict[_room] 
                         if (not i in traversed_rooms) and (s_dict[i] is None)]
        for n_room in _n_rooms:
            next_rooms.add(n_room) # 今の次の階層を、次のiteration用に入れる
            s_dict[n_room] = _room # 次の階層は、今の階層への道標を置けば十分
    now_rooms = [i for i in next_rooms if not i in traversed_rooms] # まだ訪れてない部屋を探す
    
print('Yes') # 常に答えは存在する

for i in range(2, N+1):
    print(s_dict[i])

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

room_dict = {i+1:[] for i in range(N)}
for _ in range(N):
  _a, _b = list(map(int, input().split()))
  room_dict[_a].append(_b)
  room_dict[_b].append(_a)

rooms = set(room_dict.keys())
s_dict = {i+1:None for i in range(1, N)}
traversed_rooms = set([1])

now_rooms = [1]
from operator import add
while now_rooms:
    next_rooms = set()
    for _room in now_rooms:
        traversed_rooms.add(_room) # 訪問済みを保存
        _n_rooms  = [i for i in room_dict[_room] 
                         if (not i in traversed_rooms) and (s_dict[i] is None)]
        for n_room in _n_rooms:
            next_rooms.add(n_room) # 今の次の階層を、次のiteration用に入れる
            s_dict[n_room] = _room # 次の階層は、今の階層への道標を置けば十分
    now_rooms = [i for i in next_rooms if not i in traversed_rooms] # まだ訪れてない部屋を探す
    
print('Yes') # 常に答えは存在する

for i in range(2, N+1):
    print(s_dict[i])
Problem p02717 (python)

Fixed submission:
x, y, z = map(int, input().split())
print(z, x, y)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())

m_1 = n % k
m_2 = k - m_1
print(min(m_1, m_2))
Problem p02720 (python)

Fixed submission:
from collections import deque

k = int(input())
count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(l)

Buggy submission (verdict: Runtime Error):
k = int(input())

count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(q[k-1])

Buggy submission (verdict: Runtime Error):
K = int(input())

from itertools import product
d = {}
num_list = []
for i in range(10):
    nums = set([min((i-1)%10, i), i, max((i+1)%10, i)])
#     nums = set([i, min(10-(i-1)%10, i),max((i+1)%10, i)])
    nums = [str(el) for el in nums]
    d[i] = list(product([str(i)], list(nums)))
    d[i] = [int(''.join(el)) for el in d[i]]
    d[i] = ['{:02}'.format(el) for el in d[i]]
    
    num_list.extend(d[i])
num_list = sorted(num_list)
dd = [None, None, d, 
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(10)}]

def gen_2ll():
    count = 0
    ret = 0
    while int(ret)!=99:
        if int(ret)< 9 :
            ret += 1
            count += 1
            yield ret
        else:
            for i in range(1,10):
                for ret in d[i]:
                    count += 1
                    yield ret

ll2_list = list(gen_2ll())
                   
def get_digit_top_list(num_digit, top_num):
    ret = dd[num_digit][top_num]
    if ret:
        return ret

    second_nums = sorted(set([min((top_num-1)%10, top_num), top_num, max((top_num+1)%10, top_num)]))    
    for second_num in second_nums:
        rem_nums = get_digit_top_list(num_digit-1, int(second_num))
        for rem_num in rem_nums:
            ll = str(top_num) + rem_num
            ret.append(ll)
    dd[num_digit][top_num] = ret

    
    return ret

def get_ll(K):

def get_kth_ll(K):
    if K<=len(ll2_list):
        print(ll2_list[K-1])
    else:
        K -= len(ll2_list)
        for num_digit in range(3,100):
            for top_num in range(1,10):
                _ll_list = get_digit_top_list(num_digit, top_num)
                if K-len(_ll_list)<0:
                    print(sorted([int(el) for el in _ll_list])[K])
                else:
                    K -= len(_ll_list)
get_kth_ll(K)
Problem p02724 (python)

Fixed submission:
x = int(input())
 
print(x//500*1000 + (x%500)//5*5)

Buggy submission (verdict: Runtime Error):
x = input()

print(x//500*1000 + (x%500)//5*5)
Problem p03370 (python)

Fixed submission:
n, x = map(int, input().split())
m_list = []
for _ in range(n):
  m_list.append(int(input()))

print(n + (x - sum(m_list))//min(m_list))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
m_list = []
for _ in range(n):
  m_list.append(int(input()))

print(n + (x - sum(x_list))//min(x_list))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
m_list = []
for _ in range(n):
  m_list.append(int(input())

print(n + (x - sum(x_list))//min(x_list))
Problem p02675 (python)

Fixed submission:
N=str(input())
a=list(map(int,N))
A=a[-1]
if A==3:
  print("bon")
  exit()
if A==2 or A==4 or A==5 or A==7 or A==9:
  print("hon")
  exit()
print("pon")

Buggy submission (verdict: Runtime Error):
N=list(input())
if N[-1]=="2","4","5","7","9":
  print("hon")
elif N[-1]=="3":
  print("bon")
else:
  print("pon")
Problem p02694 (python)

Fixed submission:
import math
X=int(input())
a=0
o=100
while True:
  o*=1.01
  o=math.floor(o)
  a+=1
  if o>=X:
    print(a)
    break

Buggy submission (verdict: Runtime Error):
import math
X=int(input())
a=0
o=100
while True:
  o*=1.01
  o=math.floor()
  a+=1
  if o>=X:
    print(a)
    break
Problem p02795 (python)

Fixed submission:
H=int(input())
W=int(input())
N=int(input())
B=max(H,W)
ans=(N+B-1)//B
print(ans)

Buggy submission (verdict: Runtime Error):
H,W,N=map(int,input().split())
B=max(H,W)
ans=(N+B-1)//B
print(ans)
Problem p02853 (python)

Fixed submission:
X,Y=map(int,input().split())
ans=0
if X==1:
  ans+=300000
if X==2:
  ans+=200000
if X==3:
  ans+=100000
if Y==1:
  ans+=300000
if Y==2:
  ans+=200000
if Y==3:
  ans+=100000
if X==1 and Y==1:
  ans+=400000
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
dif=9999999999999999999
x=-1
ans=0
for i in range(N):
  long=abs(sum(A[i+1:])-sum(A[:i+1]))
  if long<dif:
    dif=long
    x=i+1
pl=max(sum(A[:x]),sum(A[x:]))
mi=min(sum(A[:x]),sum(A[x:]))
while mi<pl:
  mi+=1
  ans+=1
  if mi==pl:
    break
print(ans)
Problem p02882 (python)

Fixed submission:
from math import atan2,degrees
a,b,x=map(int,input().split())
if 2*x<=b*a*a:
  print(90-degrees(atan2(2*x,a*b*b)))
else:
  print(90-degrees(atan2(a*a*a,2*(a*a*b-x))))

Buggy submission (verdict: Runtime Error):
from math import atan2,degrees
a,b,x=map(int,input().split())
if 2*x<=b*a*a:
  print(90-degrees(atan2(2*x,a*b*b)))
else:
  print(90-degrees(atan2(a*a*a,2*(a*a*b-x)))
Problem p02913 (python)

Fixed submission:
N=int(input())
S=input()
a=i=j=0
while j<N:
  t=S[i:j]
  if t in S[j:]:
    a=max(a,len(t))
    j+=1
  else:
    i+=1
print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
a,i,j=0
while j<N:
  t=S[i:j]
  if t in S[j:]:
    a=max(a,len(t))
    j+=1
  else:
    i+=1
print(a)
Problem p02922 (python)

Fixed submission:
A,B=map(int,input().split())
print((B-2)//(A-1)+1)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
x=((B-1)//A+1)
all=A*x
use=x
notuse=all-use
if notuse<B:
    add=(B-notuse-1)//A+1
print(x+add)
Problem p02939 (python)

Fixed submission:
S = input()

if len(S) == 1:
    print(1)
    exit(0)

now = S[0]
k = 1
l = 2
ans = 1
while k < len(S) and l <= len(S):
    while S[k:l] == now:
        l += 1
        if l == len(S)+1:
            if now == S[k:l]:
                ans -= 1
            break
    now = S[k:l]
    k = l
    l = k+1
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
l=len(S)

C=[]
for i in range(l):
  for j in range(l+1):
    C.append(S[i:j])
C2=[x for x in C if x]
li=[]
s=0
for k in range(l):
  g=s+l-k
  li.append(C2[s:g])
  s=g
print(l)
Problem p02953 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))[::-1]
ans="Yes"
for i in range(N-2):
  if H[i]-H[i+1]>=0:
    continue
  elif H[i]-H[i+1]==-1:
    H[i+1]-=1
  else:
    ans="No"
    break
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
ans="Yes"
for i in range(N):
  if H[i+1]-H[i]>=0:
    continue
  elif H[i+1]-H[i]==-1:
    if H[i]-1>=H[i-1]:
      H[i]-=1
      continue
    else:
      ans="No"
      break
  else:
    ans="No"
    break
print(ans)
Problem p02958 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
AA=sorted(A)
li=[]
for i in range(N):
  if A[i]!=AA[i]:
    li.append(A[i])
if len(li)>2:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
li=[]
for i in range(N):
  if A[i]!=AA[i]:
    li.append(A[i])
if len(li)>2:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
AA=sorted(A)
li=[]
li_i=[]
for i in range(len(A)):
  if A[i]!=AA[i]:
    li_i.append(i)
    li.append(A[i])
    if len(li_i)>2:
      ans="NO"
      break
s=li_i[0]
t=li_i[1]
A[s]=li[1]
A[t]=li[0]
if A==AA:
  ans="YES"
else:
  ans="NO"
print(ans)
Problem p02981 (python)

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
R=min(R, L+673)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    mod=(i*j)%2019
    if mod==0:
      break
    li.append(mod)
print(min(li))
Problem p02982 (python)

Fixed submission:
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        s = sum((X[i][d] - X[j][d])**2 for d in range(d))
        if any(k**2 == s for k in range(1000)):
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    s = sum((X[i][d] - X[j][d])**2 for d in range(d))
      if (s ** .5).is_integer():
        ans += 1
print(ans)
Problem p02983 (python)

Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      if i*j>=2019**2:
        break
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    while i*j<2019**2:
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))
Problem p02988 (python)

Fixed submission:
N = int(input())
P = [int(x) for x in input().split()]
#とりまリストに入れる。
answer = 0
for i in range(1,N-1):
  #iがN-2まででいい理由は次行で最終項目までカバーするから
  a,b,c = P[i-1:i+2]
  if b != min(a,b,c) and b != max(a,b,c):
    #三つのうち真ん中というのは最大でも最小でもないということ。
    answer += 1

print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
P= [int(x) for x in input().split]

answer=0
for i in range(1,N-1):
  a,b,c=P[i-1:i+2]
  if b != max(a,b,c) and b!= min(a,b,c):
    answer+=1

print(answer)
Problem p02999 (python)

Fixed submission:
X,A = map(int,input().split())
if X < A:print(0)
else:print(10)

Buggy submission (verdict: Runtime Error):
X, A = map(int,input().split())
print(0) if X < A
print(10) if X >= A
Problem p03029 (python)

Fixed submission:
a,p = map(int,input().split())
print((3*a+p)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
list=[]
for i in range(n):
  s,p=input().split()
  list.append((s, -int(p), i+1))
list.sort()
for s,p,i in list:
  print(i)
Problem p03059 (python)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""

Buggy submission (verdict: Runtime Error):
n=int(input())
listv=[int(x) for x in input().split()]
listc=[int(y) for y in input().split()]
values=[x - y for (x, y) in zip(listv, listc)]
ans = 0
for i in values:
  if i>0:
    ans+=i
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
c = t // a
if t >= a:print(b*c)
else:print(0)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
c = t//a
if t >= a:print(b*c)
else:print(0)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
if t >= a:print((t//a)*b)
else:print(0)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
if t >= a:print(b*(t//a))
else:print(0)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
if t > a:print(b*(t//a))
else:print(0)
Problem p03067 (python)

Fixed submission:
A,B,C=map(int,input().split())
ans="No"
if A>B:
  if B<C and C<A:
    ans="Yes"
elif A<B:
  if A<C and C<B:
    ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
ans="No"
if A>B:
  if B<C and C<A:
    ans="Yes"
elif A<B:
    if A<C and C<B:
    ans="Yes"
print(ans)
Problem p03069 (python)

Fixed submission:
N=int(input())
S=input()
b=0
w=S.count(".")
ans=b+w
for s in S:
  if s=="#":
    b+=1
  else:
    w-=1
  ans=min(ans, b+w)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
b=0
w=S.count(".")
ans=b+w
for s in S:
  if s=="#":
    b+=1
  else:
	w-=1
  ans=min(ans, b+w)
print(ans)
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
if a== b:print(a+b)
else:print(2*(a+b -min(a,b))-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(a+b, 2*a-1, 2*b-1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a!= b:print(2*(a+b -min(a,b))-1)
else:print(2a-1)
Problem p03085 (python)

Fixed submission:
dna={"A":"T", "T":"A", "C":"G", "G":"C"}
print(dna[input()])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
li=[]
t=0
for i in range(1,N):
  if S[i-1:i+1]=="AC":
      t+=1
  li.append(t)
for _ in range(Q):
  l,r=map(int,input().split())
  print(li[r-1]-li[l-1])
Problem p03086 (python)

Fixed submission:
s=input()
n=len(s)
list=["A","C","G","T"]
new=[]
a=0
for i in range(n):
  if s[i] in list:
    a+=1
    if i == n-1:
      new.append(a)
  if s[i] not in list:
    new.append(a)
    a=0
print(max(new))

Buggy submission (verdict: Runtime Error):
s=input()
list=["A","C","G","T"]
new=[]
a=0
for i in s:
  if i in list:
    a+=1
  if i not in list:
    new.append(a)
    a=0
print(max(new))
Problem p03105 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(min(b//a,c))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(min(b//a, c)
Problem p03111 (python)

Fixed submission:
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
if cur == N:
return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Problem p03140 (python)

Fixed submission:
N=int(input())
A=input()
B=input()
C=input()
ans=0
for i in range(N):
  ans+=len(set([A[i],B[i],C[i]]))-1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=input()
B=input()
C=input()
ans=0
for i in range(N):
  ans+=len(set(A[i],B[i],C[i]))-1
print(ans)
Problem p03145 (python)

Fixed submission:
ab,bc,ca=map(int,input().split())
print(ab*bc//2)

Buggy submission (verdict: Runtime Error):
s=int(input())
li=[s]
for i in range(1000000):
  if s%2==0:
    s=s//2
  else:
    s=3*s+1
  if s in li:
    print(i+2)
    break
  li.append(s)
Problem p03147 (python)

Fixed submission:
N=int(input())
h=list(map(int, input().split()))
c=i=0
while sum(h)>0:
  if h[i]>0:
    j=i
    c+=1
    while j<N and h[j]>0:
      h[j]-=1
      j+=1
  else:
    i+=1
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
h=[0]+list(map(int,input().split()))
c=0
for i in range(N):
  c+=max(h[i+1]-l[i],0)
print(c)
Problem p03231 (python)

Fixed submission:
N,M=map(int,input().split())
S=input()
T=input()
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
g=gcd(N,M)
L=N*M//g
if all(S[i*N//g]==T[i*M//g]for i in range(g)):
  print(L)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, S: str, T: str):
    # from math import gcd
    from fractions import gcd

    def lcm(a: int, b: int):
        return (a * b) // gcd(a, b)

    l = lcm(N, M)

    x = [''] * l

    for i in range(N):
        x[i*(l//N)] = S[i]

    for i in range(M):
        if(x[i*(l//M)] != '' and x[i*(l//M)] != T[i]):
            print(-1)
            exit()
        else:
            x[i*(l//M)] = T[i]

    

    print(l)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, M, S, T)

if __name__ == '__main__':
    main()
Problem p03273 (python)

Fixed submission:
H,W=map(int,input().split())
L=[list(input()) for _ in range(H)]
L=[l for l in L if "#" in l]
#リストの中のリストで#を含まないリストは取り除く
LL=list(zip(*L))
#同じサブインデックスをもつ要素からなる配列を作る
LL=[l for l in LL if "#" in l]
L=list(zip(*LL))
for l in L:
  print("".join(l))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
l=[input() for i in range(h)]
li=[]
li4=[]
for L in l:
  if (L=="."*w):
    continue
  li.append(L)
  li2=[list(x) for x in zip(*li)]
  ll=len(li2[0])
for i in range(h):
  li3=[''.join(li2[i])]
  for L in li3:
    if (L=="."*ll):
      continue
    li4.append(L)
    li5=[list(x) for x in zip(*li4)]
for i in range(ll):
  li6=[''.join(li5[i])]
  for L in li6:
    print(L)
Problem p03289 (python)

Fixed submission:
S=input()
ans="WA"
for i in range(len(S)):
  if S[i]=="A" and S[2:-1].count("C")==1:
    s=S.find("C",2,-1)-1
    SS=S[1:]
    SS=SS[:s]+SS[s+1:]
    if SS.islower() is True:
      ans="AC"
      break
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
ans="WA"
if S[0]=="A" and S[2:-1].count("C")==1:
  s=S.find("C",2,-1)-
  SS=S[1:s]+S[s+1:]
  if SS.islower() is True:
    ans="AC"
print(ans)
Problem p03292 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(max(a,b,c) - min(a,b,c))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
abc = sorted(list(n))
print(max(abc) - min(abc))
Problem p03296 (python)

Fixed submission:
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(1,n):
  if li[i] == li[i-1]:
    li[i] = 0
    a+=1
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(1,n):
  if li[i] == li[i+1]:
    li[i] = 0
    a+=1
print(a)
Problem p03324 (python)

Fixed submission:
D,N=map(int, input().split())
x=100**D
ans=x*N
if N==100:
  ans+=x
  #N=100の時は100で割り切れてしまうから、N=101にする
print(ans)

Buggy submission (verdict: Runtime Error):
D,N=map(int, input().split())
ans=0
if D==0:
  ans=N
elif D==1:
  ans=100*N
elif D==2:
  ans=10000*N
if N==100 ans D==2:
  ans+=ans
  #N=100の時は100で割り切れてしまうから、N=101にする
print(ans)
Problem p03378 (python)

Fixed submission:
n,m,x=map(int,input().split())
A=[int(x) for x in input().split()]
start=0
goal=0
for i in range(x, n+1):
  for a in A:
    if i ==a:
      start+=1
for j in range(x):
  for a in A:
    if j ==a:
      goal+=1
print(min(start, goal))

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
A=[int(input()) for _ in range(m)]
start=0
goal=0
for i in range(x, n+1):
  for a in A:
    if i ==a:
      start+=1
for j in range(x):
  for a in A:
    if i ==a:
      goal+=1
print(min(start, goal))
Problem p03385 (python)

Fixed submission:
s=sorted(input())
if s == list("abc"):print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
set(li2)
for ll in li2:
  print(ll)
Problem p03386 (python)

Fixed submission:
A,B,K=map(int,input().split())
li=[]  
for i in range(A,A+K):
  li.append(i)
for j in range(B-K+1,B+1):
  li.append(j)
ans=sorted(set(li))
for l in ans:
  if A<=l<=B:
    print(l)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
li3=sorted(set(li2))
for ll in li3:
  print(ll)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
set(li2)
for ll in li2:
  print(ll)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
for ll in li2:
  print(set(li2))
Problem p03423 (python)

Fixed submission:
print(int(input())//3)

Buggy submission (verdict: Runtime Error):
N=int(input())
n=[input()[0] for _ in range(N)]
m,a,r,c,h=n.count("M"),n.count("A"),n.count("R"),n.count("C"),n.count("H")
print(m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h)

Buggy submission (verdict: Runtime Error):
N=int(input())
name=[input()[0] for _ in range(N)]
m,a,r,c,h=name.count("M"),name.count("A"),name.count("R"),name.count("C"),name.count("H")
print(m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h)