Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
    N,D =map(int, input().split())
    all_list = [list(map(int, input().split())) for i in range(N)]
    #>>>4
    count = 0
    for n in range (N):
        for nn in range(N):
            distance = 0
            for d in range(D):
                kou = (all_list[n][d] - all_list[nn][d])**2
                distance += kou
            for s in range(250):
                if distance == s**2:
                    count += 1
                    break
    print(round((count - N) / 2) +)

Fixed submission:
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(n):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(250):
            if distance == s**2:
                count += 1
                break
print(count)

Buggy python submission (verdict: Runtime Error):
count = 0
    for n in range (N):
        for nn in range(N):
            distance = 0
            for d in range(D):
                kou = (all_list[n][d] - all_list[nn][d])**2
                distance += kou
            for s in range(250):
                if distance == s**2:
                    count += 1
                    break
    print(round((count - N) / 2))

Fixed submission:
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(n):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(250):
            if distance == s**2:
                count += 1
                break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int, input().split())
rec = 2019
for i in range (R - L +1):
    for j in range(R - L +1):
        if i >= j:
            continue
        elif (((L+i)*(L+j)) % 2019) < rec:
            rec = ((L+i)*(L+j)) % 2019
print(rec)


Fixed submission:
L,R = map(int, input().split())
rec = 2019
for i in range (2020):
    for j in range(2020):
        if i >= j or (L+j) > R:
            continue
        elif (((L+i)*(L+j)) % 2019) < rec:
            rec = ((L+i)*(L+j)) % 2019
print(rec)
Buggy python submission (verdict: Runtime Error):
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
mod = (10**2)+7
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%mod)

Fixed submission:
S = list(input())
if len(S) == 4 and (S.count(S[1])) == 2  and len(set(S))==2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
print(nCr(N,K))
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%(10**9+7))

Fixed submission:
S = list(input())
if len(S) == 4 and (S.count(S[1])) == 2  and len(set(S))==2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = list(input())
if len(S) == 4 and (S.count(S[1])) == 2  and len(set(s))==2:
    print('Yes')
else:
    print('No')


Fixed submission:
S = list(input())
if len(S) == 4 and (S.count(S[1])) == 2  and len(set(S))==2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
def nCr(n,r):
    nk = 1
    nrk = 1
    rk = 1
    for i in range (n):
        nk *= i + 1
    for i in range (n-r):
        nrk *= i + 1
    for i in range (r):
        rk *= i + 1
    return int(nk/(nrk*rk))
 
N,K = map(int,input().split())
mod =(10**9)+7
for i in range(K):
    com1 = nCr(N - K + 1, i+1)
    com2 = nCr(K-1,i)
    print((com1*com2)%mod)

Fixed submission:
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
mod = (10**9)+7
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%mod)

Buggy python submission (verdict: Runtime Error):
def nCr(n,r):
    nk = 1
    nrk = 1
    rk = 1
    for i in range (n):
        nk *= i + 1
    for i in range (n-r):
        nrk *= i + 1
    for i in range (r):
        rk *= i + 1
    return int(nk/(nrk*rk))

N,K = map(int,input().split())
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%(10**9+7))


Fixed submission:
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
mod = (10**9)+7
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%mod)

Buggy python submission (verdict: Runtime Error):
def nCr(n,r):
    nk = 1
    nrk = 1
    rk = 1
    for i in range (n):
        nk *= i + 1
    for i in range (n-r):
        nrk *= i + 1
    for i in range (r):
        rk *= i + 1
    return int(nk/(nrk*rk))

N,K = map(int,input().split())
for i in range(1,K):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%(10**9+7))

Fixed submission:
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
mod = (10**9)+7
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%mod)

Buggy python submission (verdict: Runtime Error):
def nCr(n,r):
    nk = 1
    nrk = 1
    rk = 1
    for i in range (n):
        nk *= i + 1
    for i in range (n-r):
        nrk *= i + 1
    for i in range (r):
        rk *= i + 1
    return int(nk/(nrk*rk))

N,K = map(int,input().split())
for i in range(K):
    com1 = nCr(N - K + 1, i+1)
    com2 = nCr(K-1,i)
    print((com1*com2)%(10**9+7))


Fixed submission:
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
mod = (10**9)+7
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%mod)
Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
    eat = N - 1
    for m in range(N):
        if abs(L + m) < abs(L + eat):
            eat = m
aj = N*(N-1)//2
pie = (N-1)*L + aj - eat
print(pie)


Fixed submission:
N,L = map(int,input().split())
if L >=0:
    eat = 0
else:
    eat = N - 1
    for m in range(N):
        if abs(L + m) < abs(L + eat):
            eat = m
aj = N*(N-1)//2
pie = (N-1)*L + aj - eat
print(pie)
Buggy python submission (verdict: Runtime Error):
import math
def gcm(a,b):
    k = a * b / math.gcd(a,b)
    return int(k)

A,B,C,D = map(int,input().split())
bk = B - B//C - B//D + B//gcm(C,D)
ak = (A-1) - (A-1)//C - (A-1)//D + (A-1)//gcm(C,D)

print(bk-ak)

Fixed submission:
from fractions import gcd
def gcm(a,b):
    k = a * b / gcd(a,b)
    return int(k)

A,B,C,D = map(int,input().split())
bk = B - B//C - B//D + B//gcm(C,D)
ak = (A-1) - (A-1)//C - (A-1)//D + (A-1)//gcm(C,D)

print(bk-ak)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
bro = [int(input()) for i in range(M)]
mod = 10**9 + 7
dp = [0]*(N+1)
dp[0] = 1
if len(bro) >= 1 and bro[0] != 1:
    dp[1] = 1
elif len(bro) >= 1:
    del bro[0]
elif len(bro) == 0:
    dp[1] = 1
for i in range(2,N+1):
    if i in bro:
        continue
    else:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
print(dp[-1] % mod)


Fixed submission:
N,M = map(int,input().split())
bro = [int(input()) for i in range(M)]
mod = 10**9 + 7
dp = [0]*(N+1)
dp[0] = 1
if len(bro) >= 1 and bro[0] != 1:
    dp[1] = 1
elif len(bro) >= 1:
    del bro[0]
elif len(bro) == 0:
    dp[1] = 1
for i in range(2,N+1):
    if len(bro) == 0:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
    elif bro[0] == i:
        del bro[0]
        continue
    else:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
print(dp[-1] % mod)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
bro = [int(input()) for i in range(M)]
mod = 10**9 + 7
dp = [0]*(N+1)
dp[0] = 1
if bro[0] != 1:
    dp[1] = 1
else:
    del bro[0]
for i in range(2,N+1):
    if len(bro) == 0:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
    elif bro[0] == i:
        del bro[0]
        continue
    else:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
print(dp[-1] % mod)


Fixed submission:
N,M = map(int,input().split())
bro = [int(input()) for i in range(M)]
mod = 10**9 + 7
dp = [0]*(N+1)
dp[0] = 1
if len(bro) >= 1 and bro[0] != 1:
    dp[1] = 1
elif len(bro) >= 1:
    del bro[0]
elif len(bro) == 0:
    dp[1] = 1
for i in range(2,N+1):
    if len(bro) == 0:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
    elif bro[0] == i:
        del bro[0]
        continue
    else:
        dp[i]= (dp[i-1] + dp[i-2]) % mod
print(dp[-1] % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
l_a = sorted(list(map(int,input().split())))
l_b = []
ans = 0
for i in range(M):
    b,c = map(int,input().split())
    l_b.extend([c]*b)
l_b.sort()
for i in range(N):
    if l_b ==[] or l_a[-1]>= l_b[-1]:
        ans += l_a[-1]
        del l_a[-1]
    else:
        ans += l_b[-1]
        del l_b[-1]
print(ans)


Fixed submission:
from operator import itemgetter
N,M = map(int,input().split())
l_a = sorted(list(map(int,input().split())))
#O(NlogN)
l_bc = [list(map(int,input().split())) for i in range(M)]
l_bc.sort(key = itemgetter(1), reverse = True)
#O(MlogM)
for b,c in l_bc:
    l_a.extend([c]*b)
    if len(l_a) > N*2:
        break
l_a.sort(reverse = True)
print(sum(l_a[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M = map(int,input().split())
l_a = sorted(list(map(int,input().split())))
for i in range(M):
    b,c = map(int,input().split())
    if l_a[b-1] <= c:
        l_a[:b] = [c]*b
        l_a.sort()
    else:
        ins = bisect.bisect_right(l_a,c)
        l_a[:ins] = [c]*ins
print(sum(l_a))

Fixed submission:
from operator import itemgetter
N,M = map(int,input().split())
l_a = sorted(list(map(int,input().split())))
#O(NlogN)
l_bc = [list(map(int,input().split())) for i in range(M)]
l_bc.sort(key = itemgetter(1), reverse = True)
#O(MlogM)
for b,c in l_bc:
    l_a.extend([c]*b)
    if len(l_a) > N*2:
        break
l_a.sort(reverse = True)
print(sum(l_a[:N]))
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
k,l = 0,0
lv = [0] * N
lw = [0] * N
for i in range(N):
    lw[i],lv[i] = map(int,input().split())
V = sum(lv)
dp = [[float("inf") for i in range(V+1)] for j in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for sv in range(V):
        if sv-lv[i] < 0:
            dp[i+1][sv] = dp[i][sv]
            k +=1
        else:
            dp[i+1][sv] = min(dp[i][sv],(dp[i][sv-lv[i]]+lw[i]))
            l += 1
a = V

while a >= 0:
    if dp[-1][a] <= W:
        print(a)
        a = -1
    else:
        a -= 1


Fixed submission:
N,W = map(int,input().split())
dp = [[0 for i in range(W+1)] for j in range (N+1)]

for i in range(N):
    w,v = map(int,input().split())
    for sw in range(W+1):
        if sw < w:
            dp[i+1][sw] = dp[i][sw]
        else:
            dp[i+1][sw] = max((dp[i][sw]),(dp[i][sw-w]+v))
print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
numlist = []
 
for i in range(a, b+1):
    if i < a + k or i >  b - k:
        numlist.append(i)

print(numlist[l])

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

if (b-a+1)/2 < k:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1, b+1):
        print(k)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
numlist = []
 
for i in range(a, b+1):
    if i < a + k or i >  b - k:
        numlist.append(i)

numlist.sort()
 
for l in range(len(numlist)):
    print(numlist[l])

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

if (b-a+1)/2 < k:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1, b+1):
        print(k)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
numlist = []

for i in range(a, b+1):
    if i < a + k or i >  b - k:
        numlist.append(i)

numSet = set(numlist)
numlist = list(numSet)
numlist.sort()
 
for l in range(len(numlist)):
    print(numlist[l])

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

if (b-a+1)/2 < k:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1, b+1):
        print(k)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
numlist = []

for i in range(a, b+1):
    if i <= a + k - 1:
        numlist.append(i)
for j in reversed(range(a, b+1)):
    if j >= b - k + 1:
        numlist.append(j)

numSet = set(numlist)
numlist = list(numSet)
numlist.sort()
 
for l in range(len(numlist)):
    print(numlist[l])

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

if (b-a+1)/2 < k:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1, b+1):
        print(k)
Buggy python submission (verdict: Runtime Error):
# https://qiita.com/c-yan/items/e117269cc447fa61dddf
N = int(input())
A = list(map(int, input().split()))

d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

A = sorted(set(A))
t = [True] * (10 ** 6 + 1)
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]))

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]


def test():
    # x = map(int, input().split())
    x = input().split()
    print(x.index("0") + 1)

test()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]

from itertools import count
def test():
    n = int(input())
    a = [int(i) for i in input().split()]
    r = [True for i in range(1, n+1) if all([a[i-1] % a[j-1] != 0 for j in range(1, n+1) if i != j])]
    print(len([i for i in r if i]))

test()

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

from itertools import count
from collections import Counter

def test():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    mxn = a[-1]
    c = Counter(a)
    a = sorted(list(set(a)))
    r = dict()
    for i in a:
        for j in count(1):
            if i * j > mxn: break
            r[i * j] = r.get(i * j, 0) + 1
    print(len([k for k in a if r[k] == 1 and c[k] == 1]))


test()
Buggy python submission (verdict: Runtime Error):
#coding: utf-8

line = input().strip()
N = int(line[0])
A = int(line[2])
B = int(line[4])
monster = [int(input()) for i in range(N)]

times = 0
while len(monster) > 0:
    n = monster.index(max(monster)) #一番体力が大きい魔物のインデックス
    monster[n] = monster[n] - A
    if monster[n] < 1:
        monster[n] = 0

    for i, x in enumerate(monster):
        if i != n:
            monster[i] = monster[i] - B
            if monster[i] < 1:
                monster[i] = 0
    for i in monster:
        if i == 0:
            monster.remove(0)

    times = times + 1

print (times-1)

Fixed submission:
#coding: utf-8
import math

N, A, B = map(int, input().split())
monster = [int(input()) for i in range(N)]


def enough(T):
    attack = B * T
    diff = A-B
    count = 0
    for i in monster:
        tmp = math.ceil((i - attack)/diff)
        if tmp > 0:
            count += tmp

    if count <= T:
        return True
    else:
        return False

def bs():
    left = 0
    right = 1000000000

    while left < right:
        mid = (left + right) // 2
        if enough(mid):
            right = mid
        else:
            left = mid + 1
    return left

print(bs())

Buggy python submission (verdict: Runtime Error):
#coding: utf-8



line = input().strip()
N = int(line[0])
A = int(line[2])
B = int(line[4])
monster = [int(input()) for i in range(N)]

times = 0
while len(monster) > 0:
    n = monster.index(max(monster)) #一番体力が大きい魔物のインデックス
    print('max', n)
    print('monster', monster)
    monster[n] = monster[n] - A
    if monster[n] < 1:
        monster[n] = 0

    for i, x in enumerate(monster):
        if i != n:
            monster[i] = monster[i] - B
            if monster[i] < 1:
                monster[i] = 0
    for i in monster:
        if i == 0:
            monster.remove(0)


    times = times + 1

print (times-1)

Fixed submission:
#coding: utf-8
import math

N, A, B = map(int, input().split())
monster = [int(input()) for i in range(N)]


def enough(T):
    attack = B * T
    diff = A-B
    count = 0
    for i in monster:
        tmp = math.ceil((i - attack)/diff)
        if tmp > 0:
            count += tmp

    if count <= T:
        return True
    else:
        return False

def bs():
    left = 0
    right = 1000000000

    while left < right:
        mid = (left + right) // 2
        if enough(mid):
            right = mid
        else:
            left = mid + 1
    return left

print(bs())
Buggy python submission (verdict: Runtime Error):
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
ans=1
curr=0
ind=0
while(curr<=x):
    curr+=a[ind]
    ind+=1
    if(curr>x):
        break
    ans+=1
print(ans)


Fixed submission:
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
ans=1
curr=0
ind=0
while(curr<=x):
    if(ind>=n):
        break
    curr+=a[ind]
    ind+=1
    if(curr>x):
        break
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
l = list(map(int,input().split()))

for i in range(len(l)):
  if l[i] == 0:
    return i


        

Fixed submission:
l = list(map(int,input().split()))
for i in range(len(l)):
	if l[i] == 0:
		print(i+1)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
list1 = list(map(int,input().split()))
visited_town = [[] for i in range(N+1)] #どの町にいつ訪れたか,配列の0あける。
visited_time = [None for i in range(2*N)] #訪れた町の時系列。こっちは0あけない。

visited_town[1].append(0) 
visited_time[0] = 1

cycle_start = -1
cycle_end = -1
cycle_detect = False

for i in range(1,min([K,2*N])):
  next_town = list1[visited_time[i-1]-1]
  visited_town[next_town].append(i)
  visited_time[i] = next_town
  if len(visited_town[next_town]) == 2:
    cycle_start = visited_town[next_town][0]
    cycle_end   = visited_town[next_town][1]
    cycle_detect = True
    break

print(visited_time)

if (!cycle_detect)
  ans = visited_time[K]
  print(ans)
else :   
  syuuki = cycle_end-cycle_start
  cycle = visited_time[cycle_start:cycle_end]
  ans = cycle[(K-cycle_start) % syuuki]
  print(ans)


Fixed submission:
N,K = map(int,input().split())
list1 = list(map(int,input().split()))
visited_town = [[] for i in range(N+1)] #どの町にいつ訪れたか,配列の0あける。
visited_time = [None for i in range(2*N)] #訪れた町の時系列。こっちは0あけない。

visited_town[1].append(0) 
visited_time[0] = 1

cycle_start = -1
cycle_end = -1

for i in range(1,2*N):
  next_town = list1[visited_time[i-1]-1]
  visited_town[next_town].append(i)
  visited_time[i] = next_town
  if len(visited_town[next_town]) == 2:
    cycle_start = visited_town[next_town][0]
    cycle_end   = visited_town[next_town][1]
    break

if K < cycle_start:
  ans = visited_time[K]
  print(ans)
else :   
  syuuki = cycle_end-cycle_start
  cycle = visited_time[cycle_start:cycle_end]
  ans = cycle[(K-cycle_start) % syuuki]
  print(ans)
Buggy python submission (verdict: Runtime Error):
import math
ary1 = [int(input()) for x in range(5)]
ans = sum(10*math.ceil(x/10) for x in ary1) - max([10-(y % 10) for y in ary1 if y % 10 !=0])
print(ans)

Fixed submission:
import math
ary1 = [int(input()) for x in range(5)]
x1 = sum(10*math.ceil(x/10) for x in ary1)
x2 = max([10-(y % 10) if y % 10 !=0 else 0 for y in ary1 ])
ans = x1 - x2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
N, M = map(int,input().split())
ary1 =[]
for x in range(N):
  ary1.append(list(map(int,input().split())))

ary2 = sorted(ary1)
print(sum(reduce(lambda a,b: a+b ,[[x[0]]*x[1] for x in ary2])[0:M]))



Fixed submission:
from functools import reduce
N, M = map(int,input().split())
ary1 =[]
for x in range(N):
  ary1.append(list(map(int,input().split())))

ary2 = sorted(ary1)
count = 0
total_sum = 0
for i in range(N):
  if count + ary2[i][1] <= M:
    total_sum += ary2[i][0] * ary2[i][1]
    count += ary2[i][1]
  elif count > M :
    break
  else:
    zan = M - count
    total_sum += ary2[i][0] * zan
    count += zan

print(total_sum)
Buggy python submission (verdict: Time Limit Exceeded):
s = int(input())
def f(k):
  if k % 2 ==0:
    return k//2
  else:
    return 3*k+1

ary1 = [None]*1000001
ary1[1] = s

for i in range(2,1000001):
  fn = f(ary1[i-1])
  if fn in ary1:
    print(i)
    break
  else:
    ary1[i] = fn

Fixed submission:
s = int(input())
def f(k):
  if k % 2 ==0:
    return k//2
  else:
    return 3*k+1

ary1 = [None]*1000001
ary1[1] = s

for i in range(2,1000001):
  fn = f(ary1[i-1])
  if fn in ary1:
    print(i)
    break
  else:
    ary1[i] = fn
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int,input().split()))
xlist = list(map(int,input().split()))

def f(list1):
  min1 = list1[0]
  max1 = list1[-1]
  if min1>=0 and max1>=0:
    return abs(max1)
  elif min1<0 and max1 <0:
    return abs(min1)
  else:
    return total+min([abs(min1),abs(max1)])

ans = 2*10**8 + 2
for i in range(N-K+1):
  dist =f (xlist[i:i+K]) 
  if dist < ans :
    ans = dist

print(ans)



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

def f(min1,max1):
  if min1>=0 and max1>=0:
    return abs(max1)
  elif min1<=0 and max1 <=0:
    return abs(min1)
  else:
    return min([-2*min1 + max1,-min1 + 2*max1])

ans = 2*10**9
for i in range(N-K+1):
  min1 = xlist[i]
  max1 = xlist[i+K-1]
  dist =f (min1,max1) 
  if dist < ans :
    ans = dist

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
list_ai = list(map(int,input().split()))
a1 = np.array(list_ai)-np.arange(1,N+1)
median1 = int(np.floor(np.median(a1)))
ans = np.sum(np.abs(a1-median1))
print(ans)


Fixed submission:
N = int(input())
if N % 2 ==0:
  print(N)
else:
  print(2*N)
Buggy python submission (verdict: Runtime Error):
num = input()
lst = list(map(int, num))
ele = lst[-1]
if ele==2 or ele==4 or ele==5 or ele==7 or ele==9:
  	print("hon")
elif ele==1 or ele==6 or ele==8:
 	print("pon")
elif ele==3
	print("bon")

Fixed submission:
num = input()
lst = list(map(int, num))
ele = lst[-1]
if ele==2 or ele==4 or ele==5 or ele==7 or ele==9:
  	print("hon")
elif ele==0 or ele==1 or ele==6 or ele==8:
 	print("pon")
elif ele==3:
	print("bon")

Buggy python submission (verdict: Runtime Error):
num = input()
lst = lst(map(int, num))
ele = lst[-1]
if ele==2 or ele==4 or ele==5 or ele==7 or ele==9:
  	print("hon")
elif ele==1 or ele==6 or ele==8:
 	print("pon")
elif ele==3
	print("bon")

Fixed submission:
num = input()
lst = list(map(int, num))
ele = lst[-1]
if ele==2 or ele==4 or ele==5 or ele==7 or ele==9:
  	print("hon")
elif ele==0 or ele==1 or ele==6 or ele==8:
 	print("pon")
elif ele==3:
	print("bon")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ta = [[int(i) for i in input().split()] for j in range(n)]

a = ta[0][0]
b = ta[0][1]
for i in range(1, n):
    tempa = ta[i][0]
    tempb = ta[i][1]
    j = 2
    while(tempa < a or tempb < b):
        tempa = ta[i][0] * j
        tempb = ta[i][1] * j
        j += 1

    a = tempa
    b = tempb

print(a+b)


Fixed submission:
import math

n = int(input())
ta = [[int(i) for i in input().split()] for j in range(n)]

a = 1
b = 1
for i in range(n):
    #n = max(math.floor(a/ta[i][0]), math.floor(b/ta[i][1]))
    n = max(~-a//ta[i][0] + 1, ~-b//ta[i][1] + 1)
    a = n * ta[i][0]
    b = n * ta[i][1]

print(a+b)