Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import itertools
import math
N = int(input())
As =list(map(int,input().split(" ")))
odds = 0
two = 0
four = 0
nums = []
for a in As:
    if a % 2 == 1:
        odds += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1
if odds > 0:
    nums.append(1)
    odds -= 1
elif two > 0:
    nums.append(2)
    two -=1
else:
    nums.append(4)
    four-=1
ans = "Yes"

if N==2:
    if As[0] * As[1]%4 !=0:
       ans = "No"
else:
    for i in range(1,N):
        if nums[i-1] == 1:
            if four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
        elif nums[i - 1] == 2:
            if two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"

        elif nums[i - 1] == 4:
            if odds> 0:
                nums.append(1)
                odds -= 1
            elif two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1

print(ans)

Fixed submission:
import itertools
import math
N = int(input())
As =list(map(int,input().split(" ")))
odds = 0
two = 0
four = 0
nums = []
for a in As:
    if a % 2 == 1:
        odds += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1
if odds > 0:
    nums.append(1)
    odds -= 1
elif two > 0:
    nums.append(2)
    two -=1
else:
    nums.append(4)
    four-=1
ans = "Yes"

if N==2:
    if As[0] * As[1]%4 !=0:
       ans = "No"
else:
    for i in range(1,N):
        if nums[i-1] == 1:
            if four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
                break
        elif nums[i - 1] == 2:
            if two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
                break
        elif nums[i - 1] == 4:
            if odds> 0:
                nums.append(1)
                odds -= 1
            elif two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1

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

N,K =list(map(int,input().split(" ")))
As= list(map(int,input().split(" ")))
g = As[0]
ma = -1
for a in As:
    g = math.gcd(g,a)
    ma = max(ma,a)
    if K == a:
        print("POSSIBLE")
        exit()
if K % g == 0 and ma >= K:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
import fractions

N,K =list(map(int,input().split(" ")))
As= list(map(int,input().split(" ")))
g = As[0]
ma = -1
for a in As:
    g = fractions.gcd(g,a)
    ma = max(ma,a)
    if K == a:
        print("POSSIBLE")
        exit()
if K % g == 0 and ma >= K:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):

import math
N = int(input())
graph = {}
SCORE = 0
def dfs(visted,v,depth):
    visted[v] = depth
    for next_v in graph[v]:
        if  visted[next_v]  == -1 :
            dfs(visted,next_v,depth + 1)




for _ in range(N-1):
    a,b = map(int,input().split(" "))
    if a not in graph:
        graph[a] = [b]
    else:
        graph[a].append(b)

    if b not in graph:
        graph[b] = [a]
    else:
        graph[b].append(a)

vF = [-1] * (N + 1)
vF[1] = 0
dfs(vF,1,0)
# print(vF)

vS = [-1] * (N + 1)
vS[N] = 0

dfs(vS,N,0)
# print(vS)

fc = 0
sc = 0

for f,s in zip(vF[1:N + 1],vS[1:N + 1]):
    if f <= s:
        fc += 1
    else:
        sc += 1

# print(fc,sc)
if fc > sc:
    print("Fennec")
else:
    print("Snuke")


Fixed submission:

import math
import sys
sys.setrecursionlimit(1000000)
N = int(input())
graph = {}
SCORE = 0
def dfs(visted,v,depth):
    visted[v] = depth
    for next_v in graph[v]:
        if  visted[next_v]  == -1 :
            dfs(visted,next_v,depth + 1)




for _ in range(N-1):
    a,b = map(int,input().split(" "))
    if a not in graph:
        graph[a] = [b]
    else:
        graph[a].append(b)

    if b not in graph:
        graph[b] = [a]
    else:
        graph[b].append(a)

vF = [-1] * (N + 1)
vF[1] = 0
dfs(vF,1,0)
# print(vF)

vS = [-1] * (N + 1)
vS[N] = 0

dfs(vS,N,0)
# print(vS)

fc = 0
sc = 0

for f,s in zip(vF[1:N + 1],vS[1:N + 1]):
    if f <= s:
        fc += 1
    else:
        sc += 1

# print(fc,sc)
if fc > sc:
    print("Fennec")
else:
    print("Snuke")
Buggy python submission (verdict: Runtime Error):

n,m =list(map(int,input().split(" ")))
xs  =list(map(int,input().split(" ")))
ys =list(map(int,input().split(" ")))
MOD = (10**9) + 7
x_diff = [abs(i - j) for i,j in zip(xs[:n-1],xs[1:n]) ]
y_diff = [abs(i - j) for i,j in zip(ys[:n-1],ys[1:n]) ]

cot = 1
x = 0
for i in range(n -1 ):
    x +=cot * (n-i -1) * x_diff[i]
    cot += 1

cot = 1
y = 0
for i in range(m -1):
    y += cot * (m-i -1) * y_diff[i]
    cot += 1



print (x* y % MOD )


Fixed submission:

n,m =list(map(int,input().split(" ")))
xs  =list(map(int,input().split(" ")))
ys =list(map(int,input().split(" ")))
MOD = (10**9) + 7
x_diff = [abs(i - j) for i,j in zip(xs[:n-1],xs[1:n]) ]
y_diff = [abs(i - j) for i,j in zip(ys[:m-1],ys[1:m]) ]

cot = 1
x = 0
for i in range(n -1 ):
    x +=cot * (n-i -1) * x_diff[i]
    cot += 1

cot = 1
y = 0
for i in range(m -1):
    y += cot * (m-i -1) * y_diff[i]
    cot += 1



print (x* y % MOD )
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
nums.sort()
ans = 0

for _ in  range(N):
    nums.pop(-1)
    ans += nums.pop(-1)
    nums.pop(0)
print(ans)

Fixed submission:
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
nums.sort()
ans = 0

for _ in  range(N):
    nums.pop()
    ans += nums.pop()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
nums.sort()
ans = 0

for _ in  range(N):
    nums.pop(-1)
    ans += nums.pop(-1)
    nums.pop(0)
print(ans)

Fixed submission:
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
nums.sort()
ans = 0

for _ in  range(N):
    nums.pop()
    ans += nums.pop()
print(ans)
Buggy python submission (verdict: Runtime Error):


import math
N,Ma,Mb = map(int,input().split(" "))
drags = [list(map(int,input().split(" "))) for  _ in range(N)]
INF = 10 ** 9
lim = N * 10 + 1
dp = [[[ INF for i in range(lim)] for j in range(lim)] for _ in range(N+1)]
dp[0][0][0] = 0
for num in range( N ):
    a,b,c = drags[num]
    for i in range(a,401): #薬品厨のa の量
        for j in range(b,401 ):#薬品厨のb の量
             dp[num + 1][i][j] = min(dp[num][i ][j] ,dp[num][i - a][j - b]  + c)

ans = INF
for i in range(1,41):
    MA = Ma * i
    MB = Mb * i
    if MA >= lim or MB >= lim:
        break
    ans = min(ans, dp[-1][MA][MB])
if ans == INF:
    ans = -1
print(ans)


Fixed submission:


import math
N,Ma,Mb = map(int,input().split(" "))
drags = [list(map(int,input().split(" "))) for  _ in range(N)]
INF = 10 ** 9
lim = N* 10 + 1
dp = [[[ INF for i in range(lim)] for j in range(lim)] for _ in range(N+1)]
dp[0][0][0] = 0
for num in range( N ):
    a,b,c = drags[num]
    dp[num + 1][0][0] = 0
    for i in range(0,lim): #完成した液体の aの量
        for j in range(0,lim):# bの量
            dp[num + 1][i][j]  =  dp[num][i][j]
            if i - a >= 0 and j - b >= 0:
                dp[num + 1][i ][j ] = min(dp[num][i ][j ] ,dp[num][i -a ][j -b  ]  + c)

ans = INF
for i in range(1,41):
    MA = Ma * i
    MB = Mb * i
    if MA >= lim or MB >= lim:
        break
    ans = min(ans, dp[-1][MA][MB])
if ans == INF:
    ans = -1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split(" "))
ans = 0
for x in range(K + 1):
  for y in range(K + 1):
    for z in range(K + 1):
      if x + y + z == S:
        ans += 1
print(ans)
      

Fixed submission:
K,S = map(int,input().split(" "))
ans = 0
for x in range(K + 1):
  for y in range(K + 1):
      if  0 <= S - (x + y) <= K:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):

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

dp = [[[0 for i in range(2800)]for j in range(50)]for k in range(50)]

# dp[i][j][k] → i枚のうちj枚を選んで 和が kになる組み合わせ
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(2501):
            if dp[i][j][k] != 0:
                dp[i+1][j][k] += dp[i][j][k]    #i枚目を選ばなかった世界線
                dp[i + 1][j + 1][k + nums[i]]  += dp[i][j][k]          #i枚目を選んだ世界線


ans = 0
for j in range(1,N+1):
    ans += dp[N][j][j*A]
print(ans)

Fixed submission:

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

dp = [[[0 for i in range(4000)]for j in range(51)]for k in range(51)]

# dp[i][j][k] → i枚のうちj枚を選んで 和が kになる組み合わせ
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(3000):
            if dp[i][j][k] != 0:
                dp[i+1][j][k] += dp[i][j][k]    #i枚目を選ばなかった世界線
                dp[i + 1][j + 1][k + nums[i]]  += dp[i][j][k]          #i枚目を選んだ世界線


ans = 0
for j in range(1,N+1):
    ans += dp[N][j][j*A]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=1
c=0
for n in range(N):
    if A[n]==0:
        c=2
for n in range(N):
    ans=ans*A[n]
    if ans>10**18:
        c=-1
for n in range(N):
    if A[n]==0:
        c=2
if c==-1:
    print(-1)
elif c==2:
    print(0)
else:
    print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
c=1
for n in range(N):
    if A[n]==0:
        c=0
        break
if c!=0:
    for n in range(N):
        ans=ans*A[n]
        if ans>10**18:
            c=-1
            break
if c==-1:
    print(-1)
elif c==0:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M=(int(x) for x in input().split())
a=list(map(int,input().split()))
A=np.array(a)
for m in range(M):
    A[np.argmax(A)]=A[np.argmax(A)]/2
ans=0
for n in range(N):
    ans+=round(A[n])
print(ans)


Fixed submission:
import heapq
N,M=(int(x) for x in input().split())
a=list(map(int,input().split()))
a=list(map(lambda x: x*(-1),a))
heapq.heapify(a)
for _ in range(M):
    dai=heapq.heappop(a)
    heapq.heappush(a,(-1)*(dai*(-1)//2))
print((-1)*sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
    return get_counter(first_word) == get_counter(second_word)
ans=[]
N=int(input())
kotae=[0]*N
for n in range(N):
    a=input()
    if n==0:
        ans.append(a)
        kotae[0]=1
    else:
        u=0
        for i in range(len(ans)):
            if verify_anagrams(a,ans[i])==True:
                kotae[i]+=1
                u=1
                break
        if u==0:
            kotae[len(ans)]=1
            ans.append(a)
c=0
for n in range(len(kotae)):
    c=c+kotae[n]*(kotae[n]-1)/2
print(round(c))


Fixed submission:
import collections


N=int(input())
c=0
ans=[]
for n in range(N):
    a=input()
    a=sorted(a)
    a=''.join(a)
    ans.append(a)
c = collections.Counter(ans)
values, counts = zip(*c.most_common())
uu=0
for n in range(len(counts)):
    uu+=(counts[n]*(counts[n]-1))/2
print(round(uu))
Buggy python submission (verdict: Time Limit Exceeded):
import math
S=int(input())
ss=math.sqrt(S)
s=math.floor(ss)
for i in range(s):
    n=s-i
    if S%n==0:
        t=n
        break
print(0,0,0,t,round(S/t),0)


Fixed submission:
import math
S=int(input())
ss=math.sqrt(S)
s=math.ceil(ss)
t=s*s-S
if t>10**9:
    for n in range(2,t+1):
        if t%n==0:
            k=n
            break
elif t>0:
    k=1
    print(0,0,s,k,round(t/k),s)
if t==0:
    print(0,0,s,0,0,s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
S=int(input())
ss=math.sqrt(S)
s=math.floor(ss)
for i in range(s):
    n=s-i
    if S%n==0:
        t=n
        break
print(0,0,0,t,round(S/t),0)


Fixed submission:
import math
S=int(input())
ss=math.sqrt(S)
s=math.ceil(ss)
t=s*s-S
if t>10**9:
    for n in range(2,t+1):
        if t%n==0:
            k=n
            break
elif t>0:
    k=1
    print(0,0,s,k,round(t/k),s)
if t==0:
    print(0,0,s,0,0,s)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
ans=[]
for i in range(N):
    n=N-i
    syou=N//n
    c=0
    for l in range(1,syou):
        aa=n*(l+1)-1
        c=(c+b[aa])%2
    if a[n-1]==0:
        if c==0:
            b[n-1]=0
        else:
            b[n-1]=1
            ans.append(n)
    if a[n-1]==1:
        if c==0:
            b[n-1]=1
            ans.append(n)
        else:
            b[n-1]=0
print(len(ans))
if len(ans)>1:
    print(' '.join(ans))
if len(ans)==1:
    print(1)


Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
ans=[]
for i in range(N):
    n=N-i
    syou=N//n
    c=0
    for l in range(1,syou):
        aa=n*(l+1)-1
        c=(c+b[aa])%2
    if a[n-1]==0:
        if c==0:
            b[n-1]=0
        else:
            b[n-1]=1
            ans.append(str(n))
    if a[n-1]==1:
        if c==0:
            b[n-1]=1
            ans.append(str(n))
        else:
            b[n-1]=0
print(len(ans))
if len(ans)>1:
    print(' '.join(ans))
if len(ans)==1:
    print(1)
Buggy python submission (verdict: Runtime Error):
L,R=(int(x) for x in input().split())
L_mod=L%2019
R_mod=R%2019
if L_mod>=R_mod:
    print(0)
else:
    print(L_mod*(L_mod+1s))


Fixed submission:
L,R=(int(x) for x in input().split())
ans=[]
for n in range(2019):
    if L+n>=R:
        break
    for l in range(n+1,2019):
        if L+l>R:
            break
        a=(L+n)%2019
        b=(L+l)%2019
        c=a*b%2019
        ans.append(c)
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
suu=(N/2)-1
d=list(map(int,input().split()))
for n in range(round(suu)):
    s=d.index(max(d))
    d.pop(s)
dai=max(d)
s=d.index(max(d))
d.pop(s)
syo=max(d)
print(dai-syo)


Fixed submission:
N=int(input())
d=list(map(int,input().split()))
d.sort()
dai=d[round((N/2)-1)]
syo=d[round(N/2)]
print(syo-dai)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
s=list(b)
x=s.count('R')
y=s.count('B')
if x>y:
    print('Yes')
else:
    print('No')

Fixed submission:
a=input()
s=list(input())
x=s.count('R')
y=s.count('B')
if x>y:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = ''
while N > 0:
    N -= 1
    ans += chr(ord('a' + N % 26))
    N //= 26
print(ans[::-1])


Fixed submission:
n = int(input())
ans = ''
i = 1
while n > 0 :
    x = n % 26
    if x != 0:
        ans += chr(x+96)
    else:
        ans += 'z'
        n -= 1
    n = n//26
print(ans[::-1])

Buggy python submission (verdict: Runtime Error):
import itertools
import math
N = int(input())
alphabet = list('abcdefghijklmnopqrstuvwxyz')
num = math.ceil(math.log(N, 26))
cnt = [26**i for i in range(1, 15)]
cumsum = list(itertools.accumulate(cnt))
if num == 1:
    ans_n = N-1
    ans_li = list(itertools.product(alphabet, repeat=num))
    print(''.join(ans_li[ans_n]))
else:
    ans = ''
    # for i in range(num):
    #     if i == 1:
    #         ans_n = N-1
    #         ans_li = list(itertools.product(alphabet, repeat=num))
    #         ans += ans_li[ans_n]
    #     else:
    #         now_n = N-26**(i-1) - 1
    #         pre = 26**(i-1)
    #         tmp = ans_n//pre

    ans_n = N - cumsum[num-1] - 1
    pre = 26**(num-1)
    tmp = ans_n//pre
    ans = alphabet[tmp]
    final = ans_n - pre*tmp
    ans_li = list(itertools.product(alphabet, repeat=num-1))
    print(ans + ''.join(ans_li[final]))



Fixed submission:
n = int(input())
ans = ''
i = 1
while n > 0 :
    x = n % 26
    if x != 0:
        ans += chr(x+96)
    else:
        ans += 'z'
        n -= 1
    n = n//26
print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
import sys
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
        print(*An)
        sys.exit()
print(*An)


Fixed submission:
from itertools import accumulate
import sys
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
        print(*An)
        sys.exit()
print(*An)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
        break
print(*An)


Fixed submission:
from itertools import accumulate
import sys
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
        print(*An)
        sys.exit()
print(*An)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
print(*An)


Fixed submission:
from itertools import accumulate
import sys
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
        print(*An)
        sys.exit()
print(*An)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 1
for a in an:
    if 0 in an:
        ans = 0
        break
    ans *= a
    if ans > 10**18:
        ans = -1
        break
print(ans)


Fixed submission:
N = int(input())
an = list(map(int, input().split()))
ans = 1
if 0 in an:
    ans = 0
else:
    for a in an:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()
print(A*B//1)

Fixed submission:
A, B = input().split()
B = int(B[0]+B[-2]+B[-1])
A = int(A)
ans = A*B
print(ans//100)

Buggy python submission (verdict: Runtime Error):
import math
A, B = input().split()
A = int(A)
B = float(B)
B = format(B, '.20f')
# B *= 100
# B = int(B)
# ans = A*B
# ans /= 100
ans = A*B
print(math.floor(ans))


Fixed submission:
A, B = input().split()
B = int(B[0]+B[-2]+B[-1])
A = int(A)
ans = A*B
print(ans//100)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
    temp = An[i]
    if check[temp-1] == 1:
        dup = temp
        break
    root.append(temp)
    check[temp-1] = 1
    i = temp - 1
    cnt += 1
index = root.index(dup)
if index <= k:
    print(root[k-1])
elif index == cnt - 1:
    print(dup)
else:
    print(root[(k-index) % (cnt-index) + index])


Fixed submission:
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
    temp = An[i]
    if check[temp-1] == 1:
        dup = temp
        break
    root.append(temp)
    check[temp-1] = 1
    i = temp - 1
    cnt += 1
index = root.index(dup)
if index >= k:
    print(root[k])
elif index == cnt - 1:
    print(dup)
else:
    print(root[(k-index) % (cnt-index) + index])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
an = list(map(int, input().split()))
check1 = []
check2 = []
ans = 0
for i, a in enumerate(an):
    check1.append(i+a)
    check2.append(i-a)
    if i-a in check1:
        ans += check1.count(i-a)
    if i+a in check2:
        ans += check2.count(i+a)
print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(n) for n in input().split()]
record = defaultdict(int)
count = 0
for i in range(len(A)):
    cur = i-A[i]
    count += record[cur]
    record[i+A[i]] += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
an = list(map(int, input().split()))
check1 = []
check2 = []
ans = 0
for i, a in enumerate(an):
    check1.append(i+a)
    check2.append(i-a)
    ans += check1.count(i-a)
    ans += check2.count(i+a)
print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(n) for n in input().split()]
record = defaultdict(int)
count = 0
for i in range(len(A)):
    cur = i-A[i]
    count += record[cur]
    record[i+A[i]] += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
an = list(map(int, input().split()))
diff = itertools.combinations(list(range(1, n+1)), 2)
li = itertools.combinations(an, 2)
ans = 0
for d, l in zip(diff, li):
    if abs(d[0]-d[1]) == l[0]+l[1]:
        ans += 1
print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(n) for n in input().split()]
record = defaultdict(int)
count = 0
for i in range(len(A)):
    cur = i-A[i]
    count += record[cur]
    record[i+A[i]] += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
if n < b:
    ans = a*n//b
else:
    ans = max(ans, (a*(b*2-1))//b - a)
    li = [1, (1+(n//b))//2, -(-(1+(n//b))//2)]
    for i in li:
        check = (a*(b*(i+1)-1))//b - a*i
        ans = max(ans, check)
    ans = max(ans, (a*n)//b)-a*(n//b)
print(ans)

Fixed submission:
a, b, n = map(int, input().split())
ans = 0
if n < b:
    ans = max(ans, a*n//b)
else:
    ans = max(ans, (a*n)//b)-a*(n//b)
    ans = max(ans, ((a*(b*(n//b)-1))//b)-a*(n//b - 1))
print(ans)