Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(_) for _ in input().split(" ")]

max=max(A)
if A[0] == max:
  total=0
  for i in range(len(A)):
    total = total + max - A[i]
  print(total)
  exit()

ans=0
total=0
b=len(A)
a=1

while a!=0:
  max=0
  for i in range(b):
    if max < A[i]:
      a=i
      max=A[i]
  for i in range(a+1,b):
    total += max - A[i]
  b=a

print(total)
    


Fixed submission:
N=int(input())
A=[int(_) for _ in input().split(" ")]

max=0
total=0

for i in range(len(A)):
  if max < A[i]:
    max=A[i]
  else:
    total+=max-A[i]

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(_) for _ in input().split(" ")]

max=max(A)
 
if A[0] == max:
  total=0
  for i in range(len(A)):
    total=total+max-A[i]
  print(total)
  exit()

ans=0
total=0
b=len(A)
a=1

while a!=0:
  max=0
  for i in range(b):
    if max < A[i]:
      a=i
      max=A[i]
  for i in range(a,b):
    total += max - A[i]
  b=a

print(total)
    


Fixed submission:
N=int(input())
A=[int(_) for _ in input().split(" ")]

max=0
total=0

for i in range(len(A)):
  if max < A[i]:
    max=A[i]
  else:
    total+=max-A[i]

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)


#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    c[C] += c[B]
    del c[B]
  else:
    c[C] = c[B]
    del c[B]
  
  #print(c)
  
  #s=list(c.keys())
  ans=0
  for v in c:
    ans += v*c[v]
  
  print(ans)

Fixed submission:
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)

ans=0
for v in c:
  ans += v*c[v]

#print(c)
#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    ans=ans-B*c[B]+C*c[B]
    c[C] += c[B]
    del c[B]
  else:
    ans=ans-B*c[B]+C*c[B]
    c[C] = c[B]
    del c[B]
  
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)


#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    c[C] += c[B]
    del c[B]
  else:
    c[C] = c[B]
    del c[B]
  
  #print(c)
  
  s=list(c.keys())
  j=0
  ans=0
  for v in c.values():
    ans += s[j]*v
    j=j+1
  
  print(ans)


  
  

Fixed submission:
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)

ans=0
for v in c:
  ans += v*c[v]

#print(c)
#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    ans=ans-B*c[B]+C*c[B]
    c[C] += c[B]
    del c[B]
  else:
    ans=ans-B*c[B]+C*c[B]
    c[C] = c[B]
    del c[B]
  
  print(ans)

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

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)


#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    c[C] += c[B]
    del c[B]
  else:
    c[C] = c.pop(B)
  
  #print(c)
  
  s=list(c.keys())
  j=0
  ans=0
  for v in c.values():
    ans += s[j]*v
    j=j+1
  
  print(ans)


  
  

Fixed submission:
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)

ans=0
for v in c:
  ans += v*c[v]

#print(c)
#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    ans=ans-B*c[B]+C*c[B]
    c[C] += c[B]
    del c[B]
  else:
    ans=ans-B*c[B]+C*c[B]
    c[C] = c[B]
    del c[B]
  
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
# a=int(input())
# a,b=map(int,input().split(" "))
A=[int(_) for _ in input().split(" ")]

if A[0] == 0:
    ans=0
    print(ans)
    exit()
else:
    ans=A[0]

for i in range(1,N):
    if A[i] == 0:
        ans=0
        break
    ans *= A[i]

if ans > 10**18:
    ans = -1
print(ans)


Fixed submission:
N=int(input())
# a=int(input())
# a,b=map(int,input().split(" "))
A=[int(_) for _ in input().split(" ")]

if A[0] == 0:
    ans=0
    print(ans)
    exit()
else:
    ans=A[0]

for i in range(1,N):
    if A[i] == 0:
        ans=0
        break
    elif ans < 0:
        ans = -1
    elif A[i] == 10**18:
        ans = -1
    else:
        ans *= A[i]
        if ans > 10**18:
            ans = -1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#A,B,C,D=map(int,input().split(" "))

N=int(input())

S=[]
ans=0

for i in range(N):
  a=input()
  if a in S:
    a=0
  else:
    S.append(a)
    ans += 1
  
print(ans)

Fixed submission:
#A,B,C,D=map(int,input().split(" "))

N=int(input())

S=[]
ans=0

for i in range(N):
  S.append(input())

ans = len(list(set(S)))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#A,B,C,D=map(int,input().split(" "))

N=int(input())

S=[]

for i in range(N):
  a=input()
  if a in S:
    a=0
  else:
    S.append(a)
ans=len(S)
  
print(ans)

Fixed submission:
#A,B,C,D=map(int,input().split(" "))

N=int(input())

S=[]
ans=0

for i in range(N):
  S.append(input())

ans = len(list(set(S)))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

total=0
N=int(input())

for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            total += gcd(i,j,k)
            

print(total)


Fixed submission:
import math
from functools import reduce

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

total=0
N=int(input())

for i in range(1,N+1):
    for j in range(i,N+1):
        if i==j:
            for k in range(j,N+1):
                if j==k:
                    total += gcd(i,j,k)
                else:
                    total += 3*gcd(i,j,k)
        else:
            for k in range(j,N+1):
                if j==k:
                    total += 3*gcd(i,j,k)
                else:
                    total += 6*gcd(i,j,k)
            
print(total)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
c=s[k-1]
sl=list(s)
for i in range(n):
	if sl[i] != c:
		sl[i] = '*'

print("".join(sl))

Fixed submission:
arr=input().split(' ')
a=int(arr[0])
b=int(arr[1])
c=int(arr[2])
if ( a < c and c < b ) or ( b < c and c < a ):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
sides = []
for i in range(n):
  sides.append(int(input()))
maxim = max(sides)
if maxim>sum(sides)-maxim:
  print("No")
else:
  print("Yes")

Fixed submission:
n = int(input())
sides = []
sides2 = input()
sides2 = sides2.split()
for i in sides2:
  sides.append(int(i))
maxim = max(sides)
if maxim>=sum(sides)-maxim:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
nm = input()
nm = nm.split()
n = int(nm[0])
m = int(nm[1])
nums = input()
nums = nums.split()
nums2 = []
for i in nums:
  nums2.append(int(i))
nums3 = []
i = 1
while i<len(nums2):
  nums3.append(nums2[i]-nums2[i-1])
  i+=1
for i in range(n-1):
  nums3.remove(max(nums3))
print(sum(nums3))

Fixed submission:
nm = input()
nm = nm.split()
n = int(nm[0])
m = int(nm[1])
nums = input()
nums = nums.split()
nums2 = []
for i in nums:
  nums2.append(int(i))
nums2.sort()
nums3 = []
i = 1
while i<len(nums2):
  nums3.append(nums2[i]-nums2[i-1])
  i+=1
nums3.sort()
nums3 = nums3[:len(nums3)-n+1]
if(n>=m):
  print(0)
else:
  print(sum(nums3))
Buggy python submission (verdict: Runtime Error):
n = int(input())
items = []
for i in range(n):
  items.append(int(input()))
result = sum(items)-max(items)/2
print(result[:len(result)-2])


Fixed submission:
n = int(input())
items = []
for i in range(n):
  items.append(int(input()))
result = str(sum(items)-max(items)/2)
print(result[:len(result)-2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
items = []
for i in range(n):
  items.append(int(input())
print(sum(items)-max(items)/2)

Fixed submission:
n = int(input())
items = []
for i in range(n):
  items.append(int(input()))
result = str(sum(items)-max(items)/2)
print(result[:len(result)-2])
Buggy python submission (verdict: Runtime Error):
nk = input()
nk = nk.split()
n = int(n[0])
k = int(n[1])
trees = []
for i in range(n):
  trees.append(int(input()))
trees.sort()
minimum = 1000000000
i = 0
while i<=n-k:
  if trees[i+k-1]-trees[i]<minimum:
    minimum = trees[i+k-1]-trees[i]
  i+=1
print(minimum)

Fixed submission:
nk = input()
nk = nk.split()
n = int(nk[0])
k = int(nk[1])
trees = []
for i in range(n):
  trees.append(int(input()))
trees.sort()
minimum = 1000000000
i = 0
while i<=n-k:
  if trees[i+k-1]-trees[i]<minimum:
    minimum = trees[i+k-1]-trees[i]
  i+=1
print(minimum)
Buggy python submission (verdict: Runtime Error):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(a+"+"+b+"+"+c+"+"+d+"=7")
elif a+b+c-d==7:
  print(a+"+"+b+"+"+c+"-"+d+"=7")
elif a+b-c+d==7:
  print(a+"+"+b+"-"+c+"+"+d+"=7")
elif a+b-c-d==7:
  print(a+"+"+b+"-"+c+"-"+d+"=7")
elif a-b+c+d==7:
  print(a+"-"+b+"+"+c+"+"+d+"=7")
elif a-b+c-d==7:
  print(a+"-"+b+"+"+c+"-"+d+"=7")
elif a-b-c+d==7:
  print(a+"-"+b+"-"+c+"+"+d+"=7")
else:
  print(a+"-"+b+"-"+c+"-"+d+"=7")

Fixed submission:
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
else:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

Buggy python submission (verdict: Runtime Error):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(a+"+"b+"+"+c+"+"+d+"=7")
elif a+b+c-d==7:
  print(a+"+"b+"+"+c+"-"+d+"=7")
elif a+b-c+d==7:
  print(a+"+"b+"-"+c+"+"+d+"=7")
elif a+b-c-d==7:
  print(a+"+"b+"-"+c+"-"+d+"=7")
elif a-b+c+d==7:
  print(a+"-"b+"+"+c+"+"+d+"=7")
elif a-b+c-d==7:
  print(a+"-"b+"+"+c+"-"+d+"=7")
elif a-b-c+d==7:
  print(a+"-"b+"-"+c+"+"+d+"=7")
else:
  print(a+"-"b+"-"+c+"-"+d+"=7")

Fixed submission:
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
else:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
i = int(math.sqrt(n))
while i<=n:
  if n%i==0:
    print(len(str(i)))
    break
  i+=1


Fixed submission:
import math

n = int(input())
i = int(math.sqrt(n))
while i>0:
  if n%i==0:
    print(len(str(int(n/i))))
    break
  i-=1

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
i = int(math.sqrt(n))
while i<=n:
  if n%i==0:
    print(len(str(i)))
    break
  i+=1

Fixed submission:
import math

n = int(input())
i = int(math.sqrt(n))
while i>0:
  if n%i==0:
    print(len(str(int(n/i))))
    break
  i-=1
Buggy python submission (verdict: Runtime Error):
import math

nab = [int(x) for x in input().split()]
n = nab[0]
a = nab[1]
b = nab[2]
counts = []
nums = [int(x) for x in input().split()]
means = []
nums.sort(reverse = True)
for i in range(a, b+1):
  #means.append(sum(nums[:i])/i)
    
  
  j = i
  while j<n:
    if nums[j-1]==nums[j]:
      j+=1
    else:
      break
  
  for k in range(int(math.factorial(j)/(math.factorial(i)*math.factorial(j-i)))):
    means.append(sum(nums[:i])/i)
  #counts.append(math.comb(j, i))
  print(math.factorial(j)/(math.factorial(i)*math.factorial(j-i)))
  print(math.factorial(4)/(math.factorial(2)*math.factorial(2)))
  print(math.factorial(4))
  print(j, i)
print(max(means))
#print(counts[
print(means.count(max(means)))

'''
def C(n, k):
  return C(n-1, k-1) + C(n-1, k)
  
for n in range(MAX_N):
  for k in range(MAX_K):
    C[n][k] = C[n-1][k-1] + C[n-1][k]

Fixed submission:
import math

nab = [int(x) for x in input().split()]
n = nab[0]
a = nab[1]
b = nab[2]
counts = []
nums = [int(x) for x in input().split()]
means = []
nums.sort(reverse = True)
for i in range(a, b+1):
  means.append(sum(nums[:i])/i)
  counts.append(int(math.factorial(nums.count(nums[i-1]))/(math.factorial(nums[:i].count(nums[i-1]))*math.factorial(nums.count(nums[i-1])-nums[:i].count(nums[i-1])))))

maxim = max(means)
print(maxim)
k = 0
count = 0
while k<len(means):
  if means[k]==maxim:
    count+=counts[k]
  k+=1
print(count)

#print(means.count(max(means)))

'''
def C(n, k):
  return C(n-1, k-1) + C(n-1, k)
  
for n in range(MAX_N):
  for k in range(MAX_K):
    C[n][k] = C[n-1][k-1] + C[n-1][k]
'''
Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A_list=list(map(int,input().split()))
B_list=list(map(int,input().split()))

ans = 0

def dfs_A(n,m,t,c):
  global ans
  x = t+A_list[n]
  if x > K:
    if c > ans:
      ans = c
  elif x == K:
    if c+1 > ans:
      ans = c+1
  else:
    if n+1 <= N-1 and m <= M-1:
      dfs_A(n+1,m,x,c+1)
    if n <= N and m+1 <= M-1:
      dfs_B(n+1,m,x,c+1)

def dfs_B(n,m,t,c):
  global ans
  x = t+B_list[m]
  if x > K:
    if c > ans:
      ans =c
  elif x == K:
    if c+1 > ans:
      ans = c+1
  else:
    if n+1 <= N-1 and m <= M-1:
      dfs_A(n,m+1,x,c+1)
    if n <= N and m+1 <= M-1:
      dfs_B(n,m+1,x,c+1)

dfs_A(0,0,0,0)
dfs_B(0,0,0,0)
print(ans)

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

a,b = [0],[0]

for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
  
ans = 0
j = M

for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int,input().split())
ans=0

for x in range(n+1):
  c = math.floor(a*x/b)-a*(math.floor(x/b))
  if c > ans:
    ans = c

print(ans)

Fixed submission:
import math

a,b,n = map(int,input().split())
ans=0
c = 0

if n >= b:
  c = b-1
else:
  c = n

ans = math.floor(c*a/b)-a*(math.floor(c/b))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = list(int(input()))
answer = "No"
 
for i in range(N):
  if N[i] == 7:
    answer = "Yes"
 
print(answer)

Fixed submission:
N = list((input()))
ans = "No"
 
for i in N:
  if i == "7":
    ans = "Yes"
         
print(ans)

Buggy python submission (verdict: Runtime Error):
N = list(int(input()))
answer = "No"

for i in N:
  if i == 7:
    answer = "Yes"

print(answer)

Fixed submission:
N = list((input()))
ans = "No"
 
for i in N:
  if i == "7":
    ans = "Yes"
         
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
ans = 0

K = int(input())

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd(i,j,k)
      
print(ans)

Fixed submission:
import math
ans = 0

K = int(input())

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd(i,math.gcd(j,k))
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
ans = 0

K = int(input())

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd(i,math.gcd(j,k))
      
print(ans)

Fixed submission:
import math
ans = 0

K = int(input())

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd(i,math.gcd(j,k))
      
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
print(min(abs(n%k),k-abs(n%k))

Fixed submission:
n,k = map(int,input().split())
x = n % k
a = min(abs(k-x),n,x)


print(a)
Buggy python submission (verdict: Runtime Error):
n,k,c = map(int,input().split())
s = list(input())

front = [0]*n
back = [0]*n

# 前から貪欲
c = k
i = 0
while c > 0:
  if s[i] == "o":
    front[i] = 1
    i += c+1
  else:
    i += 1
  c -= 1

# 後ろから貪欲

c = k
i = n-1
while c > 0:
  if s[i] == "o":
    back[i] = 1
    i -= c+1
  else:
    i -= 1
  c -= 1
  
for i in range(n):
  if front[i] == 1 and back[i] == 1:
    print(i+1)

Fixed submission:
import copy
 
n,k,c = map(int,input().split())
s = list(input())
 
front = []
back = []
 
# 前から貪欲
j = copy.copy(k)
i = 0
while j > 0:
  if s[i] == "o":
    front.append(i)
    i += c+1
    j -= 1
  else:
    i += 1
 
# 後ろから貪欲
 
j = copy.copy(k)
i = n-1
while j > 0:
  if s[i] == "o":
    back.append(i)
    i -= c+1
    j -= 1
  else:
    i -= 1

back.sort()
for i in range(k):
  if front[i] == back[i]:
    print(front[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
ans = 1
for i in range(n):
    ans = ans * a[0][i]

if ans > 10**18:
    ans = str('-1')
print(ans)

Fixed submission:
import numpy as np
import sys

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = a[0]
list.sort(arr, reverse=True)

if arr[-1] == 0:
    print(arr[-1])
    sys.exit()

ans = 1
for i in range(n):
    ans = ans * arr[i]
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
t = input()
t = list(t)
count = 1
while(True):
    count = 0
    for i in range(len(t)):
        if t[i] == "?":
            count = count + 1
            if t[i+1] == "P":
                t[i] = 'D'
            elif t[i+1] == "D":
                t[i] = 'P'
    if count == 0:
        break
ans = "".join(t)
print(ans)

Fixed submission:
t = input()
t = list(t)

for i in range(len(t)):
    if t[i] == "?":
        t[i] = 'D'
ans = "".join(t)
print(ans)
Buggy python submission (verdict: Runtime Error):
k=int(input())
if k%2==0 k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
a=0
while True:
    a=(a*10+7)%k
    if a==0:
        print(count)
        exit()
    count+=1

Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=1


Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=1


Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=1

Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=len(str(k))

Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()
Buggy python submission (verdict: Runtime Error):
import functools
import operator
n,k=map(int,input().split())
a=list(map(int,input().split()))
a1=a[k-1:]
result = functools.reduce(operator.mul, a1)
for i in range(n-k):
    if result<result/a[i]*a[i+k]:
        print('Yes')
    else:
        print('No')
    result=result/a[i]*a[i+k]

Fixed submission:
x=int(input())
print(8-(x-400)//200)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
time=0
count=0
while time<k:
    if count==(n+m-1):
        count=n+m+1
        break
    elif count//2>=n or count//2>=m:
        count+=1
        continue
    elif count%2==0:
        time+=a[count//2]
        count+=1
    else:
        time+=b[count//2]
        count+=1
print(count-1)

Fixed submission:
n=int(input())
print(n+n**2+n**3)

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
time=0
count=0
while time<k:
    if count==(n+m-1):
        count=n+m+1
        break
    elif count//2>=n or count//2>=m:
        count+=1
        continue
    elif count%2==0:
        time+=a[count//2]
        count+=1
    else:
        time+=b[count//2]
        count+=1
print(count-1)

Fixed submission:
n=int(input())
print(n+n**2+n**3)
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    mina=100
    for i in range(min(p),max(p)):
        if i not in p:
            if mina>abs(i-x):
                mina=abs(i-x)
                ans=i
                if ans>x and (x-mina) not in p:
                    ans=x-mina
except:
    ans=x

print(ans)

Fixed submission:
x=list(map(int,input().split()))
count=0
for i in x:
    count+=1
    if i==0:
        print(count)
        break

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    p.sort()
    min=abs(p[0])
    for i in range(p[0],p[n-1]):
        if i not in p:
            if min>abs(i-x):
                min=abs(i-x)
                ans=i
except:
    ans=x
print(ans)

Fixed submission:
x=list(map(int,input().split()))
count=0
for i in x:
    count+=1
    if i==0:
        print(count)
        break