peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import math

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

print(math.ceil((n-k)/k+1))
# Judge status: Wrong Answer
n, k = map(int,input().split())
ans = 0
if n < k:
    ans = n
else:
    ans = min(n%k,k-n%k)

print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
A=[0]*n
print(A)
for i in range(m):
    a,b=map(int,input().split())
    A[a-1] += 1
    A[b-1] += 1
for h in range(n):
    print(A[h])
# Judge status: Accepted
def I(): return int(input())
x = I()
div,mod = divmod(x,11)
print(div*2+(0 if mod==0 else 1 if mod<=6 else 2))
# Judge status: Accepted
n = int(input())
c = input()

print(c[:c.count('R')].count('W'))
# Judge status: Accepted
from itertools import accumulate
import sys
a,b=map(int,input().split())
n = 500000
l=[]
for i in range(n):
    l.append(i)
    tmp = sum(l)
    if abs(abs(a+tmp) - abs(b+tmp)) == i:
        print(tmp -b)
        sys.exit()
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)[:X]
Q = sorted(list(map(int, input().split())), reverse=True)[:Y]
R = sorted(list(map(int, input().split())), reverse=True)
print(sum(sorted(P+Q+R, reverse=True)[:X+Y]))
# Judge status: Wrong Answer
import math
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1,1):
  temp = i
  count = 0
  while (temp <= k):
      temp *= 2
      count += 1
  #print("1/{} * (1/2)^{}".format(n,count))
  ans += min(1,(math.pow((1/2),count)))
print("{:1.9f}".format(ans/n))
# Judge status: Accepted
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
cnt=max(c.values())
tmp = [k for k, v in c.items() if cnt==v]
print(*sorted(tmp), sep='\n')
# Judge status: Accepted
N,x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
count = 0

while a[0] > x:
    count += a[0] - x
    a[0] = x

for i in range(N-1):
    if a[i] + a[i+1] > x:
        count += a[i+1] - (x - a[i])
        a[i+1] = x - a[i]

print(count)
# Judge status: Accepted
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

num = 10 ** 6 + 1 #適当に値を入れる
L = [0 for i in range(num)]
ans = 0
N = int(input())
A = getlist()
for i in range(N):
	L[A[i]] += 1

for i in range(num):
	if L[i] >= 1:
		if L[i] == 1:
			ans += 1
		c = 2
		while i * c <= num - 1:
			L[i * c] = 0; c += 1

print(ans)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10**9)

ordA = ord('a')

N = int(input())

def dfs(i, sSt):
    if i == N:
#        print(Ss)
        ans = ''.join([chr(ordA+S) for S in Ss])
        anss.append(ans)
    else:
        for s in range(0, sSt+2):
            Ss[i] = s
            dfs(i+1, s)

anss = []
Ss = [0] * N
dfs(1, 0)

print('\n'.join(anss))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A=sorted(A,reverse=1)
print(sum(A[1:N*2:2]))
# Judge status: Accepted
a,b,c=tuple(map(int,input().split()))
[print("Yes") if a+b>=c else print("No")]
# Judge status: Wrong Answer
N, K = map(int, input().split())
l = []
for i in range(N):
  a, b = map(int, input().split())
  l.append([a, b])
c = 0
ans = 0
for r in l:
  c += r[1]
  if c >= K:
    ans = r[0]
    break
print(ans)
# Judge status: Accepted
S = list(input())
 
cnt0 = S.count("0")
cnt1 = S.count("1")
 
print(min(cnt0, cnt1) * 2)
# Judge status: Accepted
S = int(input())

L = S // 100 # 前半2桁
R = S % 100 # 後半2桁

if L > 12 or L == 0:
  if R > 12 or R == 0: print('NA')
  else: print('YYMM')
else:
  if R > 12 or R == 0: print('MMYY')
  else: print('AMBIGUOUS')
# Judge status: Accepted
import collections

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

c = collections.Counter(ls)
ans = 0

for k, v in c.items():
    if k <= v:
        ans += v - k
    else:
        ans += v

print(ans)
# Judge status: Accepted
r, g, b = map(int, input().split())
if (r * 100 + g * 10 + b) % 4 == 0:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
a, v = map(int,input().split())
b, w = map(int, input().split())
t = int(input())

if v < w:
    print('NO')
elif abs(a-b) <= (v-w)*t:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N,A,B = input().split()
print(B,A,N)
# Judge status: Accepted
n=int(input()) #Pythonの標準入力
ans=n*6.28
print(ans)
# Judge status: Wrong Answer
n, k = (int(x) for x in input().split())
h = sorted([int(input()) for i in range(n)])
res = 10 ** 6
for i in range(n-k+1):
  res = min(res, h[i+k-1]-h[i])
print(res)
# Judge status: Accepted
n = int(input())
s = input()

ans = "No"

if n%2 == 0:
  half = n//2
  if s[0:half] == s[half:n]:
    ans = "Yes"
    
print(ans)
# Judge status: Wrong Answer
n,p = map(int,input().split())
a = list(map(int,input().split()))
odd = [i for i in a if i%2==1]
eve = [i for i in a if i%2==0]
odd_len = len(odd)
eve_len = len(eve)
if p==0:
    ans = 2**eve_len
else:
    ans = 0
count = 0
if p==0:
    ans *= 2**odd_len//2
else:
    ans +=   (2**eve_len)*(2**odd_len//2)
print(ans)
# Judge status: Accepted
def solve(n):
    if n % 2 == 1:
        return 0 
    div_2 = 0
    cur = 2
    while cur <= n:
        div_2 += (n // cur)
        cur = cur * 2
    div_5 = 0
    cur = 5
    while cur <= n:
        div_5 += (n // cur) // 2
        cur = cur * 5
    return min(div_2, div_5)

n = int(input())
print(solve(n))
# Judge status: Wrong Answer
s = str(input())
n = len(s)
for i in range(n):
   A=(s.replace(s[i],"x"))

print(A)
# Judge status: Accepted
def main():
    n,k=map(int,input().split())
    arr = []
    for _ in range(n):
        a,b=map(int,input().split())
        arr.append((a, b))
    arr.sort()
    for x, c in arr:
        if k <= c:
            print(x)
            break
        else:
            k -= c
    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a = int(input())
b = int(input())

if (a==1) | (b==2):
  print(3)
if (a==1) | (b==3):
  print(2)
if (a==2) | (b==3):
  print(1)
# Judge status: Wrong Answer
from sys import stdin
input = stdin.readline

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if B > A:
    if (V - W) * T + A >= B:
        print("YES")
    else:
        print("NO")
else:
    if (V - W) * T + A <= B:
        print("YES")
    else:
        print("NO")
# Judge status: Wrong Answer
def main():
    AB, BC, CA = list(map(int, input().split()))

    print(AB * BC / 2)

main()
# Judge status: Wrong Answer
n = int(input())

mod = 10**9 + 7

ans = 1
for i in range(1,n+1):
  ans *= i
  ans %= mod
print(mod)
# Judge status: Wrong Answer
mat = [map(int ,raw_input().split()) for _ in range(3)]
def f(m):
	return m[1] - m[0] == m[2] - m[1]
b = True
for l in mat:
	if not(f(l)):
		b = False
for j in range(3):
	c = [mat[i][j] for i in range(3)]
	if not(f(c)):
		b = False


print 'Yes' if b else 'No'
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))

state = [0] * (N + 1)
for i in range(N, 0, -1):
    if N < i + i:
        state[i] = A[i-1]
    else:
        state[i] = A[i-1]
        j = i + i
        while j <= N:
            state[i] ^= state[j]
            j += i
ans = [str(i) for i, x in enumerate(state) if x == 1]
print(len(ans))
if ans:
    print(" ".join(ans))
# Judge status: Accepted
n, p, *a = map(int, open(0).read().split())
c = 0
for a, b in zip(a, a[n:]):
    c += min(p+a, b)
    p = a - max(min(b-p, a), 0)
print(c)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x = int(input())
    print('Yse' if x >= 30 else 'No')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a=input()
a=list(map(int,input().split()))
count=0
for itr in range(len(a)):
    if itr+1==a[itr]: count+=1
if count==0: print(0)
elif count%2:
    print(count//2)
else: print(count//2+1)
# Judge status: Accepted
import bisect
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a=bisect.bisect_left(A,b)
    c=bisect.bisect_right(C,b)
    ans += a *(N-c)
print(ans)
# Judge status: Accepted
n = int(input())
w = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += w[i]
    if ans >= sum(w)//2:
        print(min(abs(sum(w[:i+1])-sum(w[i+1:])), abs(sum(w[:i])-sum(w[i:]))))
        break
# Judge status: Wrong Answer
X = input()

print("Yes" if (X in "753") else "NO")
# Judge status: Accepted
X = int(input())
A = 1
while True:
    if X > A ** 5:
        S = X - A ** 5
        B = S ** (1 / 5) * (-1)
    else:
        S = A ** 5 - X
        B = S ** (1 / 5)
    if A ** 5 - int(B) ** 5 == X:
        break
    A += 1
print(A, int(B))
# Judge status: Accepted
from bisect import bisect_left
import copy

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


ans = 0
for small in range(n - 2):
    for mid in range(small + 1, n - 1):
        div = bisect_left(l, l[small] + l[mid], 0, n)
        if div > mid + 1:
            ans += div - mid - 1

print(ans)
# Judge status: Accepted
print('YNeos'[len(set(input()))!=2::2])
# Judge status: Wrong Answer
def main():
    S=int(input())

    mod=10**9+7
    all=pow(2,S-1)
    for i in range(S-2,S-5,-1):
        all=all-pow(2,i)
    all-=S
    print(all%mod)

if __name__=="__main__":
    main()
# Judge status: Wrong Answer
s = list(input()).sort()
t = list(input()).sort()
 
if str(s) < str(t):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import math
N=int(input())
p=math.sqrt(N*2-0.25)-0.5
q=int(p)+1
M=q*(q+1)//2
L=M-N#must0or+
for i in range(q+1):
    if i != L:
        print(i)
# Judge status: Wrong Answer
s = input()

print("Yes" if s[4]==s[5] else "No")
# Judge status: Accepted
a, b = map(int, input().split())
if a <= 9 and b <= 9:
    print(a*b)
else:
    print(-1)
# Judge status: Wrong Answer
a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = list(map(int, input().split()))
if (a and b and c) in A:
    print("Yes")
elif (d and e and f) in A:
    print("Yes")
elif (g and h and i) in A:
    print("Yes")
elif (a and d and g) in A:
    print("Yes")
elif (b and e and h) in A:
    print("Yes")
elif (c and f and i) in A:
    print("Yes")
elif (a and e and i) in A:
    print("Yes")
elif (c and e and g) in A:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b = map(int, input().split())

str1 = str(a)*b
str2 = str(b)*a
if str1<=str2:
    print(str1)
else:
    print(str2)
# Judge status: Accepted
S = list(input())

count_0 = 0
count_1 = 0

for i in S:
	if i == "0":
		count_0 += 1
	if i == "1":
		count_1 += 1

print(min(count_0, count_1)*2)
# Judge status: Accepted
n = int(input())
li = list(map(int,input().split()))
ans = 100000000000000000

for i in range(1,n):
    if i == 1:
        x = sum(li[:i])
        y = sum(li[i:])
    else:
        x += li[i-1]
        y -= li[i-1]
    z = abs(x-y)
    if z < ans:
        ans = z
    
print(ans)
# Judge status: Accepted
X = int(input())
sum = 0
i = 1
while sum < X:
    sum += i
    i += 1
print(i-1)
# Judge status: Accepted
X = int(input())
if X in [3,5,7]:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n = int(input())
ans = []
tmp = 0
i = 1
while tmp < n:
    ans.append(i)
    tmp += i
    i += 1
print('\n'.join(map(str, ans)))
# Judge status: Accepted
s = input()
l = list(s)
count = 0
ans = 0
for i in range(len(l)):
    if l[i] == "A" or l[i] == "T" or l[i] == "G" or l[i] == "C":
        count += 1
        continue
    ans = max(ans,count)
    count = 0
ans = max(ans,count)
print(ans)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
n=input()
for i in range(len(n)):
    if n[i] ==9:
        print('Yes')
        break
    else:
        print('No')
# Judge status: Accepted
X,Y = list(map(int,input().split()))
if X % Y == 0:
  print(-1)
else:
  for i in range(1,1000000):
      if X*i > 10**18:
          print(-1)
          break
      if X*i % Y != 0:
          print(X*i)
          break
# Judge status: Accepted
a,b = map(int,input().split())
s=input()
if s[a]=="-" and len(s)==a+b+1 and s.count("-")==1:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s=input()
n=len(s)
def check(s):
    a=list(set(list(s)))
    b=list("ACGT")
    for i in b:
        if i in a:
            a.remove(i)
    if a==[]:
        return len(s)
    return 0
ans=0
for i in range(n):
    for j in range(n+1):
        ans=max(ans,check(s[i:j]))
print(ans)
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
s = input()

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a+1, d+1):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

for i in range(b+1, d+1):
    if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
import itertools

N, M, Q = map(int, input().split())
input_lists = []
A = []
point = [0]

for _ in range(Q):
    input_lists.append([int(i) for i in input().split()])

for A in itertools.combinations_with_replacement(range(1, M+1), N):
    d_sum = 0
    for input_list in input_lists:
        a, b, c, d = input_list
        if A[b-1] - A[a-1] == c:
            d_sum += d
    point.append(d_sum)

print(max(point))
# Judge status: Accepted
s=input()
a=0
b=0
for i in range(len(s)):
    if i%2==0:
        if s[i]!="0":
            a+=1
    else:
        if s[i]!="1":
            a+=1
for i in range(len(s)):
    if i%2==1:
        if s[i]!="0":
            b+=1
    else:
        if s[i]!="1":
            b+=1
print(min(a,b))
# Judge status: Wrong Answer
S = input()
N = len(S)#7
a = 0
f = (N-1)//2
for i in range(f):
    if S[i] !=S[f-i-1]:
        a = 1
b = 0
for j in range((N+3)//2-1,N):
    b += 1
    if S[j] != S[N-b]:
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x=int(input())
out="Christmas"
for i in range(x-25):
  out+=" Eve"
print(out)
# Judge status: Accepted
A, B, C = map(int, input().split())
if A % 2 == 0 or B % 2 == 0 or C % 2 ==0:
    print(0)
else:
    print(min(A*B, B*C, C*A))
# Judge status: Wrong Answer
s = input()
s_n = ''.join(sorted(s))

t = input()
t_n = ''.join(sorted(t,reverse = True))

if s_n > t_n:
  print('No')

else:
  print('Yes')
# Judge status: Accepted
n,*a=map(int,open(0).read().split())

b=sum(map(lambda x:x*x,a))
mod=10**9+7
ans=(sum(a)**2-b)//2

print(ans%mod)
# Judge status: Wrong Answer
from functools import reduce

n,a,b = [int(i) for i in input().split()]
mod = 10**9 + 7
total = (2**n -1)%mod

def f(A):
    num = reduce(lambda x, y: x * y % mod, range(n, n - a, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, a + 1))
    return num * pow(den, mod - 2, mod) % mod

print((total - f(a) - f(b))%mod)
# Judge status: Wrong Answer
def actual(a, b):
    multiple_a_set = set()
    multiple_b_set = set()

    for i in range(2, 10 ** 5 + 1):
        if i % a == 0:
            multiple_a_set.add(i)
        if i % b == 0:
            multiple_b_set.add(i)

    if multiple_a_set & multiple_b_set:
        return min(multiple_a_set & multiple_b_set)

    # 共通の倍数を持たない場合は、積が最小公倍数
    return a * b


a, b = map(int, input().split())
print(actual(a, b))
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
for i in A:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            print('DENIED')
            exit()
print('APPROVED')
# Judge status: Accepted
n = int(input())
list_res = []
for i in range(0, n):
    s, p = input().split()
    list_res.append([s, int(p), i + 1])
list_res_point = sorted(list_res, key=lambda x: (x[1]), reverse=True)
list_ans = sorted(list_res_point, key=lambda x: (x[0]))
for i in range(0, n):
    print(list_ans[i][2])
# Judge status: Accepted
X = int(input())
dp = [True] + [False] * (X)

if X < 106:
  if 100 <= X <= 105:
    print(1)
    exit()
  else:
    print(0)
    exit()


# 100~105円はyes
for i in range(100,106):
  dp[i] = True

for i in range(106,X+1):
  for j in range(100,106):
    if dp[i-j] == True:
      dp[i] = True
      break

print(1 if dp[X] == True else 0)
# Judge status: Accepted
from math import factorial
def f(a, b):
    if a == 0 or b == 0:
        return 1
    else:
        return factorial(a) // (factorial(a - b) * factorial(b))
n, p = map(int, input().split())
a = [int(x) % 2 for x in input().split()]
e, o = a.count(0), a.count(1)
if p == 0:
    print((2**e)*sum([f(o, i) for i in range(0, o+1, 2)]))
else:
    print((2**e)*sum([f(o, i) for i in range(1, o+1, 2)]))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
x = a%b
f = False
for i in range(1,b):
  if x*i == c:
    f = True
print("Yes" if f is True else "No")
# Judge status: Accepted
def main():
    from collections import Counter
    s = input()

    l = [0]
    t = 1
    for i, x in enumerate(s[::-1]):
        t = t * 10 % 2019
        y = (l[-1] + int(x) * t) % 2019
        l.append(y)

    c = Counter(l)
    ans = sum([v * (v - 1) // 2 for v in c.values()])
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
n, d = map(int, input().split())
x = []
ans = [i**2 for i in range(1, (n*d)**2)]
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)
cnt = 0
sum_t = 0
for i in range(n):
    for j in range(i+1, n):
        sum_t = 0
        for k in range(d):
            sum_t += (x[i][k]-x[j][k])**2
        if sum_t in ans:
            cnt += 1
print(cnt)
# Judge status: Accepted
A,B,C=map(int,input().split())
x=C-A+B
if x<0:
    print(0)
else:
    print(x)
# Judge status: Accepted
n,k=map(int,input().split())
p=list(map(int,input().split()))
maxim=[0]*(n-k+1)
cnt=0
s=0
for i in range(n):
    cnt+=1
    s+=p[i]
    if cnt==k:
        maxim[i-(k-1)]=s
        cnt=k-1
        s+=-p[i-(k-1)]

ans=(max(maxim)+k)/2
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline


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

    x = min(B-1, N)
    ans = int(A*x/B) - A*int(x/B)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n=int(input())
if n%1000!=0:
  print(1000-n%1000)
else:
  print(0)
# Judge status: Accepted
n, T = list(map(int, input().split()))
ans = 1001
for _ in range(n):
    c, t = list(map(int, input().split()))
    if t <= T:
        ans = min(ans, c)
if ans == 1001:
    print('TLE')
else:
    print(ans)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]
a,b,t = map(int,input().split(' '))

S = a+b+t
M = max(a,b,t)
print(M*10+(S-M))
# Judge status: Wrong Answer
m=10**9+7
n=int(input())
a=(8**n)%m
b=(9**n)%m
c=(10**n)%m
print((2*b-c+a)%m)
# Judge status: Accepted
s = input()
print(len([i for i in s if i == '1']))
# Judge status: Accepted
# coding: utf-8
N, M = map(int, input().split())
AC, WA = [], []
AC = [False for _ in range(10**5)]
WA = [0 for _ in range(10**5)]
ac, wa = 0, 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0]) - 1
    s = tmp[1]
    if AC[p]:
        continue
    else:
        if s == "AC":
            AC[p] = True
        else:
            WA[p] += 1
for i in range(N):
    if AC[i]:
        ac += 1
        wa += WA[i]
print(ac, wa)
# Judge status: Wrong Answer
import math
A, B, H, M = map(int, input().split())

A_rad = (360/12)*H + ((360/12)/60)*M
B_rad = (360/60)*M

if A_rad > B_rad:
    rad_dif = A_rad -B_rad
else:
    rad_dif = B_rad

if rad_dif > 180:
    rad_dif = 360 - rad_dif


ans = math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(rad_dif)))

print('%20.20Lf' %ans)
# Judge status: Accepted
def solve():
    A, B = map(int, input().split())
    S = input()
    if S[:A].isdigit() and S[A] == '-' and S[A+1:].isdigit():
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
n=int(input())
ab=[map(int,input().split()) for _ in range(n)]
a,b = [list(i) for i in zip(*ab)]

s=0
for i in range(n):
    if a[n-1-i]%b[n-1-i]==0:
        continue
    else:
        c=b[n-1-i]-((a[n-1-i]+s)%b[n-1-i])
        s+=c
print(s)
# Judge status: Accepted
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

S.sort()
#print(S)
S_out=''
for ii in S:
  S_out += ii
print(S_out)
# Judge status: Wrong Answer
A,B,C,K = map(int,input().split())
sum_ = 0
sum_ += min(A,K)
K = max(K-A,0)
if K > 0:
    K = min(K-B,0)
if K > 0:
    sum_ -= min(K)
print(sum_)
# Judge status: Accepted
n=int(input())
s=input()

a=0
l=0

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

print('('*l+s+')'*a)
# Judge status: Wrong Answer
X,Y,A,B,C=map(int,input().split())
P=sorted(list(map(int,input().split())))
Q=sorted(list(map(int,input().split())))
R=sorted(list(map(int,input().split())))
S=sorted(P[A-X:]+Q[B-Y:])
i=0
while S[i]<R[-1-i]:
    if len(R)>i or len(S)>i:
        break
    i+=1
print(sum(S[i+1:])+sum(R[-1-i:]))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=b[a[0]-1]

for i in range(1,n):
  ans+=b[a[i]-1]
  if a[i]==a[i-1]+1:
    ans+=c[i-2]
print(ans)
# Judge status: Accepted
n = int(input())
print(sum(n//i * (n//i+1) // 2 * i for i in range(1, n+1)))
# Judge status: Wrong Answer
n, x = map(int,input().split())
l = list(map(int,input().split()))
i, d = 0, 0
while i<n and d < x:
    d += l[i]
    i += 1
print(i)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(n+1)]
leaf = sum(a)

if n == 0 and a[0] != 1:
    print(-1)
    exit()
b[0] = 1 - a[0]
leaf -= a[0]
ans = 1
for i in range(1,n+1):
    kosu = min(b[i-1] * 2,leaf)
    ans += kosu
    b[i] = kosu - a[i]
    if b[i] < 0:
        print(-1)
        exit()
    leaf -= a[i]
print(ans)
# Judge status: Wrong Answer
S = input()
W = ["Sunny","Cloudy","Rainy"]
print(W.index(S)+1 % 3)
# Judge status: Accepted
N = int(input())
An = list(map(int, input().split()))
done = 0
for i in An:
    if done+1 == i:
        done = i
if done == 0:
    print(-1)
else:
    print(N-done)
# Judge status: Accepted
from sys import stdin
input = stdin.readline


def main():
  N, K = list(map(int, input().split()))

  sum_ = 0
  for k in range(K, N+2):
    sum_ += (k*(N-k+1)+1)

  print(sum_ % 1_000_000_007)


if(__name__ == '__main__'):
  main()
# Judge status: Wrong Answer
N, K = map(int, input().split())
ans = 0

for i in range(1, N + 1):
    tmp = 1 / N
    now = i
    while now <= K:
        now *= 2
        tmp *= 1 / 2
    
    ans += tmp
        
print(ans)
# Judge status: Accepted
n,w = map(int,input().split())
ww = [0]*n
vv = [0]*n
dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(n):
  ww[i],vv[i] = map(int,input().split())      
  
for i in range(1,n+1):
  for j in range(1,w+1):
    dp[i][j] = dp[i-1][j]
    if j - ww[i-1] >= 0:
      dp[i][j] = max(dp[i][j], \
                     dp[i-1][j-ww[i-1]] + vv[i-1])        

print(dp[-1][-1])
# Judge status: Accepted
S = input()
T = input()
d = len(S) - len(T)
print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + len(T) + 1])) for i in range(d + 1)))
# Judge status: Wrong Answer
import math
n,d=map(int,input().split())
c=0
for i in range(n):
    x,y=map(int,input().split())
    res=math.floor(math.sqrt((x**2+y**2)))
    print(res)
    if(res<=d):
        c+=1
print(c)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

max_index = [i for i, x in enumerate(A) if x == max(A)]
stopbuy = max_index[-1]

money = 1000
stock = 0

for i in range(stopbuy):
    if A[i+1] > A[i]:
        stock = money // A[i]
        money = money % A[i]
    else: # A[i+1] <= A[i]
        money = money + A[i] * stock
        stock = 0

money = money + A[stopbuy] * stock
print(money)
# Judge status: Wrong Answer
S=int(input())

#S=x1y2-x2y1
#S+x2y1=x1y2
#S+y1=10**9y2 (x1=10**9, x2=1)
Y1=S%(10**9)
Y2=S//(10**9)
print(10**9,Y1,1,Y2,0,0)
# Judge status: Wrong Answer
# 1%
import math

N = int(input())
x = 100
ans = 0
while x < N:
    x += math.floor(x /100)
    ans += 1

print(ans)