Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = tuple([y for idx, y in enumerate(A) if idx != x])
        result = tuple(filter(lambda t: t[0] == t[1], itertools.combinations(tmp, 2)))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)

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

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = tuple([y for idx, y in enumerate(A) if idx != x])
        result = tuple(filter(lambda t: t[0] == t[1], itertools.combinations(tmp, 2)))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)

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

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = [y for idx, y in enumerate(A) if idx != x]
        result = tuple(filter(lambda t: t[0] == t[1], itertools.combinations(tmp, 2)))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)

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

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = [y for idx, y in enumerate(A) if idx != x]
        result = list(filter(lambda t: t[0] == t[1], itertools.combinations(tmp, 2)))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)

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

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = [y for idx, y in enumerate(A) if idx != x]
        result = list(filter(lambda t: t[0] == t[1], list(itertools.combinations(tmp, 2))))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)

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

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = _pickle.loads(_pickle.dumps(A, -1))
        del tmp[x]
        result = list(filter(lambda t: t[0] == t[1], list(itertools.combinations(tmp, 2))))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)

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

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = []
        for idx, y in enumerate(A):
            if idx == x:
                continue
            else:
                tmp.append(y)
        result = list(filter(lambda t: t[0] == t[1], list(itertools.combinations(tmp, 2))))
        print(len(result))


Fixed submission:
import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)