peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = str(input())
N = len(S)
if S == S[::-1] and S[:(N-1)//2] == S[(N-1)//2-1::-1] and S[(N+3)//2-1:N] == S[-1:(N+3)//2-2:-1]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n=int(input())
ans=n%1000
print(1000-ans)
# Judge status: Wrong Answer
N=int(input())
for i in range(N,999):
  if i%111==0:
    print(i)
    break
# Judge status: Accepted
import sys
S = input()

if S[0] != "A":
    print("WA")
    sys.exit()
if S[1].isupper() or S[-1].isupper():
    print("WA")
    sys.exit()
T = S[2:len(S)-1]
if list(T).count("C") == 0 or list(T).count("C") > 1:
    print("WA")
    sys.exit()
for i in range(len(T)):
    if T[i].isupper() and T[i] != "C":
        print("WA")
        sys.exit()
print("AC")
# Judge status: Accepted
def solve():
  N = int(input())
  A = [-float('inf')]+list(map(int, input().split()))
  A.sort()
  ans = [A[-1]]
  n = A[-1]//2
  for i in range(1,N+1):
    if A[i]>n or i==N-1:
      if A[i]-n>n-A[i-1]:
        ans.append(A[i-1])
      else:
        ans.append(A[i])
      break
  return ans
print(*solve())
# Judge status: Wrong Answer
import math
N,K = map(int, input().split())

print(min(abs(N-K*int(N/K)),abs(N-K*math.ceil(N/K)),min(abs(N-(1+K*int(N/K))),abs(N-K*(1+math.ceil(N/K))),N)))
# Judge status: Wrong Answer
a,b,c = map(int,input().split(' '))
i = 1
ans = 'No'
while i < b:
    if (i*a)%b == c:
        ans = 'Yes'
        break
    i += 1
print(ans)
# Judge status: Accepted
import math
N = int(input())
x = list(map(int,input().split()))

minimum = math.inf
for i in range(101):
    stamina = 0
    for j in range(N):
        stamina += (x[j]-i)**2
    minimum = min(minimum,stamina)

print(minimum)
# Judge status: Wrong Answer
# ABC 167 C
N,M,X = map(int,input().split())
C =[]
for m in range(N):
    C.append([int(i) for i in input().split()])
C.sort(key=lambda x:x[0])

from itertools import combinations
import numpy as np


ans = 10**5 +1

for m in range(1,N+1):
    P=list(combinations(C,m))
    print(P)
    tmp =np.sum(P,axis=1)
    for t in tmp:

        if min(t[1:])>=X and ans > t[0]:
            ans = t[0]

        
          
if min(t[1:])<X:
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
n, k= map(int, input().split())
num = range(1,n)
c = set()
num = set(num)
for i in range(k):
  a = input()
  b = set(list(map(int, input().split())))
  c = b | c
num = list(num -c)
L=[str(a) for a in num]
L=" ".join(L)
print(L)
# Judge status: Accepted
s=input()
n=len(s)
k=['R','U','D']
g=['L','U','D']
for i in range(n):
  if (i+1)%2!=0 and s[i] not in k:
    print('No')
    exit()
  elif (i+1)%2==0 and s[i] not in g:
    print('No')
    exit()
print('Yes')
# Judge status: Accepted
a, b = [int(x) for x in input().split()]

if a >= 13:
    print(b)
elif a <= 12 and a >= 6:
    print(b // 2)
else:
    print(0)
# Judge status: Accepted
S = input()
k = 0
l = len(S)
for i in S:
  if i == 'S':
    k += 1
  else:
    if k > 0:
      k -= 1
      l -= 2
print(l)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    if n == 6:
        print(1)
    else:
        print(ceil(n / 5.5))
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""
# Judge status: Accepted
import math

n,m=map(int,input().split())
mod=10**9+7
ans=0

if abs(n-m)>=2:
    print("0")
elif abs(n-m)==1:
    print(math.factorial(n)*math.factorial(m)%mod)
else:
    print((math.factorial(n)*math.factorial(m)*2)%mod)
# Judge status: Accepted
import numpy as np 
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
    a,b=map(int,input().split())
    w+=[a]
    v+=[b]
DP=np.zeros(W+1,dtype=int)
for i in range(N):
    DP[w[i]:]=np.maximum(DP[:-w[i]]+v[i],DP[w[i]:])
print(max(DP))
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
    s = input()
    if len(s) == 1:
        if s[0] == 's':
            print('es')
        else:
            print(s+'s')
    else:
        if s[-1] == 's':
            r = s + 'es'
            print(r)
        else:
            r = s + 's'
            print(r)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
h=list(map(int,input().split()))
count=0
ma=0
for i in range(1,n):
  if h[i]<=h[i-1]:
    count+=1
  elif count>ma:
    ma=count
    count=0
if count>ma:
  ma=count
print(ma)
# Judge status: Accepted
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    s = sum(A)
    if s > N:
        print(-1)
    else:
        print(N-s)

main()
# Judge status: Accepted
n = int(input())
a,b= map(int, input().split())

i = 0

while (i <= 1000):
    i += n
    if i >= a:
        break

print("OK") if i<=b else print("NG")
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
a0 = len([i for i in range(N) if a[i] % 2 != 0])
if len([i for i in range(N) if a[i] % 2 == 0 and a[i] != 4]) > 0:
    a0 += 1
a2 = len([i for i in range(N) if a[i] % 4 == 0])
if a0 <= a2 + 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
*p, = map(int, input().split())
p = p+[-1]
ans = 0
for i in range(n):
    if p[i] == (i+1):
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]
print(ans)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
S =[]
for i in range(N):
    S.append(str(input()))

B =[]
for i in S:
    S1 =list(Counter(i).items())
    #S1 =sorted(S1, reverse = False)
    B.append(S1)

cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        if B[i] == B[j]:
            cnt += 1
print(cnt)
# Judge status: Accepted
import math
x = int(input())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
if x == 1:
  print(int(360 / x))
elif x == 45:
  print(int(360 / x))
elif x == 90:
  print(int(360 / x))
else:
  z = lcm(x, 360)
  print(int(z / x))
# Judge status: Wrong Answer
N = int(input())
S = input()

if (N % 2 == 0):
    c = int(N / 2)

    n = 0
    for x in range(c):
        if S[x] == S[x + c]:
            n += 1 

    if n == c:
        print('YES')  
    else: 
        print('NO')
        
else:
    print('NO')
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
K = int(input())

for num in range(K):
  if (A >= B) :
    B = 2*B
  elif B >= C:
    C = 2*C
  else:
    A = A *2

if A<B and B < C and A < C:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = input()
counter_A = 0
counter_Z = 0
for i in s:
    if i == 'A':
        break
    else:
        counter_A += 1
for i in s[::-1]:
    if i == 'Z':
        break
    else:
        counter_Z += 1
print(len(s) - counter_A - counter_Z)
# Judge status: Accepted
s = input()

for i in range(len(s)):
    if s[i] == "?":
        print("D",end="")
    else:
        print(s[i],end="")
# Judge status: Accepted
a = int(input())
print(a*800-(a//15)*200)
# Judge status: Accepted
def main():
    a, b, c = map(int, input().split())
    k = int(input())
    print(max(a, b, c)*(2**k-1)+a+b+c)

if __name__ == "__main__":
    main()
# Judge status: Accepted
A, B = map(int, input().split())

ans = 0
for i in range(A,B+1):
    s = str(i)
    N = len(s)-1
    l = (len(s) // 2) + 1
    for j in range(l):
        if s[j] == s[N-j]:
            continue
        else:
            break
    else:
        ans += 1

print(ans)
# Judge status: Wrong Answer
import heapq

n, m = map(int, input().split())
list_score = list(map(int, input().split()))
list_kard = [list(map(int, input().split(" "))) for i in range(m)]

list_kard.sort(key=lambda x: x[1], reverse=True)
heapq.heapify(list_score)

for i in range(m):
    k = list_kard[i]
    for _ in range(k[0]):
        if list_score[0] < k[1]:
            heapq.heappop(list_score)
            heapq.heappush(list_score, k[1])
        else:
            print(sum(list_score))
            exit()
# Judge status: Wrong Answer
a,b = map(int,input().split())
x = a+b
if (x % 2 == 0):
  print(x/2)
else:
  print(x/2 + 1)
# Judge status: Accepted
import math
a,b,x = map(int,input().split())

ans = 0

sw = 2*x/(a**3)
sw_c = abs(math.atan(sw))

ans = abs(math.atan(2/a*(b-x/(a**2))))
ans_1 = abs(math.atan(a*b**2/(2*x)))

if(ans < sw_c):
    print(math.degrees(ans))
else:
    print(math.degrees(ans_1))

'''
print("------")
print(math.degrees(ans))
print(math.degrees(sw_c))
print(math.degrees(ans_1))
'''
# Judge status: Accepted
n,x,y = map(int,input().split())
k = [0]*(n-1) #k-1に対応
for i in range(1,n):
    for j in range(i+1,n+1):
        s = min(abs(j-i),abs(j-y)+abs(i-x)+1)
        k[s-1] += 1
for i in k:
    print(i)
# Judge status: Wrong Answer
L = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
n = L.index(input())
print( L[(n+1)%7] )
# Judge status: Wrong Answer
th,ta,ah,aa = map(int,input().split())

at = ah / ta
tt = th / aa

if at >= tt:
  print("No")
elif at <= tt:
  print("Yes")
# Judge status: Accepted
x,y,z=map(int,input().split())
x-=z
print((x-x%(y+z))//(y+z))
# Judge status: Accepted
X=int(input())
a=X//500
b=X%500
c=b//5
print(a*1000+c*5)
# Judge status: Wrong Answer

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

def func(t):
    return int(t)

syo=N//B
amari=N%B

if syo==0:
    x=amari
    print(func(A*x/B)-A*func(x/B))
else:
    x1=syo*B-1
    x2=N
    ans1=func(A*x1/B)-A*func(x1/B)
    ans2=func(A*x2/B)-A*func(x2/B)
    print(max(ans1,ans2))
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))

already = [False for i in range(N)]
already[0] = True
tel = [0]

while True:
    tmp = A[tel[-1]]
    tel.append(tmp)
    
    if already[tmp]:
        tel.pop()
        break
        
    already[tmp] = True

for i in range(len(tel)):
    if tel[i] == tmp:
        s = i
        break

ans = (K - s) % (len(tel) - s)
print(tel[ans + s] + 1)
# Judge status: Accepted
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(1,q+1):
    if i != L:
        print(i)
# Judge status: Accepted
a = list(map(int, input().split()))
a.sort()
d = a[2] * 2 - a[0] - a[1]
if d % 2 == 1:
  d += 4
print(d//2)
# Judge status: Wrong Answer
x = int(input())

print((x+1)*x/2)
# Judge status: Wrong Answer
n = int(input())
X = list(map(int,input().split()))
h = int(n/2)
for i in range(1,n+1):
  if i <= h:
    print(X[h])
  else:
    print(X[h-1])
# Judge status: Wrong Answer
import string

S = list(map(str, input()))
s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

ans = 0
for i in range(N):
    d = min(A[i], B[i])
    ans += d
    A[i] -= d
    B[i] -= d
    d = min(A[i+1], B[i])
    ans += d
    A[i+1] -= d
    
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
num = C-(A-B)
print(num if num > 0 else '0')
# Judge status: Accepted
n = int(input())
cnt = 0

for i in range(1, n+1):
    if len(str(i)) % 2 == 1:
        cnt += 1
print(cnt)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
result=[a*c,a*d,b*c,b*d]
print(max(result))
# Judge status: Accepted
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
n=int(input())
ans = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if i==j==k:
              ans+=gcd(i+1,j+1,k+1)
            elif i<j<k:
              ans+=6*(gcd(i+1,j+1,k+1))  
            else:
              ans+=3*(gcd(i+1,j+1,k+1))
print(ans)
# Judge status: Wrong Answer
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

text = input()
H = int(get(text,2)[0])
A = int(get(text,2)[1])

print(H//A+1)
# Judge status: Wrong Answer
a,b=map(int,input().split())
print(a*b)
# Judge status: Accepted
N,K = map(int,input().split())
S = list(input())
S[K-1] = S[K-1].lower()
print(''.join(S))
# Judge status: Accepted
a, b, c, d = map(int, input().split())
while a > 0 and c > 0:
  c -= b
  if c <= 0:
    print("Yes")
    break
  a -= d
  if a <= 0:
    print("No")
    break
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
a = [0] + a
b = [0 for n in range(N + 1)]

for n in range(N):
    m = N - n
    q = N // m
    r = 0
    for q0 in range(2, q + 1):
        r += b[m * q0] % 2
    b[m] = (a[m] - r) % 2
print(sum(b))
ans = []
for n in range(N):
    m = N - n
    if b[m] == 1:
        ans.append(m)
print(*ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
 
ans = 0
 
for i in range(k, n+2):
    ans += (i*(n - i + 1) + 1) %(10**9+7)
 
 
    
print(ans)
# Judge status: Accepted
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(W + 1):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])
# Judge status: Accepted
x,y = map(int, input().split())
flag = 0
for i in range(x+1):
  if (2 * i + 4 * (x - i)) == y:
    print("Yes")
    flag = 1

if flag == 0:
  print("No")
# Judge status: Wrong Answer
n,k=map(int,input().split())
s=list(input())
s[k-1]=chr(ord(s[k-1])+26)
print(''.join(s))
# Judge status: Accepted
l = list(map(int, input().split()))
l.sort()
t = l[2]-l[0] + l[2]-l[1]
if t%2 == 0:
    print(t//2)
else:
    print((t+3)//2)
# Judge status: Wrong Answer
n = int(input())
if n>1:
  powers = {n}
else:
  powers = set()
for i in range(2,int(n**0.5)):
  for j in range(1,41):
    if i**j>n**0.5:
      break
    else:
      powers.add(i**j)
power = list(powers)
power.sort()
counter = 0
for s in power:
  if n%s==0:
    n = n/s
    counter += 1
  if n<s:
    break
print(counter)
# Judge status: Accepted
N, K = map(int, input().split())

L = []
for i in range(10**5+1):
    L.append(0)

for n in range(N):
    a, b = map(int, input().split())
    L[a] += b

a = 0
while K > 0:
    a += 1
    K -= L[a]
    
print(a)
# Judge status: Accepted
import math

ceil = math.ceil

def main():
    N = int(input())
    ans = [0]*N
    for i in range(N-1):
        C, S, F = map(int, input().split())
        ans[i] = S + C
        for j in range(i):
            nxt = ceil((ans[j]-S)/F)
            ans[j] = max(0, nxt)*F + S + C
    
    for a in ans:
        print(a)

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

if (B-A)%2 == 0:
	print((B-A)//2)
else:
	print((B-A)//2 + min(A,N-B+1))
# Judge status: Accepted
X = int(input())

gohyaku = X//500
goen = (X - gohyaku*500)//5

ans = gohyaku * 1000 + goen * 5
print(ans)
# Judge status: Accepted
import itertools
import math
N = int(input())
x_y = {i : list(map(int, input().split())) for i in range(N)}
P = list(itertools.permutations(range(N)))
tmp = 0
for p in P:
    for n in range(N-1):
        #print(tmp)
        tmp += math.sqrt((x_y[p[n]][0] - x_y[p[n+1]][0])**2 + (x_y[p[n]][1] - x_y[p[n+1]][1])**2)

print(tmp/len(P))
# Judge status: Wrong Answer
from itertools import groupby
inputs = open(0).readlines()

n = int(inputs[0])
*D, = map(int, inputs[1].split())
D.sort()
mod = 998244353

keys, nodes = [], [] 
for k, g in groupby(D):
    keys.append(k)
    nodes.append(len(list(g)))

if nodes[0] == 1 and all(i == k for i, k in enumerate(keys)):
    ans = 1
    for n0, n1 in zip(nodes, nodes[1:]):
        ans = ans * pow(n0, n1, mod) % mod
    print(ans)
else:
    print(0)
# Judge status: Accepted
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i  <a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()
# Judge status: Accepted
n,d = (int(i) for i in input().split())
ans = (n-1)//(2*d+1) + 1
print(ans)
# Judge status: Wrong Answer
xkd = list(map(int,input().split()))
xkd[0] = abs(xkd[0])
x = xkd[0] // xkd[2]
xkd[0] -= xkd[2] * x
xkd[1] -= x
if xkd[1] < 1:
  xkd[0] += abs(xkd[1]) * xkd[2]
ans = xkd[0]
if xkd[1] % 2 != 0:
    ans -= xkd[2]
    if abs(ans) > abs(xkd[0]) + xkd[2]:
        ans += xkd[2] * 2
print(abs(ans))
# Judge status: Accepted
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)
d=deque(b)
ans=0
tmp=0
flag1=False
flag2=False
while d:
    if d[0]==tmp and flag1==False:
        flag1=True
        d.popleft()
        h1=tmp
        tmp=0
    elif flag1 and d[0]==tmp:
        h2=tmp
        ans=h1*h2
        break
    elif d[0]!=tmp:
        tmp=d.popleft()
print(ans)
# Judge status: Wrong Answer
import math

r = input("半径を入力してください")
r1 = int(r)
A = math.pi*r1**2
ratio = A/math.pi
print('{:.00f}'.format(ratio))
# Judge status: Accepted
a, b, c = map(int, input().split())
if c > a + b:
    left = 4*a*b
    right = c**2 + (a+b)**2 - 2*c*(a+b)
    if right > left:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
sx,sy,tx,ty=map(int,input().split())
x,y=tx-sx,ty-sy
print('R'*x+'U'*y+'L'*x+'D'*(y+1)+'R'*(x+1)+'U'*(y+1)+'LU'+'L'*(x+1)+'D'*(y+1)+'R')
# Judge status: Accepted
N = int(input())

def get_divisor_num(n):
    cnt = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            cnt += 1
            if n // i != i:
                cnt += 1

    return cnt

cnt = 0
for i in range(1, N+1, 2):
    if get_divisor_num(i) == 8:
        cnt += 1

print(cnt)
# Judge status: Accepted
n = int(input())
i = int(n / 111)
if n % 111 != 0:
    i += 1
print(i * 111)
# Judge status: Wrong Answer
n = int(input())
flag= True
count = 0
for i in range(n):
  a,b = list(map(int, input().split()))
  if a==b:
    count += 1
  else:
    count= 0
  if count==3:
    flag = True
if flag:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
from itertools import zip_longest
print('Yes' if all(travelable(p,q) for p,q in zip_longest(P[:N],P[1:])) else 'No')
# Judge status: Accepted
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    # str_list = [map(int, input().split())]
    # if str_list.count(5) == 2 and str_list.count(7) == 1:
    #     print('YES')
    # else:
    #     print('NO')
    str_list = list(map(int, input().split()))
    if sum(str_list) == 17:
        print('YES')
    else:
        print('NO')
# Judge status: Accepted
import sys
input = sys.stdin.readline

a, b, m = [int(w) for w in input().split()]
a_li = [int(w) for w in input().split()]
b_li = [int(w) for w in input().split()]

ans = min(a_li) + min(b_li)

for i in range(m):
    x, y, c = [int(w) for w in input().split()]
    t = a_li[x - 1] + b_li[y - 1] - c
    ans = min(ans, t)

print(ans)
# Judge status: Accepted
n = int(input())
d = {}
for i in range(n):
    a,b = input().split()
    if a in d:
        d[a].append([int(b),i+1])
    else:
        d.setdefault(a,[[int(b),i+1]])
for k in sorted(d.keys()):
    d[k].sort(reverse=True)
    for i in d[k]:
        print(i[1])
# Judge status: Accepted

st1 = input()
st2 = input()
li = []
count = 0

k = 0

for i in range(len(st1)-len(st2)+1):
    for s2 in st2:
        if s2 in st1[i+k]:
            count += 1
        k += 1
    li.append(count)
    count = 0
    k = 0

print(len(st2) - max(li))
# Judge status: Accepted
N,M = map(int,input().split())
I = set()
n = set()
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        I.add(b)
    if b == 1:
        I.add(a)
    if a == N:
        n.add(b)
    if b == N:
        n.add(a)
if  I & n == set():
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
# Judge status: Accepted
N = int(input())
S = input()
nS = S
for i in range(50):
    nS = nS.replace("()", "")
r = nS.count(")")
l = nS.count("(")
print("(" * r + S + ")" * l)
# Judge status: Accepted
h, a = map(int,input().split())
ans = h//a
if h%a!=0:
    ans+=1
print(ans)
# Judge status: Wrong Answer
L, R = map(int, input().split())
L %= 2019
R = R % 2019 if R - L < 2019 else R % 2019 + 2019
print(L, R)
ans = float('inf')
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j) % 2019)
print(ans)
# Judge status: Accepted
s = input()
ans = []
for key in s:
    if key=='B':
        if ans:
            ans.pop()
    else:
        ans.append(key)
print(''.join(ans))
# Judge status: Accepted
import sys
from collections import defaultdict

input = lambda: sys.stdin.readline().rstrip()

N = int(input())

d = defaultdict(int)

for i in range(N):
    word = input()
    d[word] += 1

M = int(input())

for i in range(M):
    word = input()
    d[word] -= 1

sorted_d = sorted(d.items(), key=lambda x:x[1], reverse=True)

if sorted_d[0][1] <= 0:
    print(0)
else:
    print(sorted_d[0][1])
# Judge status: Accepted
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

if a[0] - b[0] == a[1] - b[1] == a[2] - b[2]:
    if  b[0] - c[0] == b[1] - c[1] == b[2] - c[2]:
        print("Yes")
        exit()
    else:
        pass

print("No")
# Judge status: Wrong Answer
n = int, input()

for a in range(1, 10):
    for b in range(1, 10):
        if a * b == n:
            print("Yes")
            break
        else:
            print("No")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

S = sum(A)

from itertools import accumulate
C = [0]+A
C = list(accumulate(C))
ans = 10**18
for i in range(1, n):
    s = C[i]
    a = S-s
    ans = min(ans, abs(s-a))
print(ans)
# Judge status: Accepted
def main():
  N,K,S=map(int,input().split())
  MAX=10**9
  ans=[]
  if S!=MAX:
    for i in range(K):
      ans.append(str(S))
    for i in range(K,N):
      ans.append(str(MAX))
  else:
    for i in range(K):
      ans.append(str(S))
    for i in range(K,N):
      ans.append(str(MAX-1))
  print(" ".join(ans))
main()
# Judge status: Wrong Answer
import collections

def main():
    x = input().replace("TS", "T S").split()
    ans = 0
    for i in x:
        s = i.count("S")
        t = i.count("T")
        ans += abs(s-t)
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=[A[0]] #累積和
C=[0]*N #ここで切った時の差分
for i in range(1,N):
  B.append(B[-1]+A[i])
  
for j in range(N):
  C[j]=abs((B[-1]-B[j])-B[j])

#print(C)
print(min(C))
# Judge status: Wrong Answer
import sys 
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

N = 101

for i in range(N):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1

    a2 = c21 - b1
    a3 = c31 - b1

    if c22 == a2+b2 and c23 == a2 + b3 and c33 == a3+b3:
        print("Yes")
        sys.exit()

print("No")
# Judge status: Accepted
def f(N,K):
    if N<K:
        return 1
    return f(N//K,K)+1

N,K=map(int,input().split())
print(f(N,K))
# Judge status: Accepted
import math
N=int(input())

print(math.factorial(N)%(10**9+7))
# Judge status: Wrong Answer
A, B, C, K = map(int, input().split())

t = K - A
if t <= 0 or t <= B:
    print(A)
else:
    print(A - (t - B))
# Judge status: Wrong Answer
import sys

n, h = map(int, input().split())
a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

b.sort(reverse=True)
max_a = max(a)

b = [x for x in b if x > max_a]

for i, x in enumerate(b):
    h -= x
    if h <= 0:
        print(i + 1)
        sys.exit()

ans = int(i + 1 + (h + 0.5) // max_a)

print(ans)