Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(n + 1)]
dp[0] = 1
cum = [0, 1]
cur = [0 for i in range(k)]
for i in range(1, n + 1):
    cnt = 0
    for j in range(k):
        r = (i - (lr[j][1] - lr[j][0] + 1))
        l = r - (lr[j][1] - lr[j][0])
        print(l, r, cum)
        if l <= 0:
            continue
        cnt += cum[r] - cum[l - 1]
    dp[i] = dp[i - 1] + cnt
    cum.append(cnt + cum[-1])
print(dp[n])

Fixed submission:
mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
for i in range(k):
    lr[i][1] += 1
dp = [0] * n
dp[0] = 1
for i in range(1, n):
    dp[i] += dp[i - 1]
    if i == 1:
        dp[1] = 0
    for l, r in lr:
        if i - l >= 0:
            dp[i] += dp[i - l]
        if i - r >= 0:
            dp[i] -= dp[i - r]
    dp[i] %= mod
print(dp[n - 1])
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = 0
for i in range(n):
    g = gcd(g, a[i])
cur = a[0]
f = False
for i in range(1, n):
    if gcd(cur, a[i]) != 1:
        f = True
        break
    cur *= a[i] // gcd(cur, a[i])
if not f:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")

Fixed submission:
import math
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def soinnsuu(x):
    s = set()
    for i in primes:
        if i > int(math.sqrt(x)):
            break
        elif x % i == 0:
            while x % i == 0:
                x //= i
            s.add(i)
    if not x == 1:
        s.add(x)
    return s
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = 0
for i in range(n):
    g = gcd(g, a[i])
primes = prime_numbers(2000000)
cur = soinnsuu(a[0])
f = False
for i in range(1, n):
    s2 = soinnsuu(a[i])
    if len(cur & s2) >= 1:
        f = True
        break
    cur |= s2
if not f:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def main():
    input = sys.stdin.readline
    R, C, k = map(int, input().split())
    s = [[0] * (C + 1) for i in range(R + 1)]
    dp = [[[0] * 4 for i in range(C + 1)] for j in range(R + 1)]
    for i in range(k):
        r, c, v = map(int, input().split())
        s[r][c] = v
    for i in range(R):
        for j in range(C):
            m = max(dp[i][j + 1][0], dp[i][j + 1][1], dp[i][j + 1][2], dp[i][j + 1][3])
            for k in range(4):
                if k == 0:
                    dp[i + 1][j + 1][k] = max(dp[i + 1][j][k], m)
                else:
                    dp[i + 1][j + 1][k] = max(dp[i + 1][j][k], dp[i + 1][j][k - 1] + s[i + 1][j + 1])
            dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], s[i + 1][j + 1] + m)
    print(max(dp[R][C]))
if __name__ == "__main__":
    main()

Fixed submission:
import sys
def main():
    input = sys.stdin.readline
    R, C, k = map(int, input().split())
    s = [[0] * (C + 1) for i in range(R + 1)]
    dp = [[[0] * (C + 1) for i in range(R + 1)] for j in range(4)]
    for i in range(k):
        r, c, v = map(int, input().split())
        s[r][c] = v
    for i in range(R):
        for j in range(C):
            m = max(dp[0][i][j + 1], dp[1][i][j + 1], dp[2][i][j + 1], dp[3][i][j + 1])
            for k in range(4):
                if k == 0:
                    dp[k][i + 1][j + 1] = max(dp[k][i + 1][j], m)
                else:
                    dp[k][i + 1][j + 1] = max(dp[k][i + 1][j], dp[k - 1][i + 1][j] + s[i + 1][j + 1])
            dp[1][i + 1][j + 1] = max(dp[1][i + 1][j + 1], s[i + 1][j + 1] + m)
    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
from decimal import Decimal
n = int(input())
a = [int(Decimal(input()) * (pow(10, 9))) for i in range(n)]
l = [[0] * 19 for i in range(19)]
ans = 0
for i in a:
    cnt2 = 0
    i2 = deepcopy(i)
    while i2 % 2 == 0 and cnt2 < 18:
        i2 //= 2
        cnt2 += 1
    cnt5 = 0
    i5 = deepcopy(i)
    while i5 % 5 == 0 and cnt5 < 18:
        i5 //= 5
        cnt5 += 1
    ans += l[19 - cnt2 - 1][19 - cnt5 - 1]
    for i in range(cnt2 + 1):
        for j in range(cnt5 + 1):
            l[i][j] += 1
print(ans)

Fixed submission:
from copy import deepcopy
from decimal import Decimal
n = int(input())
a = [int(Decimal(input()) * (pow(10, 9))) for i in range(n)]
l = [[0] * 19 for i in range(19)]
ans = 0
for i in a:
    cnt2 = 0
    i2 = deepcopy(i)
    while i2 % 2 == 0 and cnt2 < 18:
        i2 //= 2
        cnt2 += 1
    cnt5 = 0
    i5 = deepcopy(i)
    while i5 % 5 == 0 and cnt5 < 18:
        i5 //= 5
        cnt5 += 1
    ans += l[19 - cnt2 - 1][19 - cnt5 - 1]
    for i in range(cnt2 + 1):
        for j in range(cnt5 + 1):
            l[i][j] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from decimal import Decimal
n = int(input())
a = [Decimal(input()) for i in range(n)]
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if (a[i] * a[j]) % 1 == 0:
            ans += 1
print(ans)

Fixed submission:
from copy import deepcopy
from decimal import Decimal
n = int(input())
a = [int(Decimal(input()) * (pow(10, 9))) for i in range(n)]
l = [[0] * 19 for i in range(19)]
ans = 0
for i in a:
    cnt2 = 0
    i2 = deepcopy(i)
    while i2 % 2 == 0 and cnt2 < 18:
        i2 //= 2
        cnt2 += 1
    cnt5 = 0
    i5 = deepcopy(i)
    while i5 % 5 == 0 and cnt5 < 18:
        i5 //= 5
        cnt5 += 1
    ans += l[19 - cnt2 - 1][19 - cnt5 - 1]
    for i in range(cnt2 + 1):
        for j in range(cnt5 + 1):
            l[i][j] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
BIT = [0] * ((1 << 19) + 1)
def add(i, x):
    while i <= (1 << 19):
        BIT[i] += x
        i += i & (-i)
def query(i):
    res = 0
    while i > 0:
        res += BIT[i]
        i -= i & (-i)
    return res
n, q = map(int, input().split())
c = list(map(int, input().split()))
Q = [[] for i in range(n)]
for i in range(q):
    l, r = map(int, input().split())
    Q[r - 1].append([l - 1, i])
l = [-1] * n
a = [-1] * q
add(1, n)
for i in range(n):
    add(l[c[i] - 1] + 2, -1)
    add(i + 2, 1)
    l[c[i] - 1] = i
    for j in Q[i]:
        a[j[1]] = query(1 << 19) - query(j[0] + 1)
print(*a, sep="\n")

Fixed submission:
BIT = [0] * ((1 << 19) + 1)
def add(i, x):
    while i <= (1 << 19):
        BIT[i] += x
        i += i & -i
def query(i):
    res = 0
    while i > 0:
        res += BIT[i]
        i -= i & -i
    return res
n, q = map(int, input().split())
c = list(map(int, input().split()))
Q = [[] for i in range(n)]
for i in range(q):
    l, r = map(int, input().split())
    Q[r - 1].append([l - 1, i])
l = [-1] * n
a = [-1] * q
add(1, n)
for i in range(n):
    add(l[c[i] - 1] + 2, -1)
    add(i + 2, 1)
    l[c[i] - 1] = i
    for j in Q[i]:
        a[j[1]] = query(1 << 19) - query(j[0] + 1)
print(*a, sep="\n")

Buggy python submission (verdict: Runtime Error):
BIT = [0] * ((1 << 19) + 1)
def add(i, x):
    while i <= (1 << 19):
        BIT[i] += x
        i += i & -i
def query(i):
    res = 0
    while i > 0:
        res += BIT[i]
        i -= i & -i
    return res
n, q = map(int, input().split())
c = list(map(int, input().split()))
Q = [[] for i in range(n)]
for i in range(q):
    l, r = map(int, input().split())
    Q[r - 1].append([l - 1, i])
l = [-1] * n
a = [-1] * q
add(1, n)
for i in range(n):
    add(l[c[i]] + 2, -1)
    add(i + 2, 1)
    l[c[i]] = i
    for j in Q[i]:
        a[j[1]] = query(1 << 19) - query(j[0] + 1)
print(*a, sep="\n")

Fixed submission:
BIT = [0] * ((1 << 19) + 1)
def add(i, x):
    while i <= (1 << 19):
        BIT[i] += x
        i += i & -i
def query(i):
    res = 0
    while i > 0:
        res += BIT[i]
        i -= i & -i
    return res
n, q = map(int, input().split())
c = list(map(int, input().split()))
Q = [[] for i in range(n)]
for i in range(q):
    l, r = map(int, input().split())
    Q[r - 1].append([l - 1, i])
l = [-1] * n
a = [-1] * q
add(1, n)
for i in range(n):
    add(l[c[i] - 1] + 2, -1)
    add(i + 2, 1)
    l[c[i] - 1] = i
    for j in Q[i]:
        a[j[1]] = query(1 << 19) - query(j[0] + 1)
print(*a, sep="\n")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
X=0
for i in a[2:]:X^=i
m=a[0]+a[1]-X
if m>a[0]or(m&X)!=0:exit(print(-1))
l=1<<max(x.bit_length(),m.bit_length())
while l > 0:
 if (m&l)!=0and(a|b)<=a[0]:a|=b
 b>>=1
print(a[0]-m if a!=0else-1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=0
for i in a[2:]:x^=i
m=(a[0]+a[1]-x)//2
if a[0]+a[1]!=x+m*2or m>a[0]or(x&m)!=0:exit(print(-1))
l=1<<(max(x.bit_length(),m.bit_length())+1)
while l>0:
 if((x&l)!=0)and((m|l)<=a[0]):m|=l
 l>>=1
print(a[0]-m if m!=0else-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=""
while n>0:n-=1;s+=chr(97+n%26);n//=26
print(s[::-1])

Fixed submission:
a = input()
print("A" if a.isupper() else "a")
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
s,m,c,a=input(),10**9+7,1,1
for i in range(k):c*=25*(k+len(s)-i)*pow(i+1,m-2,m)%m;c%=m;a+=c
print(a%m)

Fixed submission:
k=int(input())
s,m,c,a=input(),10**9+7,1,1
for i in range(k):c*=25*(k+len(s)-i)*pow(i+1,m-2,m)%m;c%=m;a+=c
print(a%m)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
p=[[0]*(d+2)for i in range(c+1)]
p[a][b]=1
m=998244353
for i in range(a,c+1):
 for j in range(b,d+1):p[i][j]+=(j*p[i-1][j]+i*p[i][j-1]-(i-1)*(j-1)*p[i-1][j-1])%m;p[i][j]%=m
print(p[-1][-2]%m)

Fixed submission:
a,b,c,d=map(int,input().split())
p=[[0]*(d+2)for i in range(c+1)]
p[a][b]=1
m=998244353
for i in range(a,c+1):
 for j in range(b,d+1):p[i][j]+=(j*p[i-1][j]+i*p[i][j-1]-(i-1)*(j-1)*p[i-1][j-1])%m;p[i][j]%=m
print(p[-1][-2]%m)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k):
    l = [0] * (n + 1)
    for j in range(n):
        l[max(0, j - a[j])] += 1
        l[min(n, j + a[j] + 1)] -= 1
    for j in range(n - 1):
        l[j + 1] += l[j]
    a = l
    if set(a) == set([n]):
        break
print(*a[:n])

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k):
    l = [0] * (n + 1)
    for j in range(n):
        l[max(0, j - a[j])] += 1
        l[min(n, j + a[j] + 1)] -= 1
    for j in range(n - 1):
        l[j + 1] += l[j]
    a = l
    if a.count(n) == n:
        break
print(*a[:n])
Buggy python submission (verdict: Time Limit Exceeded):
n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += dp[i - 1][j] * 2
        dp[i][j] %= mod
        if a[i - 1] + j <= s:
            dp[i][a[i - 1] + j] += dp[i - 1][j]
            dp[i][a[i - 1] + j] %= mod
print(dp[n][s])

Fixed submission:
n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += dp[i - 1][j] * 2
        dp[i][j] %= mod
        if a[i - 1] + j <= s:
            dp[i][a[i - 1] + j] += dp[i - 1][j]
            dp[i][a[i - 1] + j] %= mod
print(dp[n][s])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
d = [min(i, n - i - 1, j, n - j - 1) for i in range(n) for j in range(n)]
ans = 0
l = [1] * (n ** 2)
for i in p:
    ans += d[i - 1]
    l[i - 1] = 0
    que = [i - 1]
    while que:
        s = que.pop()
        if not s % n == n - 1:
            if d[s + 1] > d[s] + l[s]:
                que.append(s + 1)
                d[s + 1] = d[s] + l[s]
        if s % n:
            if d[s - 1] > d[s] + l[s]:
                que.append(s - 1)
                d[s - 1] = d[s] + l[s]
        if s >= n:
            if d[s - n] > d[s] + l[s]:
                que.append(s - n)
                d[s - n] = d[s] + l[s]
        if n ** 2 > s + n:
            if d[s + n] > d[s] + l[s]:
                que.append(s + n)
                d[s + n] = d[s] + l[s]
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
d = [min(i, n - i - 1, j, n - j - 1) for i in range(n) for j in range(n)]
ans = 0
l = [1] * (n ** 2)
for i in p:
    ans += d[i - 1]
    l[i - 1] = 0
    que = [i - 1]
    while que:
        s = que.pop()
        if not s % n == n - 1:
            if d[s + 1] > d[s] + l[s]:
                que.append(s + 1)
                d[s + 1] = d[s] + l[s]
        if s % n:
            if d[s - 1] > d[s] + l[s]:
                que.append(s - 1)
                d[s - 1] = d[s] + l[s]
        if s >= n:
            if d[s - n] > d[s] + l[s]:
                que.append(s - n)
                d[s - n] = d[s] + l[s]
        if n ** 2 > s + n:
            if d[s + n] > d[s] + l[s]:
                que.append(s + n)
                d[s + n] = d[s] + l[s]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, h, m = map(int, input().split())
angle = min(h * 30 + (m / 60) * 30 - m * 6, 360 - (h * 30 + (m / 60) * 30 - m * 6))
if angle > 90:
    angle = 90 - (180 - angle)
    n = a * math.sin(math.radians(angle))
    x = a * math.cos(math.radians(angle))
    print(math.sqrt(n ** 2 + (x + b) ** 2))
else:
    angle = 90 - angle
    n = b * math.sin(math.radians(angle))
    x = b * math.cos(math.radians(angle)) * (1 / (1 - n / a)) - b * math.cos(math.radians(angle))
    print(math.sqrt(((b * math.cos(math.radians(angle)) + x) ** 2 + a ** 2)) - math.sqrt(n ** 2 + x ** 2))

Fixed submission:
import math
a, b, h, m = map(int, input().split())
ang = min(h * 30 + (m / 60) * 30 - m * 6, 360 - (h * 30 + (m / 60) * 30 - m * 6))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang))))

Buggy python submission (verdict: Runtime Error):
import math
a, b, h, m = map(int, input().split())
angle = abs(90 - abs(h * 30 + (m / 60) * 30 - m * 6))
n = b * math.sin(math.radians(angle))
x = b * math.cos(math.radians(angle)) * (1 / (1 - n / a)) - b * math.cos(math.radians(angle))
print(math.sqrt(((b * math.cos(math.radians(angle)) + x) ** 2 + a ** 2)) - math.sqrt(n ** 2 + x ** 2))

Fixed submission:
import math
a, b, h, m = map(int, input().split())
ang = min(h * 30 + (m / 60) * 30 - m * 6, 360 - (h * 30 + (m / 60) * 30 - m * 6))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang))))
Buggy python submission (verdict: Runtime Error):
def dfs(now):
    global m
    if now in l:
        m = now
        return None
    else:
        l.append(now)
        dfs(a[now - 1])
n, k = map(int, input().split())
a = list(map(int, input().split()))
m = float("inf")
l = []
cycle = float("inf")
ans = []
dfs(a[0])
for i in range(len(l)):
    if l[i] == m:
        ans = l[i:]
        cycle = len(ans)
if k % cycle == 0:
    print(ans[-1])
else:
    print(ans[(k - (len(l) - cycle)) % cycle - 1])

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = [0]
s = set()
s.add(0)
cur = a[0] - 1
while True:
    if cur in s:
        break
    else:
        s.add(cur)
        l.append(cur)
        cur = a[cur] - 1
i = l.index(cur)
if k <= i:
    print(l[k] + 1)
else:
    print(l[(k - i) % (len(l) - i) + i] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.special import comb
n, m, k = map(int, input().split())
ans = 0
for i in range(k + 1):
    ans += pow(m - 1, n - i - 1) * comb(n - 1, i, exact=True) * m
    ans %= 998244353
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
mod = 998244353
ans = 0
x = 1
for i in range(k + 1):
    ans += (((m * pow(m - 1, n - i - 1, mod)) % mod) * x) % mod
    ans %= mod
    x = (x * (n - i - 1) * pow(i + 1, mod - 2, mod)) % mod
print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
for i in range(4, len(s) + 1):
    for j in range(len(s) - i):
        if int(s[j:j + i + 1]) % 2019 == 0:
            ans += 1
print(ans)

Fixed submission:
s = input()[::-1]
l = [0 for i in range(2019)]
l[0] = 1
a, b = 0, 1
ans = 0
for i in s:
    a += int(i) * b
    a %= 2019
    b *= 10
    b %= 2019
    l[a] += 1
for i in l:
    ans += i * (i - 1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n + 1):
    print(a.count(i))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(n)]
for i in a:
    l[i - 1] += 1
print(*l, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
k = int(input())
li = []
cnt = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            li.append(gcd(gcd(i, j), gcd(j, l)))
print(sum(li))

Fixed submission:
from math import gcd
k = int(input())
li = []
li2 = [6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
cnt = 0
if k < 170:
    for i in range(1, k + 1):
    	for j in range(1, k + 1):
            for l in range(1, k + 1):
        	    li.append(gcd(gcd(i, j), gcd(j, l)))
    print(sum(li))
else:
    print(li2[k - 170])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r, g, b = s.count("R"), s.count("G"), s.count("B")
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        try:
            k = j + (j - i)
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt += 1
        except:
            pass
print(r * g * b - cnt)

Fixed submission:
n = int(input())
s = input()
r, g, b = s.count("R"), s.count("G"), s.count("B")
ans = r * g * b
for i in range(n):
    for j in range(i + 1, n):
        k = j + (j - i)
        if k >= n:
            break
        if s[i] != s[j] != s[k] != s[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = []
ans.append(max(a) - min(a))
for i in range(n):
    if a[i] > k // 2:
        a[i] = (k - a[i]) * -1
    ans.append(max(a) - min(a)) 
print(min(ans))

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
l = [a[0] + k - a[-1]]
for i in range(1, n):
    l.append(a[i] - a[i - 1])
print(sum(l) - max(l))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
default=0
for i in set(a):
    default+=a.count(i)*(a.count(i)-1)//2
for k in a:
    print(default-(a.count(k)-1))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cnt = 0
for i in c.values():
    cnt += i * (i - 1) // 2
for i in a:
    print(cnt - c[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a1 = set(a)
default = 0
for i in a1:
    default += a.count(i) * (a.count(i) - 1) // 2
for k in a:
    print(default - (a.count(k) - 1))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cnt = 0
for i in c.values():
    cnt += i * (i - 1) // 2
for i in a:
    print(cnt - c[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a1 = set(a)
l = []
default = 0
for i in a1:
    l.append(a.count(i))
for j in l:
    default += j * (j - 1) // 2
for k in a:
    print(default - (a.count(k) - 1))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cnt = 0
for i in c.values():
    cnt += i * (i - 1) // 2
for i in a:
    print(cnt - c[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a1 = a
    a2 = set(a1)
    ans = 0
    for j in a2:
        if j == a1[i]:
            cnt = a1.count(j) - 1
        else:
            cnt = a1.count(j)
        ans += cnt * (cnt - 1) // 2
    print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cnt = 0
for i in c.values():
    cnt += i * (i - 1) // 2
for i in a:
    print(cnt - c[i] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (s + 1)
ans = 0
for i in range(n):
    dp[0] += 1
    for j in range(a[i], s + 1)[::-1]:
        dp[j] += dp[j - a[i]]
        dp[j] %= mod
    ans += dp[-1]
    ans %= mod
print(ans)

Fixed submission:
mod = 998244353
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (s + 1)
ans = 0
for i in range(n):
    dp[0] += 1
    for j in range(a[i], s + 1)[::-1]:
        dp[j] += dp[j - a[i]]
        dp[j] %= mod
    ans += dp[-1]
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
if c - a - b > 0 and 2 * sqrt(a * b) < c - a - b:
    print("Yes")
else:
    print("No")

Fixed submission:
from decimal import Decimal
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import sqrt from math
a, b, c = map(int, input().split())
if a + b + sqrt(a * b) < c:
    print("Yes")
else:
    print("No")

Fixed submission:
from decimal import Decimal
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
print(a * (n // (a + b)) + min(a, n % (a + b))

Fixed submission:
n, a, b = map(int, input().split())
print(a * (n // (a + b)) + min(a, n % (a + b)))