peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from itertools import product
from operator import add

n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

p = list(product([0, 1], repeat=n))
ans = float('inf')
for i in range(len(p)):
    total = [0]*m
    money = 0
    for j in range(n):
        if p[i][j] == 1:
            total = list(map(add, total, ca[j][1:m+1]))
            money += ca[j][0]
    if len([y for y in total if y >= x]) == m:
        ans = min(ans, money)
if ans == float('inf'):
    print(-1)
else:
    print(ans)
# Judge status: Accepted
n = input()
if int(n[-1]) in [2, 4, 5, 7, 9]:
  print('hon')
elif int(n[-1]) in [0, 1, 6, 8]:
  print('pon')
else:
  print('bon')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

for i in A:
    if i%2 == 0:
        if i%3 != 0 and i%5 != 0:
            print('DENIED')
            exit()
print('APPROVED')
# Judge status: Wrong Answer
import copy
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    d = copy.copy(a)
    sum = 0
    for j in range(len(a)):
        if d[j] == b:
            d[j] = c
            sum += d[j]
    print(sum)
# Judge status: Accepted
def schange(s):
    if s=="E":
        return 1
    else:
        return 0

n = int(input())
s = list(map(schange,input()))
ssum = [0]*(n+1)

for i in range(n):
    ssum[i+1] = ssum[i] + s[i]

ans = float('inf')
for i in range(1,n+1):
    turnE = (i-1)-ssum[i-1]
    turnW = ssum[-1] - ssum[i]
    ans=min(ans,turnE+turnW)
    
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

res=False
for dh in range(N-M+1):
    for dw in range(N-M+1):
        tres=True
        for h in range(M):
            for w in range(M):
                if B[h][w]!=A[h+dh][w+dw]:
                    tres=False
        res|=tres
print("Yes"if res else "No")
# Judge status: Wrong Answer
import sys

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

number = N-1
while True:
    number += 1
    for j in range(K):
        if Ds[j] in str(number):
            break
        if j == K-1:
            print(number)
            sys.exit(0)
# Judge status: Wrong Answer
a,b = map(int,input().split())
num = input()
if num[:2].isdecimal() and num[3]== "-" and num[4:].isdecimal():
	print("Yes")
else:
	print("No")
# Judge status: Accepted
w,a,b=map(int,input().split())
print(0 if b<=a<=b+w or a<=b<=a+w else min(abs(b-a-w),abs(a-b-w)))
# Judge status: Accepted
x, y = map(int, input().split())
def grp(z):
  if z in [1,3,5,7,8,10,12]:
    return 'a'
  elif z in [4,6,9,11]:
    return 'b'
  elif z == 2:
    return 'c'
print('Yes' if grp(x) == grp(y) else 'No')
# Judge status: Accepted
x, y = list(map(int, input().split()))

a = {1,3,5,7,8,10,12}
b = {4,6,9,11}
c = {2}

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=0
for i in range(n-1):
  s-=a[i]
  ans+=a[i]*s
  if ans>(10**9+7):
    ans=ans%(10**9+7)
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=0
num=0
for i in range(1,N):
    if A[i-1]<A[i]:
        ans=max(ans,num)
        num=0
    else:
        num+=1
ans=max(ans,num)
print(ans)
# Judge status: Accepted
N=int(input())
A=map(int,input().split())
A=list(A)

L = {}
R = {}
for i in range(N+1):
    L[i] = []  
    R[i] = []

for i in range(N):
    key = i+1+A[i]
    if key<N+1: L[key].append(i+1)
   
for i in range(N):
    key = i+1-A[i]
    if (key<N+1)and(0<=key): R[key].append(i+1)
    

ans=0
for x in range(N+1):
    ans+=len(L[x])*len(R[x])
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
D = B + C - A
print(max(0, D))
# Judge status: Accepted
x = int(input())

if x < 30:
  print("No")
else:
  print ("Yes")
# Judge status: Wrong Answer
N, X, T = [int(s) for s in input().split(" ")]

t = T * (N + X - 1) / X 
print(t)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0 for _ in range(N)]

now = 0
l[now] = 1
count = 0
loop = [0]

while count < K:
    count += 1
    now = A[now]-1
    loop.append(now)
    if l[now] == 1:
        loop = loop[loop.index(now):-1]
        break
    else:
        l[now] = 1

if count == K:
    print(now + 1)
else:
    ans = loop[K % len(loop)]
    print(ans + 1)
# Judge status: Wrong Answer
def split_monster(n, count):
  if n == 0:
    return count
  count += 1
  count = split_monster(int(n/2), count)
  count = split_monster(int(n/2), count)
  return count
 
n = int(input())
count = 0
if n > 1:
	count = split_monster(n, count)
  
print(count)
# Judge status: Accepted
S = input()
K = int(input())

not_1_idx = -1
not_1_num = 1
for i, c in enumerate(S):
    if c != "1":
        not_1_idx = i
        not_1_num = c
        break
if not_1_idx >= 0:
    print(1) if K < not_1_idx + 1 else print(not_1_num)
else:
    print(not_1_num)
# Judge status: Accepted
#C
A,B=map(int,input().split())
GCD=1
for i in range(2,10**5+1):
    if A%i==0 and B%i==0:
        GCD=i

LCM=A*B/GCD
print(int(LCM))
# Judge status: Accepted
A, B, C = map(int,input().split())

for i in range(1,B+1):
    a = A*i
    if a % B == C:
        print('YES')
        exit()
print('NO')
# Judge status: Accepted
s=input()
if s=='ABC':
  print('ARC')
else:
  print('ABC')
# Judge status: Wrong Answer

N = int(input())
A = [int(input()) for i in range(N)]
now = A[0]
ans = 1
for i in range(1,N):
    if now < A[i]:
        continue
    else:
        now = A[i]
        ans += 1
print(ans)
# Judge status: Accepted
S=[int(input()) for i in range(5)]
K=int(input())

def antenna(s,k):
    while True:
        for i in range(5):
            for j in range(5):
                if i!=j:
                    if abs(s[i]-s[j])>k:
                        return ':('
        return 'Yay!'

print(antenna(S,K))
# Judge status: Accepted
k=int(input())
if k%2==0:
  print((k//2)**2)
else:
  print((k//2)*(k//2+1))
# Judge status: Accepted

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

for i in range(N-1):
    tm = 0 #時刻を表す
    for j in range(i, N-1):
        if tm < M[j][1]: #開通していない
            tm = M[j][1]
        elif tm % M[j][2] != 0: #発車していない
            tm += M[j][2] - (tm % M[j][2])
 
        tm += M[j][0]
 
    print(tm)
print(0)
# Judge status: Accepted
import math
N = int(input())
A = list(map(int, input().split()))

g = A[0]

for i in range(1, N):
	g = math.gcd(g, A[i])
	
print(g)
# Judge status: Accepted
N = int(input())
S = input()
MOD = 10 ** 9 + 7
from collections import defaultdict
dic = defaultdict(int)

for s in S:
  dic[s] += 1
  
ans = 1
for value in dic.values():
  ans *= (value + 1)
  ans %= MOD
  
print((ans - 1) % MOD)
# Judge status: Wrong Answer
input_angle = int(input())
input_length = input()

length = input_length.split(' ')
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if sum >= int(length[-1]):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=sum(a)//4*m
c=0

for i in range(n):
    if a[i]>=x:
        c+=1
if c<m:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
ab,bc,ca=abs(a-b),abs(b-c),abs(c-a)
ans=0
if a==b==c:
  print(-1)
else:
  while ab%2==0 and bc%2==0 and ca%2==0:
    ab//=2
    bc//=2
    ca//=2
    ans+=1
  print(ans)
# Judge status: Wrong Answer
A,B,C,D=map(int, input().split())
if A<C:
  if C<A+B:
    if C+D<A+B:
      print(D)
    else:
      print(A+B-C)
  else:
    print(0)
else:
  if A<C+D:
    if A+B<C+D:
      print(B)
    else:
      print(C+D-A)
  else:
    print(0)
# Judge status: Accepted
n, m = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(m)]

ans = [0 for i in range(n)]
balls = [1 for i in range(n)]
ans[0] = 1

for x, y in xy:
    x -= 1
    y -= 1
    if ans[x] == 1 and balls[x] > 0:
        ans[y] = 1
    if balls[x] > 0:
        balls[x] -= 1
        balls[y] += 1
        if balls[x] == 0:
            ans[x] = 0

print(sum(ans))
# Judge status: Accepted
(*abc,) = map(int, input().split())
print(sum(abc) + max(abc) * ((2 ** int(input())) - 1))
# Judge status: Accepted
X,Y = list(map(int, input().split()))
ans = 0
while X<=Y:
    X*=2
    ans+=1

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

mm = 10**18
s = sum(a)
l, r = 0, 0

for i in range(n):
    l += a[i]
    r = s - l
    mm = min(mm, abs(l-r))

print(mm)
# Judge status: Wrong Answer
K, S = map(int, input().split())

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed+1)*(S-ed)//2 # Σ^n{k} = n*(n+1)/2
print(res)
# Judge status: Wrong Answer
import sys

import numpy as np

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = np.array(A)
    B = 61

    ans = 0
    for b in range(B):
        cnt_1 = np.sum((A >> b) & 1)
        ans += 2 ** b * cnt_1 * (N - cnt_1)
        ans %= P
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,d = map(int,input().split())
ans = 0
for i in range(n):
  x,y = map(int,input().split())
  if x**2+y**2 <= d**2:
    ans += 1
print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())
l = [list(map(int,input().split())) for i
     in range(N)]
for i in range(N):
  del l[i][0]
if N!=1:
  for i in range(N-1):
    a = set(l[i])&set(l[i+1])
    l[i+1] = a
    print(len(a))
else:
  print(len(l))
# Judge status: Accepted
a,b,c = map(int,input().split())
print (c) if a*c <= b else print (b//a)
# Judge status: Accepted
import math

a, b = map(int, input().split())
x = int(str(a) + str(b))
if math.sqrt(x) == math.ceil(math.sqrt(x)):
  print("Yes")
else :
  print("No")
# Judge status: Wrong Answer
from sys import stdin
import math

h, w = [int(x) for x in stdin.readline().rstrip().split()]

if h % 2 == 0:
    print(int(h * w / 2))
elif w % 2 == 0:
    print(int(h * w / 2))
else:
    print(int(h * w / 2 + 1))
# Judge status: Accepted
II = lambda: int(input())
SI = lambda: input()
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
n = II()
a = LI()
d = [0]*n
d[1] = abs(a[1]-a[0])
for i in range(2,n):
	d[i] = min(d[i-1]+abs(a[i-1]-a[i]),d[i-2]+abs(a[i-2]-a[i]))
print(d[-1])
# Judge status: Accepted
import math

radius = int(input())

ans = 2*radius*math.pi
print(ans)
exit()
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = map(int,readline().split())
h = list(map(int,readline().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(1,n):
  for j in range(min(k,i)):
    dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]))

print(dp[n-1])
# Judge status: Wrong Answer
import sys
n = int(input())
x = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 != d2:
        x = 0
    else:
        x += 1
        if x == 3:
            print("Yes")
            sys.exit
if x != 3:
    print("No")
# Judge status: Accepted
from collections import Counter
n = int(input())
D = list(map(int,input().split()))
Dc = Counter(D)
mod = 998244353
ans = 1

if Dc[0]!=1 or D[0]!=0:
    print(0)
else:
    for i in range(max(D)):
        ans = ans*pow(Dc[i],Dc[i+1])%mod
    print(ans%mod)
# Judge status: Accepted
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a=min(a*int(i),d+1)
print([a,-1][a>d])
# Judge status: Accepted
import collections
S = input()
T = input()
if sorted(collections.Counter(S).values()) == sorted(collections.Counter(T).values()):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
_,p=open(0)
*p,=map(int,p.split())
print(sum(a<b<c or c<b<a for a,b,c in zip(p,p[1:],p[2:])))
# Judge status: Accepted
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.reverse()
B.reverse()
cnt = 0
for i in range(N):
    cnt += -(A[i]+cnt)%B[i]
print(cnt)
# Judge status: Accepted
n, m = map(int, input().split())
mod = 10**9 + 7
if abs(n-m) > 1:
    ans = 0
elif n == m:
    ans = 2
    for i in range(2, n+1):
        ans = ans*i % mod
    for i in range(2, m+1):
        ans = ans*i % mod
else:
    ans = 1
    for i in range(2, n+1):
        ans = ans*i % mod
    for i in range(2, m+1):
        ans = ans*i % mod
print(ans)
# Judge status: Wrong Answer
n,x,y= map(int, input().split())

ans=[0]*n

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

for i in range(n):
    print(ans[i])
# Judge status: Accepted
import fractions
N=int(input())
A=list(map(int,input().split()))
ans=A[0]
for i in range(N):
    a=fractions.gcd(ans,A[i])
    ans=a
print(ans)
# Judge status: Accepted
S = input()

if 'RSR' in S:
	print(1)
else:
	print(S.count("R"))
# Judge status: Accepted
N=int(input())
S=input()
ans,r,g,b=0,0,0,0
for s in S:
  if s=='R':
    r+=1
  elif s=='G':
    g+=1
  elif s=='B':
    b+=1
ans=r*g*b
for i in range(N-2):
  a=S[i]
  for j in range(i+1,N-1):
    if 2*j-i>=N:
      break
    b,c=S[j],S[j+j-i]
    if a!=b and b!=c and c!=a:
      ans-=1
print(ans)
# Judge status: Accepted
a = [int(i) for i in input().split()]
if max(a) == (sum(a)-max(a)):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s=list(input())
m=len(s)
a=[0]*(m+1)
add=1
for i in range(m):
    if s[i]=="<":
        a[i+1]+=add
        add+=1
    else:
        add=1
for i in range(m-1,-1,-1):
    if s[i]==">" and a[i]<=a[i+1]:
        a[i]+=a[i+1]-a[i]+1
print(sum(a))
# Judge status: Accepted
N = int(input())
S = []
for i in range(N):
    s = input()
    ss = sorted(s)
    S.append("".join(ss))
S.sort()
ans = 0
count = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        count += 1
        ans += count
    else:
        count = 0
print(ans)
# Judge status: Wrong Answer
import math
import itertools
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
def distance(x1, y1, x2, y2):
    return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)

dist = 0
cnt = 0
for p in itertools.permutations(range(n)):
    for i in range(n-1):
        dist += distance(xy[i][0], xy[i][1], xy[i+1][0], xy[i+1][1])
    cnt += 1
ans = dist / cnt
print(ans)
# Judge status: Accepted
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
sx,sy,tx,ty=map(int,input().split())
h=ty-sy
w=tx-sx

ans=""
ans+="R"*w+"U"*h
ans+="L"*w+"D"*h
ans+="D"
ans+="R"*(w+1)+"U"*(h+1)+"L"
ans+="U"+"L"*(w+1)+"D"*(h+1)+"R"
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

ans = 0
prev = a[0]
for e in a:
  if e - prev > 0:
    ans += e - prev
  prev = e

print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
h = list(map(int, input().split()))
maxh = []
for height in h:
    maxh.append(height)
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    maxh[a] = max(maxh[a], h[b])
    maxh[b] = max(maxh[b], h[a])
g = 0
for height, maxheight in zip(h, maxh):
    if height == maxheight:
        g += 1
print(g)
# Judge status: Accepted
x = int(input())
print('YES' if x == 7 or x == 5 or x == 3 else 'NO')
# Judge status: Wrong Answer
A,B,K = map(int,input().split())
result = []
for i in range(1,100,1):
  if A%i == 0 and B%i == 0:
    result.append(i)
print(result,result[-K])
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]
print(A)
a = 0
for i in range(N):
    tmp = A[:i]
    tmp.extend(A[i+1:])
    for j in range(N-2):
        for k in range(N-1-j):
            if tmp[j] == tmp[k]:
                a += 1
print(a)
# Judge status: Wrong Answer
X = int(input())
K = 360//X
if K*X < 360:
  K = K+1
print(K)
# Judge status: Accepted
def resolve():
    S = input()
    ans, cnt = 0, 0
    for s in S:
        if s == 'A' or s == 'C'or s == 'G' or s == 'T':
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    ans = max(ans, cnt)
    print(ans)

resolve()
# Judge status: Accepted
N,A,B = map(int,input().split())
count = 0
for n in range(1,N+1):
  n = str(n)
  l = []
  for i in range(len(n)):
    l.append(int(n[i]))
  if A <= sum(l) <= B:
    count += int(n)

print(count)
# Judge status: Accepted
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()

def main():
  n,m,k = map(int, input().split())
  a = list(map(int, input().split()))
  b = list(map(int, input().split()))
  sa = np.cumsum([0]+a)
  sb = np.cumsum([0]+b)
  rx = 0
  rb = m
  for ra in range(0,n+1): 
    while (sb[rb] + sa[ra]) > k and rb>0 :
      rb-=1
    if (sb[rb] + sa[ra]) <= k:
      rx = max(rx,ra+rb)
  print(rx)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
station = [list(map(int, input().split())) for _ in range(N - 1)]

lst = []

for i in range(N - 1):
    c, s, f = station[i]

    for j in range(len(lst)):
        a = lst[j]

        if a >= s:
            a += (a % f) + c
        else:
            a = s + c

        lst[j] = a

    lst.append(s + c)


lst.append(0)
for a in lst:
    print(a)
# Judge status: Accepted
a,b,c,d = tuple(map(int, input().split(" ")))

print(max(a*c, a*d, b*c, b*d))
# Judge status: Accepted
N, M = map(int, input().split())
if N == M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(N - 2, M - 2))
else:
    print((N - 2) * (M - 2))
# Judge status: Wrong Answer
S = int(input())
mod = 10 ** 9 + 7

if S < 3:
  print(0)
elif S < 6:
  print(1)
elif S == 6:
  print(2)
else:
  cnt = 3
  S -= 7
  for i in range(1,S+1):
    cnt += i
  print(cnt % mod)
# Judge status: Accepted
N,M=map(int, input().split())
S=[]
for i in range(N):
    a,b=map(int, input().split())
    S.append((a,b))

C=[]
for i in range(M):
    c,d=map(int, input().split())
    C.append((c,d,i+1))
#print(C)
for s in S:
    a,b=s
    now=0
    dis=10**9

    for t in C:
        c,d,n=t
        D=abs(c-a)+abs(d-b)
        
        if D<dis:
            dis=D
            now=n
    print(now)
# Judge status: Accepted
import fractions

def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    G = [A[0]]
    prev = A[0]
    for i in range(1, n):
        prev = fractions.gcd(prev, A[i])
        G.append(prev)

    ANS = [G[n - 2]]
    prev = A[n - 1]
    for i in range(n - 2, 0, -1):
        ANS.append(fractions.gcd(G[i - 1], prev))
        prev = fractions.gcd(A[i], prev)

    ANS.append(prev)

    print(max(ANS))

if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c,d,e,k=[int(input()) for _ in range(6)]
print('Yay!' if k>=e-a else ':(')
# Judge status: Accepted
n,m = [int(x) for x in input().split()]
x = []
for i in range(m):
  x.append([int(x) for x in input().split()])
count = [1] * (n+1)
flag = [0] * (n+1)
flag[1] = 1
for i in range(m):
  if flag[x[i][0]] == 1:
    flag[x[i][1]] = 1
  if count[x[i][0]] == 1:
    flag[x[i][0]] = 0
  count[x[i][0]] -= 1
  count[x[i][1]] += 1

res = 0
for i in range(n+1):
  if flag[i] == 1:
    res += 1
    
print(res)
# Judge status: Wrong Answer
n,a,b=map(int,input().rstrip().split(' '))

def count(n):
  x = str(n)
  sum=0
  for s in x:
    sum+=int(s)
  return sum
    
ans=0
for i in range(1,n+1):
  if(a <= count(i) and count(i) <=b):ans+=1

print(ans)
# Judge status: Accepted
from collections import deque

X = input()
stack = deque([X[0]])
for i in range(1, len(X)):
    if X[i] == 'S':
        stack.appendleft(X[i])

    if X[i] == 'T':
        if stack:
            check = stack.popleft()
            if check == 'T':
                stack.appendleft(check)
                stack.appendleft(X[i])
        else:
            stack.appendleft(X[i])

print(len(stack))
# Judge status: Accepted
s = input()
ans = []
for i in s:
    if i == "1":
        ans += [1]
    elif i == "0":
        ans += [0]
    elif len(ans) > 0:
        ans.pop(-1)
for x in ans:
    print(x, end="")
# Judge status: Accepted
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

else:
    p = list(map(int, input().split()))
    li = [i for i in range(-101, 102) if i not in p]
    li.sort(reverse = True)

    tmp1 = float('inf')
    ans = float('inf')

    for i in li:
        if abs(i - x) <= tmp1:
            if i < ans:
                ans = i
                tmp1 = abs(i - x)

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

c = 0
for i in range(N):
    x , y = map(int,input().split())

    z = (x**2+y**2)**0.5

    # print(z)

    if D <= z:
        c+=1
        print(c)
# Judge status: Wrong Answer
s,a='036,048,246,258,345,678,',open(0).read().split()
for i in a[9:]:s=s.replace(str(a.index(i)),'')
print('NYoe s'[',,'in s::2])
# Judge status: Wrong Answer
a,b,k=map(int, input().split())
k=min(k,b-a)
*al,=range(a,a+k+1)
*al2,=range(b-k,b+1)
ans=al+al2
ans=list(set(ans))
ans.sort()
for i in ans:print(i)
# Judge status: Accepted
N = int(input())

D = []
for i in range(N):
    d1, d2 = map(int, input().split())
    D.append([d1, d2])

count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            break
    else:
        count = 0

print("Yes") if count == 3 else print("No")
# Judge status: Wrong Answer
N = input()
nums = input().split(" ")
nums = [int(i) for i in nums]

if len(set(nums)) == N:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
from collections import defaultdict
d = defaultdict(int)
for a in A:
  d[a]+=1
ans=sum(A)
for q in range(Q):
  b,c=map(int,input().split())
  ans+=(c-b)*d[b]
  d[c]+=d[b]
  d[b]=0
  print(ans)
# Judge status: Accepted
H, N = map(int, input().split())
arr = list(map(int, input().split()))
if sum(arr) < H:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
N, K = map(int, input().split())
An = list(map(int, input().split()))
Bn = []
Bn.append(0)
for i in range(N):
    Bn.append(An[i]+Bn[i])
for i in range(K+1, N+1):
    if (Bn[i]-Bn[i-K] > Bn[i-1]-Bn[i-K-1]):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B = lr()
answer = A * B // gcd(A, B)
print(answer)
# 50
# Judge status: Wrong Answer
#A
p, q, r = map(int, input().split())
print(min(p+q,q+r,q+p))
# Judge status: Wrong Answer
a = int(input())
b = int(input())

List = {a, b}

if List == {1, 2}:
  print(3)
if List == {2, 3}:
  print(1)
if List == {3, 1}:
  print(1)
# Judge status: Wrong Answer
A=sorted(map(int,input().split()))
print( A[1]*2-1 if A[1]+A[0]-1 <= A[1]*2-1 else A[1]+A[0]-1 )
# Judge status: Accepted
d = input().split(" ")
n = int(d[0])
a = int(d[1])
b = int(d[2])
s = a + b
c = (n // s) * a
if n % s > a:
	c += a
else:
	c += n % s
print(c)
# Judge status: Accepted
import functools
import math
def gcd_2(*vals):
    return functools.reduce(math.gcd, vals)
K = int(input())
ANS = 0
L = list(range(1, K+1))
M = list(range(1, K+1))
N = list(range(1, K+1))



for i in range(K):
    for j in range(K):
        for k in range(K):
            ANS = ANS + gcd_2(L[i], M[j], N[k])

print(ANS)
# Judge status: Wrong Answer
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort(reverse = True)
b.sort()

if b[0] - a[0] < 1:
    print('War')
else:
    print('No War')
# Judge status: Accepted
s,w = map(int,input().split())
if s <=w:
    print("unsafe")
else:
    print("safe")
# Judge status: Accepted
#!/usr/bin/env python3


import math

def main():
    a,b = map(int, input().split())
    print(math.ceil((b-1)/(a-1)))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
t = input()
t = t.replace("??", "PD")
t = t.replace("P?", "PD")
t = t.replace("?D", "PD")
t = t.replace("?", "D")
print(t)
# Judge status: Wrong Answer
N,K=map(int,input().split())
a = 1
while K <= N:
  N = N // K
  a =a+1
  print(a)
 
print(a)