Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
DP = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(1,W+1):
    DP[i][j] = max(DP[i][j],DP[i-1][j])
    if j-wv[i-1][0] >= 0:
      DP[i][j] = max(DP[i][j],DP[i-1][j-wv[i-1][0]]+wv[i-1][1])
print(DP[-1][-1])

Fixed submission:
import sys
input = sys.stdin.readline
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
DP = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(1,W+1):
    DP[i][j] = max(DP[i][j],DP[i-1][j])
    if j-wv[i-1][0] >= 0:
      DP[i][j] = max(DP[i][j],DP[i-1][j-wv[i-1][0]]+wv[i-1][1])
print(DP[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
DP = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(1,W+1):
    DP[i][j] = max(DP[i][j],DP[i-1][j])
    if j-wv[i-1][0] >= 0:
      DP[i][j] = max(DP[i][j],DP[i-1][j-wv[i-1][0]]+wv[i-1][1])
print(DP[-1][-1])

Fixed submission:
import sys
input = sys.stdin.readline
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
DP = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(1,W+1):
    DP[i][j] = max(DP[i][j],DP[i-1][j])
    if j-wv[i-1][0] >= 0:
      DP[i][j] = max(DP[i][j],DP[i-1][j-wv[i-1][0]]+wv[i-1][1])
print(DP[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
path = [0 for i in range(n+1)]
for a,b in ab:
  graph[b].append(a)
  path[a] = -1
stack = []
for i in range(1,n+1):
  if path[i] == 0:
    stack.append(i)
    while stack:
      x = stack.pop()
      for y in graph[x]:
        if path[x]+1 > path[y]:
          stack.append(y)
          path[y] = path[x]+1
print(max(path))

Fixed submission:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
path = [0 for i in range(n+1)]
con = [0 for i in range(n+1)]
for a,b in ab:
  graph[b].append(a)
  path[a] = -1
  con[a] += 1
stack = []
for i in range(1,n+1):
  if path[i] == 0:
    stack.append(i)
    while stack:
      x = stack.pop()
      for y in graph[x]:
        path[y] = max(path[y],path[x]+1)
        con[y] -= 1
        if con[y] == 0:
          stack.append(y)
print(max(path))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
c1,c2,c3 = c[1],c[2],c[3]
dp = [[[0 for i in range(c3+1)] for j in range(c2+c3+1)] for k in range(c1+c2+c3+1)]
#dp[i][j][k] := 1個×i皿、2個×j皿、3個×k皿における期待値
for k in range(c3+1):
  for j in range(c2+c3+1):
    for i in range(n+1):
      if i+j+k > n or i == j == k == 0:
        continue
      x = (n-i-j-k)/n
      dp[i][j][k] = 1
      if 0<i :
        dp[i][j][k] += dp[i-1][j][k]*(i/n)
      if 0<j and i+1<=n:
        dp[i][j][k] += dp[i+1][j-1][k]*(j/n)
      if 0<k and j+1<=c2+c3:
        dp[i][j][k] += dp[i][j+1][k-1]*(k/n)
      dp[i][j][k] /= 1-x
print(dp[c1][c2][c3])

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
c1,c2,c3 = c[1],c[2],c[3]
dp = [[[0 for i in range(c3+1)] for j in range(c2+c3+1)] for k in range(c1+c2+c3+1)]
#dp[i][j][k] := 1個×i皿、2個×j皿、3個×k皿における期待値
for k in range(c3+1):
  for j in range(c2+c3+1):
    for i in range(n+1):
      if i+j+k > n or i == j == k == 0:
        continue
      x = (n-i-j-k)/n
      dp[i][j][k] = 1
      if 0<i :
        dp[i][j][k] += dp[i-1][j][k]*(i/n)
      if 0<j and i+1<=n:
        dp[i][j][k] += dp[i+1][j-1][k]*(j/n)
      if 0<k and j+1<=c2+c3:
        dp[i][j][k] += dp[i][j+1][k-1]*(k/n)
      dp[i][j][k] /= 1-x
print(dp[c1][c2][c3])
Buggy python submission (verdict: Runtime Error):
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.values():
  if n<=v:
    ans *= k**(v//n)
print(ans)

Fixed submission:
from collections import Counter
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.items():
  if n<=v:
    ans *= k**(v//n)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.values():
  if n<=v:
    ans *= k**(v//n)
print(ans)

Fixed submission:
from collections import Counter
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.items():
  if n<=v:
    ans *= k**(v//n)
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w,n=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
xy.sort()
cnt=0
ans=h
for i in range(n):
  if x-1>=y+cnt:
    ans=x-1
    break
  elif x==y+cnt:
    cnt+=1
print(ans)


Fixed submission:
h,w,n=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
xy.sort()
cnt=0
ans=h
for x,y in xy:
  if x-1>=y+cnt:
    ans=x-1
    break
  elif x==y+cnt:
    cnt+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 7 or n == 5 or n == 3:
    print(YES)
else:
    print(NO)

Fixed submission:
n = int(input())
if n == 7 or n == 5 or n == 3:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 7 or n == 5 or n == 3:
  print(YES)
else:
  print(NO)

Fixed submission:
n = int(input())
if n == 7 or n == 5 or n == 3:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,
        43,47,53,59,61,67,71,73,79,83,89,97]
ans = 0
factor = defaultdict(int)
for i in range(1,N+1):
    for j in prime:
        while i != 1:
            if i % j == 0:
                factor[j] += 1
                i = i // j
            else:
                break

fact_l = list(dict(factor).items())
for i, x in enumerate(fact_l):
    if x[1] >= 74:
        n_74 = i + 1
    if x[1] >= 24:
        n_24 = i + 1
    if x[1] >= 14:
        n_14 = i + 1
    if x[1] >= 4:
        n_4 = i + 1
    if x[1] >= 2:
        n_2 = i + 1

print(n_74+n_24*(n_2-1)+n_14*(n_4-1)+n_4*(n_4-1)*(n_2-2)//2)

Fixed submission:
from collections import defaultdict

N = int(input())
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,
        43,47,53,59,61,67,71,73,79,83,89,97]
ans = 0
factor = defaultdict(int)
for i in range(1,N+1):
    for j in prime:
        while i != 1:
            if i % j == 0:
                factor[j] += 1
                i = i // j
            else:
                break

fact_l = list(dict(factor).items())
fact_l.sort()
n_74 = 0
n_24 = 0
n_14 = 0
n_4 = 0
n_2 = 0
for i, x in enumerate(fact_l):
    if x[1] >= 74:
        n_74 = i + 1
    if x[1] >= 24:
        n_24 = i + 1
    if x[1] >= 14:
        n_14 = i + 1
    if x[1] >= 4:
        n_4 = i + 1
    if x[1] >= 2:
        n_2 = i + 1

print(n_74+(n_24*(n_2-1))+(n_14*(n_4-1))+(n_4*(n_4-1)*(n_2-2)//2))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate,combinations
n,k = map(int,input().split())
a = list(map(int,input().split()))
acc = [0]+list(accumulate(a))
ls = []
for i,j in combinations(acc,2):
  ls.append(j-i)
x = max(ls).bit_length()
ans = 0
for i in range(x-1,-1,-1):
  cnt = 0
  for j in ls:
    if ans+2**i & j == ans+2**i:
      cnt += 1
  if cnt >= k:
    ans += 2**i
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/n
difmin = 10**18
for i in range(n):
  if difmin>abs(a[i]-avg):
    difmin = abs(a[i]-avg)
    ans = i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate,combinations
n,k = map(int,input().split())
a = list(map(int,input().split()))
acc = [0]+list(accumulate(a))
ls = []
for i,j in combinations(acc,2):
  ls.append(j-i)
x = max(ls).bit_length()
ans = 0
for i in range(x-1,-1,-1):
  cnt = 0
  for j in ls:
    if ans+2**i & j == ans+2**i:
      cnt += 1
  if cnt >= k:
    ans += 2**i
print(ans)

Fixed submission:
from itertools import accumulate,combinations
n,k = map(int,input().split())
a = list(map(int,input().split()))
acc = [0]+list(accumulate(a))
ls = []
for i,j in combinations(acc,2):
  ls.append(j-i)
x = max(ls).bit_length()
ans = 0
for i in range(x-1,-1,-1):
  cnt = 0
  for j in ls:
    if ans+2**i & j == ans+2**i:
      cnt += 1
  if cnt >= k:
    ans += 2**i
print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    lscity = list(map(int, input().split(' ')))
    city.append([*lscity, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city_y[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:0=6}{:0=6}".format(city_y[i][0], city_num[city_y[i][0]]))

for i, j in sorted(city_ID.items()):
    print(j)

Fixed submission:
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    a, b = map(int, input().split(' '))
    city.append([a, b, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city_y[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:0=6}{:0=6}".format(city_y[i][0], city_num[city_y[i][0]]))

for i, j in sorted(city_ID.items()):
    print(j)

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    lscity = list(map(int, input().split(' ')))
    city.append([*lscity, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city_y[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:06d}{:06d}".format(city_y[i][0], city_num[city_y[i][0]]))

for i, j in sorted(city_ID.items()):
    print(j)

Fixed submission:
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    a, b = map(int, input().split(' '))
    city.append([a, b, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city_y[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:0=6}{:0=6}".format(city_y[i][0], city_num[city_y[i][0]]))

for i, j in sorted(city_ID.items()):
    print(j)

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    lscity = list(map(int, input().split(' ')))
    city.append([*lscity, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:06d}{:06d}".format(city_num[city[i][0]], city[i][0]))

for i, j in sorted(city_ID.items()):
    print(j)

Fixed submission:
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    a, b = map(int, input().split(' '))
    city.append([a, b, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city_y[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:0=6}{:0=6}".format(city_y[i][0], city_num[city_y[i][0]]))

for i, j in sorted(city_ID.items()):
    print(j)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(10**3):
    if n == i*(i+1)//2:
        x = i
        break
else:
    print("No")
    exit()
ans = [[] for i in range(x+1)]
app = 0
for i in range(1,x+1):
    for j in range(i):
        app += 1
        ans[j].append(app)
    ans[i].extend([k for k in range(i*(i-1)//2+1,i*(i+1)//2+1)])
print("Yes")
print(x+1)
for ansarr in ans:
    print(x, *ansarr, sep = " ")

Fixed submission:
s=input()
if len(s) == 2:
  print(s)
else:
  print(s[::-1])
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n,m = map(int,input().split())
s = input()
t = input()
x = gcd(n,m)
for i in range(x+1):
  if s[i*n//x]!=t[i*m//x]:
    print(-1)
    break
else:
  print(n*m//x)

Fixed submission:
from fractions import gcd
n,m = map(int,input().split())
s = input()
t = input()
x = gcd(n,m)
for i in range(x):
  if s[i*n//x]!=t[i*m//x]:
    print(-1)
    break
else:
  print(n*m//x)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
both = []
for i in range(n):
  both.extend(ab[i])
both.sort()
ans = 10**18
sm = sum(both[:n])
for i in range(n):
  ai = bisect.bisect_left(both,ab[i][0])
  bi = bisect.bisect_left(both,ab[i][1])
  if ai < n and bi < n:
    ans = min(ans,sm)
  elif ai < n:
    ans = min(ans,sm-both[n-1]+ab[i][1])
  elif bi < n:
    ans = min(ans,sm-both[n-1]+ab[i][0])
  else:
    ans = min(ans,sm-both[n-1]-both[n-2]+sum(ab[i]))
a,b = list(zip(*ab))
ans = min(ans,sum(a),sum(b))
if ans != sm:
  print(2/0)
else:
  print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
import bisect
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
both = []
for i in range(n):
  both.extend(ab[i])
both.sort()
ans = 10**18
sm = sum(both[:n])
for i in range(n):
  ai = bisect.bisect_left(both,ab[i][0])
  bi = bisect.bisect_left(both,ab[i][1])
  if ai < n and bi < n:
    ans = min(ans,sm)
  elif ai < n-1:
    ans = min(ans,sm-both[n-1]+ab[i][1])
  elif ai == n-1:
    ans = min(ans,sm-both[n-2]+ab[i][1])
  elif bi < n-1:
    ans = min(ans,sm-both[n-1]+ab[i][0])
  elif bi == n-1:
    ans = min(ans,sm-both[n-2]+ab[i][0])
  else:
    ans = min(ans,sm-both[n-1]-both[n-2]+sum(ab[i]))
a,b = list(zip(*ab))
ans = min(ans,sum(a),sum(b))
print(ans)
Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for i in ls:
  if i[0] <= T:
    ans = min(ans,i[1])
if ans < 10**18:
  print(ans)
else:
  print('TLE')


Fixed submission:
if int(input())==1:
  print("Hello World")
else:
  print(int(input())+int(input()))
Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')


Fixed submission:
N,T=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for i in ls:
  if i[0] <= T:
    ans = min(ans,i[1])
if ans < 10**18:
  print(ans)
else:
  print('TLE')


Fixed submission:
N,T=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for c,t in ls:
  if t <= T:
    ans = min(ans,c)
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Fixed submission:
N,T=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans='TLE'
for c,t in ls:
  if t <= T:
    ans = min(ans,c)
    
print(ans)

Fixed submission:
N,T=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5+1)):
  if M%i == 0:
    d.extend(i,M//i)
d=list(set(d)).sort()
for x in d:
  if x>=N:
    print(M//x)
    break


Fixed submission:
N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5+1)):
  if M%i == 0:
    d. append(i)
    d.append(M//i)
dd=list(set(d))
dd.sort()
for x in dd:
  if x>=N:
    print(M//x)
    break
Buggy python submission (verdict: Runtime Error):
import sys
import defaultdict
input=sys.stdin.readline()
s=input().rstrip()
t=input().rstrip()
dct=defaultdict(int)
for i in range(len(s)):
  if not dct[s[i]]:
    dct[s[i]]=t[i]
  elif dct[s[i]]!=t[i]:
    print("No")
    exit()
ls=[]
for i in dct.values():
  if i in ls:
    print("No")
    exit()
  else:
    ls.append(i)
print("Yes")

Fixed submission:
from collections import defaultdict
s=input()
t=input()
dct=defaultdict(int)
for i in range(len(s)):
  if not dct[s[i]]:
    dct[s[i]]=t[i]
  elif dct[s[i]]!=t[i]:
    print("No")
    exit()
ls=[]
for i in dct.values():
  if i in ls:
    print("No")
    exit()
  else:
    ls.append(i)
print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = city[i] - X
    
def gcd(numbers):
    return reduce(math.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)

Fixed submission:
import fractions
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = abs(city[i] - X)
    
def gcd(numbers):
    return reduce(fractions.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)
Buggy python submission (verdict: Runtime Error):
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="")

Fixed submission:
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="")

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
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="")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split(' '))
a= list(map(int, input().split(' ')))

INF = float('inf')
ans = INF

if N == K:
    ans = min(ans, abs(a[N]-a[0])+min(abs(a[0]), abs(a[N])))
else:
    for i in range(N-K):
        ans = min(ans, abs(a[i+K-1]-a[i])+min(abs(a[i+K-1]), abs(a[i])))

print(ans)

Fixed submission:
N, K = map(int, input().split(' '))
a= list(map(int, input().split(' ')))

INF = float('inf')
ans = INF

if N == K:
    ans = abs(a[N-1]-a[0])+min(abs(a[0]), abs(a[N-1]))
else:
    for i in range(N-K+1):
        ans = min(ans, abs(a[i+K-1]-a[i])+min(abs(a[i+K-1]), abs(a[i])))

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
for i in range(len(s)+1):
  if s == t:
    print("Yes")
    break
  else:
    k = s[0]
    for i in range(len(s)-1):
      s[i]=s[i+1]
    s[-1] = k
else:
  print("No")

Fixed submission:
s=list(input())
t=list(input())
for i in range(len(s)+1):
  if s == t:
    print("Yes")
    break
  else:
    k = s[0]
    for i in range(len(s)-1):
      s[i]=s[i+1]
    s[-1] = k
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
dp = [[0,0] for i in range(1<<n)]
def merge(ls1,ls2):
  p,q,r,s = *ls1,*ls2
  ret = [max(p,r)]
  if p>r:
    ret.append(max(q,r))
  else:
    ret.append(max(p,s))
  return ret
for i in range(1<<n):
  dp[i][0] = a[i]
for i in range(n):
  for j in range(1<<n):
    if 1<<i & j:
      dp[j] = merge(dp[j],dp[1<<i^j])
ans = [0 for i in range(2**n)]
for i in range(1,1<<n):
  ans[i] = max(ans[i-1],sum(dp[i]))
for i in ans:
  if i:
    print(i)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
dp = [[0,0] for i in range(1<<n)]
def merge(ls1,ls2):
  p,q = ls1
  r,s = ls2
  ret = [max(p,r)]
  if p>r:
    ret.append(max(q,r))
  else:
    ret.append(max(p,s))
  return ret
for i in range(1<<n):
  dp[i][0] = a[i]
for i in range(n):
  for j in range(1<<n):
    if 1<<i & j:
      dp[j] = merge(dp[j],dp[1<<i^j])
ans = [0 for i in range(2**n)]
for i in range(1,1<<n):
  ans[i] = max(ans[i-1],sum(dp[i]))
for i in ans:
  if i:
    print(i)
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
A = list(map(int, input().split()))
print((N-1+K-1-1)//(K-1))

Fixed submission:
S=input()
print(S.count("+")-S.count("-"))
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(12):
wa = 0
  if N // 10 ** i == 0:
    break
  else:
    wa += N // 10 ** i

if N % wa == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
wals = list(str(N))
wals = [int(s) for s in wals]
wa = sum(wals)

if N % wa == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
for i in range(8):
  binstr=bin(i)[2:]
  binstr.zfill(3)
  b=[]
  for j in range(n):
    c=0
    for k in range(3):
      if binstr[k]=="1":
        c+=a[j][k]
      else:
        c+=-a[j][k]
    b.append(c)
  b.sort()
  ans.append(sum(b[:m]))
print(max(ans))

Fixed submission:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
for i in range(8):
  binstr=format(i,"b").zfill(3)
  b=[]
  for j in range(n):
    c=0
    for k in range(3):
      if binstr[k]=="1":
        c+=a[j][k]
      else:
        c+=-a[j][k]
    b.append(c)
  b.sort(reverse=True)
  ans.append(sum(b[:m]))
print(max(ans))