Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    is_prime = hurui(10**6+10)
    i = 1
    c = 0
    while i**2 <= g:
        if g % i == 0:
            if is_prime[i] == 1:
                # print("i: ", i)
                c += 1
            if i != g // i and is_prime[g//i] == 1:
                # print("i: ", i)
                c += 1
        i += 1
    # print(g)
    print(c+1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    # is_prime = hurui(10**6+10)
    i = 2
    c = 0
    # print(g)
    ans = []
    while i**2 <= g:
        if g % i == 0:
            ans.append([i, 0])
            while g % i == 0:
                g /= i
                ans[-1][1] += 1
        i += 1
    if g != 1:
        ans.append([g, 1])
    # print(ans)
    print(len(ans)+1)

if __name__ == '__main__':
    main()
n = input( )
result = sum(list(map(int, str(n))))

if result % 9 == 0 :
    print('Yes')
else :
    print('No')


### FIXED CODE ###

N, X, T = map(int, input().split())
if int(N) % int(X) != 0 :
	print( ( int(N) // int(X) + 1) * int(T) )
if int(N) % int(X) == 0 :
	print( (int(N) // int(X) ) * int(T) )
a=int(input())
b=int(input())
c=int(input())
print((a+b)*h//2)


### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
import math
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [math.inf] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [10**10] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[-1])
import math

li = [int(i) for i in input().split(" ")]

res = (li[0] // math.gcd(li[0], li[1]) -1) * 3 * math.gcd(li[0], li[1])
print(res)

### FIXED CODE ###

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

li = [int(i) for i in input().split(" ")]
res = (li[0] // gcd(li[0], li[1]) -1) * 3 * gcd(li[0], li[1])
print(res)
N = int(input())
A = list(map(int,input().split()))
frag = 0
tmp = 0
 
for i in range(0,N):
    if A[i] > A[i+1]:
        A[i] = A[i] - 1
        tmp = max(A)
        if A[i] > A[i+1] or tmp > A[i+1]:
            frag += 1
            break
 
if frag == 1:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
pre = -999
frag = 0

for i in range(N):
    if A[i]-1 >= pre:
        pre = A[i] - 1
    elif A[i] >= pre:
        pre = A[i]
    else:
        frag += 1
        break
        
if frag == 1:
    print("No")
else:
    print("Yes")
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N, K = map(int, input().split())
R = N - K

print(R + 1)
for i in range(2, K + 1):
    tmp = cmb(R + 1, i)
    tmp2 = cmb(K - 1, K - i)
    print((tmp % (10**9 + 7) * tmp2 % (10**9 + 7)) % (10**9 + 7))

### FIXED CODE ###

from operator import mul
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=1000)
def cmb(n,r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())
R = N - K

print(R + 1)
for i in range(2, K + 1):
    if R + 1 < i:
        print(0)
        continue
    tmp = cmb(R + 1, i)
    tmp2 = cmb(K - 1, K - i)
    print((tmp % (10**9 + 7) * tmp2 % (10**9 + 7)) % (10**9 + 7))
n = int(input())

def divisior(n):
    a = []
    i = 1
    while (i*i <= n):
        if n%i == 0:
            a.append(i)
            if (i*i != n): a.append(n//i)
        i += 1

    return a

ans = 0
a = divisior(n).sort()

for x in a[1:]:
    tmp = n
    while (tmp%x == 0): tmp = tmp//x
    if (tmp%x == 1) : ans += 1

b = divisior(n-1)

ans = ans + len(b) -1

print(ans)




### FIXED CODE ###

n = int(input())

def divisior(n):
    a = []
    i = 1
    while (i*i <= n):
        if n%i == 0:
            a.append(i)
            if (i*i != n): a.append(n//i)
        i += 1
    return a

ans = 0
a = divisior(n)

for x in a[1:]:
    tmp = n
    while (tmp%x == 0): tmp = tmp//x
    if (tmp%x == 1) : ans += 1

b = divisior(n-1)

ans = ans + len(b) -1

print(ans)
S = input()
T = input()
cnt = 0
for i in S:
  if S[i] == T[i]:
    cnt += 1
print(cnt)

### FIXED CODE ###

S = input()
T = input()
cnt = 0
loop = 0
for i in S:
  if i == T[loop]:
    cnt += 1
  loop += 1
print(cnt)
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
 
M = max(a,b)  
m = min(a,b)  
  
if (v-w)*t > M - n:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
gap=abs(a-b) 
if v>w:
  c=gap/(v-w)
  if t>=c:
    print('YES')
  else:
    print('NO')
else:
  print('NO')
a,b,m=map(int, input().split())
rei=list(map(int, input().split())) 
den=list(map(int, input().split())) 
cou = [0] * m
ans = 100000
for i in range(m):
	cou[i]=list(map(int, input().split()))
	c=rei[cou[i][0]-1]+den[cou[i][1]-1]-cou[i][2]
	if ans>c:
		ans=c
c=min(a)+min(b)
if ans>c:
		ans=c
print(ans)

### FIXED CODE ###

m=list(map(int, input().split()))
rei=list(map(int, input().split())) 
den=list(map(int, input().split())) 
cou = [0] * m[2]
ans = []
for i in range(m[2]):
	cou[i]=list(map(int, input().split()))
	ans.append(rei[cou[i][0]-1]+den[cou[i][1]-1]-cou[i][2])

ans.append(min(rei)+min(den))
print(min(ans))
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[0]*(M+1) for i in range(N+1)]

for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            dp[n+1][m+1] = (dp[n+1][m]+dp[n][m+1]+1)%mod
        else:
            dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]-dp[n][m]

print((dp[N][M]+1)%mod)

### FIXED CODE ###

from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[0]*(M+1) for i in range(N+1)]

for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            dp[n+1][m+1] = (dp[n+1][m]+dp[n][m+1]+1)%mod
        else:
            dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]-dp[n][m]

print((dp[N][M]+1)%mod)
a,b,k = map(int,input().split())
c = min(a,b)
t = []

for i in range(1,c):
    if a % i == 0 and b % i == 0:
        t.append(i)
print(t[1])




### FIXED CODE ###


a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

for i in range(1,c+1):
    if c % i == 0 and d % i == 0:
        l.append(i)

#print(l)
print(l[-k])
from collections import defaultdict
import heapq


vertice,edge,source = map(int,input().split(" "))
link = defaultdict(dict)
weight = defaultdict(dict)
answer = [-1] * vertice
for e in range(edge):
    i,j,w = map(int,input().split(" "))
    link[i] = link.get(i,set()) | {j}
    weight[i].update({j:w})
goal = v
queue = []
heapq.heappush(queue,(0,source))
heapq.heapify(queue)
while queue:
    #print(queue)
    now_cost,here = heapq.heappop(queue)
    #print(now_cost,here,queue)
    if answer[here] > -1:
        continue
    answer[here] = now_cost

    #print(v,here,now_cost,not_went,queue)
    for nw in link[here]:
        if answer[nw] == -1:
            heapq.heappush(queue,(now_cost + weight[here][nw],nw))

for a in answer:
    print(a if a != -1 else "INF")

### FIXED CODE ###

import sys
from heapq import heappush, heappop
readline = sys.stdin.readline
from collections import defaultdict
vertices, edges, start = map(int, readline().split())
connect = defaultdict(list)
cost = defaultdict(dict)
answer = ["INF" for n in range(vertices)]
for _ in range(edges):
    s, t, w = map(int, readline().split())
    connect[s].append(t)
    cost[s].update({t:w})
 
 
now = start
weight = 0
p_queue = []
heappush(p_queue, (0, now))
visited = set()
while p_queue:
    weight, now = heappop(p_queue)
    if now in visited:
        continue
    visited |= {now}
    answer[now] = weight
    for c in connect[now]:
        if c not in visited:
            heappush(p_queue, (weight + cost[now][c], c))
for a in answer:
    print(a)
sn = int(input())
S = [0 for i in range(sn)]
S = input().split()
for i in range(sn):
	S[i] = int(S[i])

tn = int(input())
T = [0 for i in range(tn)]
T = input().split()
for i in range(tn):
	T[i] = int(T[i])

A=[]
cnt=0

for i in range(tn):

	key=T[i]
	left=0
	right=sn

	while left<right:

		mid=(int)((left+right)/2)

		if S[mid]==key:
			if T[i] not in A:
				cnt+=1
			    A.append(key)
			break

		if S[mid]>key:
			right=mid
			
		if S[mid]<key:
			left=mid+1


print(cnt)


### FIXED CODE ###


sn = int(input())
S = [0 for i in range(sn)]
S = input().split()
for i in range(sn):
	S[i] = int(S[i])

tn = int(input())
T = [0 for i in range(tn)]
T = input().split()
for i in range(tn):
	T[i] = int(T[i])


cnt=0

for i in range(tn):

	key=T[i]
	left=0
	right=sn
	c=0

	while left<right:

		mid=(int)((left+right)/2)

		if S[mid]==key:
			if c==0:
				cnt+=1
				c=1
				
			break

		if S[mid]>key:
			right=mid

		if S[mid]<key:
			left=mid+1


print(cnt)
def start(l):
    for i in range(1, l):
        if S_list[i] == "A":
            return i


def finish(l):
    for i in range(1, l):
        if S_list[l - i] == "Z":
            return l - i


S_list = list(input())
l = len(S_list)
start(l)
finish(l)
print(finish(l) - start(l) + 1)

### FIXED CODE ###

S_list = list(input())
l = len(S_list)
for i in range(l):
    if S_list[i] == "A":
        start = i
        break
for i in range(l):
    if S_list[i] == "Z":
        finish = i


print(finish - start + 1)
if __name__=="__main__":
    X,N = list(map(int,input().split(" ")))
    p = list(map(int,input().split(" ")))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit()

### FIXED CODE ###

if __name__=="__main__":
    X,N = list(map(int,input().split()))
    p = list(map(int,input().split()))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit(0)
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N):
  if p[i] - 1 == i:
    a = p[i]
    b = p[i + 1]
    p[i] = b
    p[i + 1] = a
    ans += 1
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(N):
  if p[i] - 1 == i:
    ans += 1
    if i != N - 1:
      a = p[i]
      b = p[i + 1]
      p[i] = b
      p[i + 1] = a
print(ans)
N = int(input())
A = input().split()

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j
    if

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())

### FIXED CODE ###

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

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())
N,K=map(int,input().split())

S=[[]for i in range(10**1+1)]
for i in range(N):
    a,b=map(int,input().split())
    S[a].append(b)
S.sort(reverse=True)
#print(S)

k=0
o=0
E=[]
for i in range(len(S)):
    if S[i]==[]:
        break
    else:
        k+=1
        o+=S[i][0]
        E.append(S[i][0])
        del S[i][0]
E.sort()
#print(S)
S.sort(reverse=True)
A=[]
for i in range(len(S)):
    if S[i]==[]:
        break
    else:
        for j in range(len(S[i])):
            A.append(S[i][j])
A.sort(reverse=True)
#print(A)
if K-k>0:
    for i in range(K-k):
        o+=A[i]
        #print(i)
    del A[:i+1]
    print(A)
    print(E)
for i in range(min(K,len(A))):
    if k*k+o<(k-1)**2+o-E[i]+A[i]:
        k=(k-1)
        o=o-E[i]+A[i]
    else:
        break
print(k*k+o)

### FIXED CODE ###

Num,K=map(int,input().split())
L=[[]for i in range(Num+1)]
for i in range(Num):
    t,d=map(int,input().split())
    L[t].append(d)
for i in range(1,Num+1):
    L[i].sort(reverse=True)

M=[]
m=[]
for i in range(1,Num+1):
    if len(L[i])>=1:
        M.append(L[i][0])
        if len(L[i])>=2:
            for j in range(1,len(L[i])):
                m.append(L[i][j])
M.sort(reverse=True)
m.sort(reverse=True)
MM=[0]
for i in range(len(M)):
    MM.append(MM[-1]+M[i])
mm=[0]
for i in range(len(m)):
    mm.append(mm[-1]+m[i])
#print(MM)
#print(mm)
ANS=0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,min(K,len(M))+1):
    ANS=max(i*i+MM[i]+mm[min(len(mm)-1,K-i)],ANS)
    #print(ANS,i)
print(ANS)
N,K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

if N <= K:
  print(0)
else:
  del l[0:K]
  print(sum(H))

### FIXED CODE ###

N,K = map(int, input().split())
H = list(map(int, input().split()))
 
H.sort(reverse=True)
 
if N <= K:
  print(0)
else:
  del H[0:K]
  print(sum(H))
a,b= input()
print a*b, 2*(a+b)

### FIXED CODE ###

a,b=map(int,raw_input().split()) #korenazo
print a*b , 2*(a+b)
import deque from collections
s=list(input())
s=deque(s)
t=input()
fot i in range(len(s)):
  if ''.join(s)==t:
    print("Yes")
    exit()
  s.append(s.popleft())
print("No")

### FIXED CODE ###

from collections import deque
s=list(input())
s=deque(s)
t=input()
for i in range(len(s)):
  if ''.join(s)==t:
    print("Yes")
    exit()
  s.append(s.popleft())
print("No")
n,w=map(int,input().split())
wv=[]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    wv.append([a,b])
    v.append(b)
v.sort(reverse=True)
ans=0
w0=wv[0][0]
for i in range(1,n+1):
    wp=w-w0*i
    if wp<0:
        continue
    elif wp>=3*i:
        ans=max(ans,sum(v[:i]))
    else:
        dp=[-1 for iii in range(wp+1)]
        dp[0]=0
        for j in range(n):
            for k in range(wp,-1,-1):
                if dp[k]>=0 and k+wv[i][0]-w0<=wp:
                    dp[k+wv[i][0]-w0]=max(dp[k]+wv[i][1],dp[k+wv[i][0]-w0])
        ans=max(max(dp),ans)
print(ans)


### FIXED CODE ###

n,w=map(int,input().split())
wv=[]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    wv.append([a,b])
    v.append(b)
v.sort(reverse=True)
ans=0
w0=wv[0][0]
wp=3*n+1
dp=[[-1 for jjj in range(n+1)] for iii in range(3*n+1)]
dp[0][0]=0
for i in range(n):
    for jj in range(n-1,-1,-1):
        for k in range(wp-1,-1,-1):
            if dp[k][jj]>=0 and k+wv[i][0]-w0<=wp-1:
                dp[k+wv[i][0]-w0][jj+1]=max(dp[k][jj]+wv[i][1],dp[k+wv[i][0]-w0][jj+1])
for i in range(1,n+1):
    wp=w-w0*i
    if wp<0:
        continue
    elif wp>=3*i:
        ans=max(ans,sum(v[:i]))
    else:
        for j in range(i+1):
            for k in range(wp+1):
                ans=max(dp[k][j],ans)
print(ans)
n,m = map(int,input().split(" "))

city_road_count = [0] * m
for i in range(m):
  a,b = map(int,input.split(" "))
  city_road_count[a-1] += 1
  city_road_count[b-1] += 1
  
for c in city_road_count:
  print(c)

### FIXED CODE ###

n,m = map(int,input().split(" "))

city_road_count = [0] * n
for i in range(m):
      a,b = map(int,input().split(" "))
      city_road_count[a-1] += 1
      city_road_count[b-1] += 1
      
for c in city_road_count:
      print(c)
n = int(input())
a = list(map(int, input().split()))

for i in range(n-1):
    if a[i] < a[i+1]:
        money += (a[i+1]-a[i])*(money//a[i])
print(money)


### FIXED CODE ###

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

money = 1000
for i in range(n-1):
    if a[i] < a[i+1]:
        money += (a[i+1]-a[i])*(money//a[i])
print(money)
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    elif count > answer:
        return
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

def main():
    global answer
    M = int(input())
    L = []
    for i in range(M):
        d, c = map(int, input().split())
        L.extend([d] * c)

    answer = 100
    dfs(0, L)
    print(answer)

if __name__ == '__main__':
    answer = 1000
    main()

### FIXED CODE ###

import sys
import numpy as np

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

M = ni()
D = [] ; C = []

for i in range(M):
    d, c = na()
    D.append(d)
    C.append(c)

D = np.array(D) ; C = np.array(C)
#桁数の9倍とそれぞれの数字の総和をx
x = C.sum() * 9 + (C * D).sum()
# 18以下で終了
answer = (x + 8) // 9 - 2
print(answer)
def resolve():
    a,b,c=sorted(list(map(int,input().split())))
    ans=c-b
    a+=c-b
    b=c
    if (c-a)%2==0: print(ans+(c-a)//2)
    else: print(ans+2+(c-a)//2)
resolve(

### FIXED CODE ###

def resolve():
    a,b,c=sorted(list(map(int,input().split())))
    ans=c-b
    a+=c-b
    b=c
    if (c-a)%2==0: print(ans+(c-a)//2)
    else: print(ans+2+(c-a)//2)
resolve()
N, A, B, C = map(int, input().split())
X = [input() for _ in range(N)]


def solve(x):
    d = {"A": 0, "B": 1, "C": 2}
    ans = []
    for i in range(N):
        u, v = X[i]
        if x[d[u]] == x[d[v]] == 0:
            return

        if x[d[u]] < x[d[v]]:
            x[d[u]] += 1
            x[d[v]] -= 1
            ans.append(u)
        elif x[d[u]] > x[d[v]]:
            x[d[u]] -= 1
            x[d[v]] += 1
            ans.append(v)
        else:
            # x[d[u]] == x[d[v]] >= 1
            if i < N - 1 and X[i] != X[i + 1]:
                x, y = X[i + 1]
                if u == x:
                    x[d[u]] += 1
                    x[d[v]] -= 1
                    ans.append(u)
                else:
                    x[d[u]] -= 1
                    x[d[v]] += 1
                    ans.append(v)
            else:
                x[d[u]] += 1
                x[d[v]] -= 1
                ans.append(u)

    return ans

ans = solve([A, B, C])
if ans:
    print("Yes")
    print(*ans, sep="\n")
else:
    print("No")


### FIXED CODE ###

N, A, B, C = map(int, input().split())
X = [input() for _ in range(N)]


def solve(x):
    d = {"A": 0, "B": 1, "C": 2}
    ans = []
    for i in range(N):
        u, v = X[i]
        if x[d[u]] == x[d[v]] == 0:
            return

        if x[d[u]] < x[d[v]]:
            x[d[u]] += 1
            x[d[v]] -= 1
            ans.append(u)
        elif x[d[u]] > x[d[v]]:
            x[d[u]] -= 1
            x[d[v]] += 1
            ans.append(v)
        elif i < N - 1 and X[i] != X[i + 1]:
            # x[d[u]] == x[d[v]] >= 1
            if u in X[i + 1]:
                x[d[u]] += 1
                x[d[v]] -= 1
                ans.append(u)
            else:
                x[d[u]] -= 1
                x[d[v]] += 1
                ans.append(v)
        else:
            x[d[u]] += 1
            x[d[v]] -= 1
            ans.append(u)

        if x[d[u]] < 0 or x[d[v]] < 0:
            return

    return ans

ans = solve([A, B, C])
if ans:
    print("Yes")
    print(*ans, sep="\n")
else:
    print("No")
T = str(input()).upper()
for i in T:
    if i == 'P' or 'D' and i== '?':
        if i + 'D':
            print(T.replace('?','P'))
        else:
            print(T.replace('?','D'))
    else:
        break

### FIXED CODE ###

t = input()
s = [i for i in t]
if s[0] == "?":
    s[0] = "D"
for i in range(1, len(t) - 1):
    if s[i] == "?":
        if s[i-1] == "D" and s[i+1] == "D":
            s[i] = "P"
        elif s[i-1] == "D" and s[i+1] == "?":
            s[i] = "P"
        else:
            s[i] = "D"
if s[-1] == "?":
    s[-1] = "D"
print("".join(s))
n=int(input())
a=0
m=n
while n>0:
    n=n//10
    a=a+n%10

if m%a==0:
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

n=int(input())
a=0
m=n
if n==0:
    print("No")

else:
    
    while n>0:
        
        a=a+n%10
        n=n//10
    if m%a==0:
        print("Yes")
    else:
        print("No")
N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
        if i == N:
            i = N - 1
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
        if i == -1:
            i = 0
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))