Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
for j in range(n-1):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c
q, k = [int(i) for i in sys.stdin.readline().split()]
k -= 1
res = dijkstra(csr_matrix(graph), indices=k)
for i in range(q):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    print(int(res[x] + res[y]))

Fixed submission:
import sys
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
import heapq


n = int(input())
graph = {j:[] for j in range(n)}
for j in range(n-1):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append([b,c])
    graph[b].append([a,c])
q, k = [int(i) for i in sys.stdin.readline().split()]
k -= 1
#res = dijkstra(csr_matrix(graph), indices=k)
candidates = [(k,0)]
res = [-1 for i in range(n)]
res[k] = 0
already = set()
while len(candidates) > 0 or len(already) < n:
    candidate, cost = heapq.heappop(candidates)
    already.add(candidate)
    res[candidate] = cost
    for goal, distance in graph[candidate]:
        if res[goal] < 0:
            heapq.heappush(candidates, (goal, cost + distance))

for i in range(q):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    print(int(res[x] + res[y]))
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
graph = {i : [] for i in range(n)}
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

stack = [0]
already = set()
parent = [i for i in range(n)]
flg = False
while len(stack) > 0:
    cur = stack.pop(-1)
    already.add(cur)
    for _next in graph[cur]:
        if _next not in already:
            stack.append(_next)
            parent[_next] = cur
            if _next == n - 1:
                flg = True
                break
    if flg:
        break

path = []
cur = n - 1
while cur != 0:
    path.append(cur)
    cur = parent[cur]
path.append(0)
path.reverse()
flg_2 = len(path) % 2 != 0
left = path[len(path) // 2 - 1 + flg_2]
right = path[len(path) // 2 + flg_2]

def dfs(x, last):
    res = 1
    for _next in graph[x]:
        if _next != last:
           res += dfs(_next, x)
    return res

left_res = dfs(left, right)
#print(left_res)
print("Fennec" if left_res > (n - left_res) else "Snuke")


Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n = int(input())
graph = {i : [] for i in range(n)}
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

stack = [0]
already = set()
parent = [i for i in range(n)]
flg = False
while len(stack) > 0:
    cur = stack.pop(-1)
    already.add(cur)
    for _next in graph[cur]:
        if _next not in already:
            stack.append(_next)
            parent[_next] = cur
            if _next == n - 1:
                flg = True
                break
    if flg:
        break

path = []
cur = n - 1
while cur != 0:
    path.append(cur)
    cur = parent[cur]
path.append(0)
path.reverse()
flg_2 = len(path) % 2 != 0
left = path[len(path) // 2 - 1 + flg_2]
right = path[len(path) // 2 + flg_2]

def dfs(x, last):
    res = 1
    for _next in graph[x]:
        if _next != last:
           res += dfs(_next, x)
    return res

left_res = dfs(left, right)
#print(left_res)
print("Fennec" if left_res > (n - left_res) else "Snuke")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = []
for i, a in enumerate(a_ls):
    if i % 2 == 0:
        b_ls.append(a)
    else:
        b_ls = [a] + b_ls
if n % 2 == 1:
    b_ls.reverse()
print(" ".join([str(i) for i in b_ls]))

Fixed submission:
import sys
from collections import deque
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = deque([])
for i, a in enumerate(a_ls):
    if i % 2 == 0:
        b_ls.append(a)
    else:
        b_ls.appendleft(a)
if n % 2 == 1:
    b_ls.reverse()
print(" ".join([str(i) for i in b_ls]))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
len_s = len(s)
INF = 1e10
memo_ls = [[0 if j < (i+3)//2 else -INF for j in range(len_s)] for i in range(len_s)]
# memo_ls[i][j] : i回目までにj回パーを出した場合の得点
for i, enemy in enumerate(s):
    if i == 0:
        memo_ls[0][0] = -1 if enemy == "p" else 0
        continue
    for j in range((i+3)//2):
        if j == 0:
            memo_ls[i][j] = memo_ls[i-1][0] if enemy == "g" else memo_ls[i-1][0] - 1
            continue
        if enemy == "g":
            memo_ls[i][j] = max(memo_ls[i-1][j-1]+1, memo_ls[i-1][j])
        else:
            memo_ls[i][j] = memo_ls[i-1][j] - 1
print(max(memo_ls[-1]))

Fixed submission:
s = input()
len_s = len(s)
cnt = 0
enemy = []
me = []
INF = 1e10
for i, _s in enumerate(s):
    if _s == "p":
        cnt += 1
    enemy.append(cnt)
    me.append((i+1) // 2)
    diff = (i + 1) // 2 - cnt
print(diff)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

if m == 0:
    print(0, 0)
else:
    check_list = [0]*20000
    wa = 0
    ac = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if check_list[p] == 1:
            continue
        elif check_list[p] == 0 and s == 'AC':
            check_list[p] = 1
            ac += 1
        elif check_list[p] ==0 and s == 'WA':
            wa += 1
    print(ac, wa)

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

ac_list = [0]*(n+1)
wa_list = [0]*(n+1)
wa = 0
ac = 0
if m == 0:
    pass
else:
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if ac_list[p] == 1:
            continue
        if ac_list[p] == 0 and s == 'AC':
            ac_list[p] = 1
        #elif check_list[p] == 0 and s == 'WA':                                          
        else:
            wa_list[p] += 1
    for t_ac, t_wa in zip(ac_list, wa_list):
        if t_ac == 1:
            wa += t_wa
            ac += t_ac
print(ac, wa)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

c = 0
for i in range(N):
    c += i
print(c)

Fixed submission:
N = int(input())

c = N*(N-1)//2

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

c_list = []
for i, a in enumerate(a_list[:]):
    b = a_list.pop(i)
    c_list.append(max(a_list))
    a_list.insert(i, b)

for c in c_list:
    print(c)

Fixed submission:
N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

b_in = a_list.index(max(a_list))
b_max = max(a_list)

a_list.pop(b_in)

c_max = max(a_list)

for i in range(N):
    if b_in != i:
        print(b_max)
    else:
        print(c_max)
Buggy python submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

bc = B // C
bd = B // D
be = B // int((C*D/math.gcd(C, D)))
BB = B - bc - bd + be

ac = (A-1) // C
ad = (A-1) // D
ae = (A-1) // int(C*D/math.gcd(C, D))
AA = (A-1) - ac - ad + ae

print(BB-AA)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

A, B, C, D = map(int, input().split())

bc = B // C
bd = B // D
be = B // int((C*D/gcd(C, D)))
BB = B - bc - bd + be

ac = (A-1) // C
ad = (A-1) // D
ae = (A-1) // int(C*D/gcd(C, D))
AA = (A-1) - ac - ad + ae

print(BB-AA)
Buggy python submission (verdict: Runtime Error):
x, a = input()
x = int(x)
a = int(a)

if x < a:
  print(0)
else:
  print(10)

Fixed submission:
x, a = input().split()
x = int(x)
a = int(a)

if x < a:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()

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

res=0
if b/a > c:
    res=c
else:
    res=b/a
print(int(res)

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

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

res=0
if b/a > c:
    res=c
else:
    res=b/a

print(int(res))
Buggy python submission (verdict: Runtime Error):
N, X = input().split()

N = int(N)
X = int(X)

all = 2**(N+2)-3
b_all = 0
for i in range(N+1):
    if i > 0:
        b_all += 2**i

p_all = all - b_all

first = 1
last = all

get = 0
for i in range(N):
    if i < N-1:
        if (first + last) / 2 == X:
            get += (p_all + 1) / 2
            break

        elif (first + last) / 2 < X:
            get += (p_all + 1) / 2
            p_all -= (p_all + 1) / 2
            first = (first + last) / 2 + 1
            last = last - 1

            if first == X:
                break
        elif (first + last) / 2 > X:
            p_all = (p_all - 1) / 2
            last = (first + last) / 2 - 1
            first = first + 1

            if last == X:
                get += p_all
                break
    else:
        if first == X:
            break
        elif last == X:
            get += 3
        else:
            get += X - first
            break

print(int(get))



Fixed submission:
a = int(input())

if a == 25:
    print("Christmas")
elif a == 24:
    print("Christmas Eve")
elif a == 23:
    print("Christmas Eve Eve")
elif a == 22:
    print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(len(B)):
    for j in range(len(A)):
        if A[j] == B[i]:
            A[j] = C[i]
    print(sum(A))

Fixed submission:
import sys
import collections
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = []
C = []

A_collections = collections.Counter(A)
sum_A = sum(A)

for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    b, c = B[i], C[i]
    if b in A_collections.keys():
        A_collections[c] += A_collections[b]
        sum_A += (c - b) * A_collections[b]
        A_collections[b] = 0
    
    print(sum_A)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math

A,B = map(int, input().split())

lcm = A * B // math.gcd(A,B)

print(lcm)

Fixed submission:
import sys
input = sys.stdin.readline
import fractions

A,B = map(int, input().split())

lcm = A * B // fractions.gcd(A,B)

print(lcm)
Buggy python submission (verdict: Time Limit Exceeded):
# aで読む冊数を固定して、bで何冊読めるか考える
# 累積和にしておく、読めるbの冊数は2分探索で求める
# 計算時間はO(N*logM)


# 2分探索、残りの時間を超えないbの冊数を探索
def binary_search(l, item):
    low = 0
    high = len(l) - 1

    while low <= high:
        mid = (low + high) // 2
        guess = l[mid]
        if guess == item:
            return mid
        elif guess > item:
            high = mid - 1 
        else:
            # elseは guess < item の場合なので、l[mid] == l[-1] は　bが全部読めることを示している
            # l[mid+1] > item ならば l[mid] < item（時間） < l[mid+1] となっている、mid冊は読めるけど、mid+1冊を読む時間はないことを示している
            if l[mid] == l[-1] or l[mid+1] > item:
                return mid
            else:
                low = mid + 1


import itertools

n, m, k = map(int, (input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.insert(0, 0)
b.insert(0, 0)

# aとbの累積和を計算
# accumulateオブジェクトをリストに変換
a_cumsum = list(itertools.accumulate(a))
b_cumsum = list(itertools.accumulate(b))



# 読める本の冊数を記録しておくリスト
books = []

# aの冊数を0冊~最大までそれぞれ固定して、bの冊数を求める
for minute in a_cumsum:
    minutes = 0
    numbers = 0
    
    minutes += minute
    
    if minutes <= k:

        # aの冊数を計算
        numbers += a_cumsum.index(minute)

        # 残り時間
        rest_minutes = k - minutes
        
        # bの冊数を計算
        b_books = binary_search(b_cumsum, rest_minutes)
        numbers += int(b_books)
    
    books.append(numbers)

print(max(books))

Fixed submission:
# aで読む冊数を固定して、bで何冊読めるか考える
# 累積和にしておく、読めるbの冊数は2分探索で求める
# 計算時間はO(N*logM)


import itertools
import bisect

n, m, k = map(int, (input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.insert(0, 0)
b.insert(0, 0)

# aとbの累積和を計算
# accumulateオブジェクトをリストに変換
a_cumsum = list(itertools.accumulate(a))
b_cumsum = list(itertools.accumulate(b))


# 読める本の冊数を記録しておくリスト
books = []


# aの冊数を0冊~最大までそれぞれ固定して、bの冊数を求める
for i in range(len(a_cumsum)):
    minutes = 0
    numbers = 0

    a_minutes = a_cumsum[i]  
    minutes += a_minutes
    
    if minutes <= k:

        # aの冊数を計算
        numbers += i

        # 残り時間
        rest_minutes = k - a_minutes
        
        # bの冊数を計算
        if b_cumsum[-1] == rest_minutes:
            b_books = len(b_cumsum) - 1
        else:
            # bisect.bisect_rightは、リストのどこに数値を入れ込めるかのインデックスを返す（右の）
            b_books = bisect.bisect_right(b_cumsum, rest_minutes)
            b_books -= 1
    
        numbers += b_books
    
    books.append(numbers)

print(max(books))
Buggy python submission (verdict: Runtime Error):
import math

# 余弦定理

a, b, h, m = map(int, input().split())

# 12時方向に対して、分針が作る角度
b_degree = 6 * m

# 12時方向に対して、時針が作る角度
# 時針は1時間に30度動くことにも注意
# 10時40分の時、時針は10時の位置から+40/60*30度動いている
a_degree = 30 * h + m / 60 * 30

print(a_degree, b_degree)

# 分針が時針を追い越しているか、追い越していないかで場合分け
# 分針が時針を追い越してない
# 分針が0の場合を考慮してminとる
if a_degree > b_degree:
    degree1 = a_degree - b_degree
    degree2 = 360 - degree1
    degree = min(degree1, degree2)
    print(degree)
    length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(degree)))
elif a_degree < b_degree:
    degree = b_degree - a_degree
    length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(degree))) 
else:
    lenght = b - a

print(length)

Fixed submission:
import math

# 余弦定理

a, b, h, m = map(int, input().split())

# 12時方向に対して、分針が作る角度
b_degree = 6 * m

# 12時方向に対して、時針が作る角度
# 時針は1時間に30度動くことにも注意
# 10時40分の時、時針は10時の位置から+40/60*30度動いている
a_degree = 30 * h + m / 60 * 30

# 分針が時針を追い越しているか、追い越していないかで場合分け
# 分針が時針を追い越してない
# 分針が0の場合を考慮してminとる
if a_degree > b_degree:
    degree1 = a_degree - b_degree
    degree2 = 360 - degree1
    degree = min(degree1, degree2)
    length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(degree)))
elif a_degree < b_degree:
    degree = b_degree - a_degree
    length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(degree))) 
else:
    length = abs(b - a)

print(length)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

n = int(input())
ans = 0

for i in range(1, n+1, 1):
    for j in range(1, n+1, 1):
        for k in range(1, n+1, 1):
            ans += reduce(math.gcd, (i, j, k))

print(ans)

Fixed submission:
# gcdをmathからimport
from math import gcd
n = int(input())
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            # gcd(i,j)とkのgcdを計算
            # 1番小さい数字が制限になる
            ans += gcd(gcd(i, j), k)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ハッシュテーブル　dictionary
n = int(input())
s = list(input() for i in range(n))
s_dict = {}

# 入力文字をkeyに、その文字の入力回数をvalueにした辞書作成
for word in s:
    num = int(s.count(word))
    s_dict[word] = num

# 入力回数が最大の単語のみのリストを作成
# s_dictに含まれるkeyとvalueを1個ずつ抜き出し、s[1](value) がmaxのときs[0](key) を max_sに入れる
max_s = [s[0] for s in s_dict.items() if s[1] == max(s_dict.values())]
# 作成したリストのソート
max_s.sort()

for word in max_s:
    print(word)

Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]

# リストsに含まれる単語と出現回数の辞書を作成
# keyに要素　valueに出現回数 
a = collections.Counter(s)

# 出現回数の最大値を取得
max_a = max(a.values())

# value=max_a　なら　keys　に key（単語） を書き込む
# k / for k, v in a.items() / if v == max_a
keys = [k for k, v in a.items() if v == max_a]
keys.sort()

[print(word) for word in keys]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
p_min = p[0]
p_sum = 1

for i in range(n):
    # リストを前から順にスライス
    p_new = p[0:i+1]
    
    # スライスしたリストの中の最小値を取得
    p_new_min = min(p_new)

    # 今までの最小値と比較して小さい場合
    if p_new_min < p_min:
        p_sum += 1
        # 最小値の更新
        p_min = p_new_min

print(p_sum)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
p_min = p[0]
p_sum = 1

# リストの前から最小値を検索
for i in range(1, n):
    
    # 最小値を見つけた場合
    if p_min > p[i]:
        p_sum += 1
        # 最小値を更新
        p_min = p[i]

print(p_sum)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

ac = 0
ans = [True] * n
wa = [0] * n

for i in range(m):
    question_number, result = input().split()
    num = int(question_number) - 1
    if result == 'AC' and ans[num]:
        ans[num] = False
        ac += 1
    elif result == 'WA' and ans[num]:
        wa[num] += 1

wa_sum = 0

for wa_num in wa:
    if not ans[num]:
        wa_sum += wa_num 

print(ac, wa_sum)

Fixed submission:
n, m=map(int,input().split())
ac = 0
ans=[True] * n
wa=[0] * n

for i in range(m):
    question, result=input().split()
    num = int(question) - 1
    if result == "AC" and ans[num]:
        ans[num]=False
        ac+=1
    # WAかつACされていない場合
    elif result == "WA" and ans[num]:
        wa[num] += 1
 
wa_sum = 0

for i in range(n):
    # 問題がACされている場合、その問題番号のWA回数を足す
    if not ans[i]:
        wa_sum += wa[i]
 
print(ac, wa_sum)

Buggy python submission (verdict: Runtime Error):
# acするまでのwaをそれぞれの問題でカウントする
cnts = [0] * n

# key：acした問題番号、value：waした回数の辞書を作成する
at_dict = {}

for i in range(m):
    question, result = map(str, input().split())
    if result == 'AC':
        # ACした時点で上記で作成した辞書に、key：問題番号、value:wa回数を記入
        at_dict[question] = cnts[int(question)-1]
    elif result == 'WA':
        # WAなら上記のwa回数のリストにカウント
        cnts[int(question)-1] += 1
    
ac = len(at_dict)
wa = sum(v for v in at_dict.values())

print(ac, wa)

Fixed submission:
n, m=map(int,input().split())
ac = 0
ans=[True] * n
wa=[0] * n

for i in range(m):
    question, result=input().split()
    num = int(question) - 1
    if result == "AC" and ans[num]:
        ans[num]=False
        ac+=1
    # WAかつACされていない場合
    elif result == "WA" and ans[num]:
        wa[num] += 1
 
wa_sum = 0

for i in range(n):
    # 問題がACされている場合、その問題番号のWA回数を足す
    if not ans[i]:
        wa_sum += wa[i]
 
print(ac, wa_sum)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
r_n = int(math.sqrt(n))
s = []

for i in range(1, r_n):
    if n%i == 0:
        s.append(n//i + i - 2)
print(min(s))


Fixed submission:
import math

n = int(input())
r_n = int(math.sqrt(n))
s = []

for i in range(1, r_n+1):
    if n%i == 0:
        s.append(n//i + i - 2)
print(min(s))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []

for i in range(1, n):
    k = n%i
    if k == 0:
        s.append(i+n//i-2)
    
print(min(s))

Fixed submission:
import math

n = int(input())
r_n = int(math.sqrt(n))
s = []

for i in range(1, r_n+1):
    if n%i == 0:
        s.append(n//i + i - 2)
print(min(s))
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j

deg = math.degrees(math.atan(tan))
print(90-deg)

Fixed submission:
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan))
    print(90-deg)
elif x == a*a*b:
    print(0)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j
    deg = math.degrees(math.atan(tan))
    print(90-deg)

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
i = a**3
j = 2*(a*a*b-x)
tan1 = i/j
deg = math.degrees(math.atan(tan1))
if x < a*a*b/2:
    tan2 = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan2))

print(90-deg)


Fixed submission:
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan))
    print(90-deg)
elif x == a*a*b:
    print(0)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j
    deg = math.degrees(math.atan(tan))
    print(90-deg)

Buggy python submission (verdict: Runtime Error):
mport math
a, b, x = map(int, input().split())
i = a**3
j = 2*(a*a*b-x)
tan1 = i/j
deg = math.degrees(math.atan(tan1))
if x < a*a*b/2:
    tan2 = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan2))

print(90-deg)

Fixed submission:
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan))
    print(90-deg)
elif x == a*a*b:
    print(0)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j
    deg = math.degrees(math.atan(tan))
    print(90-deg)

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
i = a**3
j = 2*(a*a*b-x)
tan1 = i/j
deg = math.degrees(math.atan(tan1))
if deg < 45:
    tan2 = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan2))

print(90-deg)

Fixed submission:
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan))
    print(90-deg)
elif x == a*a*b:
    print(0)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j
    deg = math.degrees(math.atan(tan))
    print(90-deg)
Buggy python submission (verdict: Time Limit Exceeded):
# 文字のリストを作成し、組み合わせを求めてアナグラムになっているかチェックする
import itertools

n = int(input())
s = list(input() for i in range(n))
s_comb = list(itertools.combinations(s, 2))

count = 0

for i in range(len(s_comb)):
    s_i = s_comb[i][0]
    # 文字列はsort()メッソドが使用できないので、sorted()で新しいリスト作成
    # 文字列を昇順にすることでアナグラムチェックしやすいようにする
    s_i_str_list = sorted(s_i)
    s_j = s_comb[i][1]
    s_j_str_list = sorted(s_j)
    
    # アナグラムかチェック
    if s_i_str_list == s_j_str_list:
        count += 1

print(count)

Fixed submission:
n = int(input())
 
words = {}
anagrams = 0
 
for i in range(n):
    word = "".join(sorted(input()))
    if word not in words:
        words[word] = 1
    else:
        anagrams += words[word]
        words[word] += 1
 
print(anagrams)
Buggy python submission (verdict: Runtime Error):
# リストのうちmaxのインデックス以外は全てmaxを出力、maxのインデックスは2番目に大きい値を出力する
n = int(input())
a = list(int(input()) for _ in range(n))

# リストのmaxとmaxのインデックスを取得
a_max = max(a)
max_index_all = [i for i, x in enumerate(a) if x == a_max]

# リストからmaxを全部削除し、2番目に大きい値を取得
for i in max_index_all:
    a.pop(i)
a_second_max = max(a)


for i in range(n):
    # maxのインデックスでは、2番目に大きな値を出力
    if i in max_index_all:
        print(a_second_max)
    # max以外のインデックスでは、maxを出力
    else:
        print(a_max)

Fixed submission:
import copy
n = int(input())
a = [int(input()) for _ in range(n)]
 
b = copy.deepcopy(a)
b.sort()
max1 = b[-1]
max2 = b[-2]
 
for i in a:
    if i == max1:
        print(max2)
    else:
        print(max1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = list(int(input()) for _ in range(n))

for i in range(n):
    # copy.copyを使用することで新しいオブジェクトを生成し、元のリストが影響を受けない
    b = copy.copy(a)
    b.pop(i)
    print(max(b))


Fixed submission:
import copy
n = int(input())
a = [int(input()) for _ in range(n)]
 
b = copy.deepcopy(a)
b.sort()
max1 = b[-1]
max2 = b[-2]
 
for i in a:
    if i == max1:
        print(max2)
    else:
        print(max1)