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

import sys
import bisect
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        left=bisect.bisect_left(l,l[i]+l[j])
        right=bisect.bisect_right(l,(l[i]+l[j]+1)//2)
        # print(left)
        # print(right)
        # print()
        cnt=left-(j+1)
        if left<=j+1:
            # print(99)
            continue
        # if right<j+2:
        #     cnt-=j+2-right
        if cnt>=0:
            ans+=cnt
        
print(ans)

### FIXED CODE ###

import sys
import bisect
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        left=bisect.bisect_left(l,l[i]+l[j])
        # right=bisect.bisect_right(l,(l[i]+l[j]+1)//2)
        # print(left)
        # print(right)
        # print()
        cnt=left-(j+1)
        if left<=j+1:
            # print(99)
            continue
        # if right<j+2:
        #     cnt-=j+2-right
        if cnt>=0:
            ans+=cnt
        
print(ans)
### BUGGY CODE ###

h, w, m = map(int, input().split())
bord_x, bord_y = [0 for i in range(h)], [0 for i in range(w)]
bord = [[0 for _j in range(w)] for _i in range(h)]

for _i in range(m):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    bord_x[s] += 1
    bord_y[t] += 1
    bord[s][t] = 1

x_max, y_max = max(bord_x), max(bord_y)
a, b = [], []
for i in range(h):
    if bord_x[i] == x_max:
        a.append(i)
for i in range(w):
    if bord_y[i] == y_max:
        b.append(i)

checker = 0
for i in a:
    for j in b:
        if bord[i][j]==0:
            import sys
            print(x_max+y_max)
            sys.exit()
        else:
            checker += 1
            if checker >= m:
                break

print(x_max+y_max-1)

### FIXED CODE ###

h, w, m = map(int, input().split())
bord_x, bord_y = [0]*h, [0]*w
 
hw = []
for _i in range(m):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    bord_x[s] += 1
    bord_y[t] += 1
    hw.append([s, t])
 
x_max, y_max = max(bord_x), max(bord_y)
 
cnt = 0
for i, j in hw:
    if bord_x[i] == x_max and bord_y[j] == y_max:
        cnt += 1
 
if cnt == bord_x.count(x_max)*bord_y.count(y_max):
    x_max -= 1
 
print(x_max+y_max)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(M):
  A[0] //= 2
  if N > 1:
    j = 0
    while A[j] < A[j+1]:
      A[j], A[j+1] = A[j+1], A[j]
      j += 1
      if j == N-2:
        break
#  print(A)
print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)
for i in range(M):
  m = heapq.heappop(A)
  heapq.heappush(A, (-m // 2) * (-1))

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

# -*- coding: utf-8 -*-
import sys

N,*A = map(int, sys.stdin.buffer.read().split())

A = sorted(A)
setA = set(A)

def yakusu(x):
  if x==1:
    return []
  result = [1]
  y = 2
  while y**2<=x:
    if x%y==0:
      result.append(y)
      result.append(x//y)
    y += 1
  return result

count = N
for i in range(N):
  a = A[i]
  if i>0 and a==A[i-1]:
    count -= 1
    continue
  if i<N-1 and a==A[i+1]:
    count -= 1
    continue
  y = 1
  while y**2<=a:
    if a%y==0:
      if y!=a and y in setA:
        count -= 1
        break
      if a//y!=a and a//y in setA:
        count -= 1
        break
    y += 1

print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

N,*A = map(int, sys.stdin.buffer.read().split())

S = [0 for _ in range(10**6+1)]
T = [0 for _ in range(10**6+1)]

for a in A:
  S[a] += 1

count = 0
for i in range(1,10**6+1):
  if T[i] == 1:
    continue
  if S[i] == 0:
    continue
  if S[i] == 1:
    count += 1
  for j in range(10**6//i+1):
    T[i*j] = 1

print(count)
### BUGGY CODE ###

N = int(raw_input())
A = map(int, raw_input().split())
A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    zeros = len([a[i] for a in A if a[i] == '0'])
    ones = len([a[i] for a in A if a[i] == '1'])
    count[i] = zeros*ones

ans = 0
for i, v in count.items():
    ans = (ans + count[i]*(2**(59-i))) % MOD

print ans


### FIXED CODE ###

import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

mod_val = dict()
curr = 1
for i in range(60):
    mod_val[i] = curr % MOD
    curr = (2*curr) % MOD

ans = 0
for i in count:
    ans = (ans + count[i]*mod_val[i]) % MOD

print ans
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
h = []
for i in range(x):
    for j in range(y):
        for l in range(z):
            if(i*j*l>k): break
            h.append(a[i] + b[j] +c[l])
h.sort(reverse = True)
for i in range(k):
    print(h[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
h = []
for i in range(x):
    for j in range(y):
        if(i*j>k): break
        for l in range(z):
            if(i*j*l>k): break
            h.append(a[i] + b[j] +c[l])
h.sort(reverse = True)
for i in range(k):
    print(h[i])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(a.count(i))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
x=[0]*n
for i in a:
  x[i-1]+=1
for i in x:
  print(i)
### BUGGY CODE ###

import bisect
n = int(input())
a_list = sorted([ int(v) for v in input().split() ])
b_list = sorted([ int(v) for v in input().split() ])
c_list = sorted([ int(v) for v in input().split() ])

ans = 0
for i in a_list:
    p = bisect.bisect_left(b_list,i+1)
    for j in b_list[p:]:
        q = bisect.bisect_left(c_list,j+1)
        ans += n - q
print(ans)


### FIXED CODE ###


import bisect



def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n = int(input())
a_list = sorted([ int(v) for v in input().split() ])
b_list = sorted([ int(v) for v in input().split() ])
c_list = sorted([ int(v) for v in input().split() ])
a_b_list = [ bisect.bisect_right(a_list,i-1) for i in b_list]
b_c_list = [ bisect.bisect_right(b_list,i-1) for i in c_list]
a_b_cumsum_list = cumsum(a_b_list)
a_b_c_list = [ a_b_cumsum_list[i-1] for i in b_c_list if i != 0]
print(sum(a_b_c_list))
### BUGGY CODE ###

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

ans = 0
for day in range(M, 0, -1):
    best_job = [0, 0]
    for job in jobs:
        if day + job[0] - 1 <= M:
            if best_job[1] <= job[1]:
                best_job = job
    if best_job != [0, 0]:
        jobs.remove(best_job)
        ans += best_job[1]

print(ans)


### FIXED CODE ###

import heapq
from collections import defaultdict

N, M = map(int, input().split())
jobs = defaultdict(list)
for _ in range(N):
    day, value = map(int, input().split())
    if day <= M:
        jobs[day].append(value)

ans = 0
hq = []
for day in range(1, M+1):
    for value in jobs[day]:
        heapq.heappush(hq, - value)
    if len(hq) > 0:
        ans -= heapq.heappop(hq)

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

import sys

if __name__ == '__main__':
    n = int(sys.stdin.readline().rstrip())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    q = int(sys.stdin.readline().rstrip())
    dic = {}
    for a in A:
        dic[a] = dic.get(a, 0) + 1

    for i in range(q):
        b, c = list(map(lambda x: int(x), sys.stdin.readline().split()))

        dic[c] = dic.get(c, 0) + dic.get(b, 0)
        dic[b] = 0

        summ = 0
        for k, v in dic.items():
            summ += k*v
        print(summ)

### FIXED CODE ###

import sys
import numpy as np

if __name__ == '__main__':
    n = int(sys.stdin.readline().rstrip())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    q = int(sys.stdin.readline().rstrip())
    dic = {}
    for a in A:
        dic[a] = dic.get(a, 0) + 1

    # keys = list(dic.keys())
    # values = list(dic.values())
    # summ = np.array(keys).dot(np.array(values))
    summ = sum([k*v for k, v in dic.items()])
    for i in range(q):
        b, c = list(map(lambda x: int(x), sys.stdin.readline().split()))

        diff = c*dic.get(b,0) - b*dic.get(b,0)
        dic[c] = dic.get(c, 0) + dic.get(b, 0)
        dic[b] = 0
        summ += diff
        print(summ)
### BUGGY CODE ###

n=int(raw_input())
li=[]
while n !=0:
    a = int(raw_input())
    if a not in li:
        li.append(a)
    else:
        li.remove(a)
    n-=1
print(len(li))


### FIXED CODE ###

n=int(raw_input())
li={}
while n !=0:
    a = raw_input()
    if a in li:
        del li[a]
    else:
        li[a]=a
    n-=1
print(len(li))
### BUGGY CODE ###

import sys

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

graph = {}
count = 1
for value in input().split():
    graph[count] = int(value)
    count += 1

queue = [1]
now_pos = 1
start = 0

for i in range(N + 1):
    next_pos = graph[now_pos]
    if not next_pos in queue:
        queue.append(next_pos)
        now_pos = next_pos

    # 循環した
    else:
        start = next_pos
        break

if K <= N:
    print(queue[K])
    sys.exit()

before_len = len(queue[:queue.index(start)])
roop = queue[queue.index(start):]

print(roop[(K - before_len) % len(roop)])


### FIXED CODE ###

import sys
import time

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

queue = {}

start = -1
count = 1

now_town = 1

for i in range(K):
    if town_list[now_town - 1] in queue:
        start = town_list[now_town - 1]
        break
    queue[town_list[now_town - 1]] = count
    now_town = town_list[now_town - 1]
    count += 1

if start == -1:
    print(now_town)
    sys.exit()

roop = len(queue) - (queue[start] - 1)
before_len = queue[start]

print(list(queue.keys())[(K - before_len) % roop + before_len - 1])
### BUGGY CODE ###

import heapq as hq

N, A, B = map(int, input().split())
h = []
for i in range(N):
    hq.heappush(h, -int(input()))
    
count = 0
while True:
    max_h = hq.heappop(h)
    
    if max_h >= 0:
        break
    
    h = [x + B for x in h]
    hq.heapify(h)
    hq.heappush(h, max_h + A)
    count += 1

print(count)

### FIXED CODE ###

N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
    
left = 0
right = max(h)

def can_kill(count):
    ness = 0
    for hp in h:
        ness += max(-(-(hp - B * count) // (A - B)), 0)
    if ness <= count:
        return True
    return False
    
while right - left > 1:
    middle = left + (right - left) // 2
    if can_kill(middle):
        right = middle
    else:
        left = middle

print(right)
### BUGGY CODE ###

s=' '+input()
t=' '+input()
dp=[['']*len(t)for _ in range(len(s))]
for i in range(1,len(s)):
    for j in range(1,len(t)):
        if s[i]==t[j]:
            dp[i][j]=''.join([dp[i-1][j-1],s[i]])
        elif len(dp[i-1][j])>len(dp[i][j-1]):
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=dp[i][j-1]
print(dp[-1][-1])

### FIXED CODE ###

s=' '+input()
t=' '+input()
dp=[[0]*len(t)for _ in range(len(s))]
for i in range(1,len(s)):
    for j in range(1,len(t)):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=[]
i,j=len(s)-1,len(t)-1
while dp[i][j]:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans.append(s[i])
        i-=1
        j-=1
print(''.join(ans[::-1]))
### BUGGY CODE ###

import math

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


def prime(n):
	if n > 1:
		for i in range(2,math.floor(math.sqrt(n))+1):
			if (n % i) == 0:
				return(False)
				break
		else:
			return(True)
	else:
		return(False)

count = 0
for i in range (0, Q):
	for j in range (P[i][0], P[i][1]+1):
		if j%2==0:
			continue
		else:
			if prime(j) == 1 and prime((j+1)/2) == 1:
				count+=1
			else:
				continue
	print(count)
	count=0

### FIXED CODE ###

import math

Q = int(input())

def prime(n):
	if n > 1:
		for i in range(2,math.floor(math.sqrt(n))+1):
			if (n % i) == 0:
				return(False)
				break
		else:
			return(True)
	else:
		return(False)

Numero = [0]*100001
for i in range (1, 50001):
	if prime(2*i+1) == 1 and prime(i+1) == 1:
		for j in range (2*i+1, 100001):
			Numero[j]+=1
	else:
		continue

for i in range (0, Q):
	A, B = map(int, input().split())
	print(Numero[B]-Numero[A-1])
### BUGGY CODE ###

H, W = map(int, input().split())
m = [list(input()) for _ in range(H)]
inf = float("inf")

V = H*W
maze = [[inf]*V for _ in range(V)]

for i in range(V):
    maze[i][i] = 0

for py in range(H):
    for px in range(W):
        if m[py][px] == "#":
            continue
        candidate = [(px+1, py), (px-1, py), (px, py+1), (px, py-1)]
        for x, y in candidate:
            if not (0<=x<W and 0<=y<H):continue
            if m[y][x] == "#":
                continue
            maze[W*py+px][W*y+x] = 1

for k in range(V):
    for i in range(V):
        for j in range(V):
            maze[i][j] = min(maze[i][j], maze[i][k]+maze[k][j])

print(max([j for i in maze for j in i if j!=inf]))

### FIXED CODE ###

H, W = map(int, input().split())
m = [list(input()) for _ in range(H)]
inf = 10**3

V = H*W
maze = [[inf]*V for _ in range(V)]

for i in range(V):
    maze[i][i] = 0

for py in range(H):
    for px in range(W):
        if m[py][px] == "#":
            continue
        candidate = [(px+1, py), (px-1, py), (px, py+1), (px, py-1)]
        for x, y in candidate:
            if not (0<=x<W and 0<=y<H):continue
            if m[y][x] == "#":
                continue
            maze[W*py+px][W*y+x] = 1

for k in range(V):
    for i in range(V):
        for j in range(V):
            maze[i][j] = min(maze[i][j], maze[i][k]+maze[k][j])

print(max([j for i in maze for j in i if j!=inf]))
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(N):
  L[i+1] = L[i]^a[i]
  R[N-i-1] = R[N-i]^a[N-i-1]
  ans = [None]*N
for i in range(N):
  ans[i] = L[i]^R[i+1]
print(*ans)

### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    L = [0]*(N+1)
    R = [0]*(N+1)
    for i in range(N):
        L[i+1] = L[i]^a[i]
        R[N-i-1] = R[N-i]^a[N-i-1]
    ans = [None]*N
    for i in range(N):
        ans[i] = L[i]^R[i+1]
    print(*ans)
    # print(L,R)


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

from math import ceil


def solve(n, h):
    a = []
    b = []
    ans = 1

    for i in range(n):
        ai, bi = map(int, input().split())
        a.append(ai)
        b.append(bi)
        a.sort(reverse=True)
        b.sort(reverse=True)

    if n == 1:
        ans += ceil((h-b[0])/a[0])

    else:
        h = h-b[0]
        i = 1
        while 0 < h:
            if i < n and a[0] <= b[i]:
                ans += 1
                h = h-b[i]
                i += 1
            else:
                ans += ceil(h/a[0])
                break

    return ans


if __name__ == '__main__':
    n, h = map(int, input().split())
    print(solve(n, h))


### FIXED CODE ###

from math import ceil
from bisect import bisect_left


def solve(n, h):
    a = []
    b = []

    for i in range(n):
        ai, bi = map(int, input().split())
        a.append(ai)
        b.append(bi)

    amax = max(a)
    b.sort()

    if n == 1:
        ans = ceil((h-b[n-1])/amax)+1

    else:
        over_amax = b[bisect_left(b, amax):]
        if h <= sum(over_amax):
            for j in range(n-1, -1, -1):
                h -= b[j]
                if h <= 0:
                    ans = n-j
                    break

        else:
            ans = ceil((h - sum(over_amax)) / amax) + len(over_amax)

    return ans


if __name__ == '__main__':
    n, h = map(int, input().split())
    print(solve(n, h))
### BUGGY CODE ###

from math import floor
A, B, N = map(int, input().split())

ans = 0
for x in range(N+1):
    ans = max(ans, floor(A*x/B)-A*floor(x/B))

print(ans)

### FIXED CODE ###

from math import floor
A, B, N = map(int, input().split())
x = B-1 if B <= N else N
ans = floor((A*x)/B)
print(ans)
### BUGGY CODE ###

import math


H,N = map(int,input().split())
Damage = []
Cost = []


DP = [0] + [pow(10,9)] * (H+1)



for i in range(N):
    a,b = map(int,input().split())
    Damage.append(a)
    Cost.append(b)
    
#print(DP)


# DP[i] = best magic points to do i damage

for i in range(1,len(DP)):
    for spell in range(N):
        DP[i] = min(DP[i],DP[max(0,i-Damage[spell])]+Cost[spell])




print (DP[H])



### FIXED CODE ###


     

import math



H,N = map(int,input().split())
Damage = []
Cost = []


DP = [0] + [pow(10,9)] * (H+1)



for i in range(N):
    a,b = map(int,input().split())
    Damage.append(a)
    Cost.append(b)
    
#print(DP)


# DP[i] = min magic points to do i damage

for i in range(1,len(DP)):
    for spell in range(N):
        DP[i] = min(DP[i],DP[max(0,i-Damage[spell])]+Cost[spell])




print (DP[H])
### BUGGY CODE ###

import numpy as np
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
h,w = map(int,input().split())
l=['#'*(w+2)]+['#'+input().strip()+'#' for i in range(h)]+['#'*(w+2)]
dp = np.zeros((h+2,w+2,2),dtype=int)
cnt = 0
ans = 0

def dfsw(x,y,cnt):
  if l[x][y+1] == '.':
    cnt += 1
    dp[x,y,0] = dfsw(x,y+1,cnt)
    return dp[x,y,0]
  else:
    dp[x,y,0] = cnt
    return dp[x,y,0]

def dfsh(x,y,cnt):
  if l[x+1][y] == '.':
    cnt += 1
    dp[x,y,1] = dfsh(x+1,y,cnt)
    return dp[x,y,1]
  else:
    dp[x,y,1] = cnt
    return dp[x,y,1]

for i in range(h+2):
  for j in range(w+2):
    if l[i][j] == '.':
      if dp[i,j,0] == 0:
        dfsw(i,j,1)
      if dp[i,j,1] == 0:
        dfsh(i,j,1)
      ans = max(ans, sum(dp[i,j]) - 1)
print(ans)

### FIXED CODE ###

import numpy as np
h,w = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
#print(ar)
l = np.zeros((h,w),dtype=int)
r = np.zeros((h,w),dtype=int)
u = np.zeros((h,w),dtype=int)
d = np.zeros((h,w),dtype=int)

for i in range(h):
  u[i] = (u[i-1]+1)*ar[i]
  #print(u)
  d[-i-1] = (d[-i]+1)*ar[-i-1]
  #print(d)
  
for j in range(w):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  #print(l)
  r[:,-j-1] = (r[:,-j]+1)*ar[:,-j-1]
  #print(r)
print(np.max(u+d+l+r)-3)
### BUGGY CODE ###

import sys
import bisect


input = sys.stdin.readline

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

    bleft = bisect.bisect_left
    bright = bisect.bisect
    ans = 0

    for i, a in enumerate(L):
        if i > N-2:
            break
        for j, b in enumerate(L):
            if j > N-1:
                break
            if j <= i:
                continue
            # print(a, b)
            c_right = bleft(L, a+b)
            # print(c_right)
            if c_right == 0:
                continue
            now_seq = L[j+1:c_right]
            c_left = bright(now_seq, b-a)
            if c_left == N:
                continue
            ans += len(now_seq) - c_left
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import bisect


input = sys.stdin.readline

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

    bleft = bisect.bisect_left
    bright = bisect.bisect
    ans = 0

    for i, a in enumerate(L):
        if i > N-2:
            break
        for j, b in enumerate(L):
            if j > N-1:
                break
            if j <= i:
                continue
            c_right = bleft(L[j+1:], a+b)
            ans += c_right
    print(ans)

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

def f(i,k):
  for j in range(13):
    dp[i+1][(j*10+k)%13]+=dp[i][j]
    dp[i+1][(j*10+k)%13]%=mod
  
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*13 for i in range(10**5+1)]
dp[0][0]=mul=1

for i in range(n):
  if s[i]=='?':
    for k in range(10):
      f(i,k)
  else:
    f(i,int(s[i]))
  
print(dp[n][5]%mod)


### FIXED CODE ###

def f(i,k):
  for j in range(13):
    dp[i+1][(j*10+k)%13]+=dp[i][j]
    dp[i+1][(j*10+k)%13]%=mod
  
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*13 for i in range(10**5+1)]
dp[0][0]=mul=1

for i in range(n):
  if s[i]=='?':
    for k in range(10):
      f(i,k)
  else:
    f(i,int(s[i]))
  
print(dp[n][5]%mod)
### BUGGY CODE ###

k,s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        l = s - i - j
        #print('{} {} {}'.format(i,j,l))
        if i + j + l == s and l >= 0 and k >= l:
            ans +=  1
            
print(ans)

### FIXED CODE ###

k,s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        l = s - i - j
        #print('{} {} {}'.format(i,j,l))
        if  l >= 0 and k >= l:
            ans +=  1
            
print(ans)
### BUGGY CODE ###

R, G, B, N = (int(i) for i in input().split())

c = 0
for r in range(N//R, -1, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        c += len([b for b in range(new2//B, -1, -1) if b*B == new2])

print(c)

### FIXED CODE ###

R, G, B, N = (int(i) for i in input().split())

c = 0
for r in range(N//R, -1, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        if new2%B == 0:
            c +=1
    
print(c)
### BUGGY CODE ###

N, W = map(int, input().split())
goods = [list(map(int, input().split())) for _ in range(N)]

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

for i in range(N):
    for w in range(W+1):
        if w-goods[i][0] >= 0:
            dp[i+1][w] = max(dp[i+1][w], dp[i][w-goods[i][0]] + goods[i][1])
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])        
print(dp[-1][-1])

### FIXED CODE ###

N, W = map(int, input().split())
dp = [-1]*(W+1)
dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    for i in range(W-w, -1, -1):
        if dp[i] == -1:
            continue
        if dp[i+w] < dp[i] + v:
            dp[i+w] = dp[i] + v
print(max(dp))
### BUGGY CODE ###

import sys

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

grid=[[0]*C for _ in range(R)]
for _ in range(K):
    r,c,v=map(int,next(sys.stdin).split())
    grid[r-1][c-1]=v

ans=0
stk=[(0,0,0,3)]
while stk:
    i,j,tt,k=stk.pop()
    ntt,nk=tt,k
    if k>0:
        ntt+=grid[i][j]
        nk=k-1
    if i+1==R and j+1==C:
        ans=max(ans,ntt)
        continue
    for ni,nj in (i,j+1),(i+1,j):
        if not (ni<R and nj<C):
            continue
        if ni!=i:
            k=nk=3
        stk.append((ni,nj,tt,k))
        if tt!=ntt:
            stk.append((ni,nj,ntt,nk))


print(ans)








### FIXED CODE ###

import sys
from pprint import pprint

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

grid=[[0]*C for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    grid[r][c-1]=v

for i in range(1,R+1):
    cell=[0]*4
    for j in range(C):
        cell[0]=max(cell[0],grid[i-1][j])
        for k in range(2,-1,-1):
            cell[k+1]=max(cell[k+1],cell[k]+grid[i][j])
        grid[i][j]=max(cell)

print(grid[-1][-1])
### BUGGY CODE ###

n,k,q = map(int,input().split())
A = []
for i in range(q):
    A.append(int(input()))

for i in range(1,n+1):
    if A.count(i) > q-k:
        print('Yes')
    else:
        print('No')



### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
A = [0]*n
for i in range(q):
    A[int(input())-1] +=1

for i in range(n):
    if A[i] > q-k:
        print('Yes')
    else:
        print('No')