Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

R,G,B,N = map(int,input().split()) 

ans = 0
tmp1 = N//R + 1

for i in range(tmp1):
    tmp2 = (N - R*i)//G + 1
    for j in range(tmp2):
        tmp3 = (N - R*i - G*j)//B + 1
        for k in range(tmp3):
            if R*i+G*j+B*k == N:
                ans += 1



print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

R,G,B,N = map(int,input().split()) 

ans = 0
tmp1 = N//R + 1

for i in range(tmp1):
    tmp2 = (N - R*i)//G + 1
    for j in range(tmp2):
        if (N - R*i - G*j)%B == 0:
            ans += 1



print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

ans = X[M-1] - X[0]
tmp = []

for i in range(1,M):
    tmp2 = X[i] - X[i-1]
    if len(tmp) < N-1:
        tmp.append(tmp2)
    else:
        tmp3 = min(tmp)
        if tmp3 < tmp2:
            tmp.remove(tmp3)
            tmp.append(tmp2)

print(ans - sum(tmp))

Fixed submission:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M = map(int, input().split())
X = list(map(int, input().split()))


X.sort()

ans = X[M-1] - X[0]
tmp = []

if N==1:
    print(ans)
    sys.exit()


for i in range(1,M):
    tmp2 = X[i] - X[i-1]
    if len(tmp) < N-1:
        tmp.append(tmp2)
    else:
        tmp3 = min(tmp)
        if tmp3 < tmp2:
            tmp.remove(tmp3)
            tmp.append(tmp2)

print(ans - sum(tmp))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M=map(int, input().split())

if N==1 and M==1:
    print(0)
    sys.exit()

if N==1 and M==2:
    print(2)
    sys.exit()

if N==2 and M==1:
    print(2)
    sys.exit()

if N==1:
    print(M-2)
    sys.exit()

if M==1:
    print(N-2)
    sys.exit()

print((N-2)*(M-2))

oo

Fixed submission:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M=map(int, input().split())

if N==1 and M==1:
    print(1)
    sys.exit()

if N==1:
    print(M-2)
    sys.exit()

if M==1:
    print(N-2)
    sys.exit()

print((N-2)*(M-2))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for _ in range(M)]

H = 3
C = [list(map(int, input().split())) for _ in range(H)]

a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]

if !((C[1][0]-b1) == (C[1][1]-b2) and (C[1][1]-b2) == (C[1][2]-b2)):
    print("No")
    sys.exit()

if !((C[2][0]-b1) == (C[2][1]-b2) and (C[2][1]-b2) == (C[2][2]-b2)):
    print("No")
    sys.exit()

print("Yes")

Fixed submission:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for _ in range(M)]

C = [list(map(int, input().split())) for _ in range(3)]
 
Dif_H = [[] for _ in range(3)]
Dif_V = [[] for _ in range(3)]
 
for i in range(3):
    Dif_H[i] = [C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]]
for i in range(3):
    Dif_V[i] = [C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]]
 
if Dif_H[0] == Dif_H[1] == Dif_H[2] and Dif_V[0] == Dif_V[1] == Dif_V[2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
A = [int(input()) for _ in range(N)]
C = collections.Counter(A)
data = C.values()

ans = 0

for i in range(len(data)):
    if data[i] % 2 == 1:
        ans+=1

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
A = [int(input()) for _ in range(N)]
C = collections.Counter(A)
data = list(C.values())

ans = 0

for i in range(len(data)):
    if data[i] % 2 == 1:
        ans+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

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

B = []

for i in range(N):
    if i%2 == 0:
        B.append(A[i])
    else:
        B.insert(0,A[i])

if N%2 == 1:
    B.reverse()

print(B[0],end="")
for i in range(1,N):
    print("",B[i],end="")

Fixed submission:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

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

B=[0]*N

for i in range(N):
  if i<(N+1)//2:
    B[i]=A[N-1-2*i]
  else:
    B[i]=A[N-2*(N-i)]

print(*B)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

ans = [0,0,0,0,0,0,0,0]
tmp = 0

for i in A:
    if A[i] >= 3200:
        tmp += 1
    else:
        ans[A[i]//400] = 1

print(max(1,sum(ans)),min(8,sum(ans)+tmp))



Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

ans = [0,0,0,0,0,0,0,0]
tmp = 0

for i in range(0,N):
    if A[i] >= 3200:
        tmp += 1
    else:
        ans[A[i]//400] = 1

print(max(1,sum(ans)),sum(ans)+tmp)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S = input()

## Logic

S = S[::-1]
print(S)

i = 0 
while i < len(S):
    if [i:i+7]=="remaerd":
        i = i + 7
    elif [i:i+6]=="resare":
        i = i + 6
    elif [i:i+5]=="maerd":
        i = i + 5
    elif [i:i+5]=="esare":
        i = i + 5
    else:
        print("NO")
        sys.exit()
print("YES")

Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S = input()

## Logic

S = S[::-1]

i = 0 
while i < len(S):
    if S[i:i+7]=="remaerd":
        i = i + 7
    elif S[i:i+6]=="resare":
        i = i + 6
    elif S[i:i+5]=="maerd":
        i = i + 5
    elif S[i:i+5]=="esare":
        i = i + 5
    else:
        print("NO")
        sys.exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N,A,B=map(int, input().split())
S = input()
tmp1 = 0
tmp2 = 0

for i in range(0,N):
    if tmp1 < A+B:
        if S[i] == "a":
            tmp1 += 1
            print("Yes")
        elif S[i] == "b" & tmp2 < B:
            tmp1 += 1
            tmp2 += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N,A,B=map(int, input().split())
S = input()
tmp1 = 0
tmp2 = 0

for i in range(0,N):
    if tmp1 < A+B:
        if S[i] == "a":
            tmp1 += 1
            print("Yes")
        elif (S[i] == "b") & (tmp2 < B):
            tmp1 += 1
            tmp2 += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
def dfs(lis,cnt,n):
    if sum(lis)>100:
        return cnt
 
    if(len(lis)==3):
        ans=lis[0]**2+lis[1]**2+lis[2]**2+lis[0]*lis[1]+lis[1]*lis[2]+lis[2]*lis[0]
        if(ans==n):
            cnt+=1
        return cnt
    
    for v in range(1,100):
        lis.append(v)
        cnt=dfs(lis,cnt,n)
        lis.pop()
    
    return cnt
 
 
n= int(input())
for i in range(1,n+1):
    cnt = 0
    print(dfs([],cnt,i))

Fixed submission:
l,r,d = map(int,input().split())
cnt=0
for i in range(l,r+1):
    if i%d == 0:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
x,n  = map(int,input().split())
if(n==0):
    print(x)
else:

    p = list(map(int,input().split()))
    l = list(range(1,101))

    rl =  set(l)-set(p)
    m = 100
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

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

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Buggy python submission (verdict: Runtime Error):
x,n  = map(int,input().split())
if(n==0):
    print(x)
else:

    p = list(map(int,input().split()))
    l = list(range(1,101))

    rl =  set(l) - set(p)
    m = max(p)
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

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

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Buggy python submission (verdict: Runtime Error):
x,n  = map(int,input().split())
if(n==0):
    print(x)
else:

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

    l = list(range(min(p),max(p)+1))

    rl =  set(l) - set(p)
    m = max(p)
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

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

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Buggy python submission (verdict: Runtime Error):
def resolve():
x,n  = map(int,input().split())
if(n==0):
    print(x)
    exit

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

l = list(range(min(p),max(p)+1))

rl =  set(l) - set(p)
m = max(p)
for i in  rl:
    if(abs(i-x) < m):
        m = abs(i-x)
        ans = i
print(ans)

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

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Buggy python submission (verdict: Runtime Error):
x,n  = map(int,input().split())
if(n==0):
    print(x)
    return

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

l = list(range(min(p),max(p)+1))

rl =  set(l) - set(p)
m = max(p)
for i in  rl:
    
    if(abs(i-x) < m):
        m = abs(i-x)
        ans = i

print(ans)

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

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i],b[i] = map(int,input().split())

z = zip(a,b)
lis = [i for i in range(1,n+1)]
cnt = n

for i,j in z:
    if h[i-1] > h[j-1]:
        if j in lis:
            lis.remove(j)
            cnt -= 1
    elif h[j-1] > h[i-1]:
        if i in lis:
            lis.remove(i)
            cnt -= 1
    else:
        if j in lis:
            lis.remove(j)
            cnt -= 1
        if i in lis:
            lis.remove(i)
            cnt -= 1

print(cnt)

Fixed submission:
import collections

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

z = zip(a,b)
lis = [0]*n

for i,j in z:

    if h[i-1] > h[j-1]:
        lis[j-1] = 1
    elif h[i-1] < h[j-1]:
        lis[i-1] = 1
    else:
        lis[i-1]=1
        lis[j-1]=1

print(collections.Counter(lis)[0])
Buggy python submission (verdict: Runtime Error):
a,b,c,d  = map(int,input().split())
for i in range(1,1000):
    if(i%2!=0):
        c -= b
    else:
        a -= d
    
    if(a<=0):
        print("No")
        return
    elif(c<=0):
        print("Yes")
        return

Fixed submission:
a,b,c,d  = map(int,input().split())
for i in range(1,1000):
    if(i%2!=0):
        c -= b
    else:
        a -= d
    
    if(a<=0):
        print("No")
        break
    elif(c<=0):
        print("Yes")
        break
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            cnt +=  math.gcd(k,math.gcd(i,j))

print(cnt)

Fixed submission:
import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            cnt +=  math.gcd(k,t)

print(cnt)

Buggy python submission (verdict: Runtime Error):

from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):

            cnt += gcd(i,j,k)

print(cnt)

Fixed submission:
import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            cnt +=  math.gcd(k,t)

print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):

            cnt += gcd(i,j,k)

print(cnt)

Fixed submission:
import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            cnt +=  math.gcd(k,t)

print(cnt)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from itertools import combinations

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        if(i==j):
            cnt += i
        else:
            cnt += gcd(i,i,j)*3

if(n>=3):
    my_list = list(range(1,n+1))
    x = combinations(my_list, 3)

    list_x = list(x)
    for i in list_x:
        cnt+= gcd(i[0],i[1],i[2])

print(cnt)


Fixed submission:
import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            cnt +=  math.gcd(k,t)

print(cnt)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from itertools import combinations

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        if(i==j):
            cnt += i
        else:
            cnt += gcd(i,i,j)*3

print(cnt)
if(n>=3):
    my_list = list(range(1,n+1))
    x = combinations(my_list, 3)


    list_x = list(x)
    for i in list_x:
        cnt+= gcd(i[0],i[1],i[2])

print(cnt)

Fixed submission:
import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            cnt +=  math.gcd(k,t)

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import collections 
import math
import copy

def combinations_count(n, r):
    if(n<r):
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

cnt=0
c =collections.Counter(a) #要素の数

#全体の式の導出
#今回は要素ごとの組み合わせの数

for i in c.values() :
    cnt += combinations_count(i,2)

#各要素の影響を排除して出力
for i in a:
    print(cnt- combinations_count(c[i],2) +combinations_count(c[i]-1,2))


Fixed submission:
import collections 
import math

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

cnt=0
c =collections.Counter(a) #要素の数

#全体の式の導出
#今回は要素ごとの組み合わせの数

for i in c.values() :
    cnt += i*(i-1)//2

#各要素の影響を排除して出力
for i in a:
    print(cnt- c[i]*(c[i]-1)//2 + (c[i]-1)*(c[i]-2)//2)