peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
X,Y=map(int,input().split())
mod=1000000007

if (X+Y)%3!=0:
    print(0)
    exit()

s=(X+Y)//3
n=(-X+2*Y)//3
m=(-Y+2*X)//3
# print('n={}'.format(n))
# print('m={}'.format(m))
if n<0 or m<0:
    print(0)
    exit()

nm=1
nn=1
# print('nm----')
for i in range(n,n+m+1):
    nm*=i
    nm%=mod
    # print(nm)
# print('nn----')
for i in range(1,n+1):
    nn*=i
    nn%=mod
    # print(nn)

print(nm//nn%mod)
# Judge status: Accepted
s=input()
t=input()
ans=1000
for i in range(len(s)-len(t)+1):
    tmp=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            tmp+=1
    if ans>tmp:
        ans=tmp
print(ans)
# Judge status: Wrong Answer
s=input()
if s=="RRR":
	print(3)
elif s=="RRS"or"SRR":
	print(2)
elif s=="SSR"or"SRS"or"RSS":
	print(1)
else:
	print(0)
# Judge status: Accepted
n, k = map(int, input().split())
d = list(map(int, input().split()))
for i in range(n, 100000):
  for j in d:
    if str(j) in str(i):
      break
  else:
    print(i)
    break
# Judge status: Accepted
a,b=map(int,input().split())

def factorization(n):
    if n < 2:
        return []

    res = []

    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            res.append(i)
            n //= i

    if n > 1:
        res.append(n)

    return res

def gcd(A, B):
    if B == 0:
        return A
    else:
        return gcd(B, A % B)

g=gcd(a,b)
l=factorization(g)

print(len(set(l))+1)
# Judge status: Accepted
s = input() #sys.stdin.readlineは最後が改行

from collections import Counter

c = Counter(s)
cm = c.most_common()

if len(c)==1:
    if len(s)==1:
        print('YES')
    else:
        print('NO')
    exit()

if len(c)==2:
    if len(s)==2:
        print('YES')
    else:
        print('NO')
    exit()

if len(c)==3:
    aa = cm[0][1]
    bb = cm[1][1]
    cc = cm[2][1]
    if aa-cc<2:
        print('YES')
    else:
        print('NO')
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
print(C-(A-B))
# Judge status: Accepted
x = int(input())
for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
# Judge status: Wrong Answer
s=sorted(input())[::-1]
t=sorted(input())[::-1]
print('Yes' if s<t else 'No')
# Judge status: Accepted
import sys
from bisect import bisect_right

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A = [-a for a in A]

    colors = []
    for a in A:
        idx = bisect_right(colors, a)
        if idx == len(colors):
            colors.append(a)
        else:
            colors[idx] = a

    ans = len(colors)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
s = input()

abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' * 2
ans = ''
for i in s:
    ans += abc[abc.index(i)+n]
print(ans)
# Judge status: Accepted
n = input()
if n.count('9') > 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a,b,n = map(int,input().split())
ma = -1
for x in range(0,b):
    ans =  ((a*x)//b) - (a * (x//b))
    print((a * (x//b)))
    if(ans > ma):
        ma = ans
        print(x,ma)
print(ma)
# Judge status: Accepted
a, b, c, k = map(int, input().split())
print((a-b)*(-1)**k)
# Judge status: Accepted
k, n = map(int, input().split())
A = list(map(int, input().split()))


start_diff = A[0] + k - A[-1]
diff = [start_diff]
answer = 0
start = A[0]

for i in range(1, n):
    diff.append(A[i] - start)
    start = A[i]

# print(diff)
# print(start_diff)

answer = sum(diff) - max(diff)
print(answer)
# Judge status: Accepted
string = input()

if string[0] == "7" or string[1] == "7" or string[2] == "7": print("Yes")
else: print("No")
# Judge status: Accepted
from math import factorial
S=int(input())
ans=0
for i in range(S // 3):
  ans+=factorial(S-2*i-3)//factorial(i)//factorial(S-3*i-3)
print(ans%1000000007)
# Judge status: Accepted
from math import log2
N = int(input())
print(2**int(log2(N)))
# Judge status: Accepted
n,m = map(int,input().split())
l = list(map(int,input().split()))
l = sorted(l)

diff = []

if n >= m:
    ans = 0
else:

    for i in range(m-1):
     diff.append(l[i+1]-l[i])

    diff = sorted(diff,reverse=True)

    for i in range(n-1):
        diff.pop(0)
    
    ans = sum(diff)
    

print(ans)
# Judge status: Accepted
S=input()
F=int(S[:2])
L=int(S[2:])

if 0<F<=12:
    if 0<L<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<L<=12:
    print('YYMM')
else:
    print('NA')
# Judge status: Wrong Answer
n,k,q = map(int,input().split())

p = [k]*n
a = [0]*q

for i in range(0,q):
  a[i] = int(input())

for i in range(0,q):
  for j in range(0,n):
    p[j] -= 1
  p[a[i]-1] += 1
  #print(a[i])
  
for i in range(0,n):
  if(p[i] <= 0):
    print("No")
  else:
    print("yes")
# Judge status: Accepted
n=int(input())
a_list= list(map(int, input().split()))
count=0
for i in range(n) :
  if i%2==0 and a_list[i]%2==1 :
    count+=1
    
print(count)
# Judge status: Accepted
import sys
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s)
    c.append(_c)

for i in range(1000):
    flag = True
    if len(str(i)) != n:
        continue
    for j in range(m):
        p = s[j]
        if str(c[j]) != str(i)[p-1]:
            flag = False
    if flag:
        print(i)
        sys.exit(0)

print(-1)
# Judge status: Wrong Answer
s = int(input())
L = [ ]
cnt = 2
while True:
    if s%2 == 0:
        s = s/2
        if s in L:
            print(cnt)
            break
        else:
            L.append(s)
            cnt += 1
    else:
        s = 3*s+1
        if s in L:
            print(cnt)
            break
        else:
            L.append(s)
            cnt += 1
# Judge status: Wrong Answer
N, M = map(int, input().split())

c_min = 1
c_max = 10 ** 5
for i in range(M):
    LM = list(map(int, input().split()))
    c_min = max(c_min, LM[0])
    c_max = min(c_max, LM[1])

print(c_max - c_min + 1)
# Judge status: Wrong Answer
N = int(input())

ans = 0

for i in range (1,N):
    if i % 3 != 0 and i % 5 != 0:
        ans += i 
      
print(ans)
# Judge status: Wrong Answer
a = input()

if a.isupper():
    print("A")
else:
    print("B")
# Judge status: Accepted
s1=list(input())
s2=list(input())

if len(s1)>len(s2):
    s2+=" "

s=[s1,s2]
sT=[list(x) for x in zip(*s)]

for i in range(len(s1)):
    print(sT[i][0],end="")
    print(sT[i][1],end="")
# Judge status: Wrong Answer
N = int(input())
print(int((N*(N-1))/(2)))
# Judge status: Accepted
def main():
    a, b = map(int, input().split())

    ans = 0

    if a == b:
        ans = a * 2
    else:
        ans = max(a,b) * 2 - 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

minus_num = 0
for i in range(n):
  if a[i] < 0:
    minus_num += 1

abs_a = list(map(abs,a))
if minus_num % 2 == 0:
  print(sum(abs_a))
else:
  print(sum(abs_a)-2*min(abs_a))
# Judge status: Wrong Answer
s = input()
q = 'keyence'

j, cnt = 0, 0
flag = False
for i in range(len(s)):
    if s[i] == q[j]:
        j += 1
        if flag:
            cnt += 1
        if j == len(q) - 1:
            break
        flag = False
    else:
        flag = True

if i < len(s)-1:
    cnt += 1

if j == len(q)-1 and cnt <= 1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
s = len(set(input()))
t = len(set(input()))
print("Yes") if s == t else print("No")
# Judge status: Accepted
n,k = list(map(int, input().split()))
lst = list(map(int, input().split()))

count = {}
for i in lst:
    if i in count.keys():
        count[i]+=1
    else:
        count[i]=1
count_sorted = sorted(count.items(), key=lambda x:x[1])
# print(count_sorted)

ans = 0
for i in range(len(count_sorted)-k):
    ans += count_sorted[i][1]
print(ans)
# Judge status: Accepted
N = int(input())

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

MOD = 1000000007
s = sum(A)

ans = 0

for i in range(N):
    s -= A[i]
    ans += A[i] * s

print(ans % MOD)
# Judge status: Accepted
a,b,c = map(int,input().split())
s = b // a
if s > c:
    print(c)
else:
    print(s)
# Judge status: Wrong Answer
x, n = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  print(100)
  exit()
old_diff = 10000
for i in range(1, 101):
  if i in p:
    continue
  else:
    diff = abs(x-i)
    if diff < old_diff:
      ans = i
      old_diff = abs(x-i)

try:
  print(ans)
except:
  print()
# Judge status: Accepted
import sys
input = sys.stdin.readline
from fractions import gcd
 
N=int(input())
a_list = list(map(int, input().split()))
MOD = 10**9+7

def cal_lcm(a, b):
  return int(a*b//gcd(a,b))
 
lcm = 1
ans = 0
for i in range(N):
  lcm_ = cal_lcm(lcm, a_list[i])
  ans = ans*(lcm_//lcm)
  ans = (ans + (lcm_//a_list[i]))
  lcm = lcm_

print(ans%MOD)
# Judge status: Wrong Answer
N=int(input())
a=N*(N+1)
print(a/2)
# Judge status: Accepted
a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
  s = str(i)
  if s == s[::-1]:
    ans += 1
print(ans)
# Judge status: Accepted
import math
N = list(input().split())

N[0], N[1] = N[1], N[0]
N[0], N[2] = N[2], N[0]

print(' '.join(N))
# Judge status: Accepted
from collections import defaultdict

N = int(input())
dic = defaultdict(int)
for i in range(N):
    S = input()
    dic[S] = dic[S] + 1

print("AC x", dic["AC"])
print("WA x", dic["WA"])
print("TLE x", dic["TLE"])
print("RE x", dic["RE"])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
t=sum(a)
s=0
for i in range(n):
  s+=a[i]*a[i]

ans=(t*t-s)//2
ans=ans%(10**9+7)



print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
print(min(str(a)*b, str(b)*a))
# Judge status: Wrong Answer
a = int(input())
s = input()
if a >= 3200:
	print(s)
else:
	print('Red')
# Judge status: Wrong Answer
n , m = map(int, input().split())
id =[]
ch = 1
for i in range(m):
    p , y = input().split()
    p = p.zfill(6)
    id.append([p,y,i])
id.sort(key = lambda x:(x[0],x[1]))
id.append(['X','X','X'])
for i in range(m):
    id[i][1]=str(ch).zfill(6)
    if id[i][0]==id[i+1][0]:
        ch+=1
    else:
        ch=1
id.pop()
id.sort(key = lambda x:x[2])
for i in range(m):
    s = id[i][0]+id[i][1]
    print(s)
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
a.sort()
b = a[N:]
print(sum(b[::2]))
# Judge status: Accepted
S = str(input())

if '2017/01/' == S[:8]:
    print('2018/01/{}'.format(S[8:]))
# Judge status: Accepted
n,k=map(int,input().split())
if n%k==0:
  print(0)
else:
  print(1)
# Judge status: Wrong Answer
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    cnt=0
    for i in range(1,N+1):
        ds=0
        for j in range(4):
            ds+=(i//(10**j))%(10)
        if A<=ds<=B:
            cnt+=i
    print(cnt)
    
if __name__=="__main__":
    main()
# Judge status: Accepted
s = input()
t = input()

res = 'UNRESTORABLE'

def check(s,t):
	if len(s) != len(t):
		return False
	else:
		for i in range(len(s)):
			if s[i] != '?' and s[i] != t[i]:
				return False
		return True

flg = False

for i in range(len(s)-len(t), -1, -1):
	L = len(t)
	sub = s[i:L+i]
	if check(sub,t):
		new = s[:i] + t + s[L+i:]
		flg = True
		break


if flg:
	print(new.replace('?', 'a'))
else:
	print(res)
# Judge status: Accepted
n,m = map(int, input().split())

s = 0
for i in range(1,m+1):
    s |= 1 << i


for i in range(n):
    a = map(int, input().split())
    a = list(a)
    t = 0
    for j in range(1, len(a)):
        t |= 1 << a[j]
    s &= t


ans = 0
for i in range(1,m+1):
    if (s & (1<<i)) != 0:
        ans += 1

print(ans)
# Judge status: Wrong Answer
s = input()

n = len(s)
for i in range(n-1, 1, -1):
    if i % 2 == 0:
        if s[0:i//2] == s[i//2:i]:
            print(i)
# Judge status: Accepted
#abc173b
n=int(input())
s=[]
for i in range(n):
 s.append(input())
print('AC x',s.count('AC'))
print('WA x',s.count('WA'))
print('TLE x',s.count('TLE'))
print('RE x',s.count('RE'))
# Judge status: Wrong Answer
d, t, s = map(int, input().split())
x = d // s
if x < t:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a=list(input())
n=len(set(a))
if n<=2:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
s = input()
s1 = s[::-1]


if s1[0] == 's':
    s2 = s1.replace('s', 'se', 1)
    s = s2[::-1]
else:
    s = s + 's'
print(s)
# Judge status: Wrong Answer
a, b, c, d = [int(e) for e in input().split(" ")]
print(a, b, c, d)
if(0 <= a or 0 <= c):
    print("A")
    print(b * d)
elif((a < 0 and b < 0) and (0 <= c and 0 <= d)):
    print("B")
    print(b * c)
elif((c < 0 and d < 0) and (0 <= a and 0 <= b)):
    print("C")
    print(d * a)
elif(a < 0 and b < 0 and c < 0 and d < 0):
    print("D")
    print(a * d)
elif((a < 0 and 0 <= b) and (c < 0 and 0 <= d)):
    print(max((a * c), (b * d)))
# Judge status: Wrong Answer
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0]*n
for i in range(n,0,-1):
  s=0
  t=i
  while t<=n:
    s+=a[t]
    t+=i
  if s%2==a[i]%2:
    b[i-1]=a[i]%2
  else:
    b[i-1]=(a[i]+1)%2
ans=0
c=[]
for i,bb in enumerate(b):
  if bb>0:
    ans+=bb
    c.append(i+1)
print(ans)
print(*c)
# Judge status: Wrong Answer
N = int(input())
L = set({})
count = 0
for i in range(N):
    L.add(input())
    count += 1
print(count)
# Judge status: Accepted
a, b = [int(i) for i in input().split()]

multiply = a * b

if multiply % 2 == 0:
  print("Even")
else:
  print("Odd")
# Judge status: Wrong Answer
a,b,c, d = map(int,input().split())

print(max(a*c,b*d,b*c,a*d,0))
# Judge status: Wrong Answer
A=input()
B=input()
nk=A.split()
N=int(nk[0])
K=int(nk[1])
list=B.split()
list_2=sorted(list)
sum=0
for i in range(K):
  sum+=int(list_2[i])
print(sum)
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
for i in range(N):
    a[i]//=400

ans=0
for i in range(8):
    if i in a:
        ans+=1
y=0
for x in a:
    if x>=8:
        y+=1
print(max(ans,1),ans+y)
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
rest = 0
for a in A:
    ans += (a + rest) // 2
    rest = 1 if (a + rest) % 2 == 1 and a > 0 else 0

print(ans)
# Judge status: Wrong Answer
def main():
	n = int(input())
	# n,m = map(int,input().split())
	#1行R列
	# a = list(map(int,input().split()))
	#R行1列
	l = [str(input()) for i in range(n)]
	#R行C列
	# a = [list(map(int,input().split())) for x in range(m)]
	# print(' '.join(map(str,)))

	# i = 0
	print(max(l[1:n]))
	m = max(l[1:n])

	# 0 < i < n
	for i in range(1,n):
		if l[i] == m:
			print(max(l[0:i],l[i+1:n]))
		else:
			print(m)


if __name__ == '__main__':
	main()
# Judge status: Accepted
N,K,Q = list(map(int,input().split()))
A = [K] * N
C = 0
for i in range(Q):
  B = int(input())
  A[B-1] += 1
  C += 1
for j in range(N):
  if A[j] > C:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
N = int(input())

res = []
sign = 1
while N:
    if N%2 == 0:
        res.append(0)
    else:
        N -= sign
        res.append(1)
    N //= 2
    sign *= -1
if not res:
    res = [0]
print(*reversed(res),sep='')
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())
    num = 1
    ans = 0
    for i in range(1, 21):

        ans = a * i - (i-1)
        if ans >= b:
            print(i)
            break
    
        


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
if N == 1:
  print(input())
else:
  A = 0
  B = 0
  a = list(map(int,input().split()))
  a.sort()
  a.reverse()
  for i in range(N):
    if i % 2 == 0:
      A += a[i]
    else:
      B += a[i]
  print(A - B)
# Judge status: Wrong Answer
N,K,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [0 for i in range(N)]
for x in A:
  B[x-1] += 1
print(B)
for x in B:
  k = Q - x
  if K - k > 0:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
s = str(input())
t= str(input())
sl = len(s)
tl = len(t)

if(t[:-1]==s):
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
#--management

member = int(input())
mem_number = [int(i) for i in input().split()]

ans = []

ans = [0] * member
print(ans)

for j in range(1,member):
  k = mem_number.count(j)
  ans[j-1] = k

for i in  range(member):
  print(ans[i])
# Judge status: Accepted
n, m = map(int, input().split())
ans = m//n
t = []
for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        t.append(i)
        t.append(m//i)
t = sorted(t,reverse = True)
for i in t:
    if i <= ans:
        print(i)
        break
# Judge status: Wrong Answer
def main():
	A,B = map(int, input().split())
	A,B = max(A,B), min(A,B)
	G = gcd(A,B)
	# G:最大公約数, L:最小公倍数
	# AB=GL
	L=A*B/G
	print(int(L))

def gcd(a,b):
	print(a,b,divmod(a,b))
	if a%b==0:
		return b
	return gcd(b, a%b)


if __name__ == '__main__':
	main()
# Judge status: Accepted
N = int(input())
N -= 1

alp = "abcdefghijklmnopqrstuvwxyz"



ans = ''
while N >= 0:
    j = N % 26
    if N == 0:
        ans += alp[j]
        break
    else:
        N = N // 26 - 1
        ans += alp[j]

print(ans[::-1])
# Judge status: Accepted
n=input()
 
if n[0] == "7" or n[1] == "7" or n[2] == "7":
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b = map (int, input ().split ())
x = 0
for i in range (b-a):
  x += i
print (x-a)
# Judge status: Accepted
N = int(input())
def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)
print(num2alpha(N))
# Judge status: Accepted
a,b=map(int,input().split())
if a==1:
  a=14
if b==1:
  b=14
if a>b:
  print('Alice')
elif b>a:
  print('Bob')
else:
  print('Draw')
# Judge status: Accepted
x = int(input())

money = 100
count = 0

for i in range(x+1):
    money = int(money*1.01)
    count += 1
    if money >= x:
        print(count)
        break
# Judge status: Accepted
N = int(input())
s = input()
t = input()
for i in range(0,N+1):
    ss = s[:i]+t
    if ss[:N] == s and ss[len(ss)-N:] == t:
        print(len(ss))
        exit()
# Judge status: Accepted
N = int(input())
ans = list(map(int, input().split()))
for _ in range(1, N):
    a, b, c = map(int, input().split())
    tmpa, tmpb, tmpc = ans
    ans[0] = a + max(tmpb, tmpc)
    ans[1] = b + max(tmpa, tmpc)
    ans[2] = c + max(tmpa, tmpb)

print(max(ans))
# Judge status: Accepted
a,b,c=map(int,input().split())
if a<c<b or b<c<a:
    ans="Yes"
else:
    ans="No"
print(ans)
# Judge status: Accepted
input = list(map(int,input().split()))

a = [input[0], input[1]]
b = [input[2], input[3]]

if a[0] > b[0]:
    a, b = b, a

if a[1] <= b[0]:
    print(0)
elif b[1] <= a[1]:
    print(b[1] - b[0])
else:
    print(a[1] - b[0])
# Judge status: Accepted
n, m = map(int, input().split())
table = [0 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    table[a-1] += 1
    table[b-1] += 1
for i in table:
    print(i)
# Judge status: Accepted
n,d = map(int,input().split())
p = n//(2*d+1)
q = n%(2*d+1)
print(p if q==0 else p+1)
# Judge status: Accepted
N, M = map(int, input().split())

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

if ans[0] == 0 and N != 1:
  neg = -1

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if N == 1:
  pass

elif ans[0] == 0:
  ans[0] = 1

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

while True:
    S = S[:-2]
    half = len(S) // 2
    if S[:half] == S[half:]:
        ans = len(S)
        break

print(ans)
# Judge status: Accepted
from collections import deque
 
N,M=map(int,input().split())
 
graph=[[]for _ in range(N+1)]
 
for _ in range(M):
    A,B=map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)
 
dist=[-1]*(N+1)
dist[0]=0
dist[1]=0
 
D=deque()
D.append(1)
 
while D:
    V=D.popleft()
    for i in graph[V]:
        if dist[i]!=-1:
            continue
        dist[i]=V
        D.append(i)
 
print('Yes')
for j in dist[2:]:
    print(j)
# Judge status: Wrong Answer
n = int(input())
w = [input() for _ in range(n)]
e = w[1][-1]
cnt = 1

for i in range(1, n):
    if w[i][0] == e:
        cnt += 1
        e = w[i][-1]

if cnt == n and len(set(w)) == n:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def resolve():
    cands = [111,222,333,444,555,666,777,888,999]
    N = int(input())
    import bisect
    print(cands[bisect.bisect_left(cands, N)])

if '__main__' == __name__:
    resolve()
# Judge status: Accepted
d,n=map(int,input().split());print((n+n//100)*(100**d))
# Judge status: Accepted
A,B,C=map(int,input().split())
l=[A,B,C]
l.sort()
#print(l)
if l[1]==C:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=input()
b=input()

z=b[:-1]

c=len(a)
d=len(b)-1

if a==z and c==d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b,k=map(int,input().split());print(*[i for i in range(a,b+1)if(i>=a+k)*b-k<i])
# Judge status: Accepted
import collections

N=int(input())
S=[input() for i in range(N)]

lis=collections.Counter(S)

max_lis_v=sorted(list(lis.values()))[-1]
lis_i=sorted(list(lis.items()))

for i in lis_i:
    if i[1]==max_lis_v:
        print(i[0])
# Judge status: Accepted
a, b, c, d = map(int, input().split())
if abs(a - c) <= d or max(abs(a - b), abs(b - c)) <= d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = input()
pattern = 'hi'
cnt = len(S)//2
for _ in range(cnt-1):
    pattern += 'hi'

if S == pattern:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())

if(n%9==0):
    print("Yes")

else:
    print("No")
# Judge status: Wrong Answer
lst = list(input().split())
print(lst)
for i in range(5):
    if lst[i] == "0":
        print(i + 1)
# Judge status: Accepted
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = readline().decode('utf-8').strip()
    T = readline().decode('utf-8').strip()
    L = len(S)
    ans = 0
    for i in range(L):
        if S[i]!=T[i]:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
#AtoZString
s = str(input())
print(s.rfind('Z') - s.find('A') + 1)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=lambda x:x[1])
A.sort()

ans = []
for b,c in BC:
  n = len(ans)
  for i in range(b):
    if n >  N-1: break
    if A[n] < c:
      ans.append(c)
      n += 1
    else: break

print(sum(ans) + sum(A[len(ans):]))
# Judge status: Accepted
N = int(input())
B = [pow(6,i) for i in range(1,10) if pow(6,i)<=N]
C = [pow(9,i) for i in range(1,10) if pow(9,i)<=N]
A = sorted(B+C+[1])
L = len(A)
DP = [[N]*(N+1) for i in range(L)]
DP[0] = [i for i in range(N+1)]
for l in range(1,L):
    k = A[l]
    for n in range(0,k):
        DP[l][n] = DP[l-1][n]
    for n in range(k,N+1):
        DP[l][n] = min(DP[l-1][n-k]+1,DP[l][n-k]+1,DP[l-1][n])
print(DP[L-1][N])
# Judge status: Accepted
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    p, q, r = map(int, input().split())
    print(sum([p, q, r]) - max(p, q, r))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(sorted(map(int, input().split())))

ans = A[0]
for i in range(N):
  for j in range(i+1,N):
    if 0 < A[j]%A[i] < ans :
      ans = A[j]%A[i]
    if ans == 1:
      break


print(ans)
# Judge status: Accepted
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
GCD= a[0]
dp = [set() for i in range(n)]
dp[1].add(a[0])
dp[1].add(a[1])
for i in range(1,n):
    x = a[i]
    for j in dp[i-1]:
            dp[i].add(gcd(j,x))
    if x % GCD != 0:
        dp[i].add(GCD)
        GCD = gcd(GCD,x)
print(max(dp[n-1]))
# Judge status: Accepted
D, N = map(int, input().split())
if N == 100:
    N += 1
print(N * 100 ** D)