peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N=int(input())

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

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(sec)
# Judge status: Accepted
#!/usr/bin/env python3

a = int(input())

print(a+a**2+a**3)
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))
minx = min(x)
maxx = max(x)
list = []
for i in range(minx,maxx+1):
  klist = []
  for j in x:
    k = (j-i)*(j-i)
    klist.append(k)
  #print(klist)
  list.append(sum(klist))
print(min(list))
# Judge status: Accepted
import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter)
# Judge status: Wrong Answer
a,b=input().split()
c=input()
a=int(a)
b=int(b)
d=0
if c[a]=="-":
  for i in range(a):
    if c[i]=="-":
      d=d+1
  if d==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")
# Judge status: Accepted
N = int(input())

ans = 0

for i in range(1,10**9):
    ans += i
    if ans >= N:
        print(i)
        break
# Judge status: Accepted
a , b = map(int , input() . split())
if a == 1 or b == 1 :
    print(1)
elif a * b % 2 == 0 :
    print(a * b // 2)
else :
    print(a * b // 2 + 1 )
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
for i in a:
  if not i%2==0 and (i%3==0 or i%5==0):
    print("DENIED")
    exit()
print("APPROVED")
# Judge status: Accepted
import fractions
def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        if(tmp%i==0):
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    arr.append([1,1])
    if(tmp!=1):
        arr.append([tmp,1])
    return arr
A,B=map(int,input().split())
g=fractions.gcd(A,B)
li=factorization(g)
print(len(li))
# Judge status: Accepted
num=int(input())
date1=input().rstrip().split(" ")
A=int(date1[0])
B=int(date1[1])
C=int((A-A%num)/num)
D=int((B-B%num)/num)
if A%num==0 or B%num==0:
    print("OK")
elif C==D:
    print("NG")
else:
    print("OK")
# Judge status: Accepted
import sys


N, Q = map(int, input().split())
S = input()

AC = [0] * N

for i in range(1, N):
    a = 0
    if S[i - 1] == 'A' and S[i] == 'C':
        a = 1
    AC[i] = AC[i - 1] + a

LR = [map(int, x.split()) for x in sys.stdin.readlines()]

for l, r in LR:
    print(AC[r - 1] - AC[l - 1])
# Judge status: Accepted
x = input()
for i in range(1,len(x)):
    if x[i-1] == x[i]:
        print("Bad")
        break
    if i == len(x)-1:
        print("Good")
        break
# Judge status: Accepted
a,b = map(int,input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

xy.sort(key=lambda x: x[0] + x[1])
mn1, mx1 = xy[0], xy[-1]
xy.sort(key=lambda x: x[0] - x[1])
mn2, mx2 = xy[0], xy[-1]

li = [mn1, mx1, mn2, mx2]
ans = 0
for x1, y1 in li:
    for x2, y2 in li:
        dist = abs(x1 - x2) + abs(y1 - y2)
        ans = max(ans, dist)

print(ans)
# Judge status: Wrong Answer
A,B,X=map(int,input().split())
if A<=X and A+B>=X:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def resolve():
    N = int(input())
    c = [[0] * 10 for _ in range(10)]
    for k in map(str, range(1, N+1)):
        i = int(k[0])
        j = int(k[-1])
        c[i][j] += 1
    n = 0
    for i in range(10):
        for j in range(10):
             n += c[i][j] * c[j][i]
    print(n)

resolve()
# Judge status: Accepted
a,b=map(int,input().split())
if a==1:
    a=100
if b==1:
    b=100
if a>b:
    print('Alice')
elif a==b:
    print('Draw')
else:
    print('Bob')
# Judge status: Accepted
s, c = map(int, input().split())
ans = 0

ans += min(s, c // 2)
c -= ans * 2
ans += c // 4

print(ans)
# Judge status: Wrong Answer
from collections import Counter
from scipy.misc import comb

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

num = 0
for v in c.values():
  if v > 1:
      num += comb(v, 2)

for k in range(N):
  print(num - (c[k]-1))
# Judge status: Accepted
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)
# Judge status: Accepted
total = sum(list(map(int, input().split())))
if total >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
K, X = list(map(int, input().split()))

if 500 * K >= X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

for i in range(1, n):
    a1[i] += a1[i - 1]

for i in range(n - 2, -1, -1):
    a2[i] += a2[i + 1]

res = 0
for i in range(n):
    tmp = a1[i] + a2[i]
    res = max(tmp, res)

print(res)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k = int(input())

a1 = max(a,b,c)
b1 = min(a,b,c)
c1 = (a + b + c) - (a1 + b1)

multipled_num = 2 * k * a1

print(multipled_num + b1 + c1)
# Judge status: Accepted
import copy

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

tlis = copy.deepcopy(lis)

sortlis = sorted(lis)


for i in range(n-1):
    for j in range(i,n):
        tmp = tlis[i]
        tlis[i] = tlis[j]
        tlis[j] = tmp
        if tlis == sortlis:
            print('YES')
            exit()
        else:
            tlis = copy.deepcopy(lis)
            
print('NO')
# Judge status: Accepted
from collections import deque
k = int(input())
a = deque([1,2,3,4,5,6,7,8,9])
count=0
while count !=k:
  b = a.popleft()
  count += 1
  if b%10==0:
    a.append(b*10)
    a.append(b*10+1)
  elif b%10==9:
    a.append(b*10+8)
    a.append(b*10+9)
  else:
    a.append(b*10+b%10-1)
    a.append(b*10+b%10)
    a.append(b*10+b%10+1)
print(b)
# Judge status: Wrong Answer
m = int(input())
if m <= 2 :
  print('2')
else:
  n = 10**5
  primes = set(range(2, n+1))
  for i in range(2, int(n**0.5+1)):
      primes.difference_update(range(i*2, n+1, i))
  primes=list(primes)

  for i in range(len(primes)-1):
    if primes[i] < m and m <= primes[i+1]:
      print(primes[i+1])
# Judge status: Wrong Answer
import math

def check_kai(arr):
    len_a = len(arr)
    check_len = int(math.ceil(len_a/2))
    lef = arr[0:check_len]
    arr.reverse()
    rig = arr[0:check_len]
    if lef == rig:
        return True
    else:
        return False


input = list(input())
N = len(input)

if check_kai(input) and check_kai(input[0:(int((N-1)/2))]) and check_kai(input[int((N+3)/2):]):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a, b, c = input().split()

print("A" + b.upper() + "C")
# Judge status: Wrong Answer
s = input().split(" ")
N = int(s[0])
K = int(s[1])

if N == 0:
    print(K)
elif N == 1 or K == 1:
    print("0")
elif N == K:
    print("0")
elif N % K == 0 or K % N == 0:
    print("0")
elif N % 2 == 0 and K % 2 == 0:
    print("2")
else:
    print("1")
# Judge status: Wrong Answer
import math
a, b = input().split()
ab = int(a + b)
result = math.sqrt(ab)

if result ** 2 == ab:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import bisect

inf = 10**15
mod = 10**9+7

kouho = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = int(input())
ind = bisect.bisect_left(kouho, n)
print(kouho[ind])
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
m = 1e+10
suma = W[0]
sumb = sum(W[1:])
for i in range(1, N):
  suma += W[i]
  sumb -= W[i]
  m = min(m, abs(suma - sumb))
print(m)
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(x * k + y * (n - k))
else:
    print(x * n)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())
a = 0
b = 0
c = 0
e = 0

for i in range(k):
    a = k * x

b = n - k

for d in range(b):
    c = b * y

e = a + c
print(e)
# Judge status: Accepted
import math
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]


def get_1_index(a):
    for i,j in enumerate(a):
        if j==1:
            return i


index=get_1_index(a)

mae=index
usiro=n-index-1

# print(math.ceil(mae/(k-1))+math.ceil(usiro/(k-1)))
print(math.ceil((n-1)/(k-1)))
# Judge status: Accepted
a = input()
a = ord(a)+1
print(chr(a))
# Judge status: Accepted
r, g, b = input().split()

ans = int(r) * 100 + int(g) *10 + int(b)

if ans % 4 == 0:
    print("YES")
elif ans % 4 != 0:
    print("NO")
# Judge status: Accepted
n=int(input())
a= list(map(int, input().strip().split()))
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
ans = min(map(how_many_times_divisible, a))
print(ans)
# Judge status: Wrong Answer
n,k= map(int,input().split())
s=input()
print(s.lower()[k-1])
# Judge status: Accepted
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
res = 0
for i in range(n):
  res += a[i] // 2
  if a[i] % 2 == 1:
    if i != n-1:
      if a[i+1] != 0:
        res += 1
        a[i+1] -= 1
  
print(res)
# Judge status: Accepted
A,B,C=map(int,input().split())
ans='NO'
for i in range(1,B+1):
    if (A*i)%B==C:
        ans='YES'

print(ans)
# Judge status: Accepted
ans=''
a, b = (input() for _ in range(2))

if len(b) < len(a):
    b += ' '
for i, j in zip(a, b):
    ans += i + j
print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
S = list(input())

lis = [1 if s=='#' else 0 for s in S]
from itertools import accumulate
lis = list(accumulate(lis))

ans = 10**18
cnt = 0
for i in range(N-1, -1, -1):
    s = S[i]
    ans = min(ans, cnt+lis[i])
    if s=='.':
        cnt += 1

print(ans)
# Judge status: Wrong Answer
import itertools
import math
import statistics

N = int(input())
direction = [list(map(int,input().split())) for _ in range(N)]
_l = itertools.permutations(direction,N)
l = []
for lst in _l:
	l.append([[0,0]] + list(lst))

s = []
for d in l:
	tmp = 0
	for i in range(len(d)-1):
	  tmp += math.sqrt((d[i+1][0]-d[i][0])**2 + (d[i+1][1]-d[i][1])**2)
	s.append(tmp)
print(sum(s)/len(s))
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]

from collections import Counter

Acnt = Counter(A)

ans = [-1] * 2
for key,cnt in Acnt.items():
    if cnt >= 4:
        if key > ans[0]:
            ans[0] = key
        if key > ans[1]:
            ans[1] = key
    elif cnt >= 2:
        if key > ans[0]:
            ans[0] = key
    
    ans.sort()

if -1 in ans:
    print(0)
else:
    print(ans[0] * ans[1])
# Judge status: Accepted
n = int(input())
p1 = list(map(int, input().split()))
p2 = p1.copy()
p2.sort()
cnt = 0
for i in range(n):
    if p1[i] != p2[i]:
        cnt += 1
if cnt <= 2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s = list(input())
s[3] = "8"
print(*s, sep="")
# Judge status: Accepted
a,b = map(int,input().split())
c = b - a
n = (c - 1) * c // 2
print(n - a)
# Judge status: Wrong Answer
import numpy as np
import itertools
N, M, X = (int(i) for i in input().split())
Y = np.zeros((N, M+1))
for i in range(N):
    Y[i,:] = [int(i) for i in input().split()]
C = Y[:,0]
A = np.matrix(Y[:,1:])
res = np.inf
f = '0'+str(N)+'b'
for i in range(2**N):
    z = np.array([int(s) for s in list(format(i, f))])
    cost = z @ C
    skill = z * A
    if (skill >= X).all() and (cost < res):
        res = cost
if np.isinf(res):
    print(-1)
else:
    print(res)
# Judge status: Accepted
N,X,T=map(int,input().split())

if N%X==0:
    print(str(((N//X))*T))
else:
    print(str(((N//X)+1)*T))
# Judge status: Accepted
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B, X = map(int, input().split())
print("YES" if A <= X <= A + B else "NO")
# Judge status: Accepted
x,y = map(int,input().split())

#最初に反転するか
#1を増やし続ける
#最後に反転するか
#この組み合わせにより4パターンについて計算すればよい

ans=float('inf')
#反転なし、反転なし
if x<=y:
    ans = min(ans,y-x)
#あり、なし
if -x<=y:
    ans = min(ans,y+x+1)
#なし、あり
if x<=-y:
    ans = min(ans,-y-x+1)
#あり、あり
if -x<=-y:
    ans = min(ans,-y+x+2)
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]

def cost(n, m):
  return abs(h[n] - h[m])

dp[0] = 0

for i in range(N):
  for j in range(1, K + 1):
    if (i + j) <= N -1:
      dp[i + j] = min(dp[i + j], dp[i] + cost(i, i + j))

print(dp)
# Judge status: Accepted
n,k=map(int,input().split())
# 累積和！max-min+1
csl=[]
sum=0
for i in range(n+1):
	sum+=i
	csl.append(sum)
#3 2
#[0, 1, 3, 6]
# 0 1 2 3
cnt=0
for i in range(k,n+1):
	max=csl[n]-csl[n-i]
	min=csl[i-1]
	#初めの数も含むの+1
	cnt+=(max-min+1)
	cnt%=(10**9+7)
#0~nまで全選択の+1
print(cnt+1)
# Judge status: Accepted
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    tmp = float("inf")
    ans = 0
    y = float("inf")
    for j in range(m):
        x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if x < tmp or x == tmp and i < y:
            tmp = x
            ans = j + 1
            y = i
    print(ans)
# Judge status: Accepted
X = int(input())
if X==1:
    print(1)
else:
    cmax = 1
    for i in range(2,int(X**0.5)+1):
        k = 2
        while i**k<=X:
            cmax = max(cmax,i**k)
            k += 1
    print(cmax)
# Judge status: Accepted
n, d = map(int, input().split(" "))
ans = 0
for i in range(n):
    x, y = map(int, input().split(" "))
    if (d ** 2 >= x ** 2 + y ** 2):
        ans += 1
print(ans)
# Judge status: Wrong Answer
import numpy as np
import sys
a,b=input().split()
a=float(a)/10000;
b=float(b)*10000;
print(int(float(a)*float(b)))
# Judge status: Accepted
X = int(input())


kouza = 100
count = 0
while X > kouza:
     kouza = int(kouza * 1.01)
     count += 1
print(count)
# Judge status: Accepted
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        if ans is not None:
            if abs(X - x) % ans:
                ans = gcd(ans, abs(X - x))
        else:
            ans = abs(X - xn[0])
    print(ans)
    return


main()
# Judge status: Wrong Answer
N, L = map(str, input().split())
P = list(map(str, input().split()))
U = sorted(list(set([str(i) for i in range(10)])-set(P)))
#print(U)
for i in range(len(N)):
    #print(N[i])
    if N[i] in P:
        #print(N[i])
        for j in U:
            #print(j)
            if j >=N[i]:
                N=N.replace(N[i],j)
                #print(N)
                break
print(N)
# Judge status: Accepted
a, b = input().split()
A = a*int(b)
B = b*int(a)
print(min(A, B))
# Judge status: Wrong Answer
N,K=map(int,input().split())
kari=int(N/K)
M=N-K*(kari)
L=abs(M-K)
B=abs(L-K)
print(min(N,abs(M-K),L,B,abs(M)))
# Judge status: Wrong Answer
_ = int(input())
a = [int(x) for x in input().split()]

answer = 10**10
for y in range(-100, 100):
    acc = 0
    for x in a:
        acc += (x - y) * (x - y)
    answer = min(answer, acc)
print(answer)
# Judge status: Accepted
age, b = map(int, input().split())

if age >= 13:
	print(b)
elif 6 <= age < 13:
	print(b // 2)
else:
	print(0)
# Judge status: Accepted
a,b,c = map(int, input().split())
s = {a,b,c}
if len(s) == 2:
    ans = 'Yes'
else:
    ans = 'No'
    
print(ans)
# Judge status: Accepted
s=input()
if len(set(s))==2 and s.count(s[0])==2:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
a_list = [int(x) for x in input().split()]
s = set()
o = 0
for a in a_list:
    r = a // 400
    if r >= 8:
        o += 1
    else:
        s.add(r)
c = len(s)
print(c if c > 0 else 1, min(c + o, 8))
# Judge status: Accepted
N, K = map(int, input().split())
p = list(map(int, input().split()))

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

for i in range(N):
    a[i+1] = (1+p[i])/2 + a[i]

ans = 0

for i in range(N-K+1):
    ans = max(ans, a[i+K]-a[i])

# print(a)
print(ans)
# Judge status: Wrong Answer
In = [int(i) for i in input()]
flag = 0
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            if eval("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}".format(In[3]))==7:
                print("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}=7".format(In[3]))
                flag = 1
                break
    if flag:
        break
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
cnt=0
for i in range(1,N+1):
    if A[i-1]%2==1 and i%2==1:
        cnt+=1
print(cnt)
# Judge status: Accepted
n,m = map(int,input().split())
h=[]
h.extend(input().split())
h=list(map(int,h))
cnt = [0]*n
cnt2 = [0]*n
ans = 0

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

for p in range(n):
  if cnt[p]==cnt2[p]:
    ans += 1
print(ans)
# Judge status: Accepted
A=input()
B=input()
if A[0]==B[2] and A[1]==B[1] and A[2]==B[0]:
	print("YES")
else:
	print("NO")
# Judge status: Accepted
N = int(input())

count = 0
for i in range(N):
    count += int((N-1)/(i+1))
print(count)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
A = map( lambda x:x//400, A)
A = list(map( lambda x:x if x<8 else 8, A))
cnt8 = A.count(8)
print(cnt8)
A = list(sorted(set(A)))
if 8 in A:
    A.remove(8)
sum = len(A)
if sum == 0 and cnt8 > 0:
    print(1, end=' ')
else:
    print(sum, end=' ')
sum += cnt8
if sum > 8:
    print(8)
else:
    print(sum)
# Judge status: Accepted

import math
import itertools
import statistics
#import collections
n = int(input())
s = input()

x = 0
a = []
for i in range(n):
    if s[i]=="I":
        x += 1
    else:
        x -= 1
    a.append(x)

print(max(max(a), 0))
# Judge status: Accepted
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
cnt = 0

L = sum(A) * (1 / (4 * M))
for i in range(N):
  if A[i] >= L:
    cnt += 1

if cnt >= M:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())
L = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if (i+1)%2 == 1 and L[i]%2 == 1:
        cnt +=1
print(cnt)
# Judge status: Accepted
get_input = input().split()
A1 = int(get_input[0])
A2 = int(get_input[1])
A3 = int(get_input[2])

if A1 + A2 + A3 >= 22:
    print("bust")
else:
    print("win")
# Judge status: Accepted
n,k=map(int,input().split())
h=list(map(int,input().split()))
c=0
if n<=k:
  print("0")
else:
  h.sort()
  for i in range(k):
    h.pop(-1)
  for x in h:
    c+=x
  print(c)
# Judge status: Accepted
N=int(input())
W=[input() for _ in range(N)]

w=set(W)
answer="Yes"

if len(w)==len(W):
    for i in range(1,N):
        if W[i-1][len(W[i-1])-1]==W[i][0]:
            pass
        else:
            answer="No"
            break
    print(answer)
else:
    print("No")
# Judge status: Accepted
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))

dp = [0 for i in range(n)]
dp[0] = abs(k-a[-1]) + a[0]

for i in range(1,n):
    dp[i] = abs(a[i]-a[i-1])

print(sum(dp) - max(dp))
# Judge status: Accepted
N = int (input())

if N < 1000:
    print('ABC')
elif N >= 1000:
    print('ABD')
# Judge status: Wrong Answer
x=input()
x=list(x)
y=int(input())
a=(len(x))

for i in range(a):
	if ord(x[i])+y>=123:
		y=y-(123-ord(x[i]))
		x[i]='a'
while (ord(x[a-1])+y)>=123:
	y=((ord(x[a-1])+y)-97)%26
x[a-1]=chr(y+97)
print(*x,sep='')
# Judge status: Accepted
n, m = map(int,input().split())

result = [j for i in range(n) for j in list(map(int,input().split()))[1:]]
count = 0
for i in range(m):
  if result.count(i+1) == n:
    count+=1

print(count)
# Judge status: Wrong Answer
x,y = map(int,input().split())
#print(x,y)

a = [1,3,5,7,8,12]
#print(a)
b = [4,6,9,11]
c = [2]

if x in a and y in a:
  print("YES")
elif x in b and y in b:
  print("YES")
elif x in c and y in c:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n = int(input())
d1 = [0]*n
d2 = [0]*n
h = 'No'
for i in range(n):
    d1[i], d2[i] = map(int, input().split())
    if i > 2:
        if d1[i] == d2[i]:
            if d1[i-1] == d2[i-1]:
                if d1[i-2] == d2[i-2]:
                    h = 'Yes'
                    break
print(h)
# Judge status: Accepted
n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n+1)
dp[2]=abs(arr[0]-arr[1])
for i in range(3,n+1):
    dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]))
 
print(dp[n])
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

if a < c < b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline


N,M,X,Y=list(map(int,input().split()))
x =list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)

if min(y) - max(x) >0:
    print('No War')
else:
    print('War')
# Judge status: Accepted

s = input()

A = [i for i, x in enumerate(s) if x == "A"]
Z = [i for i, x in enumerate(s) if x == "Z"]

print(max(Z) - min(A) + 1)
# Judge status: Accepted
n=int(input())

L=list(map(int,input().split()))
a=0
b=0

for i in range(n):
	if L[i]%4==0:
		b+=1
	if L[i]%2==1:
		a+=1

if a+b==n and a-b==1:
	print('Yes')
	exit()
if b>=a:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
le = [[p[0]-p[1], p[0]+p[1]] for p in xl]
le.sort(key = lambda x : x[1])

ans = 0
right = -(10 ** 9) - 1
for i in range(n):
    if right <= le[i][0]:
        ans += 1
        right = le[i][1]
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
A = list(map(int,input().split()))

sum_A = sum(A)
A.sort(reverse=True)
x = sum_A/(4*M)
count = 0
for i in range(N):
    if A[i] >= x:
        count += 1
if count >= M:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n, a, b, c, d  = map(int, input().split())
s = input()
ans = 'Yes'
if '##' in s[a:max(c,d)]:
    ans = 'No'
else:
    if c > d and '...' not in s[a-1:c]:
        ans = 'No'
print(ans)
# Judge status: Accepted
import itertools
t = []
for _ in range(5):
    t.append(int(input()))

most_fast = 10**5

for i in itertools.permutations(t,5):
    time = 0
    for j in range(4):
        time += i[j]
        if time % 10 != 0:
            time += 10 - (time % 10)
    time += i[4]
    if time <= most_fast:
        most_fast = time

print(most_fast)
# Judge status: Accepted
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
    exit(0)

for i in range(n//2):
    if s[i] != s[i + n //2]:
        print("No")
        exit(0)

print("Yes")
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
d = 0
i = 1
while True:
  if a % i ==0 and b % i ==0:
    d += 1
  if d == c:
    print(i)
    exit()
  i += 1
# Judge status: Accepted
import sys
readline = sys.stdin.readline

S = readline().strip()
S = list(map(int, S))
N = len(S)
P = 2019

rems = [0] * N
a = 1
b = 0
for i in range(N):
    b = (b + (a * S[N - i - 1]) % P) % P
    rems[N - i - 1] = b
    a = a * 10 % P

rems = rems + [0]

counts = [0] * P


for i in range(len(rems)):
    counts[rems[i]] += 1

ans = 0
for c in counts:
    ans += c * (c - 1) // 2

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

ans = []
while N != 0:
    if N % 2 == 1:
        ans.append("1")
        N -= 1
    else:
        ans.append("0")
    N //= - 2

ans = "".join(ans)[::-1]
print(ans)
# Judge status: Wrong Answer
from collections import deque
K = int(input())
d = deque(range(1, 10))
for i in range(K):
    x = d.popleft()
    if x % 10 != 0:
        d.append(10*x-1)
    d.append(10*x)
    if x % 10 != 9:
        d.append(10*x+1)
print(x)
# Judge status: Accepted
n = int(input())

answer = False
for num_4 in range(n//4+1):
  if (n-num_4*4)%7 == 0:
    answer = True 
    break

if answer :
  print("Yes")
else :
  print("No")