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

def popcount(n):
    bit_count = bin(n).count('1')
    n = n % bit_count 
    return n

if __name__ == "__main__":
    import sys 

    readline = sys.stdin.readline 

    N = int(input())
    X = readline()
    bit_count = X.count('1')
    X_int = int(X, 2)


    for i in range(N):
        # ビットの反転
        bit_count_n = bit_count
        X_rest = 0
        if X[i] == '0':
            bit_count_n += 1
            X_rest = X_int + pow(2, N - 1 - i)
        else:
            bit_count_n -= 1
            X_rest = X_int - pow(2, N - 1 - i)

        if X_rest == 0:
            print(0)
        else:
            popcount_X = X_rest % bit_count_n
            counter = 1
            while popcount_X != 0:
                popcount_X %= bin(popcount_X).count('1')
                counter += 1
            print(counter)






### FIXED CODE ###

def popcount(n):
    bit_count = bin(n).count('1')
    n = n % bit_count 
    return n

if __name__ == "__main__":
    import sys 

    readline = sys.stdin.readline 

    N = int(input())
    X = readline()
    bit_count = X.count('1')
    mod1 = int(X, 2) % (bit_count + 1)
    mod2 = int(X, 2) % (bit_count - 1) if (bit_count - 1) != 0 else 0

    for i in range(N):
        if X[i] == '0':
            X_rest = (mod1 + pow(2, N - 1 - i, bit_count + 1)) % (bit_count + 1)
        else:
            if bit_count - 1 != 0:
                X_rest = (mod2 - pow(2, N - 1 - i, bit_count - 1)) % (bit_count - 1)
            else:
                print(0)
                continue

        counter = 1
        while X_rest != 0:
            X_rest = popcount(X_rest)
            counter += 1
        print(counter)
### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return int(a * b / gcd(a, b))


N, M = LI()
S = input()
T = input()
#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(len(S), len(T))
L = X
XS = ['X' for i in range(L+1)]
XT = ['X' for i in range(L+1)]
count = 0
LN = L/N
while True:
    XS[int(count*LN)] = S[count]
    count += 1
    if count > N-1:
        break

count = 0
LM = L/M
while True:
    XT[int(count*LM)] = T[count]
    count += 1
    if count > M-1:
        break

#  print(XS, XT)
for i in range(0, L+1):
    if XS[i] != 'X' and XT[i] != 'X':
        if XT[i] != XS[i]:
            print(-1)
            exit()
print(L)


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

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

N, M = LI()
S = input()
T = input()

#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(N, M)
L = X
#  XS = ['X' for i in range(L+1)]
#  XT = ['X' for i in range(L+1)]
XS, XT = {}, {}
count = 0
LN = L/N
while True:
    XS[int(count*LN)] = S[count]
    count += 1
    if count > N-1:
        break

count = 0
LM = L/M
while True:
    XT[int(count*LM)] = T[count]
    count += 1
    if count > M-1:
        break

for key, value in XS.items():
    #  print(key, value)
    if key in XT:
        if value != XT[key]:
            print(-1)
            exit()
#  print(XS, XT)
#  for i in range(0, L+1):
#      if XS[i] != 'X' and XT[i] != 'X':
#          if XT[i] != XS[i]:
#              print(-1)
#              exit()
print(L)
### BUGGY CODE ###

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

g = {}
for a, b in ab:
    if a in g: g[a].append(b)
    else: g[a] = [b]
    if b in g: g[b].append(a)
    else: g[b] = [a]

cnt = [0]*(N+1)

for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

temp = [1]
visited = [0]*(N+1)
visited[1] = 1

while temp:
    q = temp.pop()   
    for i in g[q]:
        if visited[i] == 0:
            temp.append(i)
            visited[i] = 1
            cnt[i] += cnt[q]
print(*cnt[1:])


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

bond_lst = list([list(map(int,input().split())) for _ in range(N-1)])
      
point_lst = [0]*(N+1)

for _ in range(Q):
    a, b = map(int, input().split())
    point_lst[a] += b

graph = {}

for a, b in bond_lst:
    if a in graph:graph[a].append(b)
    else:graph[a] = [b]
    if b in graph:graph[b].append(a)
    else:graph[b] = [a]
      
passed = [0]*(N+1)
nxt_lst = [1]
while nxt_lst:
    nxt = nxt_lst.pop()
    for i in graph[nxt]:
        if passed[i] == 1:continue
        point_lst[i] += point_lst[nxt]
        nxt_lst.append(i)
    passed[nxt] = 1
print(*point_lst[1:])
### BUGGY CODE ###

N = int(input().strip())
A = list(map(int, input().strip().split()))

def mod(x):
	return x % 1000000007

s = 0
for i in range(N - 1):
	s = mod(s + A[i] * sum(A[i + 1:]))

print(s)

### FIXED CODE ###

N = int(input().strip())
A = list(map(int, input().strip().split()))

def mod(x):
	return x % 1000000007

sa = sum(A[1:])
s = mod(A[0] * sa)

for a in A[1:-1]:
	sa -= a
	s = mod(s + a * sa)

print(s)
### BUGGY CODE ###

S=input()
Q=int(input())
Query=[[j for j in input().split()] for i in range(Q)]


for i in range(Q):
    if Query[i][0]=='1':
        S=''.join(list(reversed(S)))
    else:
        if Query[i][1]=='1':
            S=Query[i][2]+S
        else:
            S = S+Query[i][2]

print(S)

### FIXED CODE ###

from collections import deque

S=input()
Q=int(input())
Query=[[j for j in input().split()] for i in range(Q)]

c=0
S0=deque(S)

for i in range(Q):
    if Query[i][0]=='1':
        c=c+1
    else:
        if ((Query[i][1]=='1')and(c%2==0)) or ((Query[i][1]=='2')and(c%2==1)):
            S0.appendleft(Query[i][2])
        else:
            S0.append(Query[i][2])

if c%2==0:
    print(''.join(S0))
else:
    print(''.join(reversed(S0)))
### BUGGY CODE ###

N,K=map(int, input().split())
A=list(map(int,input().split()))
count=0
for l in range(N):
    if A[l]%K==1:
        count+=1
for l in range(N-1):
    sum=A[l]
    for r in range(l+1,N):
        sum+=A[r]
        if sum%K==r-l+1:
            count+=1
print(count)


### FIXED CODE ###

from collections import defaultdict
N,K=map(int, input().split())
A=list(map(int,input().split()))
"""count=0
for l in range(N):
    if A[l]%K==1:
        count+=1
for l in range(N-1):
    sum=A[l]
    for r in range(l+1,N):
        sum+=A[r]
        if sum%K==r-l+1:
            count+=1
print(count)"""
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=(cum[i]+A[i]-1)%K
dic=defaultdict(int)
ans=0
for i in range(N+1):
    ans+=dic[cum[i]]
    dic[cum[i]]+=1
    if i-(K-1)>=0:
        dic[cum[i-(K-1)]]-=1
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = "_"+ input() +"_"

dic = {}
for i in range(N+2):
    dic[S[i]] = dic.get(S[i],[]) + [i] 
    
table = [0] + [1]*N + [0]
for _ in range(Q):
    t,d = input().split()
    if t not in dic:
        continue
    if d == "L":                
        for i in dic[t]:
            table[i-1] += table[i] 
            table[i] = 0
    else:   
        for i in dic[t]:
            table[i+1] += table[i]
            table[i] = 0
print(sum(table[1:N+1]))


### FIXED CODE ###

N,Q = map(int,input().split())
S = "_"+ input() +"_"
td = [input().split() for _ in range(Q)]

l = 0
r = N+1
for i in range(Q-1,-1,-1): 
    t,d = td[i]
    if t == S[l] and d == "R":
        l -= 1
    elif t == S[l+1] and d == "L":
        l += 1
    if t == S[r] and d == "L":
        r += 1
    elif t == S[r-1] and d == "R":
        r -= 1
print(max(0,r-l-1))
### BUGGY CODE ###

import sys

S = input()

while True:
    if S == '':
        print('YES')
        sys.exit(0)
    if len(S) < 5:
        print('NO')
        sys.exit(0)
    third = S[-3]
    if third == 'e':
        if len(S) < 5 or S[-5:] != 'dream':
            print('NO')
            sys.exit(0)
        S = S[:-5]
    if third == 'a':
        if len(S) < 5 or S[-5:] != 'erase':
            print('NO')
            sys.exit(0)
        S = S[:-5]
    if third == 'm':
        if len(S) < 7 or S[-7:] != 'dreamer':
            print('NO')
            sys.exit(0)
        S = S[:-7]
    if third == 's':
        if len(S) < 6 or S[-6:] != 'eraser':
            print('NO')
            sys.exit(0)
        S = S[:-6]


### FIXED CODE ###

import sys

S = input()

while len(S) > 0:
    if len(S) < 5:
        print('NO')
        sys.exit(0)
    third = S[-3]
    if third == 'e':
        if len(S) < 5 or S[-5:] != 'dream':
            print('NO')
            sys.exit(0)
        S = S[:-5]
        continue
    if third == 'a':
        if len(S) < 5 or S[-5:] != 'erase':
            print('NO')
            sys.exit(0)
        S = S[:-5]
        continue
    if third == 'm':
        if len(S) < 7 or S[-7:] != 'dreamer':
            print('NO')
            sys.exit(0)
        S = S[:-7]
        continue
    if third == 's':
        if len(S) < 6 or S[-6:] != 'eraser':
            print('NO')
            sys.exit(0)
        S = S[:-6]
        continue
    else:
        print('NO')
        sys.exit(0)

print('YES')
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import itertools
import numpy as np

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

lst = [i for i in range(k+1)]


prod = list(itertools.product(lst, repeat=3))

arr = np.array(prod)
arr_sum = arr.sum(axis=1)
ans = np.count_nonzero(arr_sum == s)

print(ans)











### FIXED CODE ###

# coding: utf-8
# Your code here!

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

cnt = 0

for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k and s-i-j>=0:
            cnt += 1

print(cnt)
### BUGGY CODE ###

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

r = 0
r_l = []
g = 0
g_l = []
b = 0
b_l = []

for i in range(n):
    if s[i] == "R":
        r += 1
        r_l.append(i+1)
    if s[i] == "G":
        g += 1
        g_l.append(i+1)
    if s[i] == "B":
        b += 1
        b_l.append(i+1)
        
ans = r*g*b

for i in r_l:
    for j in g_l:
        for k in b_l:
            one = max(i,max(k,j))
            three = min(i,min(k,j))
            if i != one and i != three:
                two = i
            if j != one and j != three:
                two = j
            if k != one and k != three:
                two = k 
            if two - one == three - two:
                ans -= 1

print(ans)


### FIXED CODE ###

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

r = 0
r_l = []
g = 0
g_l = []
b = 0
b_l = []

for i in range(n):
    if s[i] == "R":
        r += 1
        r_l.append(i)
    if s[i] == "G":
        g += 1
        g_l.append(i)
    if s[i] == "B":
        b += 1
        b_l.append(i)
        
ans = r*g*b

for i in r_l:
    for j in g_l:
        tmp = abs(i-j)
        if 0 <= i-tmp and s[i-tmp] == "B":
            ans -= 1
        if 0 <= j-tmp and s[j-tmp] == "B":
            ans -= 1
        if i+tmp < n and s[i+tmp] == "B":
            ans -= 1
        if j+tmp < n and s[j+tmp] == "B":
            ans -= 1

        if (tmp / 2).is_integer():
            if s[max(i,j)-(tmp//2)] == "B":
                ans -= 1
            if max(i,j)-(tmp//2) != min(i,j)+(tmp//2) and s[min(i,j)+(tmp//2)] == "B":
                ans -= 1

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

import sys
#from collections import defaultdict
sys.setrecursionlimit(10**6)

def input():
	return sys.stdin.readline()[:-1]
n, l = map(int, input().split())
ss = [input() for _ in range(n)]

def addTree(tree, sentence):
	if not sentence[0:]:
		return None   

	if sentence[0] not in tree:
		tree[sentence[0]] = {}

	tree[sentence[0]] = addTree(tree[sentence[0]], sentence[1:])

	return tree

def createTree(sentences):    
	tree = {}
	for sentence in sentences:
		tree = addTree(tree, sentence)

	return tree

tree = createTree(ss)
#print(tree)

grundy = 0
def dfs(cur, level):
	global grundy
	if cur is None:
		return
	elif len(cur) == 1:
		grundy ^= (l-level) & (-l+level)
	for k in cur.keys():
		dfs(cur[k], level+1)
	return
	
dfs(tree, 0)

if grundy == 0:
	print("Bob")
else:
	print("Alice")


### FIXED CODE ###

import sys
#from collections import defaultdict
sys.setrecursionlimit(10**6)

def input():
	return sys.stdin.readline()[:-1]
n, l = map(int, input().split())
ss = [list(input())[::-1] for _ in range(n)]

def addTree(tree, sentence):
	if not sentence:
		return None   

	if sentence[-1] not in tree:
		tree[sentence[-1]] = {}

	p = sentence.pop()
	tree[p] = addTree(tree[p], sentence)

	return tree

def createTree(sentences):    
	tree = {}
	for sentence in sentences:
		tree = addTree(tree, sentence)

	return tree

tree = createTree(ss)
#print(tree)

grundy = 0
def dfs(cur, level):
	global grundy
	if cur is None:
		return
	elif len(cur) == 1:
		grundy ^= (l-level) & (-l+level)
	for k in cur.keys():
		dfs(cur[k], level+1)
	return
	
dfs(tree, 0)

if grundy == 0:
	print("Bob")
else:
	print("Alice")
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = int(1e+9 + 7)
a = sorted(a)

kai = [1, 1]
gyaku = [1, 1]

for i in range(2, n+1):
    kai.append(kai[-1]*i % mod)
    gyaku.append(gyaku[-1]*pow(i, mod-2, mod))

answer = 0
for i in range(n-k+1):
    for j in range(i+k-1,n):
        answer = (answer + (a[j] - a[i]) * kai[j-i-1] *gyaku[j-i-1-(k-2)] * gyaku[k-2])%mod

if k == 1:
    print(0)
else:
    print(answer)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = int(1e+9 + 7)
a = sorted(a)

kai = [1]*(n+1)
gyaku = [1]*(n+1)

for i in range(2, n+1):
    kai[i] = kai[i-1]*i % mod
    gyaku[i] = gyaku[i-1]*pow(i, mod-2, mod) %mod

answer = 0
for i in range(k-1,n):
    answer = (answer + a[i] * kai[i] * gyaku[(i)-(k-1)] * gyaku[k-1]) % mod

answer2 = 0
for i in range(n-k+1):
    answer2 = (answer2 + a[i] * kai[n-i-1] * gyaku[(n-i)-k] * gyaku[k-1]) % mod


if k == 1:
    print(0)
else:
    print((answer - answer2)%mod)
### BUGGY CODE ###

#DSL_3-D Sliding Window - Sliding Minimum Elements
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
for i in range(N-L+1) : ans.append(min(A[i+L//2:i+L]+A[i:i+L//2]))
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 ###

import heapq

H, W = map(int, input().split())
board = []
goal_dst = [[float("inf") for _ in range(W)] for _ in range(H)]
no = 0

for _ in range(H):
	board.append(list(map(str, input())))
	no += board[-1].count("#")
	
# bfsで最短路を求める
Q = [[1, 0, 0]]
juuji = [[-1, 0], [1, 0], [0, -1], [0, 1]]

while Q:
	cur = heapq.heappop(Q)
	dist = cur[0]
	if goal_dst[cur[1]][cur[2]] < dist or goal_dst[-1][-1] < dist: continue
	goal_dst[cur[1]][cur[2]] = dist
	for move in juuji:
		new_y = cur[1] + move[0]
		new_x = cur[2] + move[1]
		if not (0 <= new_x and new_x <= W - 1 and 0 <= new_y and new_y <= H - 1): continue 
		if board[new_y][new_x] == ".":
			heapq.heappush(Q, [dist + 1, new_y, new_x])
			
if goal_dst[-1][-1] == float("inf"):
	print(-1)
else:
	print(H * W - goal_dst[-1][-1] - no)

### FIXED CODE ###

from heapq import heappush, heappop
H, W = map(int, input().split())
s = [input() for _ in range(H)]

dist = [[float('inf')] * W for _ in range(H)]
q = [(0, 0, 0)]
while q :
    cost, cx, cy = heappop(q)
    if cost >= dist[cy][cx] :
        continue
    dist[cy][cx] = cost
        
    for dx, dy in ((0, 1), (0, -1), (1, 0), (-1, 0)) :
        if 0 <= cx + dx < W and 0 <= cy + dy < H and s[cy+dy][cx+dx] != '#' :
            heappush(q, (cost+1, cx+dx, cy+dy))
            
if dist[H-1][W-1] == float('inf') :
    print(-1)
else :
    ret = 0
    for s_ in s :
        ret += s_.count('#')
    print(H * W - ret - dist[H-1][W-1] - 1)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
  
for i in range(n):
  if i==0:
    temp = a[1:]
  elif i==n-1:
    temp = a[:i]
  else:
    temp = a[:i]+a[i+1:]
  print(max(temp))

### FIXED CODE ###

#全体の最大値が入っているときは、それが部分列の最大値になるので、わざわざ計算しなくて良い
#こういうことに先気づかないと、TLEになる
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

a_max = max(a)
max_idx = a.index(a_max)
c = a.count(a_max)

for i in range(n):
  if i!=max_idx:
    print(a_max)
  elif i==max_idx and c>=2:
    print(a_max)
  else:
    a.remove(a[i])
    print(max(a))
### BUGGY CODE ###

import bisect
N, = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
def g(x):
    mx, mn = N, -1
    idx = mx//2
    while mx-mn>1:
        if Q[idx] >= x:
            mx, idx = idx, (idx+mn)//2
            continue
        mn, idx = idx, (idx+mx)//2
    return idx+1
mxk = 29
msk = (1<<mxk) - 1
msk2 = (1<<(mxk-1))
r = 0
for i in range(mxk):
    for j in range(N):
        Q[j] = Q[j] & msk
        P[j] = P[j] & msk
    msk >>= 1
    Q.sort()
    b = 0
    for p in P:
        x = bisect.bisect_left(Q, 2*msk2 - (p&msk))
        z = bisect.bisect_left(Q, msk2 - (p&msk))
        if p & msk2:
            b += z+N-x
        else:
            b += x-z
    if b%2:
        r += 1<<(mxk-1-i)
    msk2 >>= 1
print(r)


### FIXED CODE ###

N, = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
mxk = 29
msk = (1<<mxk) - 1
msk2 = (1<<(mxk-1))
r = 0
for i in range(mxk):
    # 下からiビット目をみる
    for j in range(N):
        Q[j] = Q[j] & msk
        P[j] = P[j] & msk
    msk >>= 1
    P.sort()
    Q.sort()
    j1 = N-1
    j2 = N-1
    b = 0
    ss = N
#    print(P, Q)
    for l in range(N):
        if P[l] & msk2:
            ss = l
            break
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
        b += j2 - j1
#        print("a",j2-j1,k1,k2,j1,j2)

    j1 = N-1
    j2 = N-1
#    print(ss)
    for l in range(ss, N):
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
#        print("b",j1 - j2 + N)
        b += j1 + N - j2

#    b = 0
#    for p in P:
#        if p & msk2:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += z+N-x
#        else:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += x-z
#    print(b, r, i)
    if b%2:
        r += 1<<(mxk-1-i)
    msk2 >>= 1
print(r)
### 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):
      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(x,k+1):
    z=s-(x+y)
    if z>k or z<y:
      continue
    if x==y and y==z:
      ans+=1
    elif x==y or y==z or x==z:
      ans+=3
    else:
      ans+=6
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
ans = 1
if len(l) == 1:
    print(1)
    exit()
if len(l) > 1 and l[0] >= l[1]:
    ans += 1
for i in range(2, n):
    if min(l[:i]) > l[i]:
        ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
ans = 1
min_l = l[0]
for i in range(1, n):
    if min_l > l[i]:
        ans += 1
        min_l = l[i]
print(ans)
### BUGGY CODE ###

N,M = map(int, input().split())
A = list(map(int, input().split()))
value = sum(A)
A.append(-10**9)

cards = M

for i in range(M):
    A = sorted(A,reverse=True)
    p = 0
    while A[p] == max(A) and cards >= 1:
        A[p] //= 2
        p += 1
        cards -= 1
    if cards == 0 or max(A) == 0:
        break

A.pop()
print(sum(A))

### FIXED CODE ###

import heapq
N, M = [int(_) for _ in input().split()]
A = [-int(_) for _ in input().split()]

heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, -(-a//2))

print(-sum(A))
### BUGGY CODE ###

from fractions import Fraction
import math
N = int(input())
ans = Fraction(4,N)
point = [1,math.floor(N/4)]
for h in range(max(point),3501):
    h_pro = Fraction(1,h)
    check = ans - h_pro
    target = [math.floor(4*h-N/N*h),h]
    for n in range(h,3501):
        check = ans - h_pro
        n_pro = Fraction(1,n)
        check -= n_pro
        if type(check) == "int":
            if check ==1:
                print(h, end=" ")
                print(n, end=" ")
                print(1)
                exit()
        elif check.numerator == 1:
            print(h, end=" ")
            print(n, end=" ")
            print(check.denominator)
            exit()

### FIXED CODE ###

from fractions import Fraction
import math
N = int(input())
ans = Fraction(4,N)
point = [1,math.floor(N/4)]
for h in range(max(point),3501):
    h_pro = Fraction(1,h)
    check = ans - h_pro
    target = [math.floor(4*h-N/N*h),h]
    for n in range(h,3501):
        check = ans - h_pro
        n_pro = Fraction(1,n)
        check -= n_pro
        if type(check) == "int":
            if check ==1:
                print(h, end=" ")
                print(n, end=" ")
                print(1)
                exit()
        elif check.numerator == 1:
            print(h, end=" ")
            print(n, end=" ")
            print(check.denominator)
            exit()