Harryxun/stf_run huggingface dataset:
n=int(input())
def factorization(n):
  primend = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primend.append([i,cnt])
  if temp!=1:
    primend.append([temp,1])
  if primen==[]:
    primend.append([n,1])
  return primend#primen,degree
pn=[0]*(n+1)
for i in range(1,n+1):
  for j in factorization(i):
    pn[j[0]]+=j[1]
ans = 1
for k in range(2,n+1):
  ans*=(pn[k]+1)%(10**9+7)
print(ans%(10**9+7))


### FIXED CODE ###

n=int(input())
def factorization(n):
  primen = []
  degree = []
  primend = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend#primen,degree
pn=[0]*(n+1)
for i in range(1,n+1):
  for j in factorization(i):
    pn[j[0]]+=j[1]
ans = 1
for k in range(2,n+1):
  ans*=(pn[k]+1)%(10**9+7)
print(ans%(10**9+7))
import sys



def check_number(p,numbers):
  for plis in p:
    if plis == numbers:
      return 1
  return 0


X,N = map(int,input().split())
p = list(map(int,input().split()))

if N == 0:
  print( X )
  sys.exit()


after_ans = X
i = 100


for i in range(X+1,100,1):#前半
  if check_number(p,i) == 0:
    after_ans = i
    after_abs = abs(X-i)
    break

for i in range(X-1,0,-1):#後半
  if check_number(p,i) == 0:
    before_ans = i
    before_abs = abs(X-i)
    break

if abs(after_abs) == abs(before_abs):
  answer = before_ans
elif abs(after_abs) > abs(before_abs):
  answer = before_ans
else:
  answer = after_ans

print( answer )


### FIXED CODE ###

import sys



def check_number(p,numbers):
  for plis in p:
    if plis == numbers:
      return 1
  return 0


X,N = map(int,input().split())
p = list(map(int,input().split()))

if N == 0:
  print( X )
  sys.exit()


after_ans = X
i = 100


for i in range(X,X+100,1):#前半
  if check_number(p,i) == 0:
    after_ans = i
    after_abs = abs(X-i)
    break

for i in range(X,X-100,-1):#後半
  if check_number(p,i) == 0:
    before_ans = i
    before_abs = abs(X-i)
    break

if abs(after_abs) == abs(before_abs):
  answer = before_ans
elif abs(after_abs) > abs(before_abs):
  answer = before_ans
else:
  answer = after_ans

print( answer )
w, h, x, y, r = map ( int, input ( ).split ( ) )
if x-r >=0 and  x+r <= w and y-r >= 0 and y+r <=h:
  print ( 'Yes' )
else:
  print ( 'No' )

### FIXED CODE ###

w, h, x, y, r = map(int, input( ).split( ))
if x-r >=0 and  x+r <= w and y-r >= 0 and y+r <=h:
  print ( "Yes" )
else:
  print ( "No" )
import sys
input = sys.stdin.readline
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)

def dfs(neighbor,start,visited):
    global k
    global c
    if sum(visited) == N:
        return 0
    for i in neighbor[start]:
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            dfs(neighbor,i,visited)
        else:
            continue

m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)
if N == 9999:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
dfs(neigh,nn,visited)

ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
A,B,K = [int(i) for i in input().split(" ")]

def check(A,B,K):
    if 0 < K < A:
        A-=K
        K = 0
    else:
        result = K-A
        A = 0
        K = result
    if 0 < B:
        if K < B:
            B-=K
        else:
            B = 0
    return "{0} {1}".format(A,B)

print(check(A,B,K))

### FIXED CODE ###

N=input().split(" ");print(N[1]+N[0])
r = int(input())
area = "{:.6f}".format(math.pi*(r*r))
circumference = "{:.6f}".format(2*r*math.pi)
print(area, circumference)


### FIXED CODE ###

import math
r = float(input())
print((r**2)*math.pi,r*2*math.pi)
N = int(input())
A = [int(i) for i in range(N)]
A.sort()

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
    print(Alice-Bob)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)
memo = input().split()
a,b,c = [int(x) for x in memo]
if(a < b && b < c):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

memo = input().split()
a,b,c = [int(x) for x in memo]
if a < b and b < c :
    print("Yes")
else:
    print("No")
A = input()
if A = "ABC":
    print("ARC")
else:
    print("ABC")

### FIXED CODE ###

A = input()
if A == "ABC":
    print("ARC")
else:
    print("ABC")
N = int(input())
ans = ""

while N > 0:
	N -= 1
	ans += chr(ord('a') + N % 26)
	N //= 26

print(ans[::-1])

### FIXED CODE ###

c = input()

if c.isupper():
	print("A")
else:
	print("a")
n,m=map(int,input().split())
if n%2==0:
  tmp=n
  n=m
  m=tmp
print(max(n*(m//2)+(n%2)*(n//2+1))


### FIXED CODE ###

n,m=map(int,input().split())
if m==1 or n==1:
  print(1)
elif m%2+n%2<2:
  print(n*m//2)
else:
  print(n*(m//2)+(n//2+1))
def main():
    import sys
    from collections import defaultdict
    N, M, K = map(int, sys.stdin.readline().split())

    F = [set() for _ in range(N)]
    B = [set() for _ in range(N)]
    for m in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a - 1, b - 1
        F[a].add(b)
        F[b].add(a)

    for k in range(K):
        c, d = map(int, sys.stdin.readline().split())
        c, d = c - 1, d - 1
        B[c].add(d)
        B[d].add(c)

    D = defaultdict(set)
    parents = [-1] * N
    visited = set()
    for s in range(N):
        if s in visited:
            continue

        stack = [s]
        D[s].add(s)
        while stack:
            n = stack.pop()
            visited.add(n)
            parents[n] = s
            for to in F[n]:
                if to in visited:
                    continue
                D[s].add(to)
                stack.append(to)

    print(1 / 0)
    ans = [0] * N
    #print(D)
    for i in range(N):
        #print(D[parents[i]] - F[i] - B[i] - {i}, F[i], B[i])
        ans[i] = len(D[parents[i]] - F[i] - B[i] - {i})

    print(*ans, sep=' ')


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict
    N, M, K = map(int, sys.stdin.readline().split())

    F = [set() for _ in range(N)]
    B = [set() for _ in range(N)]
    for m in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a - 1, b - 1
        F[a].add(b)
        F[b].add(a)

    for k in range(K):
        c, d = map(int, sys.stdin.readline().split())
        c, d = c - 1, d - 1
        B[c].add(d)
        B[d].add(c)

    D = defaultdict(set)
    parents = [-1] * N
    visited = set()
    for s in range(N):
        if s in visited:
            continue

        stack = [s]
        D[s].add(s)
        while stack:
            n = stack.pop()
            visited.add(n)
            parents[n] = s
            for to in F[n]:
                if to in visited:
                    continue
                D[s].add(to)
                stack.append(to)

    ans = [0] * N
    for i in range(N):
        X = D[parents[i]]
        tmp_ans = 0
        tmp_ans += len(X)
        tmp_ans -= len(F[i])
        tmp_ans -= 1
        for b in B[i]:
            if b in X:
                tmp_ans -= 1
        ans[i] = tmp_ans

    print(*ans, sep=' ')


if __name__ == '__main__':
    main()
n=int(input())
A=list(map(int,input().split()))

A.sort()
B=[1]*n

from math import sqrt
def eratosu():
  # if not isinstance(n,int):
  #   raise TypeError("nがint型になってねえぞ")
  # if n<2:
  #   raise ValueError('nが2よりちっちぇえぞ')
  primec = 0
  # limit = sqrt(n)
  data = A  #2,3,4,...,n
  while len(data)>0:
    p = data[0]
    # if limit <= p:
    #     return prime + data
    if len(data)>0:
        if data[1]==p:
            primec-=1
    primec+=1 
    data = [e  for e in data if e % p != 0]
  return primec 

# for i in range(n):
#     if i>0:
#         if A[i]==A[i-1]: B[i]=0 ; B[i-1]=0 ; continue
    # if B[i]==1:
    #     for j in range(i+1,n):
    #         if A[j]%A[i]==0:
    #             B[j]=0
print(eratosu())

# print(sum(B))


### FIXED CODE ###

n=int(input())
A=sorted(list(map(int,input().split())))
B=[0]*(1+A[-1])
for i in A:
    B[i]+=1
    if B[i]==1:
        for j in range(2*i,A[-1]+1,i):
            B[j]+=1
    else:
        continue
ans=0
for i in A:
  if B[i]==1: ans+=1

print(ans)
n, k = list(map(int, input().split()))
s = input()
s[k - 1] =　lower(s[k - 1])
print(s)

### FIXED CODE ###

n, k = list(map(int, input().split()))
s = list(input())
s[k - 1] = s[k - 1].lower()
print(*s, sep = "")
x=list(map(int,input().split()))
y=list(map(int,input().split()))
 
x.sort(reverse=True)
y.sort()
 
 
flag=0
for i in range(X+1,Y+1):
  if x[0]<=i and y[0]>i:
    flag=1
    break
  
 
  else:
    flag=0
    
if flag==1:
  print('No War')
  
else:
  print('War')

### FIXED CODE ###

n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
 
x.sort(reverse=True)
y.sort()
 
 
flag=0
for i in range(X+1,Y+1):
  if x[0]<i and y[0]>=i:
    flag=1
    break
  
 
  else:
    flag=0
    
if flag==1:
  print('No War')
  
else:
  print('War')
s=list(input())
s2=""
for i in range(len(s)):
  if i%==2:
    s2+=s[i]
print(s2)

### FIXED CODE ###

s=list(input())
s2=''
for i in range(len(s)):
  if i%2==0:
    s2+=s[i]
print(s2)
A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
print(str(A)+" "+str(B))

### FIXED CODE ###


N=input()
N=int(N)

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


As.sort()

l=[]
l.append(As[N//2])
#if(N%2==0):
s=0
b=0
for i in range(N-1):
	if(i%2==1):
		l.append(As[-b-1])
		b+=1
	else:
		l.append(As[s])
		s+=1
ans=0
for i in range(1,N):
	ans+=abs(l[i]-l[i-1])
#print(l)
#print(ans)

l2=[]
l2.append(As[(N-1)//2])
#if(N%2==0):
s2=0
b2=0
for i in range(N-1):
	if(i%2==0):
		l2.append(As[-b2-1])
		b2+=1
	else:
		l2.append(As[s2])
		s2+=1
ans2=0
for i in range(1,N):
	ans2+=abs(l2[i]-l2[i-1])
#print(l2)
#print(ans2)
print(max(ans,ans2))
X, K, D = map(int, input().split())

ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    a = (X+K*D)//(2*D)
    for i in range(-1,2):
        if a+i <= K and a+i >= 0:
            ans_list.append(abs(X+(K-(a+i))*D - (a+i)*D))
    ans = min(ans_list)
print(ans)

### FIXED CODE ###

X, K, D = map(int, input().split())
ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    a = (X+K*D)//(2*D)
    if a >= K:
        a = K
        ans = abs(X-K*D)
    else:
        ans_1 = abs(X+K*D-2*a*D)
        ans_2 = abs(X+K*D-2*(a+1)*D)
        ans = min(ans_1, ans_2)
print(ans)
n,k=map(int,input().split())
a=[]
for i in range(n)
 a+=map(input().split())
a.sort()
ans=0
for i in range(k)
 ans+=a[i]
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(k):
 ans+=a[n-1-i]
print(ans)
N=int(input())
S=input()
c=0
if len(S)>2:
  for i in range(1,N):
    if S[i-1]=="A" and S[i]=="B" and S[i+1]=="C":
      c+=1
print(c)

### FIXED CODE ###

N=int(input())
S=input()
c=0
if len(S)>2:
  for i in range(1,N-1):
    if S[i-1]=="A" and S[i]=="B" and S[i+1]=="C":
      c+=1
print(c)
N = int(input())
num_list = list(map(int,input().split()))
q = int(input())

for i in range(len(num_list)):
  ans += num_list[i]

for j in range(q):
  query = list(map(int,input().split()))
  cnt = num_list.count(query)
  ans += (query[1] - query[0]) * cnt
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = []
c = 0
s = sum(A)
table = [0] * 100001
 
for i in A:
    table[i] += 1
 
for i in range(Q):
    B, C = map(int,input().split())
    c = table[B]
    s += (C - B) * c
    table[C] += table[B]
    table[B] = 0
    S.append(s)

for s in S:
    print(s)
N = int(input())
stuff = list(map(int,input().split()))
#stuff = [5, 5, 6, 1, 1, 1]
junban = list(range(N))

max_happness = 0
for subset in permutations(junban):
    happness = 0
    newjunban = (list(subset))
    for i in range(len(junban)):
        happness +=stuff[i]*abs(newjunban[i]-i)
    if happness>max_happness:
        max_happness = happness
print (max_happness)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a, i) in enumerate(ABI):
    curr = [0]*(k+2)
    for l in range(k+1):
        curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))
        curr[l+1] = prev[l]+a*abs(i-l-1)
    prev = curr
print (max(prev))
a,b = map(int, input().split())
if (a+b) % :
    print("Impossible")
else:
    print("Possible")

### FIXED CODE ###

a,b = map(int, input().split())
if a % 3 ==0 or b % 3 == 0 or (a+b) % 3 == 0 :
    print("Possible")
else:
    print("Impossible")
import sys,collections as cl
import fractions
from functools import reduce
import copy
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[i]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
　　

n = int(input())
su = 0

a = l()

co = 0
k = 0
a.sort()
f = 0
for i in range(n):
	if a[i] < 0:
		co += 1
if co % 2 == 0:
	for i in range(n):
		su += abs(a[i])
	print(su)
else:
	for i in range(n):
		if f == 2 or a[i] == 0:
			break
		if a[i] >= 0 and f == 0:
			kk = a[i-1]
			f = 1
		if a[i] >= 0:
			if abs(a[0]) >= a[i]:
				k = a[i]*(-2)
			else:
				k = kk*2
			f = 2
		elif i == n-1:
			k = a[i]*2
	for i in range(n):
		su += abs(a[i])
	su += k
	print(su)



### FIXED CODE ###

import sys,collections as cl
import fractions
from functools import reduce
import copy
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[i]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a

n = int(input())
su = 0

a = l()

co = 0
k = 0
a.sort()
f = 0
for i in range(n):
	if a[i] <= 0:
		co += 1
if co % 2 == 0:
	for i in range(n):
		su += abs(a[i])
	print(su)
else:
	for i in range(n):
		if a[i] == 0:
			break
		if a[i] > 0:
			kk = a[i-1]
		if a[i] > 0:
			if abs(a[i-1]) >= a[i]:
				k = a[i]*(-2)
			else:
				k = kk*2
			break
		elif i == n-1:
			k = a[i]*2
	for i in range(n):
		su += abs(a[i])
	su += k
	print(su)
N = int(input())
p = list(map(int, input().split()))
n = [i+1 in range(N)]
c = 0
for i in range(N):
  if n[i] != p[i]:
    c += 1
if c == 0 or c == 2:
  print("YES")
else:
  print("NO")
	

### FIXED CODE ###

N = int(input())
p = list(map(int, input().split()))
n = [i+1 for i in range(N)]
c = 0
for i in range(N):
    if n[i] != p[i]:
        c += 1
if c == 0 or c == 2:
    print("YES")
else:
    print("NO")
X, Y = map(int, input().split())
price = [0, 300000, 200000, 100000]
ans = price[X] + price[Y] + 400000*(X == Y == 1)

print(ans)

### FIXED CODE ###

X, Y = map(int, input().split())
price = [0, 300000, 200000, 100000] + [0]*300
ans = price[X] + price[Y] + 400000*(X == Y == 1)

print(ans)
N = int(input())
S = input()

if(S.len()%2 == 0):
  n = (S.len())/2
  if(S[0:(n/2-1)] == S[n/2:n]):
    print("Yes")
  else:
    print("No")
else:
  print("No")

### FIXED CODE ###

N = int(input())
S = input()

if(N%2 == 0):
  #Pythonでは、//で整数の商、%で余り（剰余、mod）が算出
  n = N//2
  #[:n] 0~n-1 [n:] n~最後まで
  if(S[:n] == S[n:]):
    print("Yes")
  else:
    print("No")
else:
  print("No")
N,X,T=map(int,input().split())
if N%X ==0:
    print(NT//x)
else:
    print((N//X+1)*T)


### FIXED CODE ###

N,X,T=map(int,input().split())
if N%X ==0:
    print(N*T//X)
else:
    print(((N//X)+1)*T)
N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        break

for j in range(N-1):
    if W[j][-1]!=W[j+1][1]:
        flg = 1
        break

if flg!=1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        

for j in range(N-1):
    if W[j][-1]!=W[j+1][0]:
        flg = 1

if flg!=1:
    print('Yes')
else:
    print('No')
n, a, b = map(int, input().split())

f = n // (a+b)
g = n % (a+b)

if g <= a:
    print(a * f + g)
    
else:
    print(a * (f+1))

### FIXED CODE ###

s = input()

if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')
n,m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

a_count = [0]*110000
a_sum = [0]*110000

for i in range(n):
    a_count[a[i]] += 1
    a_sum[a[i]] += a[i]

for i in range(100005,0,-1):
    a_count[i] += a_count[i+1]
    a_sum[i] += a_sum[i+1]

def chk(x):
    case = 0
    for i in range(n):
        if x-a[i] <= 1:
            case += n
        else:
            case += a_count[x-a[i]]
    if case >= m:
        ch = True
    else:
        ch = False
    return ch


l = 1    #OK
r = 2*10**5 + 1 #NG

while r-l > 1:
    kk = (r+l)//2
    if chk(kk):
        l = kk
    else:
        r = kk

ans = 0
sm = sum(a)

for i in range(n):
    if l-a[i] <= 0:
        ans += sm + n*a[i]
    else:
        ans += a_count[l-a[i]]*a[i] + a_sum[l-a[i]]

case = 0
for i in range(n):
    if l-a[i] <= 1:
        case += n
    else:
        case += a_count[l-a[i]]

ans -= (case-m)*l

print(ans)

### FIXED CODE ###

from bisect import bisect_left
from bisect import bisect_right

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

a_count = [0]*110000
a_sum = [0]*110000

for i in range(n):
    a_count[a[i]] += 1
    a_sum[a[i]] += a[i]

for i in range(100005,0,-1):
    a_count[i] += a_count[i+1]
    a_sum[i] += a_sum[i+1]

def chk(x):
    case = 0
    for i in range(n):
        case += n-bisect_right(a,x-a[i]-1)
    if case >= m:
        ch = True
    else:
        ch = False
    return ch


l = 2*a[-1]+1    #NG
r = 1 #OK

while abs(r-l) > 1:
    kk = (r+l)//2
    if chk(kk):
        r = kk
    else:
        l = kk

ans = 0
sm = sum(a)

l = r

case = 0
for i in range(n):
    num = n-bisect_right(a,l-a[i]-1)
    case += num
    ans += num*a[i]*2

ans -= (case-m)*l

print(ans)
A,B,H,M = map(int,input().split(' '))
# 30: 12h/360° 6:  60min/360°
theta = abs((30 * H + 30 * M / 60)- 6 * M)
if(theta > 180):
theta -= 180
elif(theta == 180):
print(A + B)
return
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(theta))))


### FIXED CODE ###

from math import (pi,cos,sqrt,radians)

def main():
    A,B,H,M = map(int, input().split())

    # 長針、短針の0時0分からの角度を求める
    HTheta = H/12 * 360 + 1/12 * (M/60) *  360
    MTheta = M/60 * 360
    # |長針-短針|で角度θを求める
    Theta = abs(HTheta - MTheta) 
    # θ=180ならA+Bを出力して終了
    if Theta == 180:
        print(A + B)
        return
    # 予言定理を求める
    print(sqrt(A*A + B*B - 2*A*B*cos(radians(Theta))))

main()
p,q,r=map(int,input().split())
print(sum(p,q,r)-max(p,q,r))

### FIXED CODE ###

p,q,r=map(int,input().split())
print(sum([p,q,r])-max([p,q,r]))
a,b=int(input())
print(a*b,(a+b)*2)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b,(a+b)*2)
inp = []
for i in range(6):
    inp.append(insert(input()))
k = inp[4] - inp[0]
if k > inp[5]:
    print(':(')
else:
    print('Yay!')

### FIXED CODE ###

inp = []
for i in range(6):
    inp.append(int(input()))
k = inp[4] - inp[0]
if k > inp[5]:
    print(':(')
else:
    print('Yay!')
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
aa = 0
bb = 0
while True:
    if aa >= n and bb >= m:
        break
    elif aa >= n:
        k -= b[bb]
        bb += 1
    elif bb >= m:
        k -= a[aa]
        aa += 1
    else:        
        if a[aa] > b[bb]:
            k -= b[bb]
            bb += 1
        elif a[aa] < b[bb]:
            k -= a[aa]
            aa += 1
        else:
          if a[aa+1] > b[bb+1]:
            k-= b[bb]
            bb += 1
          else:
            k -= a[aa]
            aa += 1
    if k < 0:
      break

if k < 0:
	print(aa+bb-1)
else:
    print(aa+bb)

### FIXED CODE ###

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

A = [0]
B = [0]

for i in range(n):
    A.append(A[i]+a[i])

for i in range(m):
    B.append(B[i]+b[i])
    
ans,j = 0,m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
n=int(input())
t=input()
d=[len(list(set(list(t[:i]))&set(list(t[i:])))) for i in range(1,n-1)]
print(max(d))

### FIXED CODE ###

n=int(input())
t=input()
d=[len(list(set(list(t[:i]))&set(list(t[i:])))) for i in range(1,n-1)]
try:
  print(max(d))
except:
  print(0)
import math
def lcm(x,y):
    return x*y/math.gcd(x,y)

a,b=map(int, input().split(' '))
print(int(lcm(a,b)))


### FIXED CODE ###

import fractions
def lcm(x,y):
    return x*y/fractions.gcd(x,y)

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

print(int(lcm(a,b)))
n=int(input())
S=input()
D={}
for i in range(len(S)):
    s=S[i]
    if s in D:D[s]+=1
    else:D[s]=1
for _ in range(n-1):
    S=input()
    E={}
    DD={}
    for i in range(len(S)):
        s=S[i]
        if s in E:E[s]+=1
        else:E[s]=1
    for i in D:
        if i in E:DD[i]=min(E[i],D[i])
ans=[]
for j in DD:
    for _ in range(DD[j]):
        ans.append(j)
ans.sort()
print("".join(ans))

### FIXED CODE ###

n=int(input())
S=input()
D={}
for i in range(len(S)):
    s=S[i]
    if s in D:D[s]+=1
    else:D[s]=1
for _ in range(n-1):
    S=input()
    E={}
    DD={}
    for i in range(len(S)):
        s=S[i]
        if s in E:E[s]+=1
        else:E[s]=1
    for i in D:
        if i in E:DD[i]=min(E[i],D[i])
    D=DD
ans=[]
for j in D:
    for _ in range(D[j]):
        ans.append(j)
ans.sort()
print("".join(ans))