Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin,stdout
from numba import njit
@njit
def fn(i):
    return pro[i]//(pro[i-k] if i-k>=0 else 1)
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
pro=[a[0]]
for v in a[1:]:
    pro+=[pro[-1]*v]
for i in range(k,n):
    #print(fn(i),fn(i-1))
    if fn(i)>fn(i-1):print('Yes')
    else:print('No')


Fixed submission:
from sys import stdin,stdout
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
for i in range(k,n):
    print('Yes' if a[i]>a[i-k] else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,stdout
def fn(i):
    return pro[i]//(pro[i-k] if i-k>=0 else 1)
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
pro=[a[0]]
for v in a[1:]:
    pro+=[pro[-1]*v]
for i in range(k,n):
    #print(fn(i),fn(i-1))
    if fn(i)>fn(i-1):print('Yes')
    else:print('No')


Fixed submission:
from sys import stdin,stdout
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
for i in range(k,n):
    print('Yes' if a[i]>a[i-k] else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,stdout
n=int(stdin.readline());ans=0
fctrs=[0]*(n+1)
for i in range(1,n+1):
        for j in range(i,n+1,i):
            fctrs[j]+=1
for i in range(1,n+1):
    ans+=(i*fctrs[i])
stdout.write(str(ans))


Fixed submission:
from numba import njit
@njit
def solve(n):
	fctrs=[0]*(n+1)
	ans=0
	for i in range(1,n+1):
		for j in range(i,n+1,i):
			fctrs[j]+=1
	for i in range(1,n+1):
		ans+=(i*fctrs[i])
	return ans
n=int(input())
print(solve(n))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
num = []
if d < 0 and a > 0:
  print(a * d)
elif d > 0 and a > 0:
  print(b * d)
else:
  num = []
  for i in range(a, b + 1):
    for j in range(c, d + 1):
      num.append(i * j)
  print(max(num))

Fixed submission:
a, b, c, d = map(int, input().split())
num = [a*c, a*d, b*c, b*d]
print(max(num))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
num = []
for i in range(a, b + 1):
  for j in range(c, d + 1):
    num.append(i * j)
print(max(num))

Fixed submission:
a, b, c, d = map(int, input().split())
num = [a*c, a*d, b*c, b*d]
print(max(num))
Buggy python submission (verdict: Runtime Error):
d, t, s = map(int, inport().split())

if t*s <= d:
  print("Yes")
else:
  print("No")


Fixed submission:
d, t, s = map(int, input().split())

if d/s <= t:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
d, t, s = map(int, inport().split())

if t*s <= d:
  print("yes")
else:
  print("No")

Fixed submission:
d, t, s = map(int, input().split())

if d/s <= t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = list(input().split())

if s[0] == S:
  if s[1] == S:
    if s[2] == S:
      print("0")
    else:
      print("1")
  if s[1] == R:
    if s[2] == S:
      print("1")
    else:
      print("2")
if s[0] == R:
  if s[1] == S:
    if s[2] == S:
      print("1")
    else:
      print("1")
  if s[1] == R:
    if s[2] == S:
      print("2")
    else:
      print("3")

Fixed submission:
s = input()

if s[0] == "S":
  if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2")
if s[0] == "R":
  if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3")
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input())
ans = 0
for i in range(n):
  x, y = map(int, input())
  if x**2 + y**2 <= d**2:
    ans += 1
print(ans)

Fixed submission:
n, d = map(int, input().split())
ans = 0
for i in range(n):
  x, y = map(int, input().split())
  if x**2 + y**2 <= d**2:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ACs = 0
WAs = 0
TLEs = 0
REs = 0
for i in range(n):
  result = input()
  if result == "AC":
    ACs += 1
  elif result == "WA":
    WAs += 1
  elif result == "TLE":
    TLEs += 1
  else:
    REs += 1
print("AC x " + ACs)
print("WA x " + WAs)
print("TLE x " + TLEs)
print("RE x " + REs)

Fixed submission:
n = int(input())
ACs = 0
WAs = 0
TLEs = 0
REs = 0
for i in range(n):
  result = input()
  if result == "AC":
    ACs += 1
  elif result == "WA":
    WAs += 1
  elif result == "TLE":
    TLEs += 1
  else:
    REs += 1
print("AC x " + str(ACs))
print("WA x " + str(WAs))
print("TLE x " + str(TLEs))
print("RE x " + str(REs))
Buggy python submission (verdict: Runtime Error):
alph = input()
TF = alph.islower()
if TF == true:
  print("a")
else:
  print("A")

Fixed submission:
alpha = input()
print('A' if alpha.isupper() else 'a')
Buggy python submission (verdict: Runtime Error):
num = list(input().split())
for i in range(6):
  if num[i] == "0":
    print(int(str(i + 1)))


Fixed submission:
num = list(input().split())
for i in range(5):
  if num[i] == "0":
    print(int(str(i + 1)))

Buggy python submission (verdict: Runtime Error):
num = int(input().split())
for i in range(6):
  if num[i] == 0:
    print(int(str(i)))

Fixed submission:
num = list(input().split())
for i in range(5):
  if num[i] == "0":
    print(int(str(i + 1)))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print(a*b)

Fixed submission:
a, b = map(int, input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n[len(n) - 1] == 3:
  print("bon")
elif n[len(n) - 1] == 0 or 1 or 6 or 8:
  print("pon")
else:
  print("hon")

Fixed submission:
n = input()
if n[-1] in "24579":
  print("hon")
elif n[-1] in "0168":
  print("pon")
elif n[-1] in "3":
  print("bon")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

if (s == t[:-1] & len(s) + 1 == len(t):
    print("Yes")
else:
    print("No")

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

if (s == t[:-1]) & (len(s) + 1 == len(t)):
    print("Yes")
else:
    print("No")
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):
x, y, z = map(int, input().split())
print(z + " " + x + " " + y)

Fixed submission:
x, y, z = map(int, input().split())
print(z, end='')
print(" ", end='')
print(x, end='')
print(" ", end='')
print(y, end='')
Buggy python submission (verdict: Runtime Error):
cof = input()
if cof[2] == cof[3] & cof[4] == cof[5]:
  print("Yes")
else:
  print("No")

Fixed submission:
cof = input()
if cof[2] == cof[3] and cof[4] == cof[5]:
  print("Yes")
else:
  print("No")
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())
ans = n*(n - 1)/2 + m*(m - 1)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 = 1:
  print(n // 2 + 1)
else:
  print(n / 2)

Fixed submission:
n = int(input())
if n % 2 == 1:
  print(n // 2 + 1)
else:
  print(int(n / 2))
Buggy python submission (verdict: Time Limit Exceeded):
m = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0

for x in range(m-1):
  if a[x] % mod != 0:
    tmp = sum(a[x+1:m])
    ans += a[x] * tmp

print(ans%mod)

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

mod = 10**9 + 7
ans = 0

tmp_sum = sum(a[1:m]) % mod

for x in range(m-1):
  if a[x] % mod != 0:
    ans += (a[x] * tmp_sum) % mod
  
  tmp_sum -= a[x+1] % mod

print(ans%mod)

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

mod = 10**9 + 7
ans = 0

for x in range(m):
  for y in range(m-x-1):
    ans += (a[x] * a[y+x+1])
print(ans % mod)

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

mod = 10**9 + 7
ans = 0

tmp_sum = sum(a[1:m]) % mod

for x in range(m-1):
  if a[x] % mod != 0:
    ans += (a[x] * tmp_sum) % mod
  
  tmp_sum -= a[x+1] % mod

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int, input().split())
hl = [0] * h
wl = [0] * w
dic = set()
for i in range(m):
  x,y = map(int, input().split())
  dic.add((x,y))
  hl[x-1] += 1
  wl[y-1] += 1

h_max = max(hl)
r = [i for i in range(h) if hl[i] == h_max]
w_max = max(wl)
c = [i for i in range(w) if wl[i] == w_max]

flg = 0
for rc in r:
  for cc in c:
    if (rc+1,cc+1) not in dic:
      flg = 1
      
if flg == 0:
  print(h_max + w_max - 1)
else:
  print(h_max + w_max)

Fixed submission:
def main():
  h,w,m = map(int, input().split())
  hl = [0] * h
  wl = [0] * w
  dic = set()
  for i in range(m):
    x,y = map(int, input().split())
    dic.add((x,y))
    hl[x-1] += 1
    wl[y-1] += 1

  h_max = max(hl)
  r = [i for i in range(h) if hl[i] == h_max]
  w_max = max(wl)
  c = [i for i in range(w) if wl[i] == w_max]

  flg = 0
  for rc in r:
    for cc in c:
      if (rc+1,cc+1) not in dic:
        print(h_max + w_max)
        return

  print(h_max + w_max - 1)
  
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
if s == "RRR":
  print(3)
elif s == "RRS" or s == "SRR":
  print(2)
elif s == "RSR" or s == "RSS" or s == "SSR" or s == "SRS":
  print(1)
else:
  print(0)

Fixed submission:
s = str(input())
if s == "RRR":
  print(3)
elif s == "RRS" or s == "SRR":
  print(2)
elif s == "RSR" or s == "RSS" or s == "SSR" or s == "SRS":
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
k = int(input())

if k % 2 == 0:
  print(-1)
elif k % 5 == 0:
  print(-1)
else:
  if k % 7 == 0:
    l = k * 9 / 7
  else:
    l = k * 9
    
  tmp = 1
  for i in range(l):
    tmp = tmp * 10 % l
    if tmp == 1:
      flg == 1
      print(i+1)
      break
  
  if flg != 1
  	print(-1)

Fixed submission:
K = int(input())
mod = 7
index = 1
flag = 0

if K % 2 == 0:
  print(-1)
elif K % 5 == 0:
  print(-1)
else:  
  while(index<=K):
      mod=mod%K
      if mod==0:
          print(index)
          flag=1
          break
      mod=mod*10+7
      index+=1
  if flag==0:
      print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())

if k % 2 == 0:
  print(-1)
elif k % 5 == 0:
  print(-1)
else:
  if k % 7 == 0:
    l = k * 9 / 7
  else:
    l = k * 9
    
  tmp = 1
  for i in range(l):
    tmp = tmp * 10 % l
    if tmp == 1:
      print(i+1)
      break
  print(-1)

Fixed submission:
K = int(input())
mod = 7
index = 1
flag = 0

if K % 2 == 0:
  print(-1)
elif K % 5 == 0:
  print(-1)
else:  
  while(index<=K):
      mod=mod%K
      if mod==0:
          print(index)
          flag=1
          break
      mod=mod*10+7
      index+=1
  if flag==0:
      print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())

if k % 2 == 0:
  print(-1)
elif k % 5 == 0:
  print(-1)
else:
  if k % 7 == 0:
    l = k * 9 / 7
  else:
    l = k * 9
  
  tmp = 1
  for i in range(l):
    tmp = tmp * 10 % l
    if tmp == 1:
      print(i+1)
      break

Fixed submission:
K = int(input())
mod = 7
index = 1
flag = 0

if K % 2 == 0:
  print(-1)
elif K % 5 == 0:
  print(-1)
else:  
  while(index<=K):
      mod=mod%K
      if mod==0:
          print(index)
          flag=1
          break
      mod=mod*10+7
      index+=1
  if flag==0:
      print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
px_up = math.ceil(n/1.08)
px_next = (n+1)/1.08
 
if px_up <= px_next:
  print(px_up)
else:
  print(":(")

Fixed submission:
import math
n = int(input())
px_up = math.ceil(n/1.08)
px_next = (n+1)/1.08
 
if px_up < px_next:
  print(px_up)
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input()) #長さ
a = str(input().split()) #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
   	x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == x:
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
   	x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input()) #長さ
a = map(int, input().split()) #帽子の数
x = 0
y = 0
z = 0
ans = 1

for i in range(n): #1文字目
  if a[i] == x:
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
total=0
a=0
b=0
for h in range(N-1):
    for i in range(h+1,N):
        a+=A[i]
    b+=A[h]*a
    a=0
print(b%1000000007)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
total=0
ans=0
d=[0]*210000

for i in range(N):
    total+=A[i]
    d[i]=total

for j in range(N):
    ans+=A[j]*(total-d[j])

print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
total=0
for i in range(len(A)-1):
    for j in range(1,len(A)-i):
        total+=A[i]*A[i+j]
print(total%1000000007)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
total=0
ans=0
d=[0]*210000

for i in range(N):
    total+=A[i]
    d[i]=total

for j in range(N):
    ans+=A[j]*(total-d[j])

print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
x1=a*100//8
x2=b*10
 if x1//10==b:
    print(x1)
else:
    print(-1)


Fixed submission:
a,b=map(int,input().split())
ans=-1
for i in range(1,10000):
    if i*8//100==a and i*10//100==b:
        ans=i
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
while True:
	D=input()
	if str.isupper(D):
		print("A")
	else:
		print("a")

Fixed submission:
D=input()
if str.isupper(D):
	print("A")
else:
	print("a")

Buggy python submission (verdict: Runtime Error):
D=input()
	if D.isupper():
		print("A")
	else:
		print("a")

Fixed submission:
D=input()
if str.isupper(D):
	print("A")
else:
	print("a")

Buggy python submission (verdict: Runtime Error):

   D=input()
   
   if str.isupper(D):
       print("A")
   else:
        print("a")

Fixed submission:
D=input()
if str.isupper(D):
	print("A")
else:
	print("a")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

answer = -float('inf')
for start_p in range(1, N+1):

    cycle_total_score = 0
    cycle_in_score = -float('inf')
    cycle_count = 0
    next_p = P[start_p]
    while True:
        cycle_total_score += C[next_p]
        cycle_in_score = max(cycle_in_score, cycle_total_score)
        cycle_count += 1

        if next_p == start_p:
            # print('start_p:', start_p, ' cycle_total_score:', cycle_total_score, 'cycle_in_score:', cycle_in_score, 'cycle_count:', cycle_count)
            break
        next_p = P[next_p]

    max_score = 0
    if K == cycle_count:
        max_score = cycle_in_score
    else:
        #あふれたK % cycle_count回数分だけスコアを足すためにmaxを探さす
        add_max_count = K % cycle_count
        add_total_score = 0
        add_score = -float('inf')
        add_count = 0
        add_next_p = P[start_p]
        while True:
            add_total_score += C[add_next_p]
            add_score = max(add_score, add_total_score)
            add_count += 1

            if add_count == add_max_count:
                break
            add_next_p = P[add_next_p]

        if K < cycle_count:
            #最大の試行回数がcycle_countよりも小さい場合K % cycle_countまでで一番良いところでbeak
            max_score = add_total_score
        else:
            if cycle_total_score >= 0:
                #1サイクルでプラスの場合はできるだけサイクルを回してK % cycle_countまでで一番良いところでbeak
                max_score = (K // cycle_count) * cycle_total_score + add_total_score
            else:
                #1サイクルでマイナスの場合はサイクルを回さないで、K % cycle_countまでで一番良いところでbreak
                max_score = add_total_score
    # print('max_score', max_score)
    answer = max(answer, max_score)

print(answer)


Fixed submission:
n,k=map(int,input().split())
#0-indexed
p=[i-1 for i in list(map(int,input().split()))]
c=list(map(int,input().split()))
#1回以上K回以下
ansF=-1000000000000000000
for i in range(n):
    #すでに辿ったもの
    check=[False]*n
    #辿った順番
    turns=[]
    #今
    now=i
    while check[now]==False:
        check[now]=True
        turns.append(now)
        now=p[now]
    #答え(今の)
    ans=0
    #kのうち何回分
    #更新を毎回行う
    spare=turns.index(now)
    if spare>=k:
        for j in range(k):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
        continue
    for j in range(spare):
        ans+=c[turns[j]]
        ansF=max(ans,ansF)
    turns=turns[spare:]
    spare=k-spare
    #サイクルの長さ
    l=len(turns)
    #サイクルの和(あまりも)
    #サイクルどこで止めるか
    x=0
    for j in range(l):
        x+=c[turns[j]]
    #そもそもサイクル回らない場合
    if spare<=l:
        for j in range(spare):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
        continue
    #サイクル回した方が良い場合
    #最後のサイクルは回さない方が良いパターンも
    if x>=0:
        ans+=(x*(spare//l-1))
        ansF=max(ans,ansF)
        for j in range(l):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
        for j in range(spare%l):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
    #サイクル回さない方がいい場合
    else:
        for j in range(l):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
print(ansF)
Buggy python submission (verdict: Runtime Error):
#bottomかtopか
n=int(input())
a=list(map(int,input().split()))
an=[]
for i in range(1,n):
    if a[i]>a[i-1]:
        an.append(a[i-1])
        break
pm=0
for j in range(i+1,n):
    #print(pm)
    if pm==0:
        if a[j]>=a[j-1]:
            if j==n-1:
                an.append(a[j])
            continue
        else:
            an.append(a[j-1])
            pm=1
    else:
        if a[j]<=a[j-1]:
            continue
        else:
            an.append(a[j-1])
            pm=0
            if j==n-1:
                an.append(a[j])
#print(an)
ans=1000
k=0
if len(an)==1:
    swvc
    print(ans)
    exit()
for i in range(len(an)):
    if i%2==0:
        k=ans//an[i]
        ans-=k*an[i]
    else:
        ans+=k*an[i]
        k=0
print(ans)

Fixed submission:
#bottomかtopか
n=int(input())
a=list(map(int,input().split()))
an=[]
for i in range(1,n):
    if a[i]>a[i-1]:
        an.append(a[i-1])
        if i==n-1:
            an.append(a[i])
        break
pm=0
for j in range(i+1,n):
    #print(pm)
    if pm==0:
        if a[j]>=a[j-1]:
            if j==n-1:
                an.append(a[j])
            continue
        else:
            an.append(a[j-1])
            pm=1
    else:
        if a[j]<=a[j-1]:
            continue
        else:
            an.append(a[j-1])
            pm=0
            if j==n-1:
                an.append(a[j])
#print(an)
ans=1000
k=0
for i in range(len(an)):
    if i%2==0:
        k=ans//an[i]
        ans-=k*an[i]
    else:
        ans+=k*an[i]
        k=0
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import *
def popcount(x):
    s=0
    y=int(log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
m=[[1%(c-1),1%(c+1)]]
for i in range(1,n):
    m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
#一個だけ変えたいので全体を求める
l=[0,0]
for i in range(n):
    if x[i]=="1":
        l[0]+=m[i][0]
        l[1]+=m[i][1]
        l[0]%=(c-1)
        l[1]%=(c+1)
#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])






Fixed submission:
import math
def popcount(x):
    s=0
    y=int(math.log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
if c!=1:
    m=[[1%(c-1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c-1)
            l[1]%=(c+1)
else:
    m=[[1%(c+1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c+1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c+1)
            l[1]%=(c+1)
#一個だけ変えたいので全体を求める

#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
#imos法で更新を繰り返す
#log回で終わる
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k):
    b=[0]*n
    for i in range(n):
        b[max(0,i-a[i])]+=1
        if i+a[i]+1<n:
            b[i+a[i]+1]-=1
    #print(b)
    a=list(accumulate(b))
    if a==[n]*n:
        break
print(" ".join(map(str,a)))

Fixed submission:
#imos法で更新を繰り返す
#log回で終わる
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(k):
    b=[0]*n
    for i in range(n):
        b[max(0,i-a[i])]+=1
        if i+a[i]+1<n:
            b[i+a[i]+1]-=1
    a=list(accumulate(b))
    if a==[n]*n:
        break
    #print(a)
print(" ".join(map(str,a)))
Buggy python submission (verdict: Runtime Error):
a,b=input().split();print((int(a)*int(b.strip(".")))//100)

Fixed submission:
a,b=input().split()
a=int(a)
b=int("".join(b.split(".")))
print((a*b)//100)