Buggy python submission (verdict: Time Limit Exceeded):


def main():
    import collections

    N = int(input())
    A = list(map(int, input().split()))
    cc = collections.Counter
    # c = collections.Counter(A)
    # iglist = [x for x in c if c[x] == 1]

    # for x in iglist:
    #     A.remove(x)

    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = cc(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):


def main():
    import collections

    N = int(input())
    A = list(map(int, input().split()))
    cc = collections.Counter
    # c = collections.Counter(A)
    # iglist = [x for x in c if c[x] == 1]

    # for x in iglist:
    #     A.remove(x)

    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = cc(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):


def main():
    import collections

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

    c = collections.Counter(A)
    iglist = [x for x in c if c[x] == 1]

    for x in iglist:
        A.remove(x)

    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):


def main():
    import collections

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

    c = collections.Counter(A)
    iglist = [x for x in c if c[x] == 1]

    for x in iglist:
        A.remove(x)

    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):


def main():
    import math
    import collections
    # import numpy as np

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

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

    # As = np.tile(A, (N, 1))
    # As = [A]*N
    # print(As)
    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                # su += combinations_count(pairs, 2)
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):


def main():
    import math
    import collections
    # import numpy as np

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

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

    # As = np.tile(A, (N, 1))
    # As = [A]*N
    # print(As)
    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                # su += combinations_count(pairs, 2)
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):


def main():
    import math
    import collections
    import numpy as np

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

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

    # As = np.tile(A, (N, 1))
    # As = [A]*N
    # print(As)
    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += combinations_count(pairs, 2)
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):


def main():
    import math
    import collections
    import numpy as np

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

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

    As = np.tile(A, (N, 1))

    for i, A in enumerate(As):
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += combinations_count(pairs, 2)
            else:
                break
        print(su)


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math


def main():
    import collections
    import numpy as np

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

    As = np.tile(A, (N, 1))

    for i, A in enumerate(As):
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += combinations_count(pairs, 2)
            else:
                break
        print(su)


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


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):

import math


def main():
    import collections
    import numpy as np

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

    As = np.tile(A, (N, 1))

    for i, A in enumerate(As):
        # tmp_A = ignore(A, k)
        # tmp_A = [a in A: if ]
        A[i] = 0

        # tmp_A = collections.Counter(tmp_A)
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += combinations_count(pairs, 2)
            else:
                break
        print(su)


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




if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

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


def main():
    import collections

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

    for k in range(N):
        tmp_A = ignore(A, k)
        tmp_A = collections.Counter(tmp_A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += combinations_count(pairs, 2)
            else:
                break
        print(su)


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


def ignore(A, i):
    x = copy.copy(A)
    # del x[i]
    # return x
    x[i] = 0
    return x


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

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


def main():
    import collections

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

    for k in range(N):
        tmp_A = ignore(A, k)
        tmp_A = collections.Counter(tmp_A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += combinations_count(pairs, 2)
            else:
                break
        print(su)


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


def ignore(A, i):
    x = copy.copy(A)
    # del x[i]
    # return x
    x[i] = 0
    return x


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

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

import math


def main():
    import collections

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

    for k in range(N):
        tmp_A = ignore(A, k)
        tmp_A = collections.Counter(tmp_A)
        su = 0
        for c in tmp_A:
            pair = tmp_A[c]
            if pair >= 2:
                su += combinations_count(pair, 2)
        print(su)


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


def ignore(A, i):
    x = copy.copy(A)
    # del x[i]
    # return x
    x[i] = 0
    return x


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

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

import math


def main():
    import collections

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

    for k in range(N):
        tmp_A = ignore(A, k)
        tmp_A = collections.Counter(tmp_A)
        su = 0
        for c in tmp_A:
            pair = tmp_A[c]
            if pair >= 2:
                su += combinations_count(pair, 2)
        print(su)


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


def ignore(A, i):
    x = copy.copy(A)
    # del x[i]
    # return x
    x[i] = 0
    return x


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()

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

import math


def main():
    import collections

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

    for k in range(N):
        tmp_A = ignore(A, k)
        tmp_A = collections.Counter(tmp_A)
        su = 0
        for c in tmp_A:
            pair = tmp_A[c]
            if pair >= 2:
                su += combinations_count(pair, 2)
        print(su)


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


def ignore(A, i):
    x = copy.deepcopy(A)
    del x[i]
    return x


if __name__ == '__main__':
    main()


Fixed submission:


def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()