Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
import collections

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

for i in range(n):
    _a = np.delete(a, i)
    c_dict = collections.Counter(_a)
    total = 0
    for v in c_dict.values():
        if v >= 2:
            total += v * (v - 1) / 2
            
    print(int(total))

Fixed submission:
import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Buggy python submission (verdict: Runtime Error):
import numpy as np 
import collections

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

for i in range(n):
    _a = np.delete(a, i)
    c_dict = collections.Counter(_a)
    total = 0
    for v in c_dict.values():
        if v >= 2:
            total += v * (v - 1) / 2
            
    flag[i] = 1
    print(int(total))

Fixed submission:
import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
import collections

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

for i in range(n):
    _a = np.delete(a, i)
    c_dict = collections.Counter(_a)
    total = 0
    for v in c_dict.values():
        if v >= 2:
            total += v * (v - 1) / 2
    print(int(total))

Fixed submission:
import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 

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

for i in range(n):
    _a = np.delete(a, i)
    unique = np.unique(_a)
    for j in range(len(unique)):
        k = np.count_nonzero(_a == unique[j])
        if j == 0:
            if k >= 2:
                total = k * (k - 1) / 2 
            else:
                total = 0
        else:
            if k >= 2:
                total += k * (k - 1) / 2 
    print(int(total))

Fixed submission:
import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
n = int(input())
a = np.array(list(map(int, input().split())))
for i in range(n):
    np.delete(a, i)
    _a = np.delete(a, i)
    unique = np.unique(_a)
    for j in range(len(unique)):
        k = np.count_nonzero(_a == unique[j])
        if j == 0:
            if k >= 2:
                total = k * (k - 1) / 2 
            else:
                total = 0
        else:
            if k >= 2:
                total += k * (k - 1) / 2 
    print(int(total))

Fixed submission:
import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))