Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a , b , c , d = input().split()

a=int(a)
b=int(b)
c=int(c)
d=int(d)

while True:
  c -= b
  if c <= 0:
    print('Yes')
    break
  a -= d
  if a <= 0:
    print('No')
    break



Fixed submission:
a ,b = input().split()

a=int(a)
b=int(b)
if a>b:
	print('safe')
else:
	print('unsafe')
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
i = 0
while i < k and s[i] == '1':
    i += 1
print(s[i])


Fixed submission:
s = input()
k = int(input()) - 1
i = 0
while i < k and s[i] == '1':
    i += 1
print(s[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n&1:
    print(2*n)
else
    print(n)


Fixed submission:
n = int(input())
if n&1:
    print(2*n)
else:
    print(n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
print(max([len(set(s[:x])&set(s[x:])) for x in range(1,n-1)]))


Fixed submission:
n = int(input())
s = input()
print(max([len(set(s[:x])&set(s[x:])) for x in range(1,n)]))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import itertools
import math

    
def my_generator(C):
    for v in itertools.permutations(C):
        yield v


def check(C):
    A = [0 for i in range(M+1)]
    for i in range(N):
        A = [a + b for a, b in zip(A, C[i])]
        b = [i for i in range(M+1) if A[i] < X]
        if len(b) == 0:
            return A[0]
    else:
        print(-1)
        exit()

N, M, X = map(int, input().split())

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

genlst = my_generator(C)
lenn = math.factorial(N)
m = 0
for i in range(lenn):
    C = next(genlst)

    if i == 0:
        m = check(C)
    else:
        m = min(m, check(C))
print(m)

Fixed submission:
# coding: utf-8
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
n = len(C)
m = -1
for i in range(2 ** n):
    A = [0 for i in range(M+1)]
    total = 0
    for j in range(n):
        if((i >> j) & 1):
            A = [a + b for a, b in zip(A, C[j])]
            B = [k for k in range(1, M+1) if A[k] < X]
            if len(B) == 0:
                if m == -1:
                    m = A[0]
                else:
                    m = min(m, A[0])
                break
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import itertools
import math


def my_generator(C):
    for v in itertools.permutations(C):
        yield v

def python_list_add(A, C):
    return [a + b for a, b in zip(A, C)]

def check(A, C):
    m = 0
    for i in range(N):
        m += C[i][0]
        A = python_list_add(A, C[i])
        # print("A", A)
        b = [i for i in range(M+1) if A[i] < X]
        # print("b", b)
        if len(b) == 0:
            return m
    else:
        print(-1)
        exit()

N, M, X = map(int, input().split())

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

genlst = my_generator(C)
lenn = math.factorial(N)
m = ["" for i in range(lenn)]
for i in range(lenn):
    C = next(genlst)
    A = [0 for i in range(M+1)]
    m[i] = check(A, C)
print(min(m))


Fixed submission:
# coding: utf-8
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
n = len(C)
m = -1
for i in range(2 ** n):
    A = [0 for i in range(M+1)]
    total = 0
    for j in range(n):
        if((i >> j) & 1):
            A = [a + b for a, b in zip(A, C[j])]
            B = [k for k in range(1, M+1) if A[k] < X]
            if len(B) == 0:
                if m == -1:
                    m = A[0]
                else:
                    m = min(m, A[0])
                break
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N, M = map(int, input().split())
H = list(map(int, input().split()))
lst = [list(map(int, input().split())) for _ in range(M)]

lst2 = [[] for i in range(N)]

for j in range(M):
    for i in range(N):
        if i+1 in lst[j]:
            if lst[j][0] == i+1:
                lst2[i].append(H[lst[j][1]-1])
            else:
                lst2[i].append(H[lst[j][0]-1])

num = N
for i in range(N):

    if len(lst2[i]) == 0:
        continue

    if H[i] <= max(lst2[i]):
        num -= 1

print(num)


Fixed submission:
# coding: utf-8
N, M = map(int, input().split())
H = list(map(int, input().split()))

lst = [1 for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        lst[A-1] = 0
    if H[B-1] <= H[A-1]:
        lst[B-1] = 0

print(sum(lst))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
X = int(input())

for i in range(1000000000):
    for j in range(-10000, 100000):
        if i ** 5 - j ** 5 == X:
            print(i, j)
            exit()

Fixed submission:
# coding: utf-8
X = int(input())

for i in range(-118, 120):
    for j in range(-119, 119):
        if i ** 5 - j ** 5 == X:
            print(i, j)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import math
A, B, N = map(int, input().split())
tmp = 0
ans = 0
for i in range(1, N+1):
    tmp = math.floor(A * i / B) - A * math.floor(i / B)
    ans = max(tmp, ans)
print(ans)

Fixed submission:
# coding: utf-8
A, B, N = map(int, input().split())

num = min(B-1, N)

print(A * num // B - A * (num // B))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import math
A, B, N = map(int, input().split())
ans = [0 for i in range(N+1)]
for i in range(1, N+1):
    ans[i] = math.floor(A * i / B) - A * math.floor(i / B)
print(max(ans))

Fixed submission:
# coding: utf-8
A, B, N = map(int, input().split())

num = min(B-1, N)

print(A * num // B - A * (num // B))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    print(A.count(i+1))

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
C = [0 for i in range(N)]
A.sort()
i = 0
while i < N - 1:
    C[A[i] - 1] = C[A[i] - 1] + 1
    i += 1

for i in C:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
S = list(input())

R = S.count("R")
G = S.count("G")
B = S.count("B")

ans = R * G * B
count = 0

for i in range(N - 2):
    for j in range(i + 1, N):
        k = j * 2 - i
        if k < N and {S[i], S[j], S[k]} == {"R", "G", "B"}:
            count += 1
ans -= count
print(ans)

Fixed submission:
# coding: utf-8
N = int(input())
S = list(input())

R = S.count("R")
G = S.count("G")
B = S.count("B")

ans = R * G * B
count = 0

for i in range(N - 2):
    for j in range(i + 1, N):
        k = j * 2 - i
        if k >= N:
            break
        if {S[i], S[j], S[k]} == {"R", "G", "B"}:
            count += 1
ans -= count
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import sympy

a, b, c = map(int, input().split())
# print(a, b, c)

if sympy.sqrt(a) + sympy.sqrt(b) < sympy.sqrt(c):
    print('Yes')
else:
    print('No')

Fixed submission:
# coding: utf-8

a, b, c = map(int, input().split())
# print(a, b, c)

if 0 < c - a - b and 4 * a * b < (c - a - b)**2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
elif N <= A + B:
    print(A)
else:
    lst = np.array([1 for i in range(A)])
    # print(lst)
    lst2 = np.array([0 for i in range(B)])
    # print(lst2)
    lst3 = np.append(lst, lst2)
    # print(lst3)
    while lst3.size <= N:
        lst3 = np.append(lst3, lst3)
    lst3 = lst3[:N]
    print(np.count_nonzero(lst3 == 1))

Fixed submission:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np
N, A, B = map(int, input().split())
print("N:", N, "A:", A, "B:", B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
elif N <= A + B:
    print(A)
else:
    lst = np.array([1 for i in range(A)])
    # print(lst)
    lst2 = np.array([0 for i in range(B)])
    # print(lst2)
    lst3 = np.append(lst, lst2)
    # print(lst3)
    while lst3.size < N:
        lst3 = np.append(lst3, lst3)
    lst3 = lst3[:N]
    print(np.count_nonzero(lst3 == 1))

Fixed submission:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
lst = []
i = 0
while i < N:
    for j in range(A):
        lst.append("b")
        i += 1
    for k in range(B):
        lst.append("r")
        i += 1
# print("lst:", lst)
lst = lst[:N]
# print("lst:", lst)
print(lst.count('b'))

Fixed submission:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
S = input()
Q = int(input())
# print("S:", S, "Q:", Q)

lst = [input() for _ in range(Q)]
# print(lst)
flg = True
# print(S)
for i in lst:
    # print("i[0]:", i[0])
    if i[0] == '1':
        flg = not flg
    else:
        # print("i[2]:", i[2])
        # print("i[4]:", i[4])
        if flg == False:
            if i[2] == '1':
                S = S + i[4] 
                # print(S)
            else:
                S = i[4] + S
                # print(S)
        else:
            if i[2] == '1':
                S = i[4] + S
                # print(S)
            else:
                S = S + i[4]
                # print(S)
if flg == False:
    print(S[::-1])
else:
    print(S)

Fixed submission:
# coding: utf-8
S = input()
Q = int(input())
# print("S:", S, "Q:", Q)

lst = [input() for _ in range(Q)]
# print("lst:", lst)
flg = True
# print("S:", S)
left = ""
right = ""
for i in lst:
    if i[0] == '1':
        flg = not flg
    else:
        if flg == False:
            if i[2] == '1':
                right = right + i[4] 
                # print("right:", right)
            else:
                left = i[4] + left
                # print("left:", left)
        else:
            if i[2] == '1':
                left = i[4] + left
                # print("left:", left)
            else:
                right = right + i[4]
                # print("right:", right)
S = left + S + right
if flg == False:
    print(S[::-1])
else:
    print(S)
Buggy python submission (verdict: Runtime Error):
def cal(lst1, lst2, lst3):
    for i in range(3):
        if lst1[i] in lst3:
            lst2[i] = 1

def judge(a, b, c):
    if a == 1 and (a == b == c):
        return True
    else:
        return False

A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]
C_1 = [0, 0, 0]
C_2 = [0, 0, 0]
C_3 = [0, 0, 0]
cal(A_1, C_1, b)
cal(A_2, C_2, b)
cal(A_3, C_3, b)

a, b, c, d, e, f, g, h = False
# 縦
a = judge(C_1[0], C_2[0], C_3[0])
b = judge(C_1[1], C_2[1], C_3[1])
c = judge(C_1[2], C_2[2], C_3[2])

# 横
d = judge(C_1[0], C_1[1], C_1[2])
e = judge(C_2[0], C_2[1], C_2[2])
f = judge(C_3[0], C_3[1], C_3[2])

g = judge(C_1[0], C_2[1], C_3[2])
h = judge(C_1[2], C_2[1], C_3[0])

lst = [a, b, c, d, e, f, g]

if True in lst:
    print('Yes')
else:
    print('No')

Fixed submission:
def cal(lst1, lst2):
    lst3 = [0, 0, 0]
    for i in range(3):
        if lst1[i] in lst2:
            lst3[i] = 1
    return lst3

def judge(a, b, c):
    if (a == 1) and (a == b == c):
        return True
    else:
        return False

A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

C_1 = []
C_2 = []
C_3 = []

C_1 = cal(A_1, b)
C_2 = cal(A_2, b)
C_3 = cal(A_3, b)

a = judge(C_1[0], C_2[0], C_3[0])
b = judge(C_1[1], C_2[1], C_3[1])
c = judge(C_1[2], C_2[2], C_3[2])

d = judge(C_1[0], C_1[1], C_1[2])
e = judge(C_2[0], C_2[1], C_2[2])
f = judge(C_3[0], C_3[1], C_3[2])

g = judge(C_1[0], C_2[1], C_3[2])
h = judge(C_1[2], C_2[1], C_3[0])

lst = [a, b, c, d, e, f, g, h]

if True in lst:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
lst = [i[0]*i[1] for i in itertools.combinations(A,2)]
lst.sort()
print(lst[K - 1])

Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array([int(i) for i in input().split()])
A.sort()

A_max = max(np.abs(A))
A_minus = A[A<0]
A_zero = A[A==0]
A_plus = A[A>0]

def check(x):
    ret = 0
    if x >= 0:
        ret += N * len(A_zero)
    ret += np.searchsorted(A, x // A_plus, side='right').sum()
    ret += (N - np.searchsorted(A, -(x // -A_minus))).sum()
    ret -= np.count_nonzero(A * A <= x)
    return ret // 2

right = A_max * A_max
left = -right - 1
while (right - left > 1):
    middle = (right + left) >> 1
    if check(middle) < K:
        left = middle
    else:
        right = middle
print(right)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))
lst = [i[0]*i[1] for i in itertools.combinations(A,2)]
lst.sort()
print(lst[K - 1])

Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array([int(i) for i in input().split()])
A.sort()

A_max = max(np.abs(A))
A_minus = A[A<0]
A_zero = A[A==0]
A_plus = A[A>0]

def check(x):
    ret = 0
    if x >= 0:
        ret += N * len(A_zero)
    ret += np.searchsorted(A, x // A_plus, side='right').sum()
    ret += (N - np.searchsorted(A, -(x // -A_minus))).sum()
    ret -= np.count_nonzero(A * A <= x)
    return ret // 2

right = A_max * A_max
left = -right - 1
while (right - left > 1):
    middle = (right + left) >> 1
    if check(middle) < K:
        left = middle
    else:
        right = middle
print(right)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))
num = 1
if num not in a:
    print(-1)
    exit()
else:
    while len(a) >= 1:
        if num in a:
            a = a[a.index(num) +1 :]
            num += 1
    else:
        print(N - num + 1)

Fixed submission:
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))
num = 0
for i in range(N):
    if a[i] == num + 1:
        num += 1
if num == 0:
    print(-1)
else:
    print(N - num)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N+1):
    print(A.index(i)+1, end=" ")
print()

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

lst = [0 for i in range(N)]
for i in range(N):
    lst[A[i]-1] = i+1

print(' '.join(map(str, lst)))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
lst = [A.index(i)+1 for i in range(1, N+1)]
print(' '.join(map(str, lst)))


Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

lst = [0 for i in range(N)]
for i in range(N):
    lst[A[i]-1] = i+1

print(' '.join(map(str, lst)))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
N = int(input())
B = list(map(int, input().split()))
A = B
A.insert(0, B[0])
for i in range(1, N - 1):
    if A[i] == 0:
        A[i + 1] = A[i+2]
print(sum(A))

Fixed submission:
# coding: utf-8
N = int(input())
B = list(map(int, input().split()))
A = B
A.insert(0, B[0])
for i in range(1, N - 1):
    if A[i] > A[i+1]:
        A[i] = A[i+1]
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    B = A[:i] + A[i+1:]
    print(max(B))

Fixed submission:
# coding: utf-8
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A)
for i in range(N):
    if A[i] != B[-1]:
        print(B[-1])
    else:
        print(B[-2])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
B = set()
for i in range(M):
  L, R = map(int, input().split())
  A = set(j for j in range(L, R+1))
  if i == 0:
    B = A
  B = A & B
print(len(B))


Fixed submission:
N, M = map(int, input().split())
maxL = 1
minR = N
for i in range(M):
  L, R = map(int, input().split())
  maxL = max(maxL, L)
  minR = min(minR, R)
print(max(minR - maxL +1, 0))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
B = set()
for i in range(M):
  L, R = map(int, input().split())
  A = set(for j in range(L, R+1))
  if i == 0:
    B = A
  B = A & B
print(len(B))

Fixed submission:
N, M = map(int, input().split())
maxL = 1
minR = N
for i in range(M):
  L, R = map(int, input().split())
  maxL = max(maxL, L)
  minR = min(minR, R)
print(max(minR - maxL +1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if i < A + K or i > B - K:
        print(i)

Fixed submission:
# coding: utf-8
A, B, K = map(int, input().split())
a = set(i for i in range(A, min(A + K, B + 1)))
b = set(j for j in range(max(B - K + 1, A), B + 1))
c = list(a | b)
c.sort()
for k in c:
    print(k)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())

for i in range(a):
	if a % 10 == 9:
		print("Yes")
        print(a)
    a = a / 10
    print(a)
#	b, c = map(int, input().split())
#	d = c - b + 1
#	e += d


Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
flg = 0
while a > 0:
	if a % 10 == 9:
		print("Yes")
		flg = 1
		break
	else:
		a = int(a / 10)
if flg == 0:
	print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
b = set()
for i in range(a):
	b ^= {input()}
	print(b)
print(len(b))

Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
b = set()
for i in range(a):
	b ^= {input()}
print(len(b))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
a = int(input())
numlist = []
for i in range(a):
	b = int(input())
	if b in numlist:
		numlist.remove(b)
	else:
		numlist.append(b)
print(len(numlist))

Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
b = set()
for i in range(a):
	b ^= {input()}
print(len(b))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
a = int(input())
numlist = []
for i in range(a):
	b = int(input())
	if b in numlist:
		numlist.remove(b)
	else:
		numlist.append(b)
print(len(numlist))

Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
b = set()
for i in range(a):
	b ^= {input()}
print(len(b))
Buggy python submission (verdict: Runtime Error):
w = list(input())
w.sort()
i = 0
if len(w) % 2 == 1:
    print('No')
    exit()

while i < len(w)-1:
	if w[i] != w[i+1]:
	    print('No')
            exit()
	i += 2
else:
	print('Yes')

Fixed submission:
w = list(input())
w.sort()
i = 0
if len(w) % 2 == 1:
    print('No')
    exit()

while i < len(w)-1:
	if w[i] != w[i+1]:
		print('No')
		exit()
	i += 2
else:
	print('Yes')

Buggy python submission (verdict: Runtime Error):
w = list(input())
w.sort()
i = 0
while i < len(w):
	if w[i] != w[i+1]:
		print('No')
		exit()
	i += 2
else:
	print('Yes')

Fixed submission:
w = list(input())
w.sort()
i = 0
if len(w) % 2 == 1:
    print('No')
    exit()

while i < len(w)-1:
	if w[i] != w[i+1]:
		print('No')
		exit()
	i += 2
else:
	print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
a, b = map(int, input().split())
c = [i for i in range(a, b+1)]

if a <= 0 and b >= 0:
    print("Zero")
elif b < 0 and (a - b) % 2 == 0:
    print("Negative")
else:
    print("Positive")

Fixed submission:
# coding: utf-8
a, b = map(int, input().split())

if a <= 0 and b >= 0:
    print("Zero")
elif b < 0 and (a - b) % 2 == 0:
    print("Negative")
else:
    print("Positive")
Buggy python submission (verdict: Runtime Error):
N, K = map( int, input().split() )
 
now_N = 10 ** 19
while True:
  N = min( abs( N % K ),abs( K - N ),, now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )

Fixed submission:
N, K = map( int, input().split() )
 
now_N = 10 ** 19
while True:
  N = min( abs( N % K ),abs( K - N ), now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map( int, input().split() )

now_N = 10 ** 19
while True:
  N = min( abs( N - K ), now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )

Fixed submission:
N, K = map( int, input().split() )
 
now_N = 10 ** 19
while True:
  N = min( abs( N % K ),abs( K - N ), now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )
Buggy python submission (verdict: Time Limit Exceeded):
n = int( input())
a_s = list( map(int, input().split()))

def count_suru( list_desu ):
  points = [0] * ( n + 1 )
  for a in list_desu:
    points[a] += 1
  ret = 0
  for p in points:
    ret += ( p * ( p - 1 ) ) // 2
  return ret

for i in range( n ):
  print( count_suru( a_s[:i] + a_s[i+1:]  ) )


Fixed submission:
N = int( input())
A = list( map( int, input().split()))
L = [0] * N

for a in A:
  L[ a - 1 ] += 1

s = 0
for i in range( N ):
  l = L[ i ]
  if l > 0:
    s += ( l - 1 ) * l // 2

for i in range( N ):
  print( s - ( L[ A[ i ] - 1 ] - 1 ))
Buggy python submission (verdict: Runtime Error):
n, a, b = map( int, input().split() )
max_mod =10 ** 9 + 7

r_1 = a
n_r_1 = ( n - a )
r_2 = b
n_r_2 = ( n - b )
n_ = 1
N = n % max_mod
for i in range( 1, N + 1 ):
  n_ *= i
  n_ %= max_mod
  if i == r_1:
    r_1 = n_
  if i == n_r_1:
    n_r_1 = n_
  if i == r_2:
    r_2 = n_
  if i == n_r_2:
    n_r_2 = n_
    
k_1 = n_ // ( r_1 * n_r_1 )
k_2 = n_ // ( r_2 * n_r_2 )
x = pow( 2, n, max_mod ) - 1
x -= ( k_1 + k_2 ) 
print( x )

Fixed submission:
N, A, B = map( int, input().split() )
MOD = 10 ** 9 + 7

def combi( n, r ):
  r = min( n - r, r )
  a = 1
  b = 1
  for i in range( 1, r + 1 ):
    a = ( a * ( n - i + 1 )) % MOD
    b = ( b * i ) % MOD

  return ( a * pow( b, MOD - 2, MOD )  % MOD ) 

n1 = combi( N, A )
n2 = combi( N, B )
ans = ( pow( 2, N, MOD ) - n1 - n2 - 1 ) % MOD
print( ans )
Buggy python submission (verdict: Time Limit Exceeded):
n = int( input() )
a = list( map( int, input().split() ) )

exsit = []

ans = "YES"
for i in a:
  if i in exsit:
    ans = "NO"
    break
  else:
    exsit.append( i )

print( ans )

Fixed submission:
n = int( input() )
a = set( map( int, input().split() ) )

if n == len(a):
  ans = "YES"
else:
  ans = "NO"

print( ans )
Buggy python submission (verdict: Runtime Error):
n, *p = map( int, open(0).read().split())

cnt = 0
for i in range( 1, len( p )+1):
  p_2 = p[ : i ]
  print( p[i-1], p_2 )
  if p[i-1] == min( p_2 ):
    cnt += 1
print( cnt )


Fixed submission:
n, *p = map( int, open(0).read().split())
 
cnt = 0
min_val = 1000000
for i in range( len( p )):
  if p[i] < min_val:
    cnt += 1
    min_val = p[i]

print( cnt )