peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import combinations_with_replacement


def main():
    N, M, Q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for _ in range(Q)]

    result = 0

    for C in combinations_with_replacement(range(1, M + 1), N):
        tmp = sum([d for a, b, c, d in ABCD if C[b - 1] - C[a - 1] == c])
        result = max(result, tmp)
    print(result)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b, c = map(int,input().split())
count = 0
#偶奇を一致させる
if a % 2 == b % 2 == c % 2:
    count = 0

elif a % 2 == b % 2 != c % 2:
    count += 1
    a += 1
    b += 1

elif b % 2 == c % 2 != a % 2:
    count += 1
    b += 1
    c += 1

elif a % 2 == c % 2 != b % 2:
    count += 1
    a += 1
    c += 1
maxnum = max(a, b, c)

while a < maxnum:
    a += 2
    count += 1

while b < maxnum:
    b += 2
    count += 1

while c < maxnum:
    c += 2
    count += 1

print(count)
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    b,c=map(int,input().split())
    a.append(b)
    a.append(c)
a=sorted(a)[::-1]
ans=0
for i in range(n):
    ans+=a[i]
print(ans)
# Judge status: Accepted
from sys import stdin
from math import ceil, floor
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
s = list(stdin.readline().rstrip())
c = a + b
d = 0
e = 0
for i in range(n):
    if d < c and s[i] == "a":
        print("Yes")
        d += 1
    elif d < c and e < b and s[i] == "b":
        print("Yes")
        d += 1
        e += 1
    else:
        print("No")
# Judge status: Wrong Answer
O = input()
E = input()

x = []
for i,j in zip(O,E):
  x.extend(i+j)
  
print("".join(x))
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N+10)]

for i in range(1, N):
    if S[i-1:i+1] == "AC":
        ans[i] += 1
    ans[i] += ans[i-1]
print(ans)

for l, r in lr:
    l -= 1
    r -= 1
    print(ans[r] - ans[l])
# Judge status: Accepted
n,c,k,*t=map(int,open(0).read().split())
t=sorted(t)
cnt=0
ans=1
x=t[0]
for i in range(n):
  cnt+=1
  if t[i]-x>k or cnt>c:
    x=t[i]
    ans+=1
    cnt=1
print(ans)
# Judge status: Accepted
import sys

def base_convert(n, b):
  if not n: return 0
  res = ''
  while n:
    n, r = divmod(n, b)
    if r < 0: n += 1; r -= b
    res += str(r)
  return int(res[::-1])

n = int(sys.stdin.readline().rstrip())

def main():
    print(base_convert(n, -2))

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = input().strip()

    if N[0] == N[1] == N[2]:
        return "Yes"
    if N[1] == N[2] == N[3]:
        return "Yes"

    return "No"


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = True

while flag:
    ans = []
    for i in a:
        if i % 2 == 1:
            flag = False
        else:
            ans.append(i/2)
    if len(ans) == n:
        cnt += 1
        a = ans

print(cnt)
# Judge status: Accepted
s=input()
t=input()
l=[]
import sys
if len(t)>len(s):
  import sys
  print("UNRESTORABLE")
  exit()
  
for i in range(len(s)-len(t)+1):
  z=s[:i]
  for j in range(i,i+len(t)):
    if s[j]!=t[j-i] and s[j]!="?":
      break
    else:
      z+=t[j-i]
  else:
    z+=s[i+len(t):]
    l.append(z.replace("?","a"))
l.sort()
print(l[0] if len(l) else "UNRESTORABLE")
# Judge status: Wrong Answer
w = list(input())
w = sorted(w)
flag = True
for i in range(0,len(w)-1,2):
    if w[i]!=w[i+1]:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, K = list(map(int, input().split()))


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

print(len(Base_10_to_n(N,K)))
# Judge status: Wrong Answer
n = int(input())
a,b=[],[]

for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)

a=list(reversed(a))
b=list(reversed(b))

OK=0
for i in range(n):
    A=a[i]+OK
    if A<b[i]:
        ok=b[i]-A
    elif A==b[i]:
        continue
    else:
        ok=-(-A//b[i])*b[i]-A
    OK+=ok

print(OK)
# Judge status: Accepted
# 2020/05/01
# AtCoder Regular Contest 069 - C

# Input
n, m = map(int,input().split())

# c is c
if n >= 2 * m:
    ans = int(m / 2)
else:
    if n < m:
        ans = n + int(max(0, (m - n * 2)) / 4)
    else:
        ans = int(m / 2)

# Output
print(ans)
# Judge status: Accepted
n,d = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
  if (xy[i][0]**2) + (xy[i][1]**2) <= d**2:
    ans += 1

print(ans)
# Judge status: Accepted
N = int(input())
print((N + 1)//2)
# Judge status: Accepted
s=input()
ans=0
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[i:j].count("A")+s[i:j].count("T")+s[i:j].count("C")+s[i:j].count("G")==len(s[i:j]):
            ans=max(ans,len(s[i:j]))
print(ans)
# Judge status: Accepted
def main():
    S = input()
    N = len(S)
    min_d = 10 ** 9
    for i in range(N - 2):
        d = abs(int(S[i: i + 3]) - 753)
        min_d = min(d, min_d)

    print(min_d)


main()
# Judge status: Wrong Answer
n = int(input())
s = str(input())
x = 0
lst = []
for i in range(len(s)):
    if s[i]=='I':
        x += 1
    else:
        x -= 1
    lst.append(x)
print(max(lst))
# Judge status: Accepted
N = int(input())

words = []
ans = "Yes"
for count in range(N):
    word = input()
    if count == 0:
        words.append(word)
        next = word[-1]
        continue
    if next != word[0]:
        ans = "No"
    if words.count(word) == 1:
        ans = "No"
    words.append(word)
    next = word[-1]


print(ans)
# Judge status: Wrong Answer
N,A,B=map(int,input().split())
S=input()
cnt_a=0
cnt_b=0
for i in range(N):
    if cnt_a<A+B:
        if S[i]=='a':
            cnt_a+=1
            print('Yes')
        elif S[i]== 'b' and cnt_b<B:
            cnt_b+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')
# Judge status: Accepted
MOD = 10**9+7

MAXN = 2000
fact = [1]
ifact = [1]
for i in range(MAXN):
    fact.append(fact[-1] * (i+1) % MOD)
    ifact.append(pow(fact[-1], MOD-2, MOD))
def nCr(n, r):
    return fact[n] * ifact[r] * ifact[n-r] % MOD
def nPr(n, r):
    return fact[n] * ifact[n-r] % MOD

s = int(input())
n = s//3

ans = 0
for i in range(1,n+1):
    r = s - 3*i
    ans += nCr(r+i-1, i-1)
ans %= MOD
print(ans)
# Judge status: Accepted
s=input()
for i in range(len(s)-1):
    print("x",end="")
print("x")
# Judge status: Wrong Answer
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t = input()
d = [0]*2*10**5
for i in range(n):
  if t[i] == 'r':
    d[i] = p
  if t[i] == 's':
    d[i] = r
  if t[i] == 'p':
    d[i] = s
for i in range(n):
  if d[i] == d[k+i]:
    d[k+i] = 0
print(sum(d))
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
dp = [None]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
# Judge status: Accepted
N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]

ans=p=0
for i in range(60):
  one=sum([a>>p&1 for a in A])
  zero=N-one
  p+=1
  ans+=(one*zero)*2**i
  ans%=M
  #print(one,zero)
print(ans)
# Judge status: Accepted
k, a, b = map(int, input().split())
k += 1
cnt =  k - (a + 2)

if b - a > 2 and cnt >= 0:
    ans = b + (b - a)*(cnt//2) + cnt%2
else:
    ans = k

print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

for i in range(K, N):
	if A_list[i - K] < A_list[i]:
		print("Yes")
	else:
		print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline

N=int(input())+2
C="R"+input().strip()+"W"

W=[0]*(N+1)
R=[0]*(N+1)

for i in range(N):
    if C[i]=="W":
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]

for i in range(N-1,-1,-1):
    if C[i]=="R":
        R[i]=R[i+1]+1
    else:
        R[i]=R[i+1]

ANS=1<<30
for i in range(N-1):
    ANS=min(ANS,max(W[i],R[i+1]))

print(ANS)
# Judge status: Wrong Answer
import math

n, x = map(int, input().split())
X = sorted(list(map(int, input().split())))
dis = [0] * (n-1)

xdis = 0
for i in range(n-1):
    dis[i] = X[i+1] - X[i]
    if X[i] <= x <= X[i+1]:
        xdis = min(abs(x-X[i]), abs(X[i+1]-x))

if n == 1:
    print(X[0]-x)
        
reg = xdis

for i in range(n-1):
    reg = math.gcd(reg, dis[i])

print(reg)
# Judge status: Accepted
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        flg = True
        for k in range(M):
            for l in range(M):
                flg = flg & (B[k][l] == A[i+k][j+l])
        
        if flg:
            ans = 'Yes'
            print(ans)
            exit()

ans = 'No'
print(ans)
# Judge status: Accepted
i = input().split(" ")
a,b = int(i[0]),int(i[1])
print(int(a*(a-1)/2+b*(b-1)/2))
# Judge status: Wrong Answer
print("AtCoder A{}C Contest".format(input()[0]))
# Judge status: Accepted
N, M = map(int, input().split())
Hs = input().split()
lis = []
for i in range(N):
  lis.append([])
for m in range(M):
  A, B = map(int, input().split())
  lis[A-1].append(B-1)
  lis[B-1].append(A-1)

score = 0

for i in range(N):
  break_flag = 0
  base_h = int(Hs[i])
  #print('base',base_h)
  hikaku = lis[i]
  #print('hikaku', hikaku)
  for j in range(len(hikaku)):
    #print('hikaku', hikaku[j])
    if int(Hs[hikaku[j]]) >= base_h:
      break_flag = 1
  if break_flag != 1:
    score += 1
print(score)
# Judge status: Accepted
def solve(a, b, x):
    def f(n):
        if n == -1:
            return 0
        return n // x + 1
    
    print(f(b) - f(a - 1))



T = list(map(int, input().split()))
solve(T[0], T[1], T[2])
# Judge status: Accepted
N=int(input())
S=input()
T=input()
dup=0
for d in range(N+1):
  # print(d)
  flag=True
  for i in range(N-d):
    
    if T[i]!=S[d+i]:
      # print(T[i],S[d+i])
      flag=False
      break
  if flag:
    dup=N-d
    break
print(2*N-dup)
# Judge status: Accepted
n, m = [int(x) for x in input().split()]
print(1 if n == 1 and m == 1 else m - 2 if n == 1 else n - 2 if m == 1 else (n - 2) * (m - 2))
# Judge status: Accepted
import re

S = input()
T = input()

flag = False
for i in range(len(S) - len(T), -1, -1):
    pattern = S[i:i+len(T)].replace('?', '.')
    m = re.search(pattern, T)
    if m:
        # result = re.sub(pattern, T, S)
        result = S[:i] + T + S[i+len(T):]
        flag = True
        break

if flag > 0 :
    output = result.replace('?', 'a')
    
else :
    output = 'UNRESTORABLE'
    
print(output)
# Judge status: Accepted
def main(): 
    N=int(input())
    ANS=0
    for i in range(1,N+1):
        ANS+=i*(N//i*(N//i+1)//2)
    print(ANS)
main()
# Judge status: Accepted
a, b, x = map(int, input().split())

if x < a:
    print('NO')
elif x-a <= b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a,b,c,d,e=map(int,input().split())
if a==0:
  print(1)
elif b==0:
  print(2)
elif c==0:
  print(3)
elif d==0:
  print(4)
else:
  print(5)
# Judge status: Accepted
import math
s = input().split()
n=int(s[0])
k=int(s[1])
result=0
if n>1:
    result+=math.factorial(n)/math.factorial(2)/math.factorial(n-2)
if k>1:
    result+=math.factorial(k)/math.factorial(2)/math.factorial(k-2)
print(int(result))
# Judge status: Accepted
n = int(input())
print((-n)%1000)
# Judge status: Accepted
def main():
    import sys
    x=int(input())
    cnt=0
    if x==1:
        print(1)
        sys.exit()
    if x==2:
        print(2)
        sys.exit()
    for i in range(1,x):
        if cnt<x:
            cnt+=i
        else:
            t=i-1
            break
    print(t)

if __name__=='__main__':
    main()
# Judge status: Accepted
n=int(input())
if n in [10,100,1000,10000,100000]:
    print(10)
else:
    sum=0
    for i in range(len(str(n))):
        sum+=n%10
        n=n//10
    print(sum)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 0:
    print(-1)
    exit()
cnt = 1
for i in range(a.index(1), n):
    if a[i] == cnt + 1:
        cnt += 1
        print(i)
print(len(a) - cnt)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a+b+c>=22:
  print("bust")
if a+b+c<=21:
  print("win")
# Judge status: Wrong Answer
a, b = map(int, input().split())
print(str(min(a,b))*min(a,b))
# Judge status: Accepted
a,b,c=map(int,input().split())

print("Yes"if c>=a and c<=b else"No")
# Judge status: Accepted
import math
a,b=map(int,input().split())
ans=-1
for i in range(1,5000):
    #print(int(i*0.08))
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        #print(int(i*0.08))
        ans=i
        break
print(ans)
# Judge status: Accepted
import math

N = int(input())
data = []
for _ in range(N-1):
    data.append(list(map(int,input().split())))

def time(t, i):
    if t <= data[i][1]:
        return data[i][0] + data[i][1]
    else:
        k = math.ceil((t - data[i][1]) / data[i][2])
        return data[i][0] + data[i][1] + k * data[i][2]

for i in range(N):
    ans = 0
    for j in range(i, N - 1):
        ans = time(ans, j)
    print(ans)
# Judge status: Accepted
K,A,B=map(int,input().split())
q,r=divmod(K-A+1,2)
print(max(A+q*(B-A)+r,K+1))
# Judge status: Wrong Answer
w,h,x,y=map(int,input().split())
if x==w/2 and y==h//2:
  print("{} {}".format(w*h/2,1))
else:
  print("{} {}".format(w*h/2,0))
# Judge status: Accepted
o = str(input())
e = str(input())
password = ""

for i in range(min(len(o), len(e))):
    password += o[i] + e[i]
if len(o) != len(e):
    password += o[-1]
print(password)
# Judge status: Accepted
c = input()

if c == "ARC":
    print("ABC")

elif c == "ABC":
    print("ARC")
# Judge status: Wrong Answer
h, a = map(int,input().split())
print(int(h/a)+1)
# Judge status: Accepted
N = int(input())

if (N % 2 == 0):
	print(int((N/2)*(N/2)))
else:
	par=int(N/2)
	impar=N-par
	print(int(par*impar))
# Judge status: Accepted
import math
n, x, t = map(int, input().split(" "))

out = int(math.ceil(n/x)) * t if x != 0 else 0
print(out)
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]
s = sorted(a)
one, two = s[-1], s[-2]
for i in a:
  print(one if i != one else two)
# Judge status: Accepted
#!/usr/bin/env python3


def main():
    S = input()
    T = input()
    if S == T[:-1:]:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m = map(int,input().split())
count = 0
lmax = 0
rmin = 100000
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)
print(max(rmin-lmax+1,0))
# Judge status: Accepted

if __name__ == "__main__":
    A, B = input().split()
    if len(A) == 1 and len(B) == 1:
        print(int(A) * int(B))
    else:
        print("-1")
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
count = 0
for i in range (1,N+1):
	a=i//1000
	b=(i%1000)//100
	c=(i-a*1000-b*100)//10
	d=i%10
	#print(a,b,c,d)
	e = a+b+c+d
	if e>=A and e<=B:
		count += i
print(count)
# Judge status: Wrong Answer
x, a, b  = map(lambda x: int(x),  input().split())

if b < a:
  print('delicious')
elif x <= b - a:
  print('safe')
else:
  print('dangerous')
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))

for i in range(N-1):
    abs_a = list(map(abs, A))
    min_a = min(abs_a)
    for i in range(N-1):
        if A[i] < 0:
            A[i] = -A[i]
            A[i+1] = -A[i+1]
    if A[N-1] < 0:
        print(sum(abs_a) - min_a * 2) 
    else:
        print(sum(abs_a))
# Judge status: Wrong Answer
S = input()
len_orig = len(S)
s = set()

for i in range(len(S)):
  s.add(S[i])
if len(s)==len_orig:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N=int(input())
S=input()
ap=[0]*(N+1)
bp=[0]*(N+1)
a=0
b=0
for i in range(N):
  if S[i]=='W':
    a+=1
  else:
    b+=1
  ap[i+1]=a
  bp[i+1]=b
ans=10**9
for j in range(N):
  ans=min(ap[j-1]+bp[N]-bp[j],ans)
print(ans)
# Judge status: Accepted

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

a_ = 2 * x / a / b

import math

#print(a_, a, b, x)

if a_ < a:
    ang = math.degrees(math.atan(b / a_))
    print(ang)
else:
    b_ = 2 * ((a**2) * b - x) / (a**2)
    ang = math.degrees(math.atan(b_ / a))
    print(ang)
# Judge status: Wrong Answer
a = input()
if a == "Sunny":
  print("Cloudy")
elif a == "cloudy":
  print("Rainy")
else:
  print("Sunny")
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
ans = 0
for i in range(1, len(a)-N):
    if i % 2 == 1:
        # print(a[i])
        ans += a[i]
print(ans)
# Judge status: Wrong Answer
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
s = 0
 
for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        total.append(s + j)
    s = s + 3
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())

ans = 0
i = 1
while 5**i <= N:
    ans += ((N // (2 * 5**i)))
    i+=1

if N % 2:
    print(0)
else:
    print(ans)
# Judge status: Accepted
n = int(input())

for i in range(1,10):
    x = i*111
    if n <=x:
        print(x)
        exit()
# Judge status: Accepted
n = int(input())
nums = list(map(int,input().split()))
tall = 0
for i in nums:
    if tall - i >=2:
        print('No')
        exit()
    tall = max(tall,i)
print('Yes')
# Judge status: Wrong Answer
x = int(input())
for i in range(3, 10):
    if i * 200 > x:
        print(11 - i)
        exit()
# Judge status: Wrong Answer
N = int(input())
s = []
for i in range(len(str(N))):
  s.append(N % 10)
  N // 10
if sum(s) % 9 == 0 and sum(s) != 0:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N,K = map(int,input().split())

s = int(((N+1)*((N+1)**2 + 5))/6 -((K-1)*((K-1)**2 + 5))/6)

print(s%(10**9 + 7))
# Judge status: Accepted
N = int(input())
 
A = list(map(int, input().split()))
 
L = {}
R = {}
 
for i in range(N):
  t = A[i]+i
  if t in L:
    L[t] += 1
  else:
    L[t] = 1
  s = i - A[i]
  if s in R:
    R[s] += 1
  else:
    R[s] = 1  
#print(L,R)
ans = 0
for i in range(N):
  t = A[i]+i
  #ans += R[t]
  if t in R.keys():
    ans += R[t]
    #print(t,R[t])
print(ans)
# Judge status: Accepted
import numpy as np


n = int(input())
a = np.array(list(map(int, input().split())))
cumsum_a = a.cumsum()
sum_a = cumsum_a[-1]
ans = 2 * 10**9

for i in range(n-1):
    ans = min(ans, abs(sum_a - 2*cumsum_a[i]))

print(ans)
# Judge status: Accepted
n = int(input())
c = input()
left, right = 0, n - 1
cnt = 0
while left <= right:
    while left < n and c[left] == 'R':
        left += 1
    while right > -1 and c[right] == 'W':
        right -= 1
    if left == n or right == -1 or left >= right: break
    left += 1
    right -= 1
    cnt += 1
print(cnt)
# Judge status: Wrong Answer
n = int(input())
s = list(input())

c0 = 0
c1 = 0
z0 = 0
z1 = 0
for i in range(n):
    if s[i] == "(":
        c0 += 1
    else:
        c1 += 1
    if c0 < c1 and s[i] != "(":
        z0 += 1
    if c0 > c1 - z0 and s[i] != ")":
        z1 += 1
ans = ["("]*z0 + s + [")"]*max(z1-1,0)
print("".join(ans))
# Judge status: Accepted
def main():
    import copy
    s, t = input(), input()
    a = [[] for _ in range(26)]
    b = copy.deepcopy(a)
    for i, j in zip(s, t):
        x, y = map(lambda x: ord(x) - 97, [i, j])
        a[x].append(y)
        b[y].append(x)

    f = all(len(set(i)) <= 1 for i in a)
    g = all(len(set(i)) <= 1 for i in b)
    print("Yes" if f and g else "No")


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 w < v and (b-a)%(v-w)==0 and int((b-a)/(v-w)) <= t:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
# Judge status: Accepted
a = [[int(x) for x in input().split()] for _ in range(3)]

n = int(input())
for _ in range(n):
    b = int(input())

    for i in range(3):
        for j in range(3):
            if b == a[i][j]: a[i][j] = 0

ans = "No"
for i in range(3):
    if sum(a[i]) == 0: ans = "Yes"

for j in range(3):
    if a[0][j] + a[1][j] + a[2][j] == 0: ans = "Yes"

if a[0][0] + a[1][1] + a[2][2] == 0: ans = "Yes"
if a[2][0] + a[1][1] + a[0][2] == 0: ans = "Yes"

print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if (a+b)%2 != 0:
  print('IMPOSSIBLE')
else:
  print((a+b)/2)
# Judge status: Wrong Answer
import math
from itertools import groupby
N = int(input())
A = list(map(int, (input().split())))
cash = 1000
stock = 0
A = [i[0] for i in groupby(A)]
if (A[0] == max(A)):
    print(cash)
else:
    for i in range(len(A)-1):
        if (A[i] > A[i+1]):
            cash = cash + stock*A[i]
            stock = 0
        else:
            stock = stock + math.floor(cash/A[i])
            cash = cash - stock*A[i]
    cash = cash + stock*A[i+1]
    print(cash)
# Judge status: Accepted
a,b,c = (int(x) for x in input().split())
if a<c<b or b<c<a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
T,A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
d = 1000000000000
index = 0
for i in range(N) :
    dT = T - H[i] * 0.006
    dd = abs(A - dT)
    if dd < d :
        d = dd
        index = i
print(index+1)
# Judge status: Accepted
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    n, x = mi()
    a = li()
    cnt = 0
    for i in range(1,n):
        if a[i-1]+a[i]>x:
            cnt += a[i-1]+a[i]-x
            a[i] = max(0, x-a[i-1])
    print(cnt)
        
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n_str = input()
a_str, b_str = n_str.split()
a = int(a_str)
b = int(b_str)

if a <= 8:
    if b <= 8:
        print('Yay!')
    else:
        print(':(')
elif a > 8:
    if b <= 8:
        print('Yay!')
    else:
        print(':(')
# Judge status: Accepted
n = int(input())
import collections

a = list(input())
ans = collections.Counter(a)
for i in range(n-1):
    l = collections.Counter(list(input()))
    for i in ans.keys():
        if i in l:
            ans[i] = min(ans[i],l[i])
        else:
            ans[i] = 0
l = []
for i in ans.keys():
    for j in range(ans[i]):
        l.append(i)
if len(l) == 0:
    print("")
else:
    l.sort()
    print(*l,sep="")
# Judge status: Accepted
N,K=map(int,input().split())
Dlist=list(map(int,input().split()))
flag=True
i=0
while flag:
    ans=str(i)
    num=0
    if i>=N:
        
        for j in range(len(ans)):
            if int(ans[j]) not in Dlist:
                num+=1
            if num==len(ans):
                print(i)
                flag=False
    i+=1
# Judge status: Accepted
D, N = map(int, input().split())
if N != 100:
  if D == 0:
    print(N)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1])
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1])
else:
  if D == 0:
    print(101)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1]+100)
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1]+10000)
# Judge status: Wrong Answer
h = int(input())
w = int(input())
n = int(input())

a = max(h, w)
ans = 1

while a < n:
  a = max(h, w)
  a *= ans
  ans += 1
  
print(ans-1)
# Judge status: Accepted
def main():
    K = int(input())
    A, B = list(map(int, input().split(' ')))
    for n in range(A, B + 1):
        if n % K == 0:
            print('OK')
            exit(0)
    print('NG')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n,d=map(int,input().split())
a=n//(2*(d+1))+1
print(a)