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

m = 0
max_cnt = 0
for i in range(2, N+1, 2):
    cnt = 0
    tmp = i
    while tmp % 2 == 0:
        cnt += 1
        tmp /= 2
    if cnt > max_cnt:
        max_cnt = cnt
        m = i
print(m)
# Judge status: Accepted
def main():
    N, K, *xn = map(int, open(0).read().split())
    ans = int(1e9+7)
    for xl, xr in zip(xn[:], xn[K - 1:]):
        ans = min(ans, xr - xl + min(abs(xr), abs(xl)))
    print(ans)
    return


main()
# Judge status: Wrong Answer
S = input()
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("NO")
# Judge status: Accepted
import sys
N = int(input())
job = []
for _ in range(N):
  job.append(list(map(int,input().split())))
  
job.sort(key=lambda x:x[1])
b = 0
for i in range(N):
  if job[i][1]-job[i][0]< 0:
    print('No')
    sys.exit()
  if i < N-1:
    b += job[i][0]
    job[i+1][1] -= b
print('Yes')
# Judge status: Wrong Answer
import bisect

H=int(input())
A=[2**x for x in range(51)]
if H%4==0:
  H+=1
index=bisect.bisect_left(A,H)
if H==1:
  print(0)
elif H==2:
  print(3)
else:
  print(sum(A[:index]))
# Judge status: Accepted
a=input()
b=len(a)
c="x"
d=b*c
print(d)
# Judge status: Wrong Answer
S = input()
T_1 = S[0]=="A"
T_2 = S[2:-1].count("C")==1
T_3 = S[2:].replace("C", "").islower()
print("AC" if T_1 and T_2 and T_3 else "WA")
# Judge status: Accepted
s = input()
n = len(s)
if n%2==0:
    n -= 1
    s = s[:-1]
while n%2!=0 or s[:n//2]!=s[n//2:]:
    n -= 1
    s = s[:-1]
print(n)
# Judge status: Accepted
import numpy as np

N = int(input())
A = tuple(map(int, input().split()))
A = np.array(A)
A = np.sort(A)

for i in range(N):
    if (i > 0 and A[i-1] == A[i]) or (i < N-1 and A[i] == A[i+1]):
        print('NO')
        break
else:
    print('YES')
# Judge status: Accepted
n = int(input())

a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))

b = [[0] * n, [0] * n]

for i in range(n):
    if i == 0:
        b[0][i] = a[0][0]
        b[1][i] = a[0][0] + a[1][0]
    else:
        b[0][i] = a[0][i] + b[0][i - 1]
        b[1][i] = max(b[0][i], b[1][i - 1]) + a[1][i]

print(b[1][n - 1])
# Judge status: Accepted
A, B = map(int, input().split())
output = 'Yay!'
if A > 8 or B > 8:
    output = ':('
print(output)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
print(B, ' ', C, ' ', A)
# Judge status: Wrong Answer
from collections import defaultdict

def div(n):
    if n % 4 == 0:
        return 3
    elif n % 2 == 0:
        return 1
    else:
        return 0

N = int(input())
a = list(map(int, input().split()))
result = list(map(div, a))

d = defaultdict(int)
d[1] = 0

for i in result:
    d[i] += 1

if d[1] % 2 == 1:
    d[1] -= 1

ans = 0
for c, v in d.items():
    ans += c * v

print("Yes" if ans >= N else "No")
# Judge status: Accepted
n,c,k = [int(x) for x in input().split()]
t = [int(input()) for _ in range(n)]
t.sort()
bus = c
f_bus = 0
ans = 0
for i in range(n):
    if t[i] > f_bus or bus == 0:
        ans += 1
        f_bus = t[i]+k
        bus = c-1
    else:
        bus -= 1

print(ans)
# Judge status: Accepted
N = int(input())
List = []
for i in range(N):
  List.append(list(map(str, input().split())))
Names = []
Points = []
for i in range(N):
  Names.append(List[i][0])
  Points.append(int(List[i][1]))
slName = set(Names)
NewName = list(slName)
NewName.sort()
Points.sort(reverse = True)
for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass
# Judge status: Accepted
w, a, b = map(int, input().split())
if a + w < b:
  print(b - (a + w))
elif b + w < a:
  print(a - (b + w))
else:
  print(0)
# Judge status: Accepted
N = int(input())
S = list(input())
chars = map(lambda c: chr((ord(c) - ord('A') + N) % 26 + ord('A')), S)
print(''.join(chars))
# Judge status: Accepted
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
ans = 0
for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        if a[i+1] >  b[i]-a[i]:
            ans += b[i]-a[i]
            a[i+1] -= b[i]-a[i]
        else:
            ans += a[i+1]
            a[i+1] = 0
print(ans)
# Judge status: Accepted
A, B, M = map(int, input().split())

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

minimum = min(a) + min(b)

for _ in range(M):
  x, y, c = map(int, input().split())
  tmp = a[x-1] + b[y-1] - c
  if tmp < minimum:
    minimum = tmp
    
print(minimum)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    #２の倍数だが４の倍数でない
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    #４の倍数
    elif a[i]%4 == 0:
        count4 += 3

#print(count2,count4)

#count2が1以下か判定
if count2 > 1:
    count4 += count2
else:
    count4 += 0

if count4 >= n:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import itertools
N,M,K=MI()
A=[0]+LI()
B=[0]+LI()
A=list(itertools.accumulate(A))
B=list(itertools.accumulate(B))
j=M
ans=0
for i in range(N+1):
  if A[i]>K:
    break
  while A[i]+B[j]>K:
    j-=1
  ans=max(ans,i+j)
print(ans)
# Judge status: Accepted
N=int(input())
*A,=map(int,input().split())

if N<=2:
    ans=1
else:
    ans=1
    count=(A[0]<A[1])-(A[0]>A[1])
    i=2
    while i<N:
        if count*((A[i-1]<A[i])-(A[i-1]>A[i]))<0:
            ans+=1
            count=0
        else:
            if count==0:
                count=(A[i-1]<A[i])-(A[i-1]>A[i])
        i+=1

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

cnt = 0
ans = 0
tmp = 0
check = 0
for x in s:
    cnt += 1
    if x == '<':
        tmp += 1
        if check != cnt - 1:
            tmp = 0
        ans += tmp
        check = cnt
    else:
        tmp -= 1
        ans += tmp
        if tmp < 0:
            ans += (cnt -  check + 1)
            tmp += 1

print(ans)
# Judge status: Wrong Answer
n=int(input())
l=sorted(list(map(int,input().split())),reverse=True)
count=0
if n<3:
  print("0")
else:
  for i in range(n-2):
    for j in range(i+1,n-1):
      for k in range(j+1,n):
        if l[i]<l[j]+l[k] and l[i]!=l[j]!=l[k]:
          count+=1
print(count)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s = input()
    t = input()
    cunt=0
    for i, ss in enumerate(s):
        if ss != t[i]:
            cunt+=1
    print(cunt)

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
t = 0
for i in range(n):
 q = 0
 for j in range(i):
  q += a[i] < a[j]
 t += q>0
v = 0
for i in range(n):
 q = 0
 for j in range(i+1, n):
  q += a[i] > a[j]
 v += q>0
print("YES" if min(t, v) < 2 else "NO")
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a > b:
  print('Alice')
elif a < b:
  print('Bob')
else:
  print('Draw')
# Judge status: Accepted
import math
x = int(input())
y = math.gcd(x, 360)
print(int(360/y))
# Judge status: Wrong Answer
import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for i in range(M):
    B,C = map(int,input().split())
    D = bisect.bisect_left(A,C)
    if D <= B:
        for j in range(D):
            A[j] = C
    else:
        for j in range(B):
            A[j] = C
print(sum(A))
# Judge status: Accepted
A = input()
a, b, c, d = A[0], A[1], A[2], A[3]
op = '+-'
for i in op:
    for j in op:
        for k in op:
            s = a + i + b + j + c + k + d
            if eval(s) == 7:
                print(s+'=7')
                exit()
# Judge status: Wrong Answer
n = int(input())
x = n // 1.08
if x * 1.08 == n:
    print(x)
else:
    print(':(')
# Judge status: Accepted
import bisect
N=int(input())
ue=list(map(int,input().split()))
naka=list(map(int,input().split()))
sita=list(map(int,input().split()))
sita.sort(),naka.sort(),ue.sort()
count2=[0]*N
count1=[0]*N
for i in range(N):
    m = naka[i]
    k=naka[i]
    small=bisect.bisect_left(ue,k)
    count1[i]=small
    big = bisect.bisect_right(sita, m)
    count2[i]=N-big
ans=0
for i in range(N):
    ans+=count1[i]*count2[i]
print(ans)
# Judge status: Wrong Answer
import sys
X = int(input())

for i in range(-100, 100):
    for j in range(-100, 100):
        cand = i ** 5 - j ** 5
        if X == cand:
            print(i, j)
            sys.exit()
# Judge status: Accepted
n, k = map(int, input().split())
m = n % k
ans = min(m, abs(m - k))
print(ans)
# Judge status: Wrong Answer
N = int(input())
a_list = list(map(str, input().split()))
ans_index = []
before_index = -1
for i in range(len(a_list)):
    a_list[i] = int(a_list[i])
for i in range(len(a_list)):
    val_list = a_list[before_index+1:]
    if val_list.count(i+1) >= 1:
        val = val_list.index(i+1) + before_index
        before_index = val
        ans_index.append(val+1)
    else:
        break

result = N - len(ans_index)
print(result)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
stock = 0
mon = 1000

stock = int(mon / A[0])
mon = mon % A[0]
for i in range(0, n-1):
    if A[i] < A[i+1]:
        stock += mon // A[i]
        mon = mon % A[i]
    else:
        mon += stock * A[i]
        stock = 0
if stock > 0:
    mon += stock * A[n-1]
print(int(mon))
# Judge status: Wrong Answer
H, N = map(int, input().split())
A = list(map(int, input().split()))
print("Yes" if H <= sum(A) else "NO")
# Judge status: Accepted
import itertools as it
import math

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

path = 0
p = it.permutations(xy)
for r in p:
    for i in range(N - 1):
        path += math.sqrt((r[i][0] - r[i + 1][0])**2 +
                          (r[i][1] - r[i + 1][1])**2)

res = path / math.factorial(N)
print(res)
# Judge status: Wrong Answer
from operator import itemgetter

n, m = map(int, input().split())
X = []

ac = [0] * (n+1)
wa = [0] * (n+1)


for _ in range(m):
    x, y = input().split()
    X += [(int(x), y)]

# X = sorted(X, key=itemgetter(0))

for (x, y) in X:
    if ac[x] == 0:
        if y == 'AC':
            ac[x] = 1
        if y == 'WA':
            wa[x] += 1
    print(x, y, sum(ac), sum(wa))


print(sum(ac), sum(wa))
# Judge status: Wrong Answer
s=input();print("YNeos"[s[2::3]<s[3:5]::2])
# Judge status: Wrong Answer
num = []
vote = []
num = list(map(int,input().split()))
vote = list(map(int,input().split()))
N = num[0]
M = num[1]
j = int(sum(vote)/(4*M))
#print(j)

cnt = 0
for i in vote:
    if  i>=j:
        cnt += 1
    
if M<=cnt:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a_sum = 0
b_sum = 0
for i in range(n):
    c.append(b[i]-a[i])
    if c[i] < 0:
        b_sum += c[i]
    else:
        a_sum += c[i]

if a_sum <= abs(b_sum*2):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
X,N = map(int,input().split())
p = sorted(list(map(int,input().split())))
for i in range(X,-1,-1):
    if i not in p:
        ans = i
        break
for i in range(X+1,102):
    if i not in p:
        ans2 = i
        break
if X-ans > ans2-X:
    print(ans2)
else:
    print(ans)
# Judge status: Accepted
import math
print(int(math.sqrt(int(input())))**2)
# Judge status: Accepted
#!python3

# input
N, M = list(map(int, input().split()))

# odd
def solve1():
    return [(i + 2, N - i) for i in range(M)]        


# even
def solve2():
    t = (N - 2) // 4
    l = [(i + 2, N - i) for i in range(t)]
    n = (N - 2) // 2 - t
    l = l + [(N // 2 + 1 + i, N // 2 - i) for i in range(n)]
    return l[:M]


def main():
    l = solve1() if N % 2 else solve2()
    for ans in l:
        print(*ans)
    

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(m):
    #A.sort()
    b,c = map(int,input().split())
    index = bisect.bisect_right(A,c)
    if index == 0:
        pass
    elif b >= index:
        for i in range(0,index):
            A[i] = c
    else:
        for i in range(b):
            A[i] = c
print(sum(A))
# Judge status: Accepted
import sys
N, A, B = map(int, input().split())
if A > B:
    print(0)
    sys.exit()
if N == 1:
    if A != B:
        print(0)
        sys.exit()
    else:
        print(1)
        sys.exit()
else:
    mn = A*(N-1) + B
    mx = A + B*(N-1)
    ans =mx -mn + 1
    print(ans)
# Judge status: Accepted
try:
    s=input()
    p=input()
    count=0
    for i in range(len(s)):
        if s[i]!=p[i]:
            count+=1
    print(count)
except:
    pass
# Judge status: Accepted
a,b=map(int,input().split())
if (a+b)*a*b%3:
    print("Impossible")
else:
    print("Possible")
# Judge status: Accepted
a,b,c = map(int, input().split())
if c-a-b <= 0:
    print("No")
else:
    if 4*a*b < (c-a-b)**2:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
print(min(b,d)-max(a,c))
# Judge status: Wrong Answer
d,n = map(int,input().split())

if n != 100:
	print(100**d*n)
else:
  print(100**d*(n+1))
# Judge status: Accepted
n = int(input())
aa = list(map(int, input().split()))
total = sum(aa)

q = int(input())
from collections import Counter
dic = Counter(aa)
for i in range(q):
    b, c = map(int, input().split())
    nb = dic.pop(b,0)
    total += nb * (c-b)
    print(total)
    dic[c] = dic.get(c,0) + nb
# Judge status: Accepted
N = int(input())
alist = list(map(int, input().split()))

box = [0] * (N + 1)

for i in range(N, 0, -1):
    cnt = 0
    for j in range(i*2, N+1, i):
        cnt += box[j]
    if cnt%2 != alist[i-1]:
        box[i] = 1

M = sum(box)
ans = []
for i in range(1, N+1):
    if box[i]:
        ans.append("{}".format(i))

print(M)
print(" ".join(ans))
# Judge status: Accepted
a,b,c,d = map(int, input().split())
if abs(c - a) <= d or abs(c - b) <= d and abs(b - a) <= d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys
import numpy as np
import numba
from numba import jit

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

@jit
def main(n, a):
  ans = [None]*n
  for i, j in enumerate(a):
    ans[j-1] = i+1
  for i in a:
    print(i, end=' ')
  
  
  
n, *a = map(int,read().split())
main(n, a)
# Judge status: Accepted
s = input()
t = input()
n = len(s)

a = [0 for i in range(26)]
b = [0 for i in range(26)]

for i in range(n):
    a[ord(s[i])-ord("a")] += 1
    b[ord(t[i])-ord("a")] += 1
    
a.sort()
b.sort()

if a == b:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import math

n = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(n):
    x[i]-=i+1
ave=math.floor(sum(x)/len(x))
for i in range(n):
    ans+=abs(x[i]-ave)
print(ans)
# Judge status: Accepted
x=int(input())
x= x// 200
print(10-x)
# Judge status: Accepted
n = int(input())
a = [int(input())for i in range(n)]
b = sorted(a)
for i in range(n):
    if a[i] == b[-1]:
        print(b[-2])
    else:
        print(b[-1])
# Judge status: Accepted
n, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i == 0:
        if A[i] <= x:
            continue
        eat = A[i] - x
        ans += eat
        A[i] = A[i] - eat
        continue
    if A[i-1]+A[i] <= x:
        continue
    eat = A[i-1] + A[i] - x
    ans += eat
    A[i] = A[i] - eat

print(ans)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
x,y=0,0
if a>b:
  x=a
else:
  x=b
if c>d:
  y=c
else:
  y=d
print(x*y)
# Judge status: Accepted
import math

H, A = map(int, input().split(' '))
print(math.ceil(H/A))
# Judge status: Accepted
def main():
  l,r=map(int,input().split())
  ans=10**9
  if any([r//2019>l//2019,r==0,l==0]):
    ans=0
    print(ans)
  else:
    l%=2019
    r%=2019
    for i in range(l,r):
      for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
    print(ans)
main()
# Judge status: Accepted
w,a,b = map(int, input().split())

dx = abs(a-b)
print(max(dx-w,0))
# Judge status: Accepted
n = int(input())
al = list(map(int, input().split()))

als =list(sorted(al))
m = als[n-1]

import bisect
x = bisect.bisect(als,m/2)

if abs(m/2 - als[x-1]) > abs(m/2 - als[x]):
    print(m,als[x])
else:
    print(m,als[x-1])
# Judge status: Wrong Answer
z,a,b=map(int,input().split());print('BA'[(z-a)//(z-b)==0])
# Judge status: Accepted
a,b,c=map(int,input().split())
if min(a,b)<c<max(a,b):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n = int(input())
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        print("Yes")
        exit()
print("No")
# Judge status: Accepted
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x=int(input())
a,b=divmod(x,100)
if a*5>=b:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
K = int(input())
S = input()

if len(S)<=K:
    print(S)
else:
    print(S[:7]+'...')
# Judge status: Accepted
CA=input()
code=ord(CA)
print(chr(code+1))
# Judge status: Wrong Answer
S = sorted(input())
print('Yes' if set(S)==2 and S.count(S[0])==2 else 'No')
# Judge status: Accepted
S = input()
T = input()

if T[:len(S)] == S:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = readline().decode().rstrip()
ans = ''
A = ord('A')
for i in range(len(S)):
    char = chr(A + (ord(S[i])+N-A)%26)
    ans += char
print(ans)
# Judge status: Accepted
N = int(input())

ans = N * (N + 1) // 2 - N
print(ans)
# Judge status: Wrong Answer
n=int(input())
ans=[0,0,0,0]
for i in range(n):
  a=str(input())
  if a=="AC":
    ans[0]+=1
  elif a=="WA":
    ans[1]+=1
  elif a=="TLE":
    ans[2]+=1
  else:
    ans[3]+=0

print("AC x "+str(ans[0]))
print("WA x "+str(ans[1]))
print("TLE x "+str(ans[2]))
print("RE x "+str(ans[3]))
# Judge status: Wrong Answer
D, N = map(int, input().split())
if D == 0 or D % 100 != 0:
  ans = 100 ** D * N
else:
  ans = 100 ** D * (N+1)
print(ans)
# Judge status: Wrong Answer
W = input()
W_list = set(list(s for s in W))
ans = True 
for s in W_list:
    if W.count(s) % 2 != 0:
        ans = False
        break

print(W_list)
if ans:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = float('inf')
dp = [inf] * N
dp[0] = 0

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

print(dp[N-1])
# Judge status: Accepted
a, b = map(int, input().split())

c = (a+b) / 2

print(int(c+0.9))
# Judge status: Wrong Answer
N = int(input())
S = input()

def f(S):
  count = S.count('E')
  for s in S:
    yield count
    count += 1 if s == 'W' else -1

print(min(list(f(S))))
# Judge status: Wrong Answer
K = int(input())
x = 7 % K

for i in range(1, K + 1):
  if x == 0:
    print(i)
    break
  x = (x * 10 + 7) % K

else: print(-1)
# Judge status: Accepted
#-*-coding:utf-8-*-
import sys

def main2():
    n,y=map(int,input().split())
    for i in range(n+1):
        for j in range(n+1-i):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                print(i,j,n-i-j)
                sys.exit()
    print(-1,-1,-1)

if __name__=="__main__":
    main2()
# Judge status: Wrong Answer
#二進数に9は入るか
N = input(int())
if N in [19, 29, 39, 49, 59, 69, 79, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input(),10)


paid = N*800
got = N//15 * 200

print(paid-got)
# Judge status: Accepted
X,N = map(int,input().split())
p = list(map(int,input().split()))

i = 0
j = 0
flag = 0
while True:
    if(X - i in p):
        i += 1
    else:
        flag = 1
        break
    if(X + j in p):
        j += 1
    else:
        flag = 2
        break
if(flag == 1):
    print(X - i)
elif(flag == 2):
    print(X + j)
# Judge status: Accepted
n=int(input())

ans=[]
if(n==0):
    print(0)
    exit()


while n!=0:
    r=n%2
    ans.append(r)
    n=int((n-r)/(-2))

ans.reverse()

for i in ans:
    print(i,end='')
# Judge status: Accepted
N = int(input())
s = input()
if N%2==1:
    print('No')
else:
    if s[:(N//2)]==s[N//2:]:
        print("Yes")
    else:
        print('No')
# Judge status: Wrong Answer
c1 = input().split()
c2 = input().split()
if c1 == c2[-1:] and c2 == c1[-1:]:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)%k
  if a == 0:
    print(i+1)
    quit()
print(-1)
# Judge status: Wrong Answer
w, h, n = map(int, input().split())

xmin, xmax, ymin, ymax = 0,w,0,h

for i in range(n):
    xi,yi,ai = map(int, input().split())
    if ai == 1:
        xmin = xi
    if ai == 2:
        xmax = xi
    if ai == 3:
        ymin = yi
    if ai == 4:
        ymax = yi

if xmax < xmin or ymax < ymin:
    menseki = 0
else:
    menseki = (xmax-xmin) * (ymax-ymin)
print(menseki)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)

#print(A)

if N%2 == 0:
    print(sum(A[:N//2]) * 2 - A[0])
if N%2 == 1:
    #print(A[:N//2+1],A[N//2+1])
    print(sum(A[:N//2+1]) * 2 - A[0] - A[N//2])
# Judge status: Accepted
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
s = sum(a)
if s % 10 > 0:
    print(s)
else:
    m = sorted(i for i in a if i % 10 > 0)
    if len(m):
        print(s - m[0])
    else:
        print(0)
# Judge status: Wrong Answer
import re

def main():
    s = input().replace("?", ".")
    t = input()
    ans = []

    for i in range(len(s)-len(t)+1):
        if not re.match(s[i:i+len(t)], t):
            continue
        tmp = (s[:i] + t + s[i+len(t)+1:]).replace(".", "a")
        ans.append(tmp)

    if not ans:
        print("UNRESTORABLE")
    else:
        print(min(ans))

if __name__ == "__main__":
    main()
# Judge status: Accepted
S, W = [int(i) for i in input().split()]

if S <= W:
  print('unsafe')
else:
  print('safe')
# Judge status: Accepted
mod = 10**9 + 7
n=int(input())
s=list(map(int,input().split()))
s2=sum(map(lambda x: x ** 2,s))
ans=(((sum(s))**2)-(s2))//2%mod
print(ans)
# Judge status: Accepted
# 個数を返す

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

_min = ps[0]
mins = []
for p in ps:
    if p < _min:
        _min = p
    mins.append(_min)

count = 0
for i in range(n):
    if ps[i] <= mins[i]:
        count+=1

print(count)
# Judge status: Accepted
import sys

def solve():
    input  = sys.stdin.readline
    N = int(input())
    array = [[int(a) for a in input().split()] for _ in range(N)]
    count = 0
    for i in reversed(range(N)):
        a, b = array[i]
        if (a + count) % b == 0: continue
        else: count += b - ((a + count) % b)
    print(count)

    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
k = int(input())

cnt = 1
mod = 7

for i in range(k):
    if mod%k == 0:
        break
    cnt+=1
    mod = (mod*10 + 7)%k

if mod%k == 0:
    print(cnt)
else:
    print(-1)
# Judge status: Wrong Answer
import numpy as np

# = int(input())
# = str(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

first = np.asarray(A[:K])
fscore = np.prod(first)


for i in range(K, N):
    fq, score = divmod(fscore, 10**10)
    nextfscore = fscore * A[i] //A[i-K]
    q, nextscore = divmod(nextfscore, 10**10)
    if q > fq or (q == fq and nextscore > score):
        print("Yes")
    else:
        print("No")
    fscore = nextfscore
# Judge status: Accepted
import sys

n, x, y = map(int, input().split())

res = {}

for i in range(1, n + 1):
	for j in range(i + 1, n + 1):
		d = min(abs(i - j), min(abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x)))

		#print(i, j, d)

		if d in res:
			res[d] += 1
		else:
			res[d] = 1

for k in range(1, n):
	if k in res:
		print(res[k])
	else:
		print(0)