Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def chk(a,t):     # t=True(奇数項が正), t=False(偶数項が正) 
    cnt=0   # 操作回数
    x=0     # 塁積和        
    for i in a:
        x+=i      
        if t==True and x<=0:       # 正項予定なのに累積が負か0
            cnt+=1-x                              
            x=x+(1-x)               # 今回のcntで符号変更
        elif t==False and x>=0:   # 負項予定なのに累積が正か0
            cnt+=1+x              
            x=x-(1+x)              # 今回のcntで符号変換
        t = not t                  # 次の項は符号が逆
    return cnt
print(min(chk(a,True),chk(a,False)))

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

def chk(a,t):     # t=True(奇数項が正), t=False(偶数項が正) 
    cnt=0   # 操作回数
    x=0     # 塁積和        
    for i in a:
        x+=i      
        if t==True and x<=0:       # 正項予定なのに累積が負か0
            cnt+=1-x                              
            x=x+(1-x)               # 今回のcntで符号変更
        elif t==False and x>=0:   # 負項予定なのに累積が正か0
            cnt+=1+x              
            x=x-(1+x)              # 今回のcntで符号変換
        t = not t                  # 次の項は符号が逆
    return cnt

print(min(chk(a,True),chk(a,False)))
Buggy python submission (verdict: Runtime Error):
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < c:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)

Fixed submission:
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < C:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)

Buggy python submission (verdict: Runtime Error):
bus = 1
time = 0
for i in range(N):
    if T[i]-time > K:
        bus +=1
        time = T[i]
    else:
        time = time
print(bus)

Fixed submission:
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < C:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
pow = 1
for i in range (1,N+1):
    pow *=  i
print(pow%(10**9+7))

Fixed submission:
N = int(input())
pow = 1
for i in range(1,N+1):
    pow = pow*i%(10**9+7)
print(pow)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k==S:
                cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S-i-j
        if 0<=k<=K:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k==S:
                cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S-i-j
        if 0<=k<=K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K-1
print(ans)

Fixed submission:
N, K = map(int,input().split())
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K-1
print(ans)
Buggy python submission (verdict: Runtime Error):
v = input().split(" ")
x = int(v[0])
k = int(v[1])
d = int(v[2])

if ((k * d) > abs(x)):
    y = x // d
    if ((k - y) % 2 == 0):
        ans = abs(x) - y * d
    else:
        ans = abs(x - (x // abs(x)) * (y + 1) * d)
else:
    ans = abs(x) - k * d


print(ans)

Fixed submission:
v = input().split(" ")
x = int(v[0])
k = int(v[1])
d = int(v[2])

if (x == 0):
    if (k % 2 == 0):
        ans = 0
    else:
        ans = d
else:
    if ((k * d) > abs(x)):
        y = abs(x) // d
        ans = abs(abs(x) - y * d)
        if ((k - y) % 2 == 1):
            ans = abs(d - ans)
    else:
        ans = abs(x) - k * d


print(ans)

Buggy python submission (verdict: Runtime Error):
x = int(input())
k = int(input())
d = int(input())

if ((k * d) > abs(x)):
    y = x // d
    if ((k - y) % 2 == 0):
        ans = abs(x) - y * d
    else:
        ans = abs(x - (x // abs(x)) * (y + 1) * d)
else:
    ans = abs(x) - k * d


print(ans)

Fixed submission:
v = input().split(" ")
x = int(v[0])
k = int(v[1])
d = int(v[2])

if (x == 0):
    if (k % 2 == 0):
        ans = 0
    else:
        ans = d
else:
    if ((k * d) > abs(x)):
        y = abs(x) // d
        ans = abs(abs(x) - y * d)
        if ((k - y) % 2 == 1):
            ans = abs(d - ans)
    else:
        ans = abs(x) - k * d


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353

N, K = list(map(int, input().split()))
move = []
for _ in range(K):
    L, R = list(map(int, input().split()))
    for i in range(L, R+1):
        move.append(i)
dp = [0]*(2*N+10)
dp[0] = 1
for i in range(N):
    tmp = dp[i]
    for m in move:
        dp[i+m] += tmp
        dp[i+m] %= mod
print(dp[N-1])

Fixed submission:
mod = 998244353

N, K = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(K)]
dp = [0]*(2*N+10)
dp[0] = 1
tmp = 0
for i in range(N):
    tmp += dp[i]
    tmp %= mod
    for L, R in S:
        dp[i+L] += tmp
        dp[i+R+1] -= tmp
print(dp[N-1]%mod)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from itertools import combinations

N = int(input())
L = Counter(list(map(int, input().split())))
ans = 0
for sides in combinations(L.keys(), 3):
    a, b, c = sides.sorted()
    if a + b > c:
        ans += L[a]*L[b]*L[c]
print(ans)

Fixed submission:
from itertools import combinations

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

def f(a, b, c):
    return len(set([a, b, c])) == 3 and a+b>c and b+c>a and c+a>b

ans = 0
for a, b, c in combinations(L, 3):
    if f(a, b, c):
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from itertools import combinations

N = int(input())
L = Counter(list(map(int, input().split())))
ans = 0
for sides in combinations(L.keys(), 3):
    a, b, c = sides.sorter()
    if a + b > c:
        ans += L[a]*L[b]*L[c]
print(ans)

Fixed submission:
from itertools import combinations

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

def f(a, b, c):
    return len(set([a, b, c])) == 3 and a+b>c and b+c>a and c+a>b

ans = 0
for a, b, c in combinations(L, 3):
    if f(a, b, c):
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
pos = []
neg = []
for a in A:
    if a >= 0:
        pos.append(a)
    else:
        neg.append(-1*a)

pos.sort(reverse=True)
neg.sort(reverse=True)
p_l = len(pos)
n_l = len(neg)
sign = 1
i, j = 0, 0
for _ in range(K):
    if pos[i] > neg[j] and i < p_l - 1:
        i += 1
    elif pos[i] <= neg[j] and j < n_l - 1:
        j += 1
        sign *= -1
    elif i < p_l - 1:
        j += 1
        sign *= -1
    elif j < n_l - 1:
        i += 1
if sign == -1:
    a, b = -1, -1
    if i < p_l - 1:
        a = pos[i+1]/neg[j]
    if j < n_l - 1:
        b = neg[j+1]/pos[i]
    if a > b:
        i += 1
        j -= 1
    else:
        i -= 1
        j += 1

ans = 1
for p in pos[:i]:
    ans *= p
for n in neg[:j]:
    ans *= n

print(ans)


Fixed submission:
mod = 1000000007
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
ans = 1
# 選択の余地がない時
if len(A) == K:
    for i in range(K):
        ans = ans * (A[i]%mod) % mod
# 負になってしまう時
elif A[-1] < 0 and K%2 == 1:
    for i in range(K):
        ans = ans * (A[-i-1]%mod) % mod
else:
    n = 0
    p = -1
    # Kが奇数の時、正の候補の最大値をあらかじめ消費しておき、偶数の時と同様に処理できるようにする。
    if K%2 == 1:
        ans = ans * (A[p]%mod) % mod
        p -= 1
    # 正/負の候補から２つずつ消費していく
    for _ in range(K//2):
        if A[n]*A[n+1] > A[p]*A[p-1]:
            ans = ans * (A[n]%mod) % mod
            ans = ans * (A[n+1]%mod) % mod
            n += 2
        else:
            ans = ans * (A[p]%mod) % mod
            ans = ans * (A[p-1]%mod) % mod
            p -= 2        

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
seen = [0]*(200000+1)
A.sort()
ans = 0
for a in A:
    if seen[a] == 0:
        ans += 1
        x = a
        j = 1
        while x <= 200000:
            seen[x] = 1
            j += 1
            x = a*j
print(ans)

Fixed submission:
from collections import Counter
 
N = int(input())
A_raw = Counter(list(map(int, input().split())))
A = [x[0] for x in A_raw.items() if x[1] == 1]
A.sort()
B = [x[0] for x in A_raw.items() if x[1] > 1]
B.sort()
seen = [0]*(1000000+1)
for b in B:
    if seen[b] == 0:
        x = b
        j = 1
        while x <= 1000000:
            seen[x] = 1
            j += 1
            x = b*j
ans = 0
for a in A:
    if seen[a] == 0:
        ans += 1
        x = a
        j = 1
        while x <= 1000000:
            seen[x] = 1
            j += 1
            x = a*j
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
seen = [0]*(200+1)
A.sort()
ans = 0
for a in A:
    if seen[a] == 0:
        ans += 1
        x = a
        j = 1
        while x <= 200:
            seen[x] = 1
            j += 1
            x = a*j
print(ans)

Fixed submission:
from collections import Counter
 
N = int(input())
A_raw = Counter(list(map(int, input().split())))
A = [x[0] for x in A_raw.items() if x[1] == 1]
A.sort()
B = [x[0] for x in A_raw.items() if x[1] > 1]
B.sort()
seen = [0]*(1000000+1)
for b in B:
    if seen[b] == 0:
        x = b
        j = 1
        while x <= 1000000:
            seen[x] = 1
            j += 1
            x = b*j
ans = 0
for a in A:
    if seen[a] == 0:
        ans += 1
        x = a
        j = 1
        while x <= 1000000:
            seen[x] = 1
            j += 1
            x = a*j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for _ in range(K):
    tmp = [0]*N
    for i in range(N):
        left = max(0, i-A[i])
        right = min(N-1, i+A[i])
        for j in range(left, right+1):
            tmp[j] += 1
    A = tmp[:]
    if all([N == x for x in A]):
        break
print(*A)

Fixed submission:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for _ in range(min(K, 42)):
    B = [0]*N
    for i in range(N):
        left = max(0, i-A[i])
        right = min(N-1, i+A[i])
        B[left] += 1
        if right+1 <= N-1:
            B[right+1] -= 1
    for i in range(N-1):
        B[i+1] += B[i]
    A = B[:]
print(*A)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if N == 0 and A[0] == 1:
    print(1)
else:
    nodes = [0]*(N+1)
    s_d = 0 # 飽和してないノードが残ってる深さ
    cap_d = 1 - A[0]
    failed = False
    for i, a in enumerate(A):
        # a個の葉をなるべく浅いノードから取る
        while a > 0:
            # これ以上分岐することろがなければ失敗
            if i < s_d or cap_d <= 0:
                failed = True
                break
            # s_dから枝を取れるだけ取る
            x = min(cap_d - nodes[s_d], a)
            a -= x
            nodes[s_d:i+1] = [node + x for node in nodes[s_d:i+1]]
            # s_dがいっぱいになったら深さを一つ進める
            if nodes[s_d] >= cap_d:
                cap_d -= A[s_d]
                cap_d *= 2
                s_d += 1
        if failed:
            break
    print(-1 if failed else sum(nodes))

Fixed submission:
H1, M1, H2, M2, K = list(map(int, input().split()))
print(H2*60 + M2 - K - H1*60 - M1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
if N == 0 and A[0] == 1:
    print(1)
else:
    nodes = [0]*(N+1)
    s_d = 0 # 飽和してないノードが残ってる深さ
    cap_d = 1 - A[0]
    failed = False
    for i, a in enumerate(A):
        # a個の葉をなるべく浅いノードから取る
        while a > 0:
            # これ以上分岐することろがなければ失敗
            if i < s_d or cap_d <= 0:
                failed = True
                break
            # s_dから枝を取れるだけ取る
            x = min(cap_d - nodes[s_d], a)
            a -= x
            nodes[s_d:i+1] = [node + x for node in nodes[s_d:i+1]]
            # s_dがいっぱいになったら深さを一つ進める
            if nodes[s_d] >= cap_d:
                cap_d -= A[s_d]
                cap_d *= 2
                s_d += 1
        if failed:
            break
    print(-1 if failed else sum(nodes))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cap = [[0, 0] for _ in range(N+1)]
cap[-1] = [A[-1], A[-1]]
for i in range(N-1,-1,-1):
    cap[i][0] = (cap[i+1][0] + 2 - 1)//2
    cap[i][1] = cap[i+1][1] + A[i]
ans = 1
nodes = 1
failed = nodes < cap[0][0]
for i in range(N):
    nodes = min((nodes - A[i])*2, cap[i+1][1])
    if nodes < cap[i+1][0]:
        failed = True
        break
    ans += nodes
print(-1 if failed else ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
if N == 0 and A[0] == 1:
    print(1)
else:
    nodes = [0]*(N+1)
    s_d = 0 # 飽和してないノードが残ってる深さ
    cap_d = 1 - A[0]
    failed = False
    for i, a in enumerate(A):
        # a個の葉をなるべく浅いノードから取る
        while a > 0:
            # これ以上分岐することろがなければ失敗
            if i < s_d or cap_d <= 0:
                failed = True
                break
            # s_dから枝を取れるだけ取る
            x = min(cap_d - nodes[s_d], a)
            a -= x
            nodes[s_d:i+1] = [node + x for node in nodes[s_d:i+1]]
            # s_dがいっぱいになったら深さを一つ進める
            if nodes[s_d] >= cap_d:
                cap_d -= A[s_d]
                cap_d *= 2
                s_d += 1
        if failed:
            break
    print(-1 if failed else sum(nodes))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cap = [[0, 0] for _ in range(N+1)]
cap[-1] = [A[-1], A[-1]]
for i in range(N-1,-1,-1):
    cap[i][0] = (cap[i+1][0] + 2 - 1)//2
    cap[i][1] = cap[i+1][1] + A[i]
ans = 1
nodes = 1
failed = nodes < cap[0][0]
for i in range(N):
    nodes = min((nodes - A[i])*2, cap[i+1][1])
    if nodes < cap[i+1][0]:
        failed = True
        break
    ans += nodes
print(-1 if failed else ans)
Buggy python submission (verdict: Runtime Error):
from itertools import product
import numpy as np

N, M, X = list(map(int, input().split()))
conditions = product([0, 1], repeat=N)
A = np.array([list(map(int, input().split())) for i in range(N)])
succeed = []
for c in conditions:
    p = A * np.array(c).reshape((N, 1))
    res = p.sum(axis=0)
    if np.all(res[1:] >= X):
        succeed.append(res[0])
print(min(succeed) if len(succeed) > 0 else -1)

Fixed submission:
S = input()
T = input()
print('Yes' if T[:-1] == S else 'No')
Buggy python submission (verdict: Runtime Error):
from itertools import product
import numpy as np

N, M, X = list(map(int, input().split()))
conditions = product([0, 1], repeat=N)
A = np.array([list(map(int, input().split())) for i in range(N)])
succeed = []
for c in conditions:
    p = A * np.array(c).reshape((N, 1))
    res = p.sum(axis=0)
    if np.all(res[1:] >= X):
        succeed.append(res[0])
print(min(succeed) if len(succeed) > 0 else -1)

Fixed submission:
N, M, X = list(map(int, input().split()))
conditions = [str(bin((2**N + i) & (2**(N+1) - 1)))[3:] for i in range(2**N)]
Q = [list(map(int, input().split())) for i in range(N)]
ans = -1
for c in conditions:
    res = [0]*(M+1)
    for i in range(N):
        if c[i] == '1':
            for j in range(M+1):
                res[j] += Q[i][j]

    failed = False
    for i in range(1, M+1):
        if res[i] >= X:
            continue
        else:
            failed = True
    if failed:
        continue
    else:
        if ans == -1:
            ans = res[0]
        else:
            ans = min(ans, res[0])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
a, b = 0, -24
while a**5 - b**5 != X:
    a += 1
    b = -24
    while a**5 - b**5 != X:
        b += 1
print(a, b)


Fixed submission:
def f(X):
    for i in range(1, 120):
        for j in range(-63, 119):
            if i**5 - j**5 == X:
                return i, j
X = int(input())
print(*f(X))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A_plus_i = [i + A[i] for i in range(N)]
A_minus_i = [A[i] - i for i in range(N)]
keys = [-x for x in A_minus_i if x < 0]
ans = 0
for key in keys:
    ans += A_plus_i.count(key)
print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
i_plus_A = Counter([i + A[i] for i in range(N)])
i_minus_A = [i - A[i] for i in range(N)]
ans = 0
for x in i_minus_A:
    ans += i_plus_A[x]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A_plus_i = [(i+1) + A[i] for i in range(N)]
A_minus_i = [(i+1) - A[i] for i in range(N)]
ans = 0
for i in range(N-1):
    ans += A_minus_i[i+1:].count(A_plus_i[i])
print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
i_plus_A = Counter([i + A[i] for i in range(N)])
i_minus_A = [i - A[i] for i in range(N)]
ans = 0
for x in i_minus_A:
    ans += i_plus_A[x]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    start = i + A[i] + 1
    if start < N:
        for j in range(start, N):
            if abs(i-j) == A[i] + A[j]:
                ans += 1
print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
i_plus_A = Counter([i + A[i] for i in range(N)])
i_minus_A = [i - A[i] for i in range(N)]
ans = 0
for x in i_minus_A:
    ans += i_plus_A[x]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

X, Y, A, B, C= list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort(reverse=True)
P = P[:X]
Q = list(map(int, input().split()))
Q.sort(reverse=True)
Q = Q[:Y]
R = list(map(int, input().split()))
R.sort(reverse=True)
colored = []
for r in R:
    p_min = P[-1]
    q_min = Q[-1]
    if p_min <= q_min and p_min < r:
        P.pop()
        P.insert(0, r)
    elif q_min <= p_min and q_min < r:
        Q.pop()
        Q.insert(0, r)
    else:
        break
print(sum(P) + sum(Q))

Fixed submission:
import heapq

X, Y, A, B, C= list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort(reverse=True)
P = P[:X]
heapq.heapify(P)
Q = list(map(int, input().split()))
Q.sort(reverse=True)
Q = Q[:Y]
heapq.heapify(Q)
R = list(map(int, input().split()))
R.sort(reverse=True)
for r in R:
    p_min = P[0]
    q_min = Q[0]
    if p_min <= q_min and p_min < r:
        heapq.heapreplace(P, r)
    elif q_min <= p_min and q_min < r:
        heapq.heapreplace(Q, r)
    else:
        break
print(sum(P) + sum(Q))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
reverse = False
for i in range(Q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:
        if query[1] == '1':
            if not reverse:
                S = query[2] + S
            else:
                S = S + query[2]
        else:
            if reverse:
                S = query[2] + S
            else:
                S = S + query[2]
if reverse: S = S[::-1]
print(S)

Fixed submission:
from collections import deque

S = deque(list(input()))
Q = int(input())
reverse = True
for i in range(Q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:
        right = query[1] == '1'
        if right == reverse:
            S.appendleft(query[2])
        else:
            S.append(query[2])
if not reverse:
    print(''.join(list(reversed(S))))
else:
    print(''.join(list(S)))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

N, K = list(map(int, input().split()))
P = list(map(lambda x: int(x) + 1, input().split()))
P_cumsum = list(accumulate(P))
print(max([P_cumsum[i+K]-P_cumsum[i] for i in range(N-K)])/2)

Fixed submission:
from itertools import accumulate

N, K = list(map(int, input().split()))
P = list(map(lambda x: int(x) + 1, input().split()))
P_cumsum = [0] + list(accumulate(P))
print(max([P_cumsum[i+K]-P_cumsum[i] for i in range(N-K+1)])/2)
Buggy python submission (verdict: Runtime Error):
import bisect

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
if sum(A) <= K:
    print(0)
else:
    left = 0
    right = max([A[i]*F[i] for i in range(N)])
    while left + 1 != right:
        mid = int((left + right) / 2)
        train_n = sum([A[i]-mid//F[i] for i in range(N)])
        if train_n > K:
            left = mid
        else:
            right = mid
    print(right)


Fixed submission:
A, B = list(map(int, input().split()))
if A > 9 or B > 9:
    print(-1)
else:
    print(A*B)
Buggy python submission (verdict: Runtime Error):
import math

a, b, x = list(map(int, input().split()))
if a**2*b/2 < x:
    h = 2*x/(a**2)-b
    theta = math.atan(a/(b-h))
else:
    h = 2*x/a/b
    theta = math.atan(h/b)

print(90 - math.degrees(theta))


Fixed submission:
import math

a, b, x = list(map(int, input().split()))
if a**2*b == x:
    theta = 90
elif a**2*b/2 > x:
    h = 2*x/a/b
    theta = math.degrees(math.atan(h/b))
else:
    h = 2*x/(a**2)-b
    theta = math.degrees(math.atan(a/(b-h)))

print(90 - theta)

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

a, b, x = list(map(int, input().split()))
if a**2*b/2 < x:
    h = 2*x/(a**2)-b
    theta = math.atan(a/(b-h))
else:
    h = 2*x/a/b
    theta = math.atan(h/b)

print(90 - math.degrees(theta))


Fixed submission:
import math

a, b, x = list(map(int, input().split()))
if a**2*b == x:
    theta = 90
elif a**2*b/2 > x:
    h = 2*x/a/b
    theta = math.degrees(math.atan(h/b))
else:
    h = 2*x/(a**2)-b
    theta = math.degrees(math.atan(a/(b-h)))

print(90 - theta)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

L.sort()

ans = 0
for i in range(N-2):
    for j in range(N-i-1):
        a = L[i]
        b = L[i+j+1]
        c_left = bisect.bisect_right(L[i+j+2:], b - a)
        c_right = bisect.bisect_left(L[i+j+2:], b + a)
        ans += c_right - c_left
print(ans)


Fixed submission:
import bisect

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

L.sort()

ans = 0
for i in range(N-2):
    for j in range(N-i-1):
        a = L[i]
        b = L[i+j+1]
        c_right = bisect.bisect_left(L[i+j+2:], b + a)
        ans += c_right
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(N*(N-1)//2)

Fixed submission:
S = input()
T = input()
ans = 0
for i in range(3):
    if S[i] == T[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = [0 for i in range(len(S))]
for i in range(len(S)):
    odd = True
    j = i
    odd_j = i
    init_S = S[j]
    while init_S == S[j]:
        if S[j] == 'R':
            j += 1
        else:
            j -= 1
        odd = not odd
        if odd:
            odd_j = j
    ans[odd_j] += 1

print(*ans)

Fixed submission:
S = input()
ans = [0 for i in range(len(S))]

odd = 0
even = 0
for i in range(len(S)):
    if S[i] == 'R':
        tmp = even
        even = odd + 1
        odd = tmp
    else:
        ans[i-1] += even
        ans[i] += odd
        odd = 0
        even = 0

for i in range(len(S)):
    if S[-i-1] == 'L':
        tmp = even
        even = odd + 1
        odd = tmp
    else:
        ans[-i] += even
        ans[-i-1] += odd
        odd = 0
        even = 0

print(*ans)