Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
# 余りのリスト
counts = [0] * 2019
n, d = 0, 1

for s in S[::-1]:
    n += int(s) * d
    d *= 10
    n %= 2019
    counts[n] += 1
ans = counts[0]
for count in counts:
    ans += count * (count - 1) // 2
print(ans)


Fixed submission:
S = str(input())
# 余りのリスト
counts = [0] * 2019
n, d = 0, 1

for s in S[::-1]:
    n += int(s) * d
    d *= 10
    n %= 2019
    d %= 2019
    counts[n] += 1
ans = counts[0]
for count in counts:
    ans += count * (count - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
for i in range(len(S)-4):
    for j in range(i+4,len(S)+1):
        if(int(S[i:j]) % 2019 == 0):
            ans += 1
print(ans)

Fixed submission:
S = str(input())
# 余りのリスト
counts = [0] * 2019
n, d = 0, 1

for s in S[::-1]:
    n += int(s) * d
    d *= 10
    n %= 2019
    d %= 2019
    counts[n] += 1
ans = counts[0]
for count in counts:
    ans += count * (count - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
for i in range(len(S)+1):
    for j in range(i+4,len(S)+1):
        if(int(S[i:j]) % 2019 == 0):
            ans += 1
print(ans)

Fixed submission:
S = str(input())
# 余りのリスト
counts = [0] * 2019
n, d = 0, 1

for s in S[::-1]:
    n += int(s) * d
    d *= 10
    n %= 2019
    d %= 2019
    counts[n] += 1
ans = counts[0]
for count in counts:
    ans += count * (count - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
for i in range(len(S)+1):
    for j in range(i+1,len(S)+1):
        if(int(S[i:j]) % 2019 == 0):
            ans += 1
print(ans)


Fixed submission:
S = str(input())
# 余りのリスト
counts = [0] * 2019
n, d = 0, 1

for s in S[::-1]:
    n += int(s) * d
    d *= 10
    n %= 2019
    d %= 2019
    counts[n] += 1
ans = counts[0]
for count in counts:
    ans += count * (count - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
for i in range(len(S)+1):
    for j in range(i+1,len(S)+1):
        if(int(S[i:j]) % 2019 == 0):
            ans += 1
print(ans)

Fixed submission:
S = str(input())
# 余りのリスト
counts = [0] * 2019
n, d = 0, 1

for s in S[::-1]:
    n += int(s) * d
    d *= 10
    n %= 2019
    d %= 2019
    counts[n] += 1
ans = counts[0]
for count in counts:
    ans += count * (count - 1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter
N, K = map(int, input().split())
MOD = 10**9 + 7
pluse = 10**10
n = []
comb_list = []
for i in range(N+1):
    n.append(pluse+i)
for i in range(K,N+2):
    tmp = list(itertools.combinations(n,i))
    for j in range(len(tmp)):
        comb_list.append(sum(tmp[j]))
# print(comb_list)
counter = Counter(comb_list)
print(len(counter.values())%MOD)


Fixed submission:
N,K = map(int,input().split())
mod = 10**9 + 7
ans = 0
for i in range(K,N+2):
    M = i*(2*N-i+1)//2
    m = i*(i-1)//2
    ans += (M - m + 1)
print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

import math
K = int(input())
ans = 0

for i in range(1, K + 1):
    for j in range(1, K + 1):
        for l in range(1, K + 1):
            ans += math.gcd(math.gcd(i, j), l)

print(ans)


Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

import math
K = int(input())
ans_list = []
ans = 0
for i in range(1, K + 1):
    for j in range(1,K+1):
        ans_list.append(math.gcd(i,j))
for i in range(1,K+1):
    for j in range(0,len(ans_list)):
        ans += math.gcd(i,ans_list[j])

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

print(K - max_dis)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = K - (A[-1] - A[0])
for i in range(N - 1):
    tmp = A[i + 1] - A[i]
    ans = max(tmp,ans)
print(K - ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys


import sys
import itertools
input = sys.stdin.readline

N = int(input())
A=list(map(int, input().split()))
ans = 0
for i in range(N):
    S = A[:]
    del(S[i])
    for j,k in itertools.combinations(S,2):
        if (j == k):
            ans += 1
        else:
            pass
    print(ans)
    ans = 0


Fixed submission:
import collections

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

C = collections.Counter(a)
total = 0
for i in C.keys():
    total += C[i] * (C[i] - 1) // 2
for i in range(n):
    A = a[i]
    print(total - C[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys


import sys
input = sys.stdin.readline

N = int(input())
A=list(map(int, input().split()))
ans = 0
for i in range(N):
    S = A[:]
    del(S[i])
    for j in range(N -1):
        for k in range(j+1,N -1):
            if(S[j] == S[k]):
                ans += 1
            else:
                pass
    print(ans)
    ans = 0


Fixed submission:
import collections

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

C = collections.Counter(a)
total = 0
for i in C.keys():
    total += C[i] * (C[i] - 1) // 2
for i in range(n):
    A = a[i]
    print(total - C[A] + 1)

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

ans = 0
for i in range(N):
    S = A[:]
    del(S[i])
    for j in range(N -1):
        for k in range(j+1,N -1):
            if(S[j] == S[k]):
                ans += 1
            else:
                pass
    print(ans)
    ans = 0


Fixed submission:
import collections

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

C = collections.Counter(a)
total = 0
for i in C.keys():
    total += C[i] * (C[i] - 1) // 2
for i in range(n):
    A = a[i]
    print(total - C[A] + 1)

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

ans = 0
for i in range(N):
    S = A[:]
    del(S[i])
    for j in range(N -1):
        for k in range(j+1,N -1):
            if(S[j] == S[k]):
                ans += 1
            else:
                pass
    print(ans)
    ans = 0


Fixed submission:
import collections

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

C = collections.Counter(a)
total = 0
for i in C.keys():
    total += C[i] * (C[i] - 1) // 2
for i in range(n):
    A = a[i]
    print(total - C[A] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())
Qer = [list(map(str,input().split())) for i in range(Q)]
flag = 0
for i in range(Q):
    if Qer[i][0] == "1":
        flag+=1
    else:
        if flag%2 ==0:
            if Qer[i][1] =="1":
                S = Qer[i][2] + S
            else:
                S = S+Qer[i][2]
        else:
            if Qer[i][1] =="2":
                S = Qer[i][2] + S
            else:
                S = S+Qer[i][2]

print(S if flag%2==0 else S[::-1])

Fixed submission:
from collections import deque
S = str(input())
Q = int(input())
Qer = [list(map(str,input().split())) for i in range(Q)]
flag = True
anss = deque(S)
for i in range(Q):
    if Qer[i][0] == "1":
        flag = not flag
    else:
        if flag ==True:
            if Qer[i][1] =="1":
                anss.appendleft(Qer[i][2])
            else:
                anss.append(Qer[i][2])
        else:
            if Qer[i][1] =="2":
                anss.appendleft(Qer[i][2])
            else:
                anss.append(Qer[i][2])
anss=''.join(anss)
if flag == True:
    print(anss)
else:
    anss = anss[::-1]
    print(anss)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())
Qer = [list(map(str,input().split())) for i in range(Q)]
for i in range(Q):
    if Qer[i][0] == "1":
        S = S[::-1]
    else:
        if Qer[i][1] =="1":
            S = Qer[i][2] + S
        else:
            S = S+Qer[i][2]

print(S)

Fixed submission:
from collections import deque
S = str(input())
Q = int(input())
Qer = [list(map(str,input().split())) for i in range(Q)]
flag = True
anss = deque(S)
for i in range(Q):
    if Qer[i][0] == "1":
        flag = not flag
    else:
        if flag ==True:
            if Qer[i][1] =="1":
                anss.appendleft(Qer[i][2])
            else:
                anss.append(Qer[i][2])
        else:
            if Qer[i][1] =="2":
                anss.appendleft(Qer[i][2])
            else:
                anss.append(Qer[i][2])
anss=''.join(anss)
if flag == True:
    print(anss)
else:
    anss = anss[::-1]
    print(anss)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s,m =map(int, input().split())
    if ans[s-1]!=m and ans[s-1]!=-1:
        print(-1)
        exit()
    ans[s-1]=m
if ans[0]==0:
    print(-1)
    exit()
if ans[0]==-1 and ans[1]==0:
    ans[0]=1
for i in range(N):
    if ans[i]==-1:
        ans[i]=0
Ans = [str(a) for a in ans]
print(''.join(Ans))

Fixed submission:
N, M = map(int, input().split())
S = []
C = []
for i in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)

for i in range(10000):
    tmp = str(i)
    if len(tmp)!=N:
        continue
    flag = True
    for j in range(M):
        if int(tmp[S[j] - 1]) != C[j]:
            flag = False
    if flag == True:
        print(tmp)
        exit()
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
for i in range(K):
    if(A>=1):
        A-=1
    elif(B>=1):
        B-=1
    else:
        pass
print(A,B)

Fixed submission:
A,B,K = map(int,input().split())
if(A-K<=0):
    if(B-K+A<=0):
        print(0,0)
    else:
        print(0,B-K+A)
else:
    print(A-K,B)
Buggy python submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
print (int(A * B // (fractions.gcd(A,B))))

Fixed submission:
#a,b,c = map(int,input().split())
a = int(input())
b = int(input())
print(6-a-b)

Buggy python submission (verdict: Runtime Error):
#a,b,c = map(int,input().split())
a = input()
b = input()
print(6-a-b)


Fixed submission:
#a,b,c = map(int,input().split())
a = int(input())
b = int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print (int(A * B // (math.gcd(A,B))))

Fixed submission:
import fractions
A, B = map(int, input().split())
print (int(A * B // (fractions.gcd(A,B))))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print((A * B) // (math.gcd(A,B)))

Fixed submission:
import fractions
A, B = map(int, input().split())
print (int(A * B // (fractions.gcd(A,B))))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B // (math.gcd(A,B)))

Fixed submission:
import fractions
A, B = map(int, input().split())
print (int(A * B // (fractions.gcd(A,B))))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B / (math.gcd(A,B)))

Fixed submission:
import fractions
A, B = map(int, input().split())
print (int(A * B // (fractions.gcd(A,B))))
Buggy python submission (verdict: Runtime Error):
N = int(input())

evidences = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x-1, y))

result = 0
for i in range(1, 2**N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print (result)


Fixed submission:
a,b,c = map(int,input().split())
if(a+b+c >=22):
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Runtime Error):
A, B, X = map(int, input().split())
lb = -1
ub = X

while ub - lb > 1:
    mid = (lb + ub) // 2
    if A*mid + B*len(str(mid)) > X:
        ub = mid
    else:
        lb = mid
print(min(10**9,lb))

Fixed submission:
#a,b = map(int,input().split())
s = input()
S = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-S.index(s))

Buggy python submission (verdict: Runtime Error):
#a,b = map(int,input().split())
s = input()
S =['SUN','MON','TUE','WEB','THU','FRI','SAT']
print(7-S.index(s))


Fixed submission:
#a,b = map(int,input().split())
s = input()
S = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-S.index(s))

Buggy python submission (verdict: Runtime Error):
#a,b = map(int,input().split())
s = str(input())
S =['SUN','MON','TUE','WEB','THU','FRI','SAT']
print(7-S.index(s))


Fixed submission:
#a,b = map(int,input().split())
s = input()
S = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-S.index(s))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(max(0,a-2*b))



Fixed submission:
a,b = map(int,input().split())
print(max(0,a-2*b))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
s = a-2*b
if(s >= 0):
    print(s)
else:
    print(0)



Fixed submission:
a,b = map(int,input().split())
print(max(0,a-2*b))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
s = a-2*b
if(s > 0):
    print(s)
else:
    print(0)



Fixed submission:
a,b = map(int,input().split())
print(max(0,a-2*b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
v.sort()
ans=v[0]
for i in v[1:]:
    ans=(ans+i)/2
print(ans)

Fixed submission:
a = int(input())
s = str(input())
if(a >= 3200):
    print(s)
else:
    print("red")

Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
v1 = v.sort()
ans=v1[0]
for i in v[1:]:
    ans=(ans+i)/2
print(ans)

Fixed submission:
a = int(input())
s = str(input())
if(a >= 3200):
    print(s)
else:
    print("red")

Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
v.sort()
ans=v[0]
for i in v[1:]:
    ans=(ans+i)/2
print(ans)

Fixed submission:
a = int(input())
s = str(input())
if(a >= 3200):
    print(s)
else:
    print("red")
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
S = []
for _ in range(N):
    a = str(input())
    S.append(a)
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if sorted(S[i]) == sorted(S[j]):
            ans += 1
print(ans)




Fixed submission:
import collections

N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for i in set(s):
    n = c[i]
    ans += n * (n - 1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for i in range(n)]

for i in range(n):
    tmp = A[:]
    del tmp[i]
    print(max(tmp))


Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]
tmp = sorted(A,reverse=True)
Max = tmp[0]
Second = tmp[1]
for i in range(n):
    if A[i] != Max:
        print(Max)
    else:
        print(Second)
Buggy python submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
x = [list(map(int,input().split())) for i in range(N)]
tmp = 0
ans = 0
for i in range(N):
    for j in range(i + 1,N):
        for d in range(D):
            tmp += (x[i][d] - x[j][d])**2
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            ans += 1
        tmp = 0
print(ans)

Fixed submission:
L, R = map(int, input().split())
ans = 2019
if R - L >= 2019:
    print(0)
else:
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = sorted(list(map(int, input().split())))
ans = 0
for i in range(1,d[-1] + 1):
    if sum(x <i for x in d) == N//2:
        ans += 1
    else:
        pass
print(ans)

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

print(d[N//2] - d[N//2 - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(1,max(d) + 1):
    if sum(x > i for x in d) == N//2:
        ans += 1
    else:
        pass
print(ans)

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

print(d[N//2] - d[N//2 - 1])
Buggy python submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())
MOD = 10 ** 9 + 7
for i in range(1, K + 1):
    ans = factorial(N - K + 1) // (factorial(i) * factorial(N - K + 1 - i)) * factorial(K - 1) // (
                factorial(i - 1) * factorial(K - 1 - i + 1))
    print(ans % MOD)


Fixed submission:
from math import factorial

N, K = map(int, input().split())
MOD = 10 ** 9 + 7
for i in range(1, K + 1):
    if N-K+1 < i or K-1 < i-1:
        ans = 0
    else:
        ans = factorial(N - K + 1) // (factorial(i) * factorial(N - K + 1 - i)) * factorial(K - 1) // (
                factorial(i - 1) * factorial(K - 1 - i + 1))
    print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
  ans *= a
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
ans = reduce(lambda x, y: x*y, A)
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def partsum(n,k):
  ret = sum(list(range(n-k+1,n+1)))
  return ret

N, K = map(int,input().split())
ret  = 0
for k in range(K, N+2):
  ret += partsum(N,k) - partsum(k-1,k) + 1
print(ret)


Fixed submission:
def partsum(n,k):
  ret1 = n*(n+1)/2
  ret2 = (n-k+1)*(n-k)/2
  return ret1 - ret2

N, K = map(int,input().split())
ret  = 0
for k in range(K, N+2):
  ret += partsum(N,k) - partsum(k-1,k) + 1
print(int(ret)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a=map(int,input().split())
a=sorted(a)
if a[-m] >= sum(a)/4/m:
    print("Yes")
else:
    print("No")

Fixed submission:
n,m = map(int,input().split())
div = n//m
minval = div*m
maxval = (div+1)*m
print(min(abs(minval-n),abs(maxval-n)))
Buggy python submission (verdict: Runtime Error):
a = input()
if (a[2] == a[3]) & (a[4] == a[5]):
  print(Yes)
else:
  print(No)

Fixed submission:
a = input()
if (a[2] == a[3]) & (a[4] == a[5]):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a = input()
if a[2] == a[3] && a[4] == a[5]:
  print(Yes)
else:
  print(No)

Fixed submission:
a = input()
if (a[2] == a[3]) & (a[4] == a[5]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np

k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(k)
b = []
for k in range(len(a)):
  b.append(a[k+1] - a[k])
print(k - argmax(b))

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
b = []
for l in range(len(a)-1):
  b.append(a[l+1] - a[l])
b.append(k-a[n-1]+a[0])
print(k - max(b))
Buggy python submission (verdict: Runtime Error):
import itertools

n,m = map(int,input().split())
comb = itertools.combinations
print(comb(n,2)+comb(m,2))

Fixed submission:
import itertools

n,m = map(int,input().split())
comb = lambda x:x*(x-1)/2 if x >= 1 else 0
print(int(comb(n)+comb(m)))
Buggy python submission (verdict: Runtime Error):
s = list(input())
n = len(s)

def kaibun(st):
  sta = list()
  for k in range(len(st)//2):
    sta.append(st[k])
  for k in range(len(st)//2):
    if st[-(-len(st)//2)+k] != sta.pop():
      return False
  return True

if kaibun(s) == False:
  print('No')
elif kaibun(s[:(n-1)//2]) == No:
  print('No')
elif kaibun(s[(n+3)//2-1:]) == No:
  print('No')
else:
  print('Yes')


Fixed submission:
s = list(input())
n = len(s)

def kaibun(st):
  sta = list()
  for k in range(len(st)//2):
    sta.append(st[k])
  for k in range(len(st)//2):
    if st[-(-len(st)//2)+k] != sta.pop():
      return False
  return True

if kaibun(s) == False:
  print('No')
elif kaibun(s[:(n-1)//2]) == False:
  print('No')
elif kaibun(s[(n+3)//2-1:]) == False:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
print(((int(input())/3)**3)


Fixed submission:
print((int(input())/3)**3)

Buggy python submission (verdict: Runtime Error):
print((int(input())**3)

Fixed submission:
print((int(input())/3)**3)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An = list(map(int,input().split()))

# n(n-1)/2 - (n-1)(n-2)/2 = n-1
dic = {}
su = 0
m = 0
for a in An:
  dic[a] = 0
for a in An:
  dic[a] += 1 
for a,n in enumerate(An):
  su = 0
  for d,i in enumerate(dic):
    m = dic[i]
    su += m * (m-1) / 2
    if i == n:
      su += -m+1
  print(int(su))


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

# n(n-1)/2 - (n-1)(n-2)/2 = n-1
dic = {}
su = 0
m = 0
for a in An:
  dic[a] = 0
for a in An:
  dic[a] += 1 
for d,i in enumerate(dic):
  su += dic[i] * (dic[i]-1) / 2
for a in An:
  print(int(su - dic[a] + 1))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}
for k in sc:
  if k[0] in dic:
    if dic[k[0]] != k[1]:
      print(-1)
      exit()
  else:
    dic[k[0]] = k[1]
ans = 0
if dic[1] == 0:
  print(-1)
  exit()
for k in dic:
  ans += 10**(N-k) * dic[k]
if ans < 10**(N-1):
  ans += 10**(N-1)
print(ans)

Fixed submission:
N,M = map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}
if sc == [] and N == 1:
  print(0)
  exit()
if sc == [[1,0]] and N == 1:
  print(0)
  exit()
for k in sc:
  if k[0] in dic:
    if dic[k[0]] != k[1]:
      print(-1)
      exit()
  else:
    dic[k[0]] = k[1]
ans = 0
if 1 in dic and dic[1] == 0:
  print(-1)
  exit()
for k in dic:
  ans += 10**(N-k) * dic[k]
if ans < 10**(N-1):
  ans += 10**(N-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
print(int(math.log(N,K)+1))

Fixed submission:
import math
N,K = map(int,input().split())
print(int(math.log(N,K)+1))
Buggy python submission (verdict: Runtime Error):
H,N = map(int, input().split())
A = list(map(input().split()))
if sum(A) >= H:
  print('Yes')
else:
  print('No')

Fixed submission:
H,N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S,T = input().split()
S = list(S)
T = list(T)
ans = []
for s,t in S,T:
  ans.append(s)
  ans.append(t)
print(''.join(ans))

Fixed submission:
N = int(input())
S,T = input().split()
S = list(S)
T = list(T)
ans = []
for s,t in zip(S,T):
  ans.append(s)
  ans.append(t)
print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
from fractions import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
print(A*B//gcd(A,B))

Buggy python submission (verdict: Runtime Error):
from fractions import math
A,B=map(int,input().split())
print(A*B/math.gcd(A,B))

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
print(A*B//gcd(A,B))