Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

N, D = map(int, input().split())
count = 0
for _ in range(M):
    x, y = map(int, input().split())
    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)
    if ans >= D:
        count += 1

print(count)

Fixed submission:
import math

N, D = map(int, input().split())
count = 0
for _ in range(N):
    x, y = map(int, input().split())
    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)
    if ans <= D:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math

inp = str(input())

N, M = map(int, input().split())
count = 0
for _ in range(M):
    
    for i in inp:
        x, y = map(int, input().split())

        xx = int(x) ** 2
        yy = int(y) ** 2

        ans = math.sqrt(xx + yy)

        if ans >= M:
            count += 1
        j += 1
    print(count)

Fixed submission:
import math

N, D = map(int, input().split())
count = 0
for _ in range(N):
    x, y = map(int, input().split())
    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)
    if ans <= D:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math

inp = str(input())

N, M = map(int, input().split())
count = 0
for _ in range(M):
    
    for i in inp:
        x, y = map(int, input().split())

        xx = int(x) ** 2
        yy = int(y) ** 2

        ans = math.sqrt(xx + yy)
        print(ans)

        if ans >= M:
            count += 1
        j += 1
    print(count)

Fixed submission:
import math

N, D = map(int, input().split())
count = 0
for _ in range(N):
    x, y = map(int, input().split())
    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)
    if ans <= D:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math

inp = str(input())
m = [x.split() for x in inp]

count = 0
j = 0
for i in inp:
    x, y = i.split()
    if j == 0:
        D = int(y)
        print(D)
    else:
        xx = int(x) ** 2
        yy = int(y) ** 2

        ans = math.sqrt(xx + yy)
        print(ans)

        if ans >= int(D):
            count += 1
    j += 1
print(count)

Fixed submission:
import math

N, D = map(int, input().split())
count = 0
for _ in range(N):
    x, y = map(int, input().split())
    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)
    if ans <= D:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math

inp = input()

m = [x.split() for x in inp]

count = 0

for i in inp:
    x, y = i.split()

    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)

    if ans >= y:
        count += 1

print(count)

Fixed submission:
import math

N, D = map(int, input().split())
count = 0
for _ in range(N):
    x, y = map(int, input().split())
    xx = x ** 2
    yy = y ** 2

    ans = math.sqrt(xx + yy)
    if ans <= D:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
ans = 0
s = []
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	s.append(tmp)

for m in s:
	for n in s:
		if Counter(n)==Counter(m) and m != n:
			ans+=1
	s.remove(n)
print(ans)

Fixed submission:
ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
ans = 0
s = []
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	s.append(tmp)

for m in s:
	for n in s:
		if Counter(n)==Counter(m) and m != n:
			ans+=1
print(int(ans/2))


Fixed submission:
ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
ans = 0
s = []
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	s.append(tmp)
 
for m in range(len(s)):
	for n in range(len(s)):
		if Counter(s[n])==Counter(s[m]) and s[m] != s[n]:
			ans+=1
print(int(ans/2))

Fixed submission:
ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
    from collections import Counter
    ans = 0
    s = []
    N = int(input())
    for i in range(N):
    	tmp = []
    	string = input()
    	for st in string:
    		tmp.append(st)
    	s.append(tmp)
     
    for m in range(len(s)):
    	for n in range(len(s)):
    		if Counter(s[n])==Counter(s[m]) and s[m] != s[n]:
    			ans+=1
    print(int(ans/2))

Fixed submission:
ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
ans = 0
s = []
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	s.append(tmp)

for m in range(len(s)):
	for n in range(len(s)):
		if Counter(s[n])==Counter(s[m]) and s[m] != s[n]:
			ans+=1
print(int(ans/2))


Fixed submission:
ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

a = int(input())
while i*i <= a:
  i=i+1

i=i-1

print(i*i)

Fixed submission:
#coding:utf-8

a = int(input())
i=0
while i*i <= a:
  i=i+1

i=i-1

print(i*i)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8

a = int(input())
while i*i <= a:
  i=i+1

i=i-1

print(i*i)

Fixed submission:
#coding:utf-8

a = int(input())
i=0
while i*i <= a:
  i=i+1

i=i-1

print(i*i)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8
abc =input().split()
a,b,c= int(abc[0]),int(abc[1]),int(abc[2])

if a+b == c:
  print("+")
  if a-b == c:
    print("?")
elif a-b == c:
  print("-")
else:
  print("!")

Fixed submission:
#coding:utf-8

a = int(input())
i=0
while i*i <= a:
  i=i+1

i=i-1

print(i*i)
Buggy python submission (verdict: Runtime Error):
from copy import copy
N=10
K=4
p=list(map(int, input().split()))
expP = [(1+i)/2 for i in p]
id_H = N-K
id_T = N
minus = sum(expP[:id_H])
minimum = minus
for i in range(id_H):
    minus -= expP[id_H - i -1]
    minus += expP[id_T - i -1]
    if minus < minimum:
        minimum = copy(minus)
ans = sum(expP) - minimum
print(ans)

Fixed submission:
from copy import copy
N,K = map(int, input().split())
p=list(map(int, input().split()))
expP = [(1+i)/2 for i in p]
id_H = N-K
id_T = N
minus = sum(expP[:id_H])
minimum = minus
for i in range(id_H):
    minus -= expP[id_H - i -1]
    minus += expP[id_T - i -1]
    if minus < minimum:
        minimum = copy(minus)
ans = sum(expP) - minimum
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from itertools import accumulate
from bisect import bisect_left

def solve(N: int, M: int, A: "List[int]"):
    A.sort()

    right = 2*A[-1]+1
    left = 0

    while right - left > 1:
        mid = (left+right)//2

        # A[i]+A[j] >= midになるようなi,jの組み合わせの個数 mを 求めたい
        # m >= Mならok
        m = 0
        for i in range(N):
            a = A[i]
            res = mid - a
            # Aからres以上のものを探す
            index = bisect_left(A,res)
            m += N-index
        
        if m >= M:
            left = mid
        else:
            right = mid

    # M通り以上の握手ができる最小の組み合わせの幸福度
    B = sorted(A,reverse=True)
    accum_B = list(accumulate(B))
    answer = 0
    handshake_count = 0
    for i in range(N):
        res = left - A[i]
        if res > A[-1]:
            continue
        index = bisect_left(A,res)
        answer += (N-index)*A[i]+accum_B[N-index-1]
        handshake_count += (N-index)

    # 握手の回数がmを越えたときはその分の幸福度を引く
    if handshake_count>M:
        answer -= left*(handshake_count-M)
    print(answer)
    return


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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Fixed submission:
s,t = input().split()
print(t+s)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M  = map(int,input().split())
coeff = np.zeros((M,N))
for i in range(M):
    inputs = list(map(int,input().split()))
    for switch in inputs[1:]:
        coeff[i][switch-1] = 1
onlist = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    vec = [int(num) for num in bin(i)[2:]]
    fill = N - len(vec)
    vec = np.append(np.zeros(fill),np.array(vec))
#     print(vec)
    if sum(onlist == np.matmul(coeff,vec)%2) == M:
        ans +=1
print(ans)

Fixed submission:
import numpy as np
N,M  = map(int,input().split())
coeff = np.zeros((M,N))
for i in range(M):
    inputs = list(map(int,input().split()))
    for switch in inputs[1:]:
        coeff[i][switch-1] = 1
onlist = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    vec = [int(num) for num in bin(i)[2:]]
    fill = N - len(vec)
    vec = np.append(np.zeros(fill),np.array(vec))
#     print(vec)
    if sum(onlist == np.dot(coeff,vec)%2) == M:
        ans +=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N):
    tmp = V[i]-C[i]
    if tmp > 0:
        ans += tmp
print(ans)




Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    tmp = V[i]-C[i]
#     print(tmp)
    if tmp > 0:
        ans += tmp
#     print(ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
V = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N):
    tmp = V[i]-C[i]
    if tmp > 0:
        ans += tmp
print(ans)




Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    tmp = V[i]-C[i]
#     print(tmp)
    if tmp > 0:
        ans += tmp
#     print(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):

N, A, B, C =map(int,input().split())
l = []
for i in range(N):
    a = input()
    l.append(a)

def DFS(i,uselist0,uselista,uselistb,uselistc):
    if i == N:
        uselist = [uselist0,uselista,uselistb,uselistc]
        return calc_mp(uselist)
    mplist = []
    u0 = uselist0 + [l[i]]
    ua = uselista + [l[i]]
    ub = uselistb + [l[i]]
    uc = uselistc + [l[i]]
    mplist.append(DFS(i+1, u0,uselista,uselistb,uselistc))
    mplist.append(DFS(i+1, uselist0,ua,uselistb,uselistc))
    mplist.append(DFS(i+1, uselist0,uselista,ub,uselistc))
    mplist.append(DFS(i+1, uselist0,uselista,uselistb,uc))
    return min(mplist)


def calc_mp(uselist):
    mp = 0

    #合成魔法
    mp += (max(len(uselist[1]) - 1, 0)) * 10
    mp += (max(len(uselist[2]) - 1, 0)) * 10
    mp += (max(len(uselist[3]) - 1, 0)) * 10

    #その他魔法
    mp += abs(A - sum(uselist[1]))
    mp += abs(B - sum(uselist[2]))
    mp += abs(C - sum(uselist[3]))

    return mp

print(DFS(0,[],[],[],[]))

Fixed submission:

N, A, B, C =map(int,input().split())
l = []
for i in range(N):
    a = int(input())
    l.append(a)

infty = 1000000

def DFS(i,uselist0,uselista,uselistb,uselistc):
    if i == N:
        return calc_mp(uselista,uselistb,uselistc)
    mplist = []
    u0 = uselist0 + [l[i]]
    ua = uselista + [l[i]]
    ub = uselistb + [l[i]]
    uc = uselistc + [l[i]]
    mplist.append(DFS(i+1, u0,uselista,uselistb,uselistc))
    mplist.append(DFS(i+1, uselist0,ua,uselistb,uselistc))
    mplist.append(DFS(i+1, uselist0,uselista,ub,uselistc))
    mplist.append(DFS(i+1, uselist0,uselista,uselistb,uc))
    return min(mplist)


def calc_mp(uselista,uselistb,uselistc):
    mp = 0
    #合成魔法
    mp += (max(len(uselista) - 1, 0)) * 10
    mp += (max(len(uselistb) - 1, 0)) * 10
    mp += (max(len(uselistc) - 1, 0)) * 10

    #その他魔法
    mp += abs(A - sum(uselista))
    mp += abs(B - sum(uselistb))
    mp += abs(C - sum(uselistc))

    if len(uselista)==0:
        mp += infty
    if len(uselistb)==0:
        mp += infty
    if len(uselistc)==0:
        mp += infty
    return mp

print(DFS(0,[],[],[],[]))
Buggy python submission (verdict: Runtime Error):
Keita [9:48 PM]
import numpy as np

N=int(input())    
listA = list(map(int,input().split()))

minA = min(listA)

while True:
   minA = min(listA)
   minApos = np.argmin(listA)
   listA = [x % minA for x in listA]
   listA[minApos] = minA
   listA= [x for x in listA if x >0]
   if len(set(listA))==1:
       print(minA)
       break

Fixed submission:
import numpy as np
 
N=int(input())    
listA = list(map(int,input().split()))
 
minA = min(listA)
 
while True:
   minA = min(listA)
   minApos = np.argmin(listA)
   listA = [x % minA for x in listA]
   listA[minApos] = minA
   listA= [x for x in listA if x >0]
   if len(set(listA))==1:
       print(minA)
       break
Buggy python submission (verdict: Runtime Error):
#問題D
M,N = list(map(int,input().split())) 
ROW = list(map(int,input().split())) 
COL = list(map(int,input().split())) 
#M= 3
#N= 3 
#ROW = [8,9,7]
#COL = [6,9,8]
#N,M = 14,13
#ROW = [158, 167, 181, 147, 178, 151, 179, 182, 176, 169, #180, 129, 175, 168]
#COL = [181, 150, 178, 179, 167, 180, 176, 169, 182, 177, #175, 159, 173]
import numpy as np
row = 0
col = 0
nums = np.arange(1,M*N+1)[::-1]
pattern = np.zeros(M*N)
ans = 1
#print(nums)
for i in nums:
    if i in ROW and i in COL:
        row += 1
        col += 1
#        pattern[i-1] = 1
    elif i in ROW and i not in COL:
        row += 1
#        pattern[i-1] = col
        ans *= col
    elif i not in ROW and i in COL:
        col += 1
#        pattern[i-1] = row
        ans *= row

    elif i not in ROW and i not in COL:
#        pattern[i-1] = row * col - (M*N-i)
        ans *= (row * col - (M*N-i))
       
        if row * col - (M*N-i) <= 0:
            ans = 0
            break
    ans %= (10**9+7)
#    print(i,row,col,pattern[i-1])
#print(pattern)
#ans = int(pattern.prod())
#ans = ans % (10**9+7)
print(ans)

Fixed submission:
nums = list(map(int,input().split()))
flag1 = 1 in nums and 9 in nums and 7 in nums and 4 in nums
if flag1 == True:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
#問題 D
import numpy as np
N, W = map(int,input().split())
#普通に書くとTLEだったのでNumpy化
dp = np.zeros(W+1)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(int(dp[-1]))


#dpをN*(W+1)配列とかにしてもnumpyなら間に合う。コピーに時間がかかるのかな？

# numpy化してもやっぱりTLEなので、どうもコピーが悪かったらしい
# N, W = map(int,input().split())
# VAL = np.zeros(W+1)
# val = np.zeros(W+1)
# for n in range(N):
#     w,v = map(int,input().split())
#     for weight in range(w,W+1):
#         val[weight] = max(VAL[weight],VAL[weight-w]+v)
#     VAL = np.copy(val)
# print(int(VAL[W]))

# VAL = [0]*(W+1)
# val = [0]*(W+1)
# for n in range(N):
#     w,v = map(int,input().split())
#     for weight in range(w,W+1):
#         val[weight] = max(VAL[weight],VAL[weight-w]+v)
#     VAL = val[:]
#print(VAL[W])
    # listをコピーするときは注意　https://qiita.com/utgwkk/items/5ad2527f19150ae33322
    # listへのアクセスは重いらしい。 https://qiita.com/pegasusBS15/items/620985fdc21c75ad8026


Fixed submission:
N = int(input())
h = list(map(int,input().split()))
# N=4
# h=[10, 30, 40, 20]
l = [0]*N
l[1]=abs(h[0]-h[1])
#print(l[0],l[1])
for i in range(2,N):
    l[i] = min(l[i-1]+abs(h[i]-h[i-1]),l[i-2]+abs(h[i]-h[i-2]))
print(l[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
#問題 D
import numpy as np
N, W = map(int,input().split())
VAL = np.zeros(W+1)
val = np.zeros(W+1)
for n in range(N):
    w,v = map(int,input().split())
    for weight in range(w,W+1):
        val[weight] = max(VAL[weight],VAL[weight-w]+v)
    VAL = np.copy(val)
#    print(val)
print(int(VAL[W]))
    # listをコピーするときは注意　https://qiita.com/utgwkk/items/5ad2527f19150ae33322

Fixed submission:
import numpy as np
N, W = map(int,input().split())
#普通に書くとTLEだったのでNumpy化
dp = np.zeros(W+1,dtype=int)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
#問題 D
import numpy as np
N, W = map(int,input().split())
VAL = [0]*(W+1)
val = [0]*(W+1)
for n in range(N):
    w,v = map(int,input().split())
    for weight in range(w,W+1):
        val[weight] = max(VAL[weight],VAL[weight-w]+v)
    VAL = val[:]
print(VAL[W])
    # listをコピーするときは注意　https://qiita.com/utgwkk/items/5ad2527f19150ae33322

Fixed submission:
import numpy as np
N, W = map(int,input().split())
#普通に書くとTLEだったのでNumpy化
dp = np.zeros(W+1,dtype=int)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
#問題 D
N, W = map(int,input().split())
VAL = [0]*(W+1)
val = [0]*(W+1)
for n in range(N):
    w,v = map(int,input().split())
    for weight in range(1,W+1):
        if weight >= w:
            val[weight] = max(VAL[weight],VAL[weight-w]+v)
    VAL = val[:]
print(VAL[W])
    # listをコピーするときは注意　https://qiita.com/utgwkk/items/5ad2527f19150ae33322

Fixed submission:
import numpy as np
N, W = map(int,input().split())
#普通に書くとTLEだったのでNumpy化
dp = np.zeros(W+1,dtype=int)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(int(dp[-1]))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input()split(" "))

print(min(n%k, k-(n%k)))


Fixed submission:
n,k=map(int,input().split(" "))

r1= n%k;

r2=k-r1;

print(min(r1,r2))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>1000000000000000000:
            s=-1
            break
            
     print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>1000000000000000000:
            s=1
            break
            
print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>1000000000000000000:
            s=1
            
print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
    
    if s>1000000000000000000:
        print(-1)
    else:
        print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
if min(l)=0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
    
    if s>1000000000000000000:
        print(-1)
    else:
        print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
s=1
for x in l:
    s *= x
    
if s>1000000000000000000:
    print(-1)
else:
    print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
c=list(input())
x=0
for i in range(N):
  if c[i]=="W":
    for j in range(N):
      if i==N-1-j:
        break
      elif c[N-1-j]=="R":
        x+=1
        c[N-1-j]="W"
        break
print(x)

Fixed submission:
N=int(input())
c=list(input())
x=0
M=N
for i in range(N):
  if c[i]=="W":
    for j in range(N):
      if i==M-1-j:
        M=i
        break
      elif c[M-1-j]=="R":
        x+=1
        c[M-1-j]="W"
        M=M-j
        break
  if i==M:
    break
print(x)
Buggy python submission (verdict: Runtime Error):
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[1][1]==1 and x[2][2]==1:
      flag=1
  if x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[0][2]==1 and x[2][0]==1:
      flag=1
  if x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    elif x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  #print(x)
else:
  print("No")

Fixed submission:
N=int(input())

print(N//2+N%2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

x=0
flag=0
while N>=1:
  m=N%10
  if m==5:
    x+=5
    flag=1
  elif m<5:
    x+=m
    flag=0
  else:
    x+=(10-m)
    flag=2
  N=N//10
  if flag==2:
    N+=1
  elif flag==1:
    if N%10>=5:
      N+=1
print(x)

Fixed submission:
N=input()
n=len(N)
x=0
flag=0
#print(N)
M=[0]*(n+1)
for i in range(n):
  M[i]=int(N[n-1-i])
#print(M)
for i in range(n+1):
  
  m=M[i]
  if m==5:
    x+=5
    flag=1
  elif m<5:
    x+=m
    flag=0
  else:
    x+=(10-m)
    flag=2
  if flag==2:
    M[i+1]+=1
  elif flag==1:
    if M[i+1]>=5:
      M[i+1]+=1
print(x)
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=[[0 for j in range(2)] for i in range(N)]


for i in range(N):
  X[i]=list(map(int,input().split()))


X.sort()
n=1
i=0
k=0
flag=0
while(1):
  if X[i][0]+X[i][1]>X[n][0]-X[n][1]:
    n+=1
    flag=0
  else:
    i+=1
    if flag==0:
      k+=1
      flag=1
  if i>=N-1 or n>=N:
    break
    
print(k+1)



Fixed submission:
H=int(input())
W=int(input())
N=int(input())

X=max([W,H])
Y=N//X
if X*Y==N:
  print(Y)
else:
  print(Y+1)