Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = [a for a in input()]
N = [int(a) for a in S]
M = [N[i] for i in range(1,4)]
S.insert(1, '+')
S.insert(3, '+')
S.insert(5, '+')

if sum(N) == 7:
    S = S
    print(''.join(S) + '=7')
    exit()

for i in range(1, 4):
    N[i] = -N[i]

    if sum(N) == 7:
        S[2 * i - 1] = '-'
        print(''.join(S) + '=7')
        exit()

for i in range(1, 4):
    S[1], S[3], S[5] == '-', '-', '-'
    M[i] = -M[i]
    if sum(M) == 7:
        S[2 * i - 1] = '+'
        print(''.join(S) + '=7')
        exit()

Fixed submission:
S = [a for a in input()]
N = [int(a) for a in S]
M = [N[0]] + [-N[i] for i in range(1,4)]

S.insert(1, '+')
S.insert(3, '+')
S.insert(5, '+')

if sum(N) == 7:
    S = S
    print(''.join(S) + '=7')
    exit()

for i in range(1, 4):
    N[i] = -N[i]
    
    if sum(N) == 7:
        
        S[2 * i - 1] = '-'
        print(''.join(S) + '=7')
        exit()
    else: N[i] = -N[i]

for i in range(1, 4):
    S[1], S[3], S[5] = '-', '-', '-'
    
    M[i] = -M[i]
    
    if sum(M) == 7:
        S[2 * i - 1] = '+'
        print(''.join(S) + '=7')
        exit()
    else:
      M[i] = -M[i]

Buggy python submission (verdict: Runtime Error):
S = [a for a in input()]
N = [int(a) for a in S]
M = [-N[i] for i in range(1,4)]
S.insert(1, '+')
S.insert(3, '+')
S.insert(5, '+')

if sum(N) == 7:
    S = S
    print(''.join(S) + '=7')
    exit()

for i in range(1, 4):
    N[i] = -N[i]

    if sum(N) == 7:
        S[2 * i - 1] = '-'
        print(''.join(S) + '=7')
        exit()

for i in range(1, 4):
    M[i] = -M[i]
    if sum(M) == 7:
        S[2 * i - 1] = '+'
        print(''.join(S) + '=7')
        exit()

if N[0] + N[1] - N[2] - N[3] == 7:
    S[3] = '-'
    S[5] = '-'
elif N[0] - N[1] + N[2] - N[3] == 7:
    S[1] = '-'
    S[5] = '-'
elif N[0] - N[1] - N[2] + N[3] == 7:
    S[1] = '-'
    S[5] = '-'
print(''.join(S) + '=7')

Fixed submission:
S = [a for a in input()]
N = [int(a) for a in S]
M = [N[0]] + [-N[i] for i in range(1,4)]

S.insert(1, '+')
S.insert(3, '+')
S.insert(5, '+')

if sum(N) == 7:
    S = S
    print(''.join(S) + '=7')
    exit()

for i in range(1, 4):
    N[i] = -N[i]
    
    if sum(N) == 7:
        
        S[2 * i - 1] = '-'
        print(''.join(S) + '=7')
        exit()
    else: N[i] = -N[i]

for i in range(1, 4):
    S[1], S[3], S[5] = '-', '-', '-'
    
    M[i] = -M[i]
    
    if sum(M) == 7:
        S[2 * i - 1] = '+'
        print(''.join(S) + '=7')
        exit()
    else:
      M[i] = -M[i]
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())

S = [list(input()) for i in range(H)]
for i in range(1,H-1):
  for j in range(1,W-1):
    if S[i][j] == '.':
      x = [S[i-1][j-1], S[i-1][j], S[i-1][j+1], S[i][j-1], S[i][j+1],S[i+1][j-1], S[i+1][j],S[i+1][j+1]]
      S[i][j] = x.count('#')

for j in range(1,W-1):
  if S[0][j] == '.':
    x = [S[0][j-1], S[0][j+1], S[1][j-1], S[1][j], S[1][j+1]]
    S[0][j] = x.count('#')
    
  if S[H-1][j] == '.':
    x = [S[H-1][j-1], S[H-1][j+1], S[H-2][j-1], S[H-2][j], S[H-2][j+1]]
    S[H-1][j] = x.count('#')

for i in range(1, H-1):
  if S[i][0] == '.':
    x =[S[i-1][0],S[i-1][1],  S[i][1], S[i+1][0], S[i+1][1]]
    S[i][0] = x.count('#')
  if S[i][W-1] == '.':
    x =[S[i-1][W-1],S[i-1][W-2],  S[i][W-2], S[i+1][W-1], S[i+1][W-2]]
    S[i][W-1] = x.count('#')

if S[0][0] == '.':
  x = [S[0][1], S[1][0], S[1][1]]
  S[0][0] =x.count('#')
if S[H-1][0] == '.':
  x = [S[H-1][1], S[H-2][0], S[H-2][1]]
  S[H-1][0] = x.count('#')
if S[0][W-1] == '.':
  x = [S[0][W-2], S[1][W-1], S[1][W-2]]
  S[0][W-1] = x.count('#')
if S[H-1][W-1] == '.':
  x = [S[H-1][W-2], S[H-2][W-1], S[H-2][W-2]]
  S[H-1][W-1] = x.count('#')

for i in range(len(S)):
  S[i] = [str(x) for x in S[i]]
  print(''.join(S[i]))

Fixed submission:
h, w = map(int, input().split())

s = [['.']*(w+2)]+ [list('.'+ input() + '.') for i in range(h)] + [['.']*(w+2)]
a = [[0]*w for i in range(h)]


for i in range(1, h+1):
  for j in range(1,w+1):
    if s[i][j] == '#':
      a[i-1][j-1] = '#'
    else:
      b = [s[i-1][j-1],s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]
      c = b.count('#')
           
      a[i-1][j-1] = c

for i in range(h):
  a[i] = [str(x) for x in a[i]]
  print(''.join(a[i]))
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
dd = list(map(int, input().split()))
m = int(input())
tt = list(map(int, input().split()))
cd = collections.Counter(dd)
ct = collections.Counter(tt)

if m > n:
  print('NO')
  exit()
        

for t in tt: 
  if t in dd and ct[t] <= cd[t]:
    continue
  else:
    print('NO')
    exit()
print('YES')


Fixed submission:
import collections
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

if m > n:
    print("NO")
    exit()

d_c = collections.Counter(d_list)
t_c = collections.Counter(t_list)

for i in t_c:
    if t_c[i] <= d_c[i]:
        continue
    else:
        print("NO")
        exit()

print("YES")

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

n = int(input())
dd = list(map(int, input().split()))
m = int(input())
tt = list(map(int, input().split()))
cd = collections.Counter(dd)
ct = collections.Counter(tt)

for t in tt:
 
  if t in dd and ct[t] <= cd[t]:
    continue
  else:
    print('NO')
    exit()
print('YES')

Fixed submission:
import collections
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

if m > n:
    print("NO")
    exit()

d_c = collections.Counter(d_list)
t_c = collections.Counter(t_list)

for i in t_c:
    if t_c[i] <= d_c[i]:
        continue
    else:
        print("NO")
        exit()

print("YES")

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

for t in tt:
  if dd.count(t) >= tt.count(t):
    continue
  else:
    print('NO')
    exit()
print('YES')

Fixed submission:
import collections
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

if m > n:
    print("NO")
    exit()

d_c = collections.Counter(d_list)
t_c = collections.Counter(t_list)

for i in t_c:
    if t_c[i] <= d_c[i]:
        continue
    else:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Runtime Error):
Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
  arr.append(int(0.5*D*N))
elif:
  if N >= 3:
    arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
    
print(min(arr))

Fixed submission:
Q, H, S, D = map(int, input().split())
N = int(input())
x = N % 2
y = N // 2
arr = [4*Q*x, 2*H*x, S*x]
arr1 = [8*Q*y, 4*H*y, 2*S*y, D*y]
#if N % 2 == 0:
#  arr.append(int(0.5*D*N))
#else:
#  arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
   
print(min(arr) + min(arr1))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a1 = []
bn = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    a1.append(b)
  elif b == n:
    bn.append(a)


for x in a1:
  if x in bn:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')

Fixed submission:
n, m = map(int, input().split())
a1 = []
bn = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    a1.append(b)
  elif b == n:
    bn.append(a)
la = len(a1)
lb = len(bn)
sa = set(a1)
sb = set(bn)
if len(sa | sb) < la + lb:
  print('POSSIBLE')
  exit()
print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a1 = []
bn = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    a1.append(b)
  elif b == n:
    bn.append(a)


for x in a1:

    if x in bn:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

Fixed submission:
n, m = map(int, input().split())
a1 = []
bn = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    a1.append(b)
  elif b == n:
    bn.append(a)
la = len(a1)
lb = len(bn)
sa = set(a1)
sb = set(bn)
if len(sa | sb) < la + lb:
  print('POSSIBLE')
  exit()
print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1 or b == n:
    ab.append((a,b))

x = len(ab) # length ab
for i in range(x):
  for j in range(x):
    if ab[i][0] == ab[j][1]:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

Fixed submission:
n, m = map(int, input().split())
a1 = []
bn = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    a1.append(b)
  elif b == n:
    bn.append(a)
la = len(a1)
lb = len(bn)
sa = set(a1)
sb = set(bn)
if len(sa | sb) < la + lb:
  print('POSSIBLE')
  exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
aa = list(map(int, input().split()))
cnt = 0
for bit in range(1<<n):
  bs = 0
  for i in range(n):
    if bit &(1<<n):
      bs += aa[i]
  if bs % 2 == p:
    cnt += 1
print (cnt//2)

Fixed submission:
import math
from scipy.special import comb
n, p = map(int, input().split())
aa = list(map(int, input().split()))
odd = []
even = []
for i in range(n):
  if aa[i] % 2 == 0:
    even.append(aa[i])
  else:
    odd.append(aa[i])
    
x = len(odd)
y = len(even)


sum1 = 0
for i in range(0, x+1, 2):
  sum1 += comb(x,i)
sum2 = 0
for i in range(1, x+1, 2):
  sum2 += comb(x,i)
  
if p == 0:
  ans = int((2 ** y) * sum1)
else:
  ans = int((2 ** y) * sum2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
cnt = 1

if 2 not in A:
  print(-1)
  exit()

a = A[0]
while a != 2: 
  if a == 1:
    print(-1)
    exit()
  a = A[a-1]
  cnt += 1
  if a == 1:
    print(-1)
    exit()
print(cnt)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0

if 2 not in a:
  print(-1)
  exit()

x = 1
for i in range(n-1):
 
  x = a[x-1]
  cnt += 1

            
  if x == 2:
    print(cnt)
    exit()

print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
cnt = 1

if 2 not in A:
  print(-1)
  exit()

a = A[0]
while a != 2: 
  a = A[a-1]
  cnt += 1
  if a == 1:
    print(-1)
    exit()
print(cnt)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0

if 2 not in a:
  print(-1)
  exit()

x = 1
for i in range(n-1):
 
  x = a[x-1]
  cnt += 1

            
  if x == 2:
    print(cnt)
    exit()

print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p = 10**9 + 7



def fac(n):
  x = 1
  for i in range(1,n+1):
    x *= i
  return x

nf = fac(n) % p
mf = fac(m) % p

if abs(n-m) > 1:
  ans = 0

elif n == m:
  ans = nf * mf * 2
  
else:
  ans = nf * mf
  
print(ans % p)

Fixed submission:
import math
n, m = map(int, input().split())
p = 10**9 + 7



nf = math.factorial(n) % p
mf = math.factorial(m) % p

if abs(n-m) > 1:
  ans = 0

elif n == m:
  ans = nf * mf * 2
  
else:
  ans = nf * mf
  
print(ans % p)
Buggy python submission (verdict: Time Limit Exceeded):
xx = []
n, k = map(int, input().split())
for i in range(n):
  a, b = map(int, input().split())
  for j in range(b):
    xx.append(a)

yy = sorted(xx)
print(yy[k-1])


Fixed submission:
xx = []
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
xx = sorted(ab, key= lambda x:x[0])

ans = 0
for i in range(n):
  ans += xx[i][1]
  if ans >=  k:
    print(xx[i][0])
    break

Buggy python submission (verdict: Time Limit Exceeded):
xx = []
n, k = map(int, input().split())
for i in range(n):
  a, b = map(int, input().split())
  for j in range(b):
    xx.append(a)
yy = sorted(xx)
print(yy[k-1])

Fixed submission:
xx = []
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
xx = sorted(ab, key= lambda x:x[0])

ans = 0
for i in range(n):
  ans += xx[i][1]
  if ans >=  k:
    print(xx[i][0])
    break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aa =list(map(int, input().split()))

list1 =[0] * n
cnt = 0  
for i in range(n-1):
  if aa[i+1] > aa[i]:
    list1[i+1] = 1
  elif aa[i+1] < aa[i]:
    list1[i+1] = -1
  elif aa[i+1] == aa[i]:    
    list1[i+1] = 0

  
while 1 in list1 and -1 in list1:
  if list1[1] == 1:
    for i in range(len(list1)):
      if list1[i] == -1:
        cnt += 1
        list1[i] = 0
        list1 = list1[i:]
        
        break
        
  elif list1[1] == -1:
    for i in range(len(list1)):
      if list1[i] == 1:
        cnt += 1
        list1[i] = 0
        list1 = list1[i:]
        
        break
        
  elif list1[1] == 0:
    for i in range(len(list1)):
      if list1[i] == 1 or list1[i] == -1:
        cnt += 1
        list1[i] = 0
        list1 = list1[i:]
       
        break
  
print(cnt+1)

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

list1 =[0] * n
cnt = 1  
for i in range(n-1):
  if aa[i+1] > aa[i]:
    list1[i+1] = 1
  elif aa[i+1] < aa[i]:
    list1[i+1] = -1
  elif aa[i+1] == aa[i]:    
    list1[i+1] = 0

while 1 in list1 and -1 in list1:
  del list1[:max(list1.index(1), list1.index(-1))]
  list1[0] = 0
  cnt += 1
  
print(cnt)

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

list1 =[0] * n
list1[0] = 1
list1[1] = 1

for i in range(2,n):
  if list1[i-2] == list1[i-1]:
    if (aa[i] - aa[i-1]) * (aa[i-1] -aa[i-2]) < 0:
      list1[i] = list1[i-1] + 1
    else:
      list1[i] = list1[i-1]
  else:
    list1[i] = list1[i-1]
    
print(list1[n-1])

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

list1 =[0] * n
cnt = 1  
for i in range(n-1):
  if aa[i+1] > aa[i]:
    list1[i+1] = 1
  elif aa[i+1] < aa[i]:
    list1[i+1] = -1
  elif aa[i+1] == aa[i]:    
    list1[i+1] = 0

while 1 in list1 and -1 in list1:
  del list1[:max(list1.index(1), list1.index(-1))]
  list1[0] = 0
  cnt += 1
  
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 1
for i in range(2, N+1):
  ans *= i % 1000000007
print(ans % 1000000007)

Fixed submission:
N = int(input())
ans = 1
for i in range(2, N+1):
  ans *= i % 1000000007
  ans = ans % 1000000007
print(ans % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x + y + z == S:
        cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
  for y in range(K+1):
    if 0 <= S - x - y <= K:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for bit in range(1<<n):
  sum = 0
  for i in range(n):
    if bit & (1<<i):
      sum += i+1
      
  if sum == n:
    a = bin(bit)
    break
s = str(a)
s = s[2:]
s = s[::-1]


for i in range(len(s)):
  if s[i] == '1':
    print(i + 1)

Fixed submission:
n = int(input())

aa =[]
i = 0
score = 0

while score < n:
  i += 1
  score += i
  aa.append(i)
  
if score == n:
  for k in range(len(aa)):
    print(aa[k])
    
else:
  aa.remove(score - n)
  for k in range(len(aa)):
    print(aa[k])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
t = input()

for i in range(n):
  if t.startswith(s[i:]):
    x = n + i

print(x)

Fixed submission:
n = int(input())
s = input()
t = input()
x = 2 * n
for i in range(n):
  if t.startswith(s[i:]):
    x = n + i
    print(x)
    exit()
print(x)
Buggy python submission (verdict: Time Limit Exceeded):

count = 0
N = int(input())
A = list(map(int, input().split()))
B =[x for x in range(1,N+1)]
C = list(zip(A, B))
D = [sorted(x) for x in C]
for i in range(N):
  if D.count(D[i]) == 2:
    count += 1
    
print(int(count/2))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0

for i in range(N):
  if A[A[i]-1] == i + 1:
    count += 1

print(int(count / 2))
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = sorted([input() for i in range(N)])
print(''.join(S))

Fixed submission:
abc = list(input().split())

if abc.count('5') == 2 and abc.count('7') == 1:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
flag = False
while count < n:
  a, b = map(int, input().split())
  count += 1
  if a == b and count <= n:
    a, b = map(int, input().split())
    count += 1
    if a == b and count <= n:
      a, b = map(int, input().split())
      count += 1
      if a == b and count <= n:
        flag = True
        print("Yes")
        break

if flag == False:
  print("No")

Fixed submission:
n = int(input())
count = 0
flag = False
while count < n:
  a, b = map(int, input().split())
  count += 1
  if a == b and count < n:
    a, b = map(int, input().split())
    count += 1
    if a == b and count < n:
      a, b = map(int, input().split())
      count += 1
      if a == b and count <= n:
        flag = True
        print("Yes")
        break

if flag == False:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(range(1,n+1))
B = list(range(1,n+1))
C = list(range(1,n+1))
ans =0
for i in A:
    for j in B:
        for k in C:
            if i*j+k ==n:
                ans +=1
print(ans)

Fixed submission:
def slove():
    ans = 0
    for a in range(1,N):
        for b in range(1,N):
            c = N-a*b
            if c<=0: #a,b,cは>0なのでcが負になるときは組み合わせ除外
                break
            ans +=1
    return ans
N = int(input())
ans = slove()
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = list(map(int,input().split()))
S = input()
print(S.replace(S[k], S[k].lower()))

Fixed submission:
n,k = list(map(int,input().split()))
S = input()
print( S[:k-1]+S[k-1].lower()+ S[k:])
Buggy python submission (verdict: Time Limit Exceeded):
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    end=time.time()
    while True:
        if (end-start)>1.5:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)




Fixed submission:
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    while True:
        now=time.time()
        if (now-start)>1.8:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    end=time.time()
    while True:
        if (end-start)>1.9:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)




Fixed submission:
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    while True:
        now=time.time()
        if (now-start)>1.8:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)

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


    print(ans)




Fixed submission:
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    while True:
        now=time.time()
        if (now-start)>1.8:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)

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


    print(ans)




Fixed submission:
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    while True:
        now=time.time()
        if (now-start)>1.8:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
score=[0]*(n-k+1)
for i in range(k-1,n):
    score[i-k+1]=1
    for j in range(k):
        score[i-k+1]*=a[i-j]
for i in range(1,n-k+1):
    if score[i-1]<score[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,n):
    if a[i]>a[i-k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def soinsuu(x):#整数xの素因数分解
    n=x
    bunkai=[]
    for i in range(2,int(n**0.5)+1):
        cnt=0
        while x%i==0:
            x//=i
            cnt+=1
        if cnt==0:
            continue
        bunkai.append([i,cnt])
    if x!=1:
        bunkai.append([n,1])
    ans=1
    for l in bunkai:
        ans*=(l[1]+1)
    return ans

N=int(input())
ans=1
for i in range(2,N+1):
    ans+=i*soinsuu(i)
print(ans)

Fixed submission:
def tousa(b,l):
    cnt=l//b
    s=(b+l)*cnt//2
    return s

n=int(input())
ans=0
for k in range(1,n+1):
    N=n//k
    ans+=tousa(k,k*N)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
x=10**18
ans=1
for num in a:
    ans*=num
    if 0 in a:
        ans=0
        break
    if ans>x:
        ans=-1
        break    
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=10**18
ans=1
for num in a:
    ans*=num
    if ans>x:
        ans=-1
        break
if 0 in a:
    ans=0   
print(ans)