peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]

closest = {}
for s in student:
    min_dist = 'INF'
    ans = 1
    for c in checkpoint:
        dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if min_dist == 'INF' or dist < min_dist:
            min_dist = dist
            closest[s] = ans
        ans += 1

print(closest[s] for s in student)
# Judge status: Accepted
import math
n,d=list(map(int,input().split()))
print(math.ceil(n/(2*d+1)))
# Judge status: Accepted
s = input().strip()
a = (s[0] == "A")
c_cnt = 0
for e in s[2:(-1)]:
    if e == "C":
        c_cnt += 1
if a and c_cnt == 1 and s[1:].replace("C", "").islower():
    print("AC")
else:
    print("WA")
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(min(k,41)):
    imos=[0]*(n+1)
    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n-1,i+a[i])+1]-=1
    for i in range(n-1):
        imos[i+1]+=imos[i]
    for i in range(n):
        a[i]=imos[i]
print(*a)
# Judge status: Accepted
x,a,b=map(int,input().split())
if b-a>x:
    print('dangerous')
elif b-a<=0:
    print('delicious')
else:
    print('safe')
# Judge status: Accepted
def main():
  N,K=map(int,input().split())
  sFlag=True
  s=0
  while(sFlag):
    sk=K**s
    if(N>=sk):
      sans=s
      s=s+1
    else:
      print(sans+1)
      sFlag=False

if __name__ == '__main__':
	main()
# Judge status: Accepted
s, w = map(int, input().split())
if w >= s:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
  ans += min(b[i], b[i+1])
ans += b[0] + b[n-2]
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
abc_M = max([a, b, c])
ans = 0
no_max = list(map(lambda x: abs(x-abc_M), [a, b, c]))
no_max = [i for i in no_max if i != 0]
if all(i % 2 == 0 for i in no_max):
  for i in no_max:
    ans += i//2
if all(i % 2 != 0 for i in no_max):
  for i in no_max:
    ans += (i-1)//2
  ans += 1
if [i %2 == 0 for i in no_max] == [True, False] or [False, True]:
  ans += 1
  for i in no_max:
    if i % 2 != 0:
      ans += (i-1)//2
    if i%2 == 0:
      ans += i//2
  ans += 1
print(ans)
# Judge status: Accepted
def main():
    x = int(input())

    num = 10**3
    for a in range(-num,num):
        for b in range(-num, num):
            if a**5-b**5 == x:
                print(a,b)
                return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split());
num = a;

if k >= a + b:
  num -= k - (a + b);
  
print(num)
# Judge status: Accepted
from math import ceil

N = int(input())
C = [0]*(N-1)
S = [0]*(N-1)
F = [0]*(N-1)
for i in range(N-1):
	C[i],S[i],F[i] = map(int, input().split())


for i in range(N-1):
	t = 0
	for j in range(i,N-1):
		if t<=S[j]:
			t = S[j] + C[j]
		else:
			k = ceil((t-S[j])/F[j])
			t = S[j] + F[j]*k +C[j]
	print(t)
print(0)
# Judge status: Accepted
x = int(input())

if 1<= x%11 <= 6:
    print(x//11*2+1)
elif 7<= x%11 <= 10:
    print(x//11*2+2)
else:
    print(x//11*2)
# Judge status: Wrong Answer
A,B = map(int,input().split())

print(max(2*A-1, A-B, 2*B+1))
# Judge status: Wrong Answer
import math

A, B, C, D = map(int, input().split())
CD = int(C * D / math.gcd(C, D))

B_in_C = int(B/C)
B_in_D = int(B/D)
B_in_CD = int(B/(CD))
B_con = B - (B_in_C + B_in_D - B_in_CD)

A = A-1
A_in_C = int(A/C)
A_in_D = int(A/D)
A_in_CD = int(A/(CD))
A_con = A - (A_in_C + A_in_D - A_in_CD)

print(B_con - A_con)
# Judge status: Wrong Answer
from functools import *
@lru_cache(maxsize=None)
def f(x):
  if x==1:return 1
  s=10000000000000000
  for u in [1]+[6**i for i in range(1,11)]+[9**i for i in range(1,11)]:
    if x-u>=1:
      s=min(s,f(x-u)+1)
  return s
for i in range(1,100001):f(i)
print(f(int(input())))
# Judge status: Accepted
n,r=map(int,input().split())

if n>=10:
  print(r)
else:
  print(r+100*(10-n))
# Judge status: Accepted
q, h, s, d = [int(i) for i in input().split()]
n = int(input())
d = min(min(d, s*2), min(h*4, q*8))
s = min(s, min(h*2, q*4))
print((n // 2) * d + (n % 2) * s)
# Judge status: Accepted
N = int(input())
if N == 1:
  ans = 1
else:
  l = [2,1]
  for i in range(2, N+1):
    l.append(l[-2]+l[-1])
  ans = l[-1]
print(ans)
# Judge status: Accepted
a=int(input())
b=int(input())
c=int(input())
x=int(input())
n=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                n+=1
print(n)
# Judge status: Accepted
w = input()
s = set(list(w))

flag = True

for ss in s:
    if w.count(ss) % 2 != 0:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int,input().split())
l= []
L = []
for i in range(a):
    t= input()
    l.append(t)
for i in range(b):
    t = input()
    L.append(t)
f = 'No'
for i in range(a-b+1):
    for j in range(a-b+1):
        s = 0
        for I in range(b):
            for J in range(b):
                if l[i+I][j+J] == L[I][J] :s+=1
        if s==b**2:f='Yes'
print(f)
# Judge status: Wrong Answer
n=int(input("Test cases"))
d={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
  x=input()
  d[x]=d[x]+1
for k,v in d.items():
	print(k,"x",v)
# Judge status: Accepted
a, b, x = map(int, input().split())
a_div = (a - 1) // x + 1
b_div = b // x + 1

print(b_div - a_div)
# Judge status: Wrong Answer
a=input()
if a==25:
  print("Christmas")
if a==24:
  print("Christmas Eve")
if a==23:
  print("Christmas Eve Eve")
if a==22:
  print("Christmas Eve Eve Eve")
# Judge status: Wrong Answer
n,m=map(int,input().split())
for i in range(m):
    print(m-i,m+1+i)
# Judge status: Accepted
s=input()
ans=''
for i in range(len(s)):
    if s[i]=='0':
        ans+='0'
    elif s[i]=='1':
        ans+='1'
    elif s[i]=='B' and len(s)!=0:
        ans=ans[:-1]
print(ans)
# Judge status: Accepted
c = str(input())
vowel = ['a','i','u','e','o']

if c in vowel:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=0
ab=0
for i in range(N):
  d+=b[a[i]-1]
  
  if i != 0:
    if ab+1==a[i]:
      d+=c[ab-1]
   
  ab=a[i]
    
print(d)
# Judge status: Accepted
import math
h,w = map(int,input().split())
if(h == 1 or w == 1):
    print(1)
else:
    print(math.ceil((h*w)/2))
# Judge status: Accepted
N,P=map(int, input().split())
*A,=map(int, input().split())
p = [0,0]
for a in A: p[a&1] += 1
even,odd=p[0],p[1]

def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n-i)
        q = q * (i+1)
    return p // q

ans = 2**even
tmp = 0
if P:
    for i in range(1,odd+1,2):
        tmp += comb(odd, i)
else:
    for i in range(0,odd+1,2):
        tmp += comb(odd, i)
print(ans*tmp)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum_ = 0
for i in a:
    sum_ +=i
if(a[m-1]>(sum_/4*m)):
    print('Yes')
else: print('No')
# Judge status: Accepted
import sys
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v <= w:
    print('NO')
    sys.exit()

V = v - w
R = abs(a-b)
if V*t >= R:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
ans = a * b / 2
print(ans)
# Judge status: Accepted
n =int(input())
t,a =map(int,input().split())
h = list(map(int,input().split()))
ans = 0
near = 10000
for i in range(n):
    if abs(t-h[i]*0.006 - a) < near:
        ans = i
        near = abs(t-h[i]*0.006-a)
print(ans+1)
# Judge status: Wrong Answer
N= int(input())
L = list(map(int, input().split()))

if sum(L) - max(L) < max(L):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import sys

readline = sys.stdin.readline
N = int(readline())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, readline().split())
for i in range(N):
    time = 0
    for c, s, f in zip(C[i:N-1], S[i:N-1], F[i:N-1]):
        if time < s:
            time = s
        else:
            time += (time-s) % f
        time += c
    print(time)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b = inpl()
res = 0
for x in range(a,b+1):
    tmp = str(x)
    if tmp == tmp[::-1]:
        res += 1
print(res)
# Judge status: Wrong Answer
#二分探査かぁ…
from math import *
import fractions
import collections
import itertools
import pprint
from collections import deque
from heapq import *
N,K=map(int,input().split())
A=list(map(int,input().split()))
maxnum=10**9+20
minnum=1
while maxnum-minnum>1:
    cnt=0
    piv=(maxnum+minnum)//2
    for i in range(N):
        cnt=cnt+(ceil(A[i]/piv)-1)
    #print(cnt,piv)
    if cnt>K:
        minnum=piv
    else:
        maxnum=piv
    #print(maxnum,minnum)
    #input()
print(min(maxnum,max(A)))
# Judge status: Accepted
n, k, s = map(int, input().split())
a = [s] * k + [1 if n < s else s + 1] * (n - k)
print(*a)
# Judge status: Accepted
N=int(input())
*A,=map(int,input().split())
*B,=map(int,input().split())

i=0
ans=0
while i<N:
    if A[i]+A[i+1]>=B[i]:
        ans+=B[i]
        A[i+1]-=max(B[i]-A[i],0)
    else:
        ans+=A[i]+A[i+1]
        A[i+1]=0
    i+=1

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
cnt2 = 0
cnt4 = 0

for i in range(n):
    if a[i] % 4 == 0:
        cnt4 += 1
    elif a[i] % 2 == 0:
        cnt2 += 1

if cnt2 % 2 == 1:
    if cnt2 > 2:
        cnt2 -= 1
    else:
        cnt2 = 0

if n - ((cnt4*3)-(cnt4-1))-cnt2 <= 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(0,N,2):
    if a[i]%2==1:
        ans+=1
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
  flag = True
  si = str(i)
  for j in range(len(si) // 2):
    if si[j] != si[-(j + 1)]:
      flag = False
  if flag:
    cnt += 1
# Judge status: Accepted
import sys
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort(reverse=True)

if k >= len(hp_list):
    print(0)
    sys.exit()

hp_list = hp_list[k:]
print(sum(hp_list))
# Judge status: Accepted
#C
w,h,x,y = map(int,input().split())

if w / 2 == x and h / 2 == y:
    flg = True
else:
    flg = False

S = w * h / 2
    
if flg:
    print(S,1)
else:
    print(S,0)
# Judge status: Accepted
import fractions
a,b=map(int,input().split())
ans = a*b//fractions.gcd(a,b)
print(ans)
# Judge status: Accepted
n = int(input())

for cake in range(27):
    for donut in range(16):
        val = cake * 4 + donut * 7
        if val == n:
            print('Yes')
            exit()

print('No')
# Judge status: Accepted
a,b,x = map(int,input().split())
import math
if 2*x >= b*a**2:
    rad = math.atan(2*(b*a**2-x)*a**(-3))
    print(math.degrees(rad))
else:
    rad = math.atan(a*b**2/(x*2))
    print(math.degrees(rad))
# Judge status: Accepted
# author:  Taichicchi
# created: 29.09.2020 22:35:47

import sys
n = int(input())

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

cnt = 0

for l in a:
    if l % 2:
        pass
    elif l % 4:
        cnt += 1
    else:
        cnt += 2

# print(f"{cnt=}")

if cnt // 2 >= n // 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#!/usr/bin/env python3
s = input()
idx_a = 0
idx_z = 0
for i in range(len(s)):
    if s[i] == "A": 
        idx_a = i
        break
for i in range(len(s)-1,0,-1):
    if s[i] == "Z": 
        idx_z = i
        break
print(idx_z - idx_a + 1)
# Judge status: Accepted
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])
# Judge status: Accepted
a,b = map(int,input().split())
if a==b:
  print(2*b)
else:
  x = max(a,b)
  print(2*x-1)
# Judge status: Wrong Answer
ret = -1

A, B = [int(i) for i in input().split()]

for i in range(2000):
    if int(i*0.08) == A and int(i * 0.1) == B:
        ret = i
        break

print(i)
# Judge status: Accepted
# A - Air Conditioner
X = int(input())

if X >= 30:
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
print(b - c) if b - c >= 0 else print(0)
# Judge status: Accepted
n,x,t = map(int,input().split())
if(n%x==0):
  print((n//x)*t)
else:
  print((n//x)*t+t)
# Judge status: Accepted
N,K=map(int,input().split())
arr=[]
ans=[str(i) for  i in range(1,N+1)]
for i in range(K):
    _=input()
    arr.extend((input().split()))
    arr=list(set(arr))
p=0
for n  in  ans:
    if(not(n in arr) ) :
        p=p+1
print(p)
# Judge status: Accepted
N = input()

if N[-1] == '3':
  print('bon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print('pon')
else:
  print('hon')
# Judge status: Accepted
import math

n = int(input())
l = [int(input()) for _ in range(5)]

x = min(l)

print(math.ceil(n/x) + 4)
# Judge status: Wrong Answer
s = input()

hi = True
for i in range(len(s)):
  if i % 2 == 0 and s[i] != "h":
    hi = False
    break
  elif i % 2 == 1 and s[i] != "i":
    hi = False
    break
    
if hi:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
x = input().split()

for i, a in enumerate(x):
    if(a == "0"):
        print(i)
# Judge status: Accepted
# coding: utf-8
# Your code here!

a, b, c = map(int, input().split())
if c-a+b < 0:
    print(0)
else:    
    print(c-a+b)
# Judge status: Accepted
N,M=(int(x) for x in input().split())
T=[1]*N
H=list(map(int,(input().split())))
while 1:
    try:
        A,B=(int(x) for x in input().split())
    except:
        break
    if(H[A-1]<H[B-1]):
        T[A-1]=0
    elif(H[B-1]<H[A-1]):
        T[B-1]=0
    else:
        T[A-1]=0
        T[B-1]=0
print(T.count(1))
# Judge status: Accepted
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]

dp = [[0 for i in range(3)] for i in range(n)]

dp[0] = l[0]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1]+l[i][0], dp[i-1][2]+l[i][0])
    dp[i][1] = max(dp[i-1][0]+l[i][1], dp[i-1][2]+l[i][1])
    dp[i][2] = max(dp[i-1][0]+l[i][2], dp[i-1][1]+l[i][2])

print(max(dp[-1]))
# Judge status: Accepted
print(6-sum([int(input())for _ in range(2)]))
# Judge status: Wrong Answer
X = int(input())
print(360 // X)
# Judge status: Wrong Answer
A,B=map(int,input().split())
if A<=8 or B<=8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_val = max(dict.values())
max_list = [k for k, v in dict.items() if v == max_val]
max_list.sort()
for i in max_list:
    print(i)
# Judge status: Wrong Answer
S=input()
T=input()
l=len(S)
if S==T[:-1] and S.islower()==True and 1<=l and l<=10:
  print("Yes")
else:
  print("NO")
# Judge status: Wrong Answer
a=int(input())
a+a**2+a**3
# Judge status: Accepted
N = int(input())
A = input().split()
if N == len(list(set(A))):
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
a,b,c = map(int,input().split("/"))
print("2018/01/{}".format(c))
# Judge status: Accepted
import bisect

n = int(input())
a = list(map(int,input().split()))
a.sort()
sect = 0
col = 0
for i in range(400,3201,400):
    nsect = bisect.bisect_left(a,i)
    if nsect>sect:
        sect = nsect
        col += 1
print(max(col,1),col+n-nsect)
# Judge status: Accepted
K, S = map(int, input().split())
Y = 0

for i in range(K+1):
  for j in range(K+1):
    if 0 <= S-i-j and S-i-j <= K:
      Y = Y+1

print(Y)
# Judge status: Wrong Answer
import re
s = input()
pat = "key.*ence"
if re.findall(pat, s):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n = int(input())
s = list(input())
ans = 0
c = 0
fh = []
lh = s
for i in range(n):
  tmp = lh.pop(0)
  if tmp not in fh:
    if tmp in lh:
      c += 1
    else:
      c -= 1
  fh.append(tmp)
  ans = max(ans, c)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

flag = 1
for a in A:
    if a % 2 == 0:
        if ((a % 3 == 0) or (a % 5 == 0)):
            1
        else:
            print("DENIED")
            exit()
print("APPROVED")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()

import bisect

ncand = A[-1]
ix = bisect.bisect_left(A[:-1], ncand//2)
# print(A[:-1], ix)
if A[ix] == ncand:
    ix -= 1
ccand = A[ix]

print(ncand, ccand)
# Judge status: Accepted
print((lambda x:('IMPOSSIBLE' if (x[0]+x[1])%2==1 else (x[0]+x[1])//2))(list(map(int,input().split()))))
# Judge status: Accepted
S = input()

print('Heisei' if S <= '2019/04/30' else 'TBD')
# Judge status: Accepted
import math
import sys

s = sys.stdin.readline().rstrip()
d = {'a': 0, "b": 0, "c": 0}
for si in s:
    if si in d:
        d[si] += 1
    else:
        d[si] = 1
x = (len(s)-1) // 3+1
if d['a'] <= x and d['b'] <= x and d['c'] <= x:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
def solve():
  n = int(input())
  query  =[]
  for i in range(n):
    x,l = (int(i) for i in input().split())
    query.append((x+l,max(0,x-l)))
  query.sort()
  nowr = 0
  ans = 0
  for i in range(n):
    r,l = query[i]
    #print(nowr)
    if nowr <= l:
      nowr = r
      ans += 1
  print(ans)
solve()
# Judge status: Wrong Answer
n = int(input())
d = [tuple(map(int, input().split())) for _ in range(n)]

ans=0
for k in d:
    if ans >= 3:
        print("Yes")
        raise SystemExit(0)
    if k[0] == k[1]:
        ans+=1
    else:
        ans = 0
print("No")
# Judge status: Accepted
import itertools
import math
import fractions
import functools
s = list(input())
subs = 10**6
for i in range(len(s)-2):
    subs = min(subs,abs(int(''.join(s[i:i+3]))-753))

print(subs)
# Judge status: Accepted
a, b, c = [int(x) for x in input().split()]
if c >= a and c <= b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n, k = map(int,input().split())

moded = n%k
print(int(min(k-moded,moded)))
# Judge status: Accepted
n, x = map(int, input().split())
X = list(map(int, input().split()))

Y = [abs(x_ - x) for x_ in X]

import fractions
#import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

print(gcd_list(Y))
# Judge status: Accepted
n = int(input())

for i in range(n,1000):
    i = str(i)
    if i[0] == i[1] == i[2]:
        print(i)
        break
# Judge status: Wrong Answer
N, M = map(int, input().split())
jobs = []

for i in range(N):
    A, B = map(int, input().split())
    jobs.append((A-1, B))

jobs = sorted(jobs, key=lambda x: x[1], reverse=True)
used = [0] * M
ans = 0
cnt = 0

for job in jobs:
    if job[0] >= M:
        continue
    if used[job[0]] >= M - job[0]:
        continue
    else:
        used[job[0]] += 1
        ans += job[1]
        cnt += 1
        if cnt == M:
            break

print(ans)
# Judge status: Wrong Answer
a,b = map(int, input().split())
ans = 0
for i in range(a, b+1):
    if str(a+i) == str(a+i)[::-1]:
        ans += 1
print(ans)
# Judge status: Wrong Answer
a = list(map(int,input().split()))
counter = 0

if a[0] != a[1]:
    counter += 1

if a[1] != a[2]:
    counter += 1

if a[0] != a[2]:
    counter += 1

print(counter)
# Judge status: Wrong Answer
N = int(input())
i = 2
r = N
while i < N/2:
    if (N % i == 0):
        r = min(i+int(N/i), r)
    i += 1
print(r-2)
# Judge status: Accepted
num=list("0123456789")
a,b=map(int,input().split())
s=input()

for i in range(a+b+1):
    if i!=a:
        if s[i] not in num:
            print("No")
            break
    else:
        if s[i]!="-":
            print("No")
            break
else:
    print("Yes")
# Judge status: Accepted
A, B, K = map(int, input().split())
A_ = min(A, K)
print(A-A_, max(0, B-(K-A_)))
# Judge status: Wrong Answer
A={1, 3, 5, 7, 8, 10, 12}
B={4, 6, 9, 11}
C={2}
print("Yes" if {map(int, input().split())} <= A or B or C \
else "No")
# Judge status: Wrong Answer
n,k=map(int,input().split())
print(min(n%k,k-n))
# Judge status: Accepted
N = int(input())
S = input()
newS = ''
A = ord('A')
Z = ord('Z')
for k in range(len(S)):
    if ord(S[k]) + N > Z:
        newS += chr(ord(S[k]) + N - Z + A - 1)
    else:
        newS += chr(ord(S[k]) + N)
print(newS)
# Judge status: Wrong Answer
N, X, T = map(int, input().split())
print(int(-(-N/X)*T))
# Judge status: Accepted
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n,m = map(int,input().split())
    city = [0] * n
    for i in range(m):
        a,b = map(int,input().split())
        city[a-1] += 1
        city[b-1] += 1
    for i in range(n):
        print(city[i])
    return

if __name__=='__main__':
    main()
# Judge status: Accepted
from functools import reduce
N = int(input())
amounts = sorted(sum(([6 ** (i + 1), 9 ** i] for i in range(6)), []))
account = 1 << N
times = 0
while (times := times + 1) and not (account := reduce(lambda a, b: a | b, [account >> amount for amount in amounts])) & 1:
    pass
print(times)
# Judge status: Accepted
import numpy as np

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

average = np.mean(X)

m1 = int(average)
m2 = m1 + 1

ans1 = np.dot(X - m1, X - m1)
ans2 = np.dot(X - m2, X - m2)

print(min(ans1, ans2))
# Judge status: Accepted
s = input()

if s[0] == "A" and s[2:-1].count("C") == 1:
	if s.replace("A", "a", 1).replace("C", "c", 1).islower():
		print("AC")
		exit()

print("WA")
# Judge status: Accepted
n, w = [int(i) for i in input().split()]
wv = [[int(i) for i in input().split()] for _ in range(n)]

dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(1, n+1):
    wi, vi = wv[i-1]
    for j in range(1, w+1):
        if j < wi:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wi] + vi)
print(dp[-1][-1])
# Judge status: Accepted
L=list(map(int,input().split()))
print((sum(L)+1)//2)
# Judge status: Accepted
k, x = map(int, input().split())

if 500 * k >= x:
	print('Yes')
else:
  	print('No')
# Judge status: Accepted
n = int(input())
al=["z"]+[chr(ord('a') + i) for i in range(25)]
result = ""
while n>0:
    if n%26 !=0:
        result = al[n%26]+result
        n //= 26
    else:
        result = al[n%26]+result
        n //= 26
        n -= 1
print(result)
# Judge status: Wrong Answer
N = int(input())
Hs = list(map(int, input().split()))
res = [0] * N

for index, h in enumerate(Hs):
    l = 0
    if index > 0:
        l = max(res[index - 1] - 1, 0)

    tmp = h
    while index + l + 1 < N and tmp >= Hs[index + l + 1]:
        tmp = Hs[index + l + 1]
        l += 1
    res[index] = l

print(max(res))
# Judge status: Accepted
from bisect import *
n,*l=map(int,open(0).read().split())
l.sort()
ans=0
for i in range(1,n):
  for j in range(i+1,n):
    ans+=max(i-bisect_right(l,l[j]-l[i]),0)
print(ans)
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
print("Yes" if sum((j-i)//2*2 if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")
# Judge status: Accepted
w,a,b=map(int, input().split())

A=min(a,b)

B=max(a,b)

if A+w<B:
  print(B-A-w)
else:
  print(0)
# Judge status: Accepted
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    s=readline().strip()

    left_left=0
    need_left=0
    for i in range(n):
        if s[i]=="(":
            left_left+=1
        else:
            if left_left>0:
                left_left-=1
            else:
                need_left+=1

    print("("*need_left+s+")"*left_left)

if __name__=="__main__":
    main()