Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
t = []*(N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key = lambda x: x[0])

total = 0
i = 0

while True:
    total += AB[i][1]
    if total < m:
        i += 1
    else:
        break

ans = 0
for j in range(i):
    ans += AB[j][0]*AB[j][1]
ans += (m - sum(AB[p][1] for p in range(0,i))) * AB[i][0]

Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key = lambda x: x[0])

total = 0
i = 0

while True:
    total += AB[i][1]
    if total < M:
        i += 1
    else:
        break

ans = 0
for j in range(i):
    ans += AB[j][0]*AB[j][1]
ans += (M - sum(AB[p][1] for p in range(0,i))) * AB[i][0]
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

List = [x for x in range(min(A,B),1,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

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

List = [x for x in range(min(A,B),0,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

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

List = [x for x in range(max(A,B),1,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

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

List = [x for x in range(min(A,B),0,-1) if A%x ==0 and B%x ==0]
print(List[K-1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

x_diff = [x[i+1] - x[i] for i in range(len(x)-1)]
for _ in range(n-1):
    del x_diff[x_diff.index(max(x_diff))]
    
print(sum(x_diff))

Fixed submission:
N, M, *X = map(int, open(0).read().split())
X.sort()

y = sorted([X[i + 1] - X[i] for i in range(len(X) - 1)], reverse=True)
print(sum(y[N - 1:]))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

e = Counter(v[::2]).most_common(2)
o = Counter(v[1::2]).most_common(2)

if e[0][0] != o[0][0]:
    print(n - (e[0][1] + o[0][1]))
else:
    print(n - max(e[0][1]+o[1][1],e[1][1]+o[0][1]))

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

# Return the list of 2 most common numbers and each appearance
e = Counter(v[::2]);e[0] = 0
o = Counter(v[1::2]);o[0] = 0

e1,e2 = e.most_common(2)
o1,o2 = o.most_common(2)

if e1[0] != o1[0]:
    print(n - (e1[1] + o1[1]))
else:
    print(n - max(e1[1]+o2[1],e2[1]+o1[1]))
Buggy python submission (verdict: Runtime Error):
print("ACL"*int(input))

Fixed submission:
print("ACL"*int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())

Line = [int(s) for s in input().split()]
c = collections.Counter(Line)

# print(c)

Q = int(input())


for _ in range(Q):
    Line = [int(s) for s in input().split()]
    try:
        c[Line[1]] += c[Line[0]]
        c.pop(Line[0])
    except:
        pass
        
        # print('Error')
    # print(c)
    
    s=0
    for i in c:
        # print(i)
        s += i * c[i]
    print(s)    


Fixed submission:
import collections
N = int(input())

Line = [int(s) for s in input().split()]
c = collections.Counter(Line)

# print(c)
v = 0

for i in c:
    # print(i)
    v += i * c[i]
# print(v)    

Q = int(input())


for _ in range(Q):
    Line = [int(s) for s in input().split()]
    try:
        c[Line[1]] += c[Line[0]]
        
        # print(c[Line[1]],c[Line[0]])
        v += c[Line[0]] * (Line[1] - Line[0])
        c.pop(Line[0])
        # v += c[Line[0]] * (C[Line[1]-C[Line[0]]])
    except:
        pass
        
        # print('Error')
    # print(c)

    # s=0
    # for i in c:
    #     # print(i)
    #     s += i * c[i]
    print(v)
Buggy python submission (verdict: Runtime Error):
Line = [int(s) for s in input().split()]

print(Liine[0]*Line[1])

Fixed submission:
Line = [int(s) for s in input().split()]

print(Line[0]*Line[1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

li = [int(s) for s in input().split()]

import functools
import operator

result = functools.reduce(operator.mul, li)

if result > 10**18:
    print(-1)
else:
    print(result)

Fixed submission:
import sys

N = int(input())

Line = [int(s) for s in input().split()]
Line.sort()

ans = 1

for i in Line:
    ans = ans*i
    if ans > 10**18:
        print("-1")
        exit()
    elif ans == 0:
        print("0")
        exit()

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

Line = [int(s) for s in input().split()]

A,B,H,M = Line[0],Line[1],Line[2],Line[3]

# print(A,B,H,M)

kakudo = abs(  H/12*360 + M/12/60*360 - M/60*360 )

if kakudo > 180 :
    kakudo = 360 - kakudo

# print(kakudo)

ans = math.sqrt(A**2 + B**2 - 2*A*B*round(math.cos(round(math.radians(kakudo),100),100))

print(ans)

Fixed submission:
import math

Line = [int(s) for s in input().split()]

A,B,H,M = Line[0],Line[1],Line[2],Line[3]

# print(A,B,H,M)

kakudo = abs(  H/12*360 + M/12/60*360 - M/60*360 )

if kakudo > 180 :
    kakudo = 360 - kakudo

# print(kakudo)

ans = math.sqrt(A**2 + B**2 - 2*A*B*round(math.cos(math.radians(kakudo)),100))

print(ans)
Buggy python submission (verdict: Runtime Error):
for x in itertools.combinations(X_list, 2):
  if x[0]-x[1] == ans:
      a =abs(x[0]**(1/5))
      b =abs(x[1]**(1/5))
      if x[0] < 0:
          a = a*(-1)
      if x[1] < 0:
          b = b*(-1)
    #   print(x[0],x[1])
      print(int(a),int(b))
      sys.exit()
  if x[1]-x[0] == ans:
      a = abs(x[1]**(1/5))
      b = abs(x[0]**(1/5))
      if x[1] < 0:
          a = a*(-1)
      if x[0] < 0:
          b = b*(-1)
    #   print(x[1],x[0])
      print(int(a),int(b))
      sys.exit()

Fixed submission:
import itertools
import math
import sys

X = list(range(-200,201))

X_list = list(map(lambda x: x ** 5, X))

# print(X_list)

ans = int(input())

# print(X_list[0])
# print(math.sqrt(X_list[200]))
for x in itertools.combinations(X_list, 2):
  if x[0]-x[1] == ans:
      a =abs(x[0]**(1/5))
      b =abs(x[1]**(1/5))
      if x[0] < 0:
          a = a*(-1)
      if x[1] < 0:
          b = b*(-1)
    #   print(x[0],x[1])
      print(int(a),int(b))
      sys.exit()
  if x[1]-x[0] == ans:
      a = abs(x[1]**(1/5))
      b = abs(x[0]**(1/5))
      if x[1] < 0:
          a = a*(-1)
      if x[0] < 0:
          b = b*(-1)
    #   print(x[1],x[0])
      print(int(a),int(b))
      sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):

import collections

N = int(input())

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

for i in range(1,N+1):
    print(Line.count(i))

Fixed submission:
import collections

N = int(input())

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

c = collections.Counter(Line)

for i in range(1,N+1):
    print(c[i])
Buggy python submission (verdict: Runtime Error):
S =input()

input_line = int(input())

flag0 = ""
flag1 = ""
flag = 0


for i in range(input_line):
    action = list(input())
    # print(flag0,flag1)
    # print(action)
    if action[0]=="1":
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        # print("check")
        if action[2] == "2":
            
            if flag == 0:
                flag0 = flag0 + action[4]
            elif flag ==1:
                flag1 = action[4] + flag1
        else:
            if flag == 0:
                flag0 = action[4] + flag0
            
            elif flag == 1:
                flag1 += action[4]
                
S = flag0 + S + flag1
if flag == 1:
    S = S[::-1]
    
print(S)

Fixed submission:
Line = set(list(input()))

if len(Line) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S =input()

input_line = int(input())

for i in range(input_line):
    action = list(input())
    # print(action)
    if action[0]=="1":
        S = S[::-1]
    else:
        if action[2] == "2":
            S += action[4]
        else:
            S = action[4]+S
print(S)

Fixed submission:
S =input()

input_line = int(input())

flag0 = ""
flag1 = ""
flag = 0


for i in range(input_line):
    action = list(input())
    # print(flag0,flag1)
    # print(action)
    if action[0]=="1":
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        # print("check")
        if action[2] == "2":
            
            if flag == 0:
                flag1 = flag1 + action[4]
            elif flag ==1:
                flag0 = action[4] + flag0
        else:
            if flag == 0:
                flag0 = action[4] + flag0
            
            elif flag == 1:
                flag1 += action[4]
                
S = flag0 + S + flag1
if flag == 1:
    S = S[::-1]
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S =input()

input_line = int(input())

# alpha = alpha[::-1]

for i in range(input_line):
    action = list(input())
    # print(action)
    if action[0]=="1":
        S = S[::-1]
    else:
        if action[2] == "2":
            S += action[4]
        elif action[2] == "1":
            S = action[4]+S

print(S)
    

Fixed submission:
S =input()

input_line = int(input())

flag0 = ""
flag1 = ""
flag = 0


for i in range(input_line):
    action = list(input())
    # print(flag0,flag1)
    # print(action)
    if action[0]=="1":
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        # print("check")
        if action[2] == "2":
            
            if flag == 0:
                flag1 = flag1 + action[4]
            elif flag ==1:
                flag0 = action[4] + flag0
        else:
            if flag == 0:
                flag0 = action[4] + flag0
            
            elif flag == 1:
                flag1 += action[4]
                
S = flag0 + S + flag1
if flag == 1:
    S = S[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
#mondaisuu
N = Line[0]
#teisyutu
M = Line[1]

AC_Lists = [""]*N
# print(AC_Lists)

for i in range(M):
    input_line = input()
    Line = input_line.split()
    print(Line)
    AC_Lists[int(Line[0])-1] += Line[1][0]
    print(AC_Lists)

AC_count = 0
WA_count = 0

for s in AC_Lists:
    # print(s)
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        print(my_str)
        # print(len(my_str[0]))
        WA_count += len(my_str[0])
    else:
        # print(len(s))
        WA_count += len(s)
# print(AC_Lists)

print(AC_count,WA_count)


Fixed submission:
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
#mondaisuu
N = Line[0]
#teisyutu
M = Line[1]
 
AC_Lists = [""]*N
# print(AC_Lists)
 
for i in range(M):
    input_line = input()
    Line = input_line.split()
    # print(AC_Lists[int(Line[0])-1])
    AC_Lists[int(Line[0])-1] += Line[1][0]
 
AC_count = 0
WA_count = 0
 
for s in AC_Lists:
    # print(s)
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        # print(my_str)
        # print(len(my_str[0]))
        WA_count += len(my_str[0])
    # else:
    #     print(len(s))
    #     WA_count += len(s)
# print(AC_Lists)
 
print(AC_count,WA_count)

Buggy python submission (verdict: Runtime Error):
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
#mondaisuu
N = Line[0]
#teisyutu
M = Line[1]

AC_Lists = [""]*N
# print(AC_Lists)

for i in range(M):
    input_line = input()
    Line = input_line.split()
    print(Line)
    AC_Lists[int(Line[0])-1] += Line[1][0]
    print(AC_Lists)

AC_count = 0
WA_count = 0

for s in AC_Lists:
    # print(s)
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        print(my_str)
        # print(len(my_str[0]))
        WA_count += len(my_str[0])
    else:
        # print(len(s))
        WA_count += len(s)
# print(AC_Lists)

print(AC_count,WA_count)


Fixed submission:
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
#mondaisuu
N = Line[0]
#teisyutu
M = Line[1]
 
AC_Lists = [""]*N
# print(AC_Lists)
 
for i in range(M):
    input_line = input()
    Line = input_line.split()
    # print(AC_Lists[int(Line[0])-1])
    AC_Lists[int(Line[0])-1] += Line[1][0]
 
AC_count = 0
WA_count = 0
 
for s in AC_Lists:
    # print(s)
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        # print(my_str)
        # print(len(my_str[0]))
        WA_count += len(my_str[0])
    # else:
    #     print(len(s))
    #     WA_count += len(s)
# print(AC_Lists)
 
print(AC_count,WA_count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[int(k) for k in input().split()]
lnew={}
for i in l:
  if i in lnew:
    lnew[i]+=1
  else:lnew[i]=1

k=int(input())
for i in range(k):
  a,b=input().split()
  a=int(a)
  b=int(b)
  if a in lnew:
    c=0
    if b in lnew:
      c=lnew[b]
    lnew[b]=c+lnew[a]
  lnew.pop(a,None)
  Sum=0
  for num,val in lnew.items():
    Sum+=num*val
  print(Sum)

Fixed submission:
n=int(input())
l=[int(k) for k in input().split()]
lnew={}
for i in l:
  if i in lnew:
    lnew[i]+=1
  else:lnew[i]=1
Sum=0
for num,val in lnew.items():
    Sum+=num*val
k=int(input())
for i in range(k):
  a,b=input().split()
  a=int(a)
  b=int(b)
  if a in lnew:
    Sum-=lnew[a]*a
    c=0
    if b in lnew:
      c=lnew[b]
      Sum-=lnew[b]*b
    lnew[b]=c+lnew[a]
    Sum+=lnew[b]*b
  lnew.pop(a,None)
  
  print(Sum)
Buggy python submission (verdict: Runtime Error):
n, k= input().split()
l = list(map(int,input().split()))
checkNum=[i for i in range(11)]

def find(x):
    while x!=checkNum[x]:
        checkNum[x]=checkNum[checkNum[x]]
        x=checkNum[x]
    return x

for i in l:
    checkNum[find(i)]=checkNum[find(i+1)]

fin=""
for i in range(len(n)):
    first=int(n[i])
    k=find(first)
    if k==first:
        fin+=str(k)
    else:
        if k!=10:
            fin+=str(k)
            i+=1
        else:fin+=str(find(1))
        fin+=str(find(0))*(len(n)-i)
        break

p

Fixed submission:
n, k= input().split()
l = list(map(int,input().split()))
checkNum=[i for i in range(11)]

def find(x):
    while x!=checkNum[x]:
        checkNum[x]=checkNum[checkNum[x]]
        x=checkNum[x]
    return x

for i in l:
    checkNum[find(i)]=checkNum[find(i+1)]

fin=""
for i in range(len(n)):
    first=int(n[i])
    k=find(first)
    if k==first:
        fin+=str(k)
    else:
        if k!=10:
            fin=str(k)+str(find(0))*(len(n)-i-1)
        else:
            fin=str(find(1))+str(find(0))*len(n)
        break

print(fin)

Buggy python submission (verdict: Runtime Error):
n, k= map(int,input().split())
l = list(map(int,input().split()))
checkNum=[i for i in range(11)]
for i in l:
    checkNum[find(i)]=checkNum[find(i+1)]
def find(x):
    while x!=checkNum[x]:
        checkNum[x]=checkNum[checkNum[x]]
        x=checkNum[x]
    return x
fin=""
remain=0

if n==0:
    fin=str(find(0))

while n>0 or remain>0:
    last=n%10
    k=find(last+remain)
    remain=0
    if k!=10:
        fin=str(k)+fin
    else:
        remain+=1
        fin=str(find(0))+fin
    n//=10
print(fin)
        


Fixed submission:
n, k= input().split()
l = list(map(int,input().split()))
checkNum=[i for i in range(11)]

def find(x):
    while x!=checkNum[x]:
        checkNum[x]=checkNum[checkNum[x]]
        x=checkNum[x]
    return x

for i in l:
    checkNum[find(i)]=checkNum[find(i+1)]

fin=""
for i in range(len(n)):
    first=int(n[i])
    k=find(first)
    if k==first:
        fin+=str(k)
    else:
        if k!=10:
            fin=str(k)+str(find(0))*(len(n)-i-1)
        else:
            fin=str(find(1))+str(find(0))*len(n)
        break

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

mod = 10**9 + 7

sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += A[i] * A[j] % mod

print(sum % mod)

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

sum_A = sum(A)

mod = 10**9 + 7

sum_mod = 0

sum_minus = 0
for a in A:
    sum_mod += a * (sum_A - a - sum_minus) % mod
    sum_minus += a

print(sum_mod % mod)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join(
            '{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())

uf = UnionFind(N)

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1, B-1)

max_num = 0
for val in uf.all_group_members().values():
    max_num = max(max_num, len(val))
print(max_num)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join(
            '{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())

uf = UnionFind(N)

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1, B-1)

# print(uf.roots())

max_num = 0
for root in uf.roots():
    max_num = max(max_num, uf.size(root))
print(max_num)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = [mod]

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.append(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)
  
 

Fixed submission:
K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = {mod}

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.add(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = [mod]

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.append(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)
  
 

Fixed submission:
K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = {mod}

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.add(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

hyoten = 1

for idx, a in enumerate(A):
    if idx < K:
        hyoten *= a
    else:
        next_hyoten = hyoten * a / A[idx - K]
        if next_hyoten <= hyoten:
            print('No')
        else:
            print('Yes')
        hyoten = next_hyoten

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

for idx, a in enumerate(A):
    if idx < K:
        continue
    else:
        if a <= A[idx - K]:
            print('No')
        else:
            print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
import collections

count = 0

count_dict = collections.defaultdict(int)

for idx, a in enumerate(A):
    if idx+a+1 in count_dict:
        count += count_dict[idx+a+1]
        continue
    for i in range(idx+a+1, N):
        if a + A[i] == i - idx:
            count += 1
            count_dict[idx+a+1] += 1

print(count)

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

count = 0

count_dict = collections.defaultdict(int)

for idx, a in enumerate(A):
    count_dict[idx-a] += 1

for idx, a in enumerate(A):
    if idx+a in count_dict:
        count += count_dict[idx+a]
        continue
    # for i in range(idx+a+1, N):
    #     if a + A[i] == i - idx:
    #         count += 1
    #         count_dict[idx+a+1] += 1
# print(count_dict)

print(count)

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

count = 0

for idx, a in enumerate(A):
    for i in range(idx+a+1, N):
        if a + A[i] == i - idx:
            count += 1

print(count)

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

count = 0

count_dict = collections.defaultdict(int)

for idx, a in enumerate(A):
    count_dict[idx-a] += 1

for idx, a in enumerate(A):
    if idx+a in count_dict:
        count += count_dict[idx+a]
        continue
    # for i in range(idx+a+1, N):
    #     if a + A[i] == i - idx:
    #         count += 1
    #         count_dict[idx+a+1] += 1
# print(count_dict)

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
list = {input() for _ in range(N)}
print(len(list))

Fixed submission:
A, B, C, D = map(int, input().split())

# while A > 0 and B > 0:
#     print(A, C)
#     C -= B
#     if B <= 0:
#         print("Yes")
#         break
#     A -= D
#     if A <= 0:
#         print("No")
#         break

import math
# print(math.ceil(A / D), math.ceil(C / B))
if math.ceil(A / D) >= math.ceil(C / B):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

blue = "b"*A
red = "r"*B
br = blue + red

# print(blue, red, br)

S = br*N
import collections

print(collections.Counter(S[:N])["b"])

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


if N % (A+B) >= A:
    print((N // (A+B))*A + A)
else:
    print((N // (A+B))*A + N % (A+B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
if S[N/2] == S[N/2:]:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
S = input()
if S[:int(N / 2)] == S[int(N / 2):]:
    print("Yes")
else:
    print("No")