Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s.replace("BC","D").replace("B","E").replace("C","E")
s = s.split("E")

def solve(s):
    ans = 0
    while "AD" in s:
        ans += s.count("AD")
        s = s.replace("AD","DA")
    return ans

ans = 0
for ele in s: ans += solve(ele)
print(ans)


Fixed submission:
s = input()
s = s.replace("BC","D").replace("B","E").replace("C","E")
s = s.split("E")

def solve(s):
    ans = 0 ; tmp = 0
    for char in s:
        if char == "A": tmp += 1
        else: ans += tmp
    return ans

ans = 0
for ele in s: ans += solve(ele)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s.replace("BC","D")

ans = 0
while "AD" in s:
    ans += s.count("AD")
    s = s.replace("AD","DA")

print(ans)


Fixed submission:
s = input()
s = s.replace("BC","D").replace("B","E").replace("C","E")
s = s.split("E")

def solve(s):
    ans = 0 ; tmp = 0
    for char in s:
        if char == "A": tmp += 1
        else: ans += tmp
    return ans

ans = 0
for ele in s: ans += solve(ele)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0

while "ABC" in s:
    ans += s.count("ABC")
    s = s.replace("ABC","BCA")

print(ans)


Fixed submission:
s = input()
s = s.replace("BC","D").replace("B","E").replace("C","E")
s = s.split("E")

def solve(s):
    ans = 0 ; tmp = 0
    for char in s:
        if char == "A": tmp += 1
        else: ans += tmp
    return ans

ans = 0
for ele in s: ans += solve(ele)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

r,g,b,n = map(int,input().split())

ans = 0
rmax = n//r
gmax = n//g
for i in range(rmax+1):
    for j in range(gmax+1):
        rest = n-r*i-g*j
        flag = rest>=0 and rest%b==0
        if flag: ans += 1

print(ans)


Fixed submission:

r,g,b,n = map(int,input().split())

ans = 0
rmax = n//r
for i in range(rmax+1):
    rest = n-r*i
    gmax = rest//g
    for j in range(gmax+1):
        rest = n-r*i-g*j
        if rest%b==0: ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
  cnt = len(set(a[i],b[i],c[i]))-1
  ans += cnt

print(ans)


Fixed submission:

n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    cnt = 2
    if a[i]==b[i]: cnt -= 1
    if b[i]==c[i]: cnt -= 1
    if c[i]==a[i]: cnt -= 1
    if cnt<0: cnt = 0
    ans += cnt

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a,b,c = input(),input(),input()

ans = 0
for i in range(n):
	cnt = len(set(a[i],b[i],c[i]))-1
	ans += cnt

print(ans)


Fixed submission:

n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    cnt = 2
    if a[i]==b[i]: cnt -= 1
    if b[i]==c[i]: cnt -= 1
    if c[i]==a[i]: cnt -= 1
    if cnt<0: cnt = 0
    ans += cnt

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a,b,c = input(),input(),input()

ans = 0
for i in range(n):
  cnt = len(set(a[i],b[i],c[i]))-1
  ans += cnt

print(ans)


Fixed submission:

n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    cnt = 2
    if a[i]==b[i]: cnt -= 1
    if b[i]==c[i]: cnt -= 1
    if c[i]==a[i]: cnt -= 1
    if cnt<0: cnt = 0
    ans += cnt

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a,b,c = input(),input(),input()

ans = 0
for i in range(n):
  cnt = len(set(a[i],b[i],c[i]))-1
  ans += cnt

print(ans)

Fixed submission:

n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    cnt = 2
    if a[i]==b[i]: cnt -= 1
    if b[i]==c[i]: cnt -= 1
    if c[i]==a[i]: cnt -= 1
    if cnt<0: cnt = 0
    ans += cnt

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = []
bs = 0
for i in range(n):
  a,b = map(int,input().split())
  bs += b
  c.append(a+b)

c.sort()

ans = -bs
for i in range(n,0,-1):
  if i%2==0: ans += c[i]
    
print(ans)


Fixed submission:
n = int(input())
c = []
bs = 0
for i in range(n):
  a,b = map(int,input().split())
  bs += b
  c.append(a+b)

c.sort()

ans = -bs
for i in reversed(range(n)):
  cnt = n-1-i
  if cnt%2==0: ans += c[i]
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import functools
import math

n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

gcd = functools.reduce(math.gcd, city)
print(gcd)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

ans = city[0]
for num in city:
    ans = gcd(ans, num)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

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


n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

print(gcd_list(city))


Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

ans = city[0]
for num in city:
    ans = gcd(ans, num)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

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


n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

print(gcd_list(city))

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

ans = city[0]
for num in city:
    ans = gcd(ans, num)

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

# 最小公倍数を求める関数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm = lcm_list(a)

ans = 0
for i in range(n):
    ans += (lcm-1) % a[i]

print(ans)

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

ans = sum(a)-n

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

nums = list(range(a,b+1))
n = len(nums)


if (k-1>=n-k):
    for ele in nums: print(ele)

else:
    for i in range(0,k): print(nums[i])
    for i in range(n-k,n): print(nums[i])


Fixed submission:
a,b,k = map(int,input().split())

n=b-a+1

if (k-1>=n-k):
    for i in range(a,b+1): print(i)

else:
    for i in range(a,a+k): print(i)
    for i in range(b-k+1,b+1): print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

nums = list(range(a,b+1))
n = len(nums)
if k>n: k=n

for i in range(0,k): print(nums[i])
if (k-1<n-k):
    for i in range(n-k,n): print(nums[i])
else:
    for i in range(k,n): print(nums[i])


Fixed submission:
a,b,k = map(int,input().split())

n=b-a+1

if (k-1>=n-k):
    for i in range(a,b+1): print(i)

else:
    for i in range(a,a+k): print(i)
    for i in range(b-k+1,b+1): print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

nums = list(range(a,b+1))
n = len(nums)

for i in range(0,k): print(nums[i])
if (k-1<n-k):
    for i in range(n-k,n): print(nums[i])
else:
    for i in range(k,n): print(nums[i])


Fixed submission:
a,b,k = map(int,input().split())

n=b-a+1

if (k-1>=n-k):
    for i in range(a,b+1): print(i)

else:
    for i in range(a,a+k): print(i)
    for i in range(b-k+1,b+1): print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

nums = list(range(a,b+1))
rev = list(reversed(list(range(a,b+1))))

n = len(nums)
if k>n: k=n

ans = nums[0:k]+list(reversed(rev[0:k]))
for ele in list(set(ans)): print(ele)

Fixed submission:
a,b,k = map(int,input().split())

n=b-a+1

if (k-1>=n-k):
    for i in range(a,b+1): print(i)

else:
    for i in range(a,a+k): print(i)
    for i in range(b-k+1,b+1): print(i)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([0,0,0]) + np.array([iarr() for i in range(n)])
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 1
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

ans = "Yes" if flag else "No"
print(ans)


Fixed submission:
n=int(input())
ts=[]; xs=[]; ys=[]

for i in range(n):
    t,x,y = map(int,input().split())
    ts.append(t); xs.append(x); ys.append(y)

flag=1
for i in range(n):
    t = ts[i]
    d = abs(xs[i]) + abs(ys[i])
    if t>=d and (t-d)%2==0: continue
    else: flag=0; break

if flag: print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np

abcd = input()
#a,b,c,d = [s for s in abcd]

for i in range(2**3):
    ops = ["-","-","-",""]
    for j in range(3):
        if i>>j&1: ops[j] = "+"
    equa = ""
    for s,op in zip(abcd,ops): equa += (s+op)
    if eval(equa) == 7 : break

ans = equa + "=7"
print(ans)


Fixed submission:
import numpy as np

abcd = input()
#a,b,c,d = [s for s in abcd]

for i in range(2**3):
    ops = ["-","-","-",""]
    for j in range(3):
        if i>>j&1: ops[j] = "+"
    equa = ""
    for s,op in zip(abcd,ops): equa += (s+op)
    if eval(equa) == 7 : break

ans = equa + "=7"
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

def dfs(v1):
    if all(visited): return 1
    visited[v1] = 1
    for v2 in range(n):
        if graph[v1][v2] == 0: continue
        if visited[v2] == 1: continue
        dfs(v2)
    return 0
# nは頂点の数
n, m = MI()
ab = np.array([list(map(int,input().split()))])
a,b = ab.T[0]-1,ab.T[1]-1

#隣接行列
graph = [[0] * n for _ in range(n)]

ans = 0
for a, b in zip(a,b):
    for aa,bb in zip(a,b): graph[aa][bb],graph[bb][aa] = 1,1
    graph[a][b],graph[b][a] = 0,0
    visited = [0]*n
    if not dfs(0): ans += 1

print(ans)



Fixed submission:
import numpy as np

class unionfind: #ノード数nを読み込む
    def __init__(self,n): #コンストラクタ
        self.parent = list(range(n))
    def find(self,a): #根を探す、そのつど根を更新
        if self.parent[a] == a: return a #自分が根だったら終了
        p = self.find(self.parent[a])
        self.parent[a] = p #根をダイレクトに更新
        return p
    def unite(self,a,b): #ランク度外視で根を合体する
        pa,pb = self.find(a),self.find(b)
        if pa == pb: return 0 #根が一緒なら何もせず終了
        self.parent[pa] = pb
    def same(self,a,b):
        pa,pb = self.find(a),self.find(b)
        return pa == pb

n,m = map(int,input().split())
ab = np.array([list(map(int,input().split())) for i in range(m)])
a,b = ab.T[0] -1, ab.T[1] -1

ans = 0
for i in range(m): #除外する辺を決める
    uf = unionfind(n)
    connect = 0
    for j in range(m): #i以外の辺についてuniteしていく
        if i != j and not uf.same(a[j],b[j]): uf.unite(a[j],b[j]) ; connect += 1
    ans += 0 if connect == n-1 else 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int,input().split())

# 作れるか判定
def check(goal,ac,bd):
    flag = 0
    for x in range(int(goal//ac)+1):
            if (goal-ac*x)%bd == 0 : flag = 1 ; break
    return flag

# 水W、砂糖Sをまわす
anss = []
for w in range(100,f+1,100):
    for s in range(1,f-w+1):
        if check(w,100*a,100*b) and check(s,c,d) and s<=((w*e)/100):
            conc = 100*s/(w+s) # concentration
            anss.append([conc,w,s])

anss.sort(reverse=1)
w,s = anss[0][1],anss[0][2]
print(w+s,s)


Fixed submission:
a,b,c,d,e,f = map(int,input().split())

# 作れるか判定
def check(goal,ac,bd):
    flag = 0
    for x in range(int(goal//ac)+1):
            if (goal-ac*x)%bd == 0 : flag = 1 ; break
    return flag

# 水W、砂糖Sをまわす
anss = []
for w in range(100,f+1,100):
    for s in range(1,f-w+1):
        if check(w,100*a,100*b) and check(s,c,d) and s<=((w*e)/100):
            conc = 100*s/(w+s) # concentration
            anss.append([conc,w,s])

anss.sort(reverse=1)
if anss: w,s = anss[0][1],anss[0][2]
else: w,s = 100*a,0
print(w+s,s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
memo=[]

h=0; w=0
for element in a:
    if element in memo: pass
    else:
        memo.append(element)
        num=a.count(element)
        if num>=4 and h==0: h=w=element
        elif num>=2 and h==0: h=element
        elif num>=2 and w==0: w=element

ans=h*w
print(ans)

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

ans=[]
tmp=0
count=0
for el in a:
    if len(ans)==2: break
    if el != tmp: tmp=el; count=0
    else:
        if count%2==0: ans.append(el); tmp=el;
        count+=1

try: ans=ans[0]*ans[1]
except: ans=0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
memo=[]

h=0; w=0
for element in a:
    if element in memo: pass
    else:
        memo.append(element)
        num=a.count(element)
        if num>=4 and h==0: h=w=element
        elif num>=2 and h==0: h=element
        elif num>=2 and w==0: w=element

ans=h*w
print(ans)

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

ans=[]
tmp=0
count=0
for el in a:
    if len(ans)==2: break
    if el != tmp: tmp=el; count=0
    else:
        if count%2==0: ans.append(el); tmp=el;
        count+=1

try: ans=ans[0]*ans[1]
except: ans=0
print(ans)

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

for element in a:
    if element in list: pass
    elif a.count(element)>=2:
        list.append(element)
        if a.count(element)>=4:sqrt.append(element)

list.sort()
sqrt.sort()
n=len(list)
m=len(sqrt)

if n==0: ans=0
elif n==1:
    if m==0: ans=0
    else: ans=max(sqrt)**2
elif n>=2:
    if m==0:
        x=max(list); list.remove(x)
        y=max(list)
        ans=x*y
    else:
        x=max(list); list.remove(x)
        y=max(list)
        ans=x*y
        if ans<max(sqrt)**2: ans=max(sqrt)**2

print(ans)

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

ans=[]
tmp=0
count=0
for el in a:
    if len(ans)==2: break
    if el != tmp: tmp=el; count=0
    else:
        if count%2==0: ans.append(el); tmp=el;
        count+=1

try: ans=ans[0]*ans[1]
except: ans=0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

ans=[]
for i in range(1,n):
    x=sum(a[0:i])
    y=sum(a[i:])
    ans.append(abs(x-y))

print(min(ans))

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

total=sum(a)

ans=[]
x=0
for i in range(n-1):
    x+=a[i]
    y=total-x
    ans.append(abs(x-y))

print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input().split()
b=[]

for i in range(n):
    b.append(a[i])
    b.reverse()

ans=" ".join(b)
print(ans)

Fixed submission:
n=int(input())
a=input().split()
b=[a[i] for i in range(n) if i%2!=0] #奇数インデックス
rb=b[::-1]
c=[a[i] for i in range(n) if i%2==0] #偶数インデックス
rc=c[::-1]

if n%2==0: ans=rb+c
else: ans=rc+b

ans=" ".join(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
def resolve():
    H,W = map(int,input().split())
    if H = 1 or W = 1:
        print(1)
    else:
        ans = (H * W + 1) // 2
        print(ans)
resolve()

Fixed submission:
def resolve():
    H,W = map(int,input().split())
    if H == 1 or W == 1:
        print(1)
    else:
        ans = (H * W + 1) // 2
        print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    n_array = np.array(list(map(int,input().split())))
    mea = int(np.average(n_array) + 0.5)
    ans = n_array - mea 
    print(sum(ans*ans))
resolve()

Fixed submission:
import numpy as np

def resolve():
    N = int(input())
    n_array = np.array(list(map(int,input().split())))
    mea = int(np.average(n_array) + 0.5)
    ans = n_array - mea 
    print(sum(ans*ans))
resolve()
Buggy python submission (verdict: Runtime Error):
limit = 100000
def resolve()
	N = int(input())
  	for k in range(N, limit+1):
        if k % 2 == 0 and k != 2:
            continue
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
              	print(k)
                break
resolve()

Fixed submission:
limit = 100003
import math
def resolve():
    N = int(input())
    for k in range(N, limit+1):
        factor = 0
        if k % 2 == 0 and k != 2:
            continue
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
        if factor == 0:
                return k
print(resolve())
Buggy python submission (verdict: Runtime Error):
def resolve():
    A,B,C = map(int,input().split())
    count = 0
    if A == C and A == B:
        if A % 2 == 1:
            print(0)
        else:
            print(-1)
    else:
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):
            tmpA = (B + C) / 2 
            tmpB = (A + C) / 2 
            tmpC = (A + B) / 2
            A = tmpA
            B = tmpB
            C = tmpC
            count = count + 1
        print(count)
resolve():

Fixed submission:
def resolve():
    A,B,C = map(int,input().split())
    count = 0
    if A == C and A == B:
        if A % 2 == 1:
            print(0)
        else:
            print(-1)
    else:
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):
            tmpA = (B + C) / 2 
            tmpB = (A + C) / 2 
            tmpC = (A + B) / 2
            A = tmpA
            B = tmpB
            C = tmpC
            count = count + 1
        print(count)
resolve()
Buggy python submission (verdict: Runtime Error):
from collections import Counter

pas = 0

H, W, M = map(int, input().split())
hn = []
wn = []
tli = []
for _ in range(M):
    h, w = map(int, input().split())
    tli.append([h,w])
    hn.append(h)
    wn.append(w)

hcnt = Counter(hn)
wcnt = Counter(wn)

ha, cha = zip(*hcnt.most_common())
wa, cwa = zip(*wcnt.most_common())

hli = [int(ha[0])]
wli = [int(wa[0])]
for i in range(len(cha)-1):
    if cha[i] == cha[i+1]:
        hli.append(int(ha[i+1]))
    else:
        break
for i in range(len(cwa)-1):
    if cwa[i] == cwa[i+1]:
        wli.append(int(wa[i+1]))
    else:
        break

for i in range(len(hli)):
    if pas == 1:
        break
    for k in range(len(wli)):
        if [hli[i], wli[k]] not in tli:
            ans = cha[i] + cwa[k]
            pas = 1
            break

if pas == 0:
    print(cha[0] + cwa[0] - 1)
else:
    print(ans)



Fixed submission:
N, X, T = map(int, input().split())
 
ans = N//X

if N%X != 0:
    ans+=1
 
print(ans*T)
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int, input().split())

for k in range(K):
    if min(abs(X+D), abs(X-D)) < abs(X):
        X = min(abs(X+D), abs(X-D))
        K -= 1
    else:
        if K%2 == 0:
            print(X)
            break
        else:
            X = min(abs(X+D), abs(X-D))
            print(X)
            break

if K == 0:
    print(X)


Fixed submission:
X, K, D = map(int, input().split())
S = abs(X)//D

if abs(X)/D >= K:
    X = abs(X)-D*K
    print(X)
else:
    X = min(abs(X-D*S), abs(X+D*S))
    K = K - S
    for k in range(K):
        if min(abs(X+D), abs(X-D)) < abs(X):
            X = min(abs(X+D), abs(X-D))
            K -= 1
        else:
            if K%2 == 0:
                print(X)
                break
            else:
                X = min(abs(X+D), abs(X-D))
                print(X)
                break

    if K == 0:
        print(X)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

Z = []
for i in range(N):
    ver = [A[i], 0]
    Z.append(ver)

for k in range(K):
    h = Z.index(max(Z))
    Z[h][1] += 1
    Z[h][0] /= 2 

for j in range(N):
    A[j] = A[j]/(Z[j][1]+1)

print(math.ceil(max(A)))

Fixed submission:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

def ink(L):
    cnt = 0
    for i in range(N):
        cnt += A[i]//L
        if A[i]%L != 0:
            cnt += 1
        cnt -= 1
    return cnt <= K

bottom, top = 0, max(A)

while(top - bottom > 1):
    middle = (top + bottom) // 2
    if ink(middle): top = middle
    else: bottom = middle

print(top)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

K = 0
m = 1000

for i in range(N):
    if i == N-1:
        m += K*A[i]
        break
    for k in range(N-i):
        if A[i] < A[i+k+1]:
            if K > 0:
                m += K*A[i]
            K = m//A[i]
            m = m%A[i]
            break
        else:
            if A[i] > A[i+k+1]:
                m += K*A[i]
                K = 0
                break
            else:
                continue
print(m)


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

K = 0
m = 1000

for i in range(N):
    if i == N-1:
        m += K*A[i]
        break
    for k in range(1,N-i):
        if A[i] < A[i+k]:
            if K > 0:
                m += K*A[i]
            K = m//A[i]
            m = m%A[i]
            break
        else:
            if A[i] > A[i+k]:
                m += K*A[i]
                K = 0
                break
            else:
                continue
print(m)