Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    B = [list(map(int,input().split())) for _ in range(Q)]
    dict = {}

    for i in range(1,10**5+1):
    #for i in range(1,6):
        dict[i] = 0

    for i in range(N):
        dict[A[i]] += 1

    for i in range(Q):
        dict[B[i][1]] += dict[B[i][0]]
        dict[B[i][0]] = 0
        #print(dict)
        sum = 0
        for i in range(1,10**5+1):
        #for i in range(1,6):
            if dict[i] != 0:
                sum += dict[i]*i
        print(sum)

main()


Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    B = [list(map(int,input().split())) for _ in range(Q)]
    dict = {}

    for i in range(1,10**5+1):
    #for i in range(1,6):
        dict[i] = 0

    for i in range(N):
        dict[A[i]] += 1

    sum = 0
    for i in range(1,10**5+1):
        #for i in range(1,6):
        if dict[i] != 0:
            sum += dict[i]*i

    for i in range(Q):
        sum = sum +(dict[B[i][0]]*B[i][1] - dict[B[i][0]]*B[i][0])

        dict[B[i][1]] += dict[B[i][0]]
        dict[B[i][0]] = 0
        #print(dict)
        print(sum)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    B = [list(map(int,input().split())) for _ in range(Q)]
    dict = {}

    for i in range(1,10**5+1):
    #for i in range(1,6):
        dict[i] = 0

    for i in range(N):
        dict[A[i]] += 1

    for i in range(Q):
        dict[B[i][1]] += dict[B[i][0]]
        dict[B[i][0]] = 0
        #print(dict)
        sum = 0
        for i in range(1,10**5+1):
        #for i in range(1,6):
            sum += dict[i]*i
        print(sum)

main()


Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    B = [list(map(int,input().split())) for _ in range(Q)]
    dict = {}

    for i in range(1,10**5+1):
    #for i in range(1,6):
        dict[i] = 0

    for i in range(N):
        dict[A[i]] += 1

    sum = 0
    for i in range(1,10**5+1):
        #for i in range(1,6):
        if dict[i] != 0:
            sum += dict[i]*i

    for i in range(Q):
        sum = sum +(dict[B[i][0]]*B[i][1] - dict[B[i][0]]*B[i][0])

        dict[B[i][1]] += dict[B[i][0]]
        dict[B[i][0]] = 0
        #print(dict)
        print(sum)

main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
n_list = list(map(int, input().split()))

multi = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        multi = 0
        break

for i in range(n):
    if a == 0:
        break

    multi *= n_list[i]

    if multi>1e18:
        break

print(multi)
if multi<=1e18:
    print(multi)
else:
    print(-1)

Fixed submission:
n = int(input())
n_list = list(map(int, input().split()))

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
n_list = list(map(int, input().split()))

#n = int(input())
#n_list = list(map(int, input().split()))

multi = 1

for i in range(n):
    multi *= n_list[i]

if multi<=1e18:
    print(multi)
else:
    print(-1)

Fixed submission:
n = int(input())
n_list = list(map(int, input().split()))

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
n_list = list(map(int, input().split()))

multi = 1

for i in range(n):
    multi *= n_list[i]

if multi<=1e18:
    print(multi)
else:
    print(-1)


Fixed submission:
n = int(input())
n_list = list(map(int, input().split()))

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
n_list = list(map(int, input().split()))

multi = 1

for i in range(n):
    multi = multi*n_list[i]

if multi<=1e18:
    print(multi)
else:
    print(-1)
     


Fixed submission:
n = int(input())
n_list = list(map(int, input().split()))

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal

a,b = input().split()
b = round(b*100)
c = int(a)*int(b)//100

print(c)

Fixed submission:
from decimal import Decimal

a,b = input().split()
b = b.replace(".","")
c = int(a)*int(b)//100

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(float, input().split())

multi = a*b
i=1
test = 1

if (0<=multi) and (multi<1):
    test = 0

while True:
    if test == 0:
        i=0
        break
    elif (i<=multi) and (multi<i+1):
        break
    else:
        i = i*10
while True:
    if i ==0:
        break
    if (i<=multi) and (multi<i+1):
        break
        i=i+1

print(i)

Fixed submission:
from decimal import Decimal

a,b = input().split()
b = b.replace(".","")
c = int(a)*int(b)//100

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(float, input().split())

multi = a*b
i=0

while True:
    if i<=multi and multi<i+1:
        break
    i=i+1

print(i)


Fixed submission:
from decimal import Decimal

a,b = input().split()
b = b.replace(".","")
c = int(a)*int(b)//100

print(c)
Buggy python submission (verdict: Runtime Error):
S = input()
if S = 'ABC':
    print("ARC")
else:
    print("ABC")


Fixed submission:
S = input()
if S == 'ABC':
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())
    ans = 0
    #全てが同じ数字
    for i in range(1,K+1,1):
        for j in range(1,K+1,1):
            for k in range(1,K+1,1):
                ans += gcd(i,j,k)

    return ans

print(ans)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())
    ans = 0
    #全てが同じ数字
    for i in range(1,K+1,1):
        ans += gcd(i,i,i)
    #2つ同じ数字
    tmp = 0
    for i in range(1,K+1,1):
        for j in range(1,K+1,1):
            if j != i:
                tmp += gcd(i,i,j)
    ans += tmp*3
    #3つの異なる数字
    tmp2 = 0
    for i in range(1,K+1,1):
        for j in range(i+1,K+1,1):
            for h in range(j+1,K+1,1):
                tmp2 += gcd(i,j,h)

    ans += tmp2*6

    return ans

print(main())
Buggy python submission (verdict: Runtime Error):
import math
import sympy

def main():
    a,b,c = map(int,input().split())
    left = 4*a*b
    right = (c-a-b)**2
    if (c-a-b)<0:
        return 'No'

    if left < right:
        return 'Yes'
    else:
        return 'No'

print(main())


Fixed submission:
import math

def main():
    a,b,c = map(int,input().split())
    left = 4*a*b
    right = (c-a-b)**2
    if (c-a-b)<0:
        return 'No'

    if left < right:
        return 'Yes'
    else:
        return 'No'

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
def binery_search(left,right,L,a,b):
    while True:
            #print(left,right,mid,cnt)
            mid = int( (left+right)/2 )
            if a+b <= L[mid]:
                right = mid
            elif a+b > L[mid]:
                left = mid + 1

            if left == right:
                return left

def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1,N-1,1):
            a = L[i]
            b = L[j]
            num = binery_search(j+1,N,L,a,b)
            #print(L,a,b,num)
            ans += num-(j+1)

    return ans

print(main())


Fixed submission:
from bisect import bisect_left

N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp = bisect_left(L,L[i]+L[j])
        cnt += tmp - j - 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input()split())
    A = [-x for x in map(int,input().split())]
    heapify(A)
    for i in range(M):
        tmp = heappop(A)
        tmp2 = tmp//2
        heappush(A,tmp2)
    ans = 0
    for i in range(N):
        ans += A[i]

    ans = abs(ans)
    return ans

print(main())    


Fixed submission:
from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input().split())
    A = [ -x for x in map(int,input().split()) ]
    heapify(A)

    for i in range(M):
        #print(A)
        tmp = -heappop(A)
        #print(tmp)
        tmp = tmp//2
        #print(tmp)
        heappush(A,-tmp)


    ans = 0
    for i in range(N):
        ans += A[i]

    ans = abs(ans)
    return ans

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input().split())
    A = [ -x for x in map(int,input().split()) ]

    for i in range(M):
        heapify(A)
        #print(A)
        tmp = -heappop(A)
        #print(tmp)
        tmp = tmp//2
        #print(tmp)
        heappush(A,-tmp)


    ans = 0
    for i in range(N):
        ans += A[i]

    ans = abs(ans)
    return ans

print(main())


Fixed submission:
from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input().split())
    A = [ -x for x in map(int,input().split()) ]
    heapify(A)

    for i in range(M):
        #print(A)
        tmp = -heappop(A)
        #print(tmp)
        tmp = tmp//2
        #print(tmp)
        heappush(A,-tmp)


    ans = 0
    for i in range(N):
        ans += A[i]

    ans = abs(ans)
    return ans

print(main())
Buggy python submission (verdict: Runtime Error):
A = [int(input()) for _ in range(5)]
ans = 0

for i in range(5):
    if A[i] % 10 == 0:
        ans += A[i]
    else:
        temp = (A//10)*10
        ans += temp

print(ans)  

Fixed submission:
A = [int(input()) for _ in range(5)]
ans = 0
temp2 = 10

for i in range(5):
    if A[i] % 10 == 0:
        ans += A[i]
    else:
        temp = (A[i]//10)*10 + 10
        ans += temp
        if temp2 > A[i] % 10:
            temp2 = A[i] % 10


temp2 = 10 - temp2
ans = ans - temp2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    num = [int(input()) for _ in range(5)]

    bucket = [0] * 6
    bucket[0] = N
    ans = 0
    temp = [0] * 6
    temp[0] = N

    while True:
        for i in range(5):
            if bucket[i] > 0 and bucket[i] >= num[i]:
                temp[i] -= num[i]
                temp[i+1] += num[i]
            elif bucket[i] > 0 and bucket[i] < num[i]:
                temp[i] -= bucket[i]
                temp[i+1] += bucket[i]
            else:
                continue

        ans += 1
        for j in range(6):
            bucket[j] = temp[j]

        if bucket[5] == N:
            break

    return(ans)

print(main())


Fixed submission:
def main():
    N = int(input())
    num = [int(input()) for _ in range(5)]
    num.sort()
    temp = 0
    temp = N // num[0]
    if N%num[0] == 0:
        ans = temp
    else:
        ans = temp + 1

    ans += 4
    return ans

print(main())
Buggy python submission (verdict: Runtime Error):
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S = 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())


Fixed submission:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S == 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())

Buggy python submission (verdict: Runtime Error):
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())


Fixed submission:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S == 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())

Buggy python submission (verdict: Runtime Error):
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')

    ans = 'keyence'
    i = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt <= num:
        cnt += 1
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())     


Fixed submission:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S == 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

#def numsearch(list):
    #for i in list:
        #print(i)
        #if (i+1)/2 not in list:
            #list.remove(i)
    #return list

def main():
    Q = int(input())
    list = seachPrimeNum(100000)
    #list2 = numsearch(list)
    #print(list2)
    c = [0]*100001
    c[0] = 0
    for i in range(1,100001,1):
        #print(i)
        if i in list and (i+1)/2 in list:
            c[i] = c[i-1]+1
        else:
            c[i] = c[i-1]
    #print(c)
    for i in range(Q):
        l,r = map(int,input().split())
        print(c[r]-c[l-1])

main()


Fixed submission:
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

#def numsearch(list):
    #for i in list:
        #print(i)
        #if (i+1)/2 not in list:
            #list.remove(i)
    #return list

def main():
    Q = int(input())
    list = seachPrimeNum(100000)
    #フラグを立てるよ
    check = [0]*100001
    primeCheck = [0]*100001
    for i in list:
        primeCheck[i] = 1
    for i in list:
        if i == 2:
            continue
        tmp = int((i+1)/2)
        if primeCheck[tmp] == 1:
            check[i] = 1
    #答えを求めるための累積和
    c = [0]*100001
    c[0] = 0
    for i in range(1,100001,1):
        #print(i)
        if check[i] == 1:
            c[i] = c[i-1]+1
        else:
            c[i] = c[i-1]
    #print(c)
    for i in range(Q):
        l,r = map(int,input().split())
        print(c[r]-c[l-1])

main()
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

for y in range(h):
  for x in range(w):
    if s[y][x]=='.':
      cnt=0
      for dy,dx in [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,1],[1,-1],[-1,-1]]:
        ny=y+dy
        nx=x+dx
        if 0<=ny<h and 0<=nx<w and s[ny][nx]=='#':
          cnt+=1
      s[y][x]=str(cnt)

print(''.join(s))

Fixed submission:
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

for y in range(h):
  for x in range(w):
    if s[y][x]=='.':
      cnt=0
      for dy,dx in [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,1],[1,-1],[-1,-1]]:
        ny=y+dy
        nx=x+dx
        if 0<=ny<h and 0<=nx<w and s[ny][nx]=='#':
          cnt+=1
      s[y][x]=str(cnt)

for i in s:
  print(''.join(i))
Buggy python submission (verdict: Runtime Error):
def counting_sort(array,city,road):
    bucket = [0] * city

    for i in range(road):
        for j in range(2):
            bucket[ array[i][j] ] += 1

    return bucket

def main():
    n,m = map(int, input().split())
    way = [list(map(int,input().split())) for _ in range(m)]
    ans_list = counting_sort(way, n, m)
    for k in range(n):
        print( ans_list[i] )

main()   


Fixed submission:
def counting_sort(array,city,road):
    bucket = [0] * city

    for i in range(road):
        for j in range(2):
            bucket[ (array[i][j] - 1) ] += 1

    return bucket

def main():
    n,m = map(int, input().split())
    way = [list(map(int,input().split())) for _ in range(m)]
    ans_list = counting_sort(way, n, m)
    for k in range(n):
        print( ans_list[k] )

main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    end = len(A)
    judge = 0
    ans = 0
    i = 0

    while True:
        if A[i] < A[i+1]:
            ans += 1
            while True:
                i += 1
                if i == end-1:
                    return ans
                elif A[i] <= A[i+1]:
                    continue
                else:
                    i += 1
                    if i == end-1:
                        ans += 1
                        return ans
                    else:
                        break

        elif A[i] > A[i+1]:
            ans += 1
            while True:
                i = i+1
                if i == end-1:
                    return ans
                elif A[i] >= A[i+1]:
                    continue
                else:
                    i += 1
                    if i == end-1:
                        ans += 1
                        return ans
                    else:
                        break

        elif A[i] == A[i+1]:
            i += 1
            if i == end-1:
                ans += 1
                return ans
            else:
                continue

print(main())


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    end = len(A)
    judge = 0
    ans = 0
    i = 0

    if end == 1:
        return 1

    while True:
        if A[i] < A[i+1]:
            ans += 1
            while True:
                i += 1
                if i == end-1:
                    return ans
                elif A[i] <= A[i+1]:
                    continue
                else:
                    i += 1
                    if i == end-1:
                        ans += 1
                        return ans
                    else:
                        break

        elif A[i] > A[i+1]:
            ans += 1
            while True:
                i = i+1
                if i == end-1:
                    return ans
                elif A[i] >= A[i+1]:
                    continue
                else:
                    i += 1
                    if i == end-1:
                        ans += 1
                        return ans
                    else:
                        break

        elif A[i] == A[i+1]:
            i += 1
            if i == end-1:
                ans += 1
                return ans
            else:
                continue

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            if x+y == b:
                ans += 1
            elif  x + y < b:
                for z in range(a+1):
                    if x + y + z == b:
                         ans += 1
                    elif x + y + z > b:
                        break

    return ans

print(main())


Fixed submission:
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            z = b-x-y
            if 0<=z and z<=a:
                ans += 1



    return ans

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            if x+y == b:
                ans += 1
            elif  x + y < b:
                for z in range(a+1):
                    if x + y + z == b:
                         ans += 1

    return ans

print(main())



Fixed submission:
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            z = b-x-y
            if 0<=z and z<=a:
                ans += 1



    return ans

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            for z in range(a+1):
                if x + y + z == b:
                      ans += 1
    return ans

print(main())


Fixed submission:
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            z = b-x-y
            if 0<=z and z<=a:
                ans += 1



    return ans

print(main())
Buggy python submission (verdict: Runtime Error):
def main():
    tenki = input()
    leng = len(tenki)

    count = 0
    lst = []
    for i in range(leng):
        if tenki[i] == "R":
            count += 1
        else:
            lst.append(count)
            count = 0
    
    print(max(lst))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    tenki = input()
    leng = len(tenki)

    count = 0
    lst = []
    for i in range(leng):
        if tenki[i] == "R":
            count += 1
        else:
            lst.append(count)
            count = 0
    lst.append(count)
    count = 0
    print(max(lst))


if __name__ == '__main__':
    main()