Harryxun/stf_run huggingface dataset:
from collections import defaultdict
import bisect

alphabet="abcdefghijklmnopqrstuvwxyz"

bS = int(input())
S= input()
nQ = int(input())

query = []
for i in range(nQ):
  query.append(input().split())

locs =defaultdict(list)

for i,char in enumerate(S):
    locs[char].append(i)
    
def countChars(iter,ss,ee):
  nChar = 0
  for i in alphabet:
    if len(locs[i]) == 0:
      pass
    else:
      sptr = bisect.bisect_right(locs[i],ss)
      eptr = bisect.bisect_left(locs[i],ee)
      if sptr == eptr:
        if sptr < 1 or sptr > len(locs[i]):
          continue
        else:
          if locs[i][sptr-1] == ss:
            nChar+=1
      else:
        nChar += 1
  return nChar
    
  
res = []
for iter,iQ in enumerate(query):
  if int(iQ[0]) == 2:
    res.append(str( countChars(iter,int(iQ[1])-1,int(iQ[2])) ))
  if int(iQ[0]) == 1:
    location = int(iQ[1])-1
    curChar  = S[location]
    if curChar != iQ[2]:
      locs[curChar].remove(location) #remove from old
      bisect.insort(locs[iQ[2]],location)
      
print(" ".join(res))

  

### FIXED CODE ###

from collections import defaultdict
import bisect

alphabet="abcdefghijklmnopqrstuvwxyz"

bS = int(input())
S= input()
nQ = int(input())

S = [i for i in S]

query = []
for i in range(nQ):
  query.append(input().split())

locs =defaultdict(list)

for i,char in enumerate(S):
    locs[char].append(i)
    
def countChars(iter,ss,ee):
  nChar = 0
  for i in alphabet:
    if len(locs[i]) == 0:
      pass
    else:
      sptr = bisect.bisect_right(locs[i],ss)
      eptr = bisect.bisect_left(locs[i],ee)
      if sptr == eptr:
        if sptr < 1 or sptr > len(locs[i]):
          continue
        else:
          if locs[i][sptr-1] == ss:
            nChar+=1
      else:
        nChar += 1
  return nChar
    
  
res = []
for iter,iQ in enumerate(query):
  if int(iQ[0]) == 2:
    res.append(str( countChars(iter,int(iQ[1])-1,int(iQ[2])) ))
  if int(iQ[0]) == 1:
    location = int(iQ[1])-1
    curChar  = S[location]
    if curChar != iQ[2]:
      locs[curChar].remove(location) #remove from old
      bisect.insort(locs[iQ[2]],location)
      S[location] = iQ[2]
      
print(" ".join(res))
N = int(input())
print('Yes' if '9' in N else 'No')

### FIXED CODE ###

N = input()
print('Yes' if '9' in N else 'No')
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split(' ')))
    homework_day = 0
    for i in range(2):
        homework_day = homework_day + A[i]
    if homework_day > N:
        print(-1)
    else:
        print(N - homework_day)
main()

### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split(' ')))
    homework_day = 0
    for i in range(len(A)):
        homework_day = homework_day + A[i]
    if homework_day > N:
        print(-1)
    else:
        print(N - homework_day)
main()
N, L=map(int, input().split(""))
s=[]
for i in range(n):
  s.append(input())
print(''.join(sorted(s))
  

### FIXED CODE ###

# 入力
N,L=map(int,input().split())

l=[]
for i in range(N):
  l.append(input())

# ソート
l.sort()

# 出力
print(''.join(l))
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    l = map(int,raw_input().split())
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*N
                for i in range(N):
                    R = (A*R+C)%M
                    O[i] = (l[i]+R)%M
                X = [O.count(i) for i in set(O)]
                tmp = -sum(float(x)/N*math.log(float(x)/N,2) for x in X)
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

### FIXED CODE ###

import math,itertools as it
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    I = map(int,raw_input().split())
    for S,A,C in it.product(range(16),repeat=3):
        R = S
        O = [0]*M
        for i in I:
            R = (A*R+C)%M
            O[(i+R)%M] += 1
        tmp = -sum(1.0*x/N*math.log(1.0*x/N,2) for x in O if x > 0)
        if tmp < H:
            H = tmp
            ans = [S,A,C]
    print " ".join(map(str,ans))
import functools, fractions
 
def lcm(a, b):
	return a * b // fractions.gcd(a, b)
 
def check(L, NM):
    res = []
    for i in range(NM):
        res.append(int(i*(L/NM)+1))
    return res
 
def check2(x, L, NM):
    return int((x-1)*NM/L)
 

def main():
 	N,M = map(int,input().split())
    S = input()
    T = input()
    L = lcm(N,M)
    ans = L


    a = list(set(check(L, N)) & set(check(L, M)))
    for i in a:
        if S[check2(i, L, N)] != T[check2(i, L, M)]:
            ans = -1
            break
    print(ans)
if __main__ == '__main__':
  main()

### FIXED CODE ###

import functools, fractions

N,M = map(int,input().split())
S = input()
T = input()

def lcm(a, b):
	return a * b // fractions.gcd(a, b)

def check(L, NM):
    res = []
    for i in range(NM):
        res.append(int(i*(L/NM)+1))
    return res

def check2(x, L, NM):
    return int((x-1)*NM/L)

L = lcm(N,M)
ans = L


a = list(set(check(L, N)) & set(check(L, M)))
for i in a:
    if S[check2(i, L, N)] != T[check2(i, L, M)]:
        ans = -1
        break
print(ans)
from fractions import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))

### FIXED CODE ###

from fractions import gcd
A,B=map(int,input().split())
print(A*B//gcd(A,B))
import math
import itertools
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n, k = map(int, input().split())
for i in range(k):
     if n-k+1 < i:
        print(0)
    else:
        print(((cmb(n-k+1, i+1) % (10 ** 9 + 7)) * (cmb(k-1, i) % (10 ** 9 + 7))) % (10 ** 9 + 7))


### FIXED CODE ###

import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1):
    if n-k+1 >= i:
        print(comb(n-k+1, i)*comb(k-1, i-1) % mod)
    else:
        print(0)
i = int(input())
x = i // 11
a = x * 2
b = i % 11
if b = 0:
    pass
elif b <= 6:
    a += 1
else:
    a += 2
print(a)


### FIXED CODE ###

i = int(input())
x = i // 11
a = x * 2
b = i % 11
if b == 0:
    pass
elif b <= 6:
    a += 1
else:
    a += 2
print(a)
n = int(input())
a = list(map(int, input().split()))

st = set(a)

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n  >= 4 and st == {0}:
  print("Yes")
elif n % 3 == 0 and len(st) == 2 and (0 in a) and a.count(0) = n /3:
  print("Yes")
elif n % 3 == 0 and len(st) == 3 and a.count(st.pop) = n /3 anda.count(st.pop) = n/3:
  print("Yes")
else:
  print("No")
 

### FIXED CODE ###

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

st = set(a)
lst = list(st)

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n  >= 4 and st == {0}:
  print("Yes")
elif n % 3 == 0 and len(st) == 2 and a.count(0) == n /3:
  print("Yes")
elif n % 3 == 0 and len(st) == 3 and lst[0] ^ lst[1] == lst[2] and a.count(lst[0]) == n /3 and a.count(lst[1]) == n/3:
  print("Yes")
else:
  print("No")
import bisect

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

INF = 10 ** 18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for x in range(Q):
  b = bisect.bisect_right(s, x)
  d = disect.bisect_right(t, x)
  dist = 0
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)

### FIXED CODE ###

import bisect

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

INF = 10 ** 18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for i in range(Q):
  x = int(input())
  b = bisect.bisect_right(s, x)
  d = bisect.bisect_right(t, x)
  dist = INF
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)
s=input()
n=int(input())
my_bool=True
cnt=0
for i in range(1,len(s)):
    if my_bool:
        if s[i-1]==s[i]:
            cnt+=1
            my_bool=False
    else:
        my_bool=True
        continue
if my_bool:
    if not s[-1]==s[-2] and s[0]==s[-1]:
        cnt+=1
print(cnt*n)

### FIXED CODE ###

s=input()
k=int(input())
if len(set(list(s)))==1:
    print((len(s)*k)//2)
    exit()
t=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:
      t[-1]+=1
  else:
      t.append(1)
a=0
for i in t:
    a+=(i//2)*k
if s[0]==s[-1]:
  if t[0]%2==t[-1]%2==1:
      a+=k-1
print(a)
N = int(input())
adjacent_list = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int,input().split())
    u -= 1
    v -= 1
    adjacent_list[u].append([v, w])
    adjacent_list[v].append([u, w])


colors = [-1]*N


def dfs(v, color):
    if colors[v] != -1:
        return
    colors[v] = color
    for adjacent_v in adjacent_list[v]:
        if adjacent_v[1] % 2 == 0:
            dfs(adjacent_v[0], color)
        else:
            dfs(adjacent_v[0], 1-color)

dfs(0,0)

#print(*colors)
for i in range(N):
    print(colors[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N = int(input())
adjacent_list = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int,input().split())
    u -= 1
    v -= 1
    adjacent_list[u].append([v, w])
    adjacent_list[v].append([u, w])


colors = [-1]*N


def dfs(v, color):
    if colors[v] != -1:
        return
    colors[v] = color
    for adjacent_v in adjacent_list[v]:
        if adjacent_v[1] % 2 == 0:
            dfs(adjacent_v[0], color)
        else:
            dfs(adjacent_v[0], 1-color)

dfs(0,0)

#print(*colors)
for i in range(N):
    print(colors[i])
x, y = map(int,input().split())

if (y-2*x)%2==0:
  k = (y-2*x)//2
  t = x-k
else:
  print("No")

if 0 <= k and 0 <= t:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

x, y = map(int,input().split())

if (y-2*x)%2!=0:
  print("No")
else:
  k = (y-2*x)//2
  t = x-k

  if 0 <= k and 0 <= t:
    print("Yes")
  else:
    print("No")
print('Yes' if any([n/i in range(1, 10) and (n/i).is_integer() for i in range(1, 10)]) else 'No')

### FIXED CODE ###

n = float(input())
print('Yes' if any([n/i in range(1, 10) and (n/i).is_integer() for i in range(1, 10)]) else 'No')
n=int(raw_input())
maxv=n
for a in xrang(1,n+1):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)

### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-

n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)
N,K= map(int,input().split())
X = list(map(int, input().split())) 

import numpy as np 


flag = 0
x_plus = [i for i in X if i>=0]
x_minus = [i for i in X if i<0]
x_minus.reverse()

len_plus = len(x_plus)
len_minus = len(x_minus)

use_x = []
answer = 0

i = 0
j = 0
if len_plus==0:
    answer = abs(x_minus[K-1])
    
if len_minus==0:
    answer = abs(x_plus[K-1])

if len_plus!=0 and len_minus!=0:
    while(1):
        if len(use_x)==K: break
        if x_plus[i] > abs(x_minus[j]):
            use_x.append(x_minus[j])
            if j+1>=len_minus:
                i += 1
            else:
                j += 1
        else:
            use_x.append(x_plus[i])
            if i+1>=len_minus:
                j += 1
            else:
                i += 1
    use_x.sort()
    # print(use_x)
    answer = use_x[-1]-use_x[0]+min(use_x[-1],abs(use_x[0]))

print(answer)

        



### FIXED CODE ###

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

answer = 10**9

for i in range(N):
    if i+K-1>= N: break
    answer = min(answer,abs(X[i+K-1]-X[i])+min(abs(X[i]),abs(X[i+K-1])))

print(answer)
N=int(input())
A=list(map(int,input().split()))
ans = 0
for i in range (1,N):
    if  A[i-1] > high:
        high = A[i-1]
    if high > A[i-1]:
        ans += high - A[i]
print (ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans = 0
high = 0
for i in range (1,N):
    if  A[i-1] > high:
        high = A[i-1]
    if high > A[i]:
        ans += high - A[i]
print (ans)
import sys
import numpy as np
from collections import deque,defaultdict

inp=lambda v,w:v[0]*w[0]+v[1]*w[1]
isprop = lambda a,b: a[0]*b[1]==a[1]*b[0]
cwsum = lambda l:[sum([x[0] for x in l]), sum([x[1] for x in l])]
chmin = lambda a,b:(a,b)[b<a]
# cwsum = lambda l:np.sum(l,axis=0)
            
def main():
    N,Ma,Mb=map(int,input().split())
    ch=dict()
    for _ in range(N):
        a,b,c=map(int,input().split())
        ch[(a,b)]=c
    p=[(-1)*Mb,Ma]
    pch={inp(p,v):ch[v] for v in iter(ch)} #p方向への射影
    kpch=list(pch.keys())
    infty=30
    X=N*4
    dp=[[infty]*(2*X+1) for _ in range(N)]
    for i in range(N):
        for j in range(2*X+1):
            if i==0 and j==X+kpch[0]:
                dp[i][j]=pch[kpch[0]]
            elif i>0 and j>=kpch[i] and j<=2*X+kpch[i]:
                dp[i][j]=chmin(dp[i-1][j],dp[i-1][j-kpch[i]]+pch[kpch[i]])
            elif i>0:
                dp[i][j]=dp[i-1][j]
    #  print(kpch)
    #  print(pch)
    #  print(dp)
    if dp[N-1][X]==infty:
        print(-1)
    else:
        print(dp[N-1][X])

if __name__=='__main__':
    main()


### FIXED CODE ###

import sys
import numpy as np
from collections import deque,defaultdict

inp=lambda v,w:v[0]*w[0]+v[1]*w[1]
isprop = lambda a,b: a[0]*b[1]==a[1]*b[0]
cwsum = lambda l:[sum([x[0] for x in l]), sum([x[1] for x in l])]
chmin = lambda a,b:(a,b)[b<a]
# cwsum = lambda l:np.sum(l,axis=0)
            
def main():
    N,Ma,Mb=map(int,input().split())
    infty=10**9
    ch=[list(map(int,input().split())) for _ in range(N)]
    p=[(-1)*Mb,Ma]
    # cand=[v[2] for v in ch if inp(p,v[:2])==0]
    # if cand:
        # m1=min(cand)
    # else:
        # m1=infty
    # ncand=[v for v in ch if inp(p,v[:2])!=0] #p方向への射影
    pch=[[inp(v[:2],p),v[2]] for v in ch]
    X=N*max([abs(w[0]) for w in pch])
    dp=[[infty]*(2*X+1) for _ in range(N)]
    for i in range(N):
        for j in range(2*X+1):
            if i==0 and j==X+pch[0][0]:
                dp[i][j]=pch[0][1]
            elif i>0 and j==X+pch[i][0]:
                dp[i][j]=chmin(dp[i-1][j],pch[i][1])
            elif i>0 and j>=pch[i][0] and j<=2*X+pch[i][0]:
                dp[i][j]=chmin(dp[i-1][j],dp[i-1][j-pch[i][0]]+pch[i][1])
            elif i>0:
                dp[i][j]=dp[i-1][j]
    #  print(ch)
    #  print(pch)
    #  print(dp)
    if dp[N-1][X]==infty:
        print(-1)
    else:
        print(dp[N-1][X])

if __name__=='__main__':
    main()
a,b,k=map(int,input().split())
x=a-k
if x<0:
	a=0
    x=k-a
    b=b-k
    if b<0:
		b=0
print(a,b)


### FIXED CODE ###

a,b,k=map(int,input().split())
if a>k:
    print(a-k,b)
elif a+b>k:
    print(0,b-k+a)
else:    
    print(0,0)
re=0
tle=0
wa=0
ac=0
ip=[]
n=int(input())
for i in range(n):
  ip.append(input())
for i in range(n):
  if ip[i]=="AC":
    ac=ac+1
  if ip[i]=="TLE":
    tle=tle+1
  if ip[i]=="WA":
    wa=wa+1
  if ip[i]=="RE":
    re=re+1
print("AC x "+ac)
print("WA x "+wa)
print("TLE x "+tle)
print("RE x "+re)

### FIXED CODE ###

re=0
tle=0
wa=0
ac=0
ip=[]
n=int(input())
for i in range(n):
  ip.append(input())
for i in range(n):
  if ip[i]=="AC":
    ac=ac+1
  if ip[i]=="TLE":
    tle=tle+1
  if ip[i]=="WA":
    wa=wa+1
  if ip[i]=="RE":
    re=re+1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))
K=int(input())
A,B=map(int,input())
if (A-1)/K == B/K:
  print('NG')
else:
  print('OK')

### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
if (A-1)//K == B//K:
  print('NG')
else:
  print('OK')
N, M = map(int, input().split())

mod = 1000000007

f = [] # 素因数分解(指数部のみ)

for p in range(2, M): # 素因数分解
    e = 0
    while M%p == 0:
        e += 1
        M /= p
    
    if e>0:
        f.append(e)
    
    if M == 1:
        break

def pw(a, e):
    if e == 1:
        return a
    p = pw(a, e // 2)
    if e%2 == 1:
        return p * p % mod a % mod
    else:
        return p * p % mod

# fact, inv の計算
fact = [1] * 100040
inv = [1] * 100040
for k in range(1, 100040):
    fact[k] = fact[k-1] * k % mod
    inv[k] = pw(fact[k], mod-2)

ans = 1
for e in f:
    ans = ans * fact[e+N-1] % mod * inv[e] % mod * inv[N-1] % mod # N_H_e (重複組合せ)

print(ans)


### FIXED CODE ###

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

def ans1(): # 全ての組み合わせを調べる
    return max([
        10*A + B + C, # 10*A + C + B, 
        10*B + A + C, # 10*B + C + A, 
        10*C + A + B, # 10*C + B + A, 
    ])

def ans2():
    return A + B + C + 9*max([A, B, C])

#print(ans1())
print(ans2())
n, m = [int(i) for i in input().split()

matrix = []
for ni in range(n):
   matrix.append([int(a) for a in input().split()])
   
vector = []
for mi in range(m):
    vector.append(int(input()))

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
       sum += matrix[ni][mi] * vector[mi]
    
    print(sum)

### FIXED CODE ###

n, m = [int(i) for i in input().split()]

matrix = []
for ni in range(n):
   matrix.append([int(a) for a in input().split()])
   
vector = []
for mi in range(m):
    vector.append(int(input()))

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
       sum += matrix[ni][mi] * vector[mi]
    
    print(sum)
N, K = [int(_) for _ in input().split()]
for a in range(10**9):
    if K**(a) <= N < K**(i*1):
        print(a+1)
        break

### FIXED CODE ###

N, K = [int(_) for _ in input().split()]
for a in range(0, 10**9):
    if K**(a) <= N < K**(a+1):
        print(a+1)
        break
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
i = 0
c = 0
m = list()
while i < n:
    if a[i]==a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
i = 0
c = 0
m = list()
while i < n-1:
    if a[i]==a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)
import copy
import sys
import math

def main():
	n,y = map(int,input().split())
	for i in range(n+1):
		for j in range(n-i+1):
			k = n-i-j
			if(y == i*10000 + j*5000 + k*1000):  print(f'{i} {j} {k}');sys.exit()
	print('-1 -1 -1')


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

### FIXED CODE ###

import copy
import sys
import math

def main():
	n,y = map(int,input().split())
	for i in range(n+1):
		for j in range(n-i+1):
			k = n-i-j
			if(y == i*10000 + j*5000 + k*1000):
				print('{} {} {}'.format(i,j,k))
				sys.exit()
	print('-1 -1 -1')


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()
N,x=map(int,input().split())
a=list(map(int,input().split()))
b=0
for i in range(N//2):
    b+=max(a[2*i],a[2*(i+1)])+a[2*i+1]-x
print(b)

### FIXED CODE ###

N,x=map(int,input().split())
a=list(map(int,input().split()))
b=0
for i in range(N-1):
    if a[i]+a[i+1]>x:
        if a[i]<=x:
            b+=max(0,a[i+1]-x+a[i])
            a[i+1]=max(0,x-a[i])
        else:
            b+=a[i]-x+a[i+1]
            a[i+1]=0
            a[i]=x
b+=max(0,a[-2]+a[-1]-x)
print(b)
import numpy as np
n,m,x=map(int,input().split())
c=[None for i in range(n)]
a=[None for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c[i]=l[0]
    a[i]=np.array(l[1:])
mincos=1000000000000
for mask in range(2**n):
    rikai=np.zeros(m,dtype="int32")
    cos=0
    mm=mask
    for i in range(n):
        if mm%2:
            rikai+=a[i]
            cos+=c[i]
        mm//=2
    if np.all(rikai>=x):
        mincos=min(cos,mincos)

if mincos==1000000000000:
    print(-1)
else:
    print(mincos)


### FIXED CODE ###

import sys
s=input()
t=input()
for c in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
    if s+c==t:
        print("Yes")
        sys.exit(0)
print("No")
def main():
    K = int(input())
    if K%2 == 0 or K%5==0:
        return -1

    if K % 7 == 0:
        L = K * 9 / 7
    else:
        L = K * 9
    
    for i in range(1, 10000000):
        x = pow(10, i, L)
        if x == 1:
            return i
    else:
        return -1


if __name__ == "__main__":
    ans = main()
    print(ans)

### FIXED CODE ###

def main():
    K = int(input())
    if K%2 == 0 or K%5==0:
        return -1

    if K % 7 == 0:
        L = K * 9 // 7
    else:
        L = K * 9
    
    for i in range(1, 10000000):
        x = pow(10, i, L)
        if x == 1:
            return i
    else:
        return -1


if __name__ == "__main__":
    ans = main()
    print(ans)
import sys
import math

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MAT(h): return [list(map(int, input().split())) for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    L = [0] * N
    R = [0] * N
    M = [0] * N
    for i in range(N - 1):
        L[i + 1] = math.gcd(L[i], A[i])
        R[N - i - 2] = math.gcd(R[N - i - 1], A[N - i - 1])
    maxv = 0
    for i in range(N):
        M[i] = math.gcd(L[i], R[i])
        if maxv < M[i]:
            maxv = M[i]
    print(maxv)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import math
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MAT(h): return [list(map(int, input().split())) for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    L = [0] * N
    R = [0] * N
    M = [0] * N
    for i in range(N - 1):
        L[i + 1] = gcd(L[i], A[i])
        R[N - i - 2] = gcd(R[N - i - 1], A[N - i - 1])
    maxv = 0
    for i in range(N):
        M[i] = gcd(L[i], R[i])
        if maxv < M[i]:
            maxv = M[i]
    print(maxv)

if __name__ == '__main__':
    main()
t1=raw_input()
t2=raw_input()
if t1[0]==t2[2] and t1[1]==t2[1] and t1[2]==t2[0]:
 return "YES"
else
 return "NO"

### FIXED CODE ###

t1=raw_input()
t2=raw_input()
if t1[0]==t2[2] and t1[1]==t2[1] and t1[2]==t2[0]:
 print "YES"
else:
 print "NO"