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

import bisect

a=[]
def asff(b,a,n):
    asum=0
    for j in range(n):
        asum=asum+abs(a[j]-(b+j+1))
    return asum    

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

#n=5
#stra="2 2 3 5 5"
#ans=2

#n=9
#stra="1 2 3 4 5 6 7 8 9"
#ans=0

#n=6
#stra="6 5 4 3 2 1"
#ans=18

#n=7
#stra="1 1 1 1 2 3 4"
#ans=6

#a=list(map(int,stra.split()))

for i in range(n):
    a[i]=a[i]-i-1
#print(a)
a.sort()

s=[a[0]]
for i in range(1,n):
    s.append(s[i-1]+a[i])
    
bmin=min(a)-n
bmax=max(a)+n

  
asmin=bmax*n
m0=0
for b in range(bmin,bmax+1):
    m=bisect.bisect(a,b)
    if m<=0:
        asf=-n*b+s[n-1]
    elif m<n:
        asf=(2*m-n)*b+s[n-1]-2*s[m-1]
    elif n<=m:
        asf=n*b-s[n-1]
        
#    print("b",b,"m",m,"asf",asf)
    if asf<asmin:
        asmin=asf

print(asmin)

### FIXED CODE ###

import bisect

a=[]
s=[]
def asff(a,b,s,n):
    m=bisect.bisect(a,b)
    if m<=0:
        asf=-n*b+s[n-1]
    elif m<n:
        asf=(2*m-n)*b+s[n-1]-2*s[m-1]
    elif n<=m:
        asf=n*b-s[n-1]
    return asf

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

#n=5
#stra="2 2 3 5 5"
#ans=2

#n=9
#stra="1 2 3 4 5 6 7 8 9"
#ans=0

#n=6
#stra="6 5 4 3 2 1"
#ans=18

#n=7
#stra="1 1 1 1 2 3 4"
#ans=6

#a=list(map(int,stra.split()))

for i in range(n):
    a[i]=a[i]-i-1
#print(a)
a.sort()

s=[a[0]]
for i in range(1,n):
    s.append(s[i-1]+a[i])
    
bmin=min(a)-n
bmax=max(a)+n

b1=bmin
b5=bmax+1
b2=b1+int((b5-b1)/4)
b3=b1+int((b5-b1)/2)
b4=b1+int((b5-b1)/4*3)
#b2=b1+(b5-b1)//4
#b3=b1+(b5-b1)//4*2
#b4=b1+(b5-b1)//4*3
#print("b1",b1,"b5",b5)
    
asmin=bmax*n
#m0=0
m1=bisect.bisect(a,bmin)


while b1+1<b5:
    c=[]
    c.append([asff(a,b1,s,n),b1])
    c.append([asff(a,b2,s,n),b2])
    c.append([asff(a,b3,s,n),b3])
    c.append([asff(a,b4,s,n),b4])
    c.append([asff(a,b5,s,n),b5])
    c.sort()
    asf=c[0][0]
    d=[]
    d.append(c[0][1])
    d.append(c[1][1])
    d.append(c[2][1])
    d.sort()
    b1=d[0]
    b5=d[2]
    b2=b1+int((b5-b1)/4)
    b3=b1+int((b5-b1)/2)
    b4=b1+int((b5-b1)/4*3)
    
#    print("b1",b1,"b5",b5,"d0",d[0],"asf",asf)
    if asf<asmin:
        asmin=asf

print(asmin)
### BUGGY CODE ###

import collections

n=int(input())
a=[]
for i in range(n):
  s=list(input())
  s.sort()
  t="".join(s)
  a.append(t)
c=collections.Counter(a)
l=len(c)
ans=0
for i in range(l):
  m=c.most_common()[i][1]
  ans += int(m*(m-1)/2)
print(ans)

### FIXED CODE ###

n=int(input())
dic={}
ans=0
for i in range(n):
  s="".join(sorted(input()))
  if s in dic.keys():
    ans+=dic[s]
    dic[s]+=1
  else:
    dic[s]=1
print(ans)
### BUGGY CODE ###

r,c,k=map(int, input().split())
grid=[[0]*(c+1) for _ in range(r+1)]
for i in range(k):
    ri,ci,vi=map(int, input().split())
    grid[ri][ci]=vi

dp=[[[0]*4 for _ in range(c+1)] for _ in range(r+1)]

for i in range(1,r+1):
    for j in range(1,c+1):
        for k in range(4):
            dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k])
            dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k])
        if grid[i][j]!=0:
            dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][0]+grid[i][j])
            for k in range(1,4):
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+grid[i][j])
                dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+grid[i][j])

print(max(dp[-1][-1]))

### FIXED CODE ###

R,C,K = map(int,input().split())

grid=[[0]*C for _ in range(R)]
for i in range(K):
    x,y,v = map(int,input().split())
    grid[x-1][y-1] = v
dp1 = [[0]*(C+1) for _ in range(R+1)]
dp2 = [[0]*(C+1) for _ in range(R+1)]
dp3 = [[0]*(C+1) for _ in range(R+1)]

for i in range(R):
    for j in range(C):
        dp1[i][j] = max(dp1[i][j-1],dp1[i-1][j]+grid[i][j],
                    dp2[i-1][j]+grid[i][j],dp3[i-1][j]+grid[i][j])
        dp2[i][j] = max(dp2[i][j-1],dp1[i][j-1]+grid[i][j])
        dp3[i][j] = max(dp3[i][j-1],dp2[i][j-1]+grid[i][j])
ans=0
for i in range(R):
    for j in range(C):
        ans=max(ans,dp1[i][j],dp2[i][j],dp3[i][j])
print(ans)
### BUGGY CODE ###

import time as time

s = time.time()

lines =  input().split()
n = int(lines[0])
m = int(lines[1])
#n,m = map(int,input().split())

py = []
od = [[]*1 for i in range(n)]

#print ("create list: " + str(time.time() - s) )

s = time.time()
for i in range(0,m):

    lines =  input().split()
    p = int(lines[0])
    y = int(lines[1])
    py.append([p,y])
       
    odlen = len(od[p-1])
    od[p-1].append(y)
    od[p-1].sort()
    """ if odlen >= 1 :

        low = 0
        high = odlen - 1
        mid = odlen >> 1

        while low <= high:
            mid = (low + high) >> 1
            guess = od[p-1][mid]
            if guess == y:
                break
            if guess > y :
                high = mid - 1
            else:
                low  = mid + 1
        od[p-1].insert(low,y)

    else:
        od[p-1].append(y) """

#print ("sort: " + str(time.time() - s) )
#exit(0)

#s = time.time()
for i in range(0,m):
    py0 = py[i][0]
    r = od[py0-1].index(py[i][1])

    tmp = py0
    digit = 0
    while tmp > 0 :        
        digit += 1
        tmp = tmp // 10
    
    l = 6-digit
    for j in range(l):
        print('0',end="")
    print(py0,end="")

    tmp = r + 1
    digit = 0
    while tmp > 0 :        
        digit += 1
        tmp = r // 10

    l = 6-digit
    for j in range(l):
        print('0',end="")
    print(r+1)

#print ("index: " + str(time.time() - s) )

### FIXED CODE ###

import sys as sys

lines =  input().split()
n = int(lines[0])
m = int(lines[1])

py = []
od = {}

#lines = sys.stdin.readlines()

for i in range(0,m):


    #l =  lines[i].split()
    l = input().split()
    p = int(l[0])
    y = int(l[1])
    
    if p in od :
        od[p].append([i,y])
    else:
        od[p] = [[i,y]]

a = []
for p in od.keys():
    od[p].sort(key=lambda x:x[1])
    r = 1

    for o in od[p]:
        cs = ""

        tmp = p
        digit = 0
        while tmp > 0 :        
            digit += 1
            tmp = tmp // 10
        
        l = 6-digit
        for j in range(l):
            cs += '0'
        cs += str(p)

        tmp = r 
        digit = 0
        while tmp > 0 :        
            digit += 1
            tmp = tmp // 10

        l = 6-digit
        for j in range(l):
            cs += '0'
        cs += str(r)        

        a.append([o[0],cs])
        r += 1

a.sort(key=lambda x:x[0])
for aa in a:
    print(aa[1])
### BUGGY CODE ###

import bisect


N = int(input())
str_l = input()
num = 0
L = []
for v in str_l.split(' '):
    L.append(int(v))

L.sort()
for i in range(N - 1):
    a = L[i]
    for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        for k in range(0, index):
            
            c = (L[j + 2:])[k]
            if b + c > a and a + c > b:
                num += 1

print(num)


### FIXED CODE ###

import bisect


N = int(input())
str_l = input()
num = 0
L = []
for v in str_l.split(' '):
    L.append(int(v))

L.sort()
for i in range(N - 1):
    a = L[i]
    for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        num += index
        # for k in range(0, index):
        #     c = (L[j + 2:])[k]
        #     if b + c > a and a + c > b:
        #         num += 1

print(num)
### BUGGY CODE ###


H,W=map(int, input().split())
d = [ [ 100000 for _ in range(W+2)] for _ in range(H+2)]
S = []
S.append('#' * (W+2))
for i in range(H):
    S.append('#'+ input() + '#')
S.append('#' * (W+2))

def SUB(x,y,n):
    d[y][x] = n
    if (S[y-1][x] == '.') and (d[y-1][x] > n+1): SUB(x,y-1,n+1)
    if (S[y][x-1] == '.') and (d[y][x-1] > n+1): SUB(x-1,y,n+1)
    if (S[y+1][x] == '.') and (d[y+1][x] > n+1): SUB(x,y+1,n+1)
    if (S[y][x+1] == '.') and (d[y][x+1] > n+1): SUB(x+1,y,n+1)

dmax = 0
for y in range(1,H+1):
    for x in range(1,W+1):
        if S[y][x] == '.':
            SUB(x,y,0)
            for iy in range(1,H+1):
                for ix in range(1,W+1):
                    if d[iy][ix] != 100000:
                        if dmax < d[iy][ix]:
                            dmax = d[iy][ix]
                        d[iy][ix] = 100000
print(dmax)


### FIXED CODE ###

from collections import deque

def mk_idx(y,x):
    return y*22+x

H,W=map(int, input().split())
DINF = 100000
S = []
S.append('#' * (W+2))
for i in range(H):
    S.append('#'+ input() + '#')
S.append('#' * (W+2))
dmax = 0
G = [ [] for _ in range( mk_idx(22,22) ) ]
for y in range(1,H+1):
    for x in range(1,W+1):
        if (S[y][x] == '.'):
            if (S[y-1][x] == '.'):  G[ mk_idx(y,x) ].append( mk_idx(y-1,x) )
            if (S[y][x-1] == '.'):  G[ mk_idx(y,x) ].append( mk_idx(y,x-1) )
            if (S[y+1][x] == '.'):  G[ mk_idx(y,x) ].append( mk_idx(y+1,x) )
            if (S[y][x+1] == '.'):  G[ mk_idx(y,x) ].append( mk_idx(y,x+1) )

for y in range(1,H+1):
    for x in range(1,W+1):
        if S[y][x] == '.':
            d = [ DINF for _ in range( mk_idx(22,22) ) ]
            d[ mk_idx(y,x) ] = 0
            q = deque( [mk_idx(y,x)] )
            while len(q) != 0:
                v = q.popleft()
                n = d[v];
                dmax = max(dmax, n)
                for nv in G[v]:
                    if d[ nv ] <= n+1 :
                        continue
                    d[ nv ] = n+1
                    q.append(nv)
print(dmax)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
num = 1
for i in A:
    num *= i
if num > pow(10,18):
        print(-1)
else:
    print(num)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
num = 1
flag = True
if A.count(0)>=1:
    print(0)
else:
    for i in A:
        num *= i
        if num > pow(10,18):
            print(-1)
            flag =False
            break

    if flag:
        print(num)
### BUGGY CODE ###

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

for i in range(len(A)-K+1):
    t = sum(A[i:i+K])
    ans = max(ans,t)

print((ans+K)/2)


### FIXED CODE ###

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

MAX = 0
for i in range(N-K+1):
    if i == 0:
        SUM = 0
        for j in range(K):
            SUM += (A[i+j]+1)/2

    else:
        SUM += (A[i+K-1]+1)/2
        SUM -= (A[i-1]+1)/2
    
    if MAX < SUM:
        MAX = SUM

print(MAX)
### BUGGY CODE ###

from collections import deque

n = int(input())

q = deque()

for _ in range(n):
	com,*num = input().split(" ")
	if com == "insert":
		q.appendleft(num[0])
	elif com == "delete":
		try:
			q.remove(num[0])
		except:
			pass

	elif com == "deleteFirst":
		q.popleft()
	elif com == "deleteLast":
		q.pop()

print(*q)



### FIXED CODE ###

from collections import deque
from sys import stdin

n = int(input())

q = deque()

for _ in range(n):
	cmd = stdin.readline().strip().split()
	if cmd[0] == "insert":
		q.appendleft(cmd[1])
	elif cmd[0] == "deleteFirst":
		q.popleft()
	elif cmd[0] == "deleteLast":
		q.pop()
	elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass

print(*q)
### BUGGY CODE ###

n,m,k=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
cd=[list(map(int,input().split())) for _ in range(k)]
friend=[[]for _ in range(n)]
block=[[]for _ in range(n)]
for a,b in ab:
  friend[a-1].append(b-1)
  friend[b-1].append(a-1)
for c,d in cd:
  block[c-1].append(d-1)
  block[d-1].append(c-1)
# 友達連結内でかつ友達でもブロックでもない。
# 友達連結グループわけ
friend_group=[[] for _ in range(n)]
seen=[0]*n
while 0 in seen:
  member=[]
  t=seen.index(0)
  todo=[t]
  seen[t]=1
  while todo:
    t=todo.pop()
    member.append(t)
    f=friend[t]
    for fi in f:
      if seen[fi]==0:
        todo.append(fi)
        seen[fi]=1
  mn=len(member)
  for m in member:
    friend_group[m]=len([mi for mi in member if mi!=m and mi not in friend[m]+block[m]])
print(' '.join(map(str,friend_group)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
  n,m,k=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in range(m)]
  cd=[list(map(int,input().split())) for _ in range(k)]
  gf=[[]for _ in range(n)]
  for a,b in ab:
    gf[a-1].append(b-1)
    gf[b-1].append(a-1)
  gb=[[]for _ in range(n)]
  for c,d in cd:
    gb[c-1].append(d-1)
    gb[d-1].append(c-1)
  seen=[0]*n
  ans=[0]*n
  for i in range(n):
    c=set([i])
    if seen[i]==0:
      todo=[i]
      while todo:
        e=todo.pop()
        l=gf[e]
        for li in l:
          if seen[li]==0:
            todo.append(li)
            seen[li]=1
            c.add(li)
      base=len(c)-1
      for ci in c:
        ans[ci]=base
        for fb in gb[ci]+gf[ci]:
          if fb in c:
            ans[ci]-=1
  print(' '.join(map(str,ans)))
if __name__=='__main__':
  main()
### BUGGY CODE ###

import re
class c(int):
    global p
    def __add__(self,n):
        return c((int(self)+int(n))%p)
    def __sub__(self,n):
        return c((int(self)-int(n))%p)
    def __mul__(self,n):
        return c((int(self)*int(n))%p)
    def __truediv__(self,n):
        if n==0:raise ZeroDivisionError
        return self*(int(n)**(p-2))%p
  
while 1:
    p,f=input().replace(' ','').split(':')
    p=int(p)
    if p==0:break
    try:print('%s = %s (mod %s)'%(f,eval(re.sub(r'(\d+)',r'c(\1)',f)),p))
    except:
        print('NG')

### FIXED CODE ###

import re
class c(int):
    global p
    def __add__(self,n):
        return c((int(self)+int(n))%p)
    def __sub__(self,n):
        return c((int(self)-int(n))%p)
    def __mul__(self,n):
        return c((int(self)*int(n))%p)
    def __truediv__(self,n):
        if n==0:raise ZeroDivisionError
        return self*pow(int(n),p-2,p)
  
while 1:
    p,f=input().replace(' ','').split(':')
    p=int(p)
    if p==0:break
    try:print('%s = %s (mod %s)'%(f,eval(re.sub(r'(\d+)',r'c(\1)',f)),p))
    except:print('NG')
### BUGGY CODE ###

import sys

def create_dict(N):
    d = {}
    key2rep = {}
    for i in range(N):
        d[i+1] = set([i+1])
        key2rep[i+1] = i+1
    return d, key2rep

def key2rep_iter(x, key2rep):
    if key2rep[x] != x:
        return key2rep_iter(key2rep[x], key2rep)
    return key2rep[x]

def add_x2y(x, y, d, key2rep):
    rep = key2rep_iter(y, key2rep)
    big_rep = key2rep_iter(x, key2rep)
    if rep == big_rep:
        return
    d[rep] = d[rep] | d[big_rep]
    key2rep[big_rep] = rep
    d[big_rep] = set()
#    print(d)

N, M = map(int,input().split(' '))
d, key2rep = create_dict(N)
p_list = list(map(int,input().split(' ')))

for line in sys.stdin:
    x,y = map(int, line.strip().split(' '))
    add_x2y(max(x,y), min(x,y), d, key2rep)

score = 0
for i in d:
    for x in d[i]:
        if p_list[x-1] in d[i]:
            score += 1
print(score)


### FIXED CODE ###

import sys

def key2rep_iter(key, key2rep, temp_list):
    if key2rep[key] == key:
        for i in temp_list:
            key2rep[i] = key2rep[key]
        return key
    temp_list.append(key)
    return key2rep_iter(key2rep[key], key2rep, temp_list)

def add_x2y(x, y, key2rep):
    rep = key2rep_iter(y, key2rep, [])
    big_rep = key2rep_iter(x, key2rep, [])
    if rep == big_rep:
        return
    key2rep[big_rep] = rep

N, M = map(int,input().split(' '))
p_list = [int(i) for i in input().split(' ')]
key2rep = {i+1:i+1 for i in range(N)}

for line in sys.stdin:
    x,y = map(int, line.strip().split(' '))
    add_x2y(max(x,y), min(x,y), key2rep)

print(len([1 for i in range(N) if key2rep_iter(p_list[i], key2rep, []) == key2rep_iter(i+1, key2rep, [])]))
### BUGGY CODE ###

L,A,B,mod=map(int,input().split())

def keta(k):# k-桁の数の初項、末項、項数を求める
    if A>=10**k:
        return 0,0,0
    begin=10**(k-1)
    end=10**k

    if begin>A+B*(L-1):
        return 0,0,0

    sh=A+max(-1,(begin-1-A)//B)*B+B
    ma=min(A+max(0,(end-1-A)//B)*B,A+B*(L-1))
    kou=(ma-sh)//B+1
    
    return sh,ma,kou

def f(n,r): # 1+r+...+r**(n-1)
    if n==1:
        return 1
    if n%2==0:
        return (f(n//2,r) + pow(r,n//2,mod)*f(n//2,r))%mod
    return (r*f(n-1,r)+1)%mod

def g(n,r): # 0+r+2*r**2+...+(n-1)*r**(n-1)
    if n==1:
        return 0
    if n%2==0:
        return g(n//2,r)+pow(r,n//2,mod)*(g(n//2,r)+n//2*f(n//2,r))
    return r*g(n-1,r)+r*f(n-1,r)

keta_count=1
ANS=0
for i in range(18,0,-1):
    sh,ma,kou = keta(i)
    
    if kou<=0:
        continue
    

    #print(i,sh,ma,kou)

    ANS=(keta_count*(ma*f(kou,10**i)-B*g(kou,10**i))+ANS)%mod
    #print(ANS)
    keta_count = keta_count * pow(10,kou * i,mod)

print(ANS)
    
    


### FIXED CODE ###

L,A,B,mod=map(int,input().split())

def keta(k):# k-桁の数の初項、末項、項数を求める
    if A>=10**k:
        return 0,0,0
    begin=10**(k-1)
    end=10**k

    if begin>A+B*(L-1):
        return 0,0,0

    sh=A+max(-1,(begin-1-A)//B)*B+B
    ma=min(A+max(0,(end-1-A)//B)*B,A+B*(L-1))
    kou=(ma-sh)//B+1
    
    return sh,ma,kou

from functools import lru_cache

@lru_cache(maxsize=None)
def f(n,r): # 1+r+...+r**(n-1)
    if n==1:
        return 1
    if n%2==0:
        return (f(n//2,r) + pow(r,n//2,mod)*f(n//2,r))%mod
    return (r*f(n-1,r)+1)%mod

@lru_cache(maxsize=None)
def g(n,r): # 0+r+2*r**2+...+(n-1)*r**(n-1)
    if n==1:
        return 0
    if n%2==0:
        return g(n//2,r)+pow(r,n//2,mod)*(g(n//2,r)+n//2*f(n//2,r))
    return r*g(n-1,r)+r*f(n-1,r)

keta_count=1
ANS=0
for i in range(18,0,-1):
    sh,ma,kou = keta(i)
    
    if kou<=0:
        continue
    

    #print(i,sh,ma,kou)

    ANS=(keta_count*(ma*f(kou,10**i)-B*g(kou,10**i))+ANS)%mod
    #print(ANS)
    keta_count = keta_count * pow(10,kou * i,mod)

print(ANS)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
i = 0
cnt = 1
while a[i]!=2:    
    if i == a[a[i]-1]-1:
        print(-1)
        exit()
    i=a[i]-1
    cnt += 1
else:
    print(cnt)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0
tmp = 0
for i in range(n):
    if a[tmp]==2:
        print(cnt+1)
        exit()
    else:
        tmp =a[tmp]-1
        cnt += 1
else:
    print(-1)
    exit()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
E=[]
for i in range(1,N+1):
  for j in range(N):
    if A[j]==i:
      E.append(j+1)
      break

for i in range(N):
  print(E[i],end=" ")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
  b[a[i]-1]+=i+1
c=[str(i) for i in b]
print(" ".join(c))
### BUGGY CODE ###

import math

n = int(input())
s = list(input())
mod = 10**9+7

cnt_w = 0
cnt_ans = 1

for i in range(0,n*2):
    if i%2 == 0:
        if s[i] == "B":
            s[i] = "W"
        else:
            s[i] = "B"
    if s[i] == "W":
        cnt_w += 1
        continue
    if s[i] == "B":
        cnt_ans *= cnt_w
        cnt_w -= 1

if s.count("B") != s.count("W"):
    print(0)
    exit()
    
print((cnt_ans*math.factorial(n))%mod)


### FIXED CODE ###

MOD = 10**9 + 7

N = int(input())
S = input().rstrip()

is_left = [(i%2 == 0) ^ (x == "W") for i, x in enumerate(S)]

answer = 1
left = 0
for bl in is_left:
    if bl:
        left += 1
    else:
        answer *= left
        left -= 1
        answer %= MOD

if left != 0:
    answer = 0
    
for i in range(1, N+1):
    answer *= i
    answer %= MOD

print(answer)
### BUGGY CODE ###

#B - Sum of Three Integers
K,S = map(int,input().split())
#0<=S<=3K
res = 0
for X in range(0,min((K+1,S+1))):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif (0<=S-X-Y) and ((S-X-Y) <= K):
            res += 1
print(res)

### FIXED CODE ###

K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))
### BUGGY CODE ###

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

N,M = map(int,readline().split())
A = [0]+list(map(int,readline().split()))
B = list(map(int,read().split()))

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

ticket_sum = [0]*(N*N)

for n in range(M):
    arr = B[n::M]
    # 安いチケットから入れていく -> 連結成分上で採用される
    left = list(range(1,N))+[0,0]
    right = list(range(-1,N))
    for i in sorted(range(N), key=arr.__getitem__):
        l = left[i-1]
        r = right[i+1]
        left[r] = l; right[l] = r
        # [l,i] x [i,r] に arr[i] を加える
        x = arr[i]
        ticket_sum[l*N+i]+=x
        if i<N-1:
            ticket_sum[(i+1)*N+i]-=x
        if r<N-1:
            ticket_sum[l*N+r+1]-=x
        if i<N-1 and r<N-1:
            ticket_sum[(i+1)*N+r+1]+=x

del B

# 2d累積和
for i in range(N,N*N):
    ticket_sum[i] += ticket_sum[i-N]
for i in range(N*N):
    if i%N:
        ticket_sum[i] += ticket_sum[i-1]

answer = 0
for i in range(N):
    x = A[i]
    for y,t in zip(A[i:],ticket_sum[N*i+i:N*i+N]):
        happy = x-y+t
        if answer < happy:
            answer = happy

print(answer)

### FIXED CODE ###

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

import itertools

INF=10**10

N,M = map(int,readline().split())
A = [0,0]+list(map(int,readline().split()))
B = [[INF]*M]+[list(map(int,line.split())) for line in readlines()]

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

answer = 0
INF = 10**12
diff = [INF]+[0]*N
left = [list(range(-1,N)) for m in range(M)]
arr = [INF,2,1,2]
for i in range(1,N+1):
    for m in range(M):
        p=i; prev_val=0
        q=left[m][p]
        x = B[i][m]
        while prev_val<=x:
            diff[p] += x-prev_val
            diff[q] -= x-prev_val
            p=q; q=left[m][p]
            prev_val=B[p][m]
        left[m][i]=p
    # 出発地点ごとの収入
    ticket_sum = list(itertools.accumulate(diff[::-1]))[::-1]
    for start in range(1,i+1):
        happy = ticket_sum[start] + A[start]-A[i]
        if answer < happy:
            answer = happy

print(answer)
### BUGGY CODE ###

n,q=map(int, input().split())
s=input()
ans=[]
for i in range(q):
    a,b=map(int, input().split())
    ans.append((s[a-1:b].count("AC")))

for i in ans:
    print(i)


### FIXED CODE ###

n,q=map(int, input().split())
s=input()
sn=""
ans=[0]*(n+1)

for i in range(n):
    if s[i:i+2]=="AC":
        ans[i+1]=ans[i]+1
    else:
        ans[i+1]=ans[i]

for i in range(q):
    a,b=map(int, input().split())
    print(ans[b-1]-ans[a-1])
### BUGGY CODE ###

h, n = map(int, input().strip().split())
AB = [list(map(int, input().split())) for i in range(n)]

dp=[10**9]*(h+1)

dp[0]=0
for ab in AB:
    a=ab[0]
    b=ab[1]
    for i in range(h):
        ni=min(i+a,h)
        dp[ni] = min(dp[ni],dp[i]+b)
        
print(dp[h])

### FIXED CODE ###

h, n = map(int, input().strip().split())
# AB = [list(map(int, input().split())) for i in range(n)]

dp=[10**9]*(h+1)

dp[0]=0
for _ in range(n):
    a, b = map(int, input().strip().split())
    for i in range(h):
        ni=min(i+a,h)
        dp[ni] = min(dp[ni],dp[i]+b)
        
print(dp[h])
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

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

l = [[0 for i in range(n)] for i in range(n)]

a = np.array(l)

for i in range(m):
    l[ab[i][0 ]-1][ab[i][1]-1] = 1
    l[ab[i][1]-1][ab[i][0]-1] = 1

a = np.array(l)
d, p = shortest_path(a, return_predecessors=True, indices=0)

if float('inf') in d:
    print('No')
    

else:
    print('Yes')

for i in p[1:]:
    print(i+1)


### FIXED CODE ###

from collections import deque

n, m = map(int,input().split())
graph = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
    
ans = [0]*(n+1)
seen = [False]*(n+1)

que = deque()
que.append(1)

while len(que) != 0:
    k = que.popleft()
    seen[k] = True
    
    for i in graph[k]:
        if seen[i]:
            continue
        ans[i] = k
        que.append(i)
        seen[i] = True

ans = ans[2:]

for i in ans:
    if i == 0:
        print('No')
        exit()

print('Yes')

for i in ans:
    print(i)