peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from math import pi, cos,  sqrt
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))
# Judge status: Accepted
from functools import reduce

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


def cmb(r):
    numerator = reduce(lambda x, y: x * y % mod, range(n, n - r, -1))
    denominator = reduce(lambda x, y: x * y % mod, range(1, r + 1))
    return numerator * pow(denominator, mod - 2, mod) % mod


ans = pow(2, n, mod) - 1 - cmb(a) - cmb(b)
print(ans % mod)
# Judge status: Accepted
n = int(input())
s = {n}
flg = 1
i = 1
while flg:
  if n % 2 == 0:
    n //= 2
  else:
    n = 3*n + 1
  if n in s:
    print(i+1)
    flg = 0
  else:
    s.add(n)
  i += 1
# Judge status: Accepted
S = input()

for i in range(0,len(S),2):
  if not S[i:i+2] == 'hi':
    print('No')
    exit(0)

print('Yes')
# Judge status: Wrong Answer
t=[1,0]
for i in range(2,90):
  t.append(t[i-1]+t[i-2])
print(t[int(input())])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = sum(b) - sum(a)
ans = 0
for ai, bi in zip(a, b):
    ans += max(0, (bi - ai + 1) // 2)
print('Yes' if ans <= cnt else 'No')
# Judge status: Wrong Answer
import sys

x, y = map(int, input().split())

#鶴a匹、亀x-a匹とする
for a in range(1, x + 1):
  if y == 4 * x - 2 * a:
    print('YES')
    sys.exit()
    
print('NO')
# Judge status: Wrong Answer
S,T = input().split()

print(T,S)
# Judge status: Accepted
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

N = input_int()
h_li = input_li()
dp = [0] * N
dp[0] = 0
dp[1] = abs(h_li[1] - h_li[0])
for i in range(2, N):
    dp[i] = min(
        dp[i - 1] + abs(h_li[i] - h_li[i - 1]),
        dp[i - 2] + abs(h_li[i] - h_li[i - 2])
    )
print(dp[-1])
# Judge status: Accepted
a,b,c,d = map(int,input().split())
if abs(a-c) <= d:
    print("Yes")
elif abs(a-b)<= d and abs(b-c)<=d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
 
cnt = 0
while True:
  check = sum([n % 2 for n in A])
  if check == 0:
    A = [n/2 for n in A]
    cnt += 1
  else:
    break
    
print(cnt)
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if k%2==0:
  ans=a-b
else:
  ans=b-a
if ans<=10**18:
  print(ans)
else:
  print("Unfair")
# Judge status: Accepted
a = list(map(int,input().split()))
a.sort()

if sum(a[:2]) == a[2]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n_str = list(input())
n = [int(i) for i in n_str]
l = len(n)
for i in range(2 ** l):
    sum = 0
    op_list = []
    for j in range(l):
        if (i >> j) & 1:
            sum += n[j]
            op_list.append('+')
        else:
            sum -= n[j]
            op_list.append('-')
    if sum == 7:
        print(n_str[0]+op_list[0]+n_str[1]+op_list[1]+n_str[2]+op_list[2]+n_str[3]+'=7')
        exit()
# Judge status: Accepted
import sys
readline = sys.stdin.readline

N,H = map(int,readline().split())
maxA = 0
B = [0] * N
for i in range(N):
  a,b = map(int,readline().split())
  B[i] = b
  if maxA < a:
    maxA = a

usefulB = []
for i in range(N):
  if B[i] > maxA:
    usefulB += [B[i]]

usefulB = sorted(usefulB,reverse = True)

cnt = 0
for b in usefulB:
  H -= b
  cnt += 1
  if H <= 0:
    print(cnt)
    break
else:
  cnt += (H + maxA - 1) // maxA
  print(cnt)
# Judge status: Wrong Answer
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = K - x - y
    if 0 <= z <= K:
      ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [int(x) for x in input().split()]

m1 = 0
m2 = 0
m4 = 0

for a in A:
	if a%4==0:
		m4 += 1
	elif a%2==0:
		m2 += 1
	else:
		m1 += 1

m1 = m1 + m2%2
if 2*m4>=m1:
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))

ans = 0
for i in range(min(D)+1, max(D)):
    RC = [r for r in D if r >= i]
    BC = [b for b in D if b < i]
    if len(RC) == len(BC):
        ans += 1

print(ans)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N = int(input())
    A = list(map(int, readline().split()))
    ans = 1
    if 0 in set(A):
        print(0)
        return
    for a in A:
        ans *= a
        if ans > pow(10,18):
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
res = 0
for i in range(N):
    t = 0
    for j in range(i + 1):
        t += A[0][j]
    for j in range(i, N):
        t += A[1][j]
    res = max(res, t)
print(res)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
bound = (1 / (4*M))*sum(A)

for i in range(M):
    if A[i] < bound:
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
ans=1e5
for i in range(-100,101):
    now=0
    for k in a:
        now+=(i-k)*(i-k)
    ans=min(ans,now)
print(ans)
# Judge status: Accepted
if __name__ == '__main__':
    a,b = map(int,input().split())

    list = [0]*a

    for i in range(b):
        n,m=map(int, input().split())
        list[n-1]+=1
        list[m-1]+=1
    for i in list:
        print(i)
# Judge status: Accepted
n, x = map(int, input().split())
L = list(map(int, input().split()))

ans = 1
d = 0
for l in L:
    d = d + l
    if d <= x:
        ans += 1
    else:
        break
        
print(ans)
# Judge status: Accepted
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

N = int(input())
ans = (num2alpha(N)).lower()
print(ans)
# Judge status: Accepted
n,k,q=map(int,input().split())
a=[]
for _ in range(q):
  a.append(int(input()))

points = [k]*(n+1)
plus = [0]*(n+1)
for i in range(q):
  plus[a[i]] += 1

for i in range(1,n+1):
  points[i] = points[i] - q + plus[i]
  if points[i] >= 1:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
def cal():
    n = int(input())
    lst = list(map(int,input().split()))
    if 0 in lst:
    	return 0
    else:
        prod = 1
        for a in lst:
            prod *= a
            if prod > 1000000000000000000:
                return -1
    return prod
print(cal())
# Judge status: Accepted
W, a, b = map(int, input().split())
if a <= b <= a + W or a <= b + W <= a + W:
  print(0)
else:
  print(b - (a + W) if b > a + W else a - (b + W))
# Judge status: Wrong Answer
w, a, b = map(int, input().split())
if a + w < b:
    print(b-a-w)
elif a <= b and b <= a+w:
    print(0)
elif b <= a+w and a <= b:
    print(0)
elif b + w < a:
    print(a-b-w)
# Judge status: Accepted
N = input()
for n in N:
    if n == '7':
        print('Yes')
        exit(0)
print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
S = 0
for i in range(N-1):
    S += A[(i+1)//2]
print(S)
# Judge status: Accepted
n,m=map(int,input().split())
f=[0]*(m+1)
count=0
for i in range(n):
  a=list(map(int,input().split()))
  k=a[0]
  a=a[1:]
  for i in range(k):
    f[a[i]]+=1
    
for i in range(1,m+1):
  if f[i]==n:
    count+=1
    
print(count)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from math import gcd

N = int(input())
a = list(map(int, input().split()))
l = [0]

for ai in a:
    l.append(gcd(l[-1], ai))

r = [0]

for ai in a[::-1]:
    r.append(gcd(r[-1], ai))

ans = 0

for i in range(N):
    ans = max(ans, gcd(l[i], r[N-1-i]))

print(ans)
# Judge status: Accepted
N = int(input())
S = input()
N = int(N//2)
if S[:N] == S[N:]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a, b, c = map(int, input().split())
print("Yes" if a <= c <= b or b <= c <= a else "No")
# Judge status: Wrong Answer
import sys
n = int(input())
w = input()
words=[]

words.append(w)

for i in range(1,n):
    w = input()
    words.append(w)
    if w not in words:
        if words[i-1][-1]==sords[i][0]:
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
print("Yes")
# Judge status: Accepted
a, b, k = map(int, input().split())
if a >= 1 and a <= k:
    k -= a
    a = 0

elif a >= 1 and a > k:
    a -= k
    k -= a

if b >= 1 and k > 0 and b <= k:
    k -= b
    b = 0
elif b >= 1 and k > 0 and b > k:
    b -= k
    k -= b


print(a, b)
# Judge status: Accepted
#!/usr/bin/env python3


def solve(n,a):
  a = list(sorted(a,reverse=True))
  first = a[0]
  b = a[1:]
  delta = [abs(x-first//2) for x in b]
  second = b[delta.index(min(delta))]
  return first,second

def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(*solve(N,a))

if __name__ == '__main__':
  main()
# Judge status: Accepted
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))

for i in range(n):
    a[i]*=-1

heapq.heapify(a)
for _ in range(m):
    x=heapq.heappop(a)*(-1)
    x=x//2
    heapq.heappush(a,-x)

print(sum(a)*(-1))
# Judge status: Accepted
n=input()
l=list(map(int,input().split()))
print("Yes" if max(l)<sum(l)-max(l) else "No")
# Judge status: Accepted
di = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
s = input()
print(di[s])
# Judge status: Wrong Answer
[n,m]=list(map(int,input().split()))
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
cd=[]
for i in range(m):
    cd.append(list(map(int,input().split())))
ans=[]
for i in range(n):
    kyorimin=10**9
    for j in range(m):
        kyori=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if kyorimin>kyori:
            goal=j+1
    ans.append(goal)
for i in range(len(ans)):
    print(ans[i])
# Judge status: Wrong Answer
n, m = map(int, input().split())
l_r = [ list(map(int, input().split())) for _ in range(m) ]

ans = 0
l_ans = 0
r_ans = float('inf')
for l, r in l_r:
    l_ans = max(l_ans, l)
    r_ans = min(r_ans, r)
print(r_ans-l_ans+1)
# Judge status: Accepted
n,m=map(int,input().split())
c=[0]*n
for _ in range(m):
    a,b=[int(j) for j in input().split()]
    c[a-1]+=1
    c[b-1]+=1
for i in c:
    print(i)
# Judge status: Accepted
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k,q=map(int, readline().rstrip().split())
    score=[k-q]*n
    for i in range(q):
        x=int(readline())-1
        score[x]+=1
    
    for i in range(n):
        if score[i]>0:
            print("Yes")
        else:
            print("No")

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()
# Judge status: Wrong Answer
N = int(input())
S = list(map(int,input().split()))
m = [0 for _ in range(N)]
for i in range(N):
  m[S[i]-1] = i+1
print(m)
# Judge status: Wrong Answer
l=[x for x in input()];print(max(l)*3)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


K = readint()
A, B = readnums()

if B - A < K and A % K < B % K:
    print('NG')
else:
    print('OK')
# Judge status: Accepted
import numpy as np
import bisect
n,m,k=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
A=np.cumsum(np.array([0]+a))
B=np.cumsum(np.array(b))
ans=0
for i in range(n+1):
    if A[i]>k:
        break
    t=k-A[i]
    tmp=bisect.bisect_right(B,t)
    ans=max(ans, i+tmp)
print(ans)
# Judge status: Wrong Answer
N = int(input())
Ai = input().split()
b = ""

for n, A in enumerate(Ai):
  if n%2 == 0:
    b = A + b 
  else:
    b = b + A
if N%2 == 0: b = b[::-1]
print(*[bb for bb in b], sep=" ")
# Judge status: Accepted
n,k,*p = map(int, open(0).read().split())  
p.sort()                                   
print(sum(p[:k]))
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[1:2*n:2]))
# Judge status: Accepted
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
  print(a-1, b)
elif u == t:
  print(a, b-1)
# Judge status: Wrong Answer
S = int(input())
if S == 7 or S == 5 or S == 3:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
# A - Dividing a String
def count_substrings(first_substring):

	arr = [first_substring]
	i = len(first_substring)

	while i < len(S):
		s = S[i]
	
		if s == arr[-1]:
			if i + 1 < len(S):
				i += 1
				s += S[i]
			else:
				arr[-1] += s
				break
	
		arr.append(s)
		i += 1

	ans = len(arr)

	if arr[-1] == arr[-2]:
		ans -= 1	

	return ans


S = input()

ans1 = count_substrings(S[:1])
ans2 = count_substrings(S[:2])

print(max(ans1, ans2))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print('Yes' if a<=b<=c else 'No')
# Judge status: Wrong Answer
s = input()
#11011010001011
c = max(s.count("1") - s.count("0"),s.count("1") - s.count("0"))

if len(s) == 1:
	print(0)
else:
	print(len(s)-c)
# Judge status: Accepted


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


def submit():
    a, b = map(int, input().split())
    print(lcm(a, b))


if __name__ == "__main__":
    submit()
# Judge status: Accepted
from functools import reduce
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
print(reduce(gcd,a))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if  abs(b-a)==abs(c-b):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a<=9 or b<=9:
    print(a*b)
else:
    print(-1)
# Judge status: Accepted
S =input()
T =input()
#print(S)
s = len(S)-1
S = list(S)

#print(S)
flag = 0
for i in range(len(S)):
    h = [S[0]]
    S.remove(S[0])
    S = S + h
    str_ = ''.join(S)
    #print(str_)
    if str_ == T:
        flag = 1
        break
    #print(S)

if flag == 1:
    print("Yes")
else :
    print("No")
# Judge status: Wrong Answer
a,b,c = map(int,input().split())#標準入力を行う
if (a == 5 or a== 7):
    if(b == 5 or b == 7):
        if(c == 5 or c == 7):
            if(a + b + c == 17):
                print("YES")
print("NO")
# Judge status: Accepted
s = input()
temp = s.rindex('Z') - s.index('A') + 1
print(temp)
# Judge status: Wrong Answer
N=int(input())
import collections
l=list(map(int,input().split()))
cnt=collections.Counter(l)
if cnt[0] > 1 or l[0] != 0:
   print(0)
   exit()
ans=1
mod=998244353
for i in range(1,max(cnt)):
   ans*=pow(i,cnt[i],mod)
   ans%=mod
print(ans)
# Judge status: Wrong Answer
S=input()
if (S[2] == S[3])and(S[2] == S[3]) :
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b,c=map(int,input().split())
k=int(input())
while k>0:
    if a<b:
        break
    b*=2
    k-=1
while k>0:
    if b<c:
        break
    c*=2
    k-=1
if a<b<c:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
a=[2,1]
for i in range(2,n+1):
  a.append(a[i-1]+a[i-2])
  
print(a[n])
# Judge status: Accepted
N, K = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(K, N+2):
  mi = N-i+1
  ma = N
  s_max = ((mi+ma)*i)//2
  mi = 0
  ma = i-1
  s_min = ((mi+ma)*i)//2
  #print(s_min, s_max)
  ans += (s_max-s_min+1)
  ans %= mod

print(ans)
# Judge status: Accepted
def is_prime(x):
  if x<=1:
    return False
  i=2
  while i*i<=x:
    if x%i==0:
      return False
    i+=1
  return True

X=int(input())
p=X
while not is_prime(p):
  p+=1
print(p)
# Judge status: Wrong Answer
N, M = map(int, input().split())
count = [0]*N
ans = 0
ok = 1
for _ in range(M):
    p, s = input().split()
    if count[int(p)-1] >= 0 and s == "WA":
        count[int(p) - 1] += 1
    elif count[int(p)-1] >= 0 and s == "AC":
        ans += count[int(p)-1]
        count[int(p)-1] = -1
        ok += 1
print(ok, ans)
# Judge status: Wrong Answer
w=sorted(list(input()))
temp=0
ans="Yes"
for i in range(len(w)):
    if i>0 and w[i]!=w[i-1]:
        if temp%2==1:
            ans="No"
            break
        temp=0
    temp+=1
print(ans)
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
mx=0
s=0
for i in a:
  if mx<i:
    mx=i
  s+=mx-i
print(s)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 01:36:50 2020

@author: liang
"""

S = input()
c0 = 0
c1 = 0
for i in range(len(S)):
    if S[i] == "0":
        c0 += 1
    else:
        c1 += 1
ans = len(S) - abs(c0-c1)
print(ans)
# Judge status: Accepted
n = int(input())
N = int(n*(n+1)/2)
print(N)
# Judge status: Wrong Answer
import sys
a, b = input().split()

A = int(a)
B = int(b)

Adiv = A
Bdiv = B
k = 0




for i in reversed(range(min([A, B]))):
    j = i+1
    if Adiv % j == 0 and Bdiv % j == 0:
        k = j


if k == 0:
    k = 1
    
res = A * B / k
print(int(res))
# Judge status: Accepted
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

x, n = map(int, input().split())
p = [int(item) for item in input().split()]
seen = set(p)

ans = None 
diff = 200
for val in range(200, -200, -1):
    if val not in seen:
        if abs(val - x) <= diff:
            ans = val
            diff = abs(val - x)

print(ans)
# Judge status: Accepted
import numpy as np
w, h, n = map(int, input().split())

mat = np.ones(w * h).reshape(h, w)
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        mat[:, :x] = 0
    elif a == 2:
        mat[:, x:] = 0
    elif a == 3:
        mat[-y+h:, :] = 0
    else:
        mat[:-y+h, :] = 0
print(len(mat[mat == 1]))
# Judge status: Accepted
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
a,b = inputlist()
if a <= b:
    print(a)
else:
    print(a-1)
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(1,n,1):
	if a[i]+a[i-1]>x:
		count+=a[i]-(x-a[i-1])
		if x<a[i-1]:
			a[i]=0
		else:
			a[i]=x-a[i-1]
print(count)
# Judge status: Wrong Answer
N, D = map(int, input().split())
for i in range(1,N):
    if N <= (1+(2*D))*i:
        print(i)
        exit()
    else:
        pass
# Judge status: Wrong Answer
from itertools import groupby
s=list(input())
f=0
ans=0
for k,v in groupby(s):
  d=len(list(v))
  g=d+1 if k==">" else 0 
  ans+=( max(f,g)-min(f,g)+d*(d+1)//2-g )
  f=d+1 if k=="<" else 0
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())

print('{}'.format((N*(N-1)/2+(M*(M-1))/2)))
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
 
start = max(a, c)
finish = min(b, d)
 
print(start - finish)
# Judge status: Wrong Answer
import math
import collections
n = int(input())
ans = 0
s = collections.Counter([''.join(sorted(list(input()))) for x in range(n)])

for v in s.values():
    if 1 < v:
        ans += math.factorial(v) // math.factorial(2)
print(ans)
# Judge status: Accepted
H, A = map(int, input().split())

i = 0

while H > 0:
  H -= A
  i += 1
  
print(i)
# Judge status: Accepted
n,k = map(int,input().split())
i = 0
while n > 0:
    n = n//k
    i += 1
print(i)
# Judge status: Accepted
s=input()
ans=s.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")
print("YES" if not ans else "NO")
# Judge status: Wrong Answer
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
dif = []

for i in range(1, M):
	dif.append(abs(X[i] - X[i-1]))

dif.sort()
difLen = len(dif)
# M - N = (M-1) - (N-1)
e = M - N
ans = sum(dif[0:e])

print(ans)
# Judge status: Wrong Answer
a, b, c = sorted(map(int, input().split()))

print('Yes' if a <= c and c <= b else "No")
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in arr):
  arr = [i / 2 for i in arr]
  count += 1
  
print(count)
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())

for x in range(a, b+1):
    if x % k == 0:
        print('OK')
        break
else:
    print('NG')
# Judge status: Wrong Answer
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        h_min = j
        h_max = N
        while h_max - h_min != 1:
            h_mid = (h_max + h_min) // 2
            if L[i] + L[j] > L[h_mid]:
                h_min = h_mid
            else:
                h_max = h_mid
        cnt += h_mid - j
print(cnt)
# Judge status: Accepted
import numpy as np
a,b,x = map(int,input().split())
water = x/a
bottle = a*b
if water >= bottle * 0.5:
    margin = bottle - water
    tate = margin * 2 / a
    ans = np.degrees(np.arctan2(tate, a))
else:
    height = 2 * water / b
    beta = np.degrees(np.arctan2(height, b))
    ans = 2*(45 - beta/2)
print(ans)
# Judge status: Accepted
A, B = input().split()
B1, B2 = B.split('.')
ans = int(A) * (int(B1) * 100 + int(B2))
print(ans // 100)
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())

if H >= W:
    if N%H == 0:
        count = N/H
    else:
        count = int(N/H) + 1
else:
    if N%H == 0:
        count = N/W
    else:
        count = int(N/W) + 1
print(int(count))
# Judge status: Accepted
a = input()
if a in "abcdefghijklmnopqrstuvwxyz":
    print("a")
else:
    print("A")
# Judge status: Wrong Answer
S = input()
list_S = list(S)
if list_S[2] == list_S[3] or list_S[4] == list_S[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline

s = input().replace("\n","")

reverse_s = s[::-1]

s1len = int((len(s)/2))

s1 = s[:s1len]
reverse_s1 = s1[::-1]
# print(s1)

s2len = int((len(s)/2) + 1)
s2 = s[s2len:]
reverse_s2 = s2[::-1]
# print(s2)


if (s == reverse_s) and (s1 == reverse_s1) and (s2 == reverse_s2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np

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

a = np.arange(n+1, dtype='int')

b = np.cumsum(a)

s = 0

for i in range(k, n+1):
	s += (b[n] - b[n-i]) - b[i-1] + 1
	s = s % 1000000007

s += 1
s = s % 1000000007
print(s)
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]

ans = [0] * n
for i in range(n, 0, -1):
    if sum(ans[i - 1:n + 1:i]) % 2 != a[i - 1]:
        ans[i - 1] = 1

print(*ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 00:56:12 2020

@author: liang
"""

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

if N*2 >= M:
    print(M//2)
else:
    print( N + (M-2*N)//4)
# Judge status: Accepted
a,b,x = map(int,input().split())
print("YES" if a + b >= x and a <= x else "NO")
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = input()

    l = 0
    r = 0

    for char in s:
        if char == "(":
            l += 1
        else:
            if l > 0:
                l -= 1
            else:
                r += 1
    print("(" * r + s + ")" * l)


if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,k = map(int,input().split())
ans = []
ab = [a,b]
for i in range(1,max(ab)+1):
  if(a%i == 0 and b%i == 0):
    ans.append(i)
    
print(ans[-k])
# Judge status: Accepted
x = int(input())
i = 1
tmp = 0
while tmp < x:
    tmp += i
    i += 1
print(i-1)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=a[k-1]
for i in range(n):
  if i<=k-1:
    continue
  else:
    if a[i]>cnt:
      print('Yes')
      cnt=a[i-k+1]
    else:
      print('No')
      cnt=a[i-k+1]
# Judge status: Accepted
N,W = map(int, input().split())
wv = [[int(x) for x in input().split()] for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j - wv[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])