peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
c=input()
list=[0 for i in range(n+1)]
r=0
for i in range(n):
  if c[i]=='R':
    r+=1
w=0
list[0]=max(r,w)

#i corresponds to the right side boundary of c[i]
for i in range(n):
  if c[i]=='W':
    w+=1
  if c[i]=='R':
    r-=1
  list[i+1]=max(r,w)
print(min(list))
# Judge status: Accepted
a = list(input())
b = list(input())
print("YES" if a==b[::-1] else "NO")
# Judge status: Accepted
n = int(input())
t = [int(input()) for _ in range(n)]
from fractions import gcd
def lcm(a,b):
  return a*b//gcd(a,b)
ans = 1
for i in range(n):
  ans = lcm(ans,t[i])
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
if a*c <= b:
  print(c)
elif a*c >b:
  print(b//a)
# Judge status: Wrong Answer
from bisect import bisect_right
N = int(input())
L = {1}
m = 6
n = 9
while m <= N:
    L.add(m)
    m *= 6
while n <= N:
    L.add(n)
    n *= 9
L = list(L)
L.sort()
# print(L)

dp = [N]*(N+1)
dp[0] = 0

for i in range(1, N+1):
    x = bisect_right(L, i)
    for j in range(x):
        dp[i] = min(dp[i], dp[i % L[j]]+i//L[j])

# print(dp)
print(dp[N])
# Judge status: Wrong Answer
a = list(map(int,input().split()))
# b = list(map(int,input().split()))

if a[0]<=a[2]<=a[1]:
    print("yes")
else:
    print("No")
# Judge status: Wrong Answer
S = str(input())

cnt = 0
div_value = 2019

for i in range(0, len(S)-3):
   #print(i, S[i:i+4])
   for j in range(i+4, len(S)):
       #print(i, "-", j, S[i:j])
       if j-i >= 200000:
           continue
       if int(S[i:j]) >= div_value \
           and int(S[i:j]) % div_value == 0:
           #print(i, "-", j, int(S[i:j]))
           cnt = cnt+1

print(cnt)
# Judge status: Wrong Answer

s=input(" ")
s=s.lower()
print(s[0:3])
# Judge status: Accepted
a,b,x=map(int,input().split())
import math
if a*a*b/2 >x:
     print(math.degrees(math.atan(b*b*a/(2*x))))
else:
    d=a*a*b-x
    print(math.degrees(math.atan(2*d/a**3)))
# Judge status: Accepted
# coding: utf-8
# Your code here!

l = input()
if l.count("5") == 2 and l.count("7") == 1:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import math
N = int(input())
A = list(map(int, input().split()))
X = sum(A)//N
ans = 0
for i in A:
  ans += (i-X)**2
print(math.ceil(ans))
# Judge status: Accepted
a,b,c = list(map(int,input().split()))
if b-a == c - b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from collections import*;input();i=1
for c in Counter(input()).values():i*=c+1
print(~-i%(10**9+7))
# Judge status: Accepted
X,Y=map(int,input().split())
print([-1,X][X%Y>0])
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
if a+b<=k:
    print(0,0)
elif a==0 and b>=k:
    print(0,b-k)
elif a>=k and b==0:
    print(a-k,b)
else:
    print(0,0)
# Judge status: Wrong Answer
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
ans = 0
for i in range(n):
    if a[i] < k:
        ans = max(ans,i+1 + bisect.bisect_left(b,k-a[i]))
print(ans)
# Judge status: Wrong Answer
import math

X, Y = map(int, input().split())
print(math.floor(math.log2(Y // X)) + 1)
# Judge status: Accepted
N, M = map(int, input().split())

def Main(N, M):
    if N+3 >= M:
        return M//2
    else:
        c_remain = M-N*2
        return N+c_remain//4
    
print(Main(N, M))
# Judge status: Accepted
import math

aka, mi, ao = map(int, input().split(" "))
k = int(input())

for i in range(k):
    if mi <= aka:
        mi *= 2
        continue
    if ao <= mi:
        ao *= 2
        continue
    ao *= 2

if ao > mi > aka:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m = map(int,input().split())

# n + x : m - 2 * x = 1 : 2
# 2n+2x = m - 2x
# 4x = m-2n

if n * 2 <= m:
    l = (m - 2 * n) // 4
    ans1 = min(n+l, (m-l*2)//2)
    ans2 = min(n+l+1, (m - (l+1)*2)//2)
    print(max(ans1, ans2))

else:
    print(m//2)
# Judge status: Accepted
A,B = map(int, input().split())
Ans = A + B

if Ans <= 23:
    print(Ans)
else:
    print(Ans-24)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split())) 

l.sort()

ans = 0

for i in range(n):
    for j in range(0, i):
        for k in range(0, j):
            if (l[k] != l[j]) and (l[i] != l[j]) and (l[k] + l[j] > l[i]):
                ans += 1

print(ans)
# Judge status: Wrong Answer
r = int(input())
import math
print(math.pi * r)
# Judge status: Accepted
S = input()
N = len(S)
ans = ["x" for _ in range(N)]
print("".join(ans))
# Judge status: Accepted
a,b,c,k = map(int,input().split())
i = 0
if  k % 2 == 0:
  print(a-b)
else :
  print(b-a)
# Judge status: Accepted
a, b, c, k = list(map(int, input().split()))

s = 0
if k <= a+b:
    s = min(k, a)
else:
    s = a - (k-a-b)

print(s)
# Judge status: Accepted
A = list(input().rstrip().split(" "))
ans = []
for i in A:
    ans.append(i[0])
print("".join(ans))
# Judge status: Accepted
import numpy as np

N = int(input())
X = list(map(int, input().split()))
Xs = sorted(X)
c1 = np.median(Xs[1:]).astype(int)
c2 = np.median(Xs[:-1]).astype(int)

for i in range(N):
    if X[i] < c1:
        print(c1)
    else:
        print(c2)
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = s()
N = len(S)
ans = 0
for i in range(1,N-1,2):
    a = S[:i+1]
    if a[:(i+1)//2] == a[(i+1)//2:]:
        ans = i+1
print(ans)
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 0
x = 1
for d in range(60):
    odd = 0
    even = 0
    for a in A:
        if a & (1 << d):
            odd += 1
        else:
            even += 1
    ans += odd * even * x
    ans %= MOD
    x <<= 1
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
wcnt = [0] * n
ecnt = [0] * (n)
enum = 0
wnum = 0
for i in range(n):
    if s[i] == "W":
        wnum += 1
    wcnt[i] += wnum
    if s[-i - 1] == "E":
        enum += 1
    ecnt[-i - 1] += enum
ans = 10 ** 10
for i in range(n):
    temp = 0
    if i - 1 >= 0:
        temp += wcnt[i - 1]
    if i + 1 < n:
        temp += ecnt[i + 1]
    ans = min(ans, temp)
print(ans)
# Judge status: Accepted
n = int(input())
A = sorted(map(int, input().split()))[::-1]
# print(A)
loop = 0
scoreA = 0
scoreB = 0
for e in A:
    if loop % 2 == 0:
        scoreA += e
    else:
        scoreB += e
    loop += 1
print(scoreA - scoreB)
# Judge status: Accepted
S = input()

N = len(S)
O,E = 0,0
for i,s in enumerate(S):
  O +=(i%2)^int(s)
  E +=(i%2)^(not int(s))
print(min(O,E))
# Judge status: Accepted
n = int(input())
s = set()
for i in range(n):
  s |= {input()}
print(len(s))
# Judge status: Accepted
N,A,B = map(int,input().split())
if A>B:
    ans = 0
elif N==1 and A!=B:
    ans = 0
elif N==1 and A==B:
    ans = 1
else:
    ans = (N-2)*(B-A)+1
print(ans)
# Judge status: Accepted
N=int(input())
p=list(map(int,input().split()))
q=sorted(p)
count=0
for i in range(N):
  if p[i]!=q[i]:
    count+=1
if count<=2:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import sys
n=int(input())
l=sorted([int(input()) for _ in range(n)])
sm=sum(l)

if sm%10!=0:
    print(sm)
    sys.exit()
    
else:
    for i in range(n):
        if l[i]%10!=0:
            print(sm-l[i])
            sys.exit()
print(0)
# Judge status: Accepted
a,b=input(),input();
length = len(a)+len(b)
result = []
count1 = 0
count2 = 0
for i in range(length):
  if i % 2 == 0:
    try:
      result.append(a[count1])
      count1 += 1
    except:
      continue
  else:
    try:
      result.append(b[count2])
      count2 += 1
    except:
      continue
print(''.join(result))
# Judge status: Accepted
n=int(input())
even=[2,4,8,16,32,64]
ans=1
for i in range(len(even)):
  if even[i]<=n:
    ans=even[i]
print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(min(K,41)):
    l=[0]*(N+1)
    c=0
    for j in range(N):
        if j-A[j]>0:
            l[j-A[j]]+=1
        else:
            c+=1
        if A[j]+j<N:
            l[A[j]+j+1]-=1 
    for j in range(N):
        c+=l[j]
        A[j]=c
print(*A)
# Judge status: Wrong Answer
n = int(input())
si = []
for i in range(n):
    si.append(input())

wkmax = wk = m = 0
c = []
b = list(set(si))
m = len(b)

for i in range(m):
    wk = si.count(b[i])
    if wkmax <= wk:
        wkmax = wk
    c.append([b[i],wk])

for i in range(len(c)):
    if c[i][1] == wkmax:
        print(c[i][0])
# Judge status: Wrong Answer
N = int(input())
a = map(int, input().split())

x = [0]*(10**5 + 1)
for i in a:
    x[i-1] += 1
    x[i] += 1
    x[i+1] += 1

res = max(x)
print(res)
# Judge status: Accepted
S = input()
ok = True
for i in range(len(S)):
    if (i + 1) % 2:
        if S[i] not in ['R', 'U', 'D']:
            ok = False
    else:
        if S[i] not in ['L', 'U', 'D']:
            ok = False

if ok:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b = map(int, input().split())
ans = 0

for i in range(a, b + 1):
    s = str(i)
    if s[0] == s[4] and s[1] == s[3]:
        ans += 1

print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

reversed_cumsum = []
tmp = 0
for i in range(N):
    tmp += A[N - 1 - i]
    reversed_cumsum.append(tmp)
cumsum = reversed_cumsum[::-1]

ans = 0
for i in range(N - 1):
    ans = (ans + A[i] * cumsum[i + 1]) % (10 ** 9 + 7)
print(ans)
# Judge status: Accepted
ii=lambda:int(input())
miis=lambda:map(int,input().split())
lmiis=lambda:list(map(int,input().split()))

n,m=miis()

k=lmiis()
st=set(k[1:])

for i in range(n-1):
  ki=lmiis()
  st=st&set(ki[1:])

print(len(st))
# Judge status: Wrong Answer
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

c=0
for i in range(k,-1,-1):
    if i<=s:
        for j in range(k,-1,-1):
            if s-i-j<=k:
                c += 1

print(c)
# Judge status: Accepted
S = input()
L = "abcdefghijklmnopqrstuvwxyz"
for i in L:
  if i not in S:
    print(i)
    exit()
print("None")
# Judge status: Wrong Answer
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li) < len(li4)+1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import Counter
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

c = Counter(A)
check = 0
for i in range(N):
    if (c[A[i]] > 1):
        check += 1
if (check <= 1):
    print(0)
    exit()

L = []
for i, v in c.items():
    if (v > 3):
        L.append(i)
        L.append(i)
    elif (v > 1 and v <= 3):
        L.append(i)

L.sort(reverse=True)
print(L[0] * L[1])
# Judge status: Accepted
y=input()
if y=='0':
    print("1")
if y=='1':
    print("0")
# Judge status: Wrong Answer
def main():
    n, m = map(int, input().split())
    l = [ (input().split()) for i in range(m)]
    l.sort(key=lambda x: x[1])
    res = ["0"]*n
    for s, c in l:
        res[int(s)-1] = c
    res = "".join(res)
    res = int(res)
    if len(str(res))==n:print(int(res))
    else:print(-1)

if __name__ == "__main__":
    main()
# Judge status: Accepted
N, L = map(int, input().split())
lists = []
for n in range(N):
    lists.append(input())
print(''.join(sorted(lists)))
# Judge status: Wrong Answer
n, a, b = map(int, input().split(' '))
MOD = 10**9 + 7

ans = -1

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n = n>>1
    return res

ans += modpow(2, n, MOD)


def COM(n, k):
    res = 1
    for i in range(1, k+1):
        res = int(res * (n-i+1) / i) % MOD
    return res


ans -= COM(n, a)
ans -= COM(n, b)

print(ans)
# Judge status: Accepted
N,D = map(int,input().split())
ct = 0
for i in range(N):
    X,Y = map(int,input().split())
    if X**2 + Y**2 <=D**2:
        ct += 1
print(ct)
# Judge status: Wrong Answer
n,k=map(int,input().split())
  
a=[0]*n
ans=[0]*n
a=list(map(int,input().split()))

if (k>15):
  a=[n]*n
  print(" ".join(map(str,a)))
else:
  for _ in range(k):
    ans=[0]*n
    for i in range(n):
      left=max(0,i-a[i])
      right=min(n-1,i+a[i])
      #print(left,right)
      for j in range(left,right+1):
        ans[j]+=1
    a=ans

  print(" ".join(map(str,a)))
# Judge status: Accepted
def d_multiple_of_2019():
    from collections import Counter
    S = [int(ch) for ch in input()]

    p = 2019  # ABC158-E のソースコードを流用するため
    s = S[::-1]
    u = [0] * len(S)
    u[0] = s[0] % p

    power = 1
    for i in range(1, len(S)):
        power *= 10
        power %= p
        u[i] = u[i - 1] + power * s[i]
        u[i] %= p
    count = Counter(u)
    return sum(v * (v - 1) // 2 for v in count.values()) + count[0]

print(d_multiple_of_2019())
# Judge status: Wrong Answer
N = int(input())
prod = 1
mod = int(1e9+7)
for j in range(1, N+1):
    prod = j * (prod%mod)
print(prod)
# Judge status: Accepted
a,b,c,k = map(int, input().split())
if k%2 == 0:
    print(a-b)
else:
    print(b-a)
# Judge status: Wrong Answer
x, y = list(map(int, input().split()))

if y % 2 != 0:
    print('No')
    exit(0)

a = x * 4

if a < y:
    print('No')
    exit(0)
    
if x == y:
    print('No')
    exit(0)
    
print('Yes')
# Judge status: Wrong Answer
S = list(input())
Q = int(input())
x = 1
for i in range(Q):
    a, *b = input().split()
    if a == "1":
        x *= -1
    elif a == "2":
        c, d = b
        if c == "2":
            x *= -1 
        if x == 1:
            S.insert(0, d)
        elif x == -1:
            S.append(d)
print(*S, sep="")
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    ans = 0
    ex = []
    for _ in range(5):
        t = int(input())
        e = 10 - t%10
        if e != 10:
          ex.append(e)
        ans += t
    ex.sort()
    ans += sum(ex[:-1])

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
s=input()
t=input()
ans='No'
l=len(s)
if s==t:
  ans='Yes'
for _ in range(l):
  s=s[l-1]+s[:l-1]
  if s==t:
    ans='Yes'
    break
print(ans)
# Judge status: Accepted
n = int(input())
ans = list(map(int,input().split()))
key = ans[0]
up_key = True
down_key = True
count = 0
for i in range(n):
    if key < ans[i]:
        down_key = False
    if key > ans[i]:
        up_key = False
    if up_key == False and down_key == False:
        count += 1
        up_key = True
        down_key = True
    key = ans[i]
print(count+1)
# Judge status: Wrong Answer
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  ans += i
  for j in range(i+1,k+1):
    for m in range(j+1,k+1):
      ans += 3*math.gcd(math.gcd(i,j),m)
print(ans)
# Judge status: Accepted
import numpy as np

S = input()
ans = int(S[0])
ope = []

while True:
    for i in S[1:]:
        if np.random.randint(2) == 0:
            ans += int(i)
            ope.append("+")
        else:
            ans -= int(i)
            ope.append("-")

    if ans == 7:
        print(S[0]+ope[0]+S[1]+ope[1]+S[2]+ope[2]+S[3]+"=7")
        exit()
    else:
        ans = int(S[0])
        ope = []
# Judge status: Wrong Answer
N=int(input())
T=str(N)
K=len(T)-1
A=N//10
if N<10:
    print(N)
else:
    print(A*A+8+N%10)
# Judge status: Accepted
N = int(input())
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort(reverse=True)
#print(A,B)
if N % 2 == 1:
    x = (N+1) // 2
    ans = B[x-1] - A[x-1] + 1
else:
    x = N // 2
    ans = (B[x-1] + B[x]) - (A[x] + A[x-1]) + 1
print(ans)
# Judge status: Wrong Answer
S=input()

flag =0
ans =0

for i in range(len(S)):
    flag =0
    for j in range(len(S)-i):
        if S[i+j] == 'A' or S[i+j] == 'G' or S[i+j] == 'T' or S[i+j] == 'C':
            flag +=1
        else:
            ans = max(ans,flag)
            flag =0
            break
        
print(ans)
# Judge status: Accepted
if __name__=="__main__":
    n, m = map(int, input().split())
    if n==m:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
a,b,c=sorted(list(map(int,input().split())))
p,q=(c-a)//2,(c-b)//2
c=p+q
a,b=a+2*p,b+2*q
if a==c and b==c:
  print(c)
elif a==c or b==c:
  print(c+2)
else:
  print(c+1)
# Judge status: Wrong Answer
a, b = map(int, input().split())

print(a if a>=b else a-1)
# Judge status: Wrong Answer
a,b = map(int,input().split())

print(round((a + b) / 2))
# Judge status: Accepted
k,x=map(int, input().split())
print("Yes" if 500*k >= x else "No")
# Judge status: Accepted
from collections import Counter
mod = 10**9 + 7
n = int(input())
s = [i for i in input()]
cnt = Counter(s)
l = len(cnt)
val = list(cnt.values())
val = [i + 1 for i in val if i != 1]
ans = 2**(l-len(val)) % mod
for vi in val: ans *= vi % mod
print((ans - 1) % mod)
# Judge status: Accepted
N,A,B=map(int,input().split())
if (B-A)%2==0:
  print((B-A)//2)
else:
  if A-1<=N-B:
    print((A+B-1)//2)
  else:
    print((1-A-B)//2+N)
# Judge status: Wrong Answer
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
R = [0] + R[1:][::-1]
print(max(gcd(L[i-1], R[i+1]) for i in range(1, n)))
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())

s = input()

if c < d:
    if "##" in s[a:d+1]:
        print("No")
    else:
        print("Yes")
else:
    if "..." in s[b:d+1] and "##" not in s[a:d+1]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    ans = ''
    N, K, Q = map(int, input().split())
    a = [K-Q]*N
    for _ in range(Q):
        a[int(input())-1] += 1
    for i in a:
        if i > 0:
          ans += 'Yes'
        else:
          ans += 'No'
        ans += '\n'
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
from functools import reduce

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

k = int(input())

sum_of_gcd = 0
dict_of_gcd = {}
for a in range(k):
    for b in range(k):
        for c in range(k):
            if a == b == c:
                sum_of_gcd  += a + 1
            else:
                sum_of_gcd  += gcd((a + 1), (b + 1), (c +1))
print(sum_of_gcd)
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())
s_ = min(q*4, h*2, s)
d_ = min(q*8, h*4, s*2, d)
print(min(s_*n, d_*(n//2)+(n%2)*s_))
# Judge status: Accepted
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = map(int, input().split())
mod = 10 ** 9 + 7

if (x + y) % 3 != 0:
    print(0)
else:
    cnt = (x + y) // 3
    print(bigcmb(cnt, x - cnt, mod))
# Judge status: Wrong Answer
a = int(input())
list=[]
for i in range(a):
    list.append(int(input()))

if not sum(list)%10==0:
    print(sum(list))
else:
    for i in sorted(list):
        if not i%10==0:
            print(sum(list)-i)
            break
    print(0)
# Judge status: Wrong Answer
n = int(input())
s = list(input())
d = []
x = 0

for i in range(len(s)):
    if s[i] == '(':
        x += 1
    else:
        x -= 1
    d.append(x)

ans = []
x = min(d)

for i in range(max(0,(-1*x))):
    ans.append('(')

for i in s:
    ans.append(i)

for i in range(max(d[len(d)-1]-x,0)):
    ans.append(')')

a = ''.join(ans)

print(a)
# Judge status: Wrong Answer
a = input()
if ((a == "a") or (a == "b") or (a == "c") or (a == "d") or (a == "e")):
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

base = 753
ans = 1000

for i in range(len(s)-2):
    if abs(base - int(s[i:i+3])) < ans:
        ans = abs(base - int(s[i:i+3]))

print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().rstrip()

    L = 0
    R = 0
    for s in S:
        if s == "(":
            R += 1
        else:
            if R > 0:
                R -= 1
            else:
                L += 1

    ans = "".join(["(" * L, S, ")" * R])
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, R = tuple(map(int, input().split()))


if N >= 10:
    print(R)
else:
    print(R+(100 * (10 - N)))
# Judge status: Accepted
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [float("inf")] * (N + 1)
dp[1] = 0

for i in range(2, N + 1):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))
        else:
            break

print(dp[N])
# Judge status: Accepted
lst = list(map(int, input().split()))
print(sum(lst) - max(lst))
# Judge status: Accepted
s = list(input())
s.sort()
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def fact(a, mod):
    ret = 1
    for i in range(a):
        ret *= (i + 1)
        ret %= mod
    return ret


def main():
    MOD = 10**9 + 7
    N, M = list(map(int, input().split(' ')))
    if abs(N - M) > 1:
        print(0)
    elif abs(N - M) == 0:
        print((2 * fact(N, MOD) * fact(M, MOD)) % MOD)
    else:
        print((fact(N, MOD) * fact(M, MOD)) % MOD)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# ABC C-Tsundoku
n,m,k = map(int,input().split())
an = list(map(int,input().split()))
bn = list(map(int,input().split()))

suma = [0]
sumb = [0]
a = 0
b = 0
for i in an:
    a += i
    suma.append(a)
for i in bn:
    b += i
    sumb.append(b)

res = [0]
for j in range(n+1):
    if k-suma[j] < 0:
        break
    for l in range(m+1):
        if k-suma[j]-sumb[l] < 0:
            res.append(j+l-1)
            break
print(max(res))
# Judge status: Wrong Answer
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    C = input()
    if C in ['a', 'i', 'u', 'e', 'o']:
        print('vouel')
    else:
        print('consonant')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# 入力された文字列をすべてxで置き換える

# 文字列の標準入力
s = input()
sLength = len(s)
hoge = []

for i in range(sLength):
    c = s[i]
    c = "x"
    hoge.append(c)

print(''.join(map(str,hoge)))
# Judge status: Wrong Answer
def main():
    N, K = map(int, input().split(' '))
    An = list(map(int, input().split(' ')))
    
    # N, K = 4, 3
    # An = [2, 3, 1, 4]
    
    # N, K = 8, 3
    # An = [7, 3, 1, 8, 4, 6, 2, 5]
    
    
    num = len(An)
    
    print(num // (K-1))
    
    # for i in range(0, len(An), K-1):
    #     print(i)
        
    
    
main()
# Judge status: Accepted
S = input()
a = 'ACGT'
memo = []
cnt = 0
for s in S:
  if s in a:
    cnt += 1
  else:
    cnt = 0
  memo.append(cnt)
print(max(memo))
# Judge status: Accepted
K = int(input())
A,B = map(int,input().split())
ans = 'NG'
for i in range(A,B+1):
  if i%K == 0:
    ans = 'OK'
    break
print(ans)
# Judge status: Accepted
N=int(input())
S=list(map(lambda x:1*(x=="#"),input()))

L=M=S.count(0)

for i in range(N):
    if S[i]:
        M+=1
    else:
        M-=1
        L=min(L,M)
print(L)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,n):
	ans += n//i
	if n%i == 0:
		ans -= 1
print(ans)