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

Fixed submission:
"""
can do it by subproblems. for a given i, the only information you need from the previous values
is the min value of previous values.
the first i=0 is guaranteed to satisfy the constraint. (counting from zero).
"""
import sys


def count_low_elements(N, P):
    count = 0
    min_so_far = sys.maxsize
    for val in P:
        if val <= min_so_far:
            count += 1
            min_so_far = val
    return count


if __name__ == "__main__":
    test1 = \
"""5
4 2 5 1 3"""
    test2 = \
"""4
4 3 2 1"""
    test3 = \
"""6
1 2 3 4 5 6"""
    test4 = \
"""8
5 7 4 2 6 8 1 3"""
    test5 = \
"""1
1"""
    test = test5
    # N, P_string = test.split("\n")
    # P = list(map(int, P_string.split()))
    N = int(input())
    P = list(map(int, input().split()))
    print(count_low_elements(N, P))

Buggy submission (verdict: Runtime Error):
"""
can do it by subproblems. for a given i, the only information you need from the previous values
is the min value of previous values.
the first i=0 is guaranteed to satisfy the constraint. (counting from zero).
"""
import sys


def count_low_elements(N, P):
    count = 0
    min_so_far = sys.maxsize
    for val in P:
        if val <= min_so_far:
            count += 1
            min_so_far = val
    return count


if __name__ == "__main__":
    test1 = \
"""5
4 2 5 1 3"""
    test2 = \
"""4
4 3 2 1"""
    test3 = \
"""6
1 2 3 4 5 6"""
    test4 = \
"""8
5 7 4 2 6 8 1 3"""
    test5 = \
"""1
1"""
    test = test5
    # N, P_string = test.split("\n")
    # P = list(map(int, P_string.split()))
    N = int(input())
    P = list(map(int, input().split()))
    print(count_low_elements(N, P))
`
Problem p02801 (python)

Fixed submission:
x = input()
print(chr(ord(x)+1))

Buggy submission (verdict: Runtime Error):
import queue
from itertools import product

H, W = map(int, input().split())
road_grid = [row for row in input()]

# for each start point, find the furthest travellable point
# then return largest path length of all these
# ps y is down, x is right
furthest_so_far = -1
for y_init, x_init in product(range(H), range(W)):
    if road_grid[y_init][x_init] == "#": continue
    boundary = queue.Queue()
    boundary.put((y_init, x_init))
    steps_taken = [[-1]*W for _ in range(H)]
    steps_taken[y_init][x_init] = 0
    while not boundary.empty():
        y, x = boundary.get()
        neighbours = [(y+1, x), (y, x+1), (y-1, x), (y, x-1)]
        for (new_y, new_x) in neighbours:
            if (0 <= new_y < H and 0 <= new_x < W
                and steps_taken[new_y][new_x] == -1 and road_grid[new_y][new_x] == "."):
                steps_taken[new_y][new_x] = steps_taken[y][x] + 1
                boundary.put((new_y, new_x))
    furthest_so_far = max(furthest_so_far, max(max(steps_taken)))
print(furthest_so_far)
Problem p02803 (python)

Fixed submission:
from itertools import product
import queue
 
H, W = map(int, input().split())
road_grid = list()
for _ in range(H):
  road_grid.append(input())

# for each start point, find the furthest travellable point
# then return largest path length of all these
# ps y is down, x is right
furthest_so_far = -1
for y_init, x_init in product(range(H), range(W)):
    if road_grid[y_init][x_init] == "#": continue
    boundary = queue.Queue()
    boundary.put((y_init, x_init))
    steps_taken = [[-1]*W for _ in range(H)]
    steps_taken[y_init][x_init] = 0
    while not boundary.empty():
        y, x = boundary.get()
        neighbours = [(y+1, x), (y, x+1), (y-1, x), (y, x-1)]
        for (new_y, new_x) in neighbours:
            if (0 <= new_y < H and 0 <= new_x < W
                and steps_taken[new_y][new_x] == -1 and road_grid[new_y][new_x] == "."):
                steps_taken[new_y][new_x] = steps_taken[y][x] + 1
                boundary.put((new_y, new_x))
    furthest_here = max(max(row) for row in steps_taken)
    furthest_so_far = max(furthest_so_far, furthest_here)
print(furthest_so_far)

Buggy submission (verdict: Runtime Error):
import queue
from itertools import product

test_lines = test_input.split("\n")
H, W = map(int, test_lines.pop(0).split())
road_grid = [row for row in test_lines]

# for each start point, find the furthest travellable point
# then return largest path length of all these
# ps y is down, x is right
furthest_so_far = -1
for y_init, x_init in product(range(H), range(W)):
    if road_grid[y_init][x_init] == "#": continue
    boundary = queue.Queue()
    boundary.put((y_init, x_init))
    steps_taken = [[-1]*W for _ in range(H)]
    steps_taken[y_init][x_init] = 0
    while not boundary.empty():
        y, x = boundary.get()
        neighbours = [(y+1, x), (y, x+1), (y-1, x), (y, x-1)]
        for (new_y, new_x) in neighbours:
            if (0 <= new_y < H and 0 <= new_x < W
                and steps_taken[new_y][new_x] == -1 and road_grid[new_y][new_x] == "."):
                steps_taken[new_y][new_x] = steps_taken[y][x] + 1
                boundary.put((new_y, new_x))
    furthest_so_far = max(furthest_so_far, max(max(steps_taken)))
print(furthest_so_far)
Problem p02848 (python)

Fixed submission:
# the uppercase letters are encoded as 65 to 90
# I want to put A as 0, so Z is 25

def letter_to_int(letter):
    return ord(letter)-65


def int_to_letter(encoded_value):
    return chr(encoded_value+65)


def shift_string(N, string):
    shifted_string = ""
    for char in string:
        encoding = letter_to_int(char)
        # mod ensures it wraps around, eg N=3 sends Z to C
        shifted = (encoding+N)%26
        decoded_to_letter = int_to_letter(shifted)
        shifted_string = shifted_string + decoded_to_letter
    return shifted_string


if __name__ == "__main__":
    test1 = \
"""2
ABCXYZ"""
    test2 = \
"""0
ABCXYZ"""
    test3 = \
"""13
ABCDEFGHIJKLMNOPQRSTUVWXYZ"""
    various_tests = [test1, test2, test3]
    """for test in various_tests:
        lines = test.split("\n")
        N = int(lines[0])
        string = lines[1]
        print(shift_string(N, string))"""
    N = int(input())
    string = input()
    print(shift_string(N, string))

Buggy submission (verdict: Runtime Error):
# the uppercase letters are encoded as 65 to 90
# I want to put A as 0, so Z is 25

def letter_to_int(letter):
    return ord(letter)-65


def int_to_letter(encoded_value):
    return chr(encoded_value+65)


def shift_string(N, string):
    shifted_string = ""
    for char in string:
        encoding = letter_to_int(char)
        # mod ensures it wraps around, eg N=3 sends Z to C
        shifted = (encoding+N)%26
        decoded_to_letter = int_to_letter(shifted)
        shifted_string = shifted_string + decoded_to_letter
    return shifted_string


if __name__ == "__main__":
    test1 = \
"""2
ABCXYZ"""
    test2 = \
"""0
ABCXYZ"""
    test3 = \
"""13
ABCDEFGHIJKLMNOPQRSTUVWXYZ"""
    various_tests = [test1, test2, test3]
"""    for test in various_tests:
        lines = test.split("\n")
        N = int(lines[0])
        string = lines[1]
        print(shift_string(N, string))"""
    N = int(input())
    string = input()
    print(shift_string(N, string))
Problem p04043 (python)

Fixed submission:
a,b,c=(int(x) for x in input().split())

count7=0

if a==7:
    count7=count7+1
if b==7:
    count7=count7+1
if c==7:
    count7=count7+1

if count7==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=(int(x) for x in input().split())

count7=0

if a==7:
    count7=count7+1
if b==7:
    count7=count7+1
if c==7:
    count7=count7+1

if count7==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=(int(x) for x in input().split())

count7=0

if a==7:
    count7=count7+1
if b==7:
    count7=count7+1
if c==7:
    count7=count7+1

if count7==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

count7=0

if a==7:
    count7=count7+1
if b==7:
    count7=count7+1
if c==7:
    count7=count7+1

if count7==1:
    print("YES")
else:
    print("NO")
Problem p02717 (python)

Fixed submission:
a, b, c = map(int, input().split())
tmp = b
b = a
a = tmp
tmp = c
c = a
a = tmp
print(a, b, c)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
sum_a = sum(a)
if a[n-m] >= sum_a/(4*m):
    print('Yes')
else:
    print('No')
Problem p02681 (python)

Fixed submission:
S =  list(input())
T =  list(input())
del T[-1]

if S == T:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
A,B,C,K =  map(int,input().split())

count = 0

if K <= A:
    count += A
    print(count)

elif K <= A + B:
    count += A
    print (count)

else:
    count += 2*A + B - K
    print(count)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = str(input())

if "ABC" in s:
    print(s.count("ABC"))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if "ABC" in s:
  print(s.count("ABC")
else:
  print(0)
Problem p02760 (python)

Fixed submission:
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Buggy submission (verdict: Runtime Error):
R = 3
C = 3
matrix = [] 
print("Enter the entries rowwise:") 
 
for i in range(R):         
    a =[] 
    for j in range(C):  
         a.append(int(input())) 
    matrix.append(a) 
  
# For printing the matrix 
for i in range(R): 
    for j in range(C): 
        print(matrix[i][j], end = " ") 
    print() 

i= int(input("Enter: "))
if i in matrix:
    print("Yes")
else:
    print("No")
Problem p02789 (python)

Fixed submission:
N, M = input().split()
print("Yes" if N == M else "No")

Buggy submission (verdict: Runtime Error):
N, M = input().split()
print("Yes" if N == M else "No")

Buggy submission (verdict: Runtime Error):
"Yes" if (N == M) else "No"
Problem p02830 (python)

Fixed submission:
new_str, num, string = "", int(input()), input().split(" ")
for x in range(0, num):
    new_str += string[0][x] + string[1][x]
print(new_str)

Buggy submission (verdict: Runtime Error):
new_str, num, string = "", int(input()), input().split(" ")
for i in range(0, num):
    new_str += string[0][i] + string[1][i]
print(new_str)
Problem p02675 (python)

Fixed submission:
x = int(input()) % 10
if x == 6 or x == 1 or x== 8 or x == 0:
	print('pon')
elif x == 3:
	print('bon')
else:
	print('hon')

Buggy submission (verdict: Runtime Error):
x = int(input()) % 10
if x == 6, 1, 8:
	print('pon')
if x == 3:
	print('bon')
else:
	print('hon')
Problem p02778 (python)

Fixed submission:
print(''.join(['x']*len(input())))

Buggy submission (verdict: Runtime Error):
print(''.join(['x']*len(input()))
Problem p02885 (python)

Fixed submission:
A, B = list(map(int,input().split()))
if A<2*B:
  print(0)
else:
  print(A-2*B)

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
if A<2*B:
  print(O)
else:
  print(A-2*B)
Problem p02898 (python)

Fixed submission:
N ,K = map(int, input().split())
ans=0
h=list(map(int, input().split()))
for i in range(N):
  if h[i]>=K:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N ,K = map(int, input().split())
ans=0
for i in range(N):
  h=int(input())
  if h>=K:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N ,K = map(int, input().split())
ans=0
for i in range(N):
  if int(input())>=K:
    ans+=1
print(ans)
Problem p02899 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
a = list(map(int, input().split()))
b = []
def A(N,a):
    for i in range(N):
        b.append(a.index(i+1)+1)
    b = ' '.join(map(str, b))
    print(b)  
A(N,a)
Problem p02947 (python)

Fixed submission:
n = int(input())
strings_list = [list(input()) for i in range(n)]
counter = 0
dict = {}
 
for strings in strings_list:
    strings = "".join(sorted(strings))
    if strings in dict.keys():
        counter += dict[strings]
        dict[strings] += 1
    else:
        dict[strings] = 1
print(counter)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import fractions
N = int(input())
s=[0]*N
S = []
for i in range(N):
    s_sorted =''.join(map(str, sorted(str(input()))))
    S.append(s_sorted)
c = Counter(S)
dic = {k: v for k, v in c.items() if v != 1}
if dic == {}:
    print(0)
else:
    ans = 0
    for i in range(len(list(dic.values()))):
        ans = ans+math.factorial(list(dic.values())[i])/math.factorial(2)/math.factorial(list(dic.values())[i]-2)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
import fractions

N = int(input())
s=[0]*N
S = []
mydict = {}
flag=0
for i in range(N):
    s_sorted =''.join(map(str, sorted(str(input()))))
    S.append(s_sorted)
c = Counter(S)
dic = {k: v for k, v in c.items() if v !=1}
if dic == {}:
    print(0)
else:
    ans =0
    for i in range(len(list(dic.values()))):
        ans = ans+math.factorial(list(dic.values())[i])/math.factorial(2)/math.factorial(list(dic.values())[i]-2)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
import fractions

N = int(input())
s=[0]*N
S = []
mydict = {}
flag=0
for i in range(N):
    s_sorted =''.join(map(str, sorted(str(input()))))
    S.append(s_sorted)
c = Counter(S)
dic = {k: v for k, v in c.items() if v !=1}
if dic == {}:
    print(0)
else:
    ans =0
    for i in range(len(list(c.values()))):
        ans = ans+math.factorial(list(dic.values())[i])/math.factorial(2)/math.factorial(list(dic.values())[i]-2)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
import fractions

N = int(input())
s=[0]*N
S = []
mydict = {}
flag=0
for i in range(N):
    s_sorted =''.join(map(str, sorted(str(input()))))
    S.append(s_sorted)
c = Counter(S)
ans =0
for i in range(len(list(c.values()))):
    ans = ans+math.factorial(list(c.values())[i])/math.factorial(2)/math.factorial(list(c.values())[i]-2)
print(int(ans))
Problem p02952 (python)

Fixed submission:
N = int(input())
d = len(str(N))
if d==1:
    print(N)
elif d==2:
    print(9)
elif d==3:
    print(9+N-99)
elif d==4:
    print(909)
elif d==5:
    print(909+N-9999)
elif d==6:
    print(90909)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = len(str(N))
if d==1:
    print(N)
elif d==2:
    print(9)
elif d==3:
    print(9+N-99)
elif d==4:
    print(909)
elif d==5:
    print(909+n-9999)
elif d==6:
    print(90909)
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
if A*N>=B:
  print(B)
else:
  print(A*N)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
if A*N>=B:
  print(b)
else:
  print(A*N)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
A,B,C,D = list(map(int, input().split()))
def lcm(x, y):
    return (x * y) // gcd(x, y)
lcm = lcm(C,D)
nbc = B//C
nbd = B//D
nbl = B//lcm 
nac = (A-1)//C
nad = (A-1)//D
nal = (A-1)//lcm 
ans = B - A + 1-((nbc+nbd-nbl)-(nac+nad-nal))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int, input().split()))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
lcm = lcm(C,D)
nbc = B//C
nbd = B//D
nbl = B//lcm 
nac = (A-1)//C
nad = (A-1)//D
nal = (A-1)//lcm 
ans = B - A + 1-((nbc+nbd-nbl)-(nac+nad-nal))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int, input().split()))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
lcm = lcm(C,D)
nbc = B//C
nbd = B//D
nbl = B//lcm 
nac = (A-1)//C
nad = (A-1)//D
nal = (A-1)//lcm 
ans = B - A + 1-((nbc+nbd-nbl)-(nac+nad-nal))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int, input().split()))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
lcm = lcm(C,D)
nbc = B//C
nbd = B//D
nbl = B//lcm 

nac = (A-1)//C
nad = (A-1)//D
nal = (A-1)//lcm 
ans = B - A + 1-((nbc+nbd-nbl)-(nac+nad-nal))
print(ans)
Problem p03000 (python)

Fixed submission:
N,X= map(int, input().split())
L=list(map(int, input().split()))
D, ans=0, 0
for i in range(N):
    if D<=X:
        ans+=1
        D+=L[i]
    else:
        break
if D<=X:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,X= map(int, input().split())
L=list(map(int, input().split()))
D, ans=0, 0
for i in range(N+1):
    if D<=X:
        D+=L[i]
        ans+=1
    else:
        break
print(ans)
Problem p03071 (python)

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

s_1 = sorted(s)
s_2 = sorted([s_1[0], s_1[1]-1])
A = s_1[1] + s_2[1]
 
print(A)

Buggy submission (verdict: Runtime Error):
s = input().split()

s_1 = sorted(s)

s_2 = sorted([s_1[0], s_1[1]-1])

A = s_1[1] + s_2[1]

print(A)
Problem p03289 (python)

Fixed submission:
input_a = input()
if input_a[0] != 'A':
    print("WA")
elif input_a.count('C')==0:
    print("WA")
elif input_a.count('C')>1:
    print("WA")
elif input_a.index('C') <=1:
    print("WA")
elif input_a.index('C') ==len(input_a)-1:
    print('WA')
elif input_a.count('C') ==1:
    if input_a.replace('A','a').replace('C','c').islower():
        print('AC')
    else:
        print('WA')

Buggy submission (verdict: Runtime Error):
input_a = input()

if input_a[0]　!= 'A':
    print("WA")
elif input_a.count('C')==0:
    print("WA")
elif input_a.count('C')>1:
    print("WA")
elif input_a.index('C') ==1:
    print("WA")
elif input_a.index('C') ==len(input_a)-1:
    print('WA')
elif input_a.count('C') ==1:
    if input_a.strip("A").strip('C').islower():
        print('AC')
    else:
        print('WA')
Problem p03854 (python)

Fixed submission:
import sys

s = input()
s = s[::-1]

d ='maerd'
dr = 'remaerd'
e = 'esare'
er = 'resare'

i = 0
while True:
    try:
        if s[i:i+5] == d or s[i:i+5] == e:
            i += 5
            if i == len(s):
                print('YES')
                sys.exit(0)
        
        elif s[i:i+6] == er:
            i += 6
            if i == len(s):
                print('YES')
                sys.exit(0)
        
        elif s[i:i+7] == dr:
            i += 7
            if i == len(s):
                print('YES')
                sys.exit(0)
            
        else:
            print('NO')
            sys.exit(0)
            
    except Exception as err:
        print('NO')
        sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter

N, K, L = map(int, input().split())
edge1 = [[] for _ in range(N)]
edge2 = [[] for _ in range(N)]

for _ in range(K):
    p, q = map(int, sys.stdin.readline().split())
    edge1[p-1].append(q-1)
    edge1[q-1].append(p-1)

for _ in range(L):
    p, q = map(int, sys.stdin.readline().split())
    edge2[p-1].append(q-1)
    edge2[q-1].append(p-1)


def dfs(edges):
    groups = [-1]*N

    for i in range(N):
        if groups[i] != -1:
            continue

        groups[i] = i
        stack = [i]
        while stack:
            v = stack.pop()
            for dest in edges[v]:
                if groups[dest] != -1:
                    continue
                groups[dest] = i
                stack.append(dest)

    return groups


g1, g2 = dfs(edge1), dfs(edge2)
d = Counter()
for i in range(N):
    d[(g1[i], g2[i])] += 1

print(*(d[(g1[i], g2[i])] for i in range(N)))
Problem p02677 (python)

Fixed submission:
import math
tempList = tuple(map(int, input().split()))
a = tempList[0]
b = tempList[1]
hour = tempList[2]
minute = tempList[3]
time = hour * 60 + minute
mypi = math.pi
hourAngle = time/(12*60)
minuteAngle = minute/60
diff = abs(hourAngle - minuteAngle)
if diff > 0.5:
    diff = 1 - diff
angle = diff * mypi * 2
result = a*a + b*b - 2*a*b*math.cos(angle)
print(math.sqrt(result))

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
m_=6*m
h_=30*h
if h>6:
    h_op=h-6
elif h<6:
    h_op=h+6
else:
    h_op=12
if m/5<h_op and m/5>h:
    radians=m_-h_
elif m/5<h_op and m/5<h:
    radians=m_-h_+360
elif m/5>h_op and m/5>h:
    radians=h_-m_+360
elif m/5>h_op and m/5<h:
    radians=h_-m_
degree=math.radians(radians)
out=math.sqrt(pow(a,2)+pow(b,2)-2*a*b*math.cos(degree))
print(out)
Problem p02922 (python)

Fixed submission:





inp = input().split()
for a in inp:
    out = int(a)
inp.pop(1)
for a in inp:
    i = int(a)
    
n = 1
while (i*n-(n-1)) < out:
    n += 1

else:
    if out == 1:
        print(0)
    else:
        print(n)

Buggy submission (verdict: Runtime Error):





i = input()
out = input()
n = 1

while (int(i)*n-(n-1)) < int(out):
    n += 1

else:
    print(n)
Problem p02677 (python)

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

k = 60*h + m

import math

if m <= 15:
    by = b * math.sin(math.radians(90-(6*m)))
    bx = b * math.cos(math.radians(90-(6*m)))
elif m > 15 and m <= 30:
    by = b * -(math.sin(math.radians(6*(m-15))))
    bx = b * math.cos(math.radians(6*(m-15)))
elif m > 30 and m <= 45:
    by = b * -(math.sin(math.radians(90-((6*m)-180))))
    bx = b * -(math.cos(math.radians(90-((6*m)-180))))
else:
    by = b * math.sin(math.radians((6*m)-270))
    bx = b * -(math.cos(math.radians((6*m)-270)))
    
if k <= 180:
    ay = a * math.sin(math.radians(90-((1/2)*k)))
    ax = a * math.cos(math.radians(90-((1/2)*k)))
elif k > 180 and k <= 360:
    ay = a * -(math.sin(math.radians(((1/2)*k)-90)))
    ax = a * math.cos(math.radians(((1/2)*k)-90))
elif k > 360 and k <= 540:
    ay = a * -(math.sin(math.radians(90-(((1/2)*k)-180))))
    ax = a * -(math.cos(math.radians(90-(((1/2)*k)-180))))
else:
    ay = a * math.sin(math.radians(((1/2)*k)-270))
    ax = a * -(math.cos(math.radians(((1/2)*k)-270)))

ans = math.sqrt((ax-bx)**2 + (ay-by)**2)
print('{:.11f}'.format(ans))

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

import math

if m <= 15:
    by = b * math.sin(math.radians(90-(6*m)))
    bx = b * math.cos(math.radians(90-(6*m)))
elif m > 15 and m <= 30:
    by = b * math.sin(math.radians(6*(m-15)))
    bx = b * -(math.cos(math.radians(6*(m-15))))
elif m > 30 and m <= 45:
    by = b * -(math.sin(math.radians(90-((6*m)-180))))
    bx = b * -(math.cos(math.radians(90-((6*m)-180))))
else:
    by = b * -(math.sin(math.radians((6*m)-270)))
    bx = b * math.cos(math.radians((6*m)-270))
    
if 60*H+m <= 180:
    ay = a * math.sin(math.radians(90-(1/2*(60*H+m))))
    ax = a * math.cos(math.radians(90-(1/2*(60*H+m))))
elif 60*H+m > 180 and 60*H+m <= 360:
    ay = a * -(math.sin(math.radians((1/2*(60*H+m))-90)))
    ax = a * math.cos(math.radians((1/2*(60*H+m))-90))
elif 60*H+m > 360 and 60*H+M <= 540:
    ay = a * -(math.sin(math.radians(90-((1/2*(60*H+m)-180)))))
    ax = a * -(math.cos(math.radians(90-((1/2*(60*H+m)-180)))))
else:
    ay = a * math.sin(math.radians((1/2*(60*H+m)-270)))
    ax = a * -(math.cos(math.radians((1/2*(60*H+m)-270))))
    
ans = math.sqrt((ax-bx)**2 + (ay-by)**2)
print(ans)