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

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

### FIXED CODE ###

n, m = map(int, input().split())
ans = 0
for x in range(n + 1):
    for y in range(n + 1):
        if m - x - y <= n and m - x - y >= 0:
            ans += 1
print(ans)
### BUGGY CODE ###

n,k,q=(int(x) for x in input().split())
a=[]
p=[]
for i in range(0,q):
    temp=int(input())
    a.append(temp)
for j in range(0,n):
    p.append(a.count(j+1))
for m in range(0,n):
    c=k+(-1)*q+p[m]
    #print('No %d point is %d'% (m,c))
    if c >0:
        print('Yes')
    else:
        print('No')
#print(p)


### FIXED CODE ###

n,k,q=(int(x) for x in input().split())
a=[]
p=[0]*n
for i in range(0,q):
    temp=int(input())
    p[temp-1]+=1
border=-k+q

res = '\n'.join('Yes' if p[j]> border else 'No' for j in range(0,n))

print(res)
### BUGGY CODE ###

N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
    
dp=[[0 for _ in range(N+1) ] for _ in range(W+1)]

for i in range(1,N+1):    #i番目の荷物
    for j in range(1,W+1):   #上限の重さ
        if j>=w[i-1]:
            dp[j][i]=max(dp[j-w[i-1]][i-1]+v[i-1],dp[j][i-1])
        else:
            dp[j][i]=dp[j][i-1]
            
print(dp[-1][-1])

### FIXED CODE ###

N,W=map(int,input().split())
w=[0]*(N+1)
v=[0]*(N+1)
for i in range(N):
    w[i],v[i] = map(int,input().split())
maxi=sum(v)
    
dp=[[float("inf") for _ in range(N+1)] for _ in range(maxi+1)]
for _ in range(N+1):
    dp[0][_]=0
    
last=0
for i in range(1,N+1):
    for j in range(1,maxi+1):
        if j<v[i-1]:
            dp[j][i]=min(w[i-1], dp[j][i-1])
        else:
            tmp=w[i-1]+dp[j-v[i-1]][i-1]
            if tmp<=W:
                dp[j][i]=min(tmp, dp[j][i-1])
            else:
                dp[j][i]=dp[j][i-1]

#print(dp)
for j in range(maxi,-1,-1):
    if dp[j][-1]!=float("inf"):
        k=j
        break

ans=0
for i in range(N,0,-1):
    if dp[k][i]==dp[k-v[i-1]][i-1]+w[i-1]:
        k = k-v[i-1]
        ans += v[i-1]
print(ans)
### BUGGY CODE ###

from collections import deque
def bfs(A,H,W):
    que = deque([])
    cnt = 0
    for i in range(H):
        for j,a in enumerate(A[i]):
            if a == '#':
                que.append((i,j))

    d = [-1,1]
    tmp = deque([])
    flag = 0
    while que:
        u = que.popleft()
        y,x = u
        for k in range(2):
            s = y + d[k]
            t = x + d[k]
            if 0 <= s < H:
                if A[s][x] == '.':
                    A[s][x] = '#'
                    tmp.append((s,x))
                    flag = 1
            if 0 <= t < W:
                if A[y][t] == '.':
                    A[y][t] = '#'
                    tmp.append((y,t))
                    flag = 1
            
        if not que:
            que = tmp 
            tmp = deque([])
            if flag:
                cnt += 1
            flag = 0

    return cnt

def main():
    H,W = map(int,input().split(" "))
    A = [[s for s in input()] for _ in range(H)]
    ans = bfs(A,H,W)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def bfs(A,H,W,D):
    que = deque(D)
    cnt = 0
    d = [-1,1]
    tmp = set()
    flag = 0
    while que:
        u = que.popleft()
        
        y,x = u
        for k in range(2):
            s = y + d[k]
            t = x + d[k]
            if 0 <= s < H:
                if A[s][x] == '.':
                    A[s][x] = '#'
                    tmp.add((s,x))
                    flag = 1
              
            if 0 <= t < W:
                if A[y][t] == '.':
                    A[y][t] = '#'
                    tmp.add((y,t))
                    flag = 1

            
        if not que:
            que = deque(tmp) 
            tmp = set()
            if flag:
                cnt += 1
            flag = 0
    return cnt

def main():
    H,W = map(int,input().split(" "))
    A = []
    D = []
    D_append = D.append
    for i in range(H):
        tmp = []
        for j,s in enumerate(input()):
            tmp.append(s)
            if s == '#':
                D_append((i,j))
        A.append(tmp)

    ans = bfs(A,H,W,D)
    print(ans)


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

N=int(input())
mylist=list(map(int,input().split()))
    
#print(mylist)
answer=0

for i in range(N):
    flag=0
    
    for j in range(i):
        if mylist[i]>mylist[j]:
            #一つでも条件満たさないjがあればflagを-1にする
            flag=-1
    
    if flag==0:
        #flagが0であれば、そのiに対して答えを+1する
        answer+=1
        
print(answer)

### FIXED CODE ###

N=int(input())
lt=list(map(int,input().split()))
#print(lt)

temp=0
answer=0

for i in range(N):
    if i==0:
        answer+=1
        temp=lt[i]
    elif temp>=lt[i]:
        answer+=1
        temp=lt[i]
        
print(answer)
### BUGGY CODE ###

def scheduler(N, A):
    days = 0
    while len([a for a in A if len(a)]):
        days += 1
        game = [0 for i in range(N)]
        for i in range(N):
            if len(A[i]):
                oppo = A[i][0] -1
                if A[oppo][0] - 1 == i:
                    game[i] = 1
        no_game = True
        for i in range(N):
            if game[i] == 1:
                del A[i][0]
                no_game = False
        if no_game:
            return(-1)
    return(days)


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

print(scheduler(N, A))

### FIXED CODE ###

def list_up_next_games(players):
    games = set()
    for p in players:
        if A[p]:
            opponent = A[p][-1] - 1
            if A[opponent][-1] - 1 == p:
                if p < opponent:
                    games.add((p, opponent))
                else:
                    games.add((opponent, p))
    return(games)

N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
for i in range(N):
    A[i].reverse()

games = list_up_next_games(list(range(N)))

done_games = []
days = 0
while games:
    days += 1
    players = []
    for game in games:
        done_games.append(game)
        A[game[0]].pop()
        A[game[1]].pop()
        players.append(game[0])
        players.append(game[1])
    games = list_up_next_games(players)

if len(done_games) == N*(N-1)//2:
    print(days)
else:
    print(-1)
### BUGGY CODE ###

N,M = map(int,input().split())
H = list(map(int,input().split()))
Good = list()
Bad = list()

for i in range(M):
  A,B = map(int,input().split())
  A -= 1
  B -= 1
  if H[A] > H[B]:
    Bad.append(B)
  elif H[A] < H[B]:
    Bad.append(A)
  else:
    Bad.append(A)
    Bad.append(B)
  Bad = list(set(Bad))
print(N-len(Bad))

### FIXED CODE ###

N,M = map(int,input().split())
H = list(map(int,input().split()))
Bad = dict()

for i in range(M):
  A,B = map(int,input().split())
  A -= 1
  B -= 1
  if H[A] > H[B]:
    Bad[B] = 1
  elif H[A] < H[B]:
    Bad[A] = 1
  else:
    Bad[A] = 1
    Bad[B] = 1
print(N-len(Bad))
### BUGGY CODE ###

s = list(input())
q = int(input())

ans = s
for i in range(q):
    qret = list(input().split())
    if qret[0] == "1":
        ans.reverse()
    else:
        f = qret[1]
        c = qret[2]
        if f == "1":
            ans.insert(0, c)
        else:
            ans.append(c)

print(''.join(ans))


### FIXED CODE ###

s = input()
q = int(input())

tcount = 0
rlist = ""
llist = ""

for i in range(q):
    qret = input()
    if qret[0] == "1":
        tcount += 1
        # ans = ans[::-1]
    else:
        f = qret[2]
        c = qret[4]
        if f == "1":
            if tcount % 2 == 0:
                llist = c + llist
            else:
                rlist += c
        else:
            if tcount % 2 == 0:
                rlist += c
            else:
                llist = c + llist

if tcount % 2 == 0:
    print(llist + s + rlist)
else:
    print(rlist[::-1] + s[::-1] + llist[::-1])
### BUGGY CODE ###

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

x=0
y=[]
z=l[0]
for i in range(n):
    y=y+[l[i]]
    z=min(z,l[i])
    if l[i]<=z:
        x+=1
print(x)

### FIXED CODE ###

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

x=0
y=[]
z=l[0]
for i in range(n):
    #y=y+[l[i]]
    z=min(z,l[i])
    if l[i]<=z:
        x+=1
print(x)
### BUGGY CODE ###

import numpy as np

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

res = np.zeros(N)
for i in range(N):
  res[i] = (A==A[i]).sum()

if (res>1).sum() > 0:
  ans = 'NO'
else:
  ans = 'YES'
  
print(str(ans))

### FIXED CODE ###

import numpy as np

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

A_uni = np.unique(A)
if len(A_uni) < N:
    ans = 'NO'
else:
    ans = 'YES'
print(str(ans))
### BUGGY CODE ###

from heapq import heapify, heapreplace

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

A = map(int, input("").split(" "))
A = list(A)
heapify(A)

for i in range(M):
    B, C = map(int, input("").split(" "))

    for j in range(B):
        if A[0] < C:
            heapreplace(A, C)
        else:
            break

print(sum(A))

### FIXED CODE ###

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

A = map(int, input("").split(" "))
A = list(A)
A.sort()

potentials = []
for i in range(M):
    B, C = map(int, input("").split(" "))

    potentials.append((B, C))

potentials.sort(key=lambda x: x[1], reverse=True)

c = 0
for p in potentials:
    for b in range(p[0]):
        if p[1] > A[c]:
            A[c] = p[1]
            c += 1
            if c >= len(A):
                break
        else:
            break
    if c >= len(A):
        break

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

N = int(input())

ans = [0 for _ in range(1,N+1)]

for x in range(1,N+1):
    for y in range(1,N+1):
        for z in range(1,N+1):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n < N+1:
                ans[n-1] += 1

print(*ans,sep='\n')

### FIXED CODE ###

N = int(input())
ans = [0 for _ in range(1,10101)]

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n < N+1:
                ans[n-1] += 1

print(*ans[:N],sep='\n')
### BUGGY CODE ###

x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
print(c)

### FIXED CODE ###

x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
product = 1
for i in range(len(A)):
  product *= A[i]

if product <= 10**18:
  print(product)
else:
  print(-1)
  

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
product = 1
if A[0]==0:
  print(0)
else:
  for i in range(len(A)):
    product *= A[i]
    if product > 10**18:
      print(-1)
      break
if product <= 10**18 and A[0]!=0:
  print(product)
### BUGGY CODE ###

class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

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

b = BiCoeff(n+k+10,mod)
res = 0
for i in range(n,k+n+1):
    res += b.calc(n+k,i)*pow(25,n+k-i,mod)
    res %= mod
print(res)

### FIXED CODE ###

class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

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

b = BiCoeff(n+k+10,mod)
res = 0
for i in range(n,k+n+1):
    res += b.calc(n+k,i)*pow(25,n+k-i,mod)
    res %= mod
print(res)
### BUGGY CODE ###

import bisect
N,M=map(int, input().split() )
A=list(map(int, input().split() ))
B=[0]*M
C=[0]*M
for i in range(M):
  B[i],C[i]=map(int, input().split() )

pos=A
for i in range(M):
  pos += B[i]*[C[i]]
  
pos.sort(reverse=True)
print(sum(pos[:N]))

### FIXED CODE ###

from collections import Counter

N,M = map(int, input().split() )
A   = list(map(int, input().split() ))
B   = [0]*M
C   = [0]*M
Cou = Counter(A)

for i in range(M):
  B[i],C[i]  = map(int, input().split() )
  Cou[C[i]] += B[i]
  
#print(Cou)  
ans=0
cnt=0
S=sorted(Cou,reverse=True)
#print(S)
for num in S:
  kosuu = min(Cou[num],N-cnt)
  cnt += kosuu
  ans += num*kosuu
  
print(ans)
### BUGGY CODE ###

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

a = i = j = count = ans = 0

new_p = [0] * n

for i in range(n):
    for j in range(p[i]):
        new_p[i] += j+1
    new_p[i] = float(new_p[i]/p[i])

i = j = 0
total = 0
for i in range(k):
    total += new_p[i]
ans = total
for i in range(k,n):
    total = total + new_p[i] - new_p[i-k]
    ans = max(ans,total)

print('{:.10f}'.format(ans))

### FIXED CODE ###

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

a = i = j = count = ans = 0

new_p = [0] * n

for i in range(n):
    new_p[i] = float((p[i]+1)/2)

i = j = 0
total = 0
for i in range(k):
    total += new_p[i]
ans = total
for i in range(k,n):
    total = total + new_p[i] - new_p[i-k]
    ans = max(ans,total)

print('{:.10f}'.format(ans))
### BUGGY CODE ###

import sys
import numpy as np

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [[0 if c == '.' else 1 for c in input().strip()] for _ in range(H)]

    A = np.array(A)
    N = np.array(np.nonzero(A))
    N0, N1  = N[0], N[1]
    
    ans = 0
    for i in range(H):
        for j in range(W):
            dist = np.min(np.abs(N0 - i) + np.abs(N1 - j))
            ans = max(ans, dist)
            
    return ans

if __name__ == '__main__':
    print(main())


### FIXED CODE ###

#ref: https://atcoder.jp/contests/agc033/submissions/5260580

import sys
import numpy as np

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    INF = H * W
    dp = [[INF if c == '.' else 0 for c in input().strip()] for _ in range(H)]
    dp = np.array(dp)

    for i in range(1, H):
        dp[i, :] = np.minimum(dp[i, :], dp[i-1, :] + 1)

    for i in range(H-2, -1, -1):
        dp[i, :] = np.minimum(dp[i, :], dp[i+1, :] + 1)

    for i in range(1, W):
        dp[:, i] = np.minimum(dp[:, i], dp[:, i-1] + 1)

    for i in range(W-2, -1, -1):
        dp[:, i] = np.minimum(dp[:, i], dp[:, i+1] + 1)

    return np.max(dp)

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

N, K = list(map(int, input().split()))
l = list(map(int, input().split()))

n = []
for i in range(1, N+1):
    if i in l:
        n.append(l.count(i))

ans = 0
while len(n) > K:
    n[n.index(min(n))] += -1
    ans += 1
    if 0 in n:
        n.remove(0)

print(ans)


### FIXED CODE ###

from collections import Counter
N, K = list(map(int, input().split()))
l = list(sorted(Counter(map(int, input().split())).values()))

ans = 0
w = len(l)
for v in l:
    if w <= K:
        print(ans)
        break
    w -= 1
    ans += v
### BUGGY CODE ###

import numpy as np

N = int(input())
L = np.sort(np.array(list(map(int, input().split(" ")))))[::-1]

cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        rest2 = rest[i2+1:]
        cnt += sum(rest2 > l1 - l2)

print(cnt)

### FIXED CODE ###

from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    center = (n+1)//2
    x_s = list(map(int,input().split()))
    sorted_x_s = sorted(x_s)

    for i in x_s:
        if sorted_x_s.index(i) < center:
            print(sorted_x_s[center])
        else:
            print(sorted_x_s[center-1])






if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    center = (n+1)//2
    x_s = list(map(int,input().split()))
    sorted_x_s = sorted(x_s)
    center_num = sorted_x_s[center]

    for i in x_s:
        if i < center_num:
            print(sorted_x_s[center])
        else:
            print(sorted_x_s[center-1])






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

# coding: utf-8
# Your code here!

from collections import defaultdict
import copy

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

def make_divisors(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
    
max_divisor = 0
for a in A[:2]:
    divisors = make_divisors(a)
    
    for divisor in divisors:
        divisable = 0
        for a in A:
            if a % divisor == 0:
                divisable += 1
        
        if divisable >= N - 1:
            max_divisor = max(max_divisor, divisor)
            
            
print(max_divisor)
            
    

### FIXED CODE ###

# coding: utf-8
# Your code here!

from collections import defaultdict
import copy

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

def make_divisors(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
    
max_divisor = 0
for a in A[:2]:
    divisors = make_divisors(a)
    
    for divisor in divisors:
        if divisor > max_divisor:
            nondivisable = 0
            for a in A:
                if a % divisor != 0:
                    nondivisable += 1
                if nondivisable > 2:
                    break
                
            if nondivisable <= 1:
                max_divisor = divisor
            
            
print(max_divisor)
### BUGGY CODE ###

N = int(input())
S = [input() for i in range(N)]

def put_item(table, item):
    for i in range(0, len(table)):
        if table[i][0] == item:
            table[i][1] = table[i][1] + 1
            return 
    table.append([item, 1])

def histogram(data):
    result = []
    for i in range(0, len(data)):
        put_item(result, data[i])
    return result

T = []
for i in range(N):
    T.append(S[i])
    
    
print(len(histogram(T)))

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]

def histogram_sorted(data):
    table = []
    prev = data[0]
    c = 1 
    for i in range(1,len(data)):
        if prev == data[i]:
            c=c+1
        else:
            table.append([prev,c])
            prev = data[i]
            c = 1
    table.append([prev,c]) 
    return table

T = []
for i in range(N):
    T.append(S[i])
    
    
print(len(histogram_sorted(sorted(T))))
### BUGGY CODE ###

import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    SSSS = 10 ** 9 + 7
    [A, B] = string_to_int(inputs[0])
    max_len = max([A, B])
    min_len = min([A, B])
    diff_len = abs(A-B)
    if diff_len >= 2:
        return 0

    pattern = 0
    for i in reversed(range(1, min_len + 1)):
        if i == min_len:
            if diff_len == 1:
                pattern = max_len * min_len
                pattern *= min_len
            else:
                pattern = min_len + min_len
                pattern *= min_len
        else:
            pattern *= i * i
    #     if pattern >= SSSS:
    #         patterns.append(pattern)
    #         pattern = 1

    # if len(patterns) >= 1:
    #     pattern = 1
    #     for p in patterns:
    #         pattern *= p

    return pattern % SSSS


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


### FIXED CODE ###

import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    SSSS = 10 ** 9 + 7
    [A, B] = string_to_int(inputs[0])
    max_len = max([A, B])
    min_len = min([A, B])
    diff_len = abs(A-B)
    if diff_len >= 2:
        return 0

    pattern = 0
    for i in reversed(range(1, min_len + 1)):
        if i == min_len:
            if diff_len == 1:
                pattern = max_len * min_len
                pattern *= min_len
            else:
                pattern = min_len + min_len
                pattern *= min_len
        else:
            pattern *= i * i
        pattern = pattern % SSSS

    return pattern % SSSS


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)