Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def knapsack(val,wt,n,k):
    b = [[0 for _ in range(k+1)]for _ in range(n+1)]
    for i in range(n+1):
        for j in range(k+1):
            if j==0 or i==0:
                b[i][j] = 0
            elif wt[i-1]<=j:
                b[i][j] = max(val[i-1]+b[i-1][j-wt[i-1]],b[i-1][j])
            else:
                b[i][j] = b[i-1][j]
    return b[n][k]
from sys import stdin
input = stdin.readline
n,k = list(map(int,input().split()))
val,wt = [],[]
for _ in range(n):
    x,y = list(map(int,input().split()))
    val.append(y)
    wt.append(x)
p = knapsack(val,wt,n,k)
print(p)

Fixed submission:
def knapsack(val,wt,n,k):
    b = [[0 for _ in range(k+1)]for _ in range(n+1)]
    for i in range(n+1):
        for j in range(k+1):
            if j==0 or i==0:
                b[i][j] = 0
            elif wt[i-1]<=j:
                b[i][j] = max(val[i-1]+b[i-1][j-wt[i-1]],b[i-1][j])
            else:
                b[i][j] = b[i-1][j]
    return b[n][k]
from sys import stdin
input = stdin.readline
n,k = list(map(int,input().split()))
val,wt = [],[]
for _ in range(n):
    x,y = list(map(int,input().split()))
    val.append(y)
    wt.append(x)
p = knapsack(val,wt,n,k)
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
def lcs(s,t):
    m,n = len(s),len(t)
    a = [[0 for j in range(n+1)]for i in range(m+1)]
    k,p = "",0
    for i in range(m+1):
        for j in range(n+1):
            if i==0 or j==0:
                a[i][j]=0
            elif s[i-1]==t[j-1]:
                a[i][j]=a[i-1][j-1]+1
            else:
                a[i][j] = max(a[i-1][j],a[i][j-1])
    i,j = m,n
    while i>0 and j>0:
        if s[i-1]==t[j-1]:
            k+=s[i-1]
            i-=1
            j-=1
        elif a[i-1][j]>a[i][j-1]:
            i-=1
        else:
            j-=1
    return k[::-1]
s = input()
t = input()
k = lcs(s,t)
print(k)

Fixed submission:
def lcs(s,t):
    m,n = len(s),len(t)
    a = [[0 for j in range(n+1)]for i in range(m+1)]
    k,p = "",0
    for i in range(m+1):
        for j in range(n+1):
            if i==0 or j==0:
                a[i][j]=0
            elif s[i-1]==t[j-1]:
                a[i][j]=a[i-1][j-1]+1
            else:
                a[i][j] = max(a[i-1][j],a[i][j-1])
    i,j = m,n
    while i>0 and j>0:
        if s[i-1]==t[j-1]:
            k+=s[i-1]
            i-=1
            j-=1
        elif a[i-1][j]>a[i][j-1]:
            i-=1
        else:
            j-=1
    return k[::-1]
s = input()
t = input()
k = lcs(s,t)
print(k)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
judge = True
ans = 1
for i in a:
    ans *= i
    if (ans > 1000000000000000000):
        judge = False

if judge:
    print(ans)
else:
    print(-1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
judge = True
ans = 1
for i in a:
    ans *= i
    if (ans > 1000000000000000000):
        judge = False
        break

if judge:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a>b:
  print("GREATER");
elif a==b:
  print("EQUAL");
else print("LESS");

Fixed submission:
a=int(input())
b=int(input())
if a>b:
  print("GREATER");
elif a==b:
  print("EQUAL");
elif a<b:
  print("LESS");
Buggy python submission (verdict: Runtime Error):
import itertools
from math import ceil

def main():
    n = int(input())
    ans = 10**9
    u = []
    r = []
    d = []
    l = []
    for _ in range(n):
        k = input().split()
        x,y = int(k[0]),int(k[1])
        if(k[2] == "U"):
            u.append((x,y))
        elif(k[2] == "R"):
            r.append((x,y))
        elif(k[2] == "D"):
            d.append((x,y))
        elif(k[2] == "L"):
            l.append((x,y))

    prd = list(itertools.product(l,r))
    for j in prd:
        one = j[0]
        two = j[1]
        if(one[1] == two[1] and one[0] > two[0]):
            dif = abs(one[0] - two[0])
            if(dif % 2 == 0):
                ans = min(ans,dif//2*10)
            
    prd = list(itertools.product(u,d))
    for j in prd:
        one = j[0]
        two = j[1]
        if(one[0] == two[0] and one[1] < two[1]):
            dif = abs(one[1] - two[1])
            if(dif % 2 == 0):
                ans = min(ans,dif//2 * 10)

    prd = list(itertools.product(u,r))
    for j in prd:
        one = j[0]
        two = j[1]
        if(one[0]-two[0] == two[1]-one[1] and one[0]-two[0] > 0 and one[1] - two[1] < 0):
            ans = min(ans,(one[0]-two[0])*10)

    prd = list(itertools.product(u,l))
    for j in prd:
        one = j[0]
        two = j[1]
        if(-one[0] + two[0] == one[1] - two[1] and one[0]-two[0] < 0 and one[1] - two[1] < 0):
            ans = min(ans,(two[0]-one[0])*10)
    
    prd = list(itertools.product(d,r))
    for j in prd:
        one = j[0]
        two = j[1]
        if(one[0]-two[0] == one[1]-two[1] and one[0]-two[0] > 0 and one[1] - two[1] < 0):
            ans = min(ans,(-two[0] + one[0])*10)

    prd = list(itertools.product(d,l))
    for j in prd:
        one = j[0]
        two = j[1]
        if(two[0]-one[0] == one[1] - two[1] and one[0]-two[0] < 0 and one[1] - two[1] > 0):
            ans = min(ans,(two[0] - one[0])*10)
    if(ans == 10**9):
        print("SAFE")
        return
    else:
        print(ans)
        return

if __name__ == "__main__":
    main()

Fixed submission:
n=int(input())

def main():
    if(n<600):
        print(8)
        return
    elif(n<800):
        print(7)
        return
    elif(n<1000):
        print(6)
        return
    elif(n<1200):
        print(5)
        return
    elif(n<1400):
        print(4)
        return
    elif(n<1600):
        print(3)
        return
    elif(n<1800):
        print(2)
        return
    else:
        print(1)
        return
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
while(k>0):
    if(len(a) == 0 or len(b) == 0):
        if(len(a) == 0 and len(b)==0):
            break        
        elif(len(a) == 0):
            if(k >= b[0]):
                k -= b.pop(0)
                ans += 1
            else:
                break
        elif(len(b) == 0):
            if(k >= a[0]):
                k -= a.pop(0)
                ans += 1
            else:
                break
    else:
        if(a[0]>b[0]):
            if(k >= b[0]): 
                k -= b.pop(0)
                ans +=1
            else:
                break
        else:
            if(k >= a[0]):
                k -= a.pop(0)
                ans += 1
            else:
                break
print(ans)

Fixed submission:
a = int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
import sympy
n = int(input())
ans = 0
for i in range(1,n+1):
    k = n//i
    ans += k*(k+1)//2 * i

print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    k = n//i
    ans += k*(k+1)//2 * i

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
a = sorted(list(a))
ma = max(a)

div = defaultdict(bool)
count = 0
for i in range(n):
    b = a[i]
    if div[b]:
        count += 1
    else:
        for j in range(1,ma//b+1):
            div[j*b] = True
        if(i<n and a[i] == a[i+1]):
            count += 1

if(n == 1):
    print(0)
else:
    print(n-count)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
a = sorted(list(a))
ma = max(a)

div = defaultdict(bool)
count = 0
for i in range(n):
    b = a[i]
    if div[b]:
        count += 1
    else:
        for j in range(1,ma//b+1):
            div[j*b] = True
        if(i+1<n and a[i] == a[i+1]):
            count += 1

print(n-count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
def __main__():
    ans = 1
    for i in a:
        ans *= i
    if(ans > 10**18):
        print(-1)
        return
    print(ans)
    return

if(__name__=="__main__"):
    __main__()

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

def __main__():
    ans = 1
    if(0 in a):
        print(0)
        return
    else:
        for i in a:
            ans *= i
            if(ans > 10**18):
                print(-1)
                return
        print(ans)
        return

if(__name__=="__main__"):
    __main__()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
def __main__():
    ans = 1
    for i in a:
        ans *= i
    if(ans > 10**18):
        print(-1)
        return
    print(ans)
    return

if(__name__=="__main__"):
    __main__()

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

def __main__():
    ans = 1
    if(0 in a):
        print(0)
        return
    else:
        for i in a:
            ans *= i
            if(ans > 10**18):
                print(-1)
                return
        print(ans)
        return

if(__name__=="__main__"):
    __main__()
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    for i in range(K):
        print(S[i],end="")
    print("..."3)

Fixed submission:
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    for i in range(K):
        print(S[i],end="")
    print("...")
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int,input().split())
ans = 0
flag = False
for i in range(1,N+1):
    t = math.floor(A*i/B)
    s = A*math.floor(i/B)
    if t-s >= 1:
        flag = True
    if flag and t-s == 0:
        break
    ans = t-s
print(ans)

Fixed submission:
A,B,N = map(int,input().split())
C = N - N%B
ans = A*(C-1)//B - A*((C-1)//B)
if B > N:
    ans = A*N//B - A*(N//B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [i for i in range(N)]
C = []
for i in range(N):
    C.append([A[i],B[i]])
C = sorted(C,reverse=True)
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0] + C[i-1][0]*(-C[i-1][1]+N-i)
    dp[0][i] = dp[0][i-1] + C[i-1][0]*(C[i-1][1]-i+1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i+j <= N:
            c = C[i+j-1][0]
            d = C[i+j-1][1]
            dp[i][j] = max(dp[i-1][j]+c*abs(N-i-d),dp[i][j-1]+c*abs(j-d-1))
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[N][N])

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [i for i in range(N)]
C = []
for i in range(N):
    C.append([A[i],B[i]])
C = sorted(C,reverse=True)
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0] + C[i-1][0]*(-C[i-1][1]+N-i)
    dp[0][i] = dp[0][i-1] + C[i-1][0]*(C[i-1][1]-i+1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i+j <= N:
            c = C[i+j-1][0]
            d = C[i+j-1][1]
            dp[i][j] = max(dp[i-1][j]+c*abs(N-i-d),dp[i][j-1]+c*abs(j-d-1))
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[N][N])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [i for i in range(N)]
C = []
for i in range(N):
    C.append([A[i],B[i]])
C = sorted(C,reverse=True)
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0] + C[i-1][0]*(-C[i-1][1]+N-i)
    dp[0][i] = dp[0][i-1] + C[i-1][0]*(C[i-1][1]-i+1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i+j <= N:
            c = C[i+j-1][0]
            d = C[i+j-1][1]
            dp[i][j] = max(dp[i-1][j]+c*(N-i-d),dp[i-1][j]+c*(d+i-N),dp[i][j-1]+c*(j-d-1),dp[i][j-1]+c*(d-j+1))
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[N][N])

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [i for i in range(N)]
C = []
for i in range(N):
    C.append([A[i],B[i]])
C = sorted(C,reverse=True)
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0] + C[i-1][0]*(-C[i-1][1]+N-i)
    dp[0][i] = dp[0][i-1] + C[i-1][0]*(C[i-1][1]-i+1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i+j <= N:
            c = C[i+j-1][0]
            d = C[i+j-1][1]
            dp[i][j] = max(dp[i-1][j]+c*abs(N-i-d),dp[i][j-1]+c*abs(j-d-1))
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[N][N])
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            p = math.gcd(i,j)
            ans += math.gcd(p,k)

print(ans)

Fixed submission:
import math
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            p = math.gcd(i,j)
            ans += math.gcd(p,k)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,A,B,C = map(int,input().split())
p,q,r = [sorted(map(int,input().split()),reverse=True) for i in range(3)]
ans,temp = 0,0

for i in range(X+1):
    temp = sum([p[t] for t in range(i)])
    for j in range(Y+1):
        temp_2 = temp + sum([q[t] for t in range(j)])
        t = lambda C: X-i+Y-j if X+Y-i-j < C else C
        temp_2 += sum([r[t] for t in range(t(C))]) 
        ans = max(temp_2,ans)

print(ans)

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p,q,r = [sorted(map(int,input().split()),reverse=True) for i in range(3)]
ans = 0
pp,qq = [p[i] for i in range(X)] ,[q[i] for i in range(Y)]
r = r + pp + qq
r = sorted(r,reverse=True)
for i in range(X+Y):
    ans += r[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
print(N(N+1)/2+M(M+1)/2)

Fixed submission:
N,M = map(int,input().split())
print(int(N*(N-1)/2+M*(M-1)/2))
Buggy python submission (verdict: Runtime Error):
S = input()
n = len(S)
isKaibun = True
for i in range(n//2):
    if(S[i] != S[n-i-1] or S[i] != S[n//2-i-1] or S[n//2+i+a1] != S[n//2-i-1]):
        isKaibun = False
        break
if(isKaibun):
    print("Yes")
else:
    print("No")

Fixed submission:
S = input()
n = len(S)
isKaibun = True
for i in range(n//2):
    if(S[i] != S[n-i-1] or S[i] != S[n//2-i-1] or S[n//2+i+1] != S[n//2-i-1]):
        isKaibun = False
        break
if(isKaibun):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sympy

A,B = map(int,input().split())
sympy.var("x")
sol1 = sympy.solve(x*0.08-A,x)
sol2 = sympy.solve(x*0.10-B,x)
ans = lambda x1,x2 : x1 if x1 == x2 else -1
print(int(ans(sol1[0],sol2[0])))

Fixed submission:
import math
A,B = map(int,input().split())
sol1 = math.ceil(A/0.08)
sol2 = math.ceil(B/0.10)
ans = lambda x1,x2 : x1 if x1 == x2 else -1
flagA = True
flagB = True
while True:
    if(sol1 * 0.08 < A and flagA):
        flagA = False
        if(math.floor((sol1+1)*0.10) == B):
            print(sol1+1)
            break
    sol1 -= 1
    if(sol2 * 0.10 < B and flagB):
        flagB = False
        if(math.floor((sol2+1)*0.08) == A):
            print(sol2+1)
            break
    if(not flagA and not flagB):
        print(-1)
        break
    sol2 -= 1
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
arr = np.arange(3) 
for i in range(N):
    arr[A[i]-1] = i+1
for i in range(N):   
    print(arr[i],end=" ")

Fixed submission:
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
arr = np.arange(N) 
for i in range(N):
    arr[A[i]-1] = i+1
for i in range(N):   
    print(arr[i],end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split()]
S = list(map (int, list(input())))
start = S[0]
row = []
state = [0,start]
for i in S:
    if i == start:
        state[0] += 1
    else:
        row.append(state)
        start = i
        state = [1,i]
row.append(state)
ans = []
for i in range(max(len(row)-K*2+1,1)):
    if row[i][1] == 1:
        ans.append(sum([row[i][0] for i in range(i,min(K*2+i+1,len(row)))]))
    else:
        ans.append(sum([row[i][0] for i in range(i,min(K*2+i,len(row)))]))
print(max(ans))

Fixed submission:
N,K = map(int,input().split())
S = input()
row = []
count = 1
flag = S[0]
for i in range(1,N):
    if S[i] != flag:
        row.append([count,flag])
        count = 1
        flag = S[i]
    else:
        count += 1
row.append([count,flag])
inst = 0
ans,temp = 0,0
left,right = 0,0
for i in range(len(row)):
    if row[i][1] == "1":
        temp += row[i][0]
    else:
        inst += 1
        if inst <= K:
            temp += row[i][0]
        else:
            temp -= row[left][0]
            if row[left][1] == "1":
                temp -=row[left+1][0]
                left += 1
            temp += row[i][0]
            left += 1
    ans = max(ans,temp)
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
line = input()
list = ["A","T","G","C"]
if line == list[0]:
    print(list[1])
elif line == list[1]:
    print(list[0])
elif line == list[2]:
    print(list[3])
else:
    print(list[4])

Fixed submission:
# coding: utf-8
line = input()
list = ["A","T","G","C"]
if line == list[0]:
    print(list[1])
elif line == list[1]:
    print(list[0])
elif line == list[2]:
    print(list[3])
else:
    print(list[2])
Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
num = list(map(int, input().split()))
k = K
ans = 0
count = 0
print(K)
if K == 0:
    print(sum(num))
else:
    K2 = []
    while K>0:
        K2.append(K % 2)
        K //= 2
    data = []
    for i in num:
        num2 = []
        while i > 0:
            num2.append(i % 2)
            i //= 2
        while len(num2) < len(K2):
            num2.append(0)
        data.append(list(reversed(num2)))
    for i in range(len(K2)):
        t = 0
        b = 2**(len(K2) - i - 1) #べき乗
        for j in range(N):
            t += data[j][i]
        if t >= N-t:
            ans += b * t
        else:
            count += b
            if count <= k:
                ans += b * (N-t)
            else:
                ans += b * t
    print(ans)

Fixed submission:
N, Q = [float(i) for i in input().split()]
print(N/Q)
Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
H = sorted([int(input()) for i in range(N)])
ans = H[K - 1] - H[0]
for i in range(N - K + 1):
    t = H[K + i - 1] - H[i]
    if ans > t:
        ans = t
print(ans)

Fixed submission:
D = int(input())
if D == 25:
    print("Christmas")
elif D == 24:
    print("Christmas Eve")
elif D == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Runtime Error):
s=int(input())
ans=0
wakeru=0
while s>0:
    s=s-3
    ans=ans+cmb(s+wakeru,wakeru,p)
    wakeru+=1
print(ans%(10**9+7))

Fixed submission:
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


s=int(input())
ans=0
wakeru=0
while s>0:
    s=s-3
    ans=ans+cmb(s+wakeru,wakeru,p)
    wakeru+=1
print(ans%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
ans=1
s=7%k
if k%2==1:
    while True:
        if s==0:
            break
        else:
            s=s*10+7
            s%=k
            ans+=1
    print(ans)
else:
    print(-1)

Fixed submission:
k=int(input())
ans=1
judge=0
s=7%k
while ans<=k:
    if s==0:
        judge=1
        break
    else:
        s=s*10+7
        s%=k
        ans+=1
if judge==1:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
ans=1
s=7%k
if k%2==1:
    while True:
        if s==0:
            break
        else:
            s=s*10+7
            s%=k
            ans+=1
    print(ans)
else:
    print(-1)

Fixed submission:
k=int(input())
ans=1
judge=0
s=7%k
while ans<=k:
    if s==0:
        judge=1
        break
    else:
        s=s*10+7
        s%=k
        ans+=1
if judge==1:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
s=7
ans=1
if k%2==1:
    
    while True:
        if s%k==0:
            break
        else:
            s=s*10+7
            s%=k
            ans+=1
    print(ans)
else:
    print(-1)

Fixed submission:
k=int(input())
ans=1
judge=0
s=7%k
while ans<=k:
    if s==0:
        judge=1
        break
    else:
        s=s*10+7
        s%=k
        ans+=1
if judge==1:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
s=7
ans=1
while True:
    if s%k==0:
        break
    else:
        s=s*10+7
        ans+=1
print(ans)

Fixed submission:
k=int(input())
ans=1
judge=0
s=7%k
while ans<=k:
    if s==0:
        judge=1
        break
    else:
        s=s*10+7
        s%=k
        ans+=1
if judge==1:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
x=int(input())
for i in range(100):
    k=x-i**5
    a=k**0.2
    if type(a)==complex:
        continue
    if a.is_integer():
        break
print(-i,int(a))

Fixed submission:
s=input()
if s=="ABC":
    print("ARC")
else :
    print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
lcm = 1
for i in range(n):
    lcm = a[i] * lcm // gcd(a[i], lcm)
b = [lcm // a[i] for i in range(n)]
print(sum(b) % (10**9+7))

Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
lcm = 1
for i in range(n):
    lcm = a[i] * lcm // gcd(a[i], lcm)
b = [lcm // a[i] for i in range(n)]
print(sum(b) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
#97
judge=0
N,M = map(int,input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for i in a:
    if (ans//i)%2==0:
        judge=1
        sss=0
        break
if judge==0 and M-ans//2 <0:
    sss=0
elif judge==0 and M-ans >=0:
    sss=((M-ans//2)//ans)+1
print(sss)

Fixed submission:
judge=0
N,M = map(int,input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for j in a:
    if (ans//j)%2==0:
        judge=1
        sss=0
        break
if judge==0 and M-ans//2 <0:
    sss=0
elif judge==0 and M-ans//2 >=0:
    sss=((M-ans//2)//ans)+1
print(sss)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int, input().split()))
new=sorted(a,reverse=True)
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if new[i]>=new[j]+new[k]:
                break
            else:
                ans+=1
print(ans)

Fixed submission:
import bisect
n=int(input())
a = list(map(int, input().split()))
new=sorted(a)
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        m=bisect.bisect_left(new,new[i]+new[j])
        ans+=(m-1)-j
print(ans)
Buggy python submission (verdict: Runtime Error):
N=input()
if N%2==0:
  ans=0.5
else:
  ans=(N+1)/(2*N)
print(ans)
  

Fixed submission:
n=int(input())
if n%2==0:
    print(0.5)
else:
    print((n+1)/(2*n))