Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[input() for i in range(N)]
for v in ['AC','WA','TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))

Fixed submission:
N=int(input())
s=[input()  for i in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[input() for i in range(N)]
for v in ['AC','WA','TLE','RE']:
  print('{} x {}'.format(v,s.count(v)))

Fixed submission:
N=int(input())
s=[input()  for i in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[input() for i in range[N]]
for v in ['AC','WA','TLE','RE']:
  print('{} x {}'.format(v,s.count(v)))

Fixed submission:
N=int(input())
s=[input()  for i in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[input() for i in range[N]]
for v in ['AC','WA','TLE','RE']:
  print('{} x {}'.format(v,s.count()))

Fixed submission:
N=int(input())
s=[input()  for i in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=[input() i for in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0}x{1}'.format(v,s.count(v)))

Fixed submission:
N=int(input())
s=[input()  for i in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=[(input() i for in range(N))]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0}x{1}'.format(v,s.count(v)))

Fixed submission:
N=int(input())
s=[input()  for i in range(N)]
for v in ['AC', 'WA', 'TLE','RE']:
  print('{0} x {1}'.format(v,s.count(v)))
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7

N = int(input())

result = 0

ten = pow(10, N, mod)
nine = pow(9, N, mod)
eight = pow(8, N, mod)

result = (ten - 2 * nine + eight) % mode

print(result)

Fixed submission:
mod = 10 ** 9 + 7

N = int(input())

result = 0

ten = pow(10, N, mod)
nine = pow(9, N, mod)
eight = pow(8, N, mod)

result = (ten - 2 * nine + eight) % mod

print(result)
Buggy python submission (verdict: Runtime Error):
d, t, s = list(map(int, input()))

min = d / s

if min <= t:
  print("Yes")
else:
  print("No")

Fixed submission:
d, t, s = list(map(int, input().split(" ")))

min = d / s

if min <= t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 0
for a in range(1,n):
    for b in range(1,(n//a)+1):
        if a*b < n:
            ans += 1

print(ans)

Fixed submission:
n = int(input())

ans = 0
for a in range(1,n):
    for b in range(1,(n//a)+1):
        if a*b < n:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections

n,m = map(int,input().split())
friend = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if a not in friend[b]:
        friend[a].append(b)
        friend[b].append(a)

q = collections.deque()
visited = [0 for i in range(n)]

ans = 0
for i in range(n):
    if visited[i] == 0:
        visited[i] = 1
        tmp = 1
        for j in friend[i]:
            if visited[j] == 0:
                visited[j] = 1
                tmp += 1
                q.append(j)
        while q:
            s = q.pop()
            for k in friend[s]:
                if visited[k] == 0:
                    visited[k] = 1
                    tmp += 1
                    q.append(k)
    ans = max(ans,tmp)

print(ans)

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

mod = 10**9 + 7

sum_a = sum(a)%mod
ans = 0
for i in range(n-1):
    sum_a -= a[i]
    ans += (a[i]*sum_a)%mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

mod = 10**9 + 7

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i]%mod)*(a[j]%mod)

print(ans%mod)

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

mod = 10**9 + 7

sum_a = sum(a)%mod
ans = 0
for i in range(n-1):
    sum_a -= a[i]
    ans += (a[i]*sum_a)%mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

mod = 10**9 + 7

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i]*a[j])%mod

print(ans%mod)

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

mod = 10**9 + 7

sum_a = sum(a)%mod
ans = 0
for i in range(n-1):
    sum_a -= a[i]
    ans += (a[i]*sum_a)%mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

mod = 10**9 + 7

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i]*a[j])%mod

print(ans%mod)

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

mod = 10**9 + 7

sum_a = sum(a)%mod
ans = 0
for i in range(n-1):
    sum_a -= a[i]
    ans += (a[i]*sum_a)%mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

mod = 10**9 + 7

ans = 0
for v in itertools.combinations(a,2):
    ans += (v[0] * v[1])%mod

print(ans%mod)

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

mod = 10**9 + 7

sum_a = sum(a)%mod
ans = 0
for i in range(n-1):
    sum_a -= a[i]
    ans += (a[i]*sum_a)%mod

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

import collections

h,w = map(int,input().split())
sy,sx = map(int,input().split())
gy,gx = map(int,input().split())
maze = [list(input()) for i in range(h)]

sy -= 1
sx -= 1
gy -= 1
gx -= 1

field = [[False for i in range(w)] for j in range(h)]
field[sy][sx] = True
dx = [1,0,-1,0]
dy = [0,1,0,-1]

q = collections.deque()
q2 = collections.deque()
q.append((sy,sx))
q2.append((sy,sx))
ans = 10**9
count = 0
maze[sy][sx] = 0

def f(count):
    while q:
        s = q.popleft()
        y,x = s[0],s[1]
        count = maze[y][x]
        for i in range(4):
            newy = y + dy[i]
            newx = x + dx[i]
            if 0<=newy<h and 0<=newx<w:
                if maze[newy][newx] == ".":
                    maze[newy][newx] = count
                    q.appendleft((newy,newx))
                elif maze[newy][newx] != "#" and field[newy][newx] == False:
                    maze[newy][newx] = count
                    q.appendleft((newy,newx))
                field[newy][newx] = True
        for ddy in range(-2,3):
            for ddx in range(-2,3):
                newy = y+ddy
                newx = x+ddx
                if  0<=newy<h and 0<=newx<w:
                    if maze[newy][newx] == "." and field[newy][newx] == False:
                        maze[newy][newx] = count+1
                        q.append((newy,newx))

f(count)
if maze[gy][gx] != ".":
    print(maze[gy][gx])
else:
    print(-1)

  

Fixed submission:
import collections

h,w = map(int,input().split())
sy,sx = map(int,input().split())
gy,gx = map(int,input().split())
maze = [list(input()) for i in range(h)]

sy -= 1
sx -= 1
gy -= 1
gx -= 1

field = [[False for i in range(w)] for j in range(h)]
field[sy][sx] = True
dx = [1,0,-1,0]
dy = [0,1,0,-1]

q = collections.deque()
q2 = collections.deque()
q.append((sy,sx))
count = 0
maze[sy][sx] = 0

def f(count):
    while q:
        s = q.popleft()
        y,x = s[0],s[1]
        count = maze[y][x]
        for i in range(4):
            newy = y + dy[i]
            newx = x + dx[i]
            if 0<=newy<h and 0<=newx<w:
                if newy == gy and newx == gx:
                    print(count)
                    exit()
                if maze[newy][newx] == ".":
                    maze[newy][newx] = count
                    q.appendleft((newy,newx))
                elif maze[newy][newx] != "#" and field[newy][newx] == False:
                    maze[newy][newx] = count
                    q.appendleft((newy,newx))
                field[newy][newx] = True
        for ddy in range(-2,3):
            for ddx in range(-2,3):
                newy = y+ddy
                newx = x+ddx
                if  0<=newy<h and 0<=newx<w:
                    if maze[newy][newx] == "." and field[newy][newx] == False:
                        maze[newy][newx] = count+1
                        q.append((newy,newx))

f(count)
if maze[gy][gx] != ".":
    print(maze[gy][gx])
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

h,w,m = map(int,input().split())

gyou = collections.defaultdict(int)
retu = collections.defaultdict(int)
q = collections.deque()

for i in range(m):
    y,x = map(int,input().split())
    gyou[y-1] += 1
    retu[x-1] += 1
    q.append((y-1,x-1))

ymax = max(gyou.values())
xmax = max(retu.values())
ans =  ymax + xmax 

for xk,xv in retu.items():
    if xv != xmax:
        continue
    for yk, yv in gyou.items():
        if yv != ymax:
            continue
        if (yk,xk) not in q:
            print(ans)
            exit()

print(ans-1)

Fixed submission:
import collections

h,w,m = map(int,input().split())

gyou = [0 for i in range(h)]
retu = [0 for i in range(w)]
l = []

for i in range(m):
    y,x = map(int,input().split())
    gyou[y-1] += 1
    retu[x-1] += 1
    l.append((y-1,x-1))

ymax = max(gyou)
xmax = max(retu)
c_ymax = gyou.count(ymax)
c_xmax = retu.count(xmax)
ans = ymax + xmax

c = 0
for y,x in l:
    if gyou[y] == ymax and retu[x] == xmax:
        c += 1

if c == c_ymax*c_xmax:
    print(ans-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

import collections

h,w,m = map(int,input().split())

gyou = collections.defaultdict(int)
retu = collections.defaultdict(int)
maze = [[0 for i in range(w)] for j in range(h)]

for i in range(m):
    y,x = map(int,input().split())
    gyou[y-1] += 1
    retu[x-1] += 1
    maze[y-1][x-1] = 1

ymax = max(gyou.values())
xmax = max(retu.values())
ans =  ymax + xmax 

for xk,xv in retu.items():
    if xv != xmax:
        continue
    for yk, yv in gyou.items():
        if yv != ymax:
            continue
        if maze[yk][xk] != 1:
            print(ans)
            exit()

print(ans-1)


Fixed submission:
import collections

h,w,m = map(int,input().split())

gyou = [0 for i in range(h)]
retu = [0 for i in range(w)]
l = []

for i in range(m):
    y,x = map(int,input().split())
    gyou[y-1] += 1
    retu[x-1] += 1
    l.append((y-1,x-1))

ymax = max(gyou)
xmax = max(retu)
c_ymax = gyou.count(ymax)
c_xmax = retu.count(xmax)
ans = ymax + xmax

c = 0
for y,x in l:
    if gyou[y] == ymax and retu[x] == xmax:
        c += 1

if c == c_ymax*c_xmax:
    print(ans-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

tmp = "7"*(len(str(k))-1)
while True:
    tmp += "7"
    if int(tmp)%k == 0:
        print(len(tmp))
        exit()

Fixed submission:
k = int(input())

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

tmp = 7%k
i = 1
while True:
    if tmp == 0:
        print(i)
        exit()
    tmp = (tmp*10 + 7)%k
    i += 1
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))

tmp = 1
for i in range(k):
    tmp *= a[i]

for i in range(k,n):
    now = (tmp/a[i-k])*a[i] 
    if now > tmp:
        print("Yes")
    else:
        print("No")
    tmp = now



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

for i in range(k,n):
    if a[i-k] < a[i]:
        print("Yes")
    else:
        print("No")

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

tmp = 1
for i in range(k):
    tmp *= a[i]

for i in range(k,n):
    now = (tmp/a[i-k])*a[i] 
    if now > tmp:
        print("Yes")
    else:
        print("No")
    tmp = now



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

for i in range(k,n):
    if a[i-k] < a[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int,input().split()))

ans = 1
for i in s:
    ans *= i
   
if ans > 10**18:
    print(-1)
else:
    print(ans)

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

if 0 in s:
    print(0)
    exit()

ans = 1
for i in s:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections

n,m = map(int,input().split())

s = {i:[] for i in range(m+1)}
for i in range(m):
    a,b = map(int,input().split())
    s[a].append(b)
    s[b].append(a)

bfs = [0]*(n+1)
bfs[1] = s[1][0]
q = collections.deque()
q.append({1:s[1]})

now = 1
while  q:
    tmp = q.popleft()#現在地点からたどり着ける部屋の辞書
    for k,v in tmp.items():
        for room in v:
            if bfs[room] == 0:
                bfs[room] = k
                q.append({room:s[room]})

if bfs.count(0) <= 1:
    print("Yes")
    for i in bfs[2:]:
        print(i)
else:
    print("No")

Fixed submission:
import collections

n,m = map(int,input().split())

s = {i:[] for i in range(n+1)}
for i in range(m):
    a,b = map(int,input().split())
    s[a].append(b)
    s[b].append(a)

bfs = [0]*(n+1)
try:
    bfs[1] = s[1][0]
except IndexError:
    print("No")
    exit()
q = collections.deque()
q.append({1:s[1]})

while  q:
    tmp = q.popleft()#現在地点からたどり着ける部屋の辞書
    for k,v in tmp.items():
        for room in v:
            if bfs[room] == 0:
                bfs[room] = k
                q.append({room:s[room]})

if bfs.count(0) <= 1:
    print("Yes")
    for i in bfs[2:]:
        print(i)
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(map(int,input().split()))

t = [0]*(n+1)
t[1] = 1
q = [1]

for i in range(1,k):
    if i == k:
        print(s[i])
        exit()
    if t[s[i]] == 0:
        t[s[i]] = 1
        q.append(s[i])
    elif t[s[i]] != 0:
        ans = k%(len(q))
        print(q[ans])
        exit()



    

    



    


    


Fixed submission:
n,k = map(int,input().split())
s = list(map(int,input().split()))
s.insert(0,0)

visited = [0]*(n+1)
visited[1] = 1
q = [1]

def dp(town):
    if visited[town] == 1:
        ans = k%(len(q))
        print(q[ans])
        exit()
    else:
        visited[town] += 1
        q.append(town)

i = 1
next_town = s[1]
while True:
    if i == k:
        print(next_town)
        exit()
    if visited[next_town] == 1:
        break
    else:
        visited[next_town] += 1
        q.append(next_town)
        next_town = s[next_town]
        i += 1
    
index = q.index(next_town)
q = q[index:]
ans = (k-i)%len(q)
print(q[ans])

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(map(int,input().split()))

t = [0]*(n+1)
t[1] = 1
q = [1]

for i in range(1,k):
    if t[s[i]] == 0:
        t[s[i]] = 1
        q.append(s[i])
    elif i == k:
        print(s[i])
        exit()
    elif t[s[i]] != 0:
        ans = k%(len(q))
        print(q[ans])
        exit()



    


    


Fixed submission:
n,k = map(int,input().split())
s = list(map(int,input().split()))
s.insert(0,0)

visited = [0]*(n+1)
visited[1] = 1
q = [1]

def dp(town):
    if visited[town] == 1:
        ans = k%(len(q))
        print(q[ans])
        exit()
    else:
        visited[town] += 1
        q.append(town)

i = 1
next_town = s[1]
while True:
    if i == k:
        print(next_town)
        exit()
    if visited[next_town] == 1:
        break
    else:
        visited[next_town] += 1
        q.append(next_town)
        next_town = s[next_town]
        i += 1
    
index = q.index(next_town)
q = q[index:]
ans = (k-i)%len(q)
print(q[ans])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            ans += gcd(i,j,l)

print(ans)

Fixed submission:
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
k = int(input())
 
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            ans += gcd(i,j,l)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n  = int(input())
nums = list(map(int, input().split()))
c = collections.Counter(nums)
tap = c.most_common()

cnt = 0
for i in range(len(tap)):
    s = tap[i][1]
    cnt += s*(s-1)/2

for i in range(n):
    num = nums[i]
    a = nums.count(num)
    print(int(cnt - a +1))

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

num_list = [0]*(n+1)
for i in a:
    num_list[i] += 1

cnt = 0
for i in num_list:
    cnt += i*(i-1)/2

for i in a:
    print(int(cnt +1 -num_list[i]))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

s = [0]*n

for i in range(m):
    keta, num = map(int,input().split())
    if s[keta-1] == 0 or s[keta-1] == num:
        s[keta-1] = num
    else:
        pirnt(-1)
        exit()

if s[0] != 0:
    print(*s, sep ="")
else:
    print(-1)

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

s = [0]*n

for i in range(m):
    keta, num = map(int,input().split())
    if keta == 1 and num == 0 and n != 1:
        print(-1)
        exit()
    if s[keta-1] == 0 or s[keta-1] == num:
        s[keta-1] = num
    else:
        print(-1)
        exit()

if s[0] != 0:
    print(*s, sep ="")
elif s[0] == 0 and n == 1:
    print(0)
elif s[0] == 0 and n != 1:
    s[0] = 1
    print(*s, sep ="")
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i

Fixed submission:
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import bisect

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

c = collections.Counter(s)
values,counts = zip(*c.most_common())
max_w = counts[0]
l = len(counts)

ans_list = []
i = 0
while True:
    if i < l:
        if counts[i] == max_w:
            bisect.insort(ans_list,values[i])
    else:
        break
    i += 1 

for j in ans_list:
    print(j)

Fixed submission:
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import bisect

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

c = collections.Counter(s)
values,counts = zip(*c.most_common())
max_w = counts[0]
l = len(counts)

ans_list = []
i = 0
while True:
    if i < l:
        if counts[i] == max_w:
            bisect.insort(ans_list,values[i])
    else:
        break
    i += 1 

for j in ans_list:
    print(j)

Fixed submission:
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a = list(map(int,input().split()))
s = collections.deque()

for i in a:
    if i not in s:
        s.appendleft(i)
    else:
        print("NO")
        exit()

print("YES")

Fixed submission:
import collections

n = int(input())
a = list(map(int,input().split()))
a.sort()

for i in range(n-1):
    if a[i] == a[i+1]:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))

ans = 0
q = collections.deque()
for i in range(n):
    tmp = (1+a[i])/2
    q.append(tmp)
    if len(q) > k:
        q.popleft()
    ans = max(ans,sum(q))
print(ans)




Fixed submission:
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))

ans = 0
tmp = 0
q = collections.deque()
for i in range(n):
    e = (1+a[i])/2
    q.append(e)
    tmp += e
    if len(q) > k:
        tmp -= q.popleft()
    ans = max(ans,tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
magic = [ list(map(int,input().split())) for i in range(n)]
INF = float("inf")

dp =  [[INF]*(h+1) for i in range(n+1)]

"""
i番目までの魔法の中から攻撃力の合計が
jを超えるように選んだときの消費精神力の最小値
"""

for i in range(n):
    for j in range(h):
        if j < magic[i][0]:#その魔法で一撃
             dp[i+1][j+1] = min(dp[i][j+1],magic[i][1])
        elif j >= magic[i][0] and 0<= j+1-magic[i][0] <= h:
            dp[i+1][j+1] = min(dp[i][j+1],dp[i][j+1-magic[i][0]]+magic[i][1],dp[i+1][j+1-magic[i][0]]+magic[i][1])#その魔法を連打したときが考慮されていない
        
print(dp[n][h])



Fixed submission:
h,n = map(int,input().split())
magic = [ list(map(int,input().split())) for i in range(n)]
INF = float("inf")

dp =  [[INF]*(h+1) for i in range(n+1)]

"""
i番目までの魔法の中から攻撃力の合計が
jを超えるように選んだときの消費精神力の最小値
"""

for i in range(n):
    for j in range(h):
        if j < magic[i][0]:#その魔法で一撃
             dp[i+1][j+1] = min(dp[i][j+1],magic[i][1])
        elif j >= magic[i][0] and 0<= j+1-magic[i][0] <= h:
            dp[i+1][j+1] = min(dp[i][j+1],dp[i][j+1-magic[i][0]]+magic[i][1],dp[i+1][j+1-magic[i][0]]+magic[i][1])#その魔法を連打したときが考慮されていない
        
print(dp[n][h])
Buggy python submission (verdict: Runtime Error):
import math

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

if x == (a**2)*b/2:
    ans = 45
elif x < (a**2)*b/2:
    rad = math.atan(2*x/(a*b**2))
    ans = math.degrees(rad)
else:
    rad = math.atan(a**3/(2*a**2*b - 2*x))
    ans = math.degrees(rad)
print(90-ans)

Fixed submission:
import math

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

if x == (a**2)*b:
    ans = 90
elif x == (a**2)*b/2:
    ans = 45
elif x < (a**2)*b/2:
    rad = math.atan(2*x/(a*b**2))
    ans = math.degrees(rad)
else:
    rad = math.atan(a**3/(2*a**2*b - 2*x))
    ans = math.degrees(rad)
print(90-ans)