peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

x = int(stdin.readline().rstrip())

for i in range(-150,150):
    for j in range(-150,150):
        if i**5-j**5 == x: print(i,j); sys.exit()
# Judge status: Accepted
import numpy as np
N, M = map(int, input().split())
A, B = np.array(tuple(tuple(map(int, input().split())) for _ in range(N)), dtype=np.int64).T
C, D = np.array(tuple(tuple(map(int, input().split())) for _ in range(M)), dtype=np.int64).T
print(*((np.abs(np.subtract.outer(A, C)) + np.abs(np.subtract.outer(B, D))).argmin(axis=1) + 1), sep="\n")
# Judge status: Accepted
A,B,C,K=map(int,input().split())
if K<A:
  print(K)
if A<=K<A+B:
  print(A)
if A+B<=K:
  print(2*A+B-K)
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())

s = ''

for i in range(ty - sy):
    s = s + 'U'
for i in range(tx - sx):
    s = s + 'R'
for i in range(ty - sy):
    s = s + 'D'
for i in range(tx - sx):
    s = s + 'L'

s = s + 'L'

for i in range(ty - sy + 1):
    s = s + 'U'
for i in range(tx - sx + 1):
    s = s + 'R'

s = s + 'DR'

for i in range(ty - sy + 1):
    s = s + 'D'
for i in range(tx - sx + 1):
    s = s + 'L'

s = s + 'U'

print(s)
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())

if a+b<=2*c:
  print(x*a+y*b)
else:
  ans = c*2*min(x, y)
  if x>=y:
    ans += (x-y)*a
  else:
    ans += (y-x)*b
  print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
k -= 1
s = input()

ans = s[:k] + s[k].lower() + s[k + 1:]

print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
l,r = 1,n
for i in range(m):
    l_tmp,r_tmp = map(int,input().split())
    if l_tmp > l:
        l = l_tmp
    if r_tmp < r:
        r = r_tmp
print(r-l+1)
# 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(1,N):
    if A[i-1]+1==A[i]:
        ans+=C[A[i]-2]
print(ans)
# Judge status: Accepted
K, N = map(int, input().split())
Ai = list(map(int, input().split()))
Di = [0]*len(Ai)

for i in range(len(Ai)):
    if i == len(Ai) - 1:
        Di[i] = (K - Ai[i]) + Ai[0]
    else:   
        Di[i] = Ai[i + 1] - Ai[i]

ans = K - max(Di)

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

print('A'+a[8]+'B')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

a.sort()

print(sum(a[n:2*n]))
# Judge status: Accepted
n = int(input())
s = input()

freq = {'R': 0, 'G': 0, 'B': 0}
for x in s:
    freq[x] += 1

ans = freq['R'] * freq['G'] * freq['B']
for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + (j-i)
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1

print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())

print(N*(N-1)+M*(M-1))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
n_money = 1000
n_stock = 0
for i in range(N-1):
    if A[i+1] > A[i]:
        # buy
        n_stock = n_money // A[i]
        n_money = n_money - n_stock * A[i]
    else:
        # sell
        n_money += n_stock * A[i]
        n_stock = 0
n_money += n_stock * A[N-1]
print(n_money)
# Judge status: Wrong Answer
#デフォルト
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

h1, m1, h2, m2, k = map(int, input().split())

minute = ((h2 * 60) + m2) - (h1 * 60) + m1

print(minute - k)
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
if b == 1:
  b = 14
if a == 1:
  a = 14
if a < b:
  print('Bob')
elif a > b:
  print('Alice')
else:
  print('Draw')
# Judge status: Wrong Answer
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
max = 0
for ss in s:
  if s.count(ss) -t.count(ss) > 0:
    max = s.count(ss) - t.count(ss)
print(max)
# Judge status: Accepted
N=int(input())
i = 0
while N>=i*i :
    i+=1
print((i-1)*(i-1))
# Judge status: Accepted
n =int(input())
V = list(map(int,input().split()))
V.sort()

ans = V[0]
for i in range(1,n):
    ans = (ans+V[i])/2

print(ans)
# Judge status: Wrong Answer
l, r = [int(i) for i in input().split()]
ln = l // 2019
rn = r // 2019
if ln == rn:
	l = l % 2019
	print (l * (l + 1))
else:
	print (0)
# Judge status: Wrong Answer
import datetime

S = input()
S = datetime.datetime.strptime(S, '%Y/%m/%d')



a = int(S.year)

if a != 2018:
    S = S.replace(2018)
    
S = S.date

print(S)
# Judge status: Accepted
n, m, X = map(int, input().split())

ans = 10**9

price = []
a = []
for _ in range(n):
    c = [int(x) for x in input().split()]
    price.append(c[0])
    a.append(c[1:])

for i in range(1 << n):
    l = [0]*m
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp += price[j]
            for x in range(m):
                l[x] += a[j][x]
    if all(x >= X for x in l):
        ans = min(ans, tmp)

print(-1 if ans == 10**9 else ans)
# Judge status: Wrong Answer
n=int(input())
li=[]
for i in range(n):
  if i==0:
    li.append(input())
  else:
    s=input()
    if s not in li and li[-1][-1]==s[0]:
      continue
    else:
      print("No")
      exit()
print("Yes")
# Judge status: Wrong Answer
S = input().split(" ")
print([i[0] for i in S])
# Judge status: Wrong Answer
S = list(input())
L = len(S)

def change():
    global moji
    if moji == "1":
        moij = "0"
    else:
        moji = "1"

# case 1
count_1 = 0
moji = "1"
for c in range(L):
    if moji == S[c]:
        pass
    else:
        count_1 += 1
    change()

# case 2
count_2 = 0
moji = "0"
for c in range(L):
    if moji == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)
# Judge status: Wrong Answer
N = int(input())
s = input()
t = input()

if s == t:
    print(N)
    exit(0)

tr = t[::-1]
match = 0
for i in reversed(range(0, N)):
    if s[i] == tr[i]:
        match += 1
    else:
        break
print(N*2-match)
# Judge status: Wrong Answer
s=input()
t=input()
n=len(s)
f=0
a=[[] for i in range(26)]
for i in range(n):
    if s[i]!=t[i]:
        if len(a[ord(s[i])-97])==0:
            a[ord(s[i])-97].append(t[i])
        else:
            if a[ord(s[i])-97][0]!=t[i]:
                f=1
x=[a[i][0] for i in range(26) if len(a[i])==1]
if len(x)!=len(set(x)):
    f=1
print("Yes" if f==0 else "No")
# Judge status: Wrong Answer
A,B,K=map(int, input().split())
if B-A<2*K:
  for i in range(A,B+1):
    print(i)
else:
  for i in range(K):
    print(A+i)
  for i in range(K):
    print(B-K+i)
# Judge status: Accepted
s = input()
k = int(input())

ans = []
for c in s[:-1]:
    to_a = (ord('z')-ord(c)+1) % 26
    if k < to_a:
        ans.append(c)
    else:
        k -= to_a
        ans.append('a')
else:
    c = s[-1]
    x = ord(c)-ord('a')
    y = (k+x) % 26
    ans.append(chr(ord('a')+y))


print(''.join(ans))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
k = int(read())
for ss in s:
    ss = int(ss)
    if ss > 1:
        print(ss)
        break
    else:
        if k > 1:
            k -= 1
        else:
            print(ss)
            break
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
lst = [ abs((t - i * 0.006)-a) for i in list(map(int, input().split()))]
print(lst.index(min(lst)) + 1)
# Judge status: Accepted
num = sorted(list(map(int,input().split())))

ans = num[2]-num[1]
num[0] += num[2]-num[1]
num[1] += num[2]-num[1]

while num[0]<num[1]:
    ans += 1
    num[0] += 2
    
if num[0] != num[1]:
    ans += 1
    
print(ans)
# Judge status: Wrong Answer
X, Y = map(int, input().split())

bird_only = 2 * X
r = (Y-bird_only) / 2
if r <= X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s=input()
t=input()
for i in range(len(t)-1,len(s))[::-1]:
    if s[i]==t[-1] or s[i]=="?":
        if all(s[i-j]==t[-1-j] or s[i-j]=="?" for j in range(len(t))):
            s=s.replace("?","a")
            print(s[:i-len(t)+1]+t+s[i+1:])
            exit()
print("UNRESTORABLE")
# Judge status: Accepted
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K, X = MAP()

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

result = 'APPROVED'
for a in aa:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            result = 'DENIED'
            break
print(result)
# Judge status: Accepted
s=int(input())
mod=10**9+7

dp=[0]*2001

for i in range(3,2001):
  dp[i]+=1
  for j in range(i-3,-1,-1):
    dp[i]+=dp[j]
    dp[i]%=mod
  

    

print(dp[s])
# Judge status: Wrong Answer
n,a,b=map(int,input().split())

if a==b:
  print(1)
elif n==1:
  print(0)
elif n==2:
  print(2)
else:
  print((b-a)*(n-2)+1)
# Judge status: Accepted
def main():
    s = input()
    t = input()
    
    s = s.replace('?','.')
    import re
    for i in range(len(s)-len(t),-1,-1):
        if re.match(s[i:i+len(t)],t):
            s = s.replace('.','a')
            print(s[:i]+t+s[i+len(t):])
            return 0
    print('UNRESTORABLE')
 
if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b = map(int, input().split())
if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Accepted
a,b,c = map(int, input().split())
if a+b+c >= 22:
  print("bust")
else:
  print("win")
# Judge status: Wrong Answer
N,K=map(int,input().split())
M=N+1
L=K-1
print(M*(M*M+5)/6 + L*(L*L*2+L*3-5-M*(L+1)*3)/6%(10**9+7))
# Judge status: Accepted
s = input()

so=""
se=""
for i in range(1, len(s), 2):
  so += s[i]
for i in range(0, len(s), 2):
  se += s[i]

print(len(s) - max(so.count("1") + se.count("0"), so.count("0") + se.count("1")))
# Judge status: Accepted
K = int(input())
ans = 0


def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(a, b % a)


for c in range(1, K+1):
    for b in range(1, K+1):
        for a in range(1, K+1):
            ans += gcd(gcd(a, b), c)
print(ans)
# Judge status: Accepted
N = int(input())
a = [int(input()) for _ in range(N)]

next = 0
for i in range(1, N):
    if a[next] == 2:
        print(i)
        exit()
    next = a[next]-1

print(-1)
# Judge status: Wrong Answer
x,a,b = map(int,input().split())
print('AB'[abs(a-x)<abs(b-x)::2])
# Judge status: Accepted
a,b,c=map(int,input().split())
mina=0
minb=0
minc=0

if a%2==1:
    mina=b*c
else:
    mina=0
if b%2==1:
    minb=c*a
else:
    minb=0
if c%2==1:
    minc=a*b
else:
    minc=0

print(min(mina,minb,minc))
# Judge status: Accepted
import sys
input = sys.stdin.readline
h,n = map(int,input().split())
mg = [list(map(int,input().split())) for i in range(n)]
DP = [[10**18 for i in range(h+1)] for j in range(n+1)]
for i in range(n+1):
  DP[i][0] = 0
for i in range(1,n+1):
  for j in range(1,h+1):
    DP[i][j] = min(DP[i][j],DP[i-1][j])
    DP[i][j] = min(DP[i][j],DP[i][max(0,j-mg[i-1][0])]+mg[i-1][1])
print(DP[-1][-1])
# Judge status: Accepted
input_ = input()
a = int(input_.split(' ')[0])
b = int(input_.split(' ')[1])
c = int(input_.split(' ')[2])
k = int(input())
count = 0
ans = "No"
while count < k:
  if a >= b:
    b *= 2
    count += 1
  elif b >= c:
    c *= 2
    count += 1
  if a < b and b < c:
    ans = "Yes"
    break

print(ans)
# Judge status: Accepted
N, Q = map(int , input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
# Judge status: Wrong Answer
a,b,h,m = map(int,input().split())
import math
h_pi = h * 0.0833333333* math.pi +m * (-math.pi*0.0069444444444)  + math.pi/4
m_pi = math.pi/2 - m*60*math.pi
if h_pi - m_pi <= math.pi :
    theta = h_pi - m_pi
else :
    theta = 2 * math.pi - (h_pi - m_pi)
ans = a**2 + b**2 -2 * a * b * math.cos(theta)
print(math.sqrt(ans))
print(h_pi)
# Judge status: Wrong Answer
from scipy.special import comb
S = int(input())
if S  == 1 or S == 2:
  print(0)

n = S//3
ans = 0
for i in range(n):
  a = S-3*i
  b = i+1

  ans += comb(a, b, exact=True)
  
print(ans%((10**9)+7))
# Judge status: Accepted
def resolve():
	n = int(input())
	dp = [[0]*3 for _ in range(n+1)]
	for i in range(1, n+1):
		nums = list(map(int, input().split()))
		for j in range(3):
			for k in range(3):
				if j == k:
					continue
				dp[i][j] = max(dp[i][j], nums[j] + dp[i-1][k])
	print(max(dp[-1]))
resolve()
# Judge status: Accepted
N=int(input())
S=input()
ans=0
for i in range(1,N):
    T1=S[:i]
    T2=S[i:]
    sub=0
    L=set(T1)
    for t in set(T2):
        if t in L:
            sub+=1
    ans=max(ans, sub)

print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
lst=[int(input()) for i in range(m)]
DP=[0]*(n+1)
temp=0
DP[0]=1
for i in range(1, n+1):
  if i==1:
    DP[i]=1
  elif i in lst:
    DP[i]=0
  else:
    DP[i]=DP[i-1]+DP[i-2]
print(DP[n]%1000000007)
# Judge status: Accepted
from fractions import gcd
K = int(input())


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


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)
# Judge status: Accepted
X=int(input())

if X>=30:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n-1):
    print(ans[i])
# Judge status: Accepted
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    x = int(input())

    if x == 0:
        res = 1
    else:
        res = 0

    print(res)



main()
# Judge status: Wrong Answer
a,b=map(int,input().split())
ans=-1
if a<10 and b<10:
  print(a*b)
# Judge status: Wrong Answer
w, a, b = [int(x) for x in input().split()]
print(min(abs(a + w - b), abs(b + w - a)))
# Judge status: Accepted
# ABC95_C
a,b,c,x,y = map(int,input().split())

ans = 0
if c * 2 > a + b:
    ans += a * x + b * y
else:
    if x > y:
        ans += c * 2 * y
        if a > c * 2:
            ans += (x - y) * c * 2
        else:
            ans += (x - y) * a
    else:
        ans += c * 2 * x
        if b > c * 2:
            ans += (y - x) * c * 2
        else:
            ans += (y - x) * b
        
print(ans)
# Judge status: Wrong Answer
n=int(input())
lis=list(map(int,input().split()))
ans=1
if n<=2:
  ans=1
else:
  bb=lis.pop(0)
  b=lis.pop(0)
  f=False
for i in lis:
  if n<=2:
    break
  if f:
    f^=1
  elif (bb>b and b<i) or (bb<b and b>i):
    ans+=1
    f^=1
  bb=b
  b=i
print(ans)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
ans = (N//(A+B)) * A
if(N % (A+B) <= A):
    ans += (N % (A+B))
print(ans)
# Judge status: Wrong Answer
import itertools
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    A,B,C,K = map(int,input().split())
    abc = [A,B,C]
    ans = 0

    a = A
    b = (K-a) if (K-a)>=0 and (K-a)<B else B
    c = K-A-B
    print(a-c)


main()
# Judge status: Accepted
n = int(input())
dp = [0]
for i in range(1, n+1):
    now = []
    k = 1
    while i >= k:
        now.append(dp[i-k]+1)
        k *= 6
    k = 1
    while i >= k:
        now.append(dp[i-k]+1)
        k *= 9
    dp.append(min(now))
print(dp[-1])
# Judge status: Accepted
import sys
from fractions import gcd
input = sys.stdin.readline


def mod_inverse(n, mod=10**9+7):
    return pow(n, mod-2, mod)

    
def lcm(a, b):
    return a * b // gcd(a, b)


mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))

ans = 0
inv_sum = 0
l = A[0]
for a in A:
    l = lcm(l, a)
    inv_sum = (inv_sum + mod_inverse(a)) % mod
print(l * inv_sum % mod)
# Judge status: Wrong Answer
input_str = input().split()
input_int = list(map(int, input().split()))
input_line = input()

input_dict = {}

input_dict[input_str[0]] = input_int[0]
input_dict[input_str[1]] = input_int[1]

input_dict[input_line] = input_dict[input_line] - 1

for i in input_dict:
    print(input_dict[i],end=' ')
# Judge status: Accepted
N,A,B = map(int,input().split())
t = 0
for i in range(N+1):
    if A <= sum([int(x) for x in str(i)]) <= B:
        t += i
print(t)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print(0)
elif a > 0:
    print("Positive")
else:
    if (b-a+1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")
# Judge status: Wrong Answer
def fermat_binom(n,k,p):
  if k > n:
    return 0
  num = 1
  for i in range(n,n-k,-1):
    num = (num*i)%p
  denom = 1
  for i in range(1,k+1):
    denom = (denom*i)%p
  return (num * pow(denom,p-2,p))%p

if __name__ == '__main__':
  n, a, b = map(int, input().split())
  mod = 1000000007 
  k = pow(2, n, mod)
  k1 = fermat_binom(n, a, mod)
  k2 = fermat_binom(n, b, mod)
  r = (k1+k2)%mod
  print(max(k-r-1, 0))
# Judge status: Accepted
a,b,c,d=map(int,input().split())
x=max(a*c,a*d,b*c,b*d)
if (b<0 and 0<c) or (d<0 and 0<a):
    print(x)
else:
    print(max(x,0))
# Judge status: Accepted
N = int(input())
if N==0:
  print("1")
else:
  print("0")
# Judge status: Accepted
import math
n,h=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
k=ab[0][0]
ab.sort(reverse=True,key=lambda x:x[1])
ans=0
while h>0:
    if ans==n:
        break
    if k<=ab[ans][1]:
        h-=ab[ans][1]
        ans+=1
    else:
        break
if h<=0:
    print(ans)
else:
    print(ans+math.ceil(h/k))
# Judge status: Accepted
N = list(map(int, input().split()))
n_sum = 0

for n in N:
    n_sum += n

if n_sum % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
A,B = map(int, input().split())
count = 0
for i in range(A,B+1):
  k = str(i)
  karray = list(map(int, k))
  if karray == karray.reverse:
    count += 1
print(count)
# Judge status: Wrong Answer
from collections import defaultdict
d=defaultdict(int)
n,*s=open(0).read().split()
for i in s:d["".join(sorted(list(i)))]+=1
print(max(d.values()))
# Judge status: Wrong Answer
n,x,t = map(int, input().split())

ans = n / x
ans = round(ans)
ans = ans * t
if ans == 0:
    ans = t
print(ans)
# Judge status: Accepted
A, B, M = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
r = min(a) + min(b)
for i in range(M):
  x, y, c = [int(x) for x in input().split(' ')]
  r = min(r, a[x-1] + b[y-1] - c)
print(r)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = A[0]
if n%2 == 0:
    ans += sum(A[1:n//2])*2
else:
    ans += sum(A[1:n//2])*2 + A[n//2]

print(ans)
# Judge status: Accepted
def main():
    length, num = map(int, input().split())
    a = list(map(int, input().split()))
    max_dis = 0
    first_h = a[0]
    prev_h = a[0]
    for h in a[1:]:
        dis = h - prev_h
        max_dis = max(max_dis, dis)
        prev_h = h

    dis = (length - prev_h) + first_h
    max_dis = max(max_dis, dis)
    print(length - max_dis)


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

A,B = map(int,input().split())
judge=False
for x in range(A,B+1):
    if x%K==0:
        judge=True
        break
if judge==True:
    print("OK")
else:
    print("NG")
# Judge status: Accepted
N,P = map(int, input().split())
A = list(map(int, input().split()))
x = y = 0
for i in range (N):
  if A[i]%2 == 0:
    x += 1
  else:
    y += 1
if P%2 == 0:
  print(2**N if y == 0 else 2**(N-1))
else:
  print(0 if y == 0 else 2**(N-1))
# Judge status: Wrong Answer
s = input()

if s[-1] == s:
  print(s+"es")
else:
  print(s+"s")
# Judge status: Wrong Answer
s = input()
k = int(input())

flag  = 0

for i in s:
    if i == "1":
        continue
    else:
        print(i)
        flag = 1
        break

if flag == 0:
    print("1")
# Judge status: Accepted
A = int(input())
S = input()
if A < 3200:
	print("red")
else:
	print(S)
# Judge status: Accepted
N,K = map(int,input().split())
tree = sorted([int(input())for i in range(N)])
d = 10**18  


for i in range(N-K+1):
  d = min(d,tree[i+K-1]-tree[i])
print(d)
# Judge status: Accepted
from itertools import combinations_with_replacement as combi

n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]

def points(A, queries):
    score = 0
    for query in queries:
        a, b, c, d = query
        if A[b-1] - A[a-1] == c:
            score += query[3]
    return score

score = 0
for iter in combi([i for i in range(1, m+1)], n):
    score = max(points(sorted(iter), queries), score)

print(score)
# Judge status: Accepted
def main():
    S = input()
    K = int(input())
    one_seq = sum([int(c) for c in S[:min([K, len(S)])]])
    if one_seq == min([K, len(S)]):
        print(1)
    else:
        for c in S:
            if c != '1':
                print(c)
                return


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
N = int(input())
A = list(map(int,input().split()))
B = []
tmp = 1
for i in range(N+1):
    B.append(tmp)
    tmp -= A[i]
    if tmp < 0:
        print(-1)
        sys.exit()
    tmp *= 2

for i in range(N, 0, -1):
    A[i-1] += A[i]

ans = 0

for i in range(N+1):
    ans += min(B[i], A[i])

print(ans)
# Judge status: Accepted
from heapq import *
n, m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x * (-1), a))
heapify(a)

for i in range(m):
    temp_num = heappop(a) * (-1)
    heappush(a,(-1) * (temp_num //2))

print(-sum(a))
# Judge status: Wrong Answer
K = int(input())
A, B = map(int,input().split())
C = A % K
if B - A >= K - 1:
  print('OK')
elif C + B - A >= K:
  print('OK')
else:
  print('NG')
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())

if H >= W:
  if N//H != 0:print(N//H + 1)
  else: print(N//H)
else:
  if N//W != 0:print(N//W + 1)
  else: print(N//W)
# Judge status: Accepted
number = int(input())
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]+1):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])
# Judge status: Accepted
n,k,s= map(int, input().split())

ans=[s]*k
if s<=100:
    zeros=[10**9]*(n-k)
else:
    zeros=[s-1]*(n-k)
ans.extend(zeros)

print(*ans)
# Judge status: Accepted
from decimal import Decimal

a, b, c = map(Decimal, input().split())
if a.sqrt() + b.sqrt() < c.sqrt():
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = int(input())
if x == 7 or x == 5 or x == 3:
    print('Yes')

else:
    print('No')
# Judge status: Accepted
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
ans=0
for i in range(n):
    if ab[i][1]<m:
        ans+=ab[i][0]*ab[i][1]
        m-=ab[i][1]
    elif ab[i][1]>=m:
        ans+=ab[i][0]*m
        break
print(ans)
# Judge status: Accepted
k,s = list(map(int, input().split()))
cnt=0
for i in range(k+1):
    for j in range(k+1):
        if s>=i+j>=s-k:
            cnt+=1
print(cnt)