Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res

n, m = map(int, input().split())
ans = 0
nums = divisors(m)
nums.sort()
num = nums.pop(0)
while num * n <= m:
    if (m - num * n) % num == 0:
        ans = num
    num = nums.pop(0)
print(ans)

Fixed submission:
def divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res

n, m = map(int, input().split())
ans = 0
nums = divisors(m)
nums.sort()
num = nums.pop(0)
while num * n <= m:
    if (m - num * n) % num == 0:
        ans = num
    if nums == []:
        break
    num = nums.pop(0)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
num = m // n
ans = 0
for i in range(1, num + 1):
    if (m - i * n) % i == 0:
        ans = i
print(ans)

Fixed submission:
def divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res

n, m = map(int, input().split())
ans = 0
nums = divisors(m)
nums.sort()
num = nums.pop(0)
while num * n <= m:
    if (m - num * n) % num == 0:
        ans = num
    if nums == []:
        break
    num = nums.pop(0)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
for i in range(0, N - 1):
    diff.append(x[i + 1] - x[i])

if diff:
    ans = gcd_list(diff)
else:
    ans = x[0] - 1

print(ans)


Fixed submission:
from fractions import gcd
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
for i in range(N):
    diff.append(abs(x[i] - X))

while len(diff) > 1:
    a, b = diff.pop(), diff.pop()
    diff.append(gcd(a, b))

print(diff[0])
Buggy python submission (verdict: Runtime Error):
s = list(map(int, list(str(input()))))
k = int(input())

i = 0
while i <= k:
    ans = s[i]
    if s[i] != 1:
        break
    i += 1
print(ans)

Fixed submission:
s = list(map(int, list(str(input()))))
k = int(input())

i = 0
while i + 1 <= k:
    ans = s[i]
    if s[i] != 1:
        break
    i += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = list(map(int, list(str(input()))))
k = int(input())

if k == 1:
    ans = s[0]
else:
    if s[0] != 1:
        ans = s[0]
    else:
        i = 0
        while i < len(s):
            i += 1
            ans = s[i]
            if s[i] != 1:
                break
print(ans)

Fixed submission:
s = list(map(int, list(str(input()))))
k = int(input())

i = 0
while i + 1 <= k:
    ans = s[i]
    if s[i] != 1:
        break
    i += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = list(map(int, list(str(input()))))
k = int(input())

if k == 1:
    ans = s[0]
if s[0] != 1:
    ans = s[0]
else:
    i = 0
    while i < k:
        i += 1
        ans = s[i]
        if s[i] != 1:
            break
print(ans)

Fixed submission:
s = list(map(int, list(str(input()))))
k = int(input())

i = 0
while i + 1 <= k:
    ans = s[i]
    if s[i] != 1:
        break
    i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()

n = numbers[-1]
if n % 2 == 0:
    rl = n // 2
    rr = n // 2
else:
    rl = n // 2
    rr = n // 2 + 1

while not rr in numbers and not rl in numbers:
    rl -= 1
    rr += 1
if rl in numbers:
    ans = [n, rl]
else:
    ans = [n, rr]

print(*ans)


Fixed submission:
n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()

ai = numbers[-1]
r = ai / 2

for i in range(n - 1):
    if numbers[i] == r:
        ans = [ai, int(r)]
        break
    if numbers[i] > r:
        if numbers[i] - r < r - numbers[i - 1]:
            ans = [ai, numbers[i]]
        break
    ans = [ai, numbers[i]]

print(*ans)

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

max_comb = 0
ai = numbers[-1]
ans = [ai, 0]

numerator = 1
denominator = 1

for i in range(1, ai):
    denominator *= i
    numerator *= ai - i + 1
    comb = numerator // denominator
    if i in numbers and comb > max_comb:
        max_comb = comb
        ans = [ai, i]
print(*ans)

Fixed submission:
n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()

ai = numbers[-1]
r = ai / 2

for i in range(n - 1):
    if numbers[i] == r:
        ans = [ai, int(r)]
        break
    if numbers[i] > r:
        if numbers[i] - r < r - numbers[i - 1]:
            ans = [ai, numbers[i]]
        break
    ans = [ai, numbers[i]]

print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
f = [list(map(int, input().split())) for _ in range(N)]
p = [list(map(int, input().split())) for _ in range(N)]

ans = -(10 ** 7)
stk = []

stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        for k in range(N):
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        ans = max(ans, total)
        stk.append(arr)

print(ans)


Fixed submission:
N = int(input())
params = [list(map(int, input().split())) for _ in range(N - 1)]

for i in range(N - 1):
    time = 0
    for j in range(i, N - 1):
        c = params[j][0]
        s = params[j][1]
        f = params[j][2]
        if s > time:
            time += s - time + c
        else:
            time += (s - time) % f + c
    print(time)
    
print(0)
Buggy python submission (verdict: Runtime Error):
A, B, X = map(int, input().split())
ans = 0

if (X - B * 10) // A > pow(10, 9):
  ans = pow(10, 9)  
else:
        for i in range(1, 10):
       	    num = (X - i * B) // A
        if i == 10 and num > pow(10, 9):
            ans = pow(10, 9)
        if pow(10, i) > num >= pow(10, i - 1):
            ans = max(ans, num)
        elif num >= pow(10, i):
            ans = max(ans, pow(10, i) - 1)

print(ans)


Fixed submission:
N = int(input())
f = [list(map(int, input().split())) for _ in range(N)]
p = [list(map(int, input().split())) for _ in range(N)]

ans = []
stk = []

stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        for k in range(N):
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        ans.append(total)
        stk.append(arr)

print(max(ans))
Buggy python submission (verdict: Runtime Error):
import string
s = list(set(list(input())))
s.sort()
comp = string.ascii_lowercase
if len(s) == len(comp):
    ans = 'None'
else:
    for i in range(len(s)):
        if s[i] != comp[i]:
            ans = comp[i]
            break
print(ans)


Fixed submission:
import string
s = set(list(input()))
ans = 'None'
for c in string.ascii_lowercase:
    if not c in s:
        ans = c
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
import string
s = list(set(list(input())))
s.sort()
comp = string.ascii_lowercase
if len(s) == len(comp):
    ans = 'None'
else:
    for i, j in zip(s, string.ascii_lowercase):
        if i != j:
            ans = j
            break
print(ans)


Fixed submission:
import string
s = set(list(input()))
ans = 'None'
for c in string.ascii_lowercase:
    if not c in s:
        ans = c
        break

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

ans = 0
for i in range(1 << n):
    biscuits = 0
    for j in range(n):
        if i >> j & 1:
            biscuits = (biscuits + a[j] % 2) % 2
    if biscuits % 2 == p:
        ans += 1
print(ans)

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

is_odd = False
for ai in a:
    if ai % 2 == 1:
        is_odd = True
        break

if is_odd:
    ans = 2 ** (n - 1)
else:
    if p == 0:
        ans = 2 ** n
    else:
        ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

min = len(colors)
max = min(len(colors) + over_cnt, 8)
print(min, max)


Fixed submission:
N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

print(max(len(colors), 1), len(colors) + over_cnt)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = 1
r = 10 ** 5
for _ in range(m):
    li, ri = map(int, input().split())
    l = max(l, li)
    r = min(r, ri)

print(r - l + 1 if r >= l else 0)


Fixed submission:
n = int(input())
ans = 0
score = []
for _ in range(n):
    score.append(int(input()))

score.sort()
total = sum(score)
if total % 10 == 0:
    for s in score:
        if s % 10 != 0:
            total -= s
            break

print(total if total % 10 != 0 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
nums = []
for _ in range(N):
    a, b = map(int, input().split())
    nums += [a] * b
nums.sort()
print(nums[K - 1])

Fixed submission:
N, K = map(int, input().split())
nums = []
for _ in range(N):
    a, b = map(int, input().split())
    nums.append([a, b])
cnt = 0
nums.sort()
for num in nums:
    cnt += num[1]
    if cnt >= K:
        print(num[0])
        break
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a > b:
    ans = 'GREATER'
elif a < b:
    ans = 'LESS'
else:
    ans = 'EQUAL
print(ans)


Fixed submission:
A = int(input())
B = int(input())

if A > B:
    print('GREATER')
elif A < B:
    print('LESS')
else:
    print('EQUAL')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

ss = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

INF = 10 ** 8 * 2
for s in ss:
    dist = INF
    c_point = 0
    a, b = s
    for i, v in enumerate(p):
        c, d = v
        manhattan = abs(a - c) + abs(b - d)
        if manhattan < dist:
            c_point = i + 1
            dist = manhattan
    print(c_point)


Fixed submission:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
ans = []

for i in range(N):
    index = 0
    lowest = pow(10, 8) * 4
    for j in range(M):
        dist = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if lowest > dist:
            lowest = dist
            index = j
    print(index + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
power = 1

for i in range(n):
    power *= (i + 1)

ans = power % (pow(10, 9) + 7)
print(ans)

Fixed submission:
import math

n = int(input())
ans = math.factorial(n) % (pow(10, 9) + 7)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = map(int,input().split())
total = 1
for i in l:
    total *= i
if total > 1000000000000000000 :
    total = -1
print(total)

Fixed submission:
n = int(input())
l = map(int, input().split())
total = 1

if __name__ == '__main__':
    for i in l:
        total *= i
        if total > 1000000000000000000:
            total = -1
            break

    if 0 in l :
        total = 0
    print(total)
Buggy python submission (verdict: Runtime Error):
a , b , c , d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

result = ""
while True :
	c -= b
	if c =< 0 :
		result ="Yse"
        break
		
	a -= d
	if a =< 0 :
		result = "No"
        break
print(result)
 
	
    
  

Fixed submission:
a , b , c , d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

a_hp = a
b_hp = c

result = ""
while True :
	b_hp -= b
	if b_hp <= 0 :
		result ="Yes"
		break
		
	a_hp -= d
	if a_hp <= 0 :
		result = "No"
		break
print(result)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list = {}
for x in range(n):
	item = input()
	list[item] = x
print(len(lest))

Fixed submission:
n = int(input())
list = {}
for x in range(n):
	item = input()
	list[item] = x
print(len(list))
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int, input().split()))
ans = prod(a)

if ans <= 10**18:
  print(ans)
else:
  print(-1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
  print(0)
else:  
  for i in a:
    ans*=i
    if ans > 10**18:
      print(-1)
      exit()
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
  ans*=i
if ans <= 10**18:
  print(ans)
else:
  print(-1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
  print(0)
else:  
  for i in a:
    ans*=i
    if ans > 10**18:
      print(-1)
      exit()
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
a = input()
k_a = deque(a + 'K')
k_a.popleft()
a = deque(a)
ans = 'K'

while len(a) >0:
    l = a.popleft()
    k_l = k_a.popleft()
    if l == '?':
        if ans[-1] == 'P' or k_l == 'P':
            ans += 'D'
        elif k_l == 'D' or k_l == '?':
            ans += 'P'
        else:
            ans+='D'    
    else:
        ans += l
print(ans[1:])


Fixed submission:
a = input()

print(a.replace('P?', 'PD').replace('?D', 'PD').replace('??', 'PD').replace('?', 'D'))

Buggy python submission (verdict: Time Limit Exceeded):
a = input() + 'K'
ans = 'K'

for i,j in enumerate(a):
    if j == '?':
        if ans[-1] == 'P':
            ans+='D'
        elif  (ans[-1] == 'D' and a[i+1] == '?') or a[i+1] == 'D':
            ans+='P'
        else:
            ans+='D'
    else:
        ans+=j

print(ans[1:-1])

Fixed submission:
a = input()

print(a.replace('P?', 'PD').replace('?D', 'PD').replace('??', 'PD').replace('?', 'D'))

Buggy python submission (verdict: Runtime Error):

a=input()
ans = ''

for i,j in enumerate(a):
    if j == '?':
        if ans[-1] == 'P':
            ans+='D'
        elif a[i+1] == 'D':
            ans+='P'
        elif a[i+1] == '?':
            ans+='P'
        else:
            ans+='D'
    else:
        ans+=j

print(ans)

Fixed submission:
a = input()

print(a.replace('P?', 'PD').replace('?D', 'PD').replace('??', 'PD').replace('?', 'D'))

Buggy python submission (verdict: Runtime Error):
a = input()
ans = []

for j in a:
    if j == '?':
        if ans[-1] == 'P':
            ans.append('D')
        else:
            ans.append('P')
    else:
        ans.append(j)

t = ''
for l in ans:
    t += l
print(t)

Fixed submission:
a = input()

print(a.replace('P?', 'PD').replace('?D', 'PD').replace('??', 'PD').replace('?', 'D'))
Buggy python submission (verdict: Runtime Error):
A,B,C,K = map(int, input().split())
L=[1]*A + [0]*B + [-1]*C

J = sum(L[:K])

print(J)

Fixed submission:
A,B,C,K = map(int, input().split())
ans =0
for c,i in enumerate([A,B, C]):
  K -= i
  if K>=0:
    if c ==0:
    	ans += i
    elif c == 2:
      	ans -= i
      
  else:
    if c ==0:
    	ans += K +i
    elif c == 2:
      	ans -= K+i
    break
    
  

print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
import numpy as np

n,m,x = map(int, input().split())
q = [np.array(list(map(int, input().split()))) for _ in range(n)]
L=[]
for i in range(1,n):
    for j in list(combinations(q,i)):
        S = np.sum(j, axis=0)
        if all([k >= x for k in S[1:]]):
            L.append(S[0])

if len(L) >0:
    print(min(L))
else:
    print(-1)


Fixed submission:
from itertools import combinations
import numpy as np

n,m,x = map(int, input().split())
q = [np.array(list(map(int, input().split()))) for _ in range(n)]
L=[]
for i in range(1,n+1):
    for j in list(combinations(q,i)):
        S = np.sum(j, axis=0)
        if all([k >= x for k in S[1:]]):
            L.append(S[0])

if len(L) >0:
    print(min(L))
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(lambda x : int(x) -1,  map(int, input().split())))

s = {0}
loop = [0]

while a[loop[-1]] not in s:
    loop.append(a[loop[-1]])
    s.add(loop[-1])

    
idx = loop.index(a[loop[-1]])

if k <= len(loop):
    print(loop[k]+1)
else:
    print(loop[(k - idx)% (len(loop) - idx) + idx] + 1)


Fixed submission:
n,k = map(int, input().split())
a = list(map(lambda x : int(x) -1,  map(int, input().split())))

s = {0}
loop = [0]

while a[loop[-1]] not in s:
    loop.append(a[loop[-1]])
    s.add(loop[-1])

    
idx = loop.index(a[loop[-1]])

if k < len(loop):
    print(loop[k]+1)
else:
    print(loop[(k - idx)% (len(loop) - idx) + idx] + 1)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(lambda x : int(x) -1,  map(int, input().split()))

s = {0}
loop = [0]

while a[loop[-1]] not in s:
    loop.append(a[loop[-1]])
    s.add(loop[-1])

    
idx = loop.index(a[loop[-1]])

if k <= len(loop):
    print(loop[k-1]+1)
else:
    print(loop[(k - idx)% (len(loop) - idx) + idx] + 1)


Fixed submission:
n,k = map(int, input().split())
a = list(map(lambda x : int(x) -1,  map(int, input().split())))

s = {0}
loop = [0]

while a[loop[-1]] not in s:
    loop.append(a[loop[-1]])
    s.add(loop[-1])

    
idx = loop.index(a[loop[-1]])

if k < len(loop):
    print(loop[k]+1)
else:
    print(loop[(k - idx)% (len(loop) - idx) + idx] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
A = deque(list(map(int, input().split())))
ans=0
while len(A)>1:
  al = A.popleft()
  for i,a in enumerate(A):
    if i+1 == al + a:
      ans +=1
        
print(ans)
        
  
  

Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
ans=0
cnt = defaultdict(int)
for i in range(N):
  x = i - A[i]
  y = i + A[i]
  cnt[y] += 1
  ans += cnt[x]
        
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
K=int(input())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7))


Fixed submission:
N,K = map(int, input().split())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7) +1)

Buggy python submission (verdict: Runtime Error):
N=int(input())
K=int(input())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7))


Fixed submission:
N,K = map(int, input().split())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7) +1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

K, N = map(int, input().split())
S=deque(list(map(int, input().split())))

ans = [S[-1] - S[0]]
for i in range(N-1):
    s = max(S) - K
    del S[-1]
    S.appendleft(s)
    ans.append(S[-1] - S[0])


print(min(ans))

Fixed submission:
from collections import deque
K, N = map(int, input().split())
S=deque(list(map(int, input().split())))
ans = [S[-1] - S[0]]
for i in range(N-1):
    ans.append(S[i]- S[i+1] + K)
print(min(ans))
Buggy python submission (verdict: Runtime Error):
from collections import deque
N,R1,R2 = map(int, input().split())
graph = [deque([]) for _ in range(N-1)]
count={}
for i in range(N-1):
    count[i+1] = 0


for i in range(N-1):
    if i != R1-1:
        graph[i].append(i+1)
    else:
        graph[i].append(i+1)
        graph[i].append(R2-1)

def dfs(v, counter):
    global count
    gs=[]
    for g in graph[v]:
        count[counter]+=1
        gs.append(g)
    gsm = max(gs)
    if gsm < N-1:
        dfs(gsm, counter+1)
    else:
        return

for i in range(N-1):
    dfs(i, 1)
    


Fixed submission:
N, R1, R2 = map(int, input().split())
n = R2 - R1 - 1
count={}
for m in range(N-1):
    count[m+1] = 0 
for i in range(N):
    for j in range(i+1, N):
        k = min(j-i, abs((R1-1)-i) + 1 +abs((R2-1)-j))
        count[k]+=1
for k in count.values():
    print(k)
Buggy python submission (verdict: Runtime Error):
import collections
_=int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M={}

for i,v in c.items():
    if v>1:
        M[i] =  v*(v-1)/2

for k in l:
    M_ = M.copy()
    M_[k] =  M_[k]*(c[k]-2)/c[k]
    print(int(sum(M_.values())))

Fixed submission:
import collections
_ = int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M=0
for v in c.values():
    if v>1:
        M +=  v*(v-1)/2

for k in l:
    print(int(M-c[k]+1))

Buggy python submission (verdict: Runtime Error):
import collections
_=int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M={}

for i,v in c.items():
    if v>1:
        M[i] =  v*(v-1)/2

for k in l:
    M_ = M.copy()
    M_[k] =  M_[k]*(c[k]-2)/c[k]
    print(sum(M_.values()))

Fixed submission:
import collections
_ = int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M=0
for v in c.values():
    if v>1:
        M +=  v*(v-1)/2

for k in l:
    print(int(M-c[k]+1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
_=int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M={}
for i,v in c.items():
    M[i] =  v*(v-1)/2

for k in l:
    M_ = M.copy()
    M_[k] =  M_[k]*(c[k]-2)/c[k]
    print(int(sum(M_.values())))


Fixed submission:
import collections
_ = int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M=0
for v in c.values():
    if v>1:
        M +=  v*(v-1)/2

for k in l:
    print(int(M-c[k]+1))

Buggy python submission (verdict: Time Limit Exceeded):

import collections
_=int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M={}
for i,v in c.items():
    M[i] =  v*(v-1)/2
M
for k in l:
    M_ = M.copy()
    M_[k] =  M_[k]*(c[k]-2)/c[k]
    print(int(sum(M_.values())))


Fixed submission:
import collections
_ = int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
M=0
for v in c.values():
    if v>1:
        M +=  v*(v-1)/2

for k in l:
    print(int(M-c[k]+1))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
 
if (c-a-b) **2 - 4*a*b > 0 and c-a-b > 0:
    print('Yes')
else:
    print('No')

Fixed submission:
L=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i','j']
L_ind = [i for i in range(10)]
N=int(input())
K=[]
for i in range(N):
    if i==0:
        K.append(str(L_ind[0]))
    else:
        K_ = []
        for j in K:
            for m in range(int(max(set(j)))+2):
                K_.append(j + str(L_ind[m]))
        K = K_
    
for k in K:
    ans = ''
    for i in k:
        ans += L[int(i)]
    print(ans)
Buggy python submission (verdict: Runtime Error):

S=list(input())
while len(S)>0:
    if S[0] == 'h' and S[1] == 'i':
        S.remove('h')
        S.remove('i')
    else:   
        break

if len(S) == 0:
    print('Yes')
else:
    print('No')






Fixed submission:
S=list(input())
while len(S)>1:
    if S[0] == 'h' and S[1] == 'i':
        S.remove('h')
        S.remove('i')
    else:   
        break

if len(S) == 0:
    print('Yes')
else:
    print('No')