Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import defaultdict

n, x, y = map(int, input().strip().split())

x -= 1
y -= 1

inf = 1000000000
dist = np.full((n, n), inf, dtype=np.int)

for i in range(n):
    for j in range(n):
        if i == j:
            dist[i][j] = 0
        else:
            path1 = abs(j - i)
            path2 = abs(x - i) + 1 + abs(y - j)
            dist[i][j] = min(abs(j - i), path2)

dist_counts = defaultdict(int)
for i in range(n):
    for j in range(i + 1, n):
        d = dist[i][j]
        dist_counts[d] += 1

for k in range(1, n):
    print(dist_counts[k])


Fixed submission:
from collections import defaultdict

n, x, y = map(int, input().strip().split())

x -= 1
y -= 1

dist_counts = defaultdict(int)
for i in range(n):
    for j in range(i + 1, n):
        path1 = abs(j - i)
        path2 = abs(x - i) + 1 + abs(y - j)
        dist = min(abs(j - i), path2)
        dist_counts[dist] += 1

for k in range(1, n):
    print(dist_counts[k])
Buggy python submission (verdict: Runtime Error):
from collections import deque

s = input().strip()
s = deque([*s])
q = int(input())

queries = [input().strip().split() for _ in range(q)]
is_reversed = False

for query in queries:
    t = query[0]
    if t == '1':
        is_reversed = not is_reversed
    else:
        f = query[1]
        c = query[2]
        if f == '1':
            if is_reversed:
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if is_reversed:
                s.appendleft(c)
            else:
                s.append(c)

str_list = list(s)
if is_reversed:
    str_list = reversed(str_list)

ans = ''.join(str_list)
print(ans)


Fixed submission:
from collections import deque

s = input().strip()
s = deque(list(s))
q = int(input())

queries = [input().strip().split() for _ in range(q)]
is_reversed = False

for query in queries:
    t = query[0]
    if t == '1':
        is_reversed = not is_reversed
    else:
        f = query[1]
        c = query[2]
        if f == '1':
            if is_reversed:
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if is_reversed:
                s.appendleft(c)
            else:
                s.append(c)

str_list = list(s)
if is_reversed:
    str_list = reversed(str_list)

ans = ''.join(str_list)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sympy

pg = sympy.primerange(2, 100001)

x = int(input())

for p in pg:
    if p >= x:
        print(p)
        break


Fixed submission:
import math

x = int(input())


def is_prime(n):
    if n < 2:
        return False
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))


for n in range(100005):
    if n >= x and is_prime(n):
        print(n)
        break
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = [int(ch) for ch in input().strip().split()]


# upper 以下で div で割り切れるものの個数
def num_divisor(upper, div):
    return upper // div


# upper 以下で c でも d でも割り切れないものの個数
def num_divisor_c_d(upper, c, d):
    gcd_cd = c * d // math.gcd(c, d)

    n1 = num_divisor(upper, c)
    n2 = num_divisor(upper, d)
    n12 = num_divisor(upper, gcd_cd)

    return upper - (n1 + n2 - n12)


ans = num_divisor_c_d(b, c, d) - num_divisor_c_d(a - 1, c, d)

print(ans)


Fixed submission:
# import math
import fractions

a, b, c, d = [int(ch) for ch in input().strip().split()]


# upper 以下で div で割り切れるものの個数
def num_divisor(upper, div):
    return upper // div


# upper 以下で c でも d でも割り切れないものの個数
def num_divisor_c_d(upper, c, d):
    # gcd_cd = c * d // math.gcd(c, d)
    gcd_cd = c * d // fractions.gcd(c, d)

    n1 = num_divisor(upper, c)
    n2 = num_divisor(upper, d)
    n12 = num_divisor(upper, gcd_cd)

    return upper - (n1 + n2 - n12)


ans = num_divisor_c_d(b, c, d) - num_divisor_c_d(a - 1, c, d)

print(ans)

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

a, b, c, d = [int(ch) for ch in input().strip().split()]


# upper 以下で div で割り切れるものの個数
def num_divisor(upper, div):
    return upper // div


# upper 以下で c でも d でも割り切れないものの個数
def num_divisor_c_d(upper, c, d):
    gcd_cd = c * d // math.gcd(c, d)

    n1 = num_divisor(upper, c)
    n2 = num_divisor(upper, d)
    n12 = num_divisor(upper, gcd_cd)

    return upper - (n1 + n2 - n12)


ans = num_divisor_c_d(b, c, d) - num_divisor_c_d(a - 1, c, d)

print(ans)


Fixed submission:
# import math
import fractions

a, b, c, d = [int(ch) for ch in input().strip().split()]


# upper 以下で div で割り切れるものの個数
def num_divisor(upper, div):
    return upper // div


# upper 以下で c でも d でも割り切れないものの個数
def num_divisor_c_d(upper, c, d):
    # gcd_cd = c * d // math.gcd(c, d)
    gcd_cd = c * d // fractions.gcd(c, d)

    n1 = num_divisor(upper, c)
    n2 = num_divisor(upper, d)
    n12 = num_divisor(upper, gcd_cd)

    return upper - (n1 + n2 - n12)


ans = num_divisor_c_d(b, c, d) - num_divisor_c_d(a - 1, c, d)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
data = [list(map(int, input().strip().split())) for _ in range(n)]

data = sorted(data, key=lambda d: d[1])

work_time = 0
impossible = False
for a, b in data:
    deadline = b
    work_time += a
    if work_time > b:
        impossible = True
        break

if impossible:
    print('No')
else:
    print('Yes')

n = int(input())
data = [list(map(int, input().strip().split())) for _ in range(n)]

data = sorted(data, key=lambda d: d[1])

work_time = 0
impossible = False
for a, b in data:
    deadline = b
    work_time += a
    if work_time > b:
        impossible = True
        break

if impossible:
    print('No')
else:
    print('Yes')



Fixed submission:
n = int(input())
data = [list(map(int, input().strip().split())) for _ in range(n)]

data = sorted(data, key=lambda d: d[1])

work_time = 0
impossible = False
for a, b in data:
    deadline = b
    work_time += a
    if work_time > b:
        impossible = True
        break

if impossible:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().strip().split())

count = 0
for r in range(3001):
    for g in range(3001):
        rest = N - r * R - g * G
        if rest >= 0 and rest % B == 0:
            count += 1

print(count)


Fixed submission:
R, G, B, N = map(int, input().strip().split())

count = 0
for r in range(3001):
    for g in range(3001):
        rest = N - r * R - g * G
        if rest >= 0 and rest % B == 0:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(map(int, input().strip()))
len_s = len(s)

p = 0
count = 0

while p < len(s) - 1:
    if s[p] != s[p + 1]:
        count += 2
        first = s[:p] if p > 0 else []
        second = s[p + 2:] if p < len(s) - 2 else []
        s = first + second
        if p > 0:
            p -= 1
        else:
            p = 0
    else:
        p += 1

print(count)


Fixed submission:
import numpy as np

s = list(map(int, input().strip()))
s = np.array(s, dtype=np.bool)
len_s = len(s)

p = 0
count = 0

while p < len_s - 1:
    if s[p] != s[p + 1]:
        count += 2
        if p < len_s - 2:
            s[p:-2] = s[p + 2:]
        if p > 0:
            p -= 1
        else:
            p = 0

        len_s -= 2
    else:
        p += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().strip().split())
data = [list(map(int, input().strip().split())) for _ in range(n)]

# i番目に重さがj以下となるように選んだときの価値の総和の最大値
dp = [[0] * (w + 1) for _ in range(n)]

for i in range(0, n):
    for j in range(w + 1):
        # i 番目の品物の重さと価値
        wi, vi = data[i]
        if i == 0:
            take = vi if j - wi >= 0 else 0
            miss = 0
            dp[i][j] = max(take, miss)
        else:
            # i番目の品物を入れる場合
            take = dp[i - 1][j - wi] + vi if j - wi >= 0 else 0
            # 入れない場合
            miss = dp[i - 1][j]
            dp[i][j] = max(take, miss)

print(max(dp[n - 1]))


Fixed submission:
n = int(input())
hs = list(map(int, input().split()))

# 足場 i にたどり着くまでのコストの総和の最小値
dp = [1e14] * n

dp[0] = 0
dp[1] = abs(hs[0] - hs[1])

for i in range(2, n):
    dp[i] = min(abs(hs[i] - hs[i - 1]) + dp[i - 1], abs(hs[i] - hs[i - 2]) + dp[i - 2])

print(dp[n - 1])

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

n, w = map(int, input().strip().split())
data = [list(map(int, input().strip().split())) for _ in range(n)]

# i番目に重さがj以下となるように選んだときの価値の総和の最大値
dp = np.zeros((n, w + 1), dtype=np.int64)

for i in range(0, n):
    for j in range(w + 1):
        # i 番目の品物の重さと価値
        wi, vi = data[i]
        if i == 0:
            take = vi if j - wi >= 0 else 0
            miss = 0
            dp[i][j] = max(take, miss)
        else:
            # i番目の品物を入れる場合
            take = dp[i - 1][j - wi] + vi if j - wi >= 0 else 0
            # 入れない場合
            miss = dp[i - 1][j]
            dp[i][j] = max(take, miss)

print(np.max(dp[n - 1]))


Fixed submission:
n = int(input())
hs = list(map(int, input().split()))

# 足場 i にたどり着くまでのコストの総和の最小値
dp = [1e14] * n

dp[0] = 0
dp[1] = abs(hs[0] - hs[1])

for i in range(2, n):
    dp[i] = min(abs(hs[i] - hs[i - 1]) + dp[i - 1], abs(hs[i] - hs[i - 2]) + dp[i - 2])

print(dp[n - 1])
Buggy python submission (verdict: Runtime Error):
n = int(input())

data = []
for i in range(n):
    row = list(map(int, input().split()))
    data.append(row)

# n日目に act を行うときの最大値
def rec(n, act):
    if n == 0:
        return data[n][act]

    if act == 0:
        available = [1, 2]
    elif act == 1:
        available = [0, 2]
    else:
        available = [0, 1]
    return data[n][act] + max(rec(n - 1, available[0]), rec(n - 1, available[1]))

mx = max(rec(n - 1, 0), rec(n - 1, 1), rec(n - 1, 2))

print(mx)

Fixed submission:
n = int(input())

data = []
for i in range(n):
    row = list(map(int, input().split()))
    data.append(row)

# n日目に act を行うときの最大値
dp = [None] * n

# 初期条件： 0日目にa, b, c (= 0, 1, 2) を行うときの最大値
dp[0] = [0, 0, 0]
dp[0][0] = data[0][0]
dp[0][1] = data[0][1]
dp[0][2] = data[0][2]

for d in range(1, n):
    dp[d] = [0, 0, 0]
    dp[d][0] = data[d][0] + max(dp[d - 1][1], dp[d - 1][2])
    dp[d][1] = data[d][1] + max(dp[d - 1][2], dp[d - 1][0])
    dp[d][2] = data[d][2] + max(dp[d - 1][0], dp[d - 1][1])

mx = max(dp[n - 1])

print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().strip().split())
xs = list(map(int, input().strip().split()))


def min_for_interval(interval):
    left = interval[0]
    right = interval[-1]

    if left < 0:
        if right < 0:
            return abs(left)
        else:
            l_r = 2 * abs(left) + abs(right)
            r_l = 2 * abs(right) + abs(left)
            return min(l_r, r_l)
    else:
        return right


min_time = 1e9
for i in range(0, n - k + 1):
    interval = xs[i:i + k]
    min_time = min(min_for_interval(interval), min_time)

print(min_time)


Fixed submission:
n, k = map(int, input().strip().split())
xs = list(map(int, input().strip().split()))


def min_for_interval(left, right):
    if left < 0:
        if right < 0:
            return abs(left)
        else:
            l_r = 2 * abs(left) + abs(right)
            r_l = 2 * abs(right) + abs(left)
            return min(l_r, r_l)
    else:
        return right


min_time = 1e9
for i in range(0, n - k + 1):
    left = xs[i]
    right = xs[i + k - 1]
    min_time = min(min_for_interval(left, right), min_time)

print(min_time)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n, p = map(int, input().strip().split())
as_ = list(map(int, input().strip().split()))

num_evens = len([a for a in as_ if a % 2 == 0])
num_odds = len([a for a in as_ if a % 2 == 1])

counts = 0
if p == 0:
    # 全部で偶数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k 個
    # 0袋食べる場合も OK.
    counts += 1
    # 1袋以上食べる場合
    for i in range(1, n + 1):
        # 全部で i 袋食べるとする i = 1 〜 n
        for a in range(i + 1):
            # そのうち偶数枚の袋を a 個食べる方法
            even_ways = comb(num_evens, a, exact=True)
            # 奇数枚の袋は (i - a) 個食べるが、それは偶数でなければならない
            b = (i - a)
            if b % 2 == 1 or b < 0:
                continue
            else:
                odd_ways = comb(num_odds, b, exact=True)

            counts += even_ways * odd_ways

else:
    # 全部で奇数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k + 1個 (k > 0)
    # 奇数の袋は0ではいけない (k > 0)
    # 0袋食べるのはダメ
    # 1袋以上食べる場合
    for i in range(1, n + 1):
        # 全部で i 袋食べるとする
        for b in range(1, i + 1):
            # 奇数枚の袋を b = 2k + 1 個食べる
            if b % 2 == 0:
                continue
            # すると偶数枚の袋は a = i - b 個食べる
            a = i - b
            if a < 0:
                continue

            odd_ways = comb(num_odds, b, exact=True)
            even_ways = comb(num_evens, a, exact=True)
            counts += even_ways * num_odds

print(counts)


Fixed submission:
# from scipy.special import comb
from scipy.misc import comb

n, p = map(int, input().strip().split())
as_ = list(map(int, input().strip().split()))

num_evens = len([a for a in as_ if a % 2 == 0])
num_odds = len([a for a in as_ if a % 2 == 1])

counts = 0
if p == 0:
    # 全部で偶数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k 個
    # 0袋食べる場合も OK.
    counts += 1
    # 1袋以上食べる場合
    for i in range(1, n + 1):
        # 全部で i 袋食べるとする i = 1 〜 n
        for a in range(i + 1):
            # そのうち偶数枚の袋を a 個食べる方法
            even_ways = comb(num_evens, a, exact=True)
            # 奇数枚の袋は (i - a) 個食べるが、それは偶数でなければならない
            b = (i - a)
            if b % 2 == 1 or b < 0:
                continue
            else:
                odd_ways = comb(num_odds, b, exact=True)

            counts += even_ways * odd_ways

else:
    # 全部で奇数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k + 1個 (k >= 0)
    # 奇数の袋は0ではいけない (k >= 0)
    # 0袋食べるのはダメ
    # 1袋以上食べる場合
    for i in range(1, n + 1):
        # 全部で i 袋食べるとする
        for b in range(0, i + 1):
            # 奇数枚の袋を b = 2k + 1 個食べる
            if b % 2 == 0:
                continue
            # すると偶数枚の袋は a = i - b 個食べる
            a = i - b
            if a < 0:
                continue

            odd_ways = comb(num_odds, b, exact=True)
            even_ways = comb(num_evens, a, exact=True)
            counts += even_ways * odd_ways

print(counts)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb


s = int(input())

if s < 3:
    print(0)
else:

    count = 0
    total = 0

    while True:
        s = s-3
        count += 1

        if s >= 0:
           total += comb(s+count-1, count-1)
        else:
            break

    print(int(total % (10**9+7)))


Fixed submission:
from scipy.special import comb


s = int(input())

if s < 3:
    print(0)
else:

    count = 0
    total = 0

    while True:
        s = s-3
        count += 1

        if s >= 0:
           total += comb(s+count-1, count-1 ,exact=True)
           total = total% (10**9+7)
        else:
            break

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

x, move, d = map(int, input().split())

for k in range(move):

    if np.sign(x) == 1:
        x = x-d
    else:
        x = x+d

    if abs(x) <= d and (move-(k+1))%2==0:
        break


print(abs(x))


Fixed submission:
import numpy as np

x, move, d = map(int, input().split())

num = int(abs(x)/d)
ans = 0

if move <= num:
    if np.sign(x) == 1:
        ans = x-d*move
    else:
        ans = x+d*move

elif (move-num)%2==0:
    if np.sign(x) == 1:
        ans = x-d*num
    else:
        ans = x+d*num

elif (move-num)%2!=0:
    if np.sign(x) == 1:
        ans = x-d*(num+1)
    else:
        ans = x+d*(num+1)


print(abs(ans))

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

x, move, d = map(int, input().split())

for k in range(move):

    if np.sign(x) == 1 or np.sign(x) == 0:
        x = x-d
    else:
        x = x+d

    if abs(x) <= d/2 and (move-(k+1))%2==0:
        break
    elif abs(x) <= d/2 and (move-(k+1))%2!=0:
        if np.sign(x) == 1 or np.sign(x) == 0:
            x = x-d
        else:
            x = x+d

        break


print(abs(x))


Fixed submission:
import numpy as np

x, move, d = map(int, input().split())

num = int(abs(x)/d)
ans = 0

if move <= num:
    if np.sign(x) == 1:
        ans = x-d*move
    else:
        ans = x+d*move

elif (move-num)%2==0:
    if np.sign(x) == 1:
        ans = x-d*num
    else:
        ans = x+d*num

elif (move-num)%2!=0:
    if np.sign(x) == 1:
        ans = x-d*(num+1)
    else:
        ans = x+d*(num+1)


print(abs(ans))

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

x, move, d = map(int, input().split())

for k in range(move):
    move_plus = x + d
    move_minus = x - d

    if abs(move_plus) > abs(move_minus):
        x = move_minus
    else:
        x = move_plus

    if abs(x) <= d/2 and (move-(k+1))%2==0:
        break
    elif abs(x) <= d/2 and (move-(k+1))%2!=0:
        if np.sign(x) == 1 or np.sign(x) == 0:
            x = x-d
        else:
            x = x+d

        break

print(abs(x))


Fixed submission:
import numpy as np

x, move, d = map(int, input().split())

num = int(abs(x)/d)
ans = 0

if move <= num:
    if np.sign(x) == 1:
        ans = x-d*move
    else:
        ans = x+d*move

elif (move-num)%2==0:
    if np.sign(x) == 1:
        ans = x-d*num
    else:
        ans = x+d*num

elif (move-num)%2!=0:
    if np.sign(x) == 1:
        ans = x-d*(num+1)
    else:
        ans = x+d*(num+1)


print(abs(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

n_list = list(map(int, input().split()))

product = 1
for num in n_list:
    product = product * num

if product > 10**18:
    print(-1)

else:
    print(product)

Fixed submission:
n = int(input())

n_list = list(map(int, input().split()))

if 0 in n_list:
    print(0)

else:

    product = 1
    for num in n_list:
        product = product * num

        if product > 10 ** 18:
            product = -1
            break


    print(product)
Buggy python submission (verdict: Runtime Error):
from decimal import *

a, b = map(decimal, input().split())

print(a*b)


Fixed submission:
from decimal import *

a, b = map(Decimal, input().split())

print(int(a*b))

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

a, b = input().split()

a = int(a)
b = int(b* 100)

print(math.floor(a*b/100))

Fixed submission:
from decimal import *

a, b = map(Decimal, input().split())

print(int(a*b))

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

a, b = input().split()

a = int(a)
b = float(b)

print(math.fllor(a*b))

Fixed submission:
from decimal import *

a, b = map(Decimal, input().split())

print(int(a*b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

boss_nums = input()
boss_nums = boss_nums.split()

subordinate = []

for boss in range(1, n+1):
    count = 0

    for num in boss_nums:
        if int(num) == boss:
            count = count + 1

    subordinate.append(count)


for num in range(0, n):
    print(subordinate[num])



Fixed submission:
n = int(input())

boss_nums = input()
boss_nums = boss_nums.split()

subordinate = [0] * n

for num in boss_nums:
    num = int(num)
    subordinate[num-1] += 1


for num in range(0, n):
    print(subordinate[num])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=list(s.split())
ans=1
for i in range(0,n):
    ans=ans*int(a[i])
    if(ans>1000000000000000000):
        ans=-1
if(ans<0):
    print("-1")
else:
    print(ans)


Fixed submission:
n=int(input())
s=input()
a=list(s.split())
ans=1
flag=0
for i in range(0,n):
    ans=ans*int(a[i])
    if(ans>1000000000000000000):
        ans=-1
        j=i
        flag=1
        break
f=0
if(flag==1):
    for i in range(j+1,n):
        if(int(a[i])==0):
            f=1
            ans=0
            break
if(ans<-1 and f==0):
    print("-1")
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=list(s.split())
ans=1
for i in range(0,n):
    ans=ans*int(a[i])
    if(ans>1000000000000000000):
        ans=-1
if(ans<0):
    print("-1")
else:
    print(ans)


Fixed submission:
n=int(input())
s=input()
a=list(s.split())
ans=1
flag=0
for i in range(0,n):
    ans=ans*int(a[i])
    if(ans>1000000000000000000):
        ans=-1
        j=i
        flag=1
        break
f=0
if(flag==1):
    for i in range(j+1,n):
        if(int(a[i])==0):
            f=1
            ans=0
            break
if(ans<-1 and f==0):
    print("-1")
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
from collections import defaultdict
n=int(input())
l=list(map(int,input().split()))
d=defaultdict(lambda :0)
d1=defaultdict(lambda :0)
for i in range(n):
    d[l[i]]+=1
for i in d:
    x=d[i]
    if d[i]<2:
        d1[i]=0
    else:
        d1[i]=factorial(x)/(factorial(x-2)*2)
sum=0
for i in d1:
    sum+=d1[i]
d2=defaultdict(lambda :0)
for i in l:
    ans=0
    if i in d2:
        print(d2[i])
    else:
        if d[i]<3:
            ans=sum-d1[i]
        else:
            ans=sum-d1[i]+(factorial(d[i]-1)/(factorial(d[i]-3)*2))
        d2[i]=int(ans)
        print(int(ans))
                


Fixed submission:
from collections import Counter
n=int(input())
ar=list(map(int,input().split()))
x=Counter(ar)
dct={}
y=list(set(ar))
pair=0
#print(x)
for i in y:
    ct=x[i]-1
    pair+=(ct*(ct+1))//2
#print(pair)
for i in range(n):
    el=ar[i]
    ct=x[el]-1
    add=((ct*(ct+1))//2)-(((ct-1)*((ct-1)+1))//2)
    #print("fff",add)
    print(pair-add)

Buggy python submission (verdict: Time Limit Exceeded):
def comb(n, r): 
    if n<r:
        return 0
    return (fact(n) // (fact(r)  
                * fact(n - r))) 
  
def fact(n):   
    res = 1
    if n<=1:
        return 1
    for i in range(2, n+1): 
        res = res * i
    return res 
  

n = int(input())
a = list(map(int,input().split()))
maxa = max(a)
hasha = [0]*(maxa+1)
for i in a:
    hasha[i]+=1
seta = set(a)
mydict=dict()
sum=0
for i in seta:
    mydict[i] = comb(hasha[i],2)
for i in mydict:
    sum+=mydict[i]
for i in range(n):
    ans = sum + comb(hasha[a[i]]-1, 2) - comb(hasha[a[i]],2)
    print(ans)
    



Fixed submission:
from collections import Counter
n=int(input())
ar=list(map(int,input().split()))
x=Counter(ar)
dct={}
y=list(set(ar))
pair=0
#print(x)
for i in y:
    ct=x[i]-1
    pair+=(ct*(ct+1))//2
#print(pair)
for i in range(n):
    el=ar[i]
    ct=x[el]-1
    add=((ct*(ct+1))//2)-(((ct-1)*((ct-1)+1))//2)
    #print("fff",add)
    print(pair-add)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += a[i] * a[j]
ans %= 1000000007
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
a_sum = sum(a)
a_sum -= a[0]
for i in range(n - 1):
    ans += a[i] * a_sum
    a_sum -= a[i + 1]
ans %= 1000000007
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(input().split(' '))
total=0
S_i=0
for i in range(n-1):
    S_i+=int(a[n-1-i])
    S_i=S_i%(7+10**9)
    total+=S_i*int(a[n-2-i])
    total=total%(7+10**9)
print(total)

Fixed submission:
A=list(input().split())

if int(A[0])<=int(A[1])*int(A[2]):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s=list(input())
t=list(input())
S=[0 for i in range(len(s)-len(t)+1)]
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if t[j]==s[j+i]:
      S[i]+=1

S_max=max(S)
print(t-S_max)

Fixed submission:
s=list(input())
t=list(input())
S=[0 for i in range(len(s)-len(t)+1)]
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if t[j]==s[j+i]:
      S[i]+=1
      
S_0=max(S)
print(len(t)-S_0)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(input().split(' '))
total=0
S_i=0
for i in range(n-1):
    S_i+=a[n-1-i]
    S_i=S_i%(7+10**9)
    total+=S_i*a[n-2-i]
    total=total%(7+10**9)
print(total)

Fixed submission:
n=int(input())
a=list(input().split(' '))
total=0
S_i=0
for i in range(n-1):
    S_i+=int(a[n-1-i])
    S_i=S_i%(7+10**9)
    total+=S_i*int(a[n-2-i])
    total=total%(7+10**9)
print(total)