Harryxun/stf_run huggingface dataset:
from sys import stdin

def main():
    A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))

    A=[0,0,1]
    wc = A.count(1)
    indices = [i for i, x in enumerate(A) if x == 1]
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()


### FIXED CODE ###

from sys import stdin

def main():
    A=stdin.readline().replace('B', '0').replace('W', '1')
    #A=list(map(int,bw))
    #A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))

    wc = A.count('1')
    indices = [i for i, x in enumerate(A) if x == '1']
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()
depth=[-1]*N
parent=[-1]*N
childs=[[] for i in range(N)]

depth[0]=0
def calc_depth(n):
    for child in childs[n]:
        depth[child]=depth[n]+1
        calc_depth(child)

def calc_height(n):
    if childs[n]==[]:
        return 0 
    childs_height=[]
    for child in childs[n]:
        childs_height.append(calc_height(child))
    childs_height.sort(reverse=True)
    heightlist=[childs_height[i]+i for i in range(len(childs_height))]
    return max(heightlist)+1

for i in range (1,N):
    a=int(input())-1
    childs[a].append(i)

print(calc_height(0))


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

N=int(input())


depth=[-1]*N
parent=[-1]*N
childs=[[] for i in range(N)]

depth[0]=0
def calc_depth(n):
    for child in childs[n]:
        depth[child]=depth[n]+1
        calc_depth(child)

def calc_height(n):
    if childs[n]==[]:
        return 0 
    childs_height=[]
    for child in childs[n]:
        childs_height.append(calc_height(child))
    childs_height.sort(reverse=True)
    heightlist=[childs_height[i]+i for i in range(len(childs_height))]
    return max(heightlist)+1

for i in range (1,N):
    a=int(input())-1
    childs[a].append(i)

print(calc_height(0))
N,K=map(int,input().split())
a=list(map(int,input().split()))
L=[]
for i in range(N):
    for j in range(i+1,N+1):
        L.append(sum(a[i:j]))

L.sort(reverse=True)
M=[]
#print(L)

for j in range(31):
    if 2**(31-j)<=L[0]:
        if 2**(31-j)<=L[K-1]:
            for l in range(N):
                if L[l]>=2**(31-j):
                    M.append(L[l])
            break
        else:
            for k in range(N):
                L[k]=L[k]%(2**(31-j))
            L.sort(reverse=True)
            
ans=2**(31-j)
#print(M)

for a in range(1,31-j):
    for b in range(len(M)):
        M[b]%=(31-j-a)
    M.sort(reverse=True)
    if M[K-1]>=2**(31-j-a):
        ans+=2**(31-j-a)
        for c in range(len(M)):
            if M[c]<2**(31-j-a):
                del M[c]
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
l=list(map(int,input().split()))
L=[0]
for i in range(N):
    L.append(L[-1]+l[i])
#print(L)
A=[]
for i in range(N):
    for j in range(i+1,N+1):
        A.append(L[j]-L[i])
#print(A)
B=[]
for i in range(len(A)):
    B.append(format(A[i],'040b'))
#print(B)


for i in range(40):
    cnt=0
    for j in B:
        if j[i]=="1":
            cnt+=1
    if cnt>=K:
        S=i
        break

ans=2**(39-S)
C=[]
for j in B:
    if j[S]=="1":
        C.append(j)
        
#print(ans)
#print(C)

for i in range(S+1,40):
    D=[]
    for j in C:
        if j[i]=="1":
            D.append(j)
    if len(D)>=K:
        ans+=2**(39-i)
        C=D
print(ans)
N = input()
A = input()
 
if A >= (N % 500):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
A = int(input())
 
if  A >= (N%500):
  print("Yes")
else:
  print("No")
S = int(input())
KL = [i for i in range(S)]
for i in range(1,S):
    for j in range(1,S):
        id = bisect.bisect_right(KL,i*j-S)
        if KL[id-1] == i*j-S:
            print(0,0,i,KL[id-1],j,1)
            exit()

### FIXED CODE ###

S = int(input())
X2 = 10**9
Y2 = 1
X3 = (X2-(S%X2))%(10**9)
Y3 = (S+X3)//X2
print(0,0,X2,Y2,X3,Y3)
def main():
    import sys
    input = lambda: sys.stdin.buffer.readline().rstrip()
    n, w_max = map(int, input().split())
    import numpy as np

    dp = np.zeros(w_max+1, dtype=int)
    v,w = [],[]
    for i in range(n):
        w_, v_ = map(int, input().split())
        v.append(v_)
        w.append(w_)
    for i in range(n):
        print(np.maximum(dp[w[i]:], v[i]+dp[:-w[i]]))
        dp[w[i]:] = np.maximum(dp[w[i]:], v[i]+dp[:-w[i]])
    print(dp[-1]) 

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = lambda: sys.stdin.buffer.readline().rstrip()
    n, w_max = map(int, input().split())
    import numpy as np

    v,w = [],[]
    for i in range(n):
        w_, v_ = map(int, input().split())
        v.append(v_)
        w.append(w_)
    dp = np.array([10**10]*(10**5+1),dtype=int)
    dp[0] = 0
    for i in range(n):
        dp[v[i]:] = np.minimum(dp[v[i]:], w[i]+dp[:-v[i]])
    ans = 0
    for i,w in enumerate(dp):
        if w<= w_max:
            ans = i
    print(ans)


if __name__ == '__main__':
    main()
a = list(map(int, input().split()))
k = []
for i in range(0, a[0]):
  b = list(map(int, input().split()))
  del b[0]
  k.append(b)
 
kk = 0
for i in range(1, a[1] + 1):
  if k.count(i) == a[0]:
    kk += 1
print(q)

### FIXED CODE ###

a = list(map(int, input().split()))
k = []
for i in range(0, a[0]):
  b = list(map(int, input().split()))
  del b[0]
  k += b

kk = 0
for i in range(1, a[1] + 1):
  if k.count(i) == a[0]:
    kk += 1
print(kk)
n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(n+1) for i in range(n+1)]

def func(n,x):
    if n==0 and x==0:
        return 1
    if dp[n][x]!=-1:
        return dp[n][x]
    
    if n==0 and x!=0:
        return 0
    
    if x==0 and n!=0:
        return 1
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))


### FIXED CODE ###


n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(n+1) for i in range(n+1)]
def func(n,x):
    for i in range(0,n+1):
        for j in range(0,n+1):
            if j==0:
                dp[i][j] = 1
            elif i==0:
                dp[i][j]=0
            else:
                p=(arr[i-1])*dp[i-1][j-1]
                q=(1-arr[i-1])*dp[i-1][j]
                dp[i][j] = p+q 
    
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))
a,b=input(),input()
aa=int(a)
bb=int(b)

c=int((3*aa+bb)/2)
print(c)

### FIXED CODE ###

import math

a,b=map(int,input().split())
aa=int(a)
bb=int(b)

c=math.floor(int((3*aa+bb)/2))
print(c)
# ABC064_B
N = int(input())
A = [list(map(int,input().split()))]
print(max(A)-min(A))

### FIXED CODE ###

# ABC064_B
N = int(input())
A = list(map(int,input().split()))
print(max(A)-min(A))
string=input

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A in range(1,10):
else:
    print(-1) break
if B in range(1,10):
else:
    print(-1) break
print(A*B)

### FIXED CODE ###


string=input()
string=string.split(' ')
A= int(string[0])
B= int(string[1])

if A>9 or B>9:
    print(-1)
else:
        print(A*B)
a,b=input().split()

if(a=b):
  print("Yes")
  
if(a!=b):
  print("No")

### FIXED CODE ###

a,b=input().split()
if(a==b):
  print("Yes")
if(a!=b):
  print("No")
l = input().strip().split()
print(l[0] + l[1]/2)

### FIXED CODE ###

x, y = map(int, input().split())
print(x + y//2)
def ceildiv(a, b):
    return -(-a // b)

h, w = map(int, input().split())

if (h==1 or w==1):
    print(1)
else:
    print(ceildiv(h,2)*ceildiv(w,2) + (ceildiv(h,2)-1)*(ceildiv(w,2)-1))

### FIXED CODE ###

ks = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(ks[k-1])
X=int(input())
for A in range(int(X**(1/5))+2):
    if X>=A**5:
        if int((X-A**5)**(1/5))==((X-A**5)**(1/5)):
            B=-int((X-A**5)**(1/5))
            break
    else:
        if int((A**5-X)**(1/5))==((A**5-X)**(1/5)):
            B=int((A**5-X)**(1/5))
            break
print(A,B)

### FIXED CODE ###

X=int(input())
flagp=False
flagm=False
flage=True
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            flage=False
            break
        elif B5==-B**5:
            flagm=True
            flage=False
            break
    else:
        continue
    break
if flagp:
    print(A,B)
elif flage:
    raise Exception
else:
    print(A,-B)
X = int(input())
 
ans = (X//500)*1000
ans += ((X % 500)//5) * 5
 
print(ans)

### FIXED CODE ###

S=input()
if (S[2]==S[3]) and (S[4]==S[5]):
    print('Yes')
else:
    print('No')
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    
    A.sort()
    print(A[N - 1] - A[0])
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = []
    data = input().split()
    for i in range(N):
        A.append(int(data[i]))
    
    A.sort()
    print(A[N - 1] - A[0])
    
if __name__ == "__main__":
    main()
str_list = input().split()
str_dic = {str_list[0]:int(input()),str_list[1]:int(input())}

### FIXED CODE ###

str_list = input().split()
num_list =  [int(i) for i in input().split()]
del_boll = input()

boll_dic = {str_list[0]:num_list[0],str_list[1]:num_list[1]}
boll_dic[del_boll] -= 1

print(boll_dic[str_list[0]],boll_dic[str_list[1]])
import fractions
import  functools

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




N = int(input())
A = [int(x) for x in input().split()]
a2 = A.copy()
max = 0
for i,_ in enumerate(A):
    A.pop(i)
    res = A[0]
    for i in A[1:]:
        res = gcd(res,i)
    max = res if res >= max else max
    A = a2.copy()


print(max)

### FIXED CODE ###

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


gcdL = []
gcdR = []

N = int(input())
A = [int(x) for x in input().split()]
gcdL.append(0)
length_A = len(A)
for i in range(1,length_A):
    gcdL.append(gcd(A[i-1],gcdL[i-1]))


gcdR.append(0)
for i in range(1,length_A):
    gcdR.append(gcd(A[length_A-i],gcdR[i-1]))



list_gcd = []
for i in range(length_A):
        list_gcd.append(gcd(gcdL[i],gcdR[length_A-i-1]))

print(max(list_gcd))
s = input()

item = np.arange(len(s) - 1) + 1
n = len(item)
count = 0
for i in range(2 ** n):
    sidx = 0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            eidx = item[j]
            count += int(s[sidx:eidx])
            sidx = eidx
    count += int(s[sidx:])
print(count)

### FIXED CODE ###

import numpy as np
s = input()

item = np.arange(len(s) - 1) + 1
n = len(item)
count = 0
for i in range(2 ** n):
    sidx = 0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            eidx = item[j]
            count += int(s[sidx:eidx])
            sidx = eidx
    count += int(s[sidx:])
print(count)
xs,ys,xt,yt = map(int, input().split())
n = int(input())
c = [(xs,ys, 0),(xt,yt,0)]
for i in range(n):
    x,y,r = map(int, input().split())
    c.append((x,y,r))

def circle_circle(ax,ay,ar,bx,by,br):
    d =((ax-bx)**2 + (ay-by)**2)**0.5
    return max(0, d-(ar+br))

def dijkstra(V, edges, root):
    import heapq

    visited = [False] * V
    nodes = [[] for i in range(V)]
    cost = [[] for i in range(V)]

    for e in edges:
        s, t, d = e
        nodes[s].append(t)
        cost[s].append(d)

    dist = [float('inf')] * V
    dist[root] = 0

    h = [(0, root)]
    while h:
        c, v = heapq.heappop(h)
        if visited[v]:
            continue
        visited[v] = True
        for i in range(len(nodes[v])):
            t = nodes[v][i]
            nc = c + cost[v][i]
            if dist[t] > nc:
                dist[t] = nc
                heapq.heappush(h, (nc, t))
    return dist
edges = []
for i in range(n+1):
    for j in range(i+1, n+2):
        d = circle_circle(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2])
        edges.append((i,j,d))
        edges.append((j,i,d))
dij = dijkstra(n+2, edges, 0)
print(dij[1])


### FIXED CODE ###

n,x = map(int, input().split())
a = list(map(int, input().split()))
b = a[::-1]

def solve(a):
    total = 0
    if a[0] > x:
        total += a[0]-x
        a[0] = x

    for i in range(1, n):
        if a[i-1] + a[i] > x:
            d = (a[i-1] + a[i]) - x
            total += d
            a[i] = max(0, a[i] - d)
    return total

print(min(solve(a), solve(b)))
n,u,v=map(int,input().split())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)
depth=[-1]*(n+1)
height=[-1]*(n+1)
def dsf_1(p,d):
    depth[p]=d
    for c in E[p]:
        if depth[c]==-1:
            dsf_1(c,d+1)
dsf_1(v,0)
def dsf_2(p):
    if len(E[p])==1 and p!=v:
        height[p]=0
    else:
        h=0
        for c in E[p]:
            if height[c]==-1 and depth[c]>depth[p]:
                dsf_2(c)
            h=max(h,height[c])
        h+=1
        height[p]=h
dsf_2(v)
d=depth[u]
dd=d//2+1
while d>dd:
    for c in E[u]:
        if depth[c]==d-1:
            u=c
            d-=1
            break
print(height[u]+depth[u]-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
n,u,v=map(int,input().split())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)
depth=[-1]*(n+1)
dis=[-1]*(n+1)
def dsf_1(p,d):
    depth[p]=d
    for c in E[p]:
        if depth[c]==-1:
            dsf_1(c,d+1)
dsf_1(v,0)
def dsf_2(p,d):
    dis[p]=d
    for c in E[p]:
        if dis[c]==-1:
            dsf_2(c,d+1)
dsf_2(u,0)
ans=0
for i in range(1,n+1):
    if len(E[i])==1 and i!=v:
        if dis[i]<depth[i]:
           ans=max(ans,depth[i]-1)
print(ans)
(r, c) = [int(i) for i in input().split()]
    src = []
    for i in range(r):
        src.append([int(i) for i in input().split()])

print(src)

### FIXED CODE ###

(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)
 
for rc in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))
import math
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0)
elif H==2 and W==2:
    print(1)
else:
    def cal(x,y):
        return max(x*y,(W-x)*y,(H-y)*W) - min(x*y,(W-x)*y,(H-y)*W)

    def cal2(H,W):
        x1,x2 = math.floor(W/2),math.ceil(W/2)
        y1,y2 = math.floor((2*H)/3),math.ceil((2*H)/3)
        return min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2),H,W)

    print(min(cal2(H,W),cal2(W,H))

### FIXED CODE ###

import math
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0)
elif H==2 and W==2:
    print(1)
else:

    def cal(x,y):
        return max(x*y,(W-x)*y,(H-y)*W) - min(x*y,(W-x)*y,(H-y)*W)

    x1,x2 = math.floor(W/2),math.ceil(W/2)
    y1,y2 = math.floor((2*H)/3),math.ceil((2*H)/3)

    ans1 = min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2))

    W,H = H,W
    x1,x2 = math.floor(W/2),math.ceil(W/2)
    y1,y2 = math.floor((2*H)/3),math.ceil((2*H)/3)

    ans2 = min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2))

    if H ==2 or W == 2:
        print(min(ans1,ans2,max(H,W)))
    else:
        print(min(ans1,ans2,H,W))
N = int(input())
L = len(str(N))
B = int(str(N)[0])
c = 0
for i in range(1,N+1):
    I = str(i)
    l = len(I)
    a,b = int(I[0]),int(I[l-1])
    if a == 0 or b == 0:
        continue
    else:
        if a == b:
            c += 1
        for m in range(max(L-2,0)):
            c += 10**m
        if L == 1:
            continue
        if b > B:
            continue
        elif b < B:
            c += 10**(L-2)
        elif L > 2:
            c += int(str(N)[1:L-1])
        elif L == 2:
            c += 1
print(c)

### FIXED CODE ###

a,b = input().split()
A,B = min(int(a),int(b)),max(int(a),int(b))
print(int(str(A)*B))
from functools import reduce
from math import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
else:
    left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
    right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

    ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
    ans = max([right[1], ans, left[-2]])
    print(ans)


### FIXED CODE ###

A, B,  T = [int(s) for s in input().split()]
print(B*(T//A))
# 例： 1 - 8 までの数列
# 1 2 3 4 5 6 7 8

# 余りを最大化するには、Nに対する N-1 の余り。つまり１ずつ減じた値の余りをとる。最初の値は N
# 8 1 2 3 4 5 6 7

#  (8 % 1) + (1 % 2) + (2 % 3) + .... + (7 % 8)
#   0 + 1   2 + ... + 7

N = int(input())
print(sum(list(range(N))))

### FIXED CODE ###

# 例： 1 - 8 までの数列
# 1 2 3 4 5 6 7 8

# 余りを最大化するには、Nに対する N-1 の余り。つまり１ずつ減じた値の余りをとる。最初の値は N
# 8 1 2 3 4 5 6 7

#  (8 % 1) + (1 % 2) + (2 % 3) + .... + (7 % 8)
#   0 + 1   2 + ... + 7

N = int(input())
print(N * (N-1) // 2)
x = input().stlip()
fn = 0
sn = 0

for i in range(len(x)):
  if int(x[i]) == 5:
    fn += 1
  elif int(x[i]) == 7:
    sn += 1

if fn = 2:
  if sn = 5:
    print("YES")
  else:
    print("NO")
else:
  print("NO")

### FIXED CODE ###

x = input().split()
fn = 0
sn = 0
 
for i in range(len(x)):
  if int(x[i]) == 5:
    fn += 1
  elif int(x[i]) == 7:
    sn += 1
 
if fn == 2:
  if sn == 1:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
max = 0
i = 0
j = 0
k = 0

n_max = int(raw_input())
price = []
for k in range(n_max):
    price.attend(int(raw_input())
    
for i in range(n_max)
    for j in range(k, n_max)
        if max <= price[j] - price[i]:
            max = price[j] - price[i]
print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
T=input()
ans=''
i=0
N=len(T)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and ans[-1]=='P':
      ans=ans+'D'
    elif i==N-1 and ans[-1]=='D':
      ans=ans+'D'
    elif i>0 and i<N-1 and ans[-1]=='D' and T[i+1]=='P':
      ans=ans+'D'
    elif i<N-1 and T[i+1]=='D':
      ans=ans+'P'
    elif i<N-1 and T[i+1]=='?':
      ans=ans+'PD'
      i+=1
  i+=1
print(ans)

### FIXED CODE ###

T=input()
ans=''
i=0
N=len(T)
if N==1 and T=='?':
  print('D')
  exit(0)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)
N = int(input())

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


for i in range(0, len(H), 1):
    if H[i] > H[i+1]:
        H[i]=H[i]-1

check_list = sorted(H)

if check_list==H:
    print("Yes")
else:
    print("No")


### FIXED CODE ###


N = int(input())

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

if len(H) != 1:
    for i in range(0, N-1, 1):
        if H[i] > H[i+1]:
            H[i+1]=H[i+1]+1

    check_list = sorted(H)

    if check_list==H:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")
int 1,2,3 = input():

if 1 != 2{
  if 1 != 3{
    print("No")
  }
}
else{
  print("Yes")
}


### FIXED CODE ###

on= input()

on = on.split()
 
if (on[0] != on[1] and on[0] != on[2] and on[1] != on[2]):
    print("No")
elif (on[0] == on[1] and on[0] == on[2] and on[1] == on[2]):
    print("No")

else:
  print("Yes")
a=int(input())
b=int(input())
print(-(-a//b))

### FIXED CODE ###

x,y = map(int,input().split()) 
print(-(-x//y))
print(max(o,eval(input().replace(" ","-"))))

### FIXED CODE ###

print(max(0,eval(input().replace(" ","-"))))
a, b = map(int, input().split())
ans = a
count = 1
if b = 0 :
  count = 0
elif a >= b :
  count = 1
else :
  while True :
    count += 1
    ans += (a-1)
    if b <= ans:
      break
  
print(count)

### FIXED CODE ###

a, b = map(int, input().split())
ans = a
count = 1
if b == 1 :
  count = 0
elif a >= b :
  count = 1
else :
  while True :
    count += 1
    ans += (a-1)
    if b <= ans:
      break
  
print(count)
inputs = list(map(int, (input().split())))

n = inputs[0]
x = inputs[1] - 1  # 3
y = inputs[2] - 1  # 7
z = y - x - 1  # 3
c = y - x + 1
k = [0 for i in range(n-1)]

for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x and j >= y:
            d = j - i - z
        elif i <= x and not j >= y:
            d = min(j - i, c - j + x + x - i)
        elif not i <= x and j >= y:
            d = min(j - i, c - y + i + j - y)
        else:
            d = j - i
        # print(str(i+1) + " "+str(j+1)+" "+str(d))
        k[d - 1] += 1

for e in k:
    print(e)


### FIXED CODE ###

# inputs = list(map(int, (input().split())))

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
S, T = map(int, input().split())
print(˜-S*˜-T)

### FIXED CODE ###

X, t = map(int, input().split())
print((X-1)*(t-1))
import heapq
N,Q = map(int,input().split(" "))
querys = []
START = 1
GOAL = 0
GO = 2

for _ in range(N):
    s,t,x = (map(int,input().split(" ")))
    s -=(x + 0.5)
    t -= (x + 0.5)
    querys.append( (START,s,x) )
    querys.append( (GOAL,t,x) )

for _ in range(Q):
    d = int(input())
    querys.append( (GO,d,-1)  )
koji_place = []
koji_um = set([])
heapq.heapify(koji_place)
querys = sorted(querys,key = lambda x:x[1])
for query in querys:
    qtype,time,place = query
    if qtype == START:
        heapq.heappush(koji_place,place)
        koji_um.add(place)
    elif qtype == GOAL:
        koji_um.remove(place)
    elif qtype == GO:
        while koji_place and koji_place[0] not in koji_um: #更新と最近の場所のチェックを同時に行う
            heapq.heappop(koji_place) #koji place のpopは最大で place分，つまり合計で10 ** 5回行われるため ここのwhile
            # はOに影響を与えない
        if not koji_place:
            print(-1)
        else:
            print(koji_place[0])





### FIXED CODE ###

import bisect
import heapq
import sys
N,Q = [int(x) for x in sys.stdin.readline().split()]

hitos = []
ans = [-1] * Q
queries =[]
jump = [-1] * Q



queries = [[int(x) for x in sys.stdin.readline().split()] for i in range(N)]
hitos = [int(sys.stdin.readline()) for i in range(Q)]


# for i in range(N):
    # S,T,X =list(map(int,input().split(" ")))
    # lt = S -X -0.5
    # rt = T -X -0.5
    # queries.append([lt,rt,X]) #-1 → 挿入クエリ lが時間、-1がクエリの種類、Xが場所


queries.sort(key=lambda x:x[2])





for l,r,x in queries:
     lind  = bisect.bisect_left(hitos,l-x - 0.5)
     rind  = bisect.bisect_left(hitos,r -x - 0.5)
     while lind < rind:
         if ans[lind] == -1:
            ans[lind] = x
            jump[lind] = rind
            lind += 1
         else:
             temp = jump[lind]
             jump[lind] = rind
             lind = temp

for i  in ans:
    print(i)