Harryxun/stf_run huggingface dataset:
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    S = input()
    C = Counter(S)
    r = C.get("R")
    g = C.get("G")
    b = C.get("B")
    answer = r * g * b
    for left in range(N):
        for mid in range(left + 1, N):
            right = mid * 2 - left
            if right < N:
                if S[right] != S[mid] and S[mid] != S[left] and S[right] != S[left]:
                    answer = -1
    print(answer)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()
    C = Counter(S)
    R = C.get("R", 0)
    G = C.get("G", 0)
    B = C.get("B", 0)
    ans = R * G * B
    for left in range(N):
        for mid in range(left + 1, N):
            right = mid + mid - left
            if right < N:
                if S[right] != S[mid] and S[mid] != S[left] and S[right] != S[left]:
                    ans -= 1
    print(ans)


if __name__ == "__main__":
    main()
n,k=map(int, input().split())
num=abs(n-k)
if num>k:
    print(num%k)
else:
    print(k%num)

### FIXED CODE ###

n,k=map(int, input().split())
if n>k:
    num=n%k
    print(min(num,k-num))
elif n==k:
    print(0)
else:
    print(min(n,k-n))
n = int(input())
s = input()
a = 0
for i in range(n):
    if s[i] == '1':
        a += int(pow(2, n - i - 1))
for i in range(n):
    add = int(pow(2, n - i - 1))
    if s[i] == '1':
        add *= -1
    copy = a + add
    x = bin(copy).count('1')
    cnt = 1
    while copy % x != 0:
        copy %= x
        x = bin(copy).count('1')
        cnt += 1
    print(cnt)
    
        


### FIXED CODE ###

n = int(input())
s = input()
pw, pw1, pw2 = [0] * n, [0] * n, [0] * n
pw[0], pw1[0], pw2[0] = 1, 1, 1
v, mod1, mod2 = 0, 0, 0
for i in range(n):
    if s[i] == '1':
        v += 1
for i in range(1, n):
    pw1[i] = int(pw1[i - 1] * 2) % (v + 1)
    if v >= 2:
        pw2[i] = int(pw2[i - 1] * 2) % (v - 1)
for i in range(n):
    if s[i] == '1':
        mod1 = (mod1 + pw1[n - i - 1]) % (v + 1)
        if v >= 2:
            mod2 = (mod2 + pw2[n - i - 1]) % (v - 1)    
for i in range(n):
    copy, x, cnt = 0, v, 1
    
    if s[i] == '0':
        x += 1
        copy = (mod1 + pw1[n - i - 1]) % x
    else:
        x -= 1
        if x >= 1:
            copy = (mod2 - pw2[n - i - 1]) % x
        else:
            copy = -1
    if copy == -1:
        print(0)
    else:
        x = bin(copy).count('1')
        while copy > 0:
            copy %= x
            x = bin(copy).count('1')
            cnt += 1
        print(cnt)
X, N = map(int, input().split())
p = list(map(int, input().split()))

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(1, X)]
big = [i for i in range(X+1, 101)]

small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

### FIXED CODE ###

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-101, X)]
big = [i for i in range(X+1, 102)]
small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()
N, A, B = input().split

if int(A) * int(N) > int(B):
  print(B)
else:
  print(int(A) * int(N))

### FIXED CODE ###

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

if int(A) * int(N) > int(B):
  print(B)
else:
  print(int(A) * int(N))
A,B,M=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
mi=min(a)+min(b)
for i in range(0,M):
  Data=list(map(int, input().split()))
  wari=a[Data[0]]+b[Data[1]]-Data[2]
  if(mi>wari):
    mi=wari
print(mi)

### FIXED CODE ###

A,B,M=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
mi=min(a)+min(b)
for i in range(0,M):
  Data=list(map(int, input().split()))
  wari=a[Data[0]-1]+b[Data[1]-1]-Data[2]
  if(mi>wari):
    mi=wari
print(mi)
print("No"if int(input())%9else"Yes")


### FIXED CODE ###

import math
def MAP(): return map(int, input().split())
N, X, T = MAP()

print(math.ceil(N / X) * T)
while True: 
	h , w=map(int, input().split())
	if (h==0) and (w==0): 
                break

	else:
		print("#"*w)
		for I in  range(h-2):
		print("#"+"."*(w-2)+"#")
		print("#"*w)
 


### FIXED CODE ###

while 1:
        (H,W)=[int(i) for i in input().split()]
        if H==W==0:
                break
        print('#'*W)
        for i in range(H-2):
                print('#'+'.'*(W-2)+'#')
        print('#'*W)
        print('')
import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
inf = float('inf')
dp = [inf for _ in range(n)]

# メモ化再帰（一度計算した結果はメモしておく）
def rec(i):
  # 値が既に更新されていたらそのまま返す（計算し直さない）
  if dp[i] != inf:
    return dp[i]
  if i==0:
    return 0
  res = inf
  res = min(res, rec(i-1) + abs(h[i]-h[i-1]))
  if i > 1:
    res = min(res, rec(i-2) + abs(h[i]-h[i-2]))
  #print('dp[{}] = {}'.format(i, res))
  dp[i] = res
  return res

ans = rec(n-1)
print(ans)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), 
             dp[i-2] + abs(h[i-2]-h[i]))
print(dp[n-1])
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[1])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K-a[i]:
        j -= 1
    
    ans = max(ans, i+j)
    
print(ans)

### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K-a[i]:
        j -= 1
    
    ans = max(ans, i+j)
    
print(ans)
result = 99999
for i in range(1,N):
    s = abs(sum(w[:i]) - sum(w[i:]))
    if s<result:
        result = s
print(result)

### FIXED CODE ###

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

result = 99999
for i in range(1,N):
    s = abs(sum(w[:i]) - sum(w[i:]))
    if s<result:
        result = s
print(result)
import numpy as np

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum = sum * i
    if np.log10(sum) >= 18:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            sum = sum * i
            if sum > 1000000000000000000:
                print(-1)
                exit()
        print(sum)
    
if __name__ == '__main__':
    main()
n=int(input())
v=list(map(int,input().split()))
d1=[0]*(10**5+1)
d2=[0]*(10**5+1)

for i in range(n):
    if i%2==0:
        d1[v[i]]+=1
    else:
        d2[v[i]]+=1
assert n-max(d1)-max(d2)<0
print(n-max(d1)-max(d2))


### FIXED CODE ###

n=int(input())
v=list(map(int,input().split()))
d1=[0]*(10**5+1)
d2=[0]*(10**5+1)

for i in range(n):
    if i%2==0:
        d1[v[i]]+=1
    else:
        d2[v[i]]+=1
if d1.index(max(d1))==d2.index(max(d2)):
    d1n=sorted(d1,reverse=True)
    d2n=sorted(d2,reverse=True)
    if d1n[1]>d2n[1]:
        print(n-d1n[1]-d2n[0])
    else:
        print(n-d1n[0]-d2n[1])
else:
    print(n-max(d1)-max(d2))
#!/usr/bin/python3

import sys

def dprint(*args):
    pass
    #print(*args)

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        dprint(f"rev_str: {rev_str}")
        cur_num_rev_str = ""
        # 12345
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
        if cur_num_rev_str != "":
            dprint(f"ans: {ans}")
            ans += int(''.join(list(reversed(cur_num_rev_str))))
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()

### FIXED CODE ###

#!/usr/bin/python3

import sys

def dprint(*args):
    pass
    #print(*args)

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        #dprint(f"rev_str: {rev_str}")
        cur_num_rev_str = ""
        # 12345
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
        if cur_num_rev_str != "":
            #dprint(f"ans: {ans}")
            ans += int(''.join(list(reversed(cur_num_rev_str))))
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()
N, R = map(int, input().split())
print(R if N>=10 else R-100*(10-K))

### FIXED CODE ###

N, R = map(int, input().split())
print(R if N>=10 else R+100*(10-N))
N = int(input())
A = input().split()
c = collections.Counter(A)

import collections
for i in range(1,N+1):
    print(c[str(i)])


### FIXED CODE ###

N = int(input())
A = input().split()

import collections
c = collections.Counter(A)

for i in range(1,N+1):
    print(c[str(i)])
D=input()
if D=25 :
    print('Christmas')
elif D=24 :
    print('Christmas Eve')
elif D=23 :
    print('Christmas Eve Eve')
elif D=22 :
    print('Christmas Eve Eve Eve')

### FIXED CODE ###

D=int(input())
if D==25 :
    print('Christmas')
elif D==24 :
    print('Christmas Eve')
elif D==23 :
    print('Christmas Eve Eve')
elif D==22 :
    print('Christmas Eve Eve Eve')
r, d, x = map(int, input().split())
for _ in range(10):
	x = x * r - d
    print(x)


### FIXED CODE ###

r, d, x = map(int, input().split())
for _ in range(10):
    x = x * r - d
    print(x)
import math
A,B,C,D = map(int,input().split())
C_wareru = B//C-(A-1)//C
D_wareru = B//D-(A-1)//D
def lcm(a,b):
    return ((a*b) // math.gcd(a,b))
CD = lcm(C,D)
CD_wareru = B//CD-(A-1)//CD
print(B-A+1-(C_wareru+D_wareru-CD_wareru))

### FIXED CODE ###

import fractions
A,B,C,D = map(int,input().split())
C_wareru = B//C-(A-1)//C
D_wareru = B//D-(A-1)//D
def lcm(a,b):
    return ((a*b) // fractions.gcd(a,b))
CD = lcm(C,D)
CD_wareru = B//CD-(A-1)//CD
print(B-A+1-(C_wareru+D_wareru-CD_wareru))
def main():
	x = int(input())
    y = x%1000
    return y

if __name__ =="__main__":
  main()
  

### FIXED CODE ###

x = int(input())
if x%1000 == 0:
  y = 0
else:
  y = 1000 - (x%1000)
    
print(y)
import fractions,sys

n,m=map(int,input().split())
a = list(map(int, input().split()))
# ans = a[0]
# for i in range(1,n):
#     ans = ans * a[i] // fractions.gcd(ans, a[i])
ff=[]
for j in  a:
    count=0
    for i in range(1,36):
        if j%(2**i)==0:
            count+=1
    ff.append(count)
ff=[i==ff[0] for i in ff]

 
# b = [int(i/2) for i in a]
# b_list=[i%4==0 for i in b]
# bb=sum(b_list)
# if bb!=0 and bb!=n:
if all(ff)==False:
    print(0)
    exit()

ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

# tf=[(ans2/i)%2==0 for i in b]
# and any(tf)
if ans2>m:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

### FIXED CODE ###

import fractions,sys

n,m=map(int,input().split())
a = list(map(int, input().split()))
# ans = a[0]
# for i in range(1,n):
#     ans = ans * a[i] // fractions.gcd(ans, a[i])
ff=[]
for j in  a:
    count=0
    for i in range(1,36):
        if j%(2**i)==0:
            count+=1
    ff.append(count)
ff=[i==ff[0] for i in ff]

 
b = [int(i/2) for i in a]
# b_list=[i%4==0 for i in b]
# bb=sum(b_list)
# if bb!=0 and bb!=n:
if all(ff)==False:
    print(0)
    exit()

ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

# tf=[(ans2/i)%2==0 for i in b]
# and any(tf)
if ans2>m:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)
r=a=o=0
while 1:
 l,m,n=sorted(list(map(int,input().split())))
 if l+m<=n:break
 c=l*l+m*m-n*n
 if c>0:a+=1
 elif c<0:o+=1
 else:r+=1
print(sum(r,a,o),r,a,o)


### FIXED CODE ###

r=a=o=0
while 1:
 l,m,n=sorted(list(map(int,input().split())))
 if l+m<=n:break
 c=l*l+m*m-n*n
 if c>0:a+=1
 elif c<0:o+=1
 else:r+=1
print(r+a+o,r,a,o)
n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
ans=0
for i in range(len(a)):
  if d[i]<=10**5:
    d[a[i]]+=1
for i in range(1,len(d)):
  if d[i]>i:
    ans+=d[i]-i
  elif d[i]<i:
    ans+=d[i]
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
ans=0
for i in range(len(a)):
  if a[i]<=10**5:
    d[a[i]]+=1
  else:
    ans+=1
for i in range(1,len(d)):
  if d[i]>i:
    ans+=d[i]-i
  elif d[i]<i:
    ans+=d[i]
print(ans)
k=int(input())
s=str(input())

if len(s)<=k:
    print(s)
elif len(s)>k:
    print(s[0:k]+'...')

### FIXED CODE ###

n=input()

if int(n[-1])==2:
    print("hon")
elif int(n[-1])==4:
    print("hon")
elif int(n[-1])==5:
    print("hon")
elif int(n[-1])==7:
    print("hon")
elif int(n[-1])==9:
    print("hon")
elif int(n[-1])==0:
    print("pon")
elif int(n[-1])==1:
    print("pon")
elif int(n[-1])==6:
    print("pon")
elif int(n[-1])==8:
    print("pon")
else:
    print("bon")
def main():
    n,w = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(n)]

    # min -> inf, max -> -1
    dp = [[-1]*(w+1) for _ in range(n+1)]

    # shoki joken
    dp[0] = [0]*(w+1)
    for i in range(n):
        for j in range(w+1):
            # i select or not select
            if j-wv[i][0] >= 0:
                dp[i+1][j] = max(dp[i][j],dp[i][j-w]+v)
            else:
                dp[i+1][j] = dp[i][j]

    print(max(dp[-1]))

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n,wmax = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(n)]

    # min -> inf, max -> -1
    dp = [[-1]*(wmax+1) for _ in range(n+1)]

    # shoki joken
    dp[0] = [0]*(wmax+1)
    for i in range(n):
        w,v = wv[i]
        for j in range(wmax+1):
            # i select or not select
            if j-w >= 0:
                dp[i+1][j] = max(dp[i][j],dp[i][j-w]+v)
            else:
                dp[i+1][j] = dp[i][j]

    print(max(dp[-1]))

if __name__ == '__main__':
    main()
def main():
  s=input()
  t=input()

  sd=list(s)
  sd.sort()
  td=list(t)
  td.sort(reverse=True)

  for (sc,tc) in zip(sd,td):
    if sc<tc:
      print("Yes")
      return
  if len(sd)<len(td) and sd[len(sd)-1]==td[len(sd)-1]:
    print("Yes")
    return
  print("No")

main()


### FIXED CODE ###

import math
a,b=map(int,input().split())
x=(a+b)/2

print(math.ceil(x))
a = int(input())
b = int(input())

if a > b:
 print(a > b)

elif a < b:
 print (a < b)

elif a == b:
 print (a == b)

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
s= input().split(' ')
s[0]=X
s[1]=Y
s[2]=Z
d=X
a=Y
b=d
d=a
a=c
c=d

print(a, b, c)



### FIXED CODE ###

X,Y,Z= input().split()
d=X
a=Y
b=d
d=a
a=Z
c=d

print(a, b, c)
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
reso

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
resolve()
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 03 13:03:51 2015

@author: hirose
"""

while(1):
    n = map(int, raw_input().split())
    a = n[0]
    b = n[1]
    count = 1
    n = 10
    while(1):
        if((a+b)/n > 0):
            count += 1
            n = n*10
        else:
            break
        print count

### FIXED CODE ###

while True:
    try:
        a, b = map(int, raw_input().split())
        print len(str(a+b))
    except EOFError:
        break
import sys

def findminsum(lst,K,N,dp):
    for s in range(K+1):
        for j in range(N):
            if j==0 and s<=lst[j]:
                dp[s][j]=lst[0]
            elif s>lst[j] and j>0:
                dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
            elif s<=lst[j] and j>0:
                dp[s][j]=min(lst[j],dp[s][j-1])
    # print(lst)
    # print(dp[0][:])
    # print(dp[1][:])
    # print(dp[K][:])
    return dp[K][N-1]

def main():
    inf=10**6
    dp=[[inf]*N for s in range(K+1)]
    N,K=map(int,sys.stdin.readline().strip().split())
    cards=list(map(int,sys.stdin.readline().strip().split()))
    # cards=list(filter(lambda x:x<K,cards))
    cards.sort()
    N=len(cards)
    nn=0
    for i in range(N):
        if cards[i]<K:
            c=cards[i]
            cards[i]=0
            if findminsum(cards,K-c,N,dp)>=K:
                nn+=1
            cards[i]=c
        else:
            break
    print(nn)

if __name__=='__main__':
    main()


### FIXED CODE ###

#4 9
#1 3 5 6
#の時に1（正解は0）と出力されるがACになる

N, K = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)
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
j = M-1
for i in range(N):
    if A[i] > K:
        break
    while B[j] > K - A[i]:
        j -= 1
    ans = max(ans, i+j+2)
print(ans)


### FIXED CODE ###

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

a = [0]
b = [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i] +B[i])
ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K -a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
n1 = int(input())
n2 = list(map(int, input().split()))
n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
a1 = []
a2 = 0
for i in range(len(n3)):
    if n3[i]:
        a2 += 1
        if i == len(n3) - 1:
            a1.append(a2)
    else:
        a1.append(a2)
        a2 = 0
print(max(a1))

### FIXED CODE ###

n1 = int(input())
n2 = list(map(int, input().split()))
if n1 == 1:
    print(0)
else:
    n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
    a1 = []
    a2 = 0
    for i in range(len(n3)):
        if n3[i]:
            a2 += 1
            if i == len(n3) - 1:
                a1.append(a2)
        else:
            a1.append(a2)
            a2 = 0
    print(max(a1))
N = int(input())
s = [int(input()) for i in range(N)]
M = int(input())
t = [int(input()) for i in range(M)]

s1 = list(set(s))
a = []
for i in range (len(s1)):
    for j in range (N):
        if s1[i] == s[j]:
            a[i]+=1
for i in range (len(s1)):
    for j in range (M):
        if s1[i] == t[j]:
            a[i]-=1
print(max(a))

### FIXED CODE ###

A, B = map(int, input().split())
cnt = 0
for i in range (A, B+1):
    if str(i) == str(i)[::-1]:
        cnt += 1
print(cnt)
a, b, x = map(int, input().split())

if a + b <= x:
    input('YES')
else:
    input('NO')

### FIXED CODE ###

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

if a > x:
    print('NO')
elif a + b < x:
    print('NO')
else:
    print('YES')
t = input()

list_t = list(t)

for i in range(len(list_t)):
    if list_t[i] == '?':
        if i > 0:
            if list_t[i - 1] == 'P':
                list_t[i] = 'D'
            else:
                list_t[i] = 'D'
        if i < len(list_t):
            if list_t[i + 1] == 'D':
                list_t[i] = 'P'

print(''.join(list_t))

### FIXED CODE ###

t = input()

list_t = list(t)

n = len(list_t)

for i in range(n):
    if n == 1:
        list_t[i] = 'D'
        break
    if list_t[i] == '?':
        if i > 0 and i < n - 1:
            if list_t[i - 1] == 'P' and list_t[i + 1] == 'P':
                list_t[i] = 'D'
            if list_t[i - 1] == 'P' and list_t[i + 1] == 'D':
                list_t[i] = 'D'
            if list_t[i - 1] == 'P' and list_t[i + 1] == '?':
                list_t[i] = 'D'
            if list_t[i - 1] == 'D' and list_t[i + 1] == 'P':
                list_t[i] = 'D'
            if list_t[i - 1] == 'D' and list_t[i + 1] == 'D':
                list_t[i] = 'P'
            if list_t[i - 1] == 'D' and list_t[i + 1] == '?':
                list_t[i] = 'P'
        elif i > 0:
            if list_t[i - 1] == 'P':
                list_t[i] = 'D'
            if list_t[i - 1] == 'D':
                list_t[i] = 'D'
        elif i < n - 1:
            if list_t[i + 1] == 'P':
                list_t[i] = 'D'
            if list_t[i + 1] == 'D':
                list_t[i] = 'P'
            if list_t[i + 1] == '?':
                list_t[i] = 'D'


print(''.join(list_t))
s = input().strip()
l = len(s)

if (l + s[0] == s[-1]) % 2:
  print("First")
else:
  print("Second")

### FIXED CODE ###

s = input().strip()
l = len(s)
 
if (l + (s[0] == s[-1])) % 2:
  print("First")
else:
  print("Second")
S = list(input())
A = []
for i in S:
  if i in A:
    remove(i)
  else:
    A.append(i)
if len(A) == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = list(input())
A = []
for i in S:
  if i in A:
    A.remove(i)
  else:
    A.append(i)
if len(A) == 0:
  print("Yes")
else:
  print("No")
n=int(input())
ilist=[str(input()) for i in range(n)]
#print(ilist)

dic={}
for i in ilist:
  dic[i]=1

print (len(dic))
~

### FIXED CODE ###

n=int(input())
ilist=[str(input()) for i in range(n)]
#print(ilist)

dic={}
for i in ilist:
  dic[i]=1

print (len(dic))
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

m = np.zeros((2, N)).astype(int)
m[0][0] = A1[0]
m[1][0] = A2[0] + A1[0] 

for i in range(1, N):
    m[0][i] = A1[i]+m[0][i-1]
    m[1][i] = max(A2[i]+m[1][i-1], A2[i]+m[0][i])
    
print(m[1][N-1])

### FIXED CODE ###

import numpy as np

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

m = np.zeros((2, N)).astype(int)
m[0][0] = A1[0]
m[1][0] = A2[0] + A1[0] 

for i in range(1, N):
    m[0][i] = A1[i]+m[0][i-1]
    m[1][i] = max(A2[i]+m[1][i-1], A2[i]+m[0][i])
    
print(m[1][N-1])