Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02765 (python)

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

if n >= 10:
    print(r)
else:
    r += 100*(10-n)
    print(r)

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

if n >= 10:
    print(r)
else:
    r += 100*(10-n)
    print(r)2
Problem p02780 (python)

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

p = list(map(int,input().split()))

a = 0

for i in range(k):
    a += p[i]

ans = a

for i in range(n-k):
    a -= p[i]
    a += p[i+k]
    if a > ans:
        ans = a

ans = (ans+k)/2

print(ans)

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

p = list(map(int,input().split()))

for i in range(n-k):
    if p[i] < p[i+k]:
        ans = p[i+1:k+i+1]
        
ans = sum(ans)
ans = (ans+k)/2

print(ans)
Problem p02886 (python)

Fixed submission:
n = int(input())

d = list(map(int,input().split()))

s = int(0)

for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        else:
            s += d[i] * d[j]

print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())

d = list(map(int,input().split())

for i in range(n):
    for j in range(n):
        if i == j:
            break
        else:
            s += d[i] * d[j]

print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))

s = int(0)
s += d[0] * d[n]

for i in range(1,n):
    s += d[n-1] * d[n]

print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))

s = int(0)

s += d[0] * d[n]


for i in range(n):
    s += d[n] * d[n+1]

print(s)
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
n = [K - Q] * N
for i in range(Q):
    n[A[i]-1] += 1
for i in range(N):
    if n[i] > 0:
        print('Yes')
    else:
        print('No')

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

A = [int,input() for i in range(q)]

a = q-k+1

for i in range(1,n+1):
    v = A.count(i)
    if v >= a and v > 0:
        print('Yes')
    else:
        print('No')

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

A = [int,input() for i in range(q)]

a = q-k+1

for i in range(1,n+1):
    v = A.count(i)
    if v >= a and v > 0:
        print('Yes')
    else:
        print('No')

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

A = [int,input() for i in range(q)]

a = q-k+1

for i in range(1,n+1):
    v = A.count(i)
    if v >= a:
        print('Yes')
    else:
        print('No')
Problem p02921 (python)

Fixed submission:
s = list(input())

t = list(input())

ans = int(0)

for i in range(3):
    if s[i]==t[i]:
            ans += 1 
        
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())

b = int(input())

ans = int(0)

for i in range(1,21):
    if b > a*i-i+1:
            ans += 1
    else:
            ans += 1
            break

print(ans)
Problem p02922 (python)

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

ans = int(1)

for i in range(20):
    ans += a-1
    if ans < b:
        continue
    elif i == 0 and 1 == b:
        print(0)
        break
    else:
        print(i+1)
        break

Buggy submission (verdict: Runtime Error):
a = int(input())

b = int(input())

ans = int(0)

for i in range(1,21):
    if b > a*i-i+1:
            ans += 1
    else:
            ans += 1
            print(ans)
            break

Buggy submission (verdict: Runtime Error):
a = int(input())

b = int(input())

ans = int(0)

for i in range(1,21):
    if b > a*i-i+1:
            ans += 1
    else:
            ans += 1
            print(ans)
            break

Buggy submission (verdict: Runtime Error):
a = int(input())

b = int(input())

ans = int(0)

for i in range(1,21):
    if b > a*i-i+1:
            ans += 1
    else:
            ans += 1
            break

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())

b = int(input())

ans = int(0)

for i in range(21):
    if b > a*i-i+1:
            ans += 1
    else:
            break

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())

b = int(input())

ans = int(0)

for i in range(21):
    if b > a*i-i:
            ans += 1
    else:
            break

print(ans)
Problem p02946 (python)

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

for i in range(k*2-1):
    print(x-k+1+i,end=' ')

Buggy submission (verdict: Runtime Error):
k, x = map(int,input().spit())

L = []

for i in range(k*2-1):
    print(x-k+1+i,end=' ')
Problem p02969 (python)

Fixed submission:
r = int(input())

print(r**2*3)

Buggy submission (verdict: Runtime Error):
n = int(input())

a = [int(input()) for i in range(n)]

x = int(0)
y = int(0)

for i in range(n):
    x = max(a[:i])
    y = max(a[i + 1:])
    print(max(x,y))
Problem p02971 (python)

Fixed submission:

n = int(input())
a = []
y = 0
for i in range(n):
    x = int(input())
    a.append(x)
    if y <= x:
        y = x
        m = i

a.sort(reverse = True)
a_1 = a[0]
a_2 = a[1]

if a_1 == a_2:
    for i in range(n):
        print(a_1)

else:
    for i in range(m):
        print(a_1)

    print(a_2)

    for j in range(m+1,n):
        print(a_1)

Buggy submission (verdict: Runtime Error):
n = int(input())

a = [int(input()) for i in range(n)]

x = int(0)
y = int(0)

for i in range(n):
    x = max(0,a[:i])
    y = max(0,a[i + 1:])
    print(max(x,y))

Buggy submission (verdict: Runtime Error):
n = int(input())

a = [int(input()) for i in range(n)]

for i in range(n):
    x = max(a[:i])
    y = max(a[i + 1:])
    print(max(x,y))
Problem p02988 (python)

Fixed submission:
n = int(input())

L = [int(i) for i in input().split()]

Answer = int(0)
for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer + 1
             continue
     if L[i+2]<L[i+1] and L[i+1]<L[i]:
             Answer = Answer + 1
             continue
print(Answer)

Buggy submission (verdict: Runtime Error):
n = int(input())

L = [int(i) for i in input().split()]

for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer + 1
             continue
     if L[i+2]<L[i+1] and L[i+1]<L[i]:
             Answer = Answer + 1
             continue
print(Answer)

Buggy submission (verdict: Runtime Error):
n = int(input())

L = [int(i) for i in input().split()]

Answer = int(0)
for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer +1
             continue
	print(Answer)

Buggy submission (verdict: Runtime Error):
n = int(input())

L = [int(i) for i in input().split()]

Answer = int(0)
for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer +1
             continue
    print(Answer)
Problem p02993 (python)

Fixed submission:
s = input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
	print('Bad')
else:
	print('Good')

Buggy submission (verdict: Runtime Error):
s = input()
if n[0]==n[1] or n[1]==n[2] or n[2]==n[3]:
	print('Bad')
else:
	print('Good')
Problem p02999 (python)

Fixed submission:
num = input()
if num[0] < num[2]:
	print('0')
else:
	print('10')

Buggy submission (verdict: Runtime Error):
num = input()
if num[0] < num[2]:
print('0')
else:
print('10')
Problem p03000 (python)

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

L = list(map(int,input().split()))

ans = int(1)
t = int(0)
for i in range(n):
    t += int(L[i])
    if t <= x:
        ans += 1

print(ans)

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

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

ans = int(1)
t = int(0)
for i in range(n):
    t += L[i]
    if t <= x:
        ans += 1

print(ans)
Problem p03030 (python)

Fixed submission:
n=int(input())
sp=[]
for i in range(n):
  x,y=input().split()
  sp.append([x,int(y),i+1])
  sp.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
  print(sp[i][2])

Buggy submission (verdict: Runtime Error):
n = int(input())

l = []
for i in range(n):
  x,y = map(str,input().split())
  l.append((x,y, i))


L = []

for i in range(n):
  L.append((l[i][0], int(l[i][1]), l[i][2]))

L.sort(key = lambda L:L[1])

L.sort(key = lambda L:L[0])

for i in range(n):
  print(L[n][2] + 1)
Problem p03059 (python)

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

i = T//A
print(B*i)

Buggy submission (verdict: Runtime Error):
n = int,input()

integer = int(0)
v = input().split()

c = input().split()

for i in range(n):
    if int(v[i])>int(c[i]):
       integer += int(v[i])-int(c[i])
       continue
print(integer)
Problem p03060 (python)

Fixed submission:
n = int(input())

integer = int(0)
v = input().split()

c = input().split()

for i in range(n):
	if int(v[i]) > int(c[i]):
		integer += int(v[i])-int(c[i])
print(integer)

Buggy submission (verdict: Runtime Error):
n = int,input()

integer = int(0)
v = input().split()

c = input().split()

for i in range(n):
    if int(v[i])>int(c[i]):
		integer += int(v[i])-int(c[i])
		continue
	print(integer)

Buggy submission (verdict: Runtime Error):
n = int,input()

integer = int(0)
v = input().split()

c = input().split()

for i in range(n):
    if int(v[i])>int(c[i]):
            integer += int(v[i])-int(c[i])
            continue
print(integer)

Buggy submission (verdict: Runtime Error):
n = int,input()
3
integer = int(0)
v = input().split()

c = input().split()
for i in range(n):
    if int(v[i])>int(c[i]):
            integer += int(v[i])-int(c[i])
            continue
    print(integer)
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split())
if a == b:
    print(a + b)
elif a > b:
    print(a + a - 1)
elif a < b:
    print(b + b - 1)

Buggy submission (verdict: Runtime Error):
n = int(input())

L = input().split()

mountain = int(1)
for i in range(n):
    for j in range(i):
            if int(L[j]) > int(L[i]):
          			break
            else:
                    mountain += 1
print(mountain)
Problem p03125 (python)

Fixed submission:
a,b = map(int,input().split())
if b%a == 0:
  print(a+b)
else:
  print(b-a)

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

d = dict()
for i in range(n):
  a,*b = list(map(int,input().split()))
  d[i] = b

x = 0
ans = 0
for j in range(1,m+1):
  for i in range(n):
    if j in d[i]:
      x += 1
    else:
      x = 0
      break
  if x == n:
    ans += 1
  else:
    ans = 0

print(ans)
Problem p03136 (python)

Fixed submission:
n = int(input())

L = list(map(int,input().split()))

sum = int(0)
a = max(L)

for i in range(n):
  sum += L[i]
  
if 2*a < sum:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())

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

sum = int(0)
a = max(L)

for i in range(n):
  sum += L[i]
  
if 2*a > sum:
  print("Yes")
else:
  print("No")
Problem p03494 (python)

Fixed submission:

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

l = []
ans = 0

for x in range(n):
    for _ in range(10000000):
        if a[x]%2 == 0 and a[x] > 0:
            a[x] = a[x]//2
            ans += 1
            continue
        else:
            l.append(ans)
            ans = 0
            break

print(min(l))

Buggy submission (verdict: Runtime Error):

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

l = []
ans = 0

for x in range(n)
    for _ in range(10000000):
        if a[x]%2 == 0 and a_min > 0:
            ans += 1
            continue
        else:
            l.append(ans)
            ans = 0
            break

print(min(l))

Buggy submission (verdict: Runtime Error):

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

a_min = min(a)
ans = 0
for _ in range(10000000):
    if a_min%2 == 0 and a_min > 0:
        ans += 1
        a_min = a_min//2
        contnue
    else:
        break

for y in a:
    if y%2==1:
        ans -= 100000000
        continue



if ans > 0:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):

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

a_min = min(a)
ans = 0
for x in range(2,1000000,2):
    if a_min%2 == 0 and a_min > 0:
        ans += 1
        a_min = a_min//2
        contnue
    else:
        break

for y in a:
    if y%2==1:
        ans -= 100000000
        continue



if ans > 0:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):

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

a_min = min(a)
ans = 0
for x in range(2,1000000,2):
    if a_min%2 == 0 and a_min > 0:
        ans += 1
        contnue
    else:
        break

for y in a:
    if y%2==1:
        ans -= 100000000
        continue



if ans > 0:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):

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

a_min = min(a)
ans = 0
for x in range(2,1000000,2):
    if a_min%2 == 0 and a_min > 0:
        a += 1
        contnue
    else:
        break

for y in a:
    if y%2==1:
        ans -= 100000000



if ans > 0:
    print(ans)
else:
    print(0)
Problem p02621 (python)

Fixed submission:
a=int(input())
p=a+a**2+a**3
print(p)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=a+a**2+a**3
print(p)
Problem p02639 (python)

Fixed submission:
n=list(map(int,input().split()))
p=sum(n)
f=15
ans=(f-p)
print(ans)

Buggy submission (verdict: Runtime Error):
n=list(map(int,input()))
p=sum(n)
f=15
ans=(f-p)
print(ans)

Buggy submission (verdict: Runtime Error):
n=list(map(input()))
p=sum(n)
ans=(15-p)
print(ans)
Problem p02778 (python)

Fixed submission:
S = len(input())
print("x" * S)

Buggy submission (verdict: Runtime Error):
S = input()

l = len(S)
K = ""
for x in l:
  K += x
  
print(K)
Problem p02811 (python)

Fixed submission:
K, X = (int(x) for x in input().split())
if 500 * K >= X:
    print("Yes")
elif 500 * K < X:
    print("No")

Buggy submission (verdict: Runtime Error):
K, X = int(input().split())
if 500 * K >= X:
    print("Yes")
elif 500 * K < X:
    print("No")
Problem p02617 (python)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1): #頂点数の総和を求める
 ans+=i*(n-i+1)
for _ in range(n-1): #各辺についてu*(n-v+1)を頂点数の総和から引く
 u,v=map(int,input().split())
 if u>v: #上記ではu<vを仮定しているのでu>vのときuとvを入れ替える
   u,v=v,u
 ans-=u*(n-v+1)
print(ans)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True,key=lambda x:abs(x)) #絶対値の順にソートする
if k==n: #k=nのときはすべてを掛け合わせるほかない
 ans=1
 for i in range(n):
   ans*=arr[i]
   ans%=mod
 print(ans)
else:
 if k%2==1 and max(arr)<0: #答えが負になる場合は絶対値の小さい順にK個掛け合わせる
   ans=1
   for i in range(k):
     ans*=arr[n-1-i]
     ans%=mod
   print(ans)
 else:
   ans=1
   cnt=0
   for i in range(k): #絶対値の大きい順にK個掛け合わせる
     if arr[i]<0: #負数を掛けた回数を数えておく
       cnt+=1
     ans*=arr[i]
     ans%=mod
   if cnt%2==0: #負数を偶数回掛けていれば答えは非負なのでそのまま出力
     print(ans)
   else: #そうでなければ調整を行う
     min_plus=-1
     min_minus=1
     for i in range(k): #絶対値の大きい順にK個を見て最小の非負の数・負の数を探す
       if arr[i]>=0:
         min_plus=arr[i]
       else:
         min_minus=arr[i]
     max_plus=-1
     max_minus=1
     for i in range(k,n): #残るN-K個を見て最大の非負の数・負の数を探す
       if arr[i]>=0 and max_plus==-1:
         max_plus=arr[i]
       if arr[i]<0 and max_minus==1:
         max_minus=arr[i]
     if min_plus==-1: #もし最小の非負の数がなければ、最小の負の数を取り除くしかない
       arr.remove(min_minus)
       ans=1
       for i in range(k-1):
         ans*=arr[i]
         ans%=mod
       ans*=max_plus
       ans%=mod
     elif min_minus==1: #もし最小の負の数がなければ、最小の非負の数を取り除くしかない
       arr.remove(min_plus)
       ans=1
       for i in range(k-1):
         ans*=arr[i]
         ans%=mod
       ans*=max_minus
       ans%=mod
     elif min_plus*max_plus>=min_minus*max_minus: #そうでなければより倍率の大きいほうを選ぶ
       arr.remove(min_minus)
       ans=1
       for i in range(k-1):
         ans*=arr[i]
         ans%=mod
       ans*=max_plus
       ans%=mod
     else:
       arr.remove(min_plus)
       ans=1
       for i in range(k-1):
         ans*=arr[i]
         ans%=mod
       ans*=max_minus
       ans%=mod
     print(ans)
Problem p02687 (python)

Fixed submission:
# coding: utf-8
S=input()
if S =="ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
S=input()
if S ="ABC":
    print("ARC")
else:
    print("ABC")
Problem p03433 (python)

Fixed submission:
# coding: utf-8
N = int(input())
A = int(input())

c = N%500

if c > A:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
N = int(input())
A = int(input())

c = N%A

if c > A:
    print("No")
else:
    print("Yes")
Problem p02755 (python)

Fixed submission:
import math
a, b = map(int, input().split())

for i in range(1300):
  if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
    print(i)
    exit()
print('-1')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
C = []
D = []
for i in range(100):
  if math.floor(i*0.08) == a:
    C.append(i)
  if math.floor(i*0.1) == b:
    D.append(i)
if list(set(C) & set(D)):
  print('-1')
else:
  print(list(set(C) & set(D)))
Problem p02765 (python)

Fixed submission:
N, R = map(int, input().split())
if N < 10:
    print(100*(10-N) + R)
else:
    print(R)

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().split())
if N < 10:
    print(100*(10-K) + R)
else:
    print(R)
Problem p02768 (python)

Fixed submission:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,a,b = nm()
mod = 10**9 + 7
s = pow(2,n,mod) - 1

def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

print((s - fur(n,a) - fur(n,b)) % mod)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
from math import factorial
N = 10**9+7
def combinations_count(n, r, N):
    ''' 組み合わせ '''
    return (factorial(n) // (factorial(n - r) * factorial(r)) ) % N

lis = list(range(1, a+1))
lis.remove(a)
lis.remove(b)

data1 = list(map(combinations_count, lis))
print(lis)
print(combinations_count(5, 2, N))
Problem p02842 (python)

Fixed submission:
import math
N = int(input())
A = N/1.08 
B = (N+1)/1.08 

if math.ceil(N/1.08) < math.ceil((N+1)/1.08 ):
  print(math.ceil(N/1.08))
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = N/1.08 
B = (N+1)/1.08 

if math.ceil(A) < math.ceil(B):
  print(ceil(A))
else:
  print(':(')
Problem p03210 (python)

Fixed submission:
N = int(input())
if N ==3 or N==5 or N==7:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
if N==3 || N==5 || N==7:
  print "YES"
else:
  print"NO"
Problem p03729 (python)

Fixed submission:
a, b,c = map(str, input().split())
if a[-1]==b[0] and b[-1]==c[0]:
  print('YES')
  exit()
print('NO')

Buggy submission (verdict: Runtime Error):
a, b,c = map(str, input().split())
if a[-1]==b[1] and b[-1]==c[1]:
  print('YES')
  exit()
print('NO')
Problem p03085 (python)

Fixed submission:
a = input()
if a == "T":
  print("A")
elif a=="A":
  print("T")
elif a=="C":
  print("G")
else:
  print("C")

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	switch(a){
		case "A":cout<<"T"<<endl;break;
		case "T":cout<<"A"<<endl;break;
		case "C":cout<<"G"<<endl;break;
		case "G":cout<<"C"<<endl;break;
	}
	return 0;
}

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	switch(a){
		case "A":cout<<"T"<<endl;
		case "T":cout<<"A"<<endl;
		case "C":cout<<"G"<<endl;
		case "G":cout<<"C"<<endl;
	}
	return 0;
}
Problem p03759 (python)

Fixed submission:
a,b,c = (int(x) for x in input().split())

if b-a==c-b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = (int(x) for x in input().split())

if b-a=c-b:
    print("YES")
else:
    print("NO")
Problem p02732 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()