peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N=int(input())
p=list(map(int,input().split()))
q=sorted(p)
count=0
for i in range(N):
  if p[i]!=q[i]:
    count+=1
  if count<=2:
    print('YES')
  else:
    print('NO')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_diffA = 0
sum_diffB = 0
for i, (ai, bi) in enumerate(zip(A,B)):
    if ai == bi:
        continue
    elif ai > bi:
        sum_diffB += (ai - bi)
    elif ai < bi:
        diffA = (bi - ai)
        sum_diffA += diffA // 2 + diffA % 2
        sum_diffB += diffA % 2
if sum_diffA >= sum_diffB:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,A,B = list(map(int,input().split()))
another=1+1*N
ans =A
N -= A-1
ans += N//2 * (B-A)
ans += N%2
print(max(ans,another))
# Judge status: Accepted
S, W = map(int, input().split())

print("unsafe") if W >= S else print("safe")
# Judge status: Accepted
S = input()
x = ['A', 'C', 'T', 'G']

i = 0
count = 0
ans = 0
while i < len(S):
    if S[i] in x:
        count += 1
        ans = max(ans, count)
    else:
        count = 0
    i += 1
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
m = 0
m = max(m, b-a)
m = max(m, c-a)
m = max(m, d-a)
m = max(m, e-a)
m = max(m, c-b)
m = max(m, d-b)
m = max(m, e-b)
m = max(m, d-c)
m = max(m, e-c)
m = max(m, e-d)
if m > k:
    print(":(")
else:
    print("Yay!")
# Judge status: Accepted
import math
x=int(input())
ans=1
for i in range(2,math.ceil(x**(0.5))):
  j=2
  tmp = i**j
  while tmp<=x and x!=1:
    ans = max(ans, tmp)
    j+=1
    tmp = i**j
print(ans)
# Judge status: Wrong Answer
X, K, D = map(int, input().split())
a = 1

if X < 0:
  X *= -1
if X > K*D:
	print(X - K*D)
else:
  for i in range(K):
    if X - D*i > 0:
      a += 1
    if -(X - D*a) > (X - D*(a - 1)):
      X -= D*(a - 1)
    else:
      X = (X - D*a)
    
    print(X)
    break
# Judge status: Wrong Answer
a = list(map(int, input().split()))
b = 0
for i in range(a[0]):
    if i % 15 == 0:
        b = b
    elif i % 3 == 0:
        b = b
    elif i % 5 == 0:
        b = b
    else:
        b += i
print(b)
# Judge status: Accepted
L=list(map(int,input().split()))
S=sorted(L)
if S[0]+S[1]==S[2] or S[0]==S[1]+S[2]:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
w,a,b = map(int, input().split())
if b>a+w:
  print(b-a-w)
elif a>b+w:
  print(a-b-w)
else:
  print(0)
# Judge status: Wrong Answer
x, y = map(int, input().split())

for i in range(y):
    if x * 2**i <= y:
        continue
    else:
        print(i)
        break
# Judge status: Wrong Answer
t=int(input())
if(360%t==0):
  print(int(360/t))
else:
  t=360/t
  s=360%t
  print(t*s)
# Judge status: Wrong Answer
import sys
readline = sys.stdin.readline

A,B,X = map(int,readline().split())

bottle = (A ** 2) * B
x = -1
y = -1
import math
area = X / A
if X < bottle / 2:
  y = (X * 2 / B) / A
  x = B
  print(90 - math.degrees(math.atan(y/x)))
else:
  print("kocchi")
  x = (bottle - X) * 2 / (A ** 2)
  y = A
  print(x,y)
  if x == 0:
    print(0)
  else:
    print(90 - math.degrees(math.atan(y/x)))
# Judge status: Accepted
x=int(input())
for a in range(120):
  for b in range(-99,a):
    if a**5-b**5==x: print(a,b); exit()
# Judge status: Accepted
s,w=map(int, input().split())
if s<=w:
    print('unsafe')
else:
    print('safe')
# Judge status: Wrong Answer
a,b=map(int,input().split())
print(max(a+b,a+b-24))
# Judge status: Wrong Answer
import math
 
N = int(input())
N1 = N
use_li = [0]*(math.ceil(math.sqrt(N))+1)
c = 0
while N!=1:
  for i in range(2,math.ceil(math.sqrt(N))+1):
    if(N%i==0 and use_li[i]==0):
      #print(i)
      use_li[i] = 1
      N //= i
      c += 1
      break
  #print(N,i,math.ceil(math.sqrt(N)))  
  if (i==math.ceil(math.sqrt(N))):
    if((len(use_li)<=N or use_li[N] == 0) and N==N1):
      c += 1
    break
      
print(c)
# Judge status: Accepted
S = input()
ss = str()
for s in S:
  ss = ss + s
  if len(ss)==3:
    print (ss)
    break
# Judge status: Accepted
a,b,x = map(int,input().split())
if a==0 and b==0:
    print(1)
elif a == 0:
    print(b//x+1)
else:
    print(b//x - (a-1)//x)
# Judge status: Accepted
S = input()
ACGT = 'ACGT'
ans = 0
temp = 0
for x in S:
    if x in ACGT:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0
ans = max(ans, temp)
print(ans)
# Judge status: Accepted
N = int(input())
left = N % 1000
if left == 0:
    print(0)
else:
    print(1000 - left)
# Judge status: Accepted
n, *a = map(int, open(0).read().split())
ans = 0
for i in a:
    ans = ans ^ i
for j in a:
    print(ans ^ j)
# Judge status: Wrong Answer
n  = int(input())
lst = list(map(int, input().split()))

count4 = 0
count2 = 0

for i in lst:
    if i%4==0:
        count4+=1
    elif i%2==0:
        count2+=1
count1 = n-count4-count2

if count4*2>=count1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
a =[int(i) for i in input().split()]
x = 0
y = 0
z = 0
for i in range(N) :
    if a[i] % 2 != 0 :
        x+=1
    elif a[i] % 2 == 0 and a[i] % 4 != 0 :
        y += 1
    else :
        z +=1
ans = "No"
if y >= 1 :
    y = 1
    if x <= z :
        ans = "Yes"
else :
    if x <= z + 1 :
        ans = "Yes"
print(ans)
# Judge status: Accepted
import bisect
n, x = map(int, input().split())
L = list(map(int, input().split()))
D = [0]
ans = 1
for i in range(1, n+1):
  d = D[i-1] + L[i-1]
  D.append(d)
  if d <= x:
    ans += 1
  else:
    break
print(ans)
# Judge status: Wrong Answer
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
    
lstA = make_divisors(A)
lstB = make_divisors(B)
#print(lstA,lstB)
fin = []
for i in lstA:
    if i in lstB:
        fin.append(i)
#print(fin)
print(fin[K-1])
# Judge status: Accepted
n = int(input())
s = input()
mod = 10 ** 9 + 7

dict = {ch: 0 for ch in 'abcdefghijklmnopqrstuvwxyz'}
for i in range(n):
    dict[s[i]] += 1

ans = 1
for x in dict.values():
    ans = ans * (x+1) % mod
print((ans - 1) % mod)
# Judge status: Accepted
import math
n,*l=map(int,open(0).read().split())
print(4+math.ceil(n/min(l)))
# Judge status: Accepted
W, H, x, y = map(int, input().split())

print(W * H / 2, int(x + x == W and y + y == H))
# Judge status: Accepted
N, K = map(int, input().split())
S = list(input())

S[K-1] = S[K-1].lower()

print(''.join(S))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
 
b = [0] * n
 
for i in range(n, 0, -1):
    if sum(b[i-1::i]) % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1
 
c = []
for i in range(n):
    if b[i] == 1:
        c.append(i+1)
print(sum(b))
if len(c) > 0:
    print(*c)
# Judge status: Accepted
n=int(input())
dp=[[0]*3 for i in range(n)]
happy=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    happy.append(tmp)
dp[0][0]=happy[0][0]
dp[0][1]=happy[0][1]
dp[0][2]=happy[0][2]
for i in range(1,n):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+happy[i][0]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+happy[i][1]
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+happy[i][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))
# Judge status: Wrong Answer
import fractions

A, B, C, D = [int(i) for i in input().split()]

l = (C * D) // fractions.gcd(C,D)
b_sum = B -(B//C) - (B//D) + (B//l)
a_sum = A - (A//C) - (A//D) + (A//l)

print(b_sum - a_sum)
# Judge status: Wrong Answer
N = int(input())


print(int((N/2) * (N - 1)))
# Judge status: Accepted
c = ["Christmas"]
D = int(input())
print(" ".join(c + ["Eve" for _ in range(25-D)]))
# Judge status: Accepted
n, t = map(int, input().split())
ans = 1001001001

for _ in range(n):
    ci, ti = map(int, input().split())
    if ti <= t:
        ans = min(ans, ci)

if ans == 1001001001:
    print('TLE')
else:
    print(ans)
# Judge status: Accepted
import sys
N,M =map(int, input().split())
a = [input().split() for l in range(M)]

for i in range(1000):
    flag = 1
    b = str(i)
    if len(b)!= N:
        flag = 0
        continue
    for j in range(M):
        if b[int(a[j][0])-1] != a[j][1]:
            flag = 0
            break
    if flag == 1:
        print(i)
        sys.exit()

print("-1")
# Judge status: Wrong Answer
def main():
  A = list(map(int, input().split()))
  
  if sum(A) <= 22:
    print('win')
  else:
    print('bust')
  
  
main()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

s = input()

if s[2]==s[3] or s[4]==s[5]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import heapq

k = int(input())

lunlun = [1,2,3,4,5,6,7,8,9]
heapq.heapify(lunlun)

for i in range(1,10**5):
    x = heapq.heappop(lunlun) #最小値
    y = x % 10
    if i == k :
        break
    if y != 0:
         heapq.heappush(lunlun, x * 10 + y- 1)
    heapq.heappush(lunlun,10*x+y)
    if y != 9:
        heapq.heappush(lunlun, x * 10 + y + 1)
#print(lunlun)
print(x)
# Judge status: Accepted
S = int(input())
M = 10 ** 9 + 7
def mod_comb(n, k, mod):
	ret = 1
	for i in range(1, k+1):
		ret = (ret * (n+1-i)) % mod
		ret = (ret * pow(i, mod-2, mod)) % mod
	return ret
ans = 0
for K in range(1, S // 3 + 1):
  ans = (ans + mod_comb(S - 2 * K - 1, K - 1, M)) % M
print(ans)
# Judge status: Accepted
n = int(input())
a = (n + 111 - 1) // 111
print(a * 111)
# Judge status: Accepted
n,k=map(int,input().split())
i=list(map(int,input().split()))
l=[0]*(n-k)
for j in range(n-k):
  l[j]=i[j+k]-i[j]
place=0
plus=0
for j in range(n-k):
  plus=plus+l[j]
  if plus>0:
    place=j+1
    plus=0
a=0.0
for j in range(k):
  a+=float(i[j+place]+1)/2
print(a)
# Judge status: Accepted
S = input()

if S[-1]=='s':
  print(S+'es')
else:
  print(S+'s')
# Judge status: Accepted
import sys

N, D = map(int, sys.stdin.readline().split())
print((N - 1)// (2*D+1) + 1)
# Judge status: Accepted
def main():
    a, b, c, k = map(int, input().split())

    if k % 2 == 0:
        ans = a - b
        if abs(ans) > 10 ** 18:
            print("Unfair")
        else:
            print(ans)
    else:
        ans = b - a
        if abs(ans) > 10 ** 18:
            print("Unfair")
        else:
            print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a,v =map(int, input().split())
b,w =map(int, input().split())
t=int(input())


if a < b :
    if a+v*t >= b+w*t :
        print('YES')
    else :
        print('NO')
        
else :
    if a+v*t <= b+w*t :
        print('YES')
    else :
        print('NO')
# Judge status: Accepted
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
L = LI()
s = sum(L)
m = max(L)
print('Yes' if m < s-m else 'No')
# Judge status: Accepted
S = input()
tmp = ""
cha = ""
lst = []
for i in range(len(S)):
    cha += S[i]
    if(cha != tmp):
        lst.append(cha)
        tmp = cha
        cha = ""
print(len(lst))
# Judge status: Accepted
s = input()
a_cnt = s.count('a')
b_cnt = s.count('b')
c_cnt = s.count('c')
if max(a_cnt, b_cnt, c_cnt) <= min(a_cnt, b_cnt, c_cnt) + 1:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N = int(input())
U = []
for i in range(N):    
    x, l = (map(int,input().split()))
    u = [x+l,x-l]
    U.append(u)
U.sort()

ans = 1
x = U[0][0]
for i in range(N-1):
    if U[i+1][1] >= x:
        ans += 1
        x = U[i+1][0]
print(ans)
# Judge status: Wrong Answer
n=int(input())
arr=sorted(list(map(int,input().split())))

t=sum(arr)
print(t-arr[0])
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a<c and b>c:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*k+y*(n-k))
# Judge status: Accepted
S = input()
T = input()

change_num = 1000000000
count = 0

for i in range(len(S)):
    if (len(T) + i) > len(S):
        break

    s = S[i:len(T) + i]
    for j, k in enumerate(s):
        if k != T[j]:
            count += 1

    if count < change_num:
        change_num = count

    count = 0


print(change_num)
# Judge status: Accepted
s=int(input())
a=[s]
a_before=s
ans=1
while True:
    buf=0
    ans+=1
    if a_before%2==0:
        buf=a_before//2
    else:
        buf=3*a_before+1
    if buf in a:
        break
    a.append(buf)
    a_before=buf
print(ans)
# Judge status: Accepted
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
 
AB.sort(key = lambda x: x[1])
time = 0
 
for A,B in AB:
    time += A
    if time > B:
        print('No')
        break
else:
    print('Yes')
# Judge status: Wrong Answer
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
lr, ls, lp = -n, -n, -n
ans = 0

for i in range(n):
    if t[i] == "r":
        if k != i+1-lr:
            ans += p
            lr = i+1
    elif t[i] == "s":
        if k != i+1-ls:
            ans += r
            ls = i+1
    else:
         if k != i+1-lp:
            ans += s
            lp = i+1

print(ans)
# Judge status: Accepted
l = list(map(int, input().split()))
if sum(l) >= 22:
    print('bust')
else:
    print('win')
# Judge status: Wrong Answer
N = int(input())
A_i = list(map(int, input().split()))

forret = sorted(A_i)
ret = A_i[-1]
for i in range(N-2):
    print('A')
    print('ret', ret)
    ret = ret + forret[-1-1-(i//2)]
print(ret)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
for k in range(B):
    if (k * A) % B == C: print("Yes"); exit()
print("No")
# Judge status: Wrong Answer
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if s1 == s2 == 0:
    print('NA')
elif s1 <= 12 and s2 <= 12:
    print('AMBIGUOUS')
elif s1 <= 12:
    print('MMYY')
elif s2 <= 12:
    print('YYMM')
else:
    print('NA')
# Judge status: Accepted
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

a2 = [a[i] - i - 1 for i in range(n)]
mean = sum(a2) / len(a2)
median = np.median(np.array(a2))
b = np.floor(median)
a3 = sum([abs(a2[i] - b) for i in range(n)])
b = np.ceil(median)
a4 = sum([abs(a2[i] - b) for i in range(n)])
print(int(min(a3, a4)))
# Judge status: Accepted
A,B = list(map(int,input().split()))
X = []
mA = int(100/8*A)
MA = int(100/8*(A+1))+1
mB = int(10*B)
MB = int(10*(B+1))+1
 

for i in range(max(mA,mB),min(MA,MB)):
    X.append(i)
#print(X)

f = True
for i in X:
    if int(i*0.08)==A and int(i*0.1)==B:
        print(i)
        f = False
        break
if f:
    print(-1)
# Judge status: Accepted
n=int(input())
count=0
ans=0
for j in range(1,n+1,2):
  count=0
  for i in range(1,int(j**0.5)+1):
    if j%i==0:
      if j//i!=i:
        count+=2
      else:
        count+=1
  if count==8:
    ans+=1
print(ans)
# Judge status: Wrong Answer
def main():
    N, *XL = map(int, open(0).read().split())
    # print(N, XL)
    robots = [0]*N
    for i in range(N):
        X, L = XL[2 * i + 0], XL[2 * i + 1]
        robots[i] = (X - L, X + L)
    robots.sort(key=lambda x: x[1])
    # print(robots)
    ans = 0
    last = robots[0][0] - 1
    for robot in robots:
        if last <= robot[1]:
            last = robot[1]
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
from functools import reduce

def factors(n):
    return set(reduce(list.__add__,
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))


n,m=map(int,input().strip().split(" "))
fact=sorted(factors(m),reverse=True)
ans=1
for i in fact:
    if m//i >=n:
        ans=i
        break
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a % 2 == 0 or b % 2 == 0:
  print("even")
else:
  print("odd")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print(ans)
# Judge status: Accepted
S = input()

if S == 'hi' or S == 'hihi' or S == 'hihihi' or S == 'hihihihi' or S == 'hihihihihi':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

dct = {}
for i in range(n):
    if a[i] not in dct:
        dct[a[i]] = 1
    else:
        dct[a[i]] += 1

l = len(dct)
if l <= k:
    ans = 0
else:
    na = sorted([int(dct[key]) for key in dct])
    ans = sum(na[:l-k])

print(ans)
# Judge status: Accepted
n,k,s=map(int,input().split())
ans = (str(s) + ' ')*k + (str(s-1 or 8) + ' ')*(n-k)
print(ans[:-1])
# Judge status: Accepted
x,y = map(int,input().split())
 
if x%y == 0:
  print(-1)
else:
  print(x)
# Judge status: Wrong Answer
n = int(input())
if n >= 3200:
  print('red')
else:
  print(input())
# Judge status: Accepted
import sys
import numpy as np

# a b c キャンディーの数
a, b, c = map(int, input().split())

candy = np.array([a, b, c])

# キャンディーの数順でソート
candy.sort()

# 少ない２つと一番多いので比較
if (candy[0] + candy[1] == candy[2]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
def solve(N):
    if N == 0:
        return '0'
    ans = ''
    while N != 0:
        ans += str(N & 1)
        N >>= 1
        N *= -1
    return ans[::-1]
print(solve(N))
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

if N == 1:
  print("Yes")
  
else:
  flag = True
  for i in range(N-1):
    if a[len(a)-1-i]-a[len(a)-2-i] < -1:
      flag=False
      break
    if a[len(a)-1-i]-a[len(a)-2-i] == -1:
      a[len(a)-2-i]-=1

  print("Yes") if flag else print("No")
# Judge status: Accepted
a, b, x = map(int,input().split())

if a+b >= x:
  if a > x:
    print("NO")
  else:
    print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
import numpy as np

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

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

score = np.product(A[:K])

i = 0

for k in range(K, N):
    score_1 = (score // A[i]) * A[k]
    
    i += 1
    
    if score < score_1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i in range(N):
    B[i] = A[i] - i
B.sort()

res = 0
x = B[N//2]

for i in range(N):
    res += abs(x - B[i])

print(res)
# Judge status: Wrong Answer
n = int(input())
b = list(map(int, input().split()))

a = list()
for num, i in enumerate(b[:]):
  if num == 0:
    a.append(0)
    a.append(0)
  elif num == n-2:
    a.append(i)
  elif i > b[num + 1]:
    a.append(b[num + 1])
  elif i <= b[num + 1]:
    a.append(i)
print(sum(a))
# Judge status: Wrong Answer
from collections import deque

k = 100
count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(q[k-1])
# Judge status: Accepted
n,m = map(int,input().split())

if n==1 or m==1:
    ans = max(max(n,m)-2,1)
else:
    ans = (n-2)*(m-2)
print(ans)
# Judge status: Accepted
X = int(input())

ret = 0
cur = 100
while cur < X :
  cur = int(cur * 1.01)
  ret += 1
print(ret)
# Judge status: Accepted
def main():
    K = [int(input()) for i in range(5)]
    k = int(input())
    ans = True
    for i in range(5):
        for j in range(i + 1, 5):
            if K[j] - K[i] > k:
                ans = False
                break

    if ans:
        print("Yay!")
    else:
        print(":(")


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

A = S//100
B = S%100

if A >= 13 or A == 0:
    if B >= 13:
        print('NA')
    elif B <13:
        if B != 0:
            print('YYMM') 
        else:
            print('NA')
elif A < 13:
    if B >= 13:
            print('MMYY')
    elif B < 13:
        if B != 0:
            print('AMBIGUOUS')
        else:
            print('MMYY')
# Judge status: Wrong Answer
import queue
num=int(input())
q=queue.Queue()
for i in range(1,10):
  q.put(i)
for j in range(num):
  ans=q.get()
  if ans%10!=0:
    q.put(10*ans+(ans%10)-1)
  q.put(10*ans+(ans%10)-1)
  if ans%10!=0:
    q.put(10*ans+(ans%10)-1)
print(ans)
# Judge status: Wrong Answer
a, b, n = map(int, input().split())

ans_list = []

for q in range(n + 1):
  ans_list.append(int(a * q / b))
print(max(ans_list))
# Judge status: Accepted
N = int(input())
ans1 = False
ans2 = False
ans3 = False
for i in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2 and ans1 == False:
    ans1 = True
  elif D1 == D2 and ans1 == True and ans2 == False:
    ans2 = True
  elif D1 == D2 and ans1 == True and ans2 == True and ans3 == False:
    ans3 = True
    print("Yes")
    exit()
  elif D1 != D2:
    ans1 = False
    ans2 = False
    ans3 = False
print("No")
# Judge status: Wrong Answer
N = int(input())
S = input()
D = {"R": [], "G": [], "B": []}
for i in range(N):
  D[S[i]].append(i)
print(D)
p = 1
for i in D:
  p *= len(D[i])
cnt = 0
for i in range(N):
  for j in range(i+1, N):
    if 2 * j - i < N:
      if S[i] != S[j] and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
        cnt += 1
print(p-cnt)
# Judge status: Accepted
S = set(input().split())
print(len(S))
# Judge status: Wrong Answer
input()
a = list(map(int, input().split()))
a.sort()
print(sum(a[::-2]) - sum(a[::2]))
# Judge status: Accepted
import numpy as np
n = int(input())
a_ls = list(map(int, input().split()))
diff_ls = [a - i for i, a in enumerate(a_ls,1)]
diff_ls.sort()
med = int(np.median(diff_ls))
ans = 0
for diff in diff_ls:
    ans += abs(diff - med)
print(ans)
# Judge status: Accepted
n = int(input())
print((int(n**(1/2)))**2)
# Judge status: Wrong Answer
dic_s = {x:input() for x in 'abc'}

dic_i = {x:i for x,i in zip('abc',[0,0,0])}
dic_max = {x:len(dic_s[x]) for x in 'abc'}
nt = 'a'
while True:
  dic_i[nt] += 1
  if dic_max[nt] == dic_i[nt]:
    break
  else:
    nt = dic_s[nt][dic_i[nt]]
print(nt)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
print("Yes" if 2*A+2*B >= C else "No")
# Judge status: Wrong Answer
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:print("Bad")
else:print("good")
# Judge status: Accepted
from operator import itemgetter, attrgetter
n = int(input())
s = [input().split() for i in range(n)]
ss = []
ll = []
l = []
for i in range(0, n):
  l.insert(i, [s[i][0], int(s[i][1]), i+1])
ss = sorted(l, key=itemgetter(1), reverse=True)
ll = sorted(ss, key=itemgetter(0))
for i in ll:
  print(i[2])
# Judge status: Accepted
# -*- coding: utf-8 -*-
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0, abs(h[0] - h[1])]
    for i in range(2, n):
        min_cost = float('inf')
        for j in range(max(i - k, 0), i):
            cost = dp[j] + abs(h[j] - h[i])
            if min_cost > cost:
                min_cost = cost
        dp.append(min_cost)


    print(dp[-1])


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
S = input()
if S[0] != "A":
  print("WA")
  exit()
elif S[2:-2].count("C") != 1 and S[:2].count("C") != 0 and S[-2:].count("C") != 0:
  print("WA")
  exit()
else:
  S = S[1:].replace("C", "")
  if S.islower():
    print("AC")
  else:
    print("WA")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
# M = max(A)+1
M = 10**6+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)
# Judge status: Accepted
# ==================== gcd   最大公約数
from fractions import gcd
#from math import gcd

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

l=[0]*(n+1)
r=[0]*(n+1)

for i in range(n):
    l[i+1]=gcd(l[i],a[i])
    r[n-i-1]=gcd(r[n-i],a[n-i-1])

mimax=1
for i in range(n):
    mi=gcd(l[i],r[i+1])
    mimax=max(mi,mimax)
   
print(mimax)
# Judge status: Wrong Answer
H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H < W and  N / o<= W:
    print(o)
    break
  elif H> W and N / o<=H:
    print(o)
    break
# Judge status: Accepted
x, y = map(int, input().split())
count = abs(abs(x)-abs(y))

if x * y < 0:
    count += 1
elif x * y == 0 and x > y:
    count += 1
elif x * y > 0:
    if x < 0 and abs(x) < abs(y):
        count += 2
    elif x > 0 and abs(x) > abs(y):
        count += 2

print(count)