peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
s = input()
qn = int(input())
left = ''
right = s
for i in range(qn):
    q = input()
    if q[0] == '1':
        left, right = right, left
    else:
        _, f, c = q.split()
        if f == '1':
            left += c
        else:
            right += c
print(left[::-1] + right)
# Judge status: Wrong Answer
s = input()
if ('N' in s and 'S' in s) or ('S' in s and 'W' in s):
    print('Yes') 
else:
    print('No')
# Judge status: Wrong Answer
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
H  = nl()

current = 0
ans = 0
for i in range(1,N-1):
    if H[i-1] >= H[i]:
       current +=1
    else:
        if current > ans: 
            ans = current
        currrent = 0

if current > ans:
    ans = current
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
n = int(input())
s = [int(input()) for _ in range(n)]
s_5 = [s[i] for i in range(n) if s[i] % 10 != 0]
# maxはsumから5の倍数ならそのまま、10の倍数ならminの5の倍数をひく
sum_s = sum(s)
s_5.sort()
#print(s_5)
if sum_s % 10 != 0:
    print(sum_s)
else:
    if len(s_5) == 0:
        print(0)
    else: print(sum_s - s_5[0])
# Judge status: Accepted
l , r, d = map(int, input().split())
a = [i for i in range(l, r+1)]
count = 0
for i in a:
    if i % d == 0:
        count += 1
print(count)
# Judge status: Accepted
N, K = map(int, input().split())
ab = sorted([[int(i) for i in input().split()] for j in range(N)])

count = 0
for i in range(N):
    count += ab[i][1]
    if count >= K:
        print(ab[i][0])
        break
# Judge status: Accepted
N, *AB = map(int, open(0).read().split())

A = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[0])
B = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[1])

if N % 2 == 1:
    L = A[N // 2][0]
    R = B[N // 2][1]
else:
    L = A[N // 2 - 1][0] + A[N // 2][0]
    R = B[N // 2 - 1][1] + B[N // 2][1]

print(R - L + 1)
# Judge status: Wrong Answer
s = list(input())

if "C" in s[2:-2] and s[0]=="A":
    del s[s.index("C")]
    del s[0]
else:
    print("WA")
    exit()
    
for i in range(len(s)):
    if s[i].islower():
        continue
    else:
        print("WA")
        exit()
print("AC")
# Judge status: Wrong Answer
import sys

k = int(input())
a,b = map(int,input().split())

if k==1:
    print('Ok')      
    sys.exit() 

wk = (a//k)+1
while wk <=b:
    if wk*k<=b:
        print('Ok')      
        sys.exit()   
    else:
        wk+=1
print('NG')
# Judge status: Wrong Answer
n=int(input())
l=[['a1']]+[[] for _ in range(9)]
for i in range(9):
  for b in l[i]:
    t=b[-1]
    for p in range(int(t)):
      l[i+1].append(b[:-1]+chr(97+p)+t)
    l[i+1].append(b[:-1]+chr(97+int(t))+str(int(t)+1))
for i in l[n-1]:
  print(i[:-1])
# Judge status: Accepted
s=input()
t=input()
ans=0
if s == t:
  print('Yes')
else:
  for i in range(len(s)):
    s = s[-1] + s[0:-1]
    if s == t:
      ans += 1
  
  if ans == 0:
    print('No')
  else:
    print('Yes')
# Judge status: Wrong Answer
x=list(map(int,input().split()))
x.sort()
if x[0]+x[1] == x[2]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
A,B = map(int,input().split())
x = -1
for i in range(1,20000):
    if int(i*1.08)-i==A and int(i*1.1)-i==B:
        x = i
        break
print(x)
# Judge status: Wrong Answer
s = input()
qn = int(input())
right = []
left = [s]
for i in range(qn):
    q = input()
    if q[0] == '1':
        right, left = left, right
    else:
        _, f, c = q.split()
        if f == '1':
            left.append(c)
        else:
            right.append(c)
print(''.join(left[::-1]) + ''.join(right))
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0
for char in S:
    if char == 'a' and a+b < A+B:
        print("Yes")
        a += 1
    elif char == 'b' and a+b < A+B and b < B:
        print("Yes")
        b += 1
    else:
        print("No")
# Judge status: Accepted
n = int(input().strip())
a = map(int, input().strip().split())

x = [0] * n
for i in a:
    x[i-1] += 1

print('\n'.join(map(str, x)))
# Judge status: Wrong Answer
xs = input().split()

print("A"+xs[2][0]+"C")
# Judge status: Wrong Answer
n, a, b = list(map(int, input().split(' ')))

M = 10**9 + 7
result = pow(2, n, M)

def comb(n, r):
    x = 1
    y = 1

    for i in range(r):
        x *= (n - i)
        y *= (i + 1)
        x %= M
        y %= M

    x %= M
    y %= M
    return x // y

print(result - comb(n, a) - comb(n, b))
# Judge status: Accepted
n=int(input())
MOD=10**9+7
ans=pow(10,n,MOD)-2*pow(9,n,MOD)+pow(8,n,MOD)
print(ans%MOD)
# Judge status: Accepted
n = int(input())

total = 0

for i in range(1, n + 1):
  m = n // i
  total += i * m * (m + 1) // 2

print(total)
# Judge status: Accepted
import collections
N=int(input())
SS=[]
for a in range(N):
    S=input()
    SS.append(S)
c = collections.Counter(SS)
print(len(c))
# Judge status: Wrong Answer
h,a = map(int,input().split())
print(h // a + 1)
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    S=list(input())
    ans=0
    for i in range(100):
        ans=max(ans,len(set(S[:i])&set(S[i:])))
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
S=input()
T=input()

lt=len(T)
ls=len(S)
if ls<lt:f=0
else:
 for i in range(ls-lt,-1,-1):
  f=1
  for s,t in zip(S[i:i+lt],T):
    if s=='?' or s==t: continue
    f=0
  if f:break
print((S[0:i]+T+S[i+lt:ls]).replace('?','a') if f else 'UNRESTORABLE')
# Judge status: Accepted
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))

MOD = 998244353

p = defaultdict(int)
for d in D:
    p[d] += 1

if p[0] == 1 and D[0] == 0:
    ans = 1
    for i in range(max(D)):
        ans *= pow(p[i], p[i + 1], mod=MOD)
        ans %= MOD
        if ans == 0:
            break

    print(ans)

else:
    print(0)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
    sys.exit(0)

ans = a
k = k - a

if k <= b:
    print(ans)
    sys.exit(0)

k = k - b
ans = ans - k
print(ans)
# Judge status: Wrong Answer
n=int(input())

now=1
while True:
  if now>n:
    break
  now*=2
print(now)
# Judge status: Wrong Answer
A,B,X = map(int,input().split())
if A <= X and X <= B:
	print("YES")
else:
	print("N0")
# Judge status: Wrong Answer
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%2==0:
    t+=1
  if i%4==0:
    f+=1
if t+f>=n:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
S = input ()
T = input ()
X = 'No'
for i in range (len(S)):
  if T == S[i:]+S[:i]:
    X = 'Yes'
    break
print (X)
# Judge status: Wrong Answer
n=int(input())
if(n==0):
  print("YES")
elif(n%9==0):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
hand = {"r" : p, "s" : r, "p" : s}
ans = 0
for i in range(n):
  temp= i-k
  if temp >=0 and t[i]==t[temp]:
    t[i]=" "
  else:
    ans+=hand[t[i]]
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N = int(input())
if N % 9 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
wt = int(input())
w = [1]
for i in range(7):
    w.append(6 ** (i + 1))
for i in range(5):
    w.append(9 ** (i + 1))
n = len(w)
dp = [[float("inf") for i in range(wt + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(wt + 1):
        if j >= w[i]:
            dp[i + 1][j] = min(dp[i + 1][j - w[i]] + 1, dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[n][wt])
# Judge status: Accepted
a,b=map(int,input().split())
if a>=13:
  print(b)
elif a<=5:
  print('0')
else:
  print(b//2)
# Judge status: Wrong Answer
n, m, k = map(int, input().split())

ans = False
for i in range(1, n + 1):
    if ans:
        break
    for j in range(1, m + 1):
        if i * (m - j) + (n - i) * j == k:
            ans = True
            break

if ans:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()

n = len(s)
if s == s[::-1]:
    t = s[:(n-1)//2]
    if t == t[::-1]:
        u = s[(n+3)//2-1:]
        if u == u[::-1]:
            print('Yes')
            exit()

print('No')
# Judge status: Accepted
N = int(input())
Nlist = [[] for _ in range(N)]
for i in range(N):
    C, P = input().split()
    P = int(P)
    Nlist[i].append(i+1)
    Nlist[i].append(C)
    Nlist[i].append(P)

Nlist.sort(key=lambda x: x[1])
Nlist.sort(key=lambda x: x[2],reverse=True)
Nlist.sort(key=lambda x: x[1])
for i in range(N):
    print(Nlist[i][0])
# Judge status: Wrong Answer
N = int(input())
s = str(input())
t = str(input())

if s == t:
    print(N)
else:
    for i in range(N,0,-1):
        #print(s[N-i:],t[0:i],)
        if s[N-i:]==t[0:i]:
            print(2*N-i)
            break
# Judge status: Accepted
A, B, C = map(int, input().split())
if A <= C <= B:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import math
a, b, x = map(int, input().split())
full = a * a * b
if x > full / 2:
    x = full - x
    tan_x = 2.0 * x / (a*a) / a
    print(math.atan(tan_x) / math.pi * 180.0)
else:
    tan_x = 2.0 * x / (a*b) / b
    print(90-math.atan(tan_x) / math.pi * 180.0)
# Judge status: Accepted
s=input()
all_different=True
for i in range(len(s)-1):
  for j in range(i+1,len(s)):
    if s[i]==s[j]:
      all_different=False
  if not all_different:
     break
if all_different:
  print("yes")
else:
  print("no")
# Judge status: Accepted
s = input()

l = []
count_a=0
count_b=0
for i in s:
  if i not in l:
    l.append(i)
    count_a+=1
  else: 
    count_b+=1
if count_a == 2 and count_b == 2:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
D =int(input())
print('Christmas'+'eve'*(25-D))
# Judge status: Wrong Answer
S = input()

print("X"*len(S))
# Judge status: Wrong Answer

def Multiple9(x):
    if x < 10:
        return x
    c = 0
    while x > 0:
        c += x%10
        x //= 10
    return c

#main
n = int(input())
while n > 10:
    n = Multiple9(n)

if(n == 9):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
l=[input() for i in range(n)]
from collections import Counter as co
k=co(l).most_common()
d=k[0][1]
for a,s in k:
  if s!=d:break
  else:
      print(a)
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for i in range(n)]

a.sort()
tmp = sum(a)
i = 0
while tmp%10==0 and i<n:
    tmp -= a[i]
    i += 1

print(tmp)
# Judge status: Accepted
n=list(input())
s=0
for i in range(len(n)):
    s+=int(n[i])
if s%9==0:print('Yes')
else:print('No')
# Judge status: Wrong Answer
s=input()

l=[]

for i in s:
  l.append(i)
new_l = l[::-1]

count=0
for a,b in zip(l,new_l):
  if a != b:
    count+=1
print(count)
# Judge status: Accepted
import statistics
n = int( input() )
a = []
b = []
for _ in range( n ):
    a_i, b_i = map( int, input().split() )
    a.append( a_i )
    b.append( b_i )

m_a = statistics.median( a )
m_b = statistics.median( b )

if n % 2 == 1:
    print( int( m_b - m_a + 1 ) )
else:
    print( int( ( m_b - m_a ) * 2 + 1 ) )
# Judge status: Accepted
n, m = map(int, input().split())
a_list = map(int, input().split())
for a in a_list:
    n -= a

if n < 0:
    print("-1")
else:
    print(n)
# Judge status: Wrong Answer
s = input()

import re
output ="NO"
s = re.sub('dreameraser', '', s)
s = re.sub('dreamerase', '', s)
s = re.sub('eraser', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
s = re.sub('erase', '', s)
if s == "":
    output = "YES"
print(output)
# Judge status: Wrong Answer
k, x = map(int, input().split())
a = []
for i in range(-(k - 1), k - 1):
  a.append(x + i)
print(sorted(a))
# Judge status: Wrong Answer
n, m = map(int, input().split())

if n == 1 and m == 1:
    print("1")
elif n == 1 and m != 1:
    print(m - 2)
else:
    print((n - 2) * (m - 2))
# Judge status: Accepted
N = int(input())
As = list(map(int, input().split()))

num = 0
for a in As:
  num ^= a

ans = [str(num ^ a) for a in As]

print(" ".join(ans))
# Judge status: Accepted
mass = input()
s1 = int(mass[0])
s2 = int(mass[1])
s3 = int(mass[2])
c = 0
if s1 == 1:
  c += 1
if s2 == 1:
  c += 1
if s3 == 1:
  c += 1
print(c)
# Judge status: Accepted
x=int(input())

num=x//100
print(1 if num*5+100*num>=x else 0)
# Judge status: Wrong Answer
a = int()
b = int()
wa_list = []
n = int(input())
for a in range(n+1):
		b = n - a
		wa_list.append(sum(map(int, list(str(a)))) + sum(map(int, list(str(b)))))
print(min(wa_list))
# Judge status: Accepted
n = int(input())

ans = 0
for i in range(1,10) :
  for j in range(i,10) :
    c_a = 0
    c_b = 0
    for k in range(1,n+1) :
      kl = len(str(k))
      if k//(10**(kl-1)) == i and k%10 == j :
        c_a += 1
      if k//(10**(kl-1)) == j and k%10 == i :
        c_b += 1
    if i == j :
      ans += c_a*c_b
    else :
      ans += c_a*c_b*2
      
print(ans)
# Judge status: Accepted
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if (x+y)>t or (x+y)%2 != t%2:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
x=input()
mini=1e+5
for i in range(len(x)-2):
    mini=min(mini,abs(753-int(x[i:i+3])))
print(mini)
# Judge status: Accepted
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    if N % 2 == 0:
        ans = N // 10
        d = 50
        while N // d > 0:
            ans += N // d
            d *= 5
        print(ans)
    else:
        print(0)
# Judge status: Accepted
n, m = list(map(int, input().split()))
ans = 1
if n==m:
    for i in range(1, n+1):
        ans *= i
        ans %= 10**9+7
    print((ans**2*2)%(10**9+7))
elif abs(n-m)==1:
    for i in range(1, n+1):
        ans *= i
        ans %= 10**9+7
    for i in range(1, m+1):
        ans *= i
        ans %= 10**9+7
    print(ans%(10**9+7))
else:
    print(0)
# Judge status: Wrong Answer
N = int(input())
nums = list(map(int, input().split()))
totalNode = 1
totalLeaf = 1
fail = False
for i in range(N + 1):
	totalLeaf = (totalLeaf-nums[i])*2
	if (totalLeaf < 0):
		fail = True
		break
	totalNode += totalLeaf
  
if (fail):
	print(-1)
else:
	print(totalNode)
# Judge status: Accepted
s = list(input())
if len(set(s)) == 2 and sorted(s)[2] != sorted(s)[1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(m)]
ans =[0] * (n + 1)

for l, r in LR:
  ans[l - 1] += 1
  ans[r] -= 1
  
accu =[0] * (n + 1)
for i in range(n):
  accu[i + 1] += ans[i] + accu[i]
  
ans = accu.count(m)

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

#count num
count = 0
for i in range(N):
    if A[i] * 4 * M >= sum(A): #A[i] = sum(A)/(4*M)
        count +=1

#Check availavle N
if count >= M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
l = ["Sunny", "Cloudy", "Rainy", "Sunny"]
print(l[l.index(input()) + 1])
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, L = map(int,input().split())
A = [0] * N
B = [0] * N
for i in range(N):
  A[i] = L + i

ans = 0
diff = 10 ** 10
for j in range(N):
  B[j] = sum(A) - A[j]
  diff = min(diff, abs(sum(A)-B[j]))

if sum(A) >= 0:
  print(sum(A)-diff)
else:
  print(sum(A)+diff)
# Judge status: Wrong Answer
def main():
    H, W = map( int, input().split())
    if H%2 == 0 or W%2 == 0:
        print(H*W//2)
    else:
        print(H*W//2+1)
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, T = map(int,input().split())
cnt = T+1
jdg = False
for _ in range(N):
    c, t = map(int,input().split())
    if t <= T: 
        cnt = min(cnt,c)
        jdg = True
        
if jdg:
    print(cnt)
else:
    print("TLE")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = 0
for i in range(N):
    ans += A[2*i+1]
print(ans)
# Judge status: Accepted
import math
from decimal import Decimal

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

s = min(a, b, c, d, e)

print(math.ceil(Decimal(n)/Decimal(s) + 4))
# Judge status: Accepted
s=input()
if s=='Sunny':
    print('Cloudy')
elif s=='Cloudy':
    print('Rainy')
else:
    print('Sunny')
# Judge status: Accepted
S = input()
T = input()
if S==T[::-1]:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
from fractions import gcd
from math import sqrt
a,s=map(int,input().split())
f=gcd(a,s)
ans=1
if f<=3:print(1+(f!=1));exit()
for i in range(2,int(sqrt(f))+1):

  if f%i==0:
    ans+=1
    while f%i==0:f//=i
print(ans+(f!=1))
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))
L.sort()
length = sum(L[:N-1])
if L[-1] < length:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s=str(input())
ans="Heisei"
if int(s[:4])<2019:
    ans="TBD"
    
elif int(s[:4])==2019:
    if int(s[6:7])<=4:
        if int(s[8:])<30:
            ans="TBD"
print(ans)
# Judge status: Wrong Answer
S = input()
slen = len(S)
count = 0
for i in range(0,slen, 2):
    if ( i == slen-1):
        inv = 0 if i == 0 else round(int(S), -1 * (slen-1))
        count = count + (int(S)-inv) + 1
        # print(i, (int(S)-inv) + 1)
    else:
        count = count + 10 ** (i+1) - 10 ** (i)
        # print(i, 10 ** (i+1) - 1)
print(count)
# Judge status: Accepted
h, a = map(int, input().split(' '))
print(h // a + 1 if h % a != 0 else h // a)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    ans += 1
print(ans)
# Judge status: Accepted
from collections import deque
from bisect import bisect_left
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
nums = deque()
for i in range(N):
    j = bisect_left(nums, A[i])
    if j == 0:
        nums.appendleft(A[i])
    else:
        nums[j-1] = A[i]
print(len(nums))
# Judge status: Wrong Answer
N, M = map(int, input().split())

A = []

for i in range (0, N):
	C, D = map(int, input().split())
	A.append([C, D])

A = sorted(A)
Days = []
Number = []

for i in range (0, N):
	Days.append(A[i][0])
	Number.append(A[i][1])

Queue = []

import bisect as bi
for i in range (1, M+1):
	left = bi.bisect_left(Days, i)
	right = bi.bisect_right(Days, i)
	if right-left > 0:
		V = Number[left:right]
		for j in range (0, min(len(V), M-i+1)):
			Queue.append(V[len(V)-1-j])

Queue = sorted(Queue, reverse = True)

print(sum(Queue[0:min(len(Queue), M)]))
# Judge status: Wrong Answer
N,K,S = map(int,input().split())
if N == 10**9:
    print(str(S)*K + str(1)*(N-K))
else:
    print(str(S)*K + str(S+1)*(N-K))
# Judge status: Accepted
n = int(input())
SP = []
for i in range(n):
    s, p = input().split()
    SP.append((s, int(p), i+1))
SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for s, p, i in SP:
    print(i)
# Judge status: Accepted
N, K, Q = map(int,input().split())
A = [0] * N
for q in range(Q):
    a = int(input())
    A[a-1] += 1


for n in range(N):
    if (Q-A[n]) >= K:
        print('No')
    else:
        print('Yes')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

# A - Table Tennis Training
N, A, B = map(int, input().split())

if (B-A) % 2 == 0:
	print(int((B-A) / 2))
else:
	print(min(B - 1, N - A))
# Judge status: Accepted
def resolve():
    a, b, c = map(int, input().split())
    if c <= a+b:
        print("Yes")
    else:
        print("No")
resolve()
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
x=0
y=0
a.sort()
min=10**6
if sum(a)==0 and n>2:
  print(0)
  exit()
for i in range(n-1):
  x+=a[i]
  if min>abs(2*x-sum(a)):
    min=abs(2*x-sum(a))
print(min)
# Judge status: Accepted
N,K = list(map(int,input().split()))
if N%K == 0:
  print('0')
else:
  print('1')
# Judge status: Accepted
a, b = map(int,input().split())

for i in range(2, 400):
    if (10**(len(str(b))) * a + b) == i**2:
        ans = 'Yes'
        break
    else:
        ans = 'No'
print(ans)
# Judge status: Accepted
x,k,d = map(int,input().split())
x = abs(x)
xmd = x%d
xdd = x//d
x -= k*d
if x < 0:
  print(xmd if (k-xdd)%2 == 0 else d-xmd)
else:
  print(x)
# Judge status: Wrong Answer
N = int(input()) + 1
A = [0] + [int(i) for i in input().split()]
i_Ai = [i + A[i] for i in range(N)]
j_Aj = [j - A[j] for j in range(0, N)]
cnt = 0

if max(A) - min(A) > N:
    print(0)
else:
    for i in range(1, N):
        for j in range(i_Ai[i], N):
            if j_Aj[j] == i_Ai[i]:
                cnt += 1
    print(cnt)
# Judge status: Accepted
A, B, T = map(int, input().split())

c = T // A

d = c * B

print(d)
# Judge status: Accepted
X=int(input())
ans_ama=X
Flag=True
while 1:
    for i in range(2,int(X/2)):
        if X%i==0:
            Flag=False
            break
    if Flag==True:
        ans=X
        break
    Flag=True
    X+=1
print(X)
# Judge status: Accepted
S = str(input())
ans = True
if ('N' in S) ^ ('S' in S) == 1:
  ans = False
if ('E' in S) ^ ('W' in S) == 1:
  ans = False
if ans: print('Yes')
else: print('No')
# Judge status: Accepted
N = int(input())
n_list = []
for i in range(N):
  n_list.append(input())
M = int(input())
m_list = []
for i in range(M):
  m_list.append(input())
add_dic = {}
for n in n_list:
  add = add_dic.get(n, 0)
  add_dic[n] = add + 1
diff_dic = {}
for m in m_list:
  diff = diff_dic.get(m, 0)
  diff_dic[m] = diff + 1

max_ = 0
for key, add in add_dic.items():
  total = add - diff_dic.get(key, 0)
  if total > max_:
    max_ = total

print(max_)
# Judge status: Accepted
a=int(input())
print(a*800-a//15*200)
# Judge status: Accepted
n = int(input())
ans = 1

for i in range(1,n+1):
    ans = i * ans % (10**9+7)

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

if N[2]-N[1] < 0:
  print(abs(N[2]-N[1]))
else:
  print(0)
# Judge status: Accepted
a,b = map(int,input().split())
print(-1 if a%b == 0 else a)
# Judge status: Accepted
from collections import Counter

N = int(input())
A1 = list(map(int, input().split()))
A2 = [-1 * A1[i] for i in range(N)]

for i in range(N):
    A1[i] -= i
    A2[i] -= i

C1 = Counter(A1)
C2 = Counter(A2)
res = 0
for c1 in C1.keys():
    res += C1[c1] * C2[c1]
print(res)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
p = 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:
                p += 1

print(p)
# Judge status: Accepted
S  = str(input())

cnt =0
flg = True

for i in range(len(S)-1):
    
    if S[i] in S[cnt+1:]:
        
        flg =False
    
    cnt+=1
    
if flg ==True:
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
n = int(input())
qq= list(map(int,input().split()))
ww = list(map(int,input().split()))
c = list(map(int,input().split()))
t = 0
for i in range(n):
  if i != 0:
    t = t+ww[qq[i]-1]+c[qq[i]-2]
  else:
    t = t + ww[qq[i]-1]
print(t)
# Judge status: Accepted
N,M,X=map(int,input().split())
B=[list(map(int,input().split())) for _ in range(N)]
inf=(10**5)*12+1
ans=inf
for i in range(1,2**N):
  tmp=[0]*M
  c=0
  for j in range(N):
    if i>>j&1:
      for k in range(M):
        tmp[k]+=B[j][k+1]
      c+=B[j][0]
  if len([i for i in tmp if i>=X])==M:
    ans=min(c,ans)
print(ans if ans<inf else -1)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()

def main():
    S = input()
    K = int(input())

    for c in S:
        if c != '1':
            print(int(c))
            return
    print(1)


if __name__ == "__main__":
    main()