Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02787 (python)

Fixed submission:
import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)

H, N = map(int, input().split())

AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append((A, B))

'''
H = 10000
N = 1000
import random
AB = []
for i in range(N):
    A = random.randint(1, 10000)
    B = random.randint(1, 10000)
    AB.append((A, B))
'''




@lru_cache(maxsize=None)
def f(h):
    if h <= 0:
        return 0
    best = float('inf')
    for a, b in AB:
        val = b + f(h - a)
        if val < best:
            best = val
        else:
            break
    return best

AB.sort(key=lambda ab: (ab[0] / ab[1], -ab[0]), reverse=True)
bestA, bestB = AB[0]
threshold = sum(a for a, b in AB)

ans = None
times = (H - threshold) // bestA
if times > 0:
    ans = bestB * times + f(H - bestA * times)
else:
    ans = f(H)

print(ans)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

H, N = map(int, input().split())

AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append((A, B))

threshold = sum(a for a, b in AB)
bestA, bestB = max(AB, key=lambda ab: ab[0] / ab[1])

@lru_cache(maxsize=None)
def f(h):
    if h <= 0:
        return 0
    times = (h - threshold) // bestA
    if times > 0:
        return bestB * times + f(h - bestA * times)

    return min(b + f(h - a) for a, b in AB)

print(f(H))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

H, N = map(int, input().split())

AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append((A, B))

@lru_cache(maxsize=None)
def f(h):
    if h <= 0:
        return 0
    return min(b + f(h - a) for a, b in AB)

print(f(H))
Problem p02602 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if i>=k:
      if a[i]>a[i-k]: print('Yes')
      else: print('No')

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k ;
    int a[n];
    int m = 1, j = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        m*=a[i];
        if (i>=k){
            int n1 = m/a[i];
            m/=a[j]; j++;
            if (n1<m) cout << "Yes" << '\n';
            else cout<< "No" << '\n';
        }
    }

    return 0;
}
Problem p02613 (python)

Fixed submission:
d = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(int(input())): d[input()]+=1
for i in d: print(i+' x', d[i])

Buggy submission (verdict: Runtime Error):
d = {AC:0; WA:0; TLE:0; RE:0}
for i in range(int(input())): d[input()]+=1
for i in d: print(i+' x', d[i])
Problem p02675 (python)

Fixed submission:
def printer(n):
    if n%10 in [2,4,5,7,9]:print("hon")
    elif n%10 in[0,1,6,8]:print("pon")
    else:print("bon")
printer(int(input()))

Buggy submission (verdict: Runtime Error):
def printer(n):
    if n%10 in [2,4,5,7,9]:print"hon"
    elif n%10 in[0,1,6,8]:print"pon"
    else:print"bon"
printer(int(input()))

Buggy submission (verdict: Runtime Error):
def printer(n):
    if n%10 in [2,4,5,7,9]:print"hon"
    elif n%10 in[0,1,6,8]:print"pon"
    else:print"bon"
printter(int(input()))
Problem p03831 (python)

Fixed submission:
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(1, n): ans+=min((x[i]-x[i-1])*a, b)
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(1, n): ans+=min((x[i+1]-x[i])*a, b)
print(ans)
Problem p02765 (python)

Fixed submission:
n, r = map(int,input().split())
print(r+100*max(0,10-n))

Buggy submission (verdict: Runtime Error):
n, r = lambda(int,input().split())
print(r-100*max(0,10-n))
Problem p02767 (python)

Fixed submission:
n = input()
s = list(map(int,input().split()))
m = 10000000
for p in range(0,101):
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)

Buggy submission (verdict: Runtime Error):
s = map(int,input().split())
m = 10000000
for p in s:
  t = 0
  for x in s:
    t+=(x-p)**2
   m = min(t,m)
print(m)
Problem p02817 (python)

Fixed submission:
t=input().split()
print(t[1]+t[0])

Buggy submission (verdict: Runtime Error):
print(input().split()[::-1].join())
Problem p02927 (python)

Fixed submission:
# coding: utf-8
# Your code here!

M, D = map(int,input().split())

c=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if d>=10:
            t=str(d)
            if int(t[0])>1 and int(t[1])>1 and int(t[0])*int(t[1]) == m:
                c+=1

print(c)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

M, D = map(int,input().split())

c=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if d>=10:
            t=str(d)
            if int(t[0])>1 and int(t[1])>1 and int(t[0])*int(t[1]) == m:
                c+=1

print(c)

n,k = map(int,input().split())
Problem p02957 (python)

Fixed submission:
a, b = map(int,input().split())
if (a - b) % 2 == 0:
  print(a-(a-b)//2)
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())
if (a - b) % 2 == 0:
  print(a-(a-b//2)
else:
  print("IMPOSSIBLE")
Problem p03071 (python)

Fixed submission:
(a,b) = map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b)))

Buggy submission (verdict: Runtime Error):
(a,b) = map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b))
Problem p02554 (python)

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

n = int(input())
mod = 10**9 + 7

# 再帰だとなんか通らん
# dp = {}
# def rec(i, zero, nine):
#     if (i, zero, nine) in dp:
#         return dp[(i, zero, nine)]
#     if i == n:
#         return 1 if (zero and nine) else 0
#     ret = 0
#     for j in range(10):
#         if j == 0:
#             ret += rec(i + 1, True, nine)
#         elif j == 9:
#             ret += rec(i + 1, zero, True)
#         else:
#             ret += rec(i + 1, zero, nine)
#         ret %= mod
#     dp[(i, zero, nine)] = ret
#     return ret

# print(rec(0, False, False))

dp = [[[0 for _ in range(2)] for _ in range(2)] for _ in range(10**6 + 10101)]
dp[0][0][0] = 1  # どういう意味なのかは不明
for i in range(n):
    for j in range(2):
        for k in range(2):
            for m in range(10):
                if m == 0:
                    dp[i + 1][1][k] += dp[i][j][k]
                    dp[i + 1][1][k] %= mod
                elif m == 9:
                    dp[i + 1][j][1] += dp[i][j][k]
                    dp[i + 1][j][1] %= mod
                else:
                    dp[i + 1][j][k] += dp[i][j][k]
                    dp[i + 1][j][k] %= mod
print(dp[n][1][1])
# 869121

# 2511445

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

n = int(input())
mod = 10**9 + 7

# 再帰だとなんか通らん
# dp = {}
# def rec(i, zero, nine):
#     if (i, zero, nine) in dp:
#         return dp[(i, zero, nine)]
#     if i == n:
#         return 1 if (zero and nine) else 0
#     ret = 0
#     for j in range(10):
#         if j == 0:
#             ret += rec(i + 1, True, nine)
#         elif j == 9:
#             ret += rec(i + 1, zero, True)
#         else:
#             ret += rec(i + 1, zero, nine)
#         ret %= mod
#     dp[(i, zero, nine)] = ret
#     return ret

# print(rec(0, False, False))

dp = [[[0 for _ in range(2)] for _ in range(2)] for _ in range(10**6)]
dp[0][0][0] = 1  # どういう意味なのかは不明
for i in range(n):
    for j in range(2):
        for k in range(2):
            for m in range(10):
                if m == 0:
                    dp[i + 1][1][k] += dp[i][j][k]
                    dp[i + 1][1][k] %= mod
                elif m == 9:
                    dp[i + 1][j][1] += dp[i][j][k]
                    dp[i + 1][j][1] %= mod
                else:
                    dp[i + 1][j][k] += dp[i][j][k]
                    dp[i + 1][j][k] %= mod
print(dp[n][1][1])
# 869121

# 2511445

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

n = int(input())
mod = 10**9 + 7

dp = {}


def rec(i, zero, nine):
    if (i, zero, nine) in dp:
        return dp[(i, zero, nine)]
    if i == n:
        return 1 if (zero and nine) else 0
    ret = 0
    for j in range(10):
        if j == 0:
            ret += rec(i + 1, True, nine)
        elif j == 9:
            ret += rec(i + 1, zero, True)
        else:
            ret += rec(i + 1, zero, nine)
        ret %= mod
    ret %= mod
    dp[(i, zero, nine)] = ret
    return ret


print(rec(0, False, False))
# 869121

# 2511445
Problem p02584 (python)

Fixed submission:
x, k, d = map(int, input().split())
if x >= 0:
    if x - k * d >= 0:
        print(x - k * d)
    else:
        # 最初に負になってしまうところとその直前を巡回する
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ok + ng) // 2
            if x - mid * d <= 0:
                # いきすぎ
                ok = mid
            else:
                ng = mid
        # ok回目で負にたどり着く？
        rest = k - ok
        if rest % 2 == 0:
            # いまいるところに戻ってこれる
            print(abs(x - ok * d))
        else:
            # 一回正方向にいどうしたもの
            print(x - (ok - 1) * d)
else:
    if x + k * d <= 0:
        print(abs(x + k * d))
    else:
        # 最初に正になるところ
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ng + ok) // 2
            if x + mid * d >= 0:
                ok = mid
            else:
                ng = mid
        rest = k - ok
        if rest % 2 == 0:
            print(x + ok * d)
        else:
            print(abs(x + ok * d - d))

Buggy submission (verdict: Runtime Error):
x, k, d = map(int, input().split())
if x >= 0:
    if x - k * d >= 0:
        print(x - k * d)
    else:
        # 最初に負になってしまうところとその直前を巡回する
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ok + ng) // 2
            if x - mid * d <= 0:
                # いきすぎ
                ok = mid
            else:
                ng = mid
        # ok回目で負にたどり着く？
        rest = k - ok
        if rest % 2 == 0:
            # いまいるところに戻ってこれる
            print(abs(x - ok * d))
        else:
            # 一回正方向にいどうしたもの
            print(x - (ok - 1) * d)
else:
    if x + k * d <= 0:
        print(abs(x + k * d))
    else:
        # 最初に正になるところ
        ok, ng = ok, 0
        while (ok - ng) > 1:
            mid = (ng + ok) // 2
            if x + mid * k >= 0:
                ok = mid
            else:
                ng = mid
        rest = k - ok
        if rest % 2 == 0:
            print(x + ok * d)
        else:
            print(abs(x + (ok - 1) * d))

Buggy submission (verdict: Runtime Error):
x, k, d = map(int, input().split())
if x >= 0:
    if x - k * d >= 0:
        print(x - k * d)
    else:
        # 最初に負になってしまうところとその直前を巡回する
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ok + ng) // 2
            if x - mid * d <= 0:
                # いきすぎ
                ok = mid
            else:
                ng = mid
        # ok回目で負にたどり着く？
        rest = k - ok
        if rest % 2 == 0:
            # いまいるところに戻ってこれる
            print(abs(x - ok * d))
        else:
            # 一回正方向にいどうしたもの
            print(x - (ok - 1) * d)
else:
    if x + k * d <= 0:
        print(abs(x + k * d))
    else:
        # 最初に正になるところ
        ok, ng = ok, 0
        while (ok - ng) > 1:
            if x + mid * k >= 0:
                ok = mid
            else:
                ng = mid
        rest = k - ok
        if rest % 2 == 0:
            print(x + ok * d)
        else:
            print(abs(x + (ok - 1) * d))
Problem p02690 (python)

Fixed submission:
# 暴力即可
# 範囲指定 A=100 B=-100で20000000000とかになるしどっちも|100|程度でいいのではないか
# なんか足りんみたい（なんで？）なので4X^2<=10^9なる最大のXを求めよう
# 2X = 1000ちょい だから500くらいあればいいのか
# 1000^2なので時間的には間に合いそう
x = int(input())
for a in range(-500, 501):
    for b in range(-500, 501):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
print(3 / 0)  # はい

Buggy submission (verdict: Runtime Error):
# 暴力即可
# 範囲指定 A=100 B=-100で20000000000とかになるしどっちも|100|程度でいいのではないか
x = int(input())
for a in range(-100, 101):
    for b in range(-100, 101):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
print(3 / 0)  # はい
Problem p02760 (python)

Fixed submission:
bingo = []
for i in range(3):
    bingo.append(list(map(int, input().split())))

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                bingo[i][j] = "o"

for i in range(3):
    flag = 0
    for j in range(3):
        if bingo[i][j] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
    flag = 0
    for j in range(3):
        if bingo[j][i] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
# 斜め
if (
    bingo[0][0] == bingo[1][1] == bingo[2][2] == "o"
    or bingo[0][2] == bingo[1][1] == bingo[2][0] == "o"
):
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
41 7 46
26 89 2
78 92 8
5
6
45
16
57
17
Problem p02780 (python)

Fixed submission:
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
# え これでもだめなの
# あほだった sumしてるし
# 単純にみたら 0.5ずつ増えてるのでそうするか
# 1WA...
# N = 1の場合か？


n, k = map(int, input().split())
arr = list(map(int, input().split()))
table = {}
ans = 0
for i in range(1, 1000 + 1):
    table[i] = (i + 1) * 0.5
if n == 1:
    print(table[arr[0]])
    exit()
lis = [0 for _ in range(n)]
lis[0] = table[arr[0]]
for i in range(n - 1):
    if i + 1 < k:
        lis[i + 1] = lis[i] + table[arr[i + 1]]
    else:
        lis[i + 1] = lis[i] + table[arr[i + 1]] - table[arr[i - k + 1]]
    ans = max(ans, lis[i + 1])
print(ans)

Buggy submission (verdict: Runtime Error):
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
# え これでもだめなの
# あほだった sumしてるし
# 単純にみたら 0.5ずつ増えてるのでそうするか
# 1WA...
# N = 1の場合か？


n, k = map(int, input().split())
arr = list(map(int, input().split()))
table = {}
ans = 0
for i in range(1, 1000 + 1):
    table[i] = (i + 1) * 0.5
if n == 1:
    print(etable[arr[0]])
    exit()
lis = [0 for _ in range(n)]
lis[0] = table[arr[0]]
for i in range(n - 1):
    if i + 1 < k:
        lis[i + 1] = lis[i] + table[arr[i + 1]]
    else:
        lis[i + 1] = lis[i] + table[arr[i + 1]] - table[arr[i - k + 1]]
    ans = max(ans, lis[i + 1])
print(ans)
Problem p02797 (python)

Fixed submission:
n, k, s = map(int, input().split())
if k == n:
    print(" ".join([str(s) for _ in range(n)]))
    exit()

arr = []
for i in range(1, n + 1):
    if i <= k:
        arr.append(s)
    else:
        arr.append(8 ** 9 + 14499)  # テキトー
print(" ".join(list(map(str, arr))))

Buggy submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
if k == n:
    print(" ".join([str(s) for _ in range(n)]))
    exit()
x = 0
arr = [1]
while True:
    if x == k:
        break
    arr.append(s - arr[-1])
    print(arr, x)
    x += 1
print(arr)
while len(arr) < n:
    arr.append(10 ** 9)

print(" ".join(list(map(str, arr))))
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
table = {}
ac = 0
pena_arr = [0 for _ in range(m + 1)]
for _ in range(n):
    a, b = input().split()
    a = int(a)
    if a not in table and b == "AC":
        ac += 1
        table[a] = True
    elif a not in table and b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, m + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
table = {}
ac = 0
pena_arr = [0 for _ in range(m + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a not in table and b == "AC":
        ac += 1
        table[a] = True
    elif a not in table and b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, m + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)
Problem p02823 (python)

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

if (b - a) % 2 == 0:
    print(b - (a + b) // 2)
else:
    # 折り返して会いにいく
    ans = 0
    if a - 1 < n - b:
        ans = a
        a, b = 1, b - a
    else:
        ans = n - b + 1
        a, b = a + (n - b) + 1, n
    print(b - (a + b) // 2 + ans)

Buggy submission (verdict: Runtime Error):
# このくらい10秒で実装しろ。。。
 n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print(b - (a + b) // 2)
else:
    print(max(n - a - 1, b - 1))
Problem p02845 (python)

Fixed submission:
# なんか雑に書いたらサンプル3通ったしこれでよさそう
# なんかしらんけど2ケースでWAなる
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 1
d = [0] * (n + 10)
d[0] = 3
for i in range(n):
    ans *= d[a[i]]
    d[a[i]] -= 1
    d[a[i] + 1] += 1
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
# なぜか途中からREなる...
n = int(input())
s = list(map(int, input().split()))
color = 0  # appeared_zero (0~2)
ans = 1
MOD = 1000000007
cur = [-1, -1, -1]
for c in s:
    if c == 0:
        cur[color] = 0
        color += 1
        ans %= MOD
    else:
        x = cur.count(c - 1)
        ans *= x
        ans %= MOD
        if c - 1 in cur:
            idx = cur.index(c - 1)
            cur[idx] += 1
        else:
            print("????????????")
            exit()
ans *= 3 if color == 0 else 3 if color == 1 else 6
ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
# なぜか途中からREなる...
n = int(input())
s = list(map(int, input().split()))
color = 0  # appeared_zero (0~2)
ans = 1
MOD = 1000000007
cur = [-1, -1, -1]
for c in s:
    if c == 0:
        cur[color] = 0
        color += 1
        ans *= 3 if color == 0 else 3 if color == 1 else 6
        ans %= MOD
    else:
        x = cur.count(c - 1)
        ans *= x
        ans %= MOD
        idx = cur.index(c - 1)
        cur[idx] += 1
ans *= 3 if color == 0 else 3 if color == 1 else 6
ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(map(int, input().split()))
color = 0  # appeared_zero (0~2)
ans = 1
MOD = 1000000007
cur = [-1, -1, -1]
for c in s:
    if c == 0:
        cur[color] = 0
        color += 1
        ans %= MOD
    else:
        x = cur.count(c - 1)
        ans *= x
        ans %= MOD
        idx = cur.index(c - 1)
        cur[idx] += 1
ans *= 3 if color == 0 else 3 if color == 1 else 6
ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(map(int, input().split()))
color = 0  # appeared_zero (0~2)
ans = 1
MOD = 1000000007
cur = [-1, -1, -1]
for c in s:
    if c == 0:
        cur[color] = 0
        color += 1
        ans %= MOD
    else:
        x = cur.count(c - 1)
        ans *= x
        ans %= MOD
        idx = cur.index(c - 1)
        cur[idx] += 1
ans *= 3 if color == 0 else 3 if color == 1 else 6
ans %= MOD
print(ans)
Problem p02866 (python)

Fixed submission:
# 最初dは与えられる距離だと思ってて「サンプルケース1は3じゃね？」とか思ってて2時間経過した
# 落ち着いて読んだら最小の辺の数だった

from collections import Counter

n = int(input())
arr = list(map(int, input().split()))
if arr[0] != 0:
    print(0)
    exit()
arr = sorted(list(Counter(arr).items()), key=lambda x: x[0])
if arr[0][1] > 1:
    print(0)
    exit()

mod = 998244353
ans = 1
tmp = 1
for i in range(1, len(arr)):
    if arr[i][0] != i:
        print(0)
        exit()
    ans *= pow(tmp, arr[i][1])
    ans %= mod
    tmp = arr[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {}
mod = 998244353
max_v = 0
lis = list(map(int, input().split()))

# 先頭はかならず0
if lis[0] != 0:
    print(0)
    exit()

for v in list(map(int, input().split())):
    if v not in d:
        d[v] = 1
    else:
        d[v] += 1
    max_v = max(max_v, v)

# 0はひとつだけ
if 0 not in d or d[0] > 1:
    print(0)
    exit()

ans = 1
# 木を作ることができるならば1~max_vまでの数字がそれぞれ1つ以上存在する
for i in range(1, max_v + 1):
    if i not in d or i - 1 not in d:
        ans *= 0
    else:
        ans *= pow(d[i - 1], d[i], mod)
        ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {}
mod = 998244353
max_v = 0
for v in list(map(int, input().split())):
    if v not in d:
        d[v] = 1
    else:
        d[v] += 1
    max_v = max(max_v, v)
# 0はひとつだけ
if d[0] > 1:
    print(0)
    exit()
ans = 1
# 木を作ることができるならば1~max_vまでの数字がそれぞれ1つ以上存在する
for i in range(1, max_v + 1):
    if i not in d or i - 1 not in d:
        ans *= 0
    else:
        ans *= pow(d[i - 1], d[i], mod)
        ans %= mod
print(ans)
Problem p02882 (python)

Fixed submission:
# 実装と発想がむずいにぶたん
# というか最初は誰でもO(1)を考えるよなこれ にぶたんはむしろ少数派では
# （実際ほかの解答を見たらみーーーんなatan使ってるし）
# でもこれを見た瞬間やるだけと言ってるヒトはちょっとよくわからん

import math

a, b, x = map(int, input().split())

l, r = 0.0, 90.0
if a * b / 2.0 > (x / a):
    # 半分未満の場合
    while l + 10 ** (-8) < r:
        theta = (l + r) / 2.0
        # 限界まで傾けたときの筒を横から見た時、水の入ってる部分はbを対辺とする直角三角形で、底辺をeとすると
        # tan(theta) = b / e -> e = b / tan(theta)
        # よって面積は (e * b)/2 -> (b/tan(theta)*b)/2
        e = b / math.tan(math.radians(theta))
        s2 = (e * b) / 2.0
        # 比較すべきは台形じゃなくてx/aだった
        if s2 > (x / a):
            l = theta
        else:
            r = theta
else:
    # 半分以上の場合
    while l + 10 ** (-8) < r:
        theta = (l + r) / 2.0
        # 限界まで傾けたときの筒を横から見た時、水の入っていない部分が直角三角形になる
        # 底辺がaなので、対辺をeとすると、tan(theta) = e/a -> e = a * tan(theta)
        # なので三角形の面積は (a * tan(theta) * a)/ 2
        # 同じくラジアンに変換して渡す
        s2 = (a * math.tan(math.radians(theta)) * a) / 2.0
        if (x / a) + s2 < a * b:
            l = theta
        else:
            r = theta
print(l)

Buggy submission (verdict: Runtime Error):
# 実装と発想がむずいにぶたん
# というか最初は誰でもO(1)を考えるよなこれ にぶたんはむしろ少数派では
# （実際ほかの解答を見たらみーーーんなatan使ってるし）
# でもこれを見た瞬間やるだけと言ってるヒトはちょっとよくわからん

import math

a, b, x = map(int, input().split())

l, r = 0.0, 90.0
if a * b / 2.0 > (x / a):
    # 半分未満の場合
    # な  ん  で これが間違ってるんだ？？？？？？？？？？？？？？？？？？？？？
    while l + 10 ** (-8) < r:
        theta = (l + r) / 2.0
        # 限界まで傾けたときの筒を横から見た時、水の入ってる部分はbを対辺とする直角三角形で、底辺をeとすると
        # tan(theta) = b / e -> e = b / tan(theta)
        # よって面積は (e * b)/2 -> (b/tan(theta)*b)/2
        # になるはずなのになぜかこれが間違ってるとか言われるし実際なんかしらんけどサンプル3が通らん
        s2 = (b * b / math.tan(math.radians(theta))) / 2.0
        if (x / a) + s2 < a * b:
            l = theta
        else:
            r = theta
    print("whyyyyyyyyyyyyyy")
    print(2 / 0)
else:
    # 半分以上の場合
    while l + 10 ** (-8) < r:
        theta = (l + r) / 2.0
        # 限界まで傾けたときの筒を横から見た時、水の入っていない部分が直角三角形になる
        # 底辺がaなので、対辺をeとすると、tan(theta) = e/a -> e = a * tan(theta)
        # なので三角形の面積は (a * tan(theta) * a)/ 2
        # 同じくラジアンに変換して渡す
        s2 = (a * math.tan(math.radians(theta)) * a) / 2.0
        if (x / a) + s2 < a * b:
            l = theta
        else:
            r = theta
print(l)