Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
counter=0
for i in range(a[0]-1,a[n-1]+2):
    sum=a.count(i-1)+a.count(i)+a.count(i+1)
    if sum>counter:
        counter=sum

print(counter)


Fixed submission:
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
c=collections.Counter(a)
counter=0
for i in range(a[0],a[n-1]+1):
    sum=c[i-1]+c[i]+c[i+1]
    if sum>counter:
        counter=sum

print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
counter=0
for i in range(a[0]-1,a[n-1]+2):
    sum=a.count(i-1)+a.count(i)+a.count(i+1)
    if sum>counter:
        counter=sum

print(counter)


Fixed submission:
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
c=collections.Counter(a)
counter=0
for i in range(a[0],a[n-1]+1):
    sum=c[i-1]+c[i]+c[i+1]
    if sum>counter:
        counter=sum

print(counter)
Buggy python submission (verdict: Runtime Error):
S=input()
x="None"
num=[False for i in range(26)]
for i in range(len(S)):
    num[ord(S[i])-ord("a")]=True

for j in range(26):
    if !num[j]:
        x=chr(j+ord("a"))
        break

print(x)


Fixed submission:
S=input()
x="None"
T="abcdefghijklmnopqrstuvwxyz"
num=[0 for i in range(26)]
for i in range(26):
    num[i]+=S.count(T[i])

for j in range(26):
    if num[j]==0:
        x=T[j]
        break

print(x)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[0,1,3,1,2,1,2,1,1,2,1,2,1
if a[x]==a[y]:
    print("Yes")
else:
    print("No")


Fixed submission:
x,y=map(int,input().split())
if x==y==2:
    print("Yes")
elif x==4:
    if y==6 or y==9 or y==11:
        print("Yes")
    else:
        print("No")
elif x==6:
    if y==4 or y==9 or y==11:
        print("Yes")
    else:
        print("No")
elif x==9:
    if y==6 or y==4 or y==11:
        print("Yes")
    else:
        print("No")
elif x==11:
    if y==6 or y==9 or y==4:
        print("Yes")
    else:
        print("No")


else:
    if y!=2 and y!=4 and y!=6 and y!=9 and y!=11:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
counter=1

while len(A)>1:
    if A[0]==A[1]:
        A=A[1:]
    else:
        res=(A[1]>A[0])
        for i in range(len(A)-1):
            if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
                A=A[i+1:]
                counter+=1
                break


print(counter)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
counter=1

while len(A)>1:
    if A[0]==A[1]:
        A=A[1:]
    else:
        res=(A[1]>A[0])
        for i in range(len(A)-1):
            if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
                A=A[i+1:]
                counter+=1
                break


print(counter)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)

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

while len(A)>1:
    if A[0]=A[1]:
        A=A[1:]
    else:
        res=(A[1]>A[0])
        for i in range(len(A)-1):
            if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
                A=A[i+1:]
                counter+=1
                break


print(counter)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)

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

while len(A)>1:
    res=(A[1]>=A[0])
    for i in range(len(A)):
        if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
            A=A[i+1:]
            counter+=1
            break

print(counter)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
counter=1
res=(A[1]>=A[0])
if N==1:
    print(1)
else:
    for i in range(N-1):
        if A[i+1]<A[i] and res:
            res=False
            counter+=1
        elif A[i+1]>A[i] and not res:
            res=True
            counter+=1
    print(counter)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
res=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k==S:
                res+=1

print(res)


Fixed submission:
K,S=map(int,input().split())
res=0
for i in range(K+1):
    for j in range(K+1):
        if S-i-j>=0 and S-i-j<=K:
            res+=1

print(res)
Buggy python submission (verdict: Runtime Error):
abc=sorted(list(map(int,input().split())))
if a==c:
    print(1)
elif a==b or b==c:
    print(2)
else:
    print(3)


Fixed submission:
abc=sorted(list(map(int,input().split())))
if abc[0]==abc[2]:
    print(1)
elif abc[0]==abc[1] or abc[1]==abc[2]:
    print(2)
else:
    print(3)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = []
ans = 1

import collections
ans = 1
all_ans = 0
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in range(1, N):
  ans = 1
  c = collections.Counter(prime_factorize(N-i))
  for i in c.values():
    ans *= (i+1)
  all_ans += ans

print(all_ans)

Fixed submission:
N = int(input())
c = []
ans = 1

import collections
ans = 1
all_ans = 0
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in range(1, N):
  ans = 1
  c = collections.Counter(prime_factorize(N-i))
  for i in c.values():
    ans *= (i+1)
  all_ans += ans

print(all_ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def main():
  n = int(input())
  a = list(map(int, input().split()))
  sum = 0
  mod = 10**9+7
  for i in range(n):
    for j in range(i+1, n):
      sum += a[i]*a[j]
  print(sum%mod)
main()



Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
S = sum(a)
S2 = sum(map(lambda x:x*x, a))
print((S*S-S2)//2%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
sum = 0
mod = 10**9+7
for i in range(n):
  for j in range(i+1, n):
    sum += a[i]*a[j]
print(sum%mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
S = sum(a)
S2 = sum(map(lambda x:x*x, a))
print((S*S-S2)//2%mod)
Buggy python submission (verdict: Runtime Error):
s = input()
count = 0
if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'SSR' in s or 'SRS' in s or 'RSS' in sor 'RSR' in s:
  print(1)
else:
  print(0)

Fixed submission:
s = input()
count = 0
if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'SSR' in s or 'SRS' in s or 'RSS' in s or 'RSR' in s:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
x, k, d = map(int ,input().split())
ans_min = x

def dfs(i, ans):
  global ans_min
  if abs(ans_min) > abs(ans) and ans >= 1:
    ans_min = ans
  if i == k:
    return abs(ans_min)
  dfs(i + 1, ans + d)
  dfs(i + 1, ans - d)

dfs(0, x)
print(ans_min)

Fixed submission:
x, k, d = map(int, input().split())

x = abs(x)
straight = min(k, x//d)
k -= straight
x -= straight*d

if k%2 == 0:
  print(x)
else:
  print(d-x)

Buggy python submission (verdict: Runtime Error):
x, k, d = map(int ,input().split())
ans_min = x

def dfs(i, ans):
  global ans_min
  if abs(ans_min) > abs(ans) and ans != 0:
    ans_min = ans
  if i == k:
    return abs(ans_min)
  dfs(i + 1, ans + d)
  dfs(i + 1, ans - d)

dfs(0, x)
print(ans_min)

Fixed submission:
x, k, d = map(int, input().split())

x = abs(x)
straight = min(k, x//d)
k -= straight
x -= straight*d

if k%2 == 0:
  print(x)
else:
  print(d-x)

Buggy python submission (verdict: Runtime Error):
x, k, d = map(int ,input().split())
ans_min = x

def dfs(i, ans):
  global ans_min
  if abs(ans_min) > abs(ans):
    ans_min = ans
  if i == k:
    return abs(ans_min)
  dfs(i + 1, ans + d)
  dfs(i + 1, ans - d)

dfs(0, x)
print(ans_min)

Fixed submission:
x, k, d = map(int, input().split())

x = abs(x)
straight = min(k, x//d)
k -= straight
x -= straight*d

if k%2 == 0:
  print(x)
else:
  print(d-x)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
mod = 7

if k % 2 == 0:
  print('-1')
else:
  for i in range(10**7):
    if mod % k == 0:
      print(i+1)
      break
    else:
      mod = mod*10 + 7
  else:
    print('-1')

Fixed submission:
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
K = str(input())
S = '7'*len(K)
ans = 0

if int(K)%2 == 0 or int(K)%5 == 0:
    ans = 2

while ans == 0:
    if int(S)%int(K) == 0:
        ans = 1
    else:
        S += '7'

if ans == 1:
    print(len(S))
else:
    print('-1')


Fixed submission:
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
K = str(input())
S = '7'*len(K)
ans = 0

if int(K)%2 == 0 or int(K)%5 == 0:
    ans = 2

while ans == 0:
    if int(S)%int(K) == 0:
        ans = 1
    else:
        S += '7'

if ans == 1:
    print(len(S))
else:
    print('-1')


Fixed submission:
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
K = str(input())
S = '7'*len(K)
ans = 0
while ans == 0:
    if int(S)%int(K) == 0:
        ans = 1
    elif int(K)%2 == 0 or int(K)%5 == 0:
        break
    else:
        S += '7'

if ans == 1:
    print(len(S))
else:
    print('-1')


Fixed submission:
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = '7'
ans = 0
while ans == 0:
    if int(S)%K == 0:
        ans = 1
    elif K%2 == 0 or K%5 == 0:
        break
    else:
        S += '7'

if ans == 1:
    print(len(S))
else:
    print('-1')


Fixed submission:
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)
Buggy python submission (verdict: Runtime Error):
a = input()
print(a + a**2 + a**3)

Fixed submission:
a = int(input())
print(int(a + a**2 + a**3))
Buggy python submission (verdict: Runtime Error):
def main():
    count = 0
    ans = []
    N, K = map(int, input().split())
    for _ in range(K):
        d = int(input())
        a = [input() for _ in range(d)]
        ans.append(a)
    for _ in range(1, N + 1):
        if _ not in ans:
            count += 1

    print(count)
    return

main()

Fixed submission:
def main():
    ans = []
    N, K = map(int, input().split())

    for i in range(K):
        d = int(input())
        a = map(int, input().split())
        for j in a:
            ans.append(j)

    count = 0
    for i in range(1, N + 1):
        if not i in ans:
            count += 1

    print(count)
    return

main()
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
while True:
    c = c - b
    if c <= 0:
        print('Yes')
        break
    a = a - d
    if a <= 0:
        print('No')
        break


Fixed submission:
s, w = map(int, input().split())
if s > w:
    print('safe')
else:
    print('unsafe')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m+1):
    if a[i]/sum(a) > 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m):
    if a[i]/sum(a) >= 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m+1):
    if a[i]/sum(a) > 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m):
    if a[i]/sum(a) >= 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
for _ in  A:
    if _ % 2 == 0:
        if _ % 3 == 0 or _ % 5 == 0:
            ans *= 1
        else:
            ans *= 0

if ans == 1:
    print('APPROVED')
else:
    print('DENIED')

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

for _ in  A:
    if _ % 2 == 0:
        if _ % 3 == 0 or _ % 5 == 0:
            ans *= 1
        else:
            ans *= 0

if ans == 1:
    print('APPROVED')
else:
    print('DENIED')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
cnt = 0
ans = [0]*n
num = 0
for i in range(0, m):
  num = int(l[i][0])
  if l[i][1] == 'AC':
    ans[num] = 1
  elif ans[num] != 1:    
    cnt += 1
print(sum(ans), cnt)

Fixed submission:
n, m = map(int, input().split())
P = [0]*n
AC = [False]*n
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem-1] == False:
    if result == 'AC':
      AC[problem-1] = True
      correct += 1
      penalty += P[problem-1]
    else:
      P[problem-1] += 1
print(correct, penalty)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def A_sum(A):
  s = 0
  for i in A.items():
    s+=i[0]*i[1]
  print(s)

def A_rep(A,f,t):
  f_num = A.get(f)
  if f_num != None:
      A[t]=A.get(t,0) + f_num
      A.pop(f)

N = int(input())
A = collections.Counter(map(int,input().split()))
Q = int(input())
for i in range(Q):
  b,c = map(int,input().split())
  A_rep(A,b,c)
  A_sum(A)


Fixed submission:
import collections

def A_sum(A):
  s = 0
  for i in A.items():
    s+=i[0]*i[1]
  return s

def A_rep(A,f,t):
  f_num = A.get(f)
  if f_num != None:
      A[t]=A.get(t,0) + f_num
      diff = f_num*(t-f)
      A.pop(f)
      return diff
  return 0

N = int(input())
A = collections.Counter(map(int,input().split()))
Q = int(input())
ans = A_sum(A)
for i in range(Q):
  b,c = map(int,input().split())
  diff = A_rep(A,b,c)
  if diff !=0:
    ans+=diff
  print(ans)
Buggy python submission (verdict: Runtime Error):
X,N,*P = map(int,open(0).read().split())
if P != []:
  P = sorted(list(map(int,P.split())),reverse=True)
else:
  print(X)
  exit()

min_diff = 101
min_val = 101

if N == 100:
  if X <=50:
    ans = 0
  else:
    ans = 101
else:
  for i in range(100,-1,-1):
    #print(i,min_val,min_val)
    if not i in P:
      if abs(X-i) <= min_diff and min_val >i:
      	min_diff = abs(X-i)
      	min_val = i
  ans = min_val
print(ans)

Fixed submission:
X,N,*P = map(int,open(0).read().split())
if P != []:
  P = sorted(list(P),reverse=True)
else:
  print(X)
  exit()

min_diff = 101
min_val = 101

for i in range(101,-1,-1):
  #print(i,min_val,min_val)
  if not i in P:
    if abs(X-i) <= min_diff and min_val >=i:
      min_diff = abs(X-i)
      min_val = i
  ans = min_val
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B =map(int,input.split())
print(A*B)

Fixed submission:
A,B =map(int,input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split()) #n:頂点数　w:辺の数


way = [[] for i in range(M)]
depth = [float("inf") for i in range(N)]
visited = [False for i in range(N)]
que=[0]

for i in range(M):
    x,y = map(int,input().split())
    way[x-1].append(y-1)
    way[y-1].append(x-1)

for i in que:
  for j in way[i]:
    if visited[j]:
      continue
    que.append(j)
    visited[j]=True
    depth[j] = min(i+1,depth[j])
print("Yes")
for i in range(1,N):
  print(depth[i])

Fixed submission:
N,M = map(int,input().split()) #n:頂点数　w:辺の数


way = [[] for i in range(N)]
depth = [float("inf") for i in range(N)]
visited = [False for i in range(N)]
que=[0]

for i in range(M):
    x,y = map(int,input().split())
    way[x-1].append(y-1)
    way[y-1].append(x-1)

for i in que:
  for j in way[i]:
    if visited[j]:
      continue
    que.append(j)
    visited[j]=True
    depth[j] = min(i+1,depth[j])
print("Yes")
for i in range(1,N):
  print(depth[i])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

S = [0 for i in range(N)]
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(d):
    S[d]+=1
ans = 0
for i in range(N):
  if S[i]==0:
    ans+=1
print(ans)

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

S = [0 for i in range(N)]

for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(d):
    S[A[j]-1]+=1
    
ans = 0
for i in range(N):
  if S[i]==0:
    ans+=1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i ,Ai in enumerate(A,1):
  for j ,Aj in enumerate(A[i:],i+1):
    if i+Ai==j-Aj:
      #print(i,j)
      ans+=1
print(ans)

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

ans = 0

R = []
for i ,Ai in enumerate(A,1):
  R.append(i+Ai)
R.sort()

L = []
for j ,Aj in enumerate(A,1):
  L.append(j-Aj)
L.sort()

for i in range(len(R)):
  r = bisect.bisect_right(L,R[i])
  l = bisect.bisect_left(L,R[i])
  ans+=r-l
 
print(ans)

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

ans = 0

for i ,Ai in enumerate(A,1):
  for j ,Aj in enumerate(A[i:],i+1):
    if i+Ai==j-Aj:
      #print(i,j)
      ans+=1
print(ans)

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

ans = 0

R = []
for i ,Ai in enumerate(A,1):
  R.append(i+Ai)
R.sort()

L = []
for j ,Aj in enumerate(A,1):
  L.append(j-Aj)
L.sort()

for i in range(len(R)):
  r = bisect.bisect_right(L,R[i])
  l = bisect.bisect_left(L,R[i])
  ans+=r-l
 
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = [0 for i in range(int(2*1e5+1))]
ans = 0

for i, x in enumerate(A, 1):
    ans += cnt[max(0,i - x +1)]
    cnt[x + i + 1] += 1

print(ans)


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

ans = 0

R = []
for i ,Ai in enumerate(A,1):
  R.append(i+Ai)
R.sort()

L = []
for j ,Aj in enumerate(A,1):
  L.append(j-Aj)
L.sort()

for i in range(len(R)):
  r = bisect.bisect_right(L,R[i])
  l = bisect.bisect_left(L,R[i])
  ans+=r-l
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
a = list(map(int,input().split()))
a = [(i+1,a[i]) for i in range(N) if a[i]-i<2*1e5]
ans=0
for i in itertools.combinations(a,2):
  if abs(i[0][0]-i[1][0])==i[0][1]+i[1][1]:
    #print(i[0],i[1])
    ans+=1
print(ans)

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

ans = 0

R = []
for i ,Ai in enumerate(A,1):
  R.append(i+Ai)
R.sort()

L = []
for j ,Aj in enumerate(A,1):
  L.append(j-Aj)
L.sort()

for i in range(len(R)):
  r = bisect.bisect_right(L,R[i])
  l = bisect.bisect_left(L,R[i])
  ans+=r-l
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

r= S.count("R")
g = S.count("G")
b= S.count("B")
ans=r*g*b

for j in range(N):
  for k in range(N):
    i=2*j-k
    if 0<=i<j<k<=N-1 and S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
      ans-=1
print(ans)

Fixed submission:
N = int(input())
S = input()

r= S.count("R")
g = S.count("G")
b= S.count("B")
ans=r*g*b

for j in range(N):
  for k in range(N):
    i=2*j-k
    if 0<=i<j<k<=N-1 and S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
      ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import *

getcontext().prec = 50000
a,b,c, = map(int,input().split())
if Decimal(a).sqrt()+Decimal(b).sqrt() <Decimal(c).sqrt():
  print("Yes")
else:
  print("No")


Fixed submission:
from decimal import *

getcontext().prec = 50000
a,b,c, = map(int,input().split())
if a+b+Decimal(4*a*b).sqrt() < c:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())
cnt = 0
h = []
t = []
for i in range(Q):
  s = input().split()
  if s[0] == "1":
    cnt+=1
  elif s[0] == "2":
    if s[1] == "1":
      if cnt%2 == 0:        
        S.insert(0,s[2])
      else:
        S.append(s[2])
    elif s[1] == "2":
      if cnt%2==1:
        S.insert(0,s[2])       
      else:
        S.append(s[2])

if cnt%2 == 1:
  S = list(reversed(S))
  
print("".join(S))
  

Fixed submission:
S = input()
Q = int(input())
b = "" #reversed
a = ""
f = 0
for i in range(Q):
  q = input()
  if q == "1":
    f+=1
  else:
    _,F,C = q.split()
    if (f+int(F))%2==1:
      b+=C
    else:
      a+=C
if f%2==0:
  print(b[::-1]+S+a)
else:
  print(a[::-1]+S[::-1]+b)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, *X = map(int,open(0).read().split())

X = np.array(X)
g0 = sum(X)//len(X)
g1 = sum(X)//len(X)+1

print(min(sum((X-g0)**2),sum((X-g1)**2)))

Fixed submission:
import numpy as np
N, *X = map(int,open(0).read().split())

X = np.array(X)
g0 = sum(X)//len(X)
g1 = sum(X)//len(X)+1

print(min(sum((X-g0)**2),sum((X-g1)**2)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, *X = map(int,open(0).read().split())

X = np.array(X)
g0 = sum(X)//len(X)
g1 = sum(X)//len(X)+1

print(min(sum((X-g0)**2),sum((X-g1)**2)))

Fixed submission:
import numpy as np
N, *X = map(int,open(0).read().split())

X = np.array(X)
g0 = sum(X)//len(X)
g1 = sum(X)//len(X)+1

print(min(sum((X-g0)**2),sum((X-g1)**2)))