Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
n,m = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
sum = sum(l)
k = sum/(4*m)
ans = "Yes"
l.sort(reverse = True)
for i in (0,m):
  if l[i]<k:
      ans="No"
      break
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = "Yes"
 
a.sort(reverse=True)
 
for i in range(m):
    if a[i] < sum(a)*(1/(4*m)):
        ans = "No"
        break
 
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
n,m = map(int, stdin.readline().rstrip().split(' '))
l = list(map(int, stdin.readline().rstrip().split(' ')))
sum = sum(l)
k = sum/(4*m)
ans = "Yes"
l.sort(reverse = True)
for i in (0,m):
  if l[i]<k:
      ans="No"
      break
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = "Yes"
 
a.sort(reverse=True)
 
for i in range(m):
    if a[i] < sum(a)*(1/(4*m)):
        ans = "No"
        break
 
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
n,m = map(int, stdin.readline().rstrip().split(' '))
l = list(map(int, stdin.readline().rstrip().split(' ')))
sum = sum(l)
k = sum/(4*m)
ans = "Yes"
l.sort(reverse = True)
for i in (0,m):
  if l[i]<k:
      ans="No"
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = "Yes"
 
a.sort(reverse=True)
 
for i in range(m):
    if a[i] < sum(a)*(1/(4*m)):
        ans = "No"
        break
 
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
n,m = map(int, stdin.readline().rstrip().split(' '))
l = list(map(int, stdin.readline().rstrip().split(' ')))
sum = sum(l)
k = sum/(4*m)
ans = "Yes"
l.sort(reverse = True)
for i in (0,m):
  if l[i]<k:
      ans="No"
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = "Yes"
 
a.sort(reverse=True)
 
for i in range(m):
    if a[i] < sum(a)*(1/(4*m)):
        ans = "No"
        break
 
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = []
if(n%m = 0):
  ans=0
else:
  n = n-m
  l.append(n)
  
print(ans)

Fixed submission:
n, m = map(int, input().split())
l = []
ans = 1
if(n%m == 0):
  ans=0
else:
  for x in (0,1000000000000000000):
    n = abs(n%m)
    l.append(n)
  l.sort()
  ans = min(m-n,l[0])
print(ans)
Buggy python submission (verdict: Runtime Error):
n =input()
a= 500
b = 5
sum = 0
if(n%a==0):
  sum = n*2
print(sum)

Fixed submission:
n =int(input())
a= 500
b = 5
sum = 0
if(n%a==0):
  sum = n*2
else:
  sum = (1000*(n//a)) + 5*((n%a)//b)
  
print(sum)
Buggy python submission (verdict: Runtime Error):
n,x,y = map(int, input().split())
ans = [0]*n
for i in range(0 , n):
  for j in range(i+1 ,n+1):
    ans= ans(min(abs(j-i), abs(x-i), abs(y-j)+1)+1
    
for i in range(1,n):
  print(ans[i])

Fixed submission:
n,x,y = map(int, input().split())
ans = [0]*n
for i in range(1 , n):
  for j in range(i+1 ,n+1):
    ans[min(abs(j-i),abs(x-i)+abs(y-j)+1)]+=1
    
for i in range(1,n):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
ans1 = 0
ans2 = 0
p1.sort(reverse = True)
p2.sort(reverse = True)
p3.sort(reverse = True)
for i in range(0,x):
  ans1= ans1 + max(p1[i],p3[0])
  if(p3[0]>p1[i]):
    del p3[0]
for i in range(0,y):
  ans2= ans2 + max(p2[i],p3[0])
  if(p3[0]>p2[i]):
    del p3[0]
print(ans1+ans2)



Fixed submission:
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
p1.sort(reverse= True)
p2.sort(reverse= True)
ans =p1[:x]+p2[:y]+p3
ans.sort(reverse= True)
print(sum(ans[:x+y]))

Buggy python submission (verdict: Runtime Error):
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
ans1 = 0
ans2 = 0
p1.sort(reverse = True)
p2.sort(reverse = True)
p3.sort(reverse = True)
for i in range(0, max(x,y)):
  p3.append(0)
for i in range(0,x):
  ans1= ans1 + max(p1[i],p3[i])
  if(p3[i]>p1[i]):
    del p[i]
for i in range(0,y):
  ans2= ans2 + max(p2[i],p3[i])
  if(p3[i]>p2[i]):
    del p3[i]
print(ans1+ans2)



Fixed submission:
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
p1.sort(reverse= True)
p2.sort(reverse= True)
ans =p1[:x]+p2[:y]+p3
ans.sort(reverse= True)
print(sum(ans[:x+y]))

Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
ans1 = 0
ans2 = 0
p1.sort(reverse = True)
p2.sort(reverse = True)
p3.sort(reverse = True)
for i in range(0, max(x,y)):
  p3.append(0)
for i in range(0,x):
  p3.sort(reverse = True)
  ans1= ans1 + max(p1[i],p3[0])
  if(p3[0]>p1[i]):
    p3[0] = 0
for i in range(0,y):
  p3.sort(reverse = True)
  ans2= ans2 + max(p2[i],p3[0])
  if(p3[0]>p2[i]):
    p3[0] = 0
print(ans1+ans2)



Fixed submission:
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
p1.sort(reverse= True)
p2.sort(reverse= True)
ans =p1[:x]+p2[:y]+p3
ans.sort(reverse= True)
print(sum(ans[:x+y]))
Buggy python submission (verdict: Runtime Error):
s= input()
l = list(s)
ans= "Yes"
if(s != s[::1]):
    ans = "No"
    break
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
    if s1!=s2:
        print("No")
    else:
        print("Yes")
print(ans)


Fixed submission:
s= str(input())
if s != s[::-1]:
    print("No")
    exit()
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
    if (s1!=s2):
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
s = input()
l = list(s)
for i in range(0,len(l)-1):
  if(l[i]!= l[i+1]):
    print("Yes")
    break()
  else:
    print("No")
  

Fixed submission:
s = input()
l = list(s)
ans= "No"
for i in range(0,len(l)-1):
  if(l[i]!= l[i+1]):
    ans = "Yes"
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
l= list(map(int input().split()))
if(l[0]==l[1] or l[1]==l[2]) and l[1]!=l[2]:
  print("Yes")
else:
  print("No")

Fixed submission:
# cook your dish here
l= list(map(int, input().split()))
if(l[0]==l[1]!=l[2] or l[0]!=l[1]==l[2] or l[0]==l[2]!=l[1]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
for i in l:
  if(i%2 ==0 and (i%3 ==0 or i%5==0):
     print("APPROVED")
  else:
     print("DENIED")
  

Fixed submission:
n = int(input());l = list(map(int, input().split()));ans = "APPROVED"
for i in (l):
  if(i%2 ==0 and (i%3 !=0 and i%5!=0)):
     ans = "DENIED"
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [input() for _ in range(N)]
l.sort()
l2 = []
for i in range(0,N-1):
    if (l[i]==l[i+1]):
        l2.append(l[i])
ans=list(set(l2))
if len(l2)==0:
    for k in range(0,N):
        print(l[k])
for j in range(0,len(l2)):
    print(ans[j])

Fixed submission:
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int, input().split());d=math.gcd(a,b)
print((a*b)//d)

Fixed submission:
a,b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b= b, a%b
    return a
def lcm(a, b):
    return (a * b) // gcd(a, b)
print(lcm(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:
a,b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b= b, a%b
    return a
def lcm(a, b):
    return (a * b) // gcd(a, b)
print(lcm(a, b))

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

Fixed submission:
a,b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b= b, a%b
    return a
def lcm(a, b):
    return (a * b) // gcd(a, b)
print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
S = input()
print(S)
print(S[2])

count = 0
for i in range(int(len(S)/2)):
    if S[i] != S[len(S)-i-1]:
        count += 1

print(count)

Fixed submission:
S = input()

count = 0
for i in range(int(len(S)/2)):
    if S[i] != S[len(S)-i-1]:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = []
for i in range(N//2):
    if(N%(i+1) == 0):
        list.append([i+1, N//(i+1)])
min = 1000000000000
for i in list:
    if(min > i[0]+i[1]):
        min = i[0]+i[1]
print(min-2)

Fixed submission:
import math
N = int(input())
list = []
for i in range(int(math.sqrt(N))):
    if(N%(i+1) == 0):
        list.append([i+1, N//(i+1)])
min = 1000000000000
for i in list:
    if(min > i[0]+i[1]):
        min = i[0]+i[1]
print(min-2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = []
for i in range(N):
    if(N%(i+1) == 0):
        list.append([i+1, N//(i+1)])
min = 1000000000000
for i in list:
    if(min > i[0]+i[1]):
        min = i[0]+i[1]
print(min-2)

Fixed submission:
import math
N = int(input())
list = []
for i in range(int(math.sqrt(N))):
    if(N%(i+1) == 0):
        list.append([i+1, N//(i+1)])
min = 1000000000000
for i in list:
    if(min > i[0]+i[1]):
        min = i[0]+i[1]
print(min-2)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
H = input().split()
for i in range(N):
    H[i] = int(H[i])

H = reversed(H)  
for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] = H[i+1]-1
    if H[i] > H[i+1]:
        print('No')
        sys.exit() 
print('Yes')


Fixed submission:
import sys
N = int(input())
H = input().split()
for i in range(N):
    H[i] = int(H[i])
H.reverse()

for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] = H[i+1]-1
    if H[i] < H[i+1]:
        print('No')
        sys.exit() 
print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    val = 0
    for j in range(N):
        if i >> j & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)


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

Buggy python submission (verdict: Runtime Error):
print(B*(T//A))


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

Buggy python submission (verdict: Runtime Error):
print(B*((T+0.5)//A))

Fixed submission:
A, B, T = map(int, input().split())
print(B*(T//A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    val = 0
    for j in range(N):
        if i >> j & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)


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

ans = 0
for i in range(2**N):
    val = 0
    for j in range(N):
        if (i >> j) & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

if d-a<=k
  print('Yay!')
else:
  print(':(')

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
 
if e-a<=k:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Time Limit Exceeded):
def knapsack(N, W, weight, value):
  inf = float("inf")
  dp = [[-inf]*(W+1) for _ in range(N+1)]
  for i in range(W+1):
    dp[0][i] = 0
  
  for i in range(N):
    for j in range(W+1):
      if weight[i] <= j:
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i])
      else:
        dp[i+1][j] = dp[i][j]
  return dp[N][W]
  
N, W = map(int, input().split())
weight, value = [], []
for i in range(N):
  w, v = map(int, input().split())
  weight.append(w)
  value.append(v)

print(knapsack(N, W, weight, value))

Fixed submission:
def knapsack(N, W, weight, value):
  inf = float("inf")
  dp = [[-inf]*(W+1) for _ in range(N+1)]
  for i in range(W+1):
    dp[0][i] = 0
  
  for i in range(N):
    for j in range(W+1):
      if weight[i] <= j:
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i])
      else:
        dp[i+1][j] = dp[i][j]
  return dp[N][W]
  
N, W = map(int, input().split())
weight, value = [], []
for i in range(N):
  w, v = map(int, input().split())
  weight.append(w)
  value.append(v)

print(knapsack(N, W, weight, value))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  num=i
  while num!=0:
    sum+=num%10
    num/=10
  if a<=sum<=b:
    ans+=i
print(ans)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  num=i
  sum=0
  while num!=0:
    sum+=num%10
    num//=10
  if a<=sum<=b:
    ans+=i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
s=set(a)
ans=0
for i in s:
    if a.count(i)%2==1:
        ans+=1
print(ans)


Fixed submission:
import collections
n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
cnt=collections.Counter(a)
ans=0
for i in s:
    if cnt[i]%2==1:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
ans=0
for i in s:
    if a.count(i)%2==1:
        ans+=1
print(ans)


Fixed submission:
import collections
n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
cnt=collections.Counter(a)
ans=0
for i in s:
    if cnt[i]%2==1:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
ans=0
for i in s:
    if a.count(i)%2==1:
        ans+=1
print(ans)


Fixed submission:
import collections
n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
cnt=collections.Counter(a)
ans=0
for i in s:
    if cnt[i]%2==1:
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())

    s = list(''.join(sorted(input()[:])) for i in range(n))

    count = 0
    for i in range(0, n):
        count += s[i+1:].count(s[i])

    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())

    count = 0
    found = {}
    for _ in range(n):
        str = ''.join(sorted(input()))
        if str in found:
            count += found[str]
            found[str] += 1
        else:
            found[str] = 1

    print(count)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())

    s = list(''.join(sorted(input()[:])) for i in range(n))

    count = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                count += 1

    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())

    count = 0
    found = {}
    for _ in range(n):
        str = ''.join(sorted(input()))
        if str in found:
            count += found[str]
            found[str] += 1
        else:
            found[str] = 1

    print(count)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())

    s = list(''.join(sorted(input()[:])) for i in range(n))

    count = 0
    for i in range(0, len(s)):
        for j in range(i + 1, len(s)):
            if s[i] == s[j]:
                count += 1

    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())

    count = 0
    found = {}
    for _ in range(n):
        str = ''.join(sorted(input()))
        if str in found:
            count += found[str]
            found[str] += 1
        else:
            found[str] = 1

    print(count)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b ,n = map(int, input().split())

if a == b and b == c:
    print(a-1)
else:
    if a <= b:
        if a >= n:
            #n_tmp = n % a
            #print(n_tmp)
            #if n_tmp == 0:
            n_tmp = n
            ans = int(a*n_tmp/b) - a*int(n_tmp/b)
            #print(ans)
            #print('####')
    
            ##for x in range(n+1):
             #   ans = int(a*x/b) - a*int(x/b)
             #   print(ans)
    
        else:
            ans = a-1
            print(ans)
    
            ##for x in range(n + 1):
             #   ans = int(a*x/b) - a*int(x/b)
             #   print(ans)
    
    
    else:
        if a >= n:
            ans_max = 0
            n_tmp = n
            for x in range(n_tmp+1):
                ans = int(a*x/b) - a*int(x/b)
                #print(ans)
                if ans_max < ans:
                    ans_max = ans
    
            print(ans_max)
    
        else:
            ans_max = 0
            n_tmp = a
            for x in range(n_tmp + 1):
                ans = int(a * x / b) - a * int(x / b)
                #print(ans)
                if ans_max < ans:
                    ans_max = ans
    
            #print('max##########################')
            print(ans_max)
    
            #print('#########################')
            #for x in range(n + 1):
            #    ans = int(a * x / b) - a * int(x / b)
            #    print(ans)
                #if ans_max < ans:
                #    ans_max = ans
    
            #print(ans_max)


Fixed submission:
a, b ,n = map(int, input().split())
tmp = min(b-1, n)
print(str(int(a*tmp/b)-a*int(tmp/b)))
Buggy python submission (verdict: Runtime Error):
s = str(input())[::-1]

tmp_amari = [0]*2019

#amari = 0
num = 0
order = 1
for i in s:
    num += int(i)*order
    num %= 2019
    #print(num)
    tmp_amari[num] += 1
    order *= 10

#tmp_print = [i for i in tmp_amari if i > 0]
#print(tmp_print)

ans = 0
ans += tmp_amari[0]

for i in tmp_print:
    ans += (i*(i-1))//2

print(ans)


Fixed submission:

s = input()[::-1]
from collections import defaultdict
amari = defaultdict(int)
keta_ = defaultdict(int)

cur = 0
keta = 1

for i in range(len(s)):
    cur += int(s[i]) * keta
    cur %= 2019

    keta *= 10
    keta %= 2019
    
    amari[cur] += 1
    keta_[keta] += 1

#print('%')
#print(2114%2019)
#print(181712114%2019)

#print(81712114%2019)
#print(1817181712114%2019)

#print('%')

#print(amari)
#print(keta_)
ans = 0
if 0 in amari:
    ans += amari[0]

for n in amari.values():
    ans += (n * (n-1)) // 2
  
print(ans)

Buggy python submission (verdict: Runtime Error):
s = str(input())[::-1]

tmp_amari = [0]*2019

#amari = 0
num = 0
order = 1
for i in s:
    num += int(i)*order
    num %= 2019
    print(num)
    tmp_amari[num] += 1
    order *= 10

#tmp_print = [i for i in tmp_amari if i > 0]
#print(tmp_print)

ans = 0
ans += tmp_amari[0]

for i in tmp_print:
    ans += (i*(i-1))//2

print(ans)


Fixed submission:

s = input()[::-1]
from collections import defaultdict
amari = defaultdict(int)
keta_ = defaultdict(int)

cur = 0
keta = 1

for i in range(len(s)):
    cur += int(s[i]) * keta
    cur %= 2019

    keta *= 10
    keta %= 2019
    
    amari[cur] += 1
    keta_[keta] += 1

#print('%')
#print(2114%2019)
#print(181712114%2019)

#print(81712114%2019)
#print(1817181712114%2019)

#print('%')

#print(amari)
#print(keta_)
ans = 0
if 0 in amari:
    ans += amari[0]

for n in amari.values():
    ans += (n * (n-1)) // 2
  
print(ans)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n, k = map(int, input().split())

ans = 0
for i in range(k, n+2):
    ans += ((n*2-i+1)*i)/2 - i*(i-1)/2 + 1

#print(ans)
print(int(ans%(10**9+7)))


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

ans = 0
for i in range(k, n+2):
    ans += ((n*2-i+1)*i)/2 - i*(i-1)/2 + 1

#print(ans)
print(int(ans%(10**9+7)))

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

n, k = map(int, input().split())

ans = 0
for i in range(k, n+2):
    ans += ((n*2-i+1)*i)/2 - i*(i-1)/2 + 1

#print(ans)
print(ans%(10**9+7))


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

ans = 0
for i in range(k, n+2):
    ans += ((n*2-i+1)*i)/2 - i*(i-1)/2 + 1

#print(ans)
print(int(ans%(10**9+7)))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections
n = int(input())

a_list = list(map(str, input().split()))
c = collections.Counter(a_list)


for k in range(n):
    ans = 0
    #tmp = c[str(a_list[k])] # a_list[k]の数の個数
    #print('tmp')
    #print(tmp)
    for j in c:
        if str(a_list[k]) == j:
            tmp = c[str(a_list[k])]-1
            #print('tmp')
            #print(tmp)
        else:
            tmp = c[str(j)]
            #print('tmp')
            #print(tmp)
        ans += (tmp-1)*tmp/2

    print(int(ans))




Fixed submission:
import copy
import collections
n = int(input())

a_list = list(map(str, input().split()))
c = collections.Counter(a_list)

tmp_list = []

ans = 0
for j in c:
    tmp = c[str(j)]
    #print('tmp')
    #print(tmp)
    ans += (tmp-1)*tmp/2

#print('ttt')
#print(ans)


for k in range(n):
    #ans = 0
    #tmp = c[str(a_list[k])] # a_list[k]の数の個数
    #print('tmp')
    #print(tmp)
    #print(c[str(a_list[k])]-1)
    #ans -= c[str(a_list[k])]-1
    #if str(a_list[k]) == j:
    #    tmp = c[str(a_list[k])]-1
    #else:
    #    tmp = c[str(j)]

    #ans += (tmp-1)*tmp/2

    print(int(ans - (c[str(a_list[k])]-1)))
Buggy python submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    
    ans = []
    check = []
    check_once = []
    false_flg = 0
    for i in range(n):
        ans.append('0')
        check.append(0)
        check_once.append(0)

    for j in range(m):
        s, c = input().split()

        if int(s) == 1 and int(c) == 0:
            false_flg = 1

        if check[int(s)-1] == 0:
            ans[int(s)-1] = c
            check[int(s)-1] = 1

        elif check[int(s)-1] == 1 and ans[int(s)-1] == c:
            ans[int(s)-1] == c:

        else:
            false_flg = 1
    
    tmp = int("".join(ans))
   
    if tmp // 10**(n-1) > 0 and false_flg != 1:
        print(tmp)
    elif false_flg != 1:
        tmp_ = 10**(n-1) + int(tmp)
        print(tmp_)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m = map(int, input().split())
    
    ans = []
    check = []
    check_once = []
    false_flg = 0
    for i in range(n):
        ans.append('0')
        check.append(0)
        check_once.append(0)

    for j in range(m):
        s, c = input().split()

        if int(s) == 1 and int(c) == 0 and n != 1:
            false_flg = 1

        if check[int(s)-1] == 0:
            ans[int(s)-1] = c
            check[int(s)-1] = 1

        elif check[int(s)-1] == 1 and ans[int(s)-1] == c:
            ans[int(s)-1] = c

        else:
            false_flg = 1
    
    tmp = int("".join(ans))
    
    if tmp // 10**(n-1) > 0 and false_flg != 1:
        print(tmp)

    elif false_flg != 1:
        if tmp == 0 and n == 1:
            print(0)
        else:
            tmp_ = 10**(n-1) + int(tmp)
            print(tmp_)
    else:
        print(-1)


if __name__ == '__main__':
    main()