peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, M = map(int, input().split())

To_List = []
for _ in range(M):
    a, b = map(int, input().split())

    if a == 1:
        To_List.append(b)
    if b == N:
        if a in To_List:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")
# Judge status: Accepted
s,t = input().split()
a,b = map(int,input().split())
u = input()

if u == s:
  print(a-1,b)
elif u == t:
  print(a,b-1)
else:
  print(a,b)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
B = iil()
C = iil()

ans = sum(B)

for i in range(1,n):
    if A[i-1] == A[i] - 1:
        ans += C[A[i-1]-1]

print(ans)
# Judge status: Accepted
N = int(input())
pts = [(list(map(int,input().split()))) for _ in range(0,N)]

from itertools import combinations
def f(x1,y1,x2,y2):
    dx = x2 - x1
    dy = y2 - y1
    return (dx**2+dy**2)**0.5
dst = 0
for i,j in combinations(range(0,N),2):
    dst += f(pts[i][0], pts[i][1], pts[j][0], pts[j][1])
print(dst / (N / 2))
# Judge status: Wrong Answer
x,y = map(int,input().split())
print(int(x/y))
# Judge status: Accepted
s = input()
q = int(input())

t = ''
for i in range(q):
    query = input().split()
    if query[0] == '1':
        s,t = t,s
    else:
        if query[1] == '1':
            t += query[2] 
        else:
            s += query[2]

print(t[::-1] + s)
# Judge status: Wrong Answer
s = input()
res = 1
flg = 0
i = 1
while i < len(s)-2:
  if s[i] == s[i-1]:
    i += 3
    res += 2
  else:
    res += 1
    i += 1
if i == len(s):
  print(res)
elif i == len(s)-1:
  if s[-1] == s[-2]:
    print(res)
  else:
    print(res+1)
elif i == len(s)-2:
  if s[-1] == s[-2] == s[-3]:
    print(res+1)
  else:
    print(res+2)
# Judge status: Accepted
def cmb(n, r, MOD):
    r = min(r, n - r)
    n1 = n + 1
    numerator = denominator = 1
    for i in range(1, r + 1):
        numerator = (numerator * (n1 - i)) % MOD
        denominator = (denominator * i) % MOD
    return (numerator * pow(denominator, MOD - 2, MOD)) % MOD


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
print((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)
# Judge status: Wrong Answer
from collections import defaultdict

s = list(map(str, input().rstrip()))
t = list(map(str, input().rstrip()))

d = defaultdict(set)

for x, y in zip(s, t):
    d[y].add(x)

print("Yes" if all([len(x) == 1 for x in list(d.values())]) else "No")
# Judge status: Accepted
s=input()
a = ''
b = ''
c = 0

for i in s:
	a += i
	if a == b:
		continue
	c += 1
	b = a
	a = ''
print(c)
# Judge status: Wrong Answer
import sys
from pprint import pprint

K = int(sys.stdin.readline().strip())
A, B = map(int, sys.stdin.readline().strip().split())
if K == 1:
    print("OK")
else:
    if B - A >= K:
        print("OK")
    else:
        print("NG")
# Judge status: Wrong Answer
s = input()
K = int(input())

ans = []

for i in s:
    if i == "a":
        ans.append("a")
        pass
    
    elif ord(i) + K > ord("z") + 1:
        ans.append("a")
        K -= ord("z") + 1 - ord(i)
    
    else:
        ans.append(i)
        


last = (K + ord(ans[-1]) - ord('a')) % 26
ans[-1] = chr(ord("a") + last)
print(''.join(ans))
# Judge status: Accepted
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>=k:
    a=k*x
    a+=(n-k)*y
else:
    a=n*x
print(a)
# Judge status: Wrong Answer
# https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
    for j in range(i + 1, n):
        pairs.append((i, j))

ans = 0
for i, j in pairs:
    a, b = L[i], L[j]
    l = bisect_left(L, b - a)
    r = bisect_left(L, a - 1)
    if l < r:
        ans += (r - l)
print(ans)
# Judge status: Accepted
import sys
import math

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a, b, x = map(int, readline().split())
    V = a * a * b / 2
    if V < x:
        ans = math.degrees(math.atan((2 * (a * a * b - x)) / a ** 3))
    else:
        ans = math.degrees(math.atan((a * b * b) / (2 * x)))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a=int(input())
b=int(input())
h=int(input())
ans = (a+b)*h/2
print(ans)
# Judge status: Accepted
a, b, k = map(int, input().split())
a1 = a
b1 = b
if k <= a:
    a1 -= k
elif k <= a + b:
    a1 = 0
    b1 -= k - a
else:
    a1 = 0
    b1 = 0
print(a1, b1)
# Judge status: Wrong Answer
contest_num = int(input())

if contest_num <= 999: # 不等号は=の手前に
    print('abc')

elif contest_num >= 1000:
    print('abd')
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
print(c - a + b) if c - a + b > 0 else print(0)
# Judge status: Accepted
n = int(input())
s = input()
if s[:(n//2)]==s[(n//2):]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = str(input())
print('*'*len(S))
# Judge status: Wrong Answer
import bisect
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
        if(N//i!=i):
            arr.append(N//i)
    return arr

N,M=map(int,input().split())
li=sorted(factor(M))
res=1
for i in li:
    if(i>M//N):
        break
    if(M//i>=N):
        res=i
print(res)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse=True)

ans = 0

for i in range(N):
  ans += A[i*2+1]
print(ans)
# Judge status: Wrong Answer
n = int(input())
trans = [ (int(input()) + n - 1) // n for i in range(5) ]
print(max(trans) + 4)
# Judge status: Accepted
a,b=map(int,input().split())
if max(a,b)>min(a,b):
    print(2*max(a,b)-1)
else:
    print(2*a)
# Judge status: Accepted
n = int(input())
S = list(input())

# aを含む -> 個数通り 含まない-> 1
# bを含む -> 個数通り 含まない-> 1
from collections import defaultdict
d = defaultdict(int)
for s in S:
    d[s] += 1
ans = 1
mod = 10**9 + 7
for k in d.keys():
    ans *= (d[k]+1)
    ans %= mod
ans -= 1
print(ans)
# Judge status: Accepted
N = int(input())
S = input()
cnt = 0
for i in range(1, N):
    # スライスで部分文字列をつくって、set型に変換し、積集合で共通する英小文字を取得
    dup_cnt = set(S[:i]) & set(S[i:])
    # 共通する英小文字の数が現時点での最大値より大きいなら最大値を更新
    if cnt < len(dup_cnt):
        cnt = len(dup_cnt)
print(cnt)
# Judge status: Wrong Answer
print('YES' if int(input()) == 3 or 5 or 7 else 'NO')
# Judge status: Wrong Answer
x,a,b=map(int,input().split())
t=a-b
if t>0:
    print('delicious')
else:
    if abs(t)<=x:
        print('safe')
    else:
        print('dangerous')
# Judge status: Accepted
import heapq
N, M = map(int, input().split())
hq = []
for price in map(int, input().split()):
    heapq.heappush(hq, -price)

for i in range(M):
    p = -heapq.heappop(hq)
    p /= 2
    heapq.heappush(hq, -p)

result = -sum([int(p) for p in hq])
print(result)
# Judge status: Accepted
a = input()

a = list(str(a))
a[3]="8"
a="".join(a)

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

ans = 0
for i in range(a, b + 1):
    s = str(i)
    if s[:2][::-1] == s[3:]:
        ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
c=0
m=1
for i in [0]*n:
    a,b=map(int,input().split())
    if a==b:
        c+=1
        if c==3:
            m=0
    else:
        c=0
print('YNeos'[m==1::2])
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def fact(n):
  ans = n
  for i in range(1, n):
    ans *= i
  return ans

def number(lst, n):
  numlst = []
  ans = 1
  for i in range(n):
    numlst.append(i+1)
  for i in range(n):
    for j in range(len(numlst)):
      if lst[i] == numlst[j]:
        ans += j*fact(n-i-1)
        numlst.pop(j)
        break
  return ans

res = number(q, n) - number(p, n)
print(abs(res))
# Judge status: Accepted
n,x = map(int,input().split())
li = list(map(int,input().split()))
cnt = 0
num = 1
for i in li:
    if cnt + i > x:
        break
    else:
        cnt += i
        num += 1
print(num)
# Judge status: Accepted
import itertools
A, B, C, D = input()
for i in itertools.product(['+', '-'], repeat=3):
    if eval(A+i[0]+B+i[1]+C+i[2]+D) ==7:
        print(A+i[0]+B+i[1]+C+i[2]+D+'=7')
        exit()
# Judge status: Accepted
def resolve():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
resolve()
# Judge status: Accepted
a, b, c, k =map(int, input().split())  #複数数値入力

if a+b >= k:
    if a < k :
        print(a)
    else:
        print(k)
else:
    print(a-(k-a-b))
# Judge status: Wrong Answer
N = input()
n = len(N)
ans = int(N[0])-1 + 9*(n-1)
print(ans)
# Judge status: Accepted
A, B, C = map(int,input().split())

if B//A >= C:
    print(C)
else:
    print(B//A)
# Judge status: Accepted
print(input().replace(str(2017), str(2018)))
# Judge status: Accepted
def main():
    N = int(input())
    print(N + N * N + N * N * N)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok
# Judge status: Accepted
a,b,c,d=map(int,input().split())
s='Yes'
if abs(a-c)>d:
  if abs(a-b)>d or abs(b-c)>d:
    s='No'
print(s)
# Judge status: Accepted
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]

t.sort()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
    if t[i] <= key and len_t < c:
        len_t += 1
    else:
        ans1 += 1
        key = t[i]+k
        len_t = 1
ans1 += 1
print(ans1)
# Judge status: Accepted
a,b,c=map(int,input().split())
if (c<=b and a<=c) or c<=a and b<=c:  
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N =int(input())
List = []
for _ in range(N):
  A, B = map(int, input().split())
  List.append([A,B])
List = sorted(List,key=lambda x: x[1],reverse = True)
Limit = List[0][1]
for item in List:
  Limit = min(item[1],Limit) - item[0]
  if Limit < 0:
    print('No')
    exit()
print('Yes')
# Judge status: Wrong Answer
N=int(input())
P=list(map(int,input().split()))
count=0
for i in range(N):
    if P[i]!=i+1:
        count+=1

print("Yes" if count<=2 else "No")
# Judge status: Accepted
N = int(input())


def f(n, lst):
    if n == N:
        print(''.join(map(str, [chr(s + 97) for s in lst])))
    else:
        for i in range(max(lst) + 2):
            f(n + 1, lst + [i])


f(1, [0])
# Judge status: Accepted
N, P = map(int, input().split())
A = [int(x) for x in input().split()]

odd = False
for i in range(N):
    if A[i] % 2 == 1:
        odd = True
        break

if odd:
    print(2**(N-1))
else:
    if P == 0:
        print(2**N)
    else:
        print(0)
# Judge status: Accepted
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i4[::1],)', cache=True)
def solve(A):
    count = np.zeros(10**6 + 10, np.int32)
    for x in A:
        if count[x] > 1:
            continue
        count[::x] += 1
    ret = 0
    for x in A:
        ret += count[x] == 1
    return ret

A = np.array(read().split(), np.int32)[1:]

print(solve(A))
# Judge status: Accepted
def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


n = int(input())
a = tuple(map(int, input().split()))
mod = 10**9 + 7
cnt = [0] * 60
for i in range(n):
    r = a[i]
    for j in range(60):
        if r & 1:
            cnt[j] += 1
        r >>= 1

ans = 0
for i in range(60):
    ans += powmod(2, i, mod) * cnt[i] * (n-cnt[i])
    ans %= mod
print(ans)
# Judge status: Wrong Answer
#MSOL C
import numpy as np

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

def checker(i):
  l = A[i-K:i:]
  return np.prod(l)

bscore = checker(K)
for i in range(K+1,N+1):
  ascore = checker(i)
  if (bscore < ascore):
    print("Yes")
  else:
    print("No")
  bscore = ascore
# Judge status: Accepted
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a > b:
    aa = a - t * v
    bb = b - t * w
    if aa > bb:
        print('NO')
    else:
        print('YES')
elif a < b:
    aa = a + t * v
    bb = b + t * w
    if aa < bb:
        print('NO')
    else:
        print('YES')
else:
    print('YES')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))
m=sum(a)
if m%2==1:
    ans=1
    m-=1
else:
    ans=0
a.insert(0,0)
b=[0]
c=[]
for l in range(n):
    b.append(b[l]+a[l+1])
for l in range(n):
    c.append(abs(m/2-b[l+1]))
print(int(min(c)+ans))
# Judge status: Accepted
inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]
S = input()

S = list(S)
S[K - 1] = S[K - 1].lower()
S = ''.join(S)

print(S)
# Judge status: Accepted
n=list(input())
if '9' in n:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
ans=999999999
n = int(input())
for i in range(1,n//2):
    x=str(i)
    y=str(n-i)
    ans=min(ans, sum(map(int, x))+sum(map(int, y)))
    
print(ans)
# Judge status: Wrong Answer
s=input()
k=10**(len(s)-1)
#print(s,str(int(s)//k*k-1))
print(sum(map(int,str(int(s)//k*k-1))) if len(s)!=1 else s)
# Judge status: Accepted
N, M = map(int, input().split())
S = []
C = []
for i in range(M):
    s, c = map(int, input().split())
    S.append(s-1)
    C.append(str(c))
ans = []
for i in range(10 ** N):
    a = list(str(i))
    if len(a) != N:
        continue
    ansFlag = True
    for i in range(M):
        if a[S[i]] != C[i]:
            ansFlag = False
    if ansFlag:
        ans = a
        break

if ans == []:
    print(-1)
else:
    print("".join(ans))
# Judge status: Wrong Answer
n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,200):
  sqset.add(i**2)
print(sqset)
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      a=x+y
      b=x**2+y**2+x*y-m
      d=a**2-4*b
      if d in sqset:
        if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))
# Judge status: Accepted
k,x=map(int,input().split(' '))

range1=(x-k)+1
range2=(x+k)-1

for i in range(range1,range2+1):
    print(i,end=' ')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
x = abs(a-b)
y = abs(b-c)

if (x%2 == 0 and y%2 == 0): # 差が ぐぐ
    ans = x//2 + y//2
elif (x%2 == 1 and y%2 == 1): #差が きき
    ans = x//2 + y//2 + 1
else: # 差が ぐき or きぐ
    ans = x//2 + y//2 + 2

print (ans)
# Judge status: Accepted
N = int(input())
a = tuple(map(int, input().split()))
x = a[0]
y = sum(a[1:])
mn = abs(x-y)
for i in range(1, N-1):
  x += a[i]
  y -= a[i]
  mn = ab if (ab := abs(x-y)) < mn else mn
print(mn)
# Judge status: Wrong Answer
S = input()
print('2018' + S[:4])
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
MOD = 10 ** 9 + 7

min_lis = [0] * (N + 2)
max_lis = [0] * (N + 2)

for i in range(1, N + 2):
    min_lis[i] = min_lis[i - 1] + (i - 1)
    max_lis[i] = max_lis[i - 1] + (N - i + 1)

answer = 0
for k in range(K, N + 2):
    answer += max_lis[k] - min_lis[k] + 1
print(answer % MOD)
# Judge status: Accepted
n = int(input())
x_list = list(map(int, input().split()))

min_count = 1e10
for i in range(101):
    count = 0
    for x in x_list:
        count += (x - i) * (x - i)
    if count < min_count:
        min_count = count

print(min_count)
# Judge status: Accepted
def f(n):
    if n == 0: return ""
    n -= 1
    return (f(n // 26) + chr(ord("a") + n % 26))

def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    n = input_number()
    ans = f(n)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
from collections import Counter
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
A_counters = Counter(A)
A.sort()
A_set = set(A)
ans = 0
for a in A:
    if a in A_set:
        if A_counters[a] == 1:
            ans += 1
        for i in range(1, A[-1] // a + 1):
            if a * i in A_set:
                A_set.remove(a * i)
print(ans)
# Judge status: Accepted
N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if i != j:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
A,B,C=map(int,input().split())
if((A<C and C<B) or (B<C and C<A)):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
# n, k = 0
n, k = map(int, input().split())
# 0,1,2,3,,,,,,n
# k個選んだ時の最小値と最大値の差をk,k+1,k+2,,,,nと積算する

iResult = 0  # 答え
for i in range(k, n + 2):
#	print(i)
	#	min = 0
	#	max = 0
	#	for j in range(0, i):
	#		print('    ' + str(j))
	#		min = min + j
	#		max = max + n - j
	iResult = iResult + i * (n - i + 1) + 1

print(iResult)
# Judge status: Wrong Answer
N, K = map(int, input().split())
R, S, P = list(map(int, input().split()))
T = list(input())

result = [0] * N
for i,t in enumerate(T):
    if t == "r":
        result[i] = P
    elif t == "s":
        result[i] = R
    else:
        result[i] = S

for i in range(K, N):
    if result[i] == result[i-K]:
        result[i] = 0
print(sum(result))
# Judge status: Accepted
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

s = []

for i in range(N):
  a = sum(A1[0:i+1])+sum(A2[i:])
  s.append(a)

print(max(s))
# Judge status: Accepted
l,r = map(int,input().split())
m = r-l

if m >= 2019:
  print(0)
else:
  cnt = []
  for i in range(l,r):
    for j in range(l+1,r+1):
      cnt.append(i*j%2019)
  print(min(cnt))
# Judge status: Accepted
N, K = map(int, input().split())
S=input()

ch=0
for i in range(N-1):
    if S[i]!=S[i+1]:
        ch+=1
print(min(N-1,N-ch-1+2*K))
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a >= 13:
  print(b)
elif 6 <= a <= 12:
  b /= 2
  print(b)
else:
  b = 0
  print(b)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
    ans[a[i]-1] = i+1
print(ans)
# Judge status: Wrong Answer
K,X=map(int,input().split())
ans='YES'
if 500*K<X:
    ans='NO'
print(ans)
# Judge status: Accepted
import sys
N = str(input())

if '7' in N:
  print('Yes')
  sys.exit()

print('No')
# Judge status: Accepted
n, dr = list(map(int, input().split()))
if n >= 10:
	print(dr)
else:
	print(dr+(100*(10-n)))
# Judge status: Accepted
x=int(input())
if x==3 or x==5 or x==7:
    print("YES")
else :
    print("NO")
# Judge status: Accepted
N , K = map(int,input().split())
dA = [list(map(int,input().split()))for k in range(2*K)]

L = list(sum(dA[1::2],[]))
print(N-len(set(L)))
# Judge status: Accepted
n = int(input())
x = [int(i) for i in input().split()]
hp = []

for p in range(min(x), max(x)+1):
    sum = 0
    for i in x:
        sum = sum + (i-p)**2 
    hp.append(sum)
    
print(min(hp))
# Judge status: Accepted
n = int(input())
num_list = list(map(int,input().split()))

tmp = num_list.copy()
tmp.sort()

mid = tmp[n//2-1]
midu =  tmp[n//2]
for i in num_list:
    if i <= mid:
        print(midu)
    else:
        print(mid)
# Judge status: Accepted
X = input()
 
val = len(X)
sum = 0
for i in X:
    if i == "S":
        sum += 1
    else:
        if sum > 0:
            val -= 2
            sum -= 1
 
print(val)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

now = A[0]
tateyoko = [0, 0]
count = 0
nowflag = False
for i in range(1, N):
  if (A[i] == now) and (not nowflag):
    tateyoko[count] = now
    count += 1
    nowflag = True
  else:
    nowflag = False
  if count == 2:
    break
  now = A[i]
  
print(tateyoko[0] * tateyoko[1])
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
s,t = 0, 0
for e in a:
    if e%4 == 0:
        s += 1
    elif e%2 == 0:
        t += 1

if t == 0:
    if N//2 <= s:
        print("Yes")
    else:
        print("No")
else:
    if (1+N-t)//2 <= s:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
s = input()

a = int(s[:2])
b = int(s[2:])

if 0 < a and a <= 12 and 0 < b and b <= 12:
  print("AMBIGUOUS")
elif a > 12 and 0 < b and b <= 12:
  print("YYMM")
elif 0 < a and a <= 12 and b > 12:
  print("MMYY")
else:
  print("NA")
# Judge status: Accepted
n,m=map(int,input().split())
g=[[] for x in range(n)]
for c in range(m):
    a,b= map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans_list=[-1]*n

queue=[0]

while queue:
    qi=queue.pop(0)
    for gi in g[qi]:
        if ans_list[gi]==-1:
            queue.append(gi)
            ans_list[gi]=qi

print("Yes")
for ans in ans_list[1:]:
    print(ans+1)
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())

hd = h2 - h1
if m1 > m2:
  hd -= 1
  m2 += 60
md = m2 - m1

m = hd * 60 + md

print(m-k)
# Judge status: Accepted
N=int(input())
s=''
if(N==0):
    print(0)
    exit()
while(N!=0):
    m=N%2
    s+=str(m)
    N=(N-m)//-2
print(s[::-1])
# Judge status: Accepted
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in range(1,N-1):
  DP[i+1]=min(DP[i]+abs(h[i]-h[i+1]),DP[i-1]+abs(h[i-1]-h[i+1]))
print(DP[N-1])
# Judge status: Wrong Answer
#DP カエルの奴 A 　配るDP
N=int(input())
S=list(map(int,input().split()))
S.append(100010)
S.append(100010)
DP=[100000000]*100010

DP[0]=0
for i in range(N):
    if DP[i]+abs(S[i]-S[i+1])<DP[i+1]:
        DP[i+1]=DP[i]+abs(S[i]-S[i+1])
    if DP[i]+abs(S[i]-S[i+2])<DP[i+2]:
        DP[i+2]=DP[i]+abs(S[i]-S[i+2])


print(DP[N-1])
print(DP)
# Judge status: Accepted
x, y = map(int, input().split())

if x <= y:
    if 0 <= x * y:
        print(y - x)
    else:
        print(abs(x + y) + 1)
else:
    if 0 < x * y:
        print(x - y + 2)
    elif x * y <= 0:
        print(abs(y + x) + 1)
# Judge status: Accepted
n, d = map(int, input().split())
if(n % (2*d+1)):
    print(n // (2*d+1) + 1)
else:
    print(n // (2*d+1))
# Judge status: Accepted
s = input()
cnt = 0
ans = 0
for c in s:
    if c in "ACGT":
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
print(ans)
# Judge status: Accepted
N, D = map(int, input().rstrip().rsplit())

ans = 0
for i in range(N):
    xi, yi = map(int, input().rstrip().rsplit())
    if D**2 >= xi**2 + yi**2:
        ans += 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
S = input()

l = S.count("(")
r = S.count(")")
S

cnt = 0
for i in range(N):
    if S[i] == "(":
        break
    cnt += 1
l += cnt
S = "(" * cnt + S

cnt = 0
for i in range(r+l)[::-1]:
    if S[i] == ")":
        break
    cnt += 1
r += cnt
S = S + ")" * cnt
                
if l >= r:
    S = S + ")" * (l - r)
else:
    S = "(" * (r - l) + S
    
print(S)
# Judge status: Wrong Answer
def main():
    n = int(input())
    blis = list(map(int, input().split()))

    alis = [blis[0], blis[0]]
    for i in range(2, n):
        alis.append(min(blis[i-2], blis[i-1]))
    if n > 2:
        alis.append(blis[n-2])
    print(sum(alis))


    


if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b = map(int, input().split())
import math
print(math.ceil((a + b) / 2))
# Judge status: Accepted
a = int(input())
print((a//2)*((a+1)//2))
# Judge status: Wrong Answer
n,m = map(int, input().split())

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

dp = [0]*m

for i in range(n):
    for j in range(ab[i][0]):
        k = ab[i][j+1]
        dp[k-1] +=1
        

print(dp.count(m))
# Judge status: Accepted
from collections import *
N = int(input())
C = Counter(input())
 
for n in range(N-1):
    C&=Counter(input())
print(*sorted(C.elements()),sep="")