peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
ls = [(0, 0)] * n
for i in range(n):
    x, ln = map(int, input().split())
    l = x - ln
    r = x + ln
    ls[i] = (l, r)
#print(ls)

ls.sort(key=lambda x: x[1])
#print(ls)
last = -float('inf')
count = 0
for i in ls:
    if last <= i[0]:
        count += 1
        last = i[1]
print(count)
# Judge status: Accepted
a, b, c = map(int, input().split())

if len(set([a, b, c])) == 2:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

peo = 0
bus = 1
out = T[0] + k

for t in T:
    peo += 1
    if t <= out and peo <= c:
        continue
    else:
        out = t + k
        peo = 0
        bus += 1

print(bus)
# Judge status: Accepted
N = input()
n = [0]*(len(N) + 1)
ans = 0
for i in range(len(N)):
    n[i] = int(N[len(N) - 1 - i])
for i in range(len(n)):
    if n[i] < 5:
        ans += n[i]
    elif n[i] == 5:
        if n[i+1] >= 5:
            ans += 10 - n[i]
            n[i+1] += 1
        else:
            ans += 5
    else:
        ans += 10 - n[i]
        n[i+1] += 1
print(ans)
# Judge status: Accepted
def solve():
    N, M, K = map(int, input().split())

    for i in range(0, N+1):
        for j in range(0, M+1):

            if i*(M-j) + j*(N-i) == K:
                print("Yes")
                return

    print("No")

solve()
# Judge status: Wrong Answer
n = int(input())
a_lst = [int(elem) for elem in input().split()]

lst = []
for i in range(n):
    lst.append(i - a_lst[i])

cnt = 0
for j in range(n-1):
    if (j + a_lst[j]) in lst[j+1:]:
        cnt += 1

print(cnt)
# Judge status: Accepted
n = int(input())
A = []

for i in range(n):
    a = int(input())
    A.append(a)
A.sort()
i = 0
ans = 0
while True:
    cnt = 0
    while A[i + cnt] == A[i]:
        cnt += 1
        if i + cnt == n:
            break
    if cnt%2 == 1:
        ans += 1
    i += cnt
    if i == n:
        break
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())

cnt= 0
for i in range(A,B+1):
    s = str(i)
    s2 = s[::-1]
    if s == s2:
        cnt+=1
print(cnt)
# Judge status: Accepted
A, B, C, X, Y = map(int, input().split())
AB = C

ans = 0
if 2*AB < A+B:
    if X < Y:
        ans += 2*AB * X
        Y -= X
        if 2*AB < B:
            ans += 2*AB * Y
        else:
            ans += B*Y
    else:
        ans += 2*AB * Y
        X -= Y
        if 2*AB < A:
            ans += 2*AB * X
        else:
            ans += A*X
else:
    ans = A*X + B*Y

print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    CNT = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a < b:
            CNT += (b-a+1)// 2
    sa = sum(A)
    sb = sum(B)
    if sa > sb:
        print('No')
    elif sb - sa >= CNT:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
x, y = (int(i) for i in input().split())

if x == 2 or y == 2:
  print('No')
  exit()
if x == 4 or  x == 6 or x == 9 or x == 11:
  if y == 4 or y == 6 or y == 9 or y == 11:
    print('Yes')
  else:
    print('No')
else:
  if y == 4 or y == 6 or y == 9 or y == 11:
    print('No')
  else:
    print('Yes')
# Judge status: Accepted
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    A, B, C, X, Y = MII()

    ans = A * X + B * Y
    for i in range(0, max(X, Y)+1):
        ans = min(ans, max(A * (X - i), 0) + max(B * (Y - i), 0) + C * 2 * i)

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
AB = sorted(AB, key=lambda x: x[0])

cnt = 0
ans = 0
for a, b in AB:
    if cnt + b >= M:
        ans += a * (M - cnt)
        break
    else:
        cnt += b
        ans += a * b
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
res = 1
cnt = 0
while res<b:
    res+=a-1
    cnt+=1
print(cnt)
# Judge status: Accepted
N = int(input())
num = N
bit = []
for i in range(1,10000):
    r = abs(num%2)
    bit.append(str(r))
    num = (num-r)//-2
    if num == 0 :
        break
bit.reverse()
print(''.join(bit))
# Judge status: Wrong Answer
import math

A, B, K = map(int, input().split())

minAB = min(A, B)
kcount = 1

if minAB == 1:
	print(1)
else:
	for i in range (0, minAB):
		if A%(minAB-i) == 0 and A%(minAB-i) == 0 and kcount <K:
			kcount+=1
		elif A%(minAB-i) == 0 and A%(minAB-i) == 0:
			print(minAB-i)
			exit()
		else:
			continue
# Judge status: Accepted
N, K = map(int, input().split())
High = [int(input()) for _ in range(N)]
High.sort()
ans = float('inf')
for i in range(N - K + 1):
    ans = min(High[K + i - 1] - High[i], ans)

print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
ans = 0
for i in range(b-a+1):
  ans += i
print(ans - b)
# Judge status: Accepted
memo = [[None for i in range(50)] for j in range(50)]
def opt(n,k): # exponents must be >= k
	if n < k:
		return 0
	else:
		if memo[n][k]==None:
			memo[n][k] = max(1+opt(n-k,k+1),opt(n,k+1))
		return memo[n][k]

def prime_factorize(n):
	pf = {}
	d = 2
	orig_n = n
	while d*d <= orig_n:
		while n%d==0:
			pf[d] = pf.get(d,0)+1
			n //= d
		d += 1

	if n > 1:
		pf[n] = 1
	return pf 

print(sum([opt(e,1) for e in prime_factorize(int(input())).values()]))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 0

uf,df = True,True
x = a[0]
for ai in a:
    
    if x > ai:
        uf = False
    if x < ai:
        df = False
    if (uf or df) is False:
        ans += 1
        uf,df, = True,True
    x = ai
print(ans+1)
# Judge status: Accepted
s = input()
print("Bad" if any([s[i] == s[i + 1] for i in range(3)]) else "Good")
# Judge status: Accepted
a,b,k=map(int, input().split())
k=min(k,b-a+1)
*al,=range(a,a+k)
*al2,=range(b-k+1,b+1)
ans=al+al2
ans=list(set(ans))
ans.sort()
for i in ans:print(i)
# Judge status: Wrong Answer
def times(X):
    if X == int(X):
        if 1<= X <= 179:
            K = 360/X
            if int(K) < K :
                K = int(K) + 1
                print(K)
            else:
                print(int(K))
        else:
            print("please input another number")
    else:
        print("please input an intege")
# Judge status: Wrong Answer
def expected_value(arr):
    print(arr)
    return ([sum(range(1, ele+1)) / ele for ele in arr])

n, k = [int(x) for x in input().split()]
arr = list(map(int,input().split()))
sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
print(expected_value(arr[max_i:max_i + k]))
print(sum(expected_value(arr[max_i:max_i + k])))
# Judge status: Wrong Answer
H , N =  [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
count  = 0
attact = True 
if len(A) <= N: 
    while(attact):
        H = H - N 
        count = count + 1
        if H <= 0:
            attact = False
       
        
      
if count == len(A):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
if 1 <= N <= 999:
    print("ABC")
elif 1000 <= N <= 1998:
    print("ABD")
# Judge status: Accepted
N = int(input())

dp = [i for i in range(N + 1)]

unit = []
for i in range(1, 2**32):
    if 6 ** i > N:
        break
    unit.append(6 ** i)
for i in range(1, 2**32):
    if 9 ** i > N:
        break
    unit.append(9 ** i)

for v in unit:
    dp[v] = 1

for i in range(2, N+1):
    num = dp[i]
    for v in unit:
        num = min(num, dp[v] + dp[i - v])
    dp[i] = num

print(dp[N])
# Judge status: Accepted
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  s = input()
  if s == "AC":
    AC += 1
  elif s == "WA":
    WA += 1
  elif s == "TLE":
    TLE +=1
  else:
    RE += 1
    
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))
# Judge status: Accepted
N = int(input())

dp = [i for i in range(N+1)]

for i in range(1,N+1):
    dp[i] = min(dp[i], 1+dp[i-1])
    tmp = 1
    while tmp <= i:
        dp[i] = min(dp[i], 1+dp[i-tmp])
        tmp *= 6
    tmp = 1
    while tmp <= i:
        dp[i] = min(dp[i], 1+dp[i-tmp])
        tmp *= 9

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

cnt = 0

for i in range(len(p)):
    if p[i] == i+1:
        if p[i] == N:
            p[i-1], p[i] = p[i], p[i-1]
        else:
            p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
    
print(cnt)
# Judge status: Wrong Answer
N,A,B=map(int,input().split())
S=input()
cnta=0
for i in range(N):
  if S[i]=="a":
    if cnta<A+B:
      print("Yes")
      cnta+=1
    else:
      print("No")
    
  elif S[i]=="b":
    if (cnta < A+B) and (i+1 <= B):
      print("Yes")
      cnta+=1
    else:
      print("No")
  else:
    print("No")
# Judge status: Accepted
n,h = map(int,input().split())
l = sorted([list(map(int,input().split())) for _ in range(n)])[::-1]
a,b = l[0]
cou = 0
if b>=h:
  print(1)
  exit()
l1 = sorted([i for j,i in l[1:]])[::-1]
for k in l1:
  if a<k:
    cou += 1
    h -= k
    if h<=0:
      print(cou)
      exit()
    elif h-b<=0:
      print(cou+1)
      exit()
h -= b
cou += 1
if h<=0:
  print(cou)
else:
  t = -(-h//a)
  print(cou+t)
# Judge status: Wrong Answer
x,y,z = map(int,input().split())

if x%(y+z) ==0:
  print((x//(y+z))-1)
else:
  print(x//(y+z))
# Judge status: Accepted
n,a=int(input()),list(map(int,input().split()))
print(*[a[1::2][::-1]+a[::2],a[0::2][::-1]+a[1::2]][n%2],sep=' ')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
from bisect import bisect_left
from bisect import bisect_right
ans=0
for b in b:
    aa=bisect_left(a,b)
    cc=bisect_right(c,b)
    ans+=aa*(n-cc)
print(ans)
# Judge status: Accepted
from collections import deque
N = int(input())
A = [int(a) for a in input().split()]

q = deque()
for i in range(N):
    if i%2 == 0:
        q.append(A[i])
    else:
        q.appendleft(A[i])

ans = list(q)
if N%2 == 1:
    ans.reverse()
print(*ans)
# Judge status: Accepted
import sys
n = int(input())
s = [int(input())for S in range(n)]
ans = sum(s)
box = []
if ans%10 != 0:
	print(ans)
	sys.exit()
for i in range(n):
	if (ans-s[i])%10 != 0:
		box.append(ans-s[i])
if len(box) > 0:
	print(max(box))
else:
	print(0)
# Judge status: Accepted
import math

N = int(input())
A = [int(n) for n in input().split()]

gcd_l = [0]
gcd_r = [0]


for i in range(N):
    gcd_l.append(math.gcd(gcd_l[i], A[i]))
    gcd_r.append(math.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]

max_gcd = 0
for i in range(N):
    max_gcd = max(max_gcd, math.gcd(gcd_l[i], gcd_r[i+1]))

print(max_gcd)
# Judge status: Wrong Answer
s = input()
if s[0]=='R' and (s[0]==s[1]):
  print(2)
elif s[1]=='R' and (s[1]==s[2]):
  print(2)
elif s[0]=='R' and s[0]==s[1]==s[2]:
  print(3)
elif s[0]=='R' or s[1]=='R' or s[2]=='R':
  print(1)
else:
  print(0)
# Judge status: Accepted
n,q = map(int,input().split())
s = list(input())
l = [0]*q
r = [0]*q
for i in range(q):
    l[i], r[i] = map(int,input().split())

lis = [0]
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        lis.append(lis[i-1]+1)
    else:
        lis.append(lis[i-1])
# print(s)
# print(lis)
for i in range(q):
    print(lis[r[i]-1] - lis[l[i]-1])
# Judge status: Wrong Answer
N = int(input())
As = list(map(int,input().split()))

out = (sum(As)**2 - sum([a**2 for a in As]))/2
print(out % (10**9+7))
# Judge status: Accepted
x,y = map(int, input().split())
ans = 'false'

for i in range(0,x+1):
  if y == 2*i + 4*(x-i):
    ans = 'true'
    break

if ans == 'true':
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())

if n % 9 == 0:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
from collections import deque

n,m = map(int,input().split())
graph = [[] for i in range(n)]
mark = [0]*n

for i in range(m):
    a, b = map(int,input().split())
    a -=1; b -=1
    graph[a].append(b)
    graph[b].append(a)

d = deque([0])
visited = [False]*n
visited[0] = True

while d:
    v = d.popleft()
    for i in graph[v]:
        if visited[i]:continue
        visited[i] = True
        mark[i] = v
        d.append(i)



print('Yes')

for i in mark:
    print(i+1)
# Judge status: Accepted
n,m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

nums = [0]*m
for i in ka:
  for j in range(1,i[0]+1):
    nums[i[j]-1] += 1
print(nums.count(n))
# Judge status: Accepted
import itertools

N, M, Q = map(int, input().split())
X = []
for i in range(Q):
    a, b, c, d = input().split(" ")
    X.append([int(a), int(b), int(c), int(d)])

l = (list(itertools.combinations_with_replacement(range(1, M + 1), N)))
r = 0
result = 0
for k in l:
    r = 0
    for x in X:
        if k[x[1] - 1] - k[x[0] - 1] == x[2]:
            r += x[3]
    if result < r:
        result = r
print(result)
# Judge status: Accepted
a,b = map(int,input().split())

if a*b % 2 == 1:
    print('Odd')

elif a*b % 2 == 0:
    print('Even')
# Judge status: Accepted
#!/usr/bin/env python3

def solve(n,s,t):
  for i in range(n+1):
    if s[i:] == t[:n-i]:
      return len(s[:i]) + n
  return 2*n


def main():
  N = int(input())
  s = input()
  t = input()
  print(solve(N,s,t))
  return

if __name__ == '__main__':
  main()
# Judge status: Accepted
def actual(x, a, b):
    # すぬけ君の位置から店A,B までの距離は異なる

    if abs(x - a) < abs(x - b):
        return 'A'

    return 'B'

x, a, b = map(int, input().split())
print(actual(x, a, b))
# Judge status: Wrong Answer
N = int(input())
n = list(map(int, input().split()))

nfl = len(list(filter(lambda x: x%4==0, n)))

if (N / 3) <= nfl:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(1,n):
  d=A[i-1]-A[i]
  if d>0:
    ans += d
    A[i]+=d
print(ans)
# Judge status: Accepted
n = int(input())

mod = 10  ** 9 + 7
ans = pow(10,n,mod)
ans -= pow(9,n,mod) * 2
ans += pow(8,n,mod)

print(ans % mod)
# Judge status: Accepted
x,a,b = tuple(map(int,input().split()))
 
if a-b>=0 :
  print("delicious")
elif b-a<=x:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
#!/usr/bin/env python3

p, q, r = list(map(int, input().split()))

print(min(p+q, q+r, r+p))
# Judge status: Accepted
S=str(input())
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return print('No')
    for j in range(len(kaibun)//4):
        if kaibun[j] != kaibun[-(j+len(kaibun)//2)-2]:
            return print('No')
        if kaibun[j+len(kaibun)//2+1] != kaibun[-(j+len(kaibun)//2)-2]:
            return print('No2')
    return print('Yes')

is_kaibun(S)
# Judge status: Accepted
N=int(input())
P=list(map(int,input().split()))
L=[]
for i in range(N):
	if P[i]==i+1:
		L.append(i+1)
count=len(L)
i=0
while(1):
	if i>len(L)-2:
		break
	elif L[i+1]-L[i]==1:
		count-=1
		i+=2
	else:
		i+=1
print(count)
# Judge status: Accepted
A,B,C=map(int, input().split())
for i in range(1000000):
    if A&1 or B&1 or C&1:
        print(i)
        break
    A,B,C=B//2+C//2,A//2+C//2,A//2+B//2
else:
    print(-1)
# Judge status: Wrong Answer
import sys
def read_string(row):
    return row().rstrip()

def read_int(row):
    return int(row().rstrip())
  
row = sys.stdin.readline
a = read_int(row)
s = read_string(row)

print("red" if a <= 3200 else s)
# Judge status: Accepted
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0

sum_tmp = 0
for j in range(0, N):
    sum_tmp += Ai[j]

for i in range(N1):
    sum_tmp -= Ai[i]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))
# Judge status: Accepted
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()
ab = []
for _ in range(n):
    abi = na()
    ab.append(abi)

ab.sort()
ai, bi = ab[0][0], ab[0][1]
c = 0
ans = 0
while m > 0:
    bi -= 1
    ans += ai
    m -= 1
    if bi == 0 and m != 0:
        c += 1
        ai, bi = ab[c][0], ab[c][1]

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
*x, = map(int, input().split())
 
ans = float("inf")
for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    ans = min(ans, min(abs(l), abs(r)) + r - l)
 
print(ans)
# Judge status: Accepted
N, H = list(map(int, input().split()))
A = [0]*N
B = [0]*N
for i in range(N):
    a, b = list(map(int, input().split()))
    A[i], B[i] = a, b
a = max(A)
T = 0
ct = 0
B = reversed(sorted(B))
for b in B:
    if b > a:
        ct += 1
        T += b
    if T >= H:
        break
print(ct + max((H-T+a-1)//a, 0))
# Judge status: Accepted
N, D = map(int, input().split())

A = D * 2 + 1

if N % A == 0:
    print(N // A)
else:
    print((N // A) + 1)
# Judge status: Accepted
n = int(input())
s = input()

res = 0
v = 0
for c in s:
    if c == 'I':
        v += 1
    else:
        v -= 1
    res = max(res, v)

print(res)
# Judge status: Wrong Answer
n,r = map(int,input().split())
if n <= 10:
  print(r-100*(10-n))
else:
  print(r)
# Judge status: Accepted
alpha = str(input())

if(alpha.islower()):
    print("a")
else:
    print("A")
# Judge status: Accepted
a = input()

b = a[::-1]

i = 0
while i  < len(b):
    if b[i:i+5] == "esare":
        i += 5
    elif b[i:i+5] == "maerd":
        i += 5
    elif b[i:i+6] == "resare":
        i += 6
    elif b[i:i+7] == "remaerd":
        i += 7
    else:
        ans = "NO"
        break

if i  == len(b):
    ans = "YES"
else:
    ans = "NO"

print(ans)
# Judge status: Accepted
x,a,b = map(int,input().split())
if a >= b:
  print("delicious")
elif (b-a) <= x:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
import math

def calc_omote(x, y):
    score = x
    omo = 0
    while(score < y):
        score *= 2
        omo += 1
    return omo
        

n, k = map(int, input().split())
ans = 0
for i in range(1,n+1):
    omote = calc_omote(i, k)
    p = 1/(2**omote)
    ans += p/n
#sump /= n
print(ans)
# Judge status: Wrong Answer
n = input()
if n.find('7'):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b = map(int,input().split())
if a%3 ==0:
    print("Possible")
elif b%3==0:
    print("Possible")
elif (a+b)%3==0:
    print("Possible")
else :
    print("Impossible")
# Judge status: Wrong Answer
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
bli = [0] * n
for i in range(n):
    bli[i] = h[i]
for i in range(m):
    a, b = map(int, input().split())
    bli[a - 1] = max(bli[a - 1], bli[b - 1])
    bli[b - 1] = max(bli[b - 1], bli[a - 1])
cnt = 0
for i in range(n):
    if h[i] == bli[i]:
        cnt += 1
print(cnt)
# Judge status: Accepted
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for i in range(q)]
d=list(itertools.combinations_with_replacement(list(range(1,m+1)), n))
ans=0
count=0
for i in range(len(d)):
  for j in range(q):
    if abcd[j][2]==d[i][abcd[j][1]-1]-d[i][abcd[j][0]-1]:
      count+=abcd[j][3]
  if ans<count:
    ans=count
  count=0
print(ans)
# Judge status: Accepted
s=int(input())
if s<3:
    print(4)
    exit()
for i in range(10**7+1):
    if s==4:
        print(i+4)
        exit()
    if s%2:
        s=3*s+1
    else:
        s//=2
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
state = None
cnt = 1
for i in range(1, n):
    if state == None:
        if a[i] > a[i-1]:
            state = 'up'
        elif a[i] < a[i-1]:
            state = 'down'
        else:
            continue
    elif state == 'up' and a[i] < a[i-1]:
        cnt += 1
        state = None
    elif state == 'down' and a[i] > a[i-1]:
        cnt += 1
        state = None
print(cnt)
# Judge status: Accepted
x = int(input())
sum_n = lambda n: (n * (n + 1)) // 2
t = 0
while sum_n(t) < x:
    t += 1
print(t)
# Judge status: Wrong Answer
N, X, T = map(int, input().split() )

a = N // X
a = (a+1) * T

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

ans = "NG"
for i in range(A, B+1):
    if i % K == 0:
        ans = 'OK'
        break

print(ans)
# Judge status: Accepted
import numpy as np
n, k = map(int, input().split())
print(-(-(n-1)//(k-1)))
# Judge status: Accepted
import bisect
n = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

A.sort()
B.sort()
C.sort()
ans = 0
for j in range(n):
    i = bisect.bisect_left(A, B[j])
    k = n - bisect.bisect_right(C, B[j])
    ans += int(i*k)
print(ans)
# Judge status: Wrong Answer
def i():
  return int(input())
A = i()
B = i()
C = i()
X = i()
ans = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
      if 500*i+100*j+50*k == X:
        ans += 1
print(ans)
# Judge status: Wrong Answer
S = list(input())
N = len(S)
while(1):
    Q = []
    for i in range(len(S)-1):
        if S[i]!=S[i+1]:
            i += 1
        else:
            Q.append(S[i])
    Q.append(S[-1])
    if S == Q:
        break
    S = Q 
    #print(S)
print(N-len(S))
# Judge status: Accepted
S = input()[::-1]
N = len(S)
amari = [0 for i in range(2019)]
before = int(S[0])
amari[before] += 1
S = S[1::]
keta = 1
for i in S:
    i = int(i)
    keta = (keta * 10) % 2019
    x = (keta * i + before) % 2019
    amari[x] += 1
    before = x
ans = amari[0]
for i in amari:
    ans += i * (i - 1) // 2
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

if abs(a - b) % 2 != 0:
    print('IMPOSSIBLE')
else:
    print(int((a + b) / 2))
# Judge status: Wrong Answer
N = int(input())
S = list(input())
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

print(A)
# Judge status: Wrong Answer
l, k = map(int, input().split(" "))
if k >= l:
  print(0)
else:
  print(sorted(map(int, input().split(" ")))[:l-k])
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(N):
    cnt = 0
    now = H[i]
    for j in H[i+1:]:
        if now >= j:
            now = j
            cnt += 1

    ans = max(cnt, ans)

print(ans)
# Judge status: Wrong Answer
n = int(input())
k = 1
while True:
  if k*(k+1)//2 >= n:
    ans = k
    break
  k += 1
print(ans)
# Judge status: Wrong Answer
import math
a,b,c=map(int,input().split())
if c-(a+b+math.sqrt(a*b)*2)>0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=sorted(set(input())^set(chr(i)for i in range(97,123)));print(a and a[0]or None)
# Judge status: Accepted
S = input()

num_eraser = S.count('eraser')
num_erase = S.count('erase') - num_eraser
num_dreamer = S.count('dreamer') - S.count('dreamerase')
num_dream = S.count('dream') - num_dreamer
# dream + erase(r) で dreamer が含まれるのに注意

# print(num_eraser, num_erase, num_dreamer, num_dream)
cnt = num_eraser * 6 + num_erase * 5 + num_dreamer * 7 + num_dream * 5
# print('cnt', cnt)
if len(S) == cnt:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a,b=map(int,input().split())
print((a+b)//2 if (a+b)%2==0 else "IMPOSSIBLE")
# Judge status: Accepted
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s :
    print( str(a-1) + " " + str(b))
elif u == t :
    print( str(a) + " " + str(b-1))
# Judge status: Accepted
a, b = map(int, input().split())

if 8 < a or 8 < b:
    ans = ':('
else:
    ans = 'Yay!'

print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
q=int(input())

s=sum(a)
d=[0]*(10**5+1)
for i in a:
    d[i-1]+=1

for _ in range(q):
    b,c=map(int,input().split())
    tmp=0
    k=d[b-1]
    d[c-1]+=k
    d[b-1]=0

    tmp = k*c-k*b
    s+=tmp
    print(s)