Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

# 1以上の同じ色の石の列は1つに集約できる
T = S[0]
prev = T
for s in S[1:]:
    if prev != s:
        T += s
        prev = s

print(len(T) - 1)


Fixed submission:
S = input()

# 1以上の同じ色の石の列は1つに集約できる
cnt = 1
prev = S[0]
for s in S[1:]:
    if prev != s:
        cnt += 1
        prev = s

print(cnt - 1)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()

# 1以上の同じ色の石の列は1つに集約できる
T = S[0]
for s in S[1:]:
    if T[-1] != s:
        T += s

print(len(T) - 1)


Fixed submission:
S = input()

# 1以上の同じ色の石の列は1つに集約できる
cnt = 1
prev = S[0]
for s in S[1:]:
    if prev != s:
        cnt += 1
        prev = s

print(cnt - 1)
Buggy python submission (verdict: Runtime Error):
a = int(input())
if a >= 3200:
    print(s)
else:
    print("red")


Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

maxv = 0
for i in range(1, N+1):
    for t in list(combinations(list(range(N)), i)):
        X = sum(V[k] for k in t)
        Y = sum(C[k] for k in t)
        maxv = max(maxv, X-Y)
print(maxv)


Fixed submission:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

maxv = 0
for v, c in zip(V, C):
    if v > c:
        maxv += (v-c)
print(maxv)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

i = N
while True:
    if i % 2 == 0 and i % N == 0:
        print(i)
        break
    i += 1


Fixed submission:
N = int(input())

i = N
while True:
    if i % 2 == 0 and i % N == 0:
        print(i)
        break
    i += N
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if A > 8 or B > 8:
    print("Yay!")
else:
    print(":(")


Fixed submission:
A, B = map(int, input().split())

if A > 8 or B > 8:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max([A+B. A-B, A*B]))


Fixed submission:
A, B = map(int, input().split())
print(max([A+B, A-B, A*B]))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
x = sorted(a, b)
y = sorted(c, b)

if (x[-1] - x[0]) <= d and (y[-1] - y[0]) <= d:
    print("Yes")
else:
    print("No")


Fixed submission:
a, b, c, d = map(int, input().split())
x = sorted([a, b])
y = sorted([c, b])

if (max(a, c) - min(a, c)) <= d:
    print("Yes")
elif (x[-1] - x[0]) <= d and (y[-1] - y[0]) <= d:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

for i in range(X, 0, -1):
    tmp = i
    if X % tmp:
        continue
    while tmp <= X:
        tmp *= tmp
    if tmp == X:
        print(i)


Fixed submission:
X = int(input())

ans = 1
for i in range(1, X):
    for j in range(2, X):
        tmp = i ** j
        if tmp > X:
            break
        ans = max(tmp, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

for i in range(X, 0, -1):
    tmp = i
    while tmp <= X:
        tmp *= tmp
    if tmp == X:
        print(i)


Fixed submission:
X = int(input())

ans = 1
for i in range(1, X):
    for j in range(2, X):
        tmp = i ** j
        if tmp > X:
            break
        ans = max(tmp, ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
substrings = {s[i:j]:0 for i in range(len(s)) for j in range(i+1, len(s)+1) if len(s[i:j]) <= K}
print(sorted(substrings)[K-1])


Fixed submission:
s = input()
K = int(input())
substrings = {s[i:j]:0 for i in range(len(s)) for j in range(i+1, min(i+1+K, len(s)+1))}
print(sorted(substrings)[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
substrings = {s[i:j]:0 for i in range(len(s)) for j in range(i+1, len(s)+1)}
print(sorted(substrings)[K-1])


Fixed submission:
s = input()
K = int(input())
substrings = {s[i:j]:0 for i in range(len(s)) for j in range(i+1, min(i+1+K, len(s)+1))}
print(sorted(substrings)[K-1])
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = ["".join(["0"]*(H+2))] + ["0"+input()+"0" for _ in range(H)] + ["".join(["0"]*(H+2))]
failed = False
for i in range(1, W+1):
    for j in range(1, H+1):
        if '#' != s[i][j]:
            continue
        if '#' in [s[i+x][j+y] for x, y in [(0, -1), (-1, 0), (1, 0), (0, 1)]]:
            continue
        else:
            failed = True
            break
    if failed:
        print("No")
        break
else:
    print("Yes")


Fixed submission:
H, W = map(int, input().split())
s = ["".join(["0"]*(W+2))] + ["0"+input()+"0" for _ in range(H)] + ["".join(["0"]*(W+2))]
failed = False
for i in range(1, H+1):
    for j in range(1, W+1):
        if '#' != s[i][j]:
            continue
        if '#' in [s[i+x][j+y] for x, y in [(0, -1), (-1, 0), (1, 0), (0, 1)]]:
            continue
        else:
            failed = True
            break
    if failed:
        print("No")
        break
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
    tmp = sorted(X[:i] + X[i+1:])[::-1]
    print(tmp[(N-1)//2])


Fixed submission:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
a, b = Y[N//2], Y[N//2-1]
for i in range(N):
    if X[i] < a:
        print(a)
    else:
        print(b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
for idx in range(1, N+1):
    i = 0
    tmp = 0
    while i < len(A)-1:
        if idx == i+1:
            tmp += abs(A[i]-A[i+2])
            i += 2
        else:
            tmp += abs(A[i]-A[i+1])
            i += 1
    print(tmp)


Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
S = sum(abs(A[i]-A[i+1]) for i in range(len(A)-1))
for i in range(1, N+1):
    print(S-(abs(A[i]-A[i+1]) + abs(A[i]-A[i-1]))+abs(A[i+1]-A[i-1]))
Buggy python submission (verdict: Runtime Error):
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
elif N != 1 and M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))


Fixed submission:
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
elif N != 1 and M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))

Buggy python submission (verdict: Runtime Error):
def get_z(x, y):
    global N
    return (y+1)*(N+2) + (x+1)

N, M = map(int, input().split())
table = [-1] * (N+2) + [[1, -1][i in [0, N+1]] for i in range(N+2)] * M + [-1] * (N+2)
for y in range(M):
    for x in range(N):
        z = get_z(x, y)
        for t in [(z-(N+3)), (z-(N+2)), (z-(N+1)), z-1, z, z+1, z+N+1, z+N+2, z+N+3]:
            table[t] = table[t] ^ 1
print(sum(1 * (t==0) for t in table))


Fixed submission:
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
elif N != 1 and M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(N)]
ans = 0
for a in range(N):
    fuga = ['M', 'A', 'R', 'C', 'H']
    ch = S[a][0]
    if ch not in fuga:
        continue
    fuga.remove(ch)
    for b in range(a+1, N):
        ch = S[b][0]
        temp = fuga[:]
        if ch not in temp:
            continue
        temp.remove(ch)
        ans += sum(1 * (S[c][0] in temp) for c in range(b+1, N))
print(ans)


Fixed submission:
from collections import Counter
from itertools import combinations
march = list("MARCH")
march = dict(zip(march, march))
N = int(input())
S = [march.get(input()[0], -1) for _ in range(N)]
cnt = Counter(S)
ans = 0
for comb in combinations("MARCH", 3):
    tmp = 1
    for c in comb:
        tmp *= cnt[c]
    ans += tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

ans = 0
for s in sorted(set(a))[::-1]:
    cnt = a.count(s)
    tmp = cnt - s
    ans += (tmp > 0) * tmp + (tmp < 0) * cnt
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = 0
for k, v in cnt.items():
    if k > v:
        ans += v
    elif k < v:
        ans += (v-k)
print(ans)

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

array = [0] * (N+1)
set_a = set(a)
for ai in a:
    try:
        array[ai] += 1
    except:
        pass

ans = 0
for sa in set_a:
    if sa > N:
        ans += a.count(sa)
        continue
    while array[sa] != sa and array[sa] > 0:
        array[sa] -= 1
        ans += 1
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = 0
for k, v in cnt.items():
    if k > v:
        ans += v
    elif k < v:
        ans += (v-k)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
x = sum(int(i) for i in N)
print("Yes" if N % x == 0 else "No")


Fixed submission:
N = input()
x = sum(int(i) for i in N)
print("Yes" if int(N) % x == 0 else "No")
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
X = ord(X)
Y = ord(Y)
if X < Y:
    print("<")
elif X > Y:
    print(">")
else:
    print("=")


Fixed submission:
X, Y = input().split()
X = ord(X)
Y = ord(Y)
if X < Y:
    print("<")
elif X > Y:
    print(">")
else:
    print("=")
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(N, 1, -1):
    tmp = int(pow(i, 0.5))
    if tmp * tmp == i:
        break
print(i)


Fixed submission:
N = int(input())
tmp = 1
for i in range(N, 1, -1):
    tmp = int(pow(i, 0.5))
    if tmp * tmp == i:
        break
print(tmp * tmp)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

ans = 0
for j in range(len(B)):
    axb = bisect.bisect_left(A, B[j])
    bxc = len(C) - len(C[:bisect.bisect(C, B[j])])
    ans += axb * bxc
print(ans)


Fixed submission:
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = map(int, input().split())
C = sorted(map(int, input().split()))
print(sum(bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()))
print(sum(len(A[:bisect.bisect_left(A, b)]) * len(C[bisect.bisect(C, b):]) for b in B))


Fixed submission:
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = map(int, input().split())
C = sorted(map(int, input().split()))
print(sum(bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B))

Buggy python submission (verdict: Runtime Error):
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()))
print(sum(len(A[:bisect.bisect_left(A, b)]) * len(C[bisect.bisect(C, b)]) b for b in B))

Fixed submission:
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = map(int, input().split())
C = sorted(map(int, input().split()))
print(sum(bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
cnt = 0
for a in A:
    for b in B:
        if a >= b:
            continue
        cnt += sum(b < c for c in C)
print(cnt)


Fixed submission:
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = map(int, input().split())
C = sorted(map(int, input().split()))
print(sum(bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

for i in range(len(S)):
    for j in range(len(T)):
        if S[i+j] != "?" and S[i+j] != T[j]:
            break
    else:
        S = S[:i] + T
        S = S.replace('?', 'a')
        print(S)
        break
else:
    print("UNRESTORABLE")


Fixed submission:
S = input()
T = input()
ans = []
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        tmp = S[:i] + T + S[i+len(T):]
        ans.append(tmp.replace('?', 'a'))
if ans:
    print(ans[-1])
else:
    print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
for _ in range(N):
    l, r = map(int, input().split())
    ans += (r - l) + 1
print(ans)


Fixed submission:
print("Yes" if "9" in input() else "No")
Buggy python submission (verdict: Runtime Error):
s = input()
print("".join([s[i] for i in range(0, len(s), 2)))


Fixed submission:
s = input()
print("".join([s[i] for i in range(0, len(s), 2)]))
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
res = list(set(range(A, B+1)) & set(range(C, D+1)))
print(res[-1] - res[0])


Fixed submission:
A, B, C, D = map(int, input().split())
res = list(set(range(A, B+1)) & set(range(C, D+1)))
try:
    print(res[-1] - res[0])
except:
    print(0)
Buggy python submission (verdict: Runtime Error):
print("Impossible" if sum(map(int, input.split())) % 3 else "Possible")


Fixed submission:
A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")

Buggy python submission (verdict: Runtime Error):
print("Impossible" if sum(map(int, input)) % 3 else "Possible")


Fixed submission:
A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [0] + [int(input()) for _ in range(N)]
preid = 1
ans = 0
while True:
    tmp = preid
    ans += 1
    if a[preid] == 2:
        print(ans)
        break
    preid = a[preid]
    if a[tmp] == a[preid]:
        print(-1)
        break


Fixed submission:
N = int(input())
a = [0] + [int(input()) for _ in range(N)]
ans = 0
idx = 1
flag = False
for i in range(N):
    ans += 1
    if a[idx] == 2:
        print(ans)
        flag = True
        break
    idx = a[idx]
else:
    print(ans if flag else -1)
Buggy python submission (verdict: Runtime Error):
print("NO " if map(int, "".join(input().split())) % 4 else "YES")


Fixed submission:
print("NO " if int("".join(input().split())) % 4 else "YES")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power = 1
for i in range(1, N+1):
    power *= i
print(power % (10**9+7))


Fixed submission:
from math import factorial as F
N = int(input())
print(F(N) % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
ans = 0
for X in range(min(K+1, S+1)):
    for Y in range(min(K+1, S+1)):
        for Z in range(min(K+1, S+1)):
            ans += (S - (X+Y)) == Z
print(ans)


Fixed submission:
K, S = map(int, input().split())
ans = 0
for X in range(min(K+1, S+1)):
    for Y in range(min(K+1, S+1)):
        ans += 0 <= (S - (X + Y)) <= K
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
while b % x:
    b -= 1
if a == 0:
    print(b // x + 1)
else:
    print((b // x) - ((a - 1) // x))


Fixed submission:
a, b, x = map(int, input().split())
if a == 0:
    print(b // x + 1)
else:
    print((b // x) - ((a - 1) // x))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
print(sum(i % x == 0 for i in range(a, b+1)))


Fixed submission:
a, b, x = map(int, input().split())
if a == 0:
    print(b // x + 1)
else:
    print((b // x) - ((a - 1) // x))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(len(set(a, b, c)))


Fixed submission:
a, b, c = map(int, input().split())
print(len(set([a, b, c])))
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int, input().split())
A=[1]*a
B=[0]*b
C=[-1]*c
L=A+B+C
print(sum(L[:k]))

Fixed submission:
a,b,c,k = map(int, input().split())
if k <= a: 
  print(k)
elif k <= a+b:
  print(a)
else:
  print(2*a+b-k)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,x = map(int, input().split())
import numpy as np
C = []
A = np.array([[0]*m]*n)
for i in range(n):
    l = list(map(int, input().split()))
    C.append(l[0])
    A[i] += np.array(l[1:])
D = sum(A[j] for j in range(n))
ans=[sum(C)]
L=set(range(n))

def f(L, D, cost):
    global x, A
    for i in L:
        next_D = D-A[i]
        if min(next_D) >= x:
            ans.append(cost-C[i])
            next_L = L^{i}
            f(next_L, next_D, cost-C[i])
f(L, D, sum(C))

if min(D) < x:
    print(-1)
else:
    print(min(ans))

Fixed submission:
n,m,x = map(int, input().split())
import numpy as np
C = np.array([0]*n)
A = np.array([[0]*m]*n)
for i in range(n):
    l = list(map(int, input().split()))
    C[i] += l[0]
    A[i] += np.array(l[1:])

def L(i):
    X = []
    for j in range(n):
        X.append(i%2)
        i = i//2
    X.reverse() 
    return np.array(X)

ans = []
for k in range(2**n):
    D = np.dot(L(k), A)
    if min(D) >= x:
        ans.append(np.dot(C, L(k)))
        
if ans == []:
    print(-1)
else:
    print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
import sys
sys.setrecursionlimit(4000)

def f(n):
  if n == 1:
    return 101
  else:
    return int(f(n-1)*1.01)
n = 1
while f(n) < x:
  n += 1
else:
  print(n)

Fixed submission:
x = int(input())
import sys
sys.setrecursionlimit(4000)

import math
p = math.log(1.01, 10)
q = int(math.log(x/100, 10)/p)


def f(n):
  if n == 1:
    return 101
  else:
    return int(f(n-1)*1.01)
n = q
while f(n) < x:
  n += 1
else:
  print(n)

Buggy python submission (verdict: Runtime Error):
x = int(input())
import sys
sys.setrecursionlimit(2000)

def f(n):
  if n == 1:
    return 101
  else:
    return int(f(n-1)*1.01)
n = 1
while f(n) < x:
  n += 1
else:
  print(n)


Fixed submission:
x = int(input())
import sys
sys.setrecursionlimit(4000)

import math
p = math.log(1.01, 10)
q = int(math.log(x/100, 10)/p)


def f(n):
  if n == 1:
    return 101
  else:
    return int(f(n-1)*1.01)
n = q
while f(n) < x:
  n += 1
else:
  print(n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
S=[]
for i in range(n):
  S.append(int(input()))
T = set(S)
print(len(T))

Fixed submission:
n = int(input())
S=[]
for i in range(n):
  S.append(input())
T = set(S)
print(len(T))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
from fractions import gcd
from functools import reduce

x = 0
for a in range(1, k+1):
  for b in range(a, k+1):
    for c in range(b, k+1):
      if len({a, b, c})==1:
        x += reduce(gcd, [a,b,c])
      elif len({a, b, c})==2:
        x += 3*reduce(gcd, [a,b,c])
      else:
        x += 6*reduce(gcd, [a,b,c])
      
print(x)


Fixed submission:
k = int(input())
from fractions import gcd
from functools import reduce

x = 3*k*k - 3*k +1
for a in range(2, k+1):
  for b in range(a, k+1):
    if gcd(a,b)==1:
      x += 6*(k-b)+3
    else:
      for c in range(b, k+1):
        if len({a, b, c})==1:
          x += reduce(gcd, [a,b,c])
        elif len({a, b, c})==2:
          x += 3*reduce(gcd, [a,b,c])
        else:
          x += 6*reduce(gcd, [a,b,c])
      
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
from fractions import gcd
from functools import reduce

x = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      x += reduce(gcd, [a,b,c])
      
print(x)

Fixed submission:
k = int(input())
from fractions import gcd
from functools import reduce

x = 3*k*k - 3*k +1
for a in range(2, k+1):
  for b in range(a, k+1):
    if gcd(a,b)==1:
      x += 6*(k-b)+3
    else:
      for c in range(b, k+1):
        if len({a, b, c})==1:
          x += reduce(gcd, [a,b,c])
        elif len({a, b, c})==2:
          x += 3*reduce(gcd, [a,b,c])
        else:
          x += 6*reduce(gcd, [a,b,c])
      
print(x)
Buggy python submission (verdict: Runtime Error):
x, y, z =map(int, input().split())
A=[z, x, y]
print(' '.join(A))


Fixed submission:
x, y, z =map(int, input().split())
A=[z, x, y]
print(' '.join(map(str, A)))
Buggy python submission (verdict: Runtime Error):
k, n = map(int, input().split())
A=[]
for i in range(n):
  A.append(int(input()))
B=[]
for i in range(n-1):
  B.append(A[i+1]-A[i])
B.append(k-A[n-1]+A[0])
print(k-max(B))

Fixed submission:
k, n = map(int, input().split())
A=list(map(int, input().split()))
B=[]
for i in range(n-1):
  B.append(A[i+1]-A[i])
B.append(k-A[n-1]+A[0])
print(k-max(B))
Buggy python submission (verdict: Runtime Error):
n, x, y = map(int, input().split())

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1,k):
    if i<=l:
      M += g(m,k-i)*2/m
  return M

A=[n]
for i in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(c)
for i in range(n-1):
  print(A[i])
    

Fixed submission:
n, x, y = map(int, input().split())

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1, k):
    if  i<=l and k-i >1:
      M += g(m,k-i)*2/m
    elif i<=l:
      M +=1 
  return M
    
A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(int(c))

for i in range(n-1):
  print(A[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split())
from collections import Counter
L = list(Counter(A))
LV = L.values()

ans = 0
for x in LV:
    ans += x*(x-1)//2

for k in range(n):
    print(ans-(A[k]-1)) 

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
D = Counter(A)
L = list(D.values())

ans = 0
for x in L:
    ans += x*(x-1)//2

for k in range(n):
    print(ans-(D[A[k]]-1))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
import.math

A = a+b+2*math.sqrt(a*b)

if A < c:
  print("Yes")
else:
  print("No")


Fixed submission:
a,b,c = map(int, input().split())
x = c-a-b

if x <= 0:
  print("No")
elif 4*a*b >= x**2:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
import.math

A = a+b+2*sqrt(a*b)

if A < c:
  print("Yes")
else:
  print("No")


Fixed submission:
a,b,c = map(int, input().split())
x = c-a-b

if x <= 0:
  print("No")
elif 4*a*b >= x**2:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
a, b, m = map(int, input().split())
A = [map(int, input().split())]
B = [map(int, input().split())]
C = sorted(A)
D = sorted(B)
l = C[0] + D[0]

for i in range(m):
  x, y, c = map(int, input().split())
  k = A[x-1] + B[y-1] -c
  if l > k:
    l = k
  else:
    l = l
print(l)

Fixed submission:
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(A)
D = sorted(B)
l = C[0] + D[0]
for i in range(m):
  x, y, c = map(int, input().split())
  k = A[x-1] + B[y-1] -c
  if l > k:
    l = k
print(l)

Buggy python submission (verdict: Runtime Error):
a, b, m = map(int, input().split())
A = [map(int, input().split())]
B = [map(int, input().split())]
C = sorted(A)
D = sorted(B)
l = C[0] + D[0]

for i in range(m):
  x, y, c = map(int, input().split())
  k = A[x-1] + B[y-1] -c
  if l > k:
    l = k
  else:
    continue
print(l)
  

Fixed submission:
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(A)
D = sorted(B)
l = C[0] + D[0]
for i in range(m):
  x, y, c = map(int, input().split())
  k = A[x-1] + B[y-1] -c
  if l > k:
    l = k
print(l)