Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(N)]

l = []
ans = 0
for s in S:
    st = "".join(sorted(list(s)))
    if st in l:
        ans += l.count(st)
    l.append(st)

print(ans)


Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

t = {}
ans = 0
for s in S:
    st = "".join(sorted(list(s)))
    if st in t.keys():
        t[st] += 1
        ans += t[st]
    else:
        t[st] = 0

print(ans)

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

N = int(input())
S = [input() for _ in range(N)]

li = []
for s in S:
    st = "".join(sorted(list(s)))
    li.append(st)

di = {}
for i in sorted(li):
    if i in di:
        di[i] = di[i] + 1
    else:
        di[i] = 1


ans = 0
for k, v in di.items():
    if v > 1:
        ans += int(factorial(v) / factorial(2) / factorial(v - 2))

print(ans)



Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

t = {}
ans = 0
for s in S:
    st = "".join(sorted(list(s)))
    if st in t.keys():
        t[st] += 1
        ans += t[st]
    else:
        t[st] = 0

print(ans)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
S = [input() for _ in range(N)]

li = []
for s in S:
    st = "".join(sorted(list(s)))
    li.append(st)

d = {}
for i in sorted(li):
    if i in d:
        d[i] = d[i] + 1
    else:
        d[i] = 1


ans = 0
for k, v in d.items():
    ans += comb(v, 2, exact=True)

print(ans)


Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

t = {}
ans = 0
for s in S:
    st = "".join(sorted(list(s)))
    if st in t.keys():
        t[st] += 1
        ans += t[st]
    else:
        t[st] = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(input()) for _ in range(N)]

for i in range(N):
    print(max(L[:i] + L[i + 1 :]))


Fixed submission:
N = int(input())
L = [int(input()) for _ in range(N)]

Ls = sorted(L, reverse=True)
for i in range(N):
    if L[i] == Ls[0]:
        print(Ls[1])
    else:
        print(Ls[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(input()) for _ in range(N)]

for i in range(N):
    print(max(L[:i] + L[i + 1 :]))


Fixed submission:
N = int(input())
L = [int(input()) for _ in range(N)]

Ls = sorted(L, reverse=True)
for i in range(N):
    if L[i] == Ls[0]:
        print(Ls[1])
    else:
        print(Ls[0])
Buggy python submission (verdict: Runtime Error):
L = [input() for i in range(1, 6)]

li = list(filter(lambda x: x[-1] != "0", L))
last = int(sorted(li, key=lambda x: x[-1])[0])

t = sum(map(int, L)) - last
print(t + (10 - (t % 10)) + last)


Fixed submission:
import math

L = [int(input()) for i in range(5)]

total = 0
sub = 0
for i in L:
    if i % 10 == 0:
        total += i
    else:
        rest = 10 - (i % 10)
        if rest > sub:
            sub = rest
        total += math.ceil(i / 10) * 10

print(total - sub)
Buggy python submission (verdict: Runtime Error):
S = input()
L = ["A", "C", "G", "T"]

arr = []
st = ""

for s in S:
    if st and s not in L:
        arr.append(st)
        st = ""
    if s in L:
        st += s

print(max(map(len, arr)))


Fixed submission:
S = input()
L = ["A", "C", "G", "T"]

arr = []
st = ""

for s in S:
    if st and s not in L:
        st = ""
    if s in L:
        st += s
        arr.append(st)

print(max(map(len, arr)) if arr else 0)
Buggy python submission (verdict: Runtime Error):
S = str(input())
if S = "ABC":
  print("ARC")
else:
  print("ABC")

Fixed submission:
S = str(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy python submission (verdict: Runtime Error):
if S = "ARC":
  print("ABC")
else:
  prnit("ABC")

Fixed submission:
S = str(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy python submission (verdict: Runtime Error):
S = input()
if S = "ABC":
  print("ARC")
else:
  print("ABC")

Fixed submission:
S = str(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy python submission (verdict: Runtime Error):
if S = "ABC"
print("ARC")
else
print("ABC")

Fixed submission:
S = str(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().split())

if S > W:
    print('safe')
if S < W:
    print('unsafe')

Fixed submission:
s, w = map(int, input().split())
if s > w:
    print("safe")
else:
    print("unsafe")
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = []

for i in range(N):
    s.add(input())
    
print(len(s))

Fixed submission:
N = int(input())
s = set()

for i in range(N):
    s.add(input())
    
print(len(s))
Buggy python submission (verdict: Runtime Error):
N, M = [map(int, input(.split()))]

works = [map(int, input().split())]

ans = N

for i in range(M):
    ans -= works[i]

if ans < 0:
    print('-1')
else:
    print(ans)

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

if N >= sum(works):
  print(N - sum(works))
else:
  print("-1")
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N[0] == '7' or N[1] == '7' or N[2] == '7':
    print("Yes")
else:
    print("No")

Fixed submission:
x = input()
if x.count("7"):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

s = N % K

print(min(abs(s), abs(K-s))

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

s = N % K

print(min(s, K-s))
Buggy python submission (verdict: Runtime Error):
x = int(input())

num_500 = x / 500

amari = x - num_500

num_5 = int(amari / 5)

print(1000 * num_500 + 5 * num_5)

Fixed submission:
N = input()
if(N[2] == N[3] and N[4] == N[5]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

ans = n // (a + b)
ans *= a

if n % (a + b) != 0:
    ans += min(a, n % (a + b))

print(ans)

Fixed submission:
s = input()

if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

flag = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            pass
        else:
            flag = 1
            break
        
if flag = 0:
    print("APPROVED")
else:
    print("DENIED")

Fixed submission:
a = set(map(int, input().split()))
if len(a) == 2:
  print("Yes")
else:
  print("No")

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

flag = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            pass
        else:
            flag = 1
            break
        
if flag = 0:
    print("PASS")
else:
    print("DENIED")

Fixed submission:
a = set(map(int, input().split()))
if len(a) == 2:
  print("Yes")
else:
  print("No")

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

flag = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            pass
        else:
            flag = 1
            break
        
 if flag = 0:
    print("PASS")
 else:
    print("DENIED")

Fixed submission:
a = set(map(int, input().split()))
if len(a) == 2:
  print("Yes")
else:
  print("No")

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

flag = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or if A[i] % 5 == 0:
            pass
        else:
            flag = 1
            break
        
if flag = 0:
    print("PASS")
else:
    print("DENIED")

Fixed submission:
a = set(map(int, input().split()))
if len(a) == 2:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

if A == B == C:
    print(No)
    
else:
    print(Yes)

Fixed submission:
a = set(map(int, input().split()))
if len(a) == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

flag = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or if A[i] % 5 == 0:
            pass
        else:
            flag = 1
            break
        
 if flag = 0:
    print("PASS")
 else:
    print("DENIED")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
flag = 0
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 == 0 or A[i] % 5 == 0:
      pass
    else:
      flag = 1
      break
if flag == 0:
  print("APPROVED")
else:
  print("DENIED")

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

flag = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or if A[i] % 5 == 0:
            pass
        else:
            flag = 1
            break
    if flag = 0:
        print("PASS")
    else:
        print("DENIED")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
flag = 0
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 == 0 or A[i] % 5 == 0:
      pass
    else:
      flag = 1
      break
if flag == 0:
  print("APPROVED")
else:
  print("DENIED")
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
a = []

for i in range(N):
    a.append(str(input()))
a = collections.Counter(a)
b = max(a.values())

max_k_list = [kv[0] for kv in a.items() if kv[1] == b]
max_k_list = sorted(max_k_list)

for i in max_k_list:
print(i)   

Fixed submission:
import collections

n = int(input())
s = []
for i in range(n):
    s.append(input())

c = collections.Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
ans = []
for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])
ans.sort()
for t in ans:
    print(t)
Buggy python submission (verdict: Runtime Error):
N = int(input())
list=[]
for i in range(N):
    list.append(int(input()))

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] > 0 and list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))

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

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))

Buggy python submission (verdict: Runtime Error):
N = int(input())
list=[]
for i in range(N):
    list.append(int(input()))

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))

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

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))

Buggy python submission (verdict: Runtime Error):
N = int(input())
list=[]
for i in range(N):
    list.append(int(input()))

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))

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

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))
Buggy python submission (verdict: Runtime Error):
if __name__ = "__main__":
  S = input() # sを取得し、strに値を入れる
  if S == "ABC":
    print("ARC")
  elif S == "ARC":
    print("ABC")
  

Fixed submission:
if __name__ == "__main__":
  S = input() # sを取得し、strに値を入れる
  if S == "ABC":
    print("ARC")
  elif S == "ARC":
    print("ABC")

Buggy python submission (verdict: Runtime Error):
if __name__ = "__main__":
  S = input() # sを取得し、strに値を入れる
  if S == "ABC":
    print "ARC"
  elif S == "ARC":
    print "ABC"
  

Fixed submission:
if __name__ == "__main__":
  S = input() # sを取得し、strに値を入れる
  if S == "ABC":
    print("ARC")
  elif S == "ARC":
    print("ABC")

Buggy python submission (verdict: Runtime Error):
if

Fixed submission:
if __name__ == "__main__":
  S = input() # sを取得し、strに値を入れる
  if S == "ABC":
    print("ARC")
  elif S == "ARC":
    print("ABC")
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0.0] * N
  for i in range(len(list_str_H_all)):
    H[i] = float(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    
  output = 0
  for i in rabge(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)


Fixed submission:
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0] * N
  for i in range(len(list_str_H_all)):
    H[i] = int(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    else:
      is_good_vp[A-1] = False
      is_good_vp[B-1] = False
    
  output = 0
  for i in range(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)

Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0.0] * N
  for i in range(len(list_str_H_all)):
    H[i] = float(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    
  output = 0
  for i in N:
    if is_good_vp[i]:
      output += 1
      
  print(output)

Fixed submission:
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0] * N
  for i in range(len(list_str_H_all)):
    H[i] = int(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    else:
      is_good_vp[A-1] = False
      is_good_vp[B-1] = False
    
  output = 0
  for i in range(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)
Buggy python submission (verdict: Runtime Error):
def get_answer():
  x = int(input())
  
  is_get = False
  for a in range(1000000000):
    if is_get:
      break
    for b in range(-1*a, a, 1):
      if x == a**5 - b**5:
        is_get = True
        break
        
  print(f"{a-1} {b}")

if __name__ = "__main__":
  get_answer()

Fixed submission:
def get_answer():
  x = int(input())
  
  is_get = False
  for a in range(1000000000):
    if is_get:
      break
    for b in range(-1*a, a, 1):
      if x == a**5 - b**5:
        is_get = True
        break
        
  print(f"{a-1} {b}")

if __name__ == "__main__":
  get_answer()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
for i in range(1,n+1):
    print(a.index(i)+1)
 

Fixed submission:
from operator import itemgetter
n=int(input())
a=list(map(int,input().split()))

print(*[t[0] +1 for t in sorted(enumerate(a),key=itemgetter(1))])

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


print(" ".join([str(a.index(i)+1) for i in range(1,n+1)]))


Fixed submission:
from operator import itemgetter
n=int(input())
a=list(map(int,input().split()))

print(*[t[0] +1 for t in sorted(enumerate(a),key=itemgetter(1))])

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


L=[str(a.index(i)+1) for i in range(1,n+1)]
print(" ".join(L))


Fixed submission:
from operator import itemgetter
n=int(input())
a=list(map(int,input().split()))

print(*[t[0] +1 for t in sorted(enumerate(a),key=itemgetter(1))])

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


L=[str(a.index(i)+1) for i in range(1,n+1)]
L=" ".join(L)
print(L)

Fixed submission:
from operator import itemgetter
n=int(input())
a=list(map(int,input().split()))

print(*[t[0] +1 for t in sorted(enumerate(a),key=itemgetter(1))])
Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split()) 

for _ in range(q):
    score[int(input())-1] +=1

for j in range(n):
    if score[j-1] > 0:
        print('Yes')
    else:
        print('No')
        
        

Fixed submission:
n,k,q=map(int,input().split()) 
score=[k-q]*(n)


for a in range(q):
    score[int(input())-1] +=1

for j in range(n):
    if score[j] > 0:
        print('Yes')
    else:
        print('No')

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

for a in range(q):
    score[int(input())-1] +=1

for j in range(n):
    if score[j-1] > 0:
        print('Yes')
    else:
        print('No')
        
        

Fixed submission:
n,k,q=map(int,input().split()) 
score=[k-q]*(n)


for a in range(q):
    score[int(input())-1] +=1

for j in range(n):
    if score[j] > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split()) 
print(score)

for a in range(q):
    score[int(input())-1] +=1

for j in range(n):
    if score[j-1] > 0:
        print('Yes')
    else:
        print('No')
        
        

Fixed submission:
n,k,q=map(int,input().split()) 
score=[k-q]*(n)


for a in range(q):
    score[int(input())-1] +=1

for j in range(n):
    if score[j] > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
a = input()
if(a == "ARC"):
  print("ABC")
elsif(a == "ABC"):
  print("ARC")


Fixed submission:
a = input()
if a == "ARC":
  print("ABC")
elif a == "ABC":
  print("ARC")

Buggy python submission (verdict: Runtime Error):
char = input()
if(char == "ARC"):
  print("ABC")
elsif(char == "ABC"):
  print("ARC")

Fixed submission:
a = input()
if a == "ARC":
  print("ABC")
elif a == "ABC":
  print("ARC")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(" ")))

b = [j - i for i, j in enumerate(a, start=1)]
c = [-j - i for i, j in enumerate(a, start=1)]
result = sum([c.count(i) for i in b])
print(result)


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

b = [j - i for i, j in enumerate(a, start=1)]
# c = [-j - i for i, j in enumerate(a, start=1)]
count = {}
for i, j in enumerate(a, start=1):
    num = -i-j
    if num not in count:
        count[num] = 0
    count[num] += 1
result = sum([count.get(i, 0) for i in b])
print(result)
Buggy python submission (verdict: Runtime Error):
S=input()
if S==ABC:
  print("ARC")
else:
  print("ABC")

Fixed submission:
S=input()
if S==("ABC"):
  print("ARC")
elif S==("ARC"):
  print("ABC")

Buggy python submission (verdict: Runtime Error):
s=input()
if s==ABC:
  print("ARC")
if s==ARC:
  print("ABC")

Fixed submission:
S=input()
if S==("ABC"):
  print("ARC")
elif S==("ARC"):
  print("ABC")
Buggy python submission (verdict: Runtime Error):
s=input()
if s==AAA,s==BBB:
  print("No")
else:
  print("Yes")

Fixed submission:
s=input()
if s=="AAA"or s=="BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N=input()
if N%2==0:
  print("N/2")
else:
  print("N/2+1")

Fixed submission:
n = int(input())
if n % 2:
    print(n // 2 + 1)
else:
    print(n // 2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split()):
  if n==m
  print(yes)
  if n!=m
  print(no)

Fixed submission:
N,M=map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split()):
  if n==m
  print(yes)
  else n!=m
  print(no)
  

Fixed submission:
N,M=map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b%2=0:
  print("Even")
else:
  print("Odd")


Fixed submission:
a,b=map(int,input().split())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))
longs2 = [j - longs[j] for j in range(len(longs))]

sum = 0
for i in range(person):
    sum += longs2.count(longs[i] + i)

print(sum)

Fixed submission:
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

longsi_dic = {}
for i in range(len(longs)):
    if str(i + longs[i]) not in longsi_dic:
        longsi_dic[str(i + longs[i])] = 0
    longsi_dic[str(i + longs[i])] += 1

longsj_dic = {}
for j in range(len(longs)):
    if str(j - longs[j]) not in longsj_dic:
        longsj_dic[str(j - longs[j])] = 0
    longsj_dic[str(j - longs[j])] += 1

sum = 0
for val, sumi in longsi_dic.items():
    if val not in longsj_dic:
        continue
    sum += int(sumi) * int(longsj_dic[val])

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

sum = 0
for i in range(person):
    if i + longs[i] < person:
        for j in range(i + longs[i], person):
            if (j - i) == longs[i] + longs[j]:
                sum += 1
print(sum)

Fixed submission:
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

longsi_dic = {}
for i in range(len(longs)):
    if str(i + longs[i]) not in longsi_dic:
        longsi_dic[str(i + longs[i])] = 0
    longsi_dic[str(i + longs[i])] += 1

longsj_dic = {}
for j in range(len(longs)):
    if str(j - longs[j]) not in longsj_dic:
        longsj_dic[str(j - longs[j])] = 0
    longsj_dic[str(j - longs[j])] += 1

sum = 0
for val, sumi in longsi_dic.items():
    if val not in longsj_dic:
        continue
    sum += int(sumi) * int(longsj_dic[val])

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

sum = 0
for i in range(person):
    for j in range(i, person):
        if (j - i) == longs[i] + longs[j]:
            sum += 1
print(sum)

Fixed submission:
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

longsi_dic = {}
for i in range(len(longs)):
    if str(i + longs[i]) not in longsi_dic:
        longsi_dic[str(i + longs[i])] = 0
    longsi_dic[str(i + longs[i])] += 1

longsj_dic = {}
for j in range(len(longs)):
    if str(j - longs[j]) not in longsj_dic:
        longsj_dic[str(j - longs[j])] = 0
    longsj_dic[str(j - longs[j])] += 1

sum = 0
for val, sumi in longsi_dic.items():
    if val not in longsj_dic:
        continue
    sum += int(sumi) * int(longsj_dic[val])

print(sum)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split(" "))

max_score = 0
y = b // a

for x in range(max(y - 1000000, 1) , min(y + 2000000, n+1)):
    score = a * x // b - a * ( x // b )
    if score > max_score:
        max_score = score
print(max_score)


Fixed submission:
x = int(input())
p, q = map(int, input().split())

ok = 0
for i in range(p, q+1):
    if i % x == 0:
        ok += 1
        break
if ok == 1:
    print("OK")
else:
    print("NG")