Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * N
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        #print(comb-(nums[A[k]]-1))
        t = nums[A[k]]
        print(comb - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import itertools as iter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * N
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools as iter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools as iter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    
    comb = [0] * (N+1)
    for i in range(N+1):
        comb[i] = len(list(iter.combinations(range(nums[i]), 2)))
    
    for k in range(1, N+1):
        c = comb[:]
        i = A[k-1]
        #print("k",k, "/ num", i)
        c[i] = len(list(iter.combinations(range(nums[i]-1), 2)))
        print(sum(c))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools as iter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    
    comb = [0] * (N+1)
    for i in range(N+1):
        comb[i] = len(list(iter.combinations(range(nums[i]), 2)))
    
    for k in range(1, N+1):
        c = comb[:]
        i = A[k-1]
        #print("k",k, "/ num", i)
        c[i] = len(list(iter.combinations(range(nums[i]-1), 2)))
        print(sum(c))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()