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


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

count = 0
flag = False

for i in range(n):
    for j in range(i+1):
        if P[i] <= P[j]:
            flag = True
        else:
            flag = False
            break
    if flag == True:
        count += 1
    flag = False

print(count)


### FIXED CODE ###


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

count = 0
m = P[0]
for i in range(n):
    if P[i] <= m:
        count += 1
        m = P[i]
print(count)
### BUGGY CODE ###

# 速いやつの文字列inを使った省メモリver
N = int(input())
S = input()

def check(l):
    for i in range(N - 2 * l + 1):
        if S[i : i + l] in S[i + l :]:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

### FIXED CODE ###

N = int(input())
S = input()

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

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if S[i] == S[j]:
            tmp = 1
            if i > 0:
                tmp += dp[i - 1][j - 1]
            if j - i < tmp:
                continue
            dp[i][j] = tmp
        ans = max(ans, dp[i][j])
print(ans)
### BUGGY CODE ###

from heapq import *
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
G=[set() for i in range(N)]
for i in range(M):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    G[u].add(v)
S,T=map(int,input().split())
A=[set() for i in range(N)]
for i in range(N):
    for v in G[i]:
        A[i]=A[i] | G[v]
B=[set() for i in range(N)]
for i in range(N):
    for v in G[i]:
        B[i]=B[i] | A[v]
C=[[] for i in range(N)]
for i in range(N):
    for j in B[i]:
        C[i].append([j,1])
INF=10**9+7
def dijkstra(G,s):

  d=[INF]*N
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,(d[node],node))
  return d
d=dijkstra(C,S-1)
if d[T-1]==INF:
  print(-1)
else:
  print(d[T-1])


### FIXED CODE ###

from heapq import *
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
G=[[] for i in range(3*N)]
for i in range(M):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    G[3*u+0].append([3*v+1,0])
    G[3*u+1].append([3*v+2,0])
    G[3*u+2].append([3*v+0,1])
S,T=map(int,input().split())
INF=10**9+7
def dijkstra(G,s):

  d=[INF]*(3*N)
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,(d[node],node))
  return d
d=dijkstra(G,(S-1)*3)
if d[(T-1)*3]==INF:
  print(-1)
else:
  print(d[(T-1)*3])
### BUGGY CODE ###

# -*- coding utf-8 -*-
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

ids = [1] * N
for i in range(M):
    ids[:LR[i][0]-1] = [0] * len(ids[:LR[i][0]-1])
    ids[(LR[i][1]):] = [0] * len(ids[(LR[i][1]):])

print(sum(ids))


### FIXED CODE ###

# -*- coding utf-8 -*-

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

max_L, min_R = 0, N+1
for i in range(M):
    L, R = map(int, input().split())
    max_L = max(max_L, L)
    min_R = min(min_R, R)

ans = max(min_R - (max_L - 1), 0)

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

import math
K=int(input())
ans=0
for a in range(1,K+1):
	for b in range(1,K+1):
		for c in range(1,K+1):
			ans+=math.gcd(math.gcd(a,b),c)
print(ans)

### FIXED CODE ###

import math
K=int(input())
ans=0
for a in range(1,K+1):
	for b in range(a,K+1):
		for c in range(b,K+1):
			A=math.gcd(math.gcd(a,b),c)
			if a==b and b==c:
				ans+=A
			elif a==b or b==c:
				ans+=(A*3)
			else:
				ans+=(A*6)
print(ans)
### BUGGY CODE ###

import bisect
N = int(input())
L = list(map(int,input().split()))
ans = (N*(N-1)*(N-2))//6
L.sort()
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        ans -= bisect.bisect_right(L[:j],L[i]-L[j])
print(ans)



### FIXED CODE ###

import bisect
N = int(input())
L = list(map(int,input().split()))
ans = (N*(N-1)*(N-2))//6
L.sort()
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        ans -= bisect.bisect_right(L[:j],L[i]-L[j])
print(ans)
### BUGGY CODE ###

S = list(input())
con = 1
max = 0
while con != 0 :
    con = 0
    if (len(S) <= 1):
        break
    for x in range(len(S)-1):
        # print(S[x]+":"+S[x+1])
        if(S[x] == '0' and S[x+1] == '1' or
           S[x] == '1' and S[x+1] == '0' ):
           max += 2
           del S[x:x+1+1]
        #    print(S)
           con = 1
           break
print(max)

### FIXED CODE ###

S = list(input())
R = S.count('0')
B = S.count('1')

if(len(S) <= 1):
    print(0)
else:
    print(len(S) - abs(R-B))
### BUGGY CODE ###

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

a,b=map(int,input().split())
c=gcd(a,b)
ans = 1
div = 2
first_flag=1
while c>1:
    while c%div == 0:
        c /= div
        if first_flag == 1:
            ans += 1
            first_flag = 0 
    div += 1
    first_flag = 1
print(ans)

### FIXED CODE ###

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

a,b=map(int,input().split())
c=gcd(a,b)
ans = 1
div = 2
first_flag=1
while c>1:
    if  div**2 > c:
        ans +=1
        break
    while c%div == 0:
        c /= div
        if first_flag == 1:
            ans += 1
            first_flag = 0 
    div += 1
    first_flag = 1
print(ans)
### BUGGY CODE ###

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

M = M - 1 if M%2==1 else M
mx = 0
for i in range(M//2):
    mx = max(min(N+i, (M-2*i)//2), mx)

print(mx)

### FIXED CODE ###

N, M = map(int, input().split())
print(min(N, M//2)+max(0, (M-2*N)//4))
### BUGGY CODE ###

N = int(input())
S = str(input())
answer = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if S[i] != S[j] and S[j] != S[k] and S[i] != S[k] and k-j != j-i:
                answer += 1
print(answer)

### FIXED CODE ###

N = int(input())
S = str(input())
R = 0
G = 0
B = 0
Z = 0
for i in range(N):
    if S[i] == 'R':
        R += 1
    if S[i] == 'G':
        G += 1
    if S[i] == 'B':
        B += 1

for i in range(N-1):
    for j in range(i+1, N):
        k = 2 * j - i
        if k > N-1:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            Z += 1
print(R*G*B-Z)
### BUGGY CODE ###

def triangles(a): 
    n = len(a) 
    a.sort() 
    count = 0
    for i in range(0,n-2):
        for j in range(i+1,n): 
            k=j+1
            while (k < n and a[i] + a[j] > a[k]): 
                k += 1
            if(k>j): 
                count += k - j - 1
    return count
n=int(input())
a=list(map(int,input().split()))
print(triangles(a))


### FIXED CODE ###

def triangles(a): 
    n = len(a) 
    a.sort() 
    count = 0
    for i in range(0,n-2):
        k=i+2
        for j in range(i+1,n): 
            while (k < n and a[i] + a[j] > a[k]): 
                k += 1
            if(k>j): 
                count += k - j - 1
    return count
n=int(input())
a=list(map(int,input().split()))
print(triangles(a))
### BUGGY CODE ###

s=input()
N=len(s)
ans=0
while True:
    if s!=s.replace("10","").replace("01",""):
        s=s.replace("10","").replace("01","")
    else:
        break;
    
    

    
print(N-len(s))

### FIXED CODE ###

s = input()
zero = 0
one = 0
 
for i in range(len(s)):
    if s[i]=="0":
        zero += 1
    else:
        one += 1
else:
    ans = min(zero,one)*2
 
print(ans)
### BUGGY CODE ###

x = int(input())
import math
a = -(-360//x)
b = math.gcd(a-(360%a),360)
tem = b
info = []
while True:
    tem = math.gcd(tem-(360%tem),360)
    info.append(tem)
    if tem == 0:
        break
ans = a*(360//b)
for i in info:
    ans *= i

print(ans)

### FIXED CODE ###

x = int(input())
b = 1
while (360*b%x) != 0:
    b += 1

print(360*b//x)
### BUGGY CODE ###

n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
ab = []
l = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        l.append(b)

for i in range(m):
    if ab[i][1] == n and ab[i][0] in l:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


### FIXED CODE ###

n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
to = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)
# print(to)
for i in range(len(to[0])):
    if n-1 in to[to[0][i]]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
### BUGGY CODE ###

N=int(input())
A=list(input().split())
cnt=[]

for i in range(N+1):
    i=str(i)
    k=A.count(i)
    cnt.append(k)

for i in range(N+1):
    if  i==0:
        continue
    print(cnt[i])

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
cnt=[0]*N

for i in range(N-1):
    cnt[A[i]-1]+=1

for k in range(N):
    print(cnt[k])
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

NOW=[0]*(K+1)
NOW[0]=1#そこまでi個使ったときの場合の数


for a in A:
    NEXT=[0]*(K+1)
    NOWSUM=[0]
    for n in NOW:
        NOWSUM.append(NOWSUM[-1]+n)
        
    for j in range(K+1):
        NEXT[j]=(NOWSUM[j+1]-NOWSUM[max(0,j-a)])%mod

    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K])


### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

NOW=[0]*(K+1)
NOW[0]=1#そこまでi個使ったときの場合の数


for i in range(N):
    NEXT=[0]*(K+1)
    NOWSUM=[0]
    for n in NOW:
        NOWSUM.append(NOWSUM[-1]+n)
        
    for j in range(K+1):
        NEXT[j]=(NEXT[j]+NOWSUM[j+1]-NOWSUM[max(0,j-A[i])])%mod

    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K])
### BUGGY CODE ###



def p(k,w,maxP):
    count = 1
    tmpList = []
    mP = 0
    for x in w:
        if sum(tmpList)+x <= maxP:
            tmpList.append(x)
            mP = max(sum(tmpList),mP)
        else:
            count += 1
            tmpList = []
            tmpList.append(x)
            mP = max(sum(tmpList),mP)
    
    if count > k :
        result = False
    else:
        result = True

    return result, count, mP

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


w = []

for _ in range(n):
    w.append((int)(input()))
rangeMax = 10000*100000
rangeMin = 1

while _:
    rangeMid = (rangeMax + rangeMin)//2
    '''print(p(k,w,rangeMid))
    print(p(k,w,rangeMid+1))
    print("---")
    '''
    if p(k,w,rangeMid)[0] == False and p(k,w,rangeMid+1)[0] == False:
        rangeMin = rangeMid
    elif p(k,w,rangeMid)[0] == True and p(k,w,rangeMid+1)[0] == True:
        rangeMax = rangeMid
    else:
        break

print(p(k,w,rangeMid+1)[2])

### FIXED CODE ###



def p(k,w,maxP):
    count = 1
    tmpWeight = 0
    for x in w:
        if tmpWeight+x <= maxP:
            tmpWeight += x
        else:
            count += 1
            if count > k :
                return False
            tmpWeight = x
    

    return True




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


w = []

for _ in range(n):
    w.append((int)(input()))
rangeMax = sum(w)
rangeMin = max(w)
rangeMid = 0
while rangeMin < rangeMax:
    rangeMid = (rangeMax + rangeMin)//2
    '''print(p(k,w,rangeMid))
    print(p(k,w,rangeMid+1))
    print("---")
    '''
    if p(k,w,rangeMid) == True:
        rangeMax = rangeMid
    else:
        rangeMid += 1
        rangeMin = rangeMid

print(rangeMid)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
p = list(map(int, input().split()))
cnt = 0
for num, i in enumerate(p):
    flag = 1
    for j in p[:num]:
        if j < i:
            flag = 0
            break
    if flag:
        cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
 
l = p[0]
ans = 0
for i in p:
    if i <= l:
        ans += 1
        l = i
print(ans)
### BUGGY CODE ###

# coding;utf-8

n=int(input())
ans_list=[]
for i in range(0, n):
    a=input()
    if a in ans_list:
        ans_list.remove(a)
    else:
        ans_list.append(a)
print(len(ans_list))


### FIXED CODE ###

# coding;utf-8

n=int(input())
ans_dict={}
for i in range(0, n):
    a=input()
    if not a in ans_dict:
        ans_dict[a]=1
    else:
        ans_dict[a]+=1
sum=0
for thing in ans_dict:
    if ans_dict[thing]%2:
        sum+=1
print(sum)
### BUGGY CODE ###

def main():
    s, t = input(), input()
    dp = ['' for _ in range(len(t) + 1)]
    for i, si in enumerate(s, 1):
        u = ''
        for j, ti in enumerate(t, 1):
            d = u
            l = dp[j - 1]
            u = dp[j]
            if si == ti:
                dp[j] = d + si
            else:
                if len(l) > len(u):
                    dp[j] = l
    print(dp[-1])


main()


### FIXED CODE ###

def main():
    s = input()
    t = input()
    v = [0] * (len(t) + 1)
    dp = [v]
    for i, si in enumerate(s, 1):
        u, v = v, v.copy()
        dp.append(v)
        ll, ul = 0, 0
        for j, ti in enumerate(t, 1):
            uu = u[j]
            if si == ti:
                v[j] = ll = ul + 1
            else:
                if ll > uu:
                    v[j] = ll
                else:
                    ll = uu
            ul = uu
    k = dp[i][j]
    r = ''
    while k:
        if dp[i - 1][j] == k:
            i -= 1
        elif dp[i][j - 1] == k:
            j -= 1
        else:
            k -= 1
            i -= 1
            j -= 1
            r += s[i]
    print(r[::-1])

main()
### BUGGY CODE ###

n, m = map(int, input().split())
ship_list = []
first = []
second = []
for i in range(m):
    a = list(map(int, input().split()))
    ship_list.append(a)

for i in range(m):
    if ship_list[i][0] == 1:
        first.append(ship_list[i][1])
    if ship_list[i][1] == n:
        second.append(ship_list[i][0])

for i in first:
    if i in second:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

### FIXED CODE ###

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

first = []
second = []
for i in range(m):
    a = list(map(int, input().split()))
    if a[0] == 1:
        first.append(a[1])
    if a[1] == n:
        second.append(a[0])


if len(set(first) & set(second)) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

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

for i in range(N):
    A[i] = [A[i],i]
    #A[i][0]:number,A[i][1]:index

A.sort(reverse = True)

sum = A[0][0]
index = [A[0][1]]
cnt = 1

for i in range(1,N):
    if A[i][1]+1 not in index and A[i][1]-1 not in index:
        sum += A[i][0]
        index.append(A[i][1])
        if len(index) == N//2:
            break

print(sum)


### FIXED CODE ###

from collections import defaultdict

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

DP = defaultdict(lambda: -10**18)

DP[(0,0)] = A[0]

for i in range(1,N):
    for j in range((i+1)//2-1,(i+2)//2):
        if j == 0:
            DP[(i,0)] = max(DP[(i-1,0)],A[i])
        else:
            DP[(i,j)] = max(DP[(i-1,j)],DP[(i-2,j-1)]+A[i])

print(DP[(N-1,N//2-1)])
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(h[0]-h[1])
    else:
        costs = []
        for j in range(1, k+1):
            if j > i:
                break
            if abs(h[i-j]-h[i]) == 0:
                costs.append(dp[i-j])
                break
            costs.append(dp[i-j] + abs(h[i-j]-h[i]))

        # if i == 3:
        #     print(costs)
        dp[i] = min(costs)

#print(dp)
print(dp[n-1])



### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(h[0]-h[1])
    else:
        costs = []
        for j in range(1, k+1):
            if j > i:
                break
            if abs(h[i-j]-h[i]) == 0:
                costs.append(dp[i-j])
                break
            costs.append(dp[i-j] + abs(h[i-j]-h[i]))

        # if i == 3:
        #     print(costs)
        dp[i] = min(costs)

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

from math import ceil, log2

def max2(x, y): return x if x >= y else y

def getNums(As, N):
    dp = list(range(16))
    nums = [0] * N
    for i in reversed(range(N - 1)):
        dx = ceil( log2( As[i] / As[i+1] ) / 2 )
        dp2 = [0] * 16
        for x in range(16):
            nx = x + dx
            if nx <= 15:
                dp2[x] = dp[max2(0, nx)] + x
            else:
                dp2[x] = dp[15] + x + (N - 1 - i) * (nx - 15)
        dp = dp2
        nums[i] = dp[0]
    return nums

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

numPstvs = getNums(As, N)
numNgtvs = getNums(As[::-1], N)[::-1]

ans = float('inf')
for i, (p, m) in enumerate(zip(numPstvs + [0], [0] + numNgtvs)):
    ans = min(ans, 2 * p + 2 * m + i)
print(ans)


### FIXED CODE ###

from math import floor, ceil, log2

def getNums(As, N):
    nums = [0] * N
    accNum = 0
    stack = [(N-1, float('inf'))]
    dNow = 0
    for i in reversed(range(N - 1)):
        if As[i] <= As[i+1]:
            dd = floor( log2( As[i+1] / As[i] ) / 2 )
            if dd > 0: stack.append((i, dNow))
            dNow -= dd
        else:
            dTgt = dNow + ceil( log2( As[i] / As[i+1] ) / 2 )
            while dNow < dTgt:
                pos, d = stack[-1]
                if dTgt > d:
                    accNum += (d - dNow) * (pos - i)
                    dNow = d
                    stack.pop()
                else:
                    accNum += (dTgt - dNow) * (pos - i)
                    if dTgt == d: stack.pop()
                    dNow = dTgt
                    break
        nums[i] = accNum
    return nums

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

numPstvs = getNums(As, N)
numNgtvs = getNums(As[::-1], N)[::-1]

ans = float('inf')
for i, (p, m) in enumerate(zip(numPstvs + [0], [0] + numNgtvs)):
    ans = min(ans, 2 * p + 2 * m + i)
print(ans)
### BUGGY CODE ###

H,W=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
l_count=[[0]*W for i in range(H)]
from collections import deque
def answer(st_X,st_Y):#X,Y座標を指定してそこからの距離を考える
   tmp_X,tmp_Y=st_X,st_Y
   que=deque([[tmp_X,tmp_Y]])
   after=[]
   while que:#スタート地点からの距離を数えながら行ったことのない場所を探索する
      tmp_X,tmp_Y=que.popleft()
      nu=l_count[tmp_Y][tmp_X]
      after.append([tmp_X,tmp_Y])
      if tmp_X>0 and l[tmp_Y][tmp_X-1]=="." and [tmp_X-1,tmp_Y] not in after:
         l_count[tmp_Y][tmp_X-1]=nu+1
         que.append([tmp_X-1,tmp_Y])
      if tmp_Y>0 and l[tmp_Y-1][tmp_X]=="." and [tmp_X,tmp_Y-1] not in after:
         l_count[tmp_Y-1][tmp_X]=nu+1
         que.append([tmp_X,tmp_Y-1])
      if tmp_X<W-1 and l[tmp_Y][tmp_X+1]=="." and [tmp_X+1,tmp_Y] not in after:
         l_count[tmp_Y][tmp_X+1]=nu+1
         que.append([tmp_X+1,tmp_Y])
      if tmp_Y<H-1 and l[tmp_Y+1][tmp_X]=="." and [tmp_X,tmp_Y+1] not in after:
         l_count[tmp_Y+1][tmp_X]=nu+1
         que.append([tmp_X,tmp_Y+1])
   que=deque(set(que))
ans=0
for i in range(H):
   for j in range(W):
      if l[i][j]==".":
         l_count=[[0]*W for i in range(H)]
         answer(j,i)
         tmp=max(sum(l_count,[]))
         ans=max(ans,tmp)
print(ans)

### FIXED CODE ###

H,W=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
l_count=[[0]*W for i in range(H)]
from collections import deque
def answer(st_X,st_Y):#X,Y座標を指定してそこからの距離を考える
   tmp_X,tmp_Y=st_X,st_Y
   que=deque([[tmp_X,tmp_Y]])
   after=set()
   while que:#スタート地点からの距離を数えながら行ったことのない場所を探索する
      tmp_X,tmp_Y=que.popleft()
      nu=l_count[tmp_Y][tmp_X]
      after.add((tmp_X,tmp_Y))
      if tmp_X>0 and l[tmp_Y][tmp_X-1]=="." and (tmp_X-1,tmp_Y) not in after and [tmp_X-1,tmp_Y] not in que:
         l_count[tmp_Y][tmp_X-1]=nu+1
         que.append([tmp_X-1,tmp_Y])
      if tmp_Y>0 and l[tmp_Y-1][tmp_X]=="." and (tmp_X,tmp_Y-1) not in after and [tmp_X,tmp_Y-1] not in que:
         l_count[tmp_Y-1][tmp_X]=nu+1
         que.append([tmp_X,tmp_Y-1])
      if tmp_X<W-1 and l[tmp_Y][tmp_X+1]=="." and (tmp_X+1,tmp_Y) not in after and [tmp_X+1,tmp_Y] not in que:
         l_count[tmp_Y][tmp_X+1]=nu+1
         que.append([tmp_X+1,tmp_Y])
      if tmp_Y<H-1 and l[tmp_Y+1][tmp_X]=="." and (tmp_X,tmp_Y+1) not in after and [tmp_X,tmp_Y+1] not in que:
         l_count[tmp_Y+1][tmp_X]=nu+1
         que.append([tmp_X,tmp_Y+1])
ans=0
for i in range(H):
   for j in range(W):
      if l[i][j]==".":
         l_count=[[0]*W for i in range(H)]
         answer(j,i)
         tmp=max(sum(l_count,[]))
         ans=max(ans,tmp)
print(ans)
### BUGGY CODE ###

from sys import stdin

S = input()
Q = int(input())

T_list = []
reverse_flg = False

for q in range(Q):
    T = stdin.readline()[:-1]

    if T == '1':
        if reverse_flg:
            reverse_flg = False
        else:
            reverse_flg = True
    
    else:
        t, f, c = T.split()

        if (f == '1' and reverse_flg == False) or (f == '2' and reverse_flg == True):
            tmp_s = [c, S]
            S = ''.join(tmp_s)
        else:
            tmp_s = [S, c]
            S = ''.join(tmp_s)

if reverse_flg:
    S = S[::-1]

print(S) 


### FIXED CODE ###

from sys import stdin

S = input()
Q = int(input())

reverse_flg = False

former_list = []
latter_list = []

for q in range(Q):
    T = stdin.readline()[:-1]

    if T == '1':
        if reverse_flg:
            reverse_flg = False
        else:
            reverse_flg = True
    
    else:
        t, f, c = T.split()
        if (f == '1' and reverse_flg == False) or (f == '2' and reverse_flg == True):
            former_list.append(c)
        else:
            latter_list.append(c)


if reverse_flg:
    latter_list = ''.join(reversed(latter_list))
    former_list = ''.join(former_list)
    S = ''.join(list(reversed(S)))
    S = ''.join([latter_list, S, former_list])

else:
    former_list = ''.join(reversed(former_list))
    latter_list = ''.join(latter_list)
    S = ''.join([former_list, S, latter_list])

print(S)
### BUGGY CODE ###


n = int(input())
strs = [sorted(list(input())) for _ in range(n)]

cnt = 0
while len(strs) > 1:
  s = strs.pop()
  cnt += strs.count(s)
print(cnt)


### FIXED CODE ###

n = int(input())
strs = ["".join(sorted(str(input()))) for _ in range(n)]

cache = {}
cnt = 0
for s in strs:
  if s in cache.keys():
    cnt = cnt + cache[s]
    cache[s] = cache[s] + 1
  else:
    cache[s] = 1
print(cnt)
### BUGGY CODE ###

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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):
        for l in range(j, k+1):
            if i + j + l == s:
                if i == j == l:
                    ans1 +=1
                elif i == l or i == j or j == l:
                    ans2 += 1
                else:
                    ans3 += 1
                    

print(ans1+ans2*3+ans3*6)

### FIXED CODE ###

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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):    
        if 0 <= s-i-j <= k and j <= s-i-j:
            if i == j == s-i-j:
                ans1 +=1
            elif i == s-i-j or i == j or j == s-i-j:
                ans2 += 1
            else:
                ans3 += 1
                    

print(ans1+ans2*3+ans3*6)
#print(ans1, ans2, ans3)