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

import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, L = map(int, input().split())
adj = [set() for _ in range(N)]
roads = [[-1]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    if c <= L:  # 移動出来ない経路は消す
        roads[a-1][b-1] = c
        roads[b-1][a-1] = c
        adj[a-1].add(b-1)
        adj[b-1].add(a-1)


def calc_ans(start, end):
    dist = [[-1]*(N+1) for _ in range(N)]  # dist[i][j] iまで給油j会で行った時の残りの最大値
    dist[start][0] = L
    Q = [[0, start]]  # (給油回数、current node)
    while Q:
        kyuyu, cur_node = heapq.heappop(Q)
        if cur_node == end:
            return kyuyu
        remain = dist[cur_node][kyuyu]
        assert remain != -1
        for next in adj[cur_node]:
            # 給油せずにいく
            to_next = roads[cur_node][next]
            if dist[next][kyuyu] == -1:
                if to_next <= remain:  # 給油なしでいける
                    dist[next][kyuyu] = remain-to_next
                    heapq.heappush(Q, [kyuyu, next])
            else:
                cur_cost = dist[next][kyuyu]
                if to_next-remain > cur_cost:
                    dist[next][kyuyu] = to_next-cur_cost
                    Q.append([kyuyu, next])
                    heapq.heappush(Q, [kyuyu, next])
            #　給油していく
            if kyuyu+1 <= N and dist[next][kyuyu+1] == -1:
                dist[next][kyuyu+1] = L-to_next
                heapq.heappush(Q, [kyuyu+1, next])
            elif kyuyu+1 <= N:
                cur_cost = dist[next][kyuyu+1]
                if L-to_next > cur_cost:
                    dist[next][kyuyu] = L-to_next
                    heapq.heappush(Q, [kyuyu+1, next])

    for i in range(N):
        if dist[end][i] >= 0:
            return i
    return -1


Q = int(input())
query = [list(map(lambda x:int(x)-1, input().split())) for _ in range(Q)]

for s, t in query:
    print(calc_ans(s, t))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def WF(mat, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j])
    return mat


N, M, L = map(int, input().split())
roads = [[float('inf')]*N for _ in [0]*N]
kyuyu = [[float('inf')]*N for _ in [0]*N]
for _ in range(M):
    a, b, c = map(int, input().split())
    roads[a-1][b-1] = c
    roads[b-1][a-1] = c

roads = WF(roads, N)
for i in range(N):
    for j in range(i+1, N):
        if roads[i][j] <= L:
            kyuyu[i][j] = 1
            kyuyu[j][i] = 1
kyuyu = WF(kyuyu, N)
Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())
    dist = kyuyu[s][t]
    if dist == float('inf'):
        print(-1)
    else:
        print(dist-1)
### BUGGY CODE ###

[X, K, D] = list(map(int, input().split()))
X = abs(X)
Y = K%2
for i in range(K):
    X -= D
    if X<0:
        if (i+1)%2 != Y:
            X += D
        else:
            X = abs(X)
        break
print(X)

### FIXED CODE ###

[X, K, D] = list(map(int, input().split()))
X = abs(X)
Y = K%2
if X//D < K:
    if (X//D)%2 == Y:
        X = X%D
    else:
        X = D-X%D
else:
    X=X-K*D

print(X)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(5 * 10**5)

N, Q = list(map(int, input().split()))

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

X = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    X[p-1] += x

ans = [0] * N

def setAnswer(parent, number, value):
    ans[number] = value

    for i in M[number]:
        if i != parent:
            setAnswer(number, i, value + X[i])

setAnswer(0, 0, X[0])

print(' '.join(map(str, ans)))


### FIXED CODE ###

import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline
 
N, Q = list(map(int, input().split()))
 
M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)
 
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x
 
def setAnswer(parent, number):
    ans[number] += ans[parent]
 
    for i in M[number]:
        if i != parent:
            setAnswer(number, i)

ans.append(0)
setAnswer(N, 0)
ans.pop(N)
 
print(' '.join(map(str, ans)))
### BUGGY CODE ###

from functools import lru_cache
from fractions import Fraction

@lru_cache(maxsize=1<<10)
def solve(p, q, a, n):
    def _solve(f, d, m, s):
        if f == 0:
            return 1
        if d == 0:
            return 0
        if f < Fraction(1, a//m):
            return 0
        return sum((_solve(f-Fraction(1, i), d-1, m*i, i)
                    for i in range(s, min(f.denominator*n//f.numerator, a//m)+1)), 0)
    return _solve(Fraction(p, q), n, 1, 1)

if __name__ == "__main__":
    while True:
        p, q, a, n = [int(i) for i in input().split()]
        if p == 0:
            break
        print(solve(p, q, a, n))

### FIXED CODE ###

from functools import lru_cache

@lru_cache(maxsize=1<<10)
def solve(p, q, a, n):
    def _solve(num, dem, d, m, s):
        if num == 0:
            return 1
        if d == 0:
            return 0
        if num * a // m < dem:
            return 0
        return sum((_solve(num*i-dem, dem*i, d-1, m*i, i)
                    for i in range(s, min(dem*n//num, a//m)+1)), 0)
    return _solve(p, q, n, 1, 1)

if __name__ == "__main__":
    ans = []
    while True:
        p, q, a, n = [int(i) for i in input().split()]
        if p == 0:
            break
        ans.append(solve(p, q, a, n))
    print(*ans, sep="\n")
### BUGGY CODE ###

div = 1000000007

n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

f = [0] * (n + 1)
f[0] = 1

if 1 not in a:
    f[1] = 1

for i in range(2, n + 1):
    if i in a:
        continue
    f[i] = (f[i - 1] + f[i - 2]) % div

print(f[-1])


### FIXED CODE ###

def main():
    N, M, *a = map(int, open(0).read().split())
    div = 1000000007
    broken = set(a)
 
    comb_list = [0] * (N + 1)
    comb_list[0] = 1
    if 1 not in broken:
        comb_list[1] = 1
 
    for i in range(2, N + 1):
        if i in broken:
            continue
        comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div
 
    print(comb_list[-1])
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import collections

N,M = map(int,input().split())

path = [[False for i in range(N)] for j in range(N)]

not_start = []

for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    not_start.append(b)

not_start = set(not_start)

start = list(set(range(N)).difference(not_start))

ans = 0

for i in range(len(start)) :
    q = collections.deque()
    q.append(start[i])
    dist = [0 for i in range(N)]
    
    while q :
        now = q.pop()
        for j in range(N) :
            if path[now][j] :
                q.append(j)
                dist[j] = max(dist[j], dist[now]+1)
    
    ans = max(ans, max(dist))

print(ans)



### FIXED CODE ###

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]

L_minus = [[] for i in range(N)]
L_plus = [0 for i in range(N)]

dp = [0 for i in range(N)]

for i in range(M) :
    x,y = L[i]
    x -= 1
    y -= 1
    L_plus[y] += 1
    L_minus[x].append(y)

A = []

for i in range(N) :
    if L_plus[i] == 0 :
        A.append(i)

while A :
    x = A.pop()
    
    for y in L_minus[x] :
        L_plus[y] -= 1
        if L_plus[y] == 0 :
            A.append(y)
        dp[y] = max(dp[y], dp[x]+1)

ans = max(dp)

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

def cnt_ac(S,l,r):
    N = len(S)
    T = [0]*(N+1)
    for i in range(N):
        T[i+1] = T[i] + (1 if S[i : i+2] == 'AC' else 0)
    return T[r-1] - T[l-1]


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

for i in range(Q):
    L, R = map(int,input().split())
    print(cnt_ac(S,L,R))


### FIXED CODE ###

N, Q = map(int,input().split())
S = input()
T = [0]*(N+1)
for i in range(N):
    T[i+1] = T[i] + (1 if S[i : i+2] == 'AC' else 0)

for i in range(Q):
    L, R = map(int,input().split())
    print(T[R-1] - T[L-1])
### BUGGY CODE ###

n,k=map(int,input().split())
xy=[list(map(int,input().split())) for _ in range(n)]
x=[t[0] for t in xy]
y=[t[1] for t in xy]

res=[]
for i in range(n):
    for j in range(n):
        for a in range(n):
            for b in range(n):
                l=min(x[i],x[j])
                r=max(x[i],x[j])
                d=min(y[a],y[b])
                u=max(y[a],y[b])
                tk=0
                for t in xy:
                    if l<=t[0]<=r and d<=t[1]<=u:
                        tk+=1
                if tk>=k:
                    res.append((r-l)*(u-d))
print(min(res))

### FIXED CODE ###

n,k=map(int,input().split())
xy=[list(map(int,input().split())) for _ in range(n)]
x=[t[0] for t in xy]
y=[t[1] for t in xy]

res=[]
for i in range(n-1):
    for j in range(i+1,n):
        for a in range(n-1):
            for b in range(a+1,n):
                l=min(x[i],x[j])
                r=max(x[i],x[j])
                d=min(y[a],y[b])
                u=max(y[a],y[b])
                tk=0
                for t in xy:
                    if l<=t[0]<=r and d<=t[1]<=u:
                        tk+=1
                if tk>=k:
                    res.append((r-l)*(u-d))
print(min(res))
### BUGGY CODE ###

from math import factorial
n = int(input())
a = [int(item) for item in input().split()]

def combination(n, r):
    if n-r < 0:
        return 0
    return factorial(n) // (factorial(n-r) * factorial(r))

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

for i in range(1, n+2):
    print((combination(n+1, i) - combination(n+1 - (r-l) - 1, i-1))%(10**9 + 7))

### FIXED CODE ###

n = int(input()) + 1
a = [int(item) for item in input().split()]
MOD = 10**9 + 7

def mod_pow(x, n):
    ans = 1
    while(n != 0):
        if n & 1:
            ans = ans * x % MOD
        x = x * x % MOD
        n = n >> 1
    return ans

fac = [1] + [0] * n
inv_fac = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    inv_fac[i] = inv_fac[i-1] * mod_pow(i, MOD-2) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = inv_fac[n-r] * inv_fac[r] % MOD
    return tmp * fac[n] % MOD 

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

for i in range(1, n+1):
    total = mod_nCr(n, i)
    doubled = mod_nCr(n -(r-l) - 1, i-1)
    ans = total - doubled
    if ans < 0:
        ans += MOD
    print(ans)
### BUGGY CODE ###

x,y,z,k = [ int(it) for it in input().split() ]
al = [ int(it) for it in input().split() ]
bl = [ int(it) for it in input().split() ]
cl = [ int(it) for it in input().split() ]

abl = [ a + b for a in al for b in bl]
abl.sort()
abl.reverse()
abl=abl[:k]

abcl = [ ab + c for ab in abl for c in cl]
abcl.sort()
abcl.reverse()
abcl=abcl[:k]
for it in abcl:
  print (it)





### FIXED CODE ###

x,y,z,k = [ int(it) for it in input().split() ]
al = [ int(it) for it in input().split() ]
bl = [ int(it) for it in input().split() ]
cl = [ int(it) for it in input().split() ]

abl = [ a + b for a in al for b in bl]
abl.sort()
abl.reverse()
abl=abl[:k]

abcl = [ ab + c for ab in abl for c in cl]
abcl.sort()
abcl.reverse()
abcl=abcl[:k]
print ( "\n".join( [ str(it) for it in abcl ]) )
### BUGGY CODE ###

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


def divisor(num):
    opside = num
    i = 2
    div = [1, opside]
    while i <= opside:
        if num % i == 0:
            opside = num // i
            if i == opside:
                div.append(i)
            elif opside <= i:
                break
            else:
                div.append(i)
                div.append(opside)
        i += 1
    div.sort()
    return div


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
print(ans)

### FIXED CODE ###

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


def divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
    else:
        break
print(ans)
### BUGGY CODE ###

import sys
N,M=map(int,input().split())
ab=[]
for i in range(M):
  ab+=[list(map(int,input().split()))]
come=[]
go=[]
for i in range(M):
  if ab[i][0]==1:
    come+=[ab[i][1]]
  if ab[i][1]==N:
    go+=[ab[i][0]]
for i in range(len(come)):
  if come[i] in go:
    print("POSSIBLE")
    sys.exit()
print("IMPOSSIBLE")

### FIXED CODE ###

import sys
N,M=map(int,input().split())
come=[0]*N
for i in range(M):
  ab=list(map(int,input().split()))
  if ab[0]==1:
    if come[ab[1]]:
      print("POSSIBLE")
      sys.exit()
    come[ab[1]]=1
  if ab[1]==N:
    if come[ab[0]]:
      print("POSSIBLE")
      sys.exit()
    come[ab[0]]=1
 
print("IMPOSSIBLE")
### BUGGY CODE ###

import copy
n = int(input())
a = list(map(int, input().split()))
array = [(a[i], i+1) for i in range(n)]
array.sort(reverse=True)
dp = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n):
    for j in range(n):
        if i + j >= n:
            break
        count = i + j
        #右に移した場合
        value, index = array[count]
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + value * abs((n - j) - index))
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + value * abs((i + 1) - index))
ans = 0
for i in range(n+1):
    for j in range(n+1):
        ans = max(ans, dp[i][j])
print(ans)
        




### FIXED CODE ###

import copy
n = int(input())
a = list(map(int, input().split()))
array = [(a[i], i+1) for i in range(n)]
array.sort(reverse=True)
dp = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n):
    for j in range(n):
        if i + j >= n:
            break
        count = i + j
        #右に移した場合
        value, index = array[count]
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + value * abs((n - j) - index))
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + value * abs((i + 1) - index))
ans = 0
for i in range(n+1):
    for j in range(n+1):
        ans = max(ans, dp[i][j])
print(ans)
### BUGGY CODE ###

n = int(input())
ans = 1
for i in range(n):
    ans = ans * (i+1)
print("{}".format(ans % (10**9+7)))

### FIXED CODE ###

n = int(input())

ans = 1
for i in range(n):
    ans = ans * (i+1) % (10**9+7)
print("{}".format(ans))
### BUGGY CODE ###

n = int(input())
dp = [0] * (n * 10 ** 4 + 1)
bs = [list(map(int, input().split())) for _ in range(n)]
bs.sort(key=lambda x: x[0] + x[1])
for w, s, v in bs:
    for i in range(w + s, w - 1, -1):
        dpw = dp[i - w] + v
        if dpw > dp[i]:
            dp[i] = dpw
print(max(dp))


### FIXED CODE ###

def f(n):
    dp = [0] * (n * 10 ** 4 + 1)
    bs = [list(map(int, input().split())) for _ in range(n)]
    bs.sort(key=lambda x: x[0] + x[1])
    for w, s, v in bs:
        for i in range(w + s, w - 1, -1):
            dpw = dp[i - w] + v
            if dpw > dp[i]:
                dp[i] = dpw
    print(max(dp))


n = int(input())
f(n)
### BUGGY CODE ###

N,M=map(int,input().split())
a=[]
b=[]
for i in range(M):
    c,d=map(int,input().split())
    if c==1:
        a.append(d)
    if d==N:
        b.append(c)

#O(M)

flag = False
for idx in a:
    if idx in b:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

### FIXED CODE ###

N,M=map(int,input().split())
G = [list() for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)
#O(M)
flag = False
for i in G[1]:
    if N in G[i]:
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

def main():
  A, B, K = [int(x) for x in input().split()]
  l = [str(i) for i in range(A, B + 1) if i < A + K or i > B - K]
  print('\n'.join(l))


if __name__ == "__main__":
  main()


### FIXED CODE ###

def main():
  A, B, K = [int(x) for x in input().split()]
  for i in range(A, min(B + 1, A + K)):
    print(i)
  for i in range(max(A + K, B - K + 1), B + 1):
    print(i)


if __name__ == "__main__":
  main()
### BUGGY CODE ###

def solve():
    T = input()
    ans = ""
    for i in range(len(T)):
        if i < len(T) -1 and T[i] + T[i+1] == "?D":
            ans += "P"
        elif T[i] == "?":
            ans += "D"
        else:
            ans += T[i]
    
    print(ans)
            
if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    T = input()
    ans = ""
    for i in range(len(T)):
        if T[i] == "?":
            ans += "D"
        else:
            ans += T[i]
    
    print(ans)
            
if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

N = int(input())
L = list(map(int, input().split()))

L = sorted(L)

ans = 0
for i in range(N-2):
    for j in range(N-1):
        if j > i:
            b = L[j] - L[i]
            c = L[i] + L[j]
            mi = bisect.bisect_left(L[j+1:], b)
            ma = bisect.bisect_left(L[j+1:], c)
            ans += ma - mi

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)

    ans = 0
    for i in range(N-2):
        for j in range(N-1):
            if j > i:
                ans += bisect.bisect_left(L[j+1:], L[i] + L[j])

    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
li=list(map(int,input().split()))

ans=[]
for i in range(n-1,n//2-1,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i-1]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

### FIXED CODE ###

n=int(input())
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)
### BUGGY CODE ###

from collections import deque, defaultdict

def bfs(graph, start):
    queue = deque([start])
    visited = set()
    distance = defaultdict(int)
    distance[start] = 0
    while queue:
        current_vertex = queue.popleft()
        visited.add(current_vertex)
        for v in graph[current_vertex]:
            if v not in visited and v not in queue:
                queue.append(v)
                distance[v] = distance[current_vertex] + 1
    return distance

N, M = map(int, input().split())
paths = [tuple(map(int, input().split())) for _ in range(M)]

graph = defaultdict(set)
for A, B in paths:
    graph[A].add(B)
    graph[B].add(A)

distance = bfs(graph, 1)
distance_map = defaultdict(set)
for k, v in distance.items():
    distance_map[v].add(k)

ans = 'Yes'
ans_list = []
for v in range(2, N+1):
    intersection = distance_map[distance[v] - 1] & graph[v]
    if len(intersection) != 0:
        ans_list.append(list(intersection)[0])
    else:
        ans = 'No'
if ans == 'No':
    print(ans)
else:
    print(ans)
    for x in ans_list:
        print(x)


### FIXED CODE ###

from collections import deque, defaultdict


def bfs(graph, start):

    queue = deque([start])
    visited = set()
    visited.add(start)
    parent = defaultdict(int)
    parent[start] = 0
    while queue:
        current_vertex = queue.popleft()
        for v in graph[current_vertex]:
            if v not in visited:
                queue.append(v)
                visited.add(v)
                parent[v] = current_vertex
    return parent

N, M = map(int, input().split())
paths = [tuple(map(int, input().split())) for _ in range(M)]

graph = defaultdict(set)
for A, B in paths:
    graph[A].add(B)
    graph[B].add(A)

parent = bfs(graph, 1)

print('Yes')
for k, v in sorted(parent.items()):
    if v != 0:
        print(v)
### BUGGY CODE ###

from bisect import bisect,insort_left
import itertools
q=int(input())
query=[list(map(int,input().split())) for i in range(q)]
inf=float("inf")
a_sum=0
b_sum=0
A=[]
count=0
for u in query:
    if u[0]==2:
        if count%2==1:
            num=count//2
            print(A[num][0],a_sum+b_sum-A[num][0])
        else:
            num=count//2
            print(A[num-1][0],a_sum+b_sum)
    else:
        count+=1
        a,b=u[1],u[2]
        b_sum+=b
        c=bisect(A,[a,-inf])
        num=count//2
        if c>=num:
            A=list(itertools.chain(A[:c],[[a,a]],A[c:]))
            a_sum+=a
        else:
            A=list(itertools.chain(A[:c],[[a,-a]],A[c:]))
            a_sum+=-a
        if num==0:
            continue
        if A[num-1][1]==A[num-1][0]:
            a_sum+=-2*A[num-1][0]
            A[num-1][1]=-A[num-1][0]
        if A[num][1]!=A[num][0]:
            a_sum+=2*A[num][0]
            A[num][1]=A[num][0]

### FIXED CODE ###

from heapq import heappop,heappush
q=int(input())
query=[list(map(int,input().split())) for _ in range(q)]
inf=10**12
left=[inf]
left_sum=0
right=[inf]
right_sum=0

cnt=0
b=0
for i in range(q):
    if query[i][0]==1:
        a=query[i][1]
        b+=query[i][2]
        if cnt==0:
            d=right[0]
            if a>d:
                heappush(left,-heappop(right))
                heappush(right,a)
                right_sum+=a-d
                left_sum-=d
            else:
                heappush(left,-a)
                left_sum-=a
            cnt=1
        else:
            c=-left[0]
            if a<c:
                heappush(right,-heappop(left))
                heappush(left,-a)
                right_sum+=c
                left_sum+=c-a
            else:
                heappush(right,a)
                right_sum+=a
            cnt=0
    else:
        x=-left[0]
        if cnt==0:
            print(x,b+right_sum+left_sum)
        else:
            print(x,b+x+right_sum+left_sum)
### BUGGY CODE ###

import itertools
k, s = map(int, input().split())

a = list(itertools.combinations_with_replacement(range(0, k+1), 3))
ans = 0
for i in a:
    if sum(i) == s:
        if i[0] == i[1] == i[2]:
            ans += 1
        elif i[0] != i[1] != i[2] != i[0]:
            ans += 6
        else:
            ans += 3
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 += max(0, 0<=s-x-y<=k)
print(ans)
### BUGGY CODE ###

#ABC129C-TypicalStairs.py

#import list
import numpy as np
from sys import stdin, setrecursionlimit
from functools import lru_cache

input = stdin.readline
setrecursionlimit(1000)

#constant
#N = int(input())
N, M = list(map(int,input().split()))
A = [int(input()) for _ in range(M)]

#variable
rootList = [1]+[0]*(N)

#function

#class

#main function
def main():
    for i in range(N):
        rootList[i+1] = rootList[i]+rootList[i-1]
        if i+1 in A:
            rootList[i+1] = 0
    print(rootList[N]%1000000007)

if __name__ == "__main__":
    main()


### FIXED CODE ###

#ABC129C-TypicalStairs.py

#import list
import numpy as np
from sys import stdin, setrecursionlimit
from functools import lru_cache

input = stdin.readline
setrecursionlimit(1000)

#constant
#N = int(input())
N, M = list(map(int,input().split()))
A = {int(input()) for _ in range(M)}

#variable
rootList = np.array([1]+[0]*(N))

#function

#class

#main function
def main():
    for i in range(N):
        rootList[i+1] = (rootList[i]+rootList[i-1])%1000000007
        if i+1 in A:
            rootList[i+1] = 0
    print(rootList[N])

if __name__ == "__main__":
    main()