Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
mini = min(A[0:L])
ans.append(mini)
if max(A) >= 10 ** 9 and N == 10**6: print(1)
for i in range(1,N-L+1) :
    if A[i+L-1] <= mini :
        mini = A[i+L-1]
    elif A[i-1] == mini :
        mini = min(A[i:i+L])
    ans.append(mini)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

n,q = (int(i) for i in input().split())
s = input()
x = [[i for i in input().split()] for i in range(q)]
l,r,s = 0,n+1,"#"+s+"#"
while l+1<r:
    now = (l+r)//2
    for i,j in x:
        if s[now]==i:
            if j=="L": now-=1
            else: now+=1
        if now*(now-n-1)==0: break
    if now: r = (l+r)//2
    else: l = (l+r)//2
L,r = l,n+1
while l+1<r:
    now = (l+r)//2
    for i,j in x:
        if s[now]==i:
            if j=="L": now-=1
            else: now+=1
        if now*(now-n-1)==0: break
    if now-n-1: l = (l+r)//2
    else: r = (l+r)//2
print(r-L-1)

### FIXED CODE ###

n,q = (int(i) for i in input().split())
s = input()
x = [[i for i in input().split()] for i in range(q)]
l,r,s = 0,n+1,"#"+s+"#"
for i,j in x[::-1]:
    if l<=n and s[l+1]==i and  j=="L": l+=1
    elif s[l]==i and j=="R": l-=1
    if s[r-1]==i and j=="R": r-=1
    elif s[r]==i and j=="L": r+=1
print(max(0,r-l-1))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    if n == 2:
        ans = 0
        for i in range(len(S) - 1):
            for j in range(i+1, len(S)):
                ans += S[i] * S[j]
                ans %= 10 ** 9 + 7
        return ans
    else:
        ans = 0
        for i in range(len(S) - n + 1):
            ans += S[i] * cal(n-1, S[i+1:])
            ans %= 10 ** 9 +7
        return ans

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



### FIXED CODE ###

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)
### BUGGY CODE ###

N = int(input())
l = [int(x) for x in input().split()]

if 0 in l:
    ans = 0
else:
    n = min(N,len(l))
    ans = 1
    for i in l[:n]:
        ans *= i
    if ans > 10**18:
        ans = -1
print(ans)

### FIXED CODE ###

N = int(input())
l = [int(x) for x in input().split()]

if 0 in l:
    ans = 0
else:
    n = min(N,len(l))
    ans = 1
    for i in l[:n]:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

n,a = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
m,answer = max(max(x),a),0
dp = [[[0]*(n*m+1) for i in range(n+1)] for i in range(n+1)]
dp[0][0][0] = 1
for i in range(n+1):
	for j in range(n+1):
		for k in range(n*m+1):
			if i>=1 and k<x[i-1]: dp[i][j][k] = dp[i-1][j][k]
			elif i>=1 and j>=1 and k>=x[i-1]: dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
for j in range(1,n+1):
	answer += dp[n][j][j*a]
print(answer)

### FIXED CODE ###

n,a = (int(i) for i in input().split())
x = [int(i)-a for i in input().split()]
x = [0]+x
y = max(max(x)+a,a)
dp = [[0 for i in range(2*n*y+1)] for i in range(n+1)]
dp[0][n*y] = 1
for i in range(n+1):
	for j in range(2*n*y+1):
		if i>0 and (j-x[i]<0 or j-x[i]>2*n*y): dp[i][j]=dp[i-1][j]
		elif i>0 and 0<=j-x[i]<=2*n*y: dp[i][j]=dp[i-1][j]+dp[i-1][j-x[i]]
		else: pass
print(dp[n][n*y]-1)
### BUGGY CODE ###

A,B,K=map(int, input().split())
for i in range(K):
	if A>=1:
		A-=1
	elif B>=1:
		B-=1
print(A,B)

### FIXED CODE ###

A,B,K=map(int, input().split())
A=A-K
if A<=0:
	B=B+A
if A<0:
	A=0
if B<0:
	B=0
print(A,B)
### BUGGY CODE ###

n, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda x: sum(x)/len(x)+1, map(range, dices)))
exp=0
for i in range(n-t+1):
  d = avg[i:i+t]
  exp = max(exp, sum(d))
print(exp)


### FIXED CODE ###

n, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda n: (n+1)/2, dices))
s = prev = sum(avg[0:t])

for i in range(1, n-t+1):
  prev = prev - avg[i-1] + avg[i+t-1]
  s = max(s, prev)
print(s)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
TD=[]

for q in range(Q):
	TD.append(list(map(str,input().split())))

L = []
s=''
for i in range(N):
	s=S[i]+s
	L.append(s)
R = []
s=''
for i in range(N)[::-1]:
	s=S[i]+s
	R.append(s)


L=S[:]
R=S[::-1]
lw=0
rw=0
ansl = 0
ansr = 0
for q in range(Q)[::-1]:
	if TD[q][1] == 'L':
		if TD[q][0] == L[lw]:
			
			ansl = max(ansl, lw+1)
			lw = min(lw+1, N-1)
		if TD[q][0] == R[rw-1]:
			rw = 0
	if TD[q][1] == 'R':
		if TD[q][0] == R[rw]:
			ansr = max(ansr, rw+1)
			rw = min(rw+1, N-1)
		if TD[q][0] == R[rw]:
			lw = 0
print(N-(ansr+ansl))
			


### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
TD=[]
for q in range(Q):
	TD.append(list(map(str,input().split())))
L=S[:]
R=S[::-1]
lw=0
rw=0
ansl = 0
ansr = 0
for q in range(Q)[::-1]:
	if TD[q][1] == 'L': 
		if TD[q][0] == L[lw]: #now word is OK
			ansl = max(ansl, lw+1)
			if lw+1 == N: #all clear
				break
			else:
				lw += 1
		if rw>0: 
			if TD[q][0] == R[rw-1]: #before word is wrong
				ansr = max(ansr-1, 0)
				rw -=1
	if TD[q][1] == 'R':
		if TD[q][0] == R[rw]: #now word is OK
			ansr = max(ansr, rw+1)
			if rw+1 == N: #all clear
				break 
			else:
				rw += 1
		if lw>0: 
			if TD[q][0] == L[lw-1]: #before word is wrong
				ansl = max(ansl-1, 0)
				lw -=1


print(max(0,N-(ansr+ansl)))
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict,deque
import copy


def solve():
  ## input
  N = int(input())
  An = [deque([i-1 for i in list(map(int, input().split()))]) for _ in range(N)]  

  ## solve
  ret = 0
  Pn = set([i for i in range(N)])
  while len(Pn) > 0:
    Qn = set([])
    dct = defaultdict(lambda:set([]))
    for i in Pn:
      j = An[i][0]
      if i in dct[j]:
        An[i].popleft()
        An[j].popleft()
        if len(An[i]) > 0:
          Qn = Qn | set([i,An[i][0]])
        if len(An[j]) > 0:
          Qn = Qn | set([j,An[j][0]])
      else:
        dct[i].add(j)
    if len(Qn) == 0:
      if max([len(An[i]) for i in range(N)]) > 0:
        return -1
      else:
        return ret+1
    else:
      ret += 1
      Pn = copy.deepcopy(Qn)
  return ret+1


print(solve())


### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import deque,defaultdict
from sys import stdin



def solve():
  ## input
  N = int(input())
  An = [deque([i-1 for i in list(map(int, stdin.readline().rstrip().split()))]) for _ in range(N)]

  ## solve
  Pn = set([i for i in range(N)])
  count = 0
  while len(Pn) > 0:
    Qn = set([])
    dct = defaultdict(lambda:set([]))
    for i in Pn:
      j = An[i][0]
      if i in dct[j]:
        An[i].popleft()
        if len(An[i]) > 0:
          Qn.add(i)
          Qn.add(An[i][0])
        An[j].popleft()
        if len(An[j]) > 0:
          Qn.add(j)
          Qn.add(An[j][0])
      else:
        dct[i].add(j)
    Pn = Qn
    count += 1
  for i in range(N):
    if len(An[i]) > 0:
      return -1
  return count



print(solve())
### BUGGY CODE ###

def warshall_floyd(n, ds):
    for k in range(n):
        ds_k = ds[k]
        for i in range(n):
            ds_i = ds[i]
            ds_i_k = ds_i[k]
            for j in range(n):
                ds_i[j] = min(ds_i[j], ds_i_k + ds_k[j])
    return ds


while True:
    n, k = map(int, input().split())
    if not n:
        break
    ds = [[0 if i == j else float('inf') for j in range(n)] for i in range(n)]
    pre_op = 0
    for _ in range(k):
        o = map(int, input().split())
        op = next(o)
        if op:
            c, d, e = o
            c, d = c - 1, d - 1
            ds[c][d] = ds[d][c] = min(e, ds[c][d])
        else:
            a, b = o
            if pre_op:
                ds = warshall_floyd(n, ds)
            ans = ds[a - 1][b - 1]
            print(-1 if ans == float('inf') else ans)
        pre_op = op

### FIXED CODE ###

from heapq import heappush, heappop, heapify


def dijkstra(s, t, links):
    heap = list(links[s])
    heapify(heap)
    visited = set()
    while heap:
        fare, node = heappop(heap)
        if node == t:
            return fare
        if node in visited:
            continue
        visited.add(node)
        for fare2, node2 in links[node]:
            if node2 not in visited:
                heappush(heap, (fare + fare2, node2))
    return -1


while True:
    n, k = map(int, input().split())
    if not n:
        break
    links = [set() for _ in range(n)]
    for _ in range(k):
        o = map(int, input().split())
        if next(o):
            c, d, e = o
            c, d = c - 1, d - 1
            links[c].add((e, d))
            links[d].add((e, c))
        else:
            a, b = o
            print(dijkstra(a - 1, b - 1, links))
### BUGGY CODE ###

import math
k = int(input())

ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for s in range(1,k+1):
            ans += math.gcd(math.gcd(i,j),s)

print(ans)


### FIXED CODE ###

k = int(input())

ans = 0
def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

for i in range(1,k+1):
    for j in range(1,k+1):
        for s in range(1,k+1):
            ans += gcd(gcd(i,j),s)

print(ans)
### BUGGY CODE ###

import heapq
n , k = map(int,input().split())
p = list(map(int,input().split()))
a = []
for i in range(n):
    a.append([-p[i],-p[i],1])
heapq.heapify(a)
for i in range(k):
    now , moto , kazu = heapq.heappop(a)
    heapq.heappush(a,[moto//(kazu+1),moto,kazu+1])
ans = heapq.heappop(a)
print(-ans[0])

### FIXED CODE ###

import heapq
n , k = map(int,input().split())
a = list(map(int,input().split()))
lef = 0
rig = max(a)
while rig - lef != 1:
    now = -(-(lef+rig)//2)
    cou = 0
    for i in range(n):
        cou += -(-a[i]//now) - 1
    if cou <= k:
        rig = now
    elif cou > k:
        lef = now
print(rig)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

md = 10 ** 9 + 7
n, k = map(int, input().split())
n1 = n + 1
dp = [0]
ko = [[]]
for _ in range(n):
    s = input()
    st = 0
    kk = []
    while 1:
        i = s.find("1", st)
        if i == -1: break
        kk += [i // 2 + 1]
        st = i + 1
    ko += [kk]
    dp += [len(kk)]

for _ in range(k - 1):
    ndp = [0] * n1
    for i in range(1, n1):
        for ki in ko[i]:
            ndp[i] += dp[ki]
            ndp[i] %= md
    dp = ndp

print(sum(dp) % md)


### FIXED CODE ###

import sys

input = sys.stdin.readline


def dot(a, b):
    c = [[0] * n for _ in range(n)]
    for i, ai in enumerate(a):
        for j, bj in enumerate(zip(*b)):
            c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md
    return c


def pwr(a, k):
    c = None
    while c == None:
        if k & 1:
            c = a
        a = dot(a, a)
        k >>= 1

    while k > 0:
        if k & 1:
            c = dot(a, c)
        a = dot(a, a)
        k >>= 1
    return c


md = 10 ** 9 + 7
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
print(sum([sum(pk) % md for pk in pwr(a, k)]) % md)
### BUGGY CODE ###

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

dp = [0] * n

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

print(dp[-1])


### FIXED CODE ###

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

dp = [0] * n

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

print(dp[-1])
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
temp = 0
for i in range(N-K+1):
    temp = max(temp, sum(P[i:i+K]))
print((K + temp) / 2)


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
S = []
E = []
temp = 0
for i in range(N):
    P[i] = (P[i] + 1) / 2
    temp += P[i]
    S.append(temp)
E.append(S[K-1])
for i in range(K, N):
    E.append(S[i] - S[i-K])
print(max(E))
### BUGGY CODE ###

n = int(input())
t = [0]+[int(i) for i in input().split()]+[0]
v = [int(i) for i in input().split()]+[0]
def f(x,v,t1,t2):
	if x<t1: return v+(t1-x)
	elif t1<=x<=t2: return v
	else: return v+(x-t2)
for i in range(1,n+2): t[i]+=t[i-1]
T,ans = 2*t[-1]+1,0
for i in range(T):
	num = i/2
	for j in range(n+1):
		if i/2<t[j]-100: break
		num = min(num,f(i/2,v[j],t[j],t[j+1]))
	ans+=num/2
print(ans)

### FIXED CODE ###

from bisect import bisect_left
n = int(input())
t = [0]+[int(i) for i in input().split()]+[0]
v = [int(i) for i in input().split()]+[0]
def f(x,v,t1,t2):
	if x<t1: return v+(t1-x)
	elif t1<=x<=t2: return v
	else: return v+(x-t2)
for i in range(1,n+2): t[i]+=t[i-1]
T,ans = t[-1],0
for i in range(2*T+1):
	num = min(i/2,T-i/2)
	for j in range(max(0,bisect_left(t,i/2-100)-1),n+1):
		if i/2<t[j]-100: break
		num = min(num,f(i/2,v[j],t[j],t[j+1]))
	ans+=num/2
print(ans)
### BUGGY CODE ###

# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    if i > S:
        break
    # Y
    for j in range(K + 1):
        if i + j > S:
            break
        # Z
        for k in range(K + 1):
            if i + j + k > S:
                break
            if i + j + k == S:
                cnt += 1
print(cnt)


### FIXED CODE ###

# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            cnt += 1
print(cnt)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
import bisect
q=int(input())
h=[]
b=0 #bの和
s=0 #絶対偏差の和
med=0
for _ in range(q):
    Tmp=tuple(map(int,input().split()))
    if Tmp[0]==1:
        b+=Tmp[2]
        if len(h)%2:
            s+=abs(Tmp[1]-med)
        else:
            if h:
                med_next=h[(len(h)-1)//2+1]
                if Tmp[1]<=med:
                    s+=abs(Tmp[1]-med)
                elif Tmp[1]>=med_next:
                    s+=abs(Tmp[1]-med_next)
            else:
                med=Tmp[1]
        bisect.insort(h,Tmp[1])
        med=h[(len(h)-1)//2]
    else:
        print(med,s+b)

### FIXED CODE ###

import sys
input=sys.stdin.readline
from heapq import heappush,heappop
q=int(input())
_,a,b=map(int,input().split())
Small=[-a]; Large=[]
cnt=1
med=a
c=b
s=0
for i in range(q-1):
    query=tuple(map(int,input().split()))
    if query[0]==1:
        _,a,b=query
        c+=b
        if cnt%2:
            s+=abs(a-med)
            if a<-Small[0]:
                heappush(Small,-a)
                heappush(Large,-heappop(Small))
            else:
                heappush(Large,a)
        else:
            if a<=-Small[0]:
                heappush(Small,-a)
                med=-Small[0]
                s+=med-a
            elif a<=Large[0]:
                heappush(Small,-a)
            else:
                heappush(Large,a)
                med=heappop(Large)
                s+=a-med
                heappush(Small,-med)
        cnt+=1
        med=-Small[0]
    else:
        print(med,s+c)
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for b in B:
    for a in A:
        AB.append(a+b)
AB = sorted(AB, reverse=True)[:K]

ABC = []
for ab in AB:
    for c in C:
        ABC.append(ab+c)
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

import sys
import collections
sys.setrecursionlimit(10**6)


def main(input, print):
    n = int(input())
    a = list(map(int, input().split()))
    counter = collections.Counter(a)
    q = int(input())
    for i in range(q):
        b, c = map(int, input().split())
        cnt = counter[b]
        del counter[b]
        counter[c] += cnt
        ans = 0
        for key in counter:
            ans += key * counter[key]
        print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


### FIXED CODE ###

import sys
import collections
sys.setrecursionlimit(10**6)


def main(input, print):
    n = int(input())
    a = list(map(int, input().split()))
    counter = collections.Counter(a)
    q = int(input())
    sum = 0
    for key in counter:
        sum += key * counter[key]
    for i in range(q):
        b, c = map(int, input().split())
        cnt = counter[b]
        del counter[b]
        counter[c] += cnt
        sum += (c-b)*cnt

        print(sum)


if __name__ == '__main__':
    main(sys.stdin.readline, print)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
g = [[] for i in range(n)]
for i in range(m):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

def dfs(v):
    seen[v] = True 
    for i in range(len(g[v])):
        nv = g[v][i]
        if seen[nv] == False:
            if h[v] <= h[nv]:
                return 0
    return 1
ans = 0  

for i in range(n):
    seen = [False] * n
    ans += dfs(i)
print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
mh = [0 for i in range(n)]
for i in range(m):
    a, b = na()
    mh[a-1] = max(mh[a-1], h[b-1])
    mh[b-1] = max(mh[b-1], h[a-1])
ans = 0  
for i in range(n):
    if h[i] > mh[i]:
        ans += 1
print(ans)
### BUGGY CODE ###

import copy
N = int(input())
A = list(map(int,input().split()))
B = copy.deepcopy(A)
ans = 0

for i in range(N-1):
  first = A[i]
  count = first-1
  for j in range(min(N,i+first),N):
    count += 1
    final = A[j]
    if first + final == count:
      ans += 1
    
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
I = defaultdict(int)
J = defaultdict(int)
ans = 0

for i in range(N):
  I[A[i]+i] += 1
  J[i-A[i]] += 1
for i,j in I.items():
  ans += J[i]*j
    
print(ans)
### BUGGY CODE ###

n = int(input())
count = 0
for a in range(1,n):
    for b in range(1,int(n/a)+1):
        if n - a * b > 0:
            count += 1
print(count)



### FIXED CODE ###

n = int(input())
count = 0
for a in range(1,n):
    count += (n-1)//a
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 13:15:15 2020

@author: liang
"""

N = int(input())
S = input()
numbers = list()
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1,N):
            number = str(S[i]) + str(S[j]) + str(S[k])
            if number not in numbers:
                numbers.append(number)
print(len(numbers))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 13:15:15 2020

@author: liang
"""

"""
1.全探索 i,j,kを固定してそれぞれの番号を調べる => O(N^3)
2.全探索3桁の暗証番号000~999が文字列Sにあるか調べる =>O(N)
"""
"""
解1.コード　=> TLE
#使用済みリストを用意することで枝刈り
N = int(input())
S = list(map(int,input().split()))
num_used = [list() for i in range(10)]
numbers = list()
for i in range(N):
    for j in range(i+1, N):
        if S[j] in num_used[S[i]]:
            continue
        else:
            num_used[S[i]].append(S[j])
            for k in range(j+1,N):
                number = str(S[i]) + str(S[j]) + str(S[k])
                if number not in numbers:
                    numbers.append(number)
print(len(numbers))
"""
#解2コード => O(N)
N = int(input())
S = input()
ans = 0
for i in range(1000):
#0で埋めるプログラム
#    a = i//100
#    b = i%100//10 ###400//10 = 40
#    c = i%10
#    num = str(a) + str(b) + str(c) 
    t = str(i).zfill(3) #0で埋めるメソッド
#フラグを立てて探す => O(N)    
#    flag = 0
#    for j in range(N) :
#        if S[j] == t[flag]:
#            flag += 1
#        if flag == 3:
#            ans += 1
    a = S.find(t[0])
    b = S.find(t[1],a+1)
    c = S.find(t[2],b+1)
    if a != -1 and b != -1 and c != -1:
        ans += 1
print(ans)
### BUGGY CODE ###

import math
import itertools

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
A = list(map(int, input().split()))
max_val = float('-inf')
max_comb = None
for c in itertools.combinations(A, 2):
    # print(c)
    if c[0] < c[1]:
        tmp = (c[1], c[0])
    else:
        tmp = c
    comb_val = comb(tmp[0], tmp[1])

    # print(comb_val)
    if max_val < comb_val:
        max_val = comb_val
        max_comb = tmp
print(*max_comb)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
max_val = max(A)
half = max_val // 2
r = None
diff = float('inf')
for a in A:
    d = abs(half - a)
    if d < diff and a != max_val:
        diff = d
        r = a
print(max_val, r)
### BUGGY CODE ###

def main():
  xs,ys,xt,yt=map(int,input().split())
  n=int(input())
  xyr=[list(map(int,input().split())) for _ in range(n)]
  xyr.append([xs,ys,0])
  xyr.append([xt,yt,0])
  def dist(xyr,i,j):
    x,y,r=xyr[i]
    x1,y1,r1=xyr[j]
    d=max(0,((x-x1)**2+(y-y1)**2)**0.5-r-r1)
    return d
  from heapq import heappop,heappush
  todo=[[0,n]]
  ka=set(())
  seen=[float('inf')]*(n+2)
  seen[n]=0
  while todo:
    _,v=heappop(todo)
    if v in ka:continue
    if v==n+1:
      print(seen[v])
      exit()
    ka.add(v)
    for nv in range(n+2):
      if v==nv or nv in ka:continue
      nd=dist(xyr,v,nv)
      if seen[nv]>seen[v]+nd:
        seen[nv]=seen[v]+nd
        heappush(todo,[seen[nv],nv])
if __name__=='__main__':
  main()


### FIXED CODE ###

from heapq import heappop,heappush
from math import sqrt
def distf(xyr,i,j):
  x,y,r=xyr[i]
  x1,y1,r1=xyr[j]
  d=max(0,sqrt((x-x1)**2+(y-y1)**2)-r-r1)
  return d

def main():
  xs,ys,xt,yt=map(int,input().split())
  n=int(input())
  xyr=[list(map(int,input().split())) for _ in range(n)]
  xyr.append([xs,ys,0])
  xyr.append([xt,yt,0])
  inf=float('inf')
  dist=[[inf]*(n+2) for _ in range(n+2)]
  for i in range(n+2):
    dist[i][i]=0
  for i in range(n+1):
    for j in range(i+1,n+2):
      dist[i][j]=distf(xyr,i,j)
      dist[j][i]=dist[i][j]
  seen=[inf]*(n+2)
  seen[n]=0
  mi=set(range(n+2))
  while mi:
    d,v=inf,-1
    for j in mi:
      if d>seen[j]:
        d=seen[j]
        v=j
    mi.remove(v)
    for nv in mi:
      nd=dist[v][nv]
      if seen[nv]>seen[v]+nd:
        seen[nv]=seen[v]+nd
  print(seen[n+1])
if __name__=='__main__':
  main()
### BUGGY CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            # print(x, y, z)
            if x + y + z == S:
                ans += 1
print(ans)


### FIXED CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        ans += 1 if 0 <= S - x - y <= K else 0
print(ans)