peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N,K=map(int,input().split())
D=list(map(int,input().split()))

import re 
L=[0,1,2,3,4,5,6,7,8,9]
D=set(D)
L=set(L)
L_D =list(L-D)

while True:
    Value=N
    S_value=str(Value)
    for j in range(len(L_D)):
        S_value=re.sub('{}'.format(L_D[j]),'',S_value)
    if S_value=='':
        print('{}'.format(Value))
        exit(0)
    N+=1
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in range(n):
  l[a[i]-1]=i+1
print(" ".join(map(str,l)))
# Judge status: Wrong Answer
N = input()

if N >= str(999):
    print('ABC')

else:
    print('ABD')
# Judge status: Accepted
import math

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

ac = (a-1) // c
ad = (a-1) // d
bc = b // c
bd = b // d
cd_lcm =  (c * d) // math.gcd(c, d)
acd_lcm = (a-1) // cd_lcm
bcd_lcm = b // cd_lcm

l = b - a + 1

print(l - (bc - ac) - (bd - ad) + (bcd_lcm - acd_lcm))
# Judge status: Accepted
x,y,z=map(int,input().split())
if x%(y+z)>=z :
  print(x//(y+z))
else:
  print(x//(y+z)-1)
# Judge status: Wrong Answer
n = int(input())

count = 0
for i in range(n):
    if i % 2 == 1:
        count += 1
        
print(count / n)
# Judge status: Wrong Answer
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]
print(s)
D = dict()
for st in s:
    if st in D:
        D[st] += 1
    else:
        D[st] = 1
ans = 0
for i in D:
    k = D[i]
    ans += (k*(k-1))//2
print(ans)
# Judge status: Accepted
W,H,x,y = map(int,input().split())

print(W*H/2,int(x*2==W and y*2 == H))
# Judge status: Accepted
#ABC118-B
n,m = map(int,input().split())
anke = []
for i in range(n):
    tmp = list(map(int,input().split()))
    anke.append(tmp[1:])
#print(anke)    
result = []
for i in range(1,m+1):
    flg = True
    for j in anke:
        if i not in j:
            flg = False
            break
    if flg:
        result.append(i)
        

print(len(result))
# Judge status: Accepted
n=int(input())
for i in range(1, 10):
  for s in range(1, 10):
    if i*s==n:
      print("Yes")
      exit()
print("No")
# Judge status: Accepted
#C
K = int(input())
judge=False
num = 7
for i in range(K):
    num = num % K
    #print(num)
    if num == 0:
        print(i+1)
        judge = True
        break
    else:
        num = num*10+7
if judge == False:print("-1")
# Judge status: Accepted
H,A = map(int,input().split())
if A == 0:
    print(0)
b = H/A//1
if H/A > b:
    print(int(b+1))
else:
    print(int(b))
# Judge status: Wrong Answer
import collections
import math


def main():
    x, y = map(int, input().split())

    if x % y == 0 or y % x == 0:
        print(-1)
        return

    k = x * y // math.gcd(x, y)
    print(k - x)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
g=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]

for i in g:
    a,b=i[0],i[1]
    dis=10**10
    ind=1
    for j in range(m):
        x,y=c[j][0],c[j][1]
        now=abs(a-x)+abs(b-y)
        if now<dis:
            dis=now
            ind=j+1
    print(ind)
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()

ac = [0 for _ in range(N+1)]

for i in range(1,N):
  if S[i-1:i+1]=='AC':
    ac[i] = 1

for i in range(1,N):
  ac[i]+=ac[i-1]

for i in range(Q):
  l,r = map(int, input().split())
  print(ac[r-1]-ac[l-1])
# Judge status: Accepted
s = input()
A = ["Sunny", "Cloudy", "Rainy", "Sunny"]
for i in range(3):
    if s == A[i]:
        print(A[i+1])
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

yosen = 0
overseas = 0
for i in range(N):
  if S[i] == "c":
    print("No")
  elif yosen < A + B:
    if S[i] == "a":
      print("Yes")
      yosen += 1
    elif S[i] == "b" and overseas < B:
      print("Yes")
      yosen += 1
      overseas += 1
    else: print("No")
  else: print("No")
# Judge status: Accepted
N = int(input())
ans = float('inf')
ls = []
l = [1]
tmp = 6
while tmp <= 100000:
    l += [tmp]
    tmp *= 6
tmp = 9
while tmp <= 100000:
    l += [tmp]
    tmp *= 9

dp = [float('inf')]*(N+1)
dp[0] = 0
dp[1] = 1
for i in range(N+1):
    for n in l:
        if i-n >= 0:
            dp[i] = min(dp[i],dp[i-n]+1)
print(dp[N])
# Judge status: Accepted
a, b, c = sorted(map(int, input().split()))
print("Yes" if a+b==c else "No")
# Judge status: Accepted
A,B,K = map(int, input().split())

if A >= K:
    A = A - K
    #B = B
elif A+B >= K:
    B = A + B - K
    A = 0
elif A+B < K:
    A, B =0, 0
print(A, B)
# Judge status: Wrong Answer
N = int(input())

if N % 2 == 0:
  print(N / 2)
else:
  print(N // 2 + 1)
# Judge status: Wrong Answer
t=list(input())
if t[-1]=='?':
    t[-1]='D'
for i in range(len(t)-1):
    if t[i]=='?':
        if t[i+1]=='?':
            t[i]='P'
            t[i+1]='D'
        elif t[i+1]=='D':
            t[i]='P'
        else:
            t[i]='D'
print(''.join(t))
# Judge status: Accepted
n = int(input())
if n==1:print(0)
else:print(1)
# Judge status: Accepted
import fractions, functools
input()
print(functools.reduce(fractions.gcd, (int(i) for i in input().split())))
# Judge status: Accepted
a,b = map(int, input().split())

if (a+b)%2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))
h = list()
for i in range(N):
    h.append(int(input()))

h.sort()

print(min(h[:K][-1] - h[:K][0], h[K-1:][-1] - h[K-1:][0]))
# Judge status: Accepted
s = list(map(int,input()))
n = len(s)
count1 = 0
count2 = 0
if n == 1:
    print(0) 
else:
    for i in range(n):
        if i%2 == 0 and s[i] != 0:
            count1 += 1
        elif i%2 != 0 and s[i] != 1:
            count1 += 1
    for i in range(n):
        if i%2 == 0 and s[i] != 1:
            count2 += 1
        elif i%2 !=0 and s[i] != 0:
            count2 += 1
    print(min(count1,count2))
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=1
limit=10**18
flag=True
for x in A:
  if x==0:
    flag=False
    ans=0
if flag:
  for x in A:
    ans=ans*x
    if ans > limit:
      ans=-1
      break
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
l = sorted(list(map(int, input().split())),reverse=True)

if a<=b:
  print(0)
else:
  print(sum(l[b:]))
# Judge status: Accepted
A, B, C = map(int, input().split())
a = abs((A-A//2) - A//2)
b = abs((B-B//2) - B//2)
c = abs((C-C//2) - C//2)
ans = min(a*B*C, A*b*C, A*B*c)
print(ans)
# Judge status: Accepted
n, a, b = map(int, input().split())

mod = 10**9 + 7
res = pow(2, n, mod)

def cmb(n, r, mod):
    r = min(n-r, r)
    if r == 0:
        return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    inv = pow(under, mod-2, mod)
    return over * inv % mod


A = cmb(n, a, mod)
B = cmb(n, b, mod)

print((res - A - B - 1) % mod)
# Judge status: Accepted
def main():
    from math import ceil
    from itertools import accumulate
    from bisect import bisect_left
    n, h, *ab = map(int, open(0).read().split())

    x = max(ab[::2])
    *y, = filter(lambda i: i >= x, ab[1::2])
    y.sort(reverse=True)
    *z, = accumulate(y)

    if z[-1] <= h:
        print(len(y) + ceil((h - z[-1]) / x))
    else:
        print(bisect_left(z, h) + 1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
a1=(a-1)%10
b1=(b-1)%10
c1=(c-1)%10
d1=(d-1)%10
e1=(e-1)%10
ans=-((a//-10)+(b//-10)+(c//-10)+(d//-10)+(e//-10))*10
ans=ans-10+min(a1,b1,c1,d1,e1)+1
print(ans)
# Judge status: Accepted
def myAnswer(S:str)-> str:
   dic = {"a":0,"b":0,"c":0}
   for s in S:dic[s]+= 1
   ans = sorted(dic.values(),reverse = True)
   return "NO" if(max(ans) - min(ans) >=2) else "YES"
def modelAnswer():
   return
def main():
   S = (input())
   print(myAnswer(S))
if __name__ == '__main__':
   main()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
L = sum(a)
l = 0
i = 0
while l < L / 2:
    l += a[i]
    i += 1
if i + 1 <= len(a):
    ans = min(abs(sum(a[:i]) - sum(a[i:])), abs(sum(a[:i + 1]) - sum(a[i + 1:])))
else:
    ans = abs(sum(a[:i]) - sum(a[i:]))
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
if((a*b*c) %2 == 0):
    print(0)
else:
    print(min(b*c, a*c, a*b))
# Judge status: Accepted
n, m = map(int, input().split())

PS = {}
for _ in range(m):
    p, s = input().split()
    try:
        PS[int(p)].append(s)
    except KeyError:
        PS[int(p)] = [s]

a, b = 0, 0
for S in PS.values():
    if "AC" in S:
        for s in S:        
            if s == "AC":
                a += 1
                break
            if s == "WA":
                b += 1

print(a, b)
# Judge status: Accepted
h,n = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) >= h:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    N, M = map(int, input().split())
    if N == 1 and M == 1:
        print(1)
        return
    if N == 1:
        print(M - 2)
        return
    if M == 1:
        print(N - 2)
        return
    ans = (N - 2) * (M - 2)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import heapq
n, m = map(int, input().split())
byte = [[] for _ in range(100001)]

for _ in range(n):
    a, b = map(int, input().split())
    byte[a].append(b)
search = []
day = 1
ans = 0
while day-1 != m:
    for b in byte[day]:
        heapq.heappush(search, -b)
    if not search:
        day += 1
        continue
    tmp = -heapq.heappop(search)
    ans += tmp
    day += 1

print(ans)
# Judge status: Wrong Answer
N=int(input())
S=input()
countB=N
countW=0
i=0
while i<N:
    if S[i]=='.':
        countW+=1
    else:
        break
    i+=1

i=N-1
while i>=0:
    if S[i]=='#':
        countB-=1
    else:
        break
    i-=1

S=S[countW:countB]
print(min(S.count('.'),S.count('#')))
# Judge status: Accepted
n, k = map(int, input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = "a"
elif s[k-1] == "B":
    s[k-1] = "b"
elif s[k-1] == "C":
    s[k-1] = "c"
print("".join(s))
# Judge status: Accepted
n=int(input())
s=input()
b=[0 for i in range(n)]
tmp=0
for i in range(n-1,-1,-1):
    if s[i]=="#":
        tmp+=1
    b[i]=tmp
w=[0 for i in range(n)]
tmp=0
for i in range(n):
    if s[i]==".":
        tmp+=1
    w[i]=tmp
tmp=0
ans=float("inf")
for i in range(n):
    tmp=n-(w[i]+b[i])
    if tmp<ans:
        ans=tmp
print(ans)
# Judge status: Accepted
from collections import Counter

s = str(input())

d = Counter(s)
l = [0] * 3
k = 0
for i, j in d.items():
    l[k] = j
    k += 1
Palindrome = False
for i in range(3):
    if abs(l[i-1] - l[i]) > 1:
        Palindrome = True

if Palindrome:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
a = input()
print("Yes" if a[2]==a[3] and a[4]==a[5] else "No")
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = a.index(1)
c,d = divmod(b,k-1)
ans = c
if d != 0:
    ans +=1
e = n-1 -b
c,d = divmod(e,k-1)
ans += c
if d != 0:
    ans +=1
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(s: str):
    if s[2] == s[3] and s[4] == s[5]:
        print(YES)
    else:
        print(NO)
    return


def main():
    s = sys.stdin.readline().strip()  # type: str
    solve(s)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys

input = sys.stdin.readline

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

x = [0] * N
c = 0

for i in range(N):
    if A[i] < 0:
        c += 1
    x[i] = abs(A[i])

ans = sum(x)
if c % 2 == 1:
    ans -= min(x) * 2

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

if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  print(min(n-max(a,b)+1,min(a,b))+(abs(a-b)-1)//2)
# Judge status: Accepted
N, M = map(int, input().split())
A = [int(s) for s in input().split()]

BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append([c, b])

A.sort()
BC.sort()

bc_index = len(BC)-1
for i in range(len(A)):
    if BC[bc_index][1] == 0:
        bc_index -= 1

    if bc_index < 0:
        break

    if A[i] < BC[bc_index][0]:
        A[i] = BC[bc_index][0]
        BC[bc_index][1] -= 1
    else:
        break

print(sum(A))
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    W, H, x, y = map(int, input().split())
    # y = a * x + b
    try:
        a = (y - H / 2) / (x - W / 2)
        b = y - a * x
        X = -b / a
    except ZeroDivisionError:
        a, b = 0, 0
        X = x

    cnt = (1 if W / 2 == x and H / 2 == y else 0)
    area = (X + W - X) * H / 2

    print(area, cnt)


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

ans = 0
while x < y:
    ans += 1
    x *= 2
else:
    if x == y:
        ans += 1

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

before_turn = []
for i in reversed(A[1::2]):
    before_turn.append(i)

for i in A[::2]:
    before_turn.append(i)

ans = " ".join(map(str, before_turn))

if N % 2 == 0 or N == 1:
    print(" ".join(map(str, before_turn)))
else:
    print(" ".join(map(str, before_turn))[::-1])
# Judge status: Wrong Answer
d=input()
if d=='Christmas':
  print(25)
elif d=='Christmas Eve':
  print(24)
elif d=='Christmas Eve Eve':
  print(23)
else:
  print(22)
# Judge status: Accepted
N=int(input())
#N=1000000000000001
ans=''
alp=list('abcdefghijklmnopqrstuvwxyz')

while N != 0:
  N,mod=divmod(N-1,26)
  ans=alp[mod]+ans
print(ans)
#27 -> aa  26 + 1
# Judge status: Accepted
n, a, b = map(int, input().split())
if a > b:
    print(0)
elif n == 1:
    if a != b:
        print(0)
    else:
        print(1)
else:
    print((a+b+b*(n-2)) - (a+b+a*(n-2)) + 1)
# Judge status: Accepted
def resolve():
  n = int(input())
  plan = []
  for i in range(n):
    t, x, y = map(int, input().split())
    plan.append((t, x, y))

  t = 0
  x = 0
  y = 0

  for p in plan:
    time = p[0] - t
    l = abs(x - p[1]) + abs(y - p[2])
    if l > time or l % 2 != time % 2:
      print('No')
      return
    t, x, y = p

  print('Yes')

  return

if __name__ == "__main__":
  resolve()
# Judge status: Accepted
n = int(input())
s = input()
c = 0
for i in range(n-1):
    xy=set(s[i+1:])&set(s[:i+1])
    c = max(c,len(xy))
print(c)
# Judge status: Wrong Answer
import sys
s = input()
for one in range(97,110):
    c = chr(one)
    if not c in s:
        print(c)
        sys.exit()
print("None")
# Judge status: Wrong Answer
x=int (input())
 
i=0
c=100
d=100
 
while x >= d:
  c=(c*1.01)//1
  d=d+c
  i=i+1
 
 
 
print(i)
# Judge status: Accepted
N, Q = map(int, input().split())
S = '0' + input()
acm_cntAC = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if S[i-1:i+1] == 'AC':
        acm_cntAC[i] = acm_cntAC[i-1] + 1
    else:
        acm_cntAC[i] = acm_cntAC[i - 1]

for _ in range(Q):
    l, r = map(int, input().split())
    if S[l-1:l+1] == 'AC':
        print(acm_cntAC[r] - acm_cntAC[l - 1] - 1)
    else:
        print(acm_cntAC[r] - acm_cntAC[l-1])
# Judge status: Accepted
N = int(input())
S = input()
s = list(S)

cr = 0
cl = 0

for i in s:
  if i == "(":
    cr += 1
  else:
    if cr > 0:
      cr -= 1
    else :
      cl += 1

print("("*cl+S+")"*cr)
# Judge status: Accepted
def main():
    button = [-1]
    n = int(input())
    for i in range(n):
        button.append(int(input()))
    count = 0
    push = 1
    while count <= n:
        push = button[push]
        count += 1
        if push == 2:
            break
    print(count) if count < n else print(button[0])

if __name__ == '__main__':
    main()
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())

print(int(((a+b)*c)/2))
# Judge status: Accepted
l = int(input())

a = l/3
b = l/3
c = l/3

print(a*b*c)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

n,m=map(int,input().split())
h=list(map(int,input().split()))

ans=[True for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        ans[b-1]=False
    elif h[a-1]<=h[b-1]:
        ans[a-1]=False

print(ans.count(True))
# Judge status: Wrong Answer
s = input()
for i in range(((len(s)-1)//2)*2,0,-2):
  s1 = s[:i//2]
  s2 = s[i//2:i]
  if s1 == s2:
    print(i)
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if abs(A - B) > 10 ** 18:
    print("Unfair")
else:
    if K % 2 == 0:
        print(A - B)
    else:
        print(B - A)
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
if b!=0:
	count = n//(a+b)*a + n%(a+b)
	print(count)
else:
	print(a)
# Judge status: Wrong Answer
import heapq
def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    for i,aa in enumerate(a):
        a[i] = -1 * aa
    heapq.heapify(a)
    for i in range(m):
        tmp = heapq.heappop(a) // 2
        heapq.heappush(a,tmp)
    print(sum(a) * (-1))
if __name__=='__main__':
    main()
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())

x=tx-sx
y=ty-sy

route = 'U'*y+'R'*x+'D'*y+'L'*x
route += 'L'+'U'*(y+1)+'R'*(x+1)+'D' + 'R'+'D'*(y+1)+'L'*(x+1)+'U'
print(route)
# Judge status: Wrong Answer
N,M,K=map(int,input().split())
for i in range(N+1):
  for j in range(M+1):
    B=i*M+j*N-i*j
    if B==K:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
N = int(input())
stone = input()
R = stone.count('R')
ans = stone.count('W', 0, R)
print(ans)
# Judge status: Wrong Answer
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
mi = 0
ma = max(a)
m = ma/2
while ma-mi>0.1:
  temp = 0
  for i in range(n):
    temp += ceil(a[i]/m)-1 
    #if a[i]%m==0:
    #  temp-=1
  if temp<=k:
    ma=m
    m=(ma+mi)/2
  else:
    mi = m
    m=(ma+mi)/2
  #print("temp " + str(temp))
  #print("ma " + str(ma)+ " mi " + str(mi) + " m " + str(m))
#print(m)
print(ceil(m))
# Judge status: Accepted
a = int(input())
b = int(input())
if a*b==2:
  print ('3')
elif a*b==3:
  print ('2')
else:
  print ('1')
# Judge status: Accepted
import math

a,b,h,m = map(int,input().split())

time = h*60 + m
ji = math.radians(time*0.5)
hun = math.radians(m*6)

ax = a*math.sin(ji)
ay = a*math.cos(ji)
bx = b*math.sin(hun)
by = b*math.cos(hun)

ans = math.sqrt((ax-bx)**2 + (ay-by)**2)

print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
if A + B < C:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
def ad_list_gen(S):
    l = len(S)
    ad_list = [[] for i in range(l)]
    al_dict = {}

    for i, moji in enumerate(S):
        if moji not in al_dict:
            al_dict[moji] = i
        else:
            ad_list[al_dict[moji]].append(i)
    
    return ad_list

S = input()
T = input()

ad_list = ad_list_gen(S)
ad_list2 = ad_list_gen(T)
if ad_list==ad_list2:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s = "cd"
s1 = sorted(s)
s2 = "abc"


ans = 0
ans2 = 0



for i in s2:
    if s == s2:
        break
    if s1[0] < i:
        ans = ans + 1
        for k in range(0,len(s1)):
            if s1[k] < i:
                ans2 = ans2 + 1
    
if ans != 0 and ans2 != 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()

import re
output ="NO"
s = re.sub('dreameraser', '', s)
s = re.sub('dreamerase', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
if s == "":
    output = "YES"
print(output)
# Judge status: Wrong Answer
en=int(input())

res=en/500+(en%500)/5

print(res)
# Judge status: Wrong Answer
n=int(input())
s=input()

from collections import Counter

ans = 1
for t in Counter(s).values():
    ans*=t

for step in range(1,n//2+2):
    for start in range(n):
#         print(start,step,start+2*step,n)
        if start+2*step>=n:
#             print("out!")
            break
        ans-=len(set((s[start], s[start+step],s[start+2*step])))==3
print(ans)
# Judge status: Wrong Answer
n=int(input())
b =list(map(int,input().split()))
ans = b[0]
for i in range(1,n-1):
        if (i+1)%2 ==0:
                ans +=b[i-1]
        else:
                ans += min(b[i-1],b[i])
ans += b[n-2]

print(ans)
# Judge status: Accepted
#https://atcoder.jp/contests/abc141/tasks/abc141_b

c = input()

ans = "Yes"
odd = ['R','U','D']
eval = ['L','U','D']
for i in range(len(c)):
    if i % 2 == 0 and not c[i] in odd:
        ans = "No"
    elif i % 2 == 1 and not c[i] in eval:
        ans = "No"
print(ans)
# Judge status: Accepted
s = input()
if s.count('N') > 0 and s.count('S') == 0:
    print('No')
    exit()
if s.count('S') > 0 and s.count('N') == 0:
    print('No')
    exit()
if s.count('W') > 0 and s.count('E') == 0:
    print('No')
    exit()
if s.count('E') > 0 and s.count('W') == 0:
    print('No')
    exit()
print("Yes")
# Judge status: Accepted
H,N=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(N)]
ab.sort()

ans=[10**9]*(H+1)
ans[0]=0
i=0
while i<=H:
    for a,b in ab:
        if a+i>H:
            a=H-i
        if ans[i+a]>ans[i]+b:
            ans[i+a]=ans[i]+b
    i+=1

print(ans[H])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
  keta=1<<i
  cnt=0
  for j in a:
    if keta & j:
      cnt+=1
  ans+=((keta%mod)*cnt*(n-cnt))%mod


print(ans%mod)
# Judge status: Wrong Answer
import math
A, B=map(int, input().split())

if B==1:
  print(0)
else:
  if math.ceil(B/A)==1:
    print(1)
  else:
    if (A-1)==1:
      print(B//(A-1))
    else:
      if (B-A)%(A-1)==0:
        print((B-A)//(A-1)+1)
      else:
        print((B-A)//(A-1)+2)
# Judge status: Wrong Answer
s = int(input())
p = 10 ** 9
xp = s % p
yp = s // p
x = p - xp
y = yp + 1

print(0,0,p,1,x,y)
# Judge status: Accepted
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 0
        
m = max(d.values())
ans = []
for t in d:
    if d[t] == m:
        ans.append(t)
ans.sort()
for u in ans:
    print(u)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if abs(a-b)>abs(a-c):
  print("A")
else:
  print("B")
# Judge status: Wrong Answer
s = input()
s.replace(s, 'x' * len(s))
# Judge status: Accepted
n=int(input())
if n%10==9 or n//10==9:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a, b, n = map(int, input().split())
if n < b:
    print(a*n//b)
else:
    print((a*(b-1))//b)
# Judge status: Accepted
s = input()
n = len(s)
print(sum(t != u for t, u in zip(s[:n//2], s[-(-n//2):][::-1])))
# Judge status: Accepted
N = int(input())

ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
S = input()
R = 1000000007

#%%
count = Counter(S)
ans = 1
for c in count.values():
    ans = ans * (c + 1) % R

print(ans - 1)
# Judge status: Accepted
n = int(input())
x = [int(i) for i in input().split()]
a = x.copy()
a.sort()
mid = a[int(n/2)-1]
for i in range(n):
    if x[i] <= mid:
        ans = a[int(n/2)]
    else:
        ans = mid
    print(ans)
# Judge status: Accepted
import numpy as np
N, A, B = list(map(int, input().split()))

count = A + B
hoge1 = N // count
hoge2 = N % count

ans1 = A * hoge1

if hoge2 < A:
    print(ans1 + hoge2)
else:
    print(ans1 + A)
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a*b%2 == 0:
  print('Even')
else:
  print('0dd')
# Judge status: Accepted
K=int(input())

k_mod=0
for i in range(1,K+1):
  k_mod=(10*k_mod+7)%K
  if k_mod==0:
    print(i)
    break
else:
  print(-1)
# Judge status: Accepted
from sys import stdin
from math import ceil, floor
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
s = list(stdin.readline().rstrip())
d = 0
e = 0
for i in range(n):
    if d < a + b and s[i] == "a":
        print("Yes")
        d += 1
    elif d < a + b and e < b and s[i] == "b":
        print("Yes")
        d += 1
        e += 1
    else:
        print("No")
# Judge status: Accepted
N=int(input())

csflist=[]
for i in range(N-1):
  c,s,f=map(int,input().split())
  csflist.append((c,s,f))
#print(csflist)

for i in range(N):
  sec=0
  for j in range(i,N-1):
    c,s,f=csflist[j]
    if sec<s:
      sec=s
    elif sec%f>0:
      sec+=f-(sec%f)
    sec+=c
    #print(i,j,sec)
  print(sec)