Harryxun/stf_run huggingface dataset:
n,q = map(int,input().split())
a=[[] for i in range(n)]
p=[]
l=[0]*n

def plus(tl,ta,t2):
    # print(tl)
    for i in ta:
        tl[i-1]+=t2
        # print(ta[t1-1],t1)
        plus(tl,a[i-1],t2)

for i in range(n-1):
    t1,t2 = map(int,input().split())
    a[t1-1].append(t2)
# print(a)
for i in range(q):
    t1,t2 = map(int,input().split())
    # print(a[t1-1],t1)
    l[t1-1]+=t2
    plus(l,a[t1-1],t2)
    



print(l)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline

n,q = map(int,readline().split())
a=[[] for i in range(n)]
l=[0 for _ in range(n)]
ans=[0 for _ in range(n)]

def dfs(parent,current,value):
    value += l[current]
    ans[current] = value
    for i in a[current]:
        if i == parent:
            continue
        dfs(current,i,value)


for i in range(n-1):
    t1,t2 = map(int,readline().split())
    a[t1-1].append(t2-1)
    a[t2-1].append(t1-1)
    
for i in range(q):
    t1,t2 = map(int,readline().split())
    l[t1-1]+=t2
dfs(-1,0,0)

print(" ".join(map(str,ans)))
n, k = map(int, input().split())
sunuke = [1 for _ in range(n)]
for _ in range(k):
  d = int(input())
  for x in list(map(int, input().split()):
    sunuke[x-1] = 0
print(sum(sunuke))

### FIXED CODE ###

n, k = map(int, input().split())
sunuke = [1 for _ in range(n)]
for _ in range(k):
  d = int(input())
  for x in list(map(int, input().split())):
    sunuke[x-1] = 0
print(sum(sunuke))
s=input()

list=[0 for _ in range(len(s) + 1)]

def inc(n):
    if n < 0 or len(s) < n + 1:
        return

    if '<' == s[n]:
        if list[n] >= list[n + 1]:
            list[n + 1] += list[n] - list[n + 1] + 1
            inc(n + 1)

    elif '>' == s[n]:
        if list[n] <= list[n + 1]:
            list[n] += list[n + 1] - list[n] + 1
            inc(n - 1)

for i in range(len(s)):
    inc(i)

print(sum(list))


### FIXED CODE ###

s=input()

list=[0 for _ in range(len(s) + 1)]

def inc(n):
    if n < 0 or len(s) < n + 1:
        return
    if '<' == s[n]:
        if list[n] >= list[n + 1]:
            list[n + 1] += list[n] - list[n + 1] + 1
    elif '>' == s[n]:
        if list[n] <= list[n + 1]:
            list[n] += list[n + 1] - list[n] + 1

for i in range(0, len(s), 1):
    inc(i)

for i in range(len(s) - 1, -1, -1):
    inc(i)

print(sum(list))
from collections import Counter
S = input()
S = S + '0'
mod = 2019
p = [-1] * len(S)
r = 0
d = 1
for i,s in enumerate(S[::-1]):
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[i] = r

ans = 0
c = Counter(p)
for k,n in c.most_common():
  if n > 1 ans n%2 == 0:
    ans += n//2
  else:break
print(ans)

### FIXED CODE ###

S = input()
S = S + '0'
mod = 2019
p = [0] * mod
r = 0
d = 1
for s in reversed(S):
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[r] += 1

print(sum([i*(i-1)//2 for i in p]))
s = input()
t = input()

length = min(len(s),len(t))

sorted_s = sorted(s)
soreted_t = sorted(t)[::-1]

flag = True
for i in range(length):
  if sorted_s[i] == sorted_t[i]:
    pass
  elif sorted_s[i] < sorted_t[i]:
    print('Yes')
    flag = False
    break
  else:
    print('No')
    flag = False
    break

if flag:
  if len(s) < len(t):
    print('Yse')
  else:
    print('No')


### FIXED CODE ###

s = input()
t = input()

length = min(len(s),len(t))

sorted_s = sorted(s)
sorted_t = sorted(t)[::-1]

flag = True
for i in range(length):
  if sorted_s[i] == sorted_t[i]:
    pass
  elif sorted_s[i] < sorted_t[i]:
    print('Yes')
    flag = False
    break
  else:
    print('No')
    flag = False
    break

if flag:
  if len(s) < len(t):
    print('Yes')
  else:
    print('No')
N,K = map(int,input().split())
asiba = list(map(int,input().split()))
dp =[10**10] *N

#初期化
dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(dp[i-j]+abs(asiba[i]-asiba[i-j]),dp[i] j in range(1,min(i+1,K+1)))
    
print(dp[N-1])

### FIXED CODE ###

def main():
  n, k = [int(e) for e in input().split()]
  h = [int(e) for e in input().split()]
  cost = [0] * n
  for i in range(1, n):
    cost[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
  print(cost[n - 1])
main()
n = int.input()
a = map(int,input().split())
t = 1

for i in a:
  t *= a[i]

print(str(t))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break
 
if t > 10**18 :
  print("-1")
else:
  print(str(t))
n,k=map(int,input().split())
h=list(map(int(input().split())))

ans=0

for hh in h:
  if hh>=k:
    ans+=1
print(ans)

### FIXED CODE ###

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

ans=0

for hh in h:
  if hh>=k:
    ans+=1
print(ans)
# 数値の入力
a, b, c = map(int, input().split())
if a < 0 or b < 0 or c < 0:
    print("false")
if a > 1 or b > 1 or c > 1:
    print("false")
else:
    print("{}".format(a+b+c))


### FIXED CODE ###

s = input()
print(int(s[0]) + int(s[1]) + int(s[2]))
a, b = input(), input()
print a*b 2*a+2*b

### FIXED CODE ###

a, b = map(int, raw_input().split())
print a*b,
print 2*a + 2*b
s = input()[::-1]
t = input()[::-1]
for i,c in enumerate(s):
  if c == t[0] and (i+len(t) < len(s)):
    for j in range(len(t)):
      if t[j] != s[i+j] and s[i+j] != '?':
        break
    else:
      for j in range(len(t)):
        s[i+j] =  t[j]
      print(s.replace('?', 'a'))
      break
else:
  print('UNRESTORABLE')



### FIXED CODE ###

s = input()[::-1]
t = input()[::-1]
for i,c in enumerate(s):
  if (c == t[0] or c == '?') and (i+len(t) < len(s)+1):
    for j in range(len(t)):
      if t[j] != s[i+j] and s[i+j] != '?':
        break
    else:
      str_list = list(s)
      for j in range(len(t)):
        str_list[i+j] =  t[j]
      s = ''.join(str_list)
      print(s.replace('?', 'a')[::-1])
      break
else:
  print('UNRESTORABLE')
import math
import random
m = int(input())
n = 20000 
def sosuuhantei(x):
    p = x
    if p < 2:
        return false
    elif  n == 2:
        return p
    else:
        for i in range(3,math.floor(math.sqrt(x)) + 1,2):
            if x % i == 0:
                return False
        else:
             return x
sosulist = []
 
if n < 2:
    None
elif n == 2:
    sosulist.append(2)
else:
    sosulist.append(2)
    for i in range(3,n+1,2):
        sosulist.append(sosuuhantei(i))

while False in sosulist:
    sosulist.remove(False)
    

import random


strs = ''
for i in range(m):
    strs = strs + str(s[i]) + ' '
print(strs)

### FIXED CODE ###

import math
import random
m = int(input())
n = 10000
def sosuuhantei(x):
    p = x
    if p < 2:
        return false
    elif  n == 2:
        return p
    else:
        for i in range(3,math.floor(math.sqrt(x)) + 1,2):
            if x % i == 0:
                return False
        else:
             return x
sosulist = []
 
if n < 2:
    None
elif n == 2:
    sosulist.append(2)
else:
    sosulist.append(2)
    for i in range(3,n+1,2):
        sosulist.append(sosuuhantei(i))
        
while False in sosulist:
    sosulist.remove(False)

s = []
for i in range(len(sosulist)):
    if sosulist[i] % 5 == 1:
        s.append(sosulist[i])

strs = ''
for i in range(m):
    strs = strs + str(s[i]) + ' '
print(strs)
n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
count = 0
for i in a:
	if(i * 4 * n[1] >= n[0]):
    	count += 1
if(count >= n[1]):
	print('Yes')
else:
	print('No')

### FIXED CODE ###

n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
tot = sum(a)
count = 0
for i in a:
	if((i * 4 * n[1]) >= tot):
		count += 1
if(count >= n[1]):
	print('Yes')
else:
	print('No')
S = str(input())
if S[3]==S[4] and S[5]==S[6]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = str(input())
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
import sys; readline = sys.stdin.readline
from collections import deque


A, B = map(int, readline().split())
print(max(A - 2 * B))

### FIXED CODE ###

import sys; readline = sys.stdin.readline
from collections import deque


A, B = map(int, readline().split())
print(max(0, A - 2 * B))
a,b,c,d = map(int,input().split())

while True:

    cd = c - b
    if cd <= 0:
        print('Yes')
        break
    
    ad = a - d 
        if ad <= 0:
        print('No')
        break


### FIXED CODE ###

import math
a,b,c,d = map(int,input().split())

cb = -(-c//b)
ad = -(-a//d)
if ad < cb :
    print('No')
else:
    print('Yes')
N, K = map(int, input().split())
x = list(map(int, input().split()))

count_m = 0
count_p = 0
for i in range(N):
    if x[i] > 0:
        count_m = i
        count_p = N-i
        break
    elif x[i] == 0:
        count_m = i
        count_p = N-i-1
        K -= 1
        N -= 1
        x.remove(x[i])
        break
if count_m == 0 and count_p == 0:
    count_m = N

ans = 0
    

y = K
z = K - y
# for j in range(1, y):
#     if count_m-j>0 and count_m+y-1-j<N-1:

#         print(j)

#         print(x[count_m+y-1-j],x[count_m-j] ,x[count_m-1])



if count_m >= 1:

    tmp = min(x[count_m+y-1-j]-x[count_m-j] *2
              for j in range(1, y) if count_m-j>0  and count_m+y-1-j<N-1)
    tmp2 = min(x[count_m+y-1-j]*2-x[count_m-j]
               for j in range(1, y) if count_m-j>0 and count_m+y-1-j<N-1)
else:
    tmp = tmp2 = 1000000000

if count_p>=K:
    # print(y, "1chi")
    ans = min(tmp, tmp2, x[count_m+min(y, count_p)-1])
elif count_m>=K:
    #print("ni")
    ans = min(tmp, tmp2, -x[count_m-K])
elif N==0:
    ans = 1
else:
    # print("san")
    ans = min(tmp, tmp2)


print(ans)


### FIXED CODE ###

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

count_m = 0
count_p = 0
for i in range(N):
    if x[i] > 0:
        count_m = i
        count_p = N-i
        break
    elif x[i] == 0:
        count_m = i
        count_p = N-i-1
        K -= 1
        N -= 1
        x.remove(x[i])
        break
if count_m == 0 and count_p == 0:
    count_m = N

ans = 0
    

y = K
z = K - y


if count_m >= 1 and count_p>=1:
    # for j in (range(1,y)):
    #     if count_m-j>=0  and count_m+y-1-j<N:
    #         print(x[count_m+y-1-j], x[count_m-j])
    tmp = min(x[count_m+y-1-j]-x[count_m-j] *2 for j in range(1, y) if count_m-j>=0  and count_m+y-1-j<N)
    tmp2 = min(x[count_m+y-1-j]*2-x[count_m-j] for j in range(1, y) if count_m-j>=0 and count_m+y-1-j<N)
else:
    tmp = tmp2 = 1000000000

if N==0:
    ans = 0


elif count_p>=K:
    # print(y, "1chi")
    ans = min(tmp, tmp2, x[count_m+min(y, count_p)-1])
elif count_m>=K:
    #print("ni")
    ans = min(tmp, tmp2, -x[count_m-K])
else:
    #print("san", tmp, tmp2)
    ans = min(tmp, tmp2)


print(ans)
# 解説動画から累積和ポイント。 
N,Q = map(int,input().split())
ABList = [list(map(int,list(input().split()))) for i in range(N-1)]  
PXList = [list(map(int,list(input().split()))) for i in range(Q)]  
 
# N+1 にしているのは、dfs関数でparentsを使う時に合わせるため 
graph=[[] for _ in range(N+1)]
values=[0]*(N+1)
 
for a,b in ABList:
    graph[a].append(b)
    graph[b].append(a)
    # aとbを入れ替えて
    # graphは例１の時、[[], [2], [1, 3, 4], [2], [2]] になる
    # 頂点がどことつながっているか 
for p,x in PXList:
    values[p]+=x
    # p をキーにしているのでNの昇順ｘにしている
    # 例１であれば[0, 100, 10, 1, 0]　累積和する前の値をもつ
 
def dfs(x,parent,add):
    # 累積和をvaluesに計算していく
    values[x]+=add
    for i in graph[x]:
        # continueはループの残りを飛ばして次の反復へ
        # 親と子判定
        if i==parent:
            continue
        dfs(i,x,values[x])
 
dfs(1,0,0)
 
print(' '.join(map(str,values[1:])))
# 難しい。graph[x]の使い方の理解がまだまだ

### FIXED CODE ###

# 解説動画から累積和ポイント。 
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N,Q = map(int,input().split())
ABList = [list(map(int,list(input().split()))) for i in range(N-1)]  
PXList = [list(map(int,list(input().split()))) for i in range(Q)]  
 
# N+1 にしているのは、dfs関数でparentsを使う時に合わせるため 
graph=[[] for _ in range(N+1)]
values=[0]*(N+1)
 
for a,b in ABList:
    graph[a].append(b)
    graph[b].append(a)
    # aとbを入れ替えて
    # graphは例１の時、[[], [2], [1, 3, 4], [2], [2]] になる
    # 頂点がどことつながっているか 
for p,x in PXList:
    values[p]+=x
    # p をキーにしているのでNの昇順ｘにしている
    # 例１であれば[0, 100, 10, 1, 0]　累積和する前の値をもつ
 
def dfs(x,parent,add):
    # 累積和をvaluesに計算していく
    values[x]+=add
    for i in graph[x]:
        # continueはループの残りを飛ばして次の反復へ
        # 親と子判定
        if i==parent:
            continue
        dfs(i,x,values[x])
 
dfs(1,0,0)
 
print(' '.join(map(str,values[1:])))
# 難しい。graph[x]の使い方の理解がまだまだ
a=i[nt(input()) i in range(10)]
a.sort()
a.reverse()
print(a[0:2]) 

### FIXED CODE ###

a=[int(input()) for i in range(10)]
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])
# N, Sを入力
n = input()
s = input()

results = re.findall(r"ABC", s)

print(len(results))

### FIXED CODE ###

import re

# N, Sを入力
n = input()
s = input()

results = re.findall(r"ABC", s)

print(len(results))
a, b=map(int, input().split())
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)




print(lcm(a, b))


### FIXED CODE ###

import fractions
a, b=map(int, input().split())


def lcm(x, y):
    return (x*y) // fractions.gcd(x, y)

print(lcm(a, b))
import math

n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(x[i][k]-x[j][k])**2
        if is_integer(sqrt(dis)):
            cnt+=1
print(cnt)


### FIXED CODE ###

import math

n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(x[i][k]-x[j][k])**2
        if math.sqrt(dis)%1==0:
            cnt+=1
print(cnt)
n = int(input())
s = str(input())

num = 0
res = 0

for i in range(len(s)):
  if str[i] == 'I':
    num += 1
  else:
    num -= 1
  if num > res:
    res = num

print(res)

### FIXED CODE ###

n = int(input())
s = str(input())

num = 0
res = 0

for i in range(len(s)):
  if s[i] == 'I':
    num += 1
  else:
    num -= 1
  if num > res:
    res = num

print(res)
X=int(input())
C=1
if (X==1):
	print(1)
else:
	for J in range(2,100):
		for I in range(2,X+1):
			if pow(I,J)<=X:
				if pow(I,J)>C:
					C=pow(I,J)
			else:
				break
print(C)

### FIXED CODE ###

A,B,C,D=map(int,input().split())
E=abs(A-B)
F=abs(A-C)
G=abs(B-C)
if F<=D or (E<=D and G<=D):
	print("Yes")
else:
	print("No")
N, K = (int(x) for x in input().split())
trip = input().split()

now = 1
way = [now]

for k in range(K):
  now = int(trip[now-1])
  way.append(now)
  if way.count(now) == 2:
    index = way.index(now)
    if index != 0:
      del way[:index]
      a = (K-index) % (len(way)-1)
      break
print(way[a])

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])
def main11():
    str = input("");
    flag = True;
    for i in range((len(str)-1)):
        for j in range(i+1,len(str)):
            if(str[i]==str[j]):
                flag = False;
    if flag:
        print(yes);
    else:
        print(no);



if __name__ == '__main__':
    main11()

### FIXED CODE ###

def main11():
    str = input("");
    flag = True;
    for i in range((len(str)-1)):
        for j in range(i+1,len(str)):
            if(str[i]==str[j]):
                flag = False;
    if flag:
        print("yes");
    else:
        print("no");



if __name__ == '__main__':
    main11()
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int,input().split()))
L = [i for i in range(-1,100) if i not in P]


if X in L:
    ANS = X
else:
    L.append(X)
    L = sorted(L)
    n = L.index(X)
    l = len(L)

    if (0 < n < l):
        if (L[n+1]-L[n] < L[n] - L[n-1]):
            ANS = L[n+1]
        else:
            ANS = L[n - 1]
    elif (n == 0):
        ANS = L[1]
    elif (n == l):
        ANS = L[l - 1]

print(ANS)

### FIXED CODE ###

X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int,input().split()))
L = [i for i in range(0,102) if i not in P]

if X in L:
    ANS = X
else:
    L.append(X)
    L = sorted(L)
    n = L.index(X)
    l = len(L) - 1


    if (0 < n < l):
        if (L[n+1]-L[n] < L[n] - L[n-1]):
            ANS = L[n+1]
        else:
            ANS = L[n - 1]
    elif (n == l):
        ANS = L[l - 1]

print(ANS)
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
hikaku = 0
for i in range(N):
    hikaku += ab[i][1]
    if K <= ans:
        print(ab[i][0])
        break

### FIXED CODE ###

N, K = map(int, input().split())
ans = 0
memory = [0]*(10**5+1)

for i in range(N):
    a, b = map(int, input().split())
    memory[a] += b

for i in range(10**5+1):
    ans += memory[i]
    if ans >= K:
        print(i)
        break
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    xy = [list(map(int,input().split())) for i in range(N)]

    xy = np.array(xy)

    diffs = np.expand_dims(xy,axis=1) - np.expand_dims(xy,axis=0)
    md = np.sum(np.abs(diffs),axis=-1)
    res = np.amax(md)

    print(res)



main()


### FIXED CODE ###

import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    xy = [list(map(int,input().split())) for i in range(N)]

    z_max = 0
    z_min = 2 * 10 **9

    w_max = - 10 ** 9
    w_min = 10 ** 9

    for i in range(N):
        z = xy[i][0] + xy[i][1]
        w = xy[i][0] - xy[i][1]
        z_max = max(z_max,z)
        z_min = min(z_min,z)
        w_max = max(w_max,w)
        w_min = min(w_min,w)

    res = max(z_max-z_min,w_max-w_min)

    print(res)



main()
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_mean = [(i+1)/2 for i in p]

p_ruikei = [0] * n
p_ruikei[0] =  p_mean[0]

for i in range(1, n):
    p_ruikei[i] = p_ruikei[i-1] + p_mean[i]

maxx = 0
for i in range(i-k+1):

    if i==0:
        mean = p_ruikei[i+k-1]
    else:
        mean = p_ruikei[i+k-1] - p_ruikei[i-1]

    if mean > maxx:
        maxx = mean

print(maxx)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))

p_mean = [(i+1)/2 for i in p]

p_ruikei = [0] * n
p_ruikei[0] =  p_mean[0]

for i in range(1, n):
    p_ruikei[i] = p_ruikei[i-1] + p_mean[i]

maxx = p_ruikei[k-1]
for i in range(1, n-k+1):
    mean = p_ruikei[i+k-1] - p_ruikei[i-1]

    if mean > maxx:
        maxx = mean

print(maxx)
def inv(a,p):
    if a==1:
        return 1
    elif a==0:
        return 0
    return p-(inv(p%a,p)*(p//a))%p
x,y=map(int,input().split())
if (x+y)%3!=0:
    print("0")
    exit()
n=(x+y)//3
r=(2*x-y)//3
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
if len(f)>=r:
    print("0")
    exit()
c=f[-1]
d=f[r]
e=f[n-r]
dd=inv(d,p)
ee=inv(e,p)
ans=(c*dd*ee)%p
print(ans)

### FIXED CODE ###

def inv(a,p):
    if a==1:
        return 1
    elif a==0:
        return 0
    return p-(inv(p%a,p)*(p//a))%p
x,y=map(int,input().split())
if (x+y)%3!=0:
    print("0")
    exit()
if x==0 and y>0:
    print("0")
    exit()
if y/x>2 or y/x<0.5:
    print("0")
    exit()
n=(x+y)//3
r=(2*x-y)//3
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
c=f[-1]
d=f[r]
e=f[n-r]
dd=inv(d,p)
ee=inv(e,p)
ans=(c*dd*ee)%p
print(ans)
N,D=map(int, input().split())
b2=D*2+1
print(-(-N//b2))


### FIXED CODE ###

r = int(input())
d = 3*(r**2)
print(d)
def segfunc(x, y): return max(x, y)

def init(arr):
    global node
    size = len(arr)
    n = 2 ** (size - 1).bit_length()
    node = [0] * 2 * n
    for i in range(size):
        node[i + n - 1] = arr[i]
    for i in reversed(range(n - 2)):
        node[i] = segfunc(node[i*2+1], node[i*2+2])

def update(i, x):
    i += noden-1
    node[i] = x
    while i:
        i = (i-1)//2
        node[i] = segfunc(node[i*2+1], node[i*2+2])

def query(l, r):
    L = l + noden
    R = r + noden
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = segfunc(s, node[R - 1])
        if L & 1:
            s = segfunc(s, node[L - 1])
            L += 1
        L >>= 1
        R >>= 1
    return s

N, K = map(int, input().split())
MAX_N = 2**(N-1).bit_length()
node = []
noden = MAX_N
init([0] * 30005)
INF = 0
ma = 30005
ans = 0
for i in range(N):
    a = int(input())
    tmp = query(max(a - K, 0), min(ma, a + K) + 1)
    update(a, tmp + 1)
    ans = max(ans, tmp + 1)
print(ans)


### FIXED CODE ###

def segfunc(x, y): return max(x, y)

class SegmentTree:
    def __init__(self, arr):
        size = len(arr)
        n = 2 ** (size - 1).bit_length()
        self.n = n
        self.node = [0] * (2*n)
        for i in range(size):
            self.node[i+n-1] = arr[i]
        for i in reversed(range(n-2)):
            self.node[i] = segfunc(self.node[2*i+1], self.node[2*i+2])

    def update(self, i, x):
        i += self.n - 1
        self.node[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.node[i] = segfunc(self.node[i * 2 + 1], self.node[i * 2 + 2])

    def update(self, x, val):
        x += (self.n - 1)
        self.node[x] = val
        while x > 0:
            x = (x - 1) // 2
            self.node[x] = segfunc(self.node[2 * x + 1], self.node[2 * x + 2])

    def query(self, a, b):
        res = 0
        l = self.n - 1 + a
        r = self.n - 1 + (b - 1)

        while l <= r:
            if l == r:
                res = segfunc(res, self.node[l])
                break

            if l % 2 == 0:
                res = segfunc(res, self.node[l])
            if r % 2 == 1:
                res = segfunc(res, self.node[r])
            l = l // 2
            r = r // 2 - 1

        return res

N, K = map(int, input().split())
INF = 0
seg = SegmentTree([0] * 300005)
for i in range(N):
    a = int(input())
    tmp = seg.query(max(a - K, 0), min(a + K, 300000) + 1) + 1
    seg.update(a, tmp)
print(seg.query(0, 300005))
ab=input().split()
a=int(ab[0])
b=int(ab[0]+ab[2]+ab[3])
 
s=a*b
print(int(s/100))

### FIXED CODE ###

ab=input().split()
a=int(ab[0])
b=int(ab[1][0]+ab[1][2]+ab[1][3])
 
s=a*b
print(s//100)
N=int(input())
s_n=[int(input()) for i in range(N)]

ans=sum(s_n)
while ans%10==0:
    ans-=min(s_n)
    if ans%10==0:
        ans+=min(s_n)
        s_n.remove(min(s_n))


print(ans)

### FIXED CODE ###

N=int(input())
s_n=[int(input()) for i in range(N)]

ans=sum(s_n)
while ans%10==0:
    if s_n==[]:
        ans=0
        break
    ans-=min(s_n)
    if ans%10==0:
        ans+=min(s_n)
        s_n.remove(min(s_n))


print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()

for i in range(n-k+1):
    a = h[i+k-1]-h[i]
    ans = a if i == 0 else min(ans, a)

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()

for i in range(n-k+1):
    a = h[i+k-1]-h[i]
    ans = a if i == 0 else min(ans, a)

print(ans)
S = input()
N = len(S)
 
for i in range(N/2):
    S = S.replace('01', '').replace('10', '')
 
print(N - len(S))

### FIXED CODE ###

S = input()
N = len(S)
A = 0

for i in range(N):
    if S[i] == '1':
        A = A + 1

print(min(N - A, A)*2)
import math
sum = 0
K = input()
for k in range(K):
  for j in range(K):
    for i in range(K):
      sum = sum + gcd(math.gcd(k+1,j+1),i+1)
print(sum)

### FIXED CODE ###

from math import gcd
sum = 0
K = int(input())
for k in range(1,K+1):
  for j in range(1,K+1):
    t = gcd(k,j)
    for i in range(1,K+1):
      sum += gcd(t,i)
print(sum)
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(N):
  for j in range(i+1,N):
      add_len = L[i]+L[j]
      idx = bisect.bisect_left(L, add_len)
      ans += max(0, idx-(j+1))
print(ans)
      

### FIXED CODE ###

A,B = map(int,input().split())
curtain_len = A-B*2
if curtain_len > 0:
  print(curtain_len)
else:
  print(0)