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

from functools import reduce

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

cum = [0] * (n - k + 1)
cum[0] = reduce(lambda x, y: x * y, a[0:0 + k])
for i in range(1, n - k + 1):
    cum[i] = cum[i - 1] * a[i + k - 1] // a[i - 1]

for i in range(1, len(cum)):
    if cum[i] > cum[i - 1]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

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

for i in range(k, n):
    if a[i - k] / a[i] < 1:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
S = input()

ans = 0

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

print(ans)

### FIXED CODE ###

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
S = input()

ans = 0

count_S = {
    "R": [0] * N,
    "G": [0] * N,
    "B": [0] * N,
}

count_S[S[-1]][-1] = 1
for i in reversed(range(N-1)):
    count_S["R"][i] = count_S["R"][i+1]
    count_S["B"][i] = count_S["B"][i+1]
    count_S["G"][i] = count_S["G"][i+1]
    count_S[S[i]][i] += 1


# for i in range(0, N-2):
#     for k in range(i+2, N):
#         if S[i]==S[k]:
#             continue
#         for j in range(i+1, k):
#             # print(S[i], S[j], S[k])
#             if j-i!=k-j and S[i]!=S[j] and S[j]!=S[k]:
#                 ans += 1


for i in range(0, N-3):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        for c in "RGB":
            if S[i] != c and S[j] != c:
                last_color = c
        ans += count_S[last_color][j+1]
        if j+j-i <= N-1 and S[j+j-i] == last_color:
            ans -= 1

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

N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


count = 0
for t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != (len(S) - 1):
        count += 1
    S.pop()
print(count)



### FIXED CODE ###

from typing import List
import math

N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


def binary_search(A: List[int], key: int) -> int:
    left = 0
    right = len(A)
    while left < right:
        mid = math.floor((left + right) / 2)
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return -1


count = 0
for t in T:
    if binary_search(S, t) != -1:
        count += 1
print(count)
### BUGGY CODE ###

import numpy as np
from collections import deque
import sys

@np.vectorize
def trans(s):
    return 1 if s == "#" else 0

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([trans([w for w in next(inp).strip()]) for _ in range(H)])

def search(S, start):
    Q = deque([start])
    C = np.full_like(S, 0)
    H, W = S.shape
    while Q:
        i, j = Q.popleft()
        if C[i, j] != 0:
            continue
        else:
            C[i, j] = 1
        if i + 1 < H and C[i+1, j] == 0 and S[i, j] != S[i+1, j]:
            Q.append((i + 1, j))
        if i > 0 and C[i-1, j] == 0 and S[i, j] != S[i-1, j]:
            Q.append((i - 1, j))
        if j + 1 < W and C[i, j+1] == 0 and S[i, j] != S[i, j+1]:
            Q.append((i, j + 1))
        if j > 0 and C[i, j-1] == 0 and S[i, j] != S[i, j-1]:
            Q.append((i, j - 1))
    return C

def search_all(S):
    ij = (0, 0)
    D = np.full_like(S, 0)
    ret = 0
    while True:
        C = search(S, ij)
        D += C
        n = np.sum(C)
        n1 = np.sum(C * S)
        n0 = n - n1
        ret += n1 * n0
        ii, jj = np.where(D == 0)
        if len(ii) == 0:
            return ret
        else:
            ij = ii[0], jj[0]

        
    
print(search_all(parse(sys.stdin)))

### FIXED CODE ###


import numpy as np
from collections import deque
import sys

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([list(next(inp).strip()) for _ in range(H)])

dis = [0, 0, 1, -1]
djs = [1, -1, 0, 0]

def search(S, i, j, Q, R):
    H, W = S.shape
    R[i, j] = True
    Q.append((i, j))
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if S[i, j] == "#":
            n1 += 1
        else:
            n0 += 1
        gen = ((i + di, j + dj) for di, dj in zip(dis, djs))
        ijs = (g for g in gen if 0 <= g[0] and g[0] < H and 0 <= g[1] and g[1] < W)
        for ni, nj in ijs:
            if not R[ni, nj] and S[ni, nj] != S[i, j]:
                R[ni, nj] = True
                Q.append((ni, nj))
    return n0 * n1


def test(S):
    i, j = 0, 0
    Q = deque()
    R = np.full(S.shape, False)
    H, W = S.shape
    n = 0
    for i in range(H):
        for j in range(W):
            if not R[i, j]:
                n += search(S, i, j, Q, R)
    return n

print(test(parse(sys.stdin)))
### BUGGY CODE ###

INF = 1000000000

while True:
  try:
    n,k = list(map(int,input().split()))
    if n == 0 and k == 0:
      break
    D = [[0 if i == j else INF for i in range(n)] for j in range(n)]
    for i in range(k):
      lst = list(map(int,input().split()))
      if lst[0] == 0:
        ans = D[lst[1] - 1][lst[2] - 1]
        if ans >= INF:
          print(-1)
        else:
          print(ans)
      elif lst[0] == 1:
        _,a,b,c = lst
        for i in range(n):
          for j in range(i):
            D[i][j] = min(D[i][j],
                          D[i][a - 1] + c + D[b - 1][j],
                          D[i][b - 1] + c + D[a - 1][j])
            D[j][i] = D[i][j]
  except EOFError:
    break


### FIXED CODE ###

from heapq import heappush,heappop

def dij(s,g,E):
  h = []
  U = []
  heappush(h,(0,s))
  while h:
    v = heappop(h)
    if v[1] == g:
      if v[0] >= INF:print(-1)
      else:print(v[0])
      break
    U.append(v[1])
    for e in E[v[1]]:
      if not e[0] in U:
        heappush(h,(v[0] + e[1],e[0]))
  else:print(-1)
INF = 100000000
while True:
  try:
    n,k = map(int,input().split())
    if n == 0 and k == 0: break
    E = [[] for i in range(n)]
    for _ in range(k):
      lst = list(map(int,input().split()))
      if lst[0] == 0:
        dij(lst[1] - 1, lst[2] - 1, E)
      else:
        E[lst[1] - 1].append([lst[2] - 1, lst[3]])
        E[lst[2] - 1].append([lst[1] - 1, lst[3]])

  except EOFError:
    break
### BUGGY CODE ###

import sys
N = int(input())
l = list(map(int, input().split()))
a = []
for i in range(N):
    a.append(l.index(i+1)+1)

print(' '.join(map(str, a)))

### FIXED CODE ###

import sys
N = int(input())
l = list(map(int, input().split()))
a = [0] * N
for i in range(N):
    index =l[i] -1
    #print(index)
    a[index] = i+1
    #print(a[index])
    

print(' '.join(map(str, a)))
### BUGGY CODE ###

def main():
    R,B,G,N = list(map(int,input().split(' ')))
    cnt = 0
    for i in range(N//R+1):
        for j in range(N//G+1):
            if (N-(R*i+G*j))//B == (N-(R*i+G*j))/B and (N-(R*i+G*j))/B >=0:
                cnt +=1
    print(cnt)

if __name__ =='__main__':
    main()

### FIXED CODE ###

def main():
    R,B,G,N = list(map(int,input().split(' ')))
    cnt = 0
    for r in range(N//R+1):
        for g in range(N//G+1):
            if R*r+G*g > N:
                break
            if (N-(R*r+G*g))%B ==0:

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

[N]=list(map(int, input().split()))
A=list(map(int, input().split()))
c=0
for i in range (0,N):
    B=sorted(A[0:i+1],reverse=True)
    if B[i] == A[i]:
        c=c+1
print(c)

### FIXED CODE ###

[N]=list(map(int, input().split()))
A=list(map(int, input().split()))
c=0
min=A[0]
for i in range (0,N):
    if A[i]<=min:
        min=A[i]
        c=c+1
print(c)
### BUGGY CODE ###

N = int(input())
L = sorted(map(int, input().split()))

counter = 0

for i in range(N):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        for k in range(j+1, N):
            c = L[k]
            if c >= a + b:
                break
            elif b < c + a and a < b + c:
                counter += 1

print(counter)

### FIXED CODE ###

import bisect

N = int(input())
L = sorted(map(int, input().split()))

counter = 0

for i in range(N):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        k = bisect.bisect_left(L, a + b)
        counter += max(0, k - (j + 1))

print(counter)
### BUGGY CODE ###

n = int(input())
L = list(map(int,input().split()))
total = 0

for i in range(n-1):
  for j in range(i+1,n):
    total += L[i]*L[j]
print(total % (10**9+7))

### FIXED CODE ###

n = int(input())
L = list(map(int,input().split()))
mod = 1000000007
ans = 0
x = 0
for i in range(n):
  ans = (ans + L[i]*x)%mod
  x = (x + L[i]%mod)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
tmp = [0]*61
MOD = 1_000_000_007
for i in range(n):
    for j in range(61):
        mask = 1<<j
        if a[i]&mask>0:
            tmp[j]+=1
ans = 0
for i in range(61):
    mask = 1<<i
    ans = (ans + mask*tmp[i]*(n-tmp[i])) % MOD
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
tmp = [0]*61
MOD = 1_000_000_007
for i in range(n):
    for j in range(61):
        mask = 1<<j
        if a[i]&mask>0:
            tmp[j]+=1
ans = 0
for i in range(61):
    mask = 1<<i
    ans = (ans + mask*tmp[i]*(n-tmp[i])) % MOD
print(ans)
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return {i for i in range(self.n) if self.find(i) == root}

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list(map(int,input().split()))
uf = UnionFind(N)
p = list(map(int,input().split()))
L = []
for i in range(M):
    x,y = map(int,input().split())
    uf.union(x - 1,y - 1)
cnt = 0
for i in range(N):
    if i in uf.members( p[i] - 1 ):
        cnt+=1
print(cnt)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return {i for i in range(self.n) if self.find(i) == root}

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list(map(int,input().split()))
uf = UnionFind(N)
p = list(map(int,input().split()))
L = []
for i in range(M):
    x,y = map(int,input().split())
    uf.union(x - 1,y - 1)
cnt = 0
for i in range(N):
    if uf.same(i,p[i]-1):
        cnt+=1
print(cnt)
### BUGGY CODE ###

import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max - 1
p = len(cand_h)*len(cand_w)
if M >= p:
   for i in range(len(cand_h)):
      for j in range(len(cand_w)):
         if not [cand_h[i], cand_w[j]] in object:
            ans = h_max + w_max
            break
            break
            
else:
   ans += 1
print(ans) 

### FIXED CODE ###

import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max
c = 0
p = len(cand_h)*len(cand_w)
cand_h = set(cand_h)
cand_w = set(cand_w)
if M >= p:
   for i in range(len(object)):
      if object[i][0] in cand_h and object[i][1] in cand_w:
         c += 1
print(ans - (c == p))
### BUGGY CODE ###

def sequence(lis, first_value):
    count = 0
    now_sum = first_value
    pre_sum = first_value
    for num in lis[1:]:
        now_sum += num
        while now_sum == 0 or now_sum * pre_sum > 0:
            now_sum -= pre_sum/abs(pre_sum)
            count += 1
        pre_sum = now_sum
    return count

n = int(input())
a = [int(i) for i in input().split()]
if a[0] == 0:
    print(min(sequence(a, 1), sequence(a, -1))+1)
else:
    print(sequence(a, a[0]))

### FIXED CODE ###

def sequence(lis, first_value):
    count = 0
    now_sum = first_value
    pre_sum = first_value
    for num in lis[1:]:
        now_sum += num
        if now_sum == 0 or pre_sum * now_sum > 0:
            count += abs(now_sum) + 1
            now_sum = -1 * pre_sum / abs(pre_sum)
        pre_sum = now_sum
    return int(count)

n = int(input())
a = [int(i) for i in input().split()]
if a[0] == 0:
    print(min(sequence(a, 1)+1, sequence(a, -1)+1))
else:
    print(min(sequence(a, a[0]), sequence(a, -1*a[0]/abs(a[0]))+abs(a[0])+1))
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = 0
while A:
    a = A.pop(-1)
    if not A or a != A[-1]:
        ans += 1
    B = []
    for i in A:
        if i%a != 0:
            B.append(i)
    A = B
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B = [True]*(A[-1]+1)
i = 0
for i in range(N):
  if i < N-1 and A[i] == A[i+1]:
    B[A[i]] = False
  if A[-1] < 2*A[i]:
    continue
  M = A[-1]//A[i]+1
  for j in range(2,M):
    B[j*A[i]] = False

ans = 0
for a in A:
  if B[a]:
    ans += 1
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
index=[]
ac=[]
pena=[]

for i in range(M):
    p,s = input().split()

    #もし初めてp問目が提出されたなら
    if not p in index:
        index.append(p)
        ac.append(0)
        pena.append(0)
    #もしp問目が未ACなら
    if ac[index.index(p)] == 0:
        if s == "AC" :
            ac[index.index(p)] += 1
        else:
            pena[index.index(p)] += 1
AC = 0
PENA = 0

for i in range(len(index)):
    if ac[i] == 1:
        AC += 1
        PENA = PENA+pena[i]
print(AC,PENA)

### FIXED CODE ###

N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)
### BUGGY CODE ###

#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

stack = [0]
while stack:
    s = stack.pop(0)
    color[s] = 1
    for t in edge[s]:
        if color[t]==0:
            stack.append(t)
            node[t] += node[s]
    color[s]=2

for n in node:
    print(n)

### FIXED CODE ###

#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

stack = [0]
while stack:
    s = stack.pop()
    color[s] = 1
    for t in edge[s]:
        if color[t]==0:
            stack.append(t)
            node[t] += node[s]
    color[s]=2

for n in node:
    print(n)
### BUGGY CODE ###

n,m = map(int,input().split())
test=list(map(int,input().split()))
test.sort()

for i in range(m):
    b, c = map(int, input().split())
    if min(test) < c:
        test = [c if j<b and test[j]<c else test[j] for j in range(len(test))]
        test.sort()
print(sum(test))

### FIXED CODE ###

from collections import defaultdict

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

test_dict = defaultdict(int)

for j in test:
    test_dict[j] += 1

for k in range(m):
    b, c = map(int, input().split())
    test_dict[c] += b

count = 0
sum_val = 0
for l in sorted(test_dict, reverse=True):
    if n-count>0:
       sum_val += l * min(test_dict[l], n-count)
       count += min(test_dict[l], n-count)
    else:
       break
print(sum_val)
### BUGGY CODE ###

from collections import deque
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
x = deque(h[:k])
mn = max(x) - min(x)

for i in range(k,n):
    x.append(h[i])
    x.popleft()
    mn = min(mn,max(x) - min(x))
print(mn)

### FIXED CODE ###

from collections import deque
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
x = deque([])
mn = 10**9
for i in h:
    x.append(i)
    if len(x) >= k:
        mn = min(mn,x[k-1]-x[0])
        x.popleft()
print(mn)
### BUGGY CODE ###

from collections import deque
H, W, M = map(int, input().split())
grid = [[0 for _ in range(W)] for _ in range(H)]
counth = deque([0 for k in range(H)])
countw = deque([0 for k in range(W)])
for k in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  grid[h][w] = 1
  counth[h] += 1 
  countw[w] += 1

maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = deque([])
k = 0
while k < H:
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)
  k += 1
k = 0
while k < W:
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)
  k += 1
ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)

if lenh*lenw > M:
  ans += 1
else:  
  for i in range(lenh):
    h = index_h.pop()
    for j in range(lenw):
      w = index_w[j]
      if grid[h][w] == 0:
        ans += 1
        break
    else:
      continue
    break
print(ans)


### FIXED CODE ###

from collections import deque
H, W, M = map(int, input().split())
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  bomb.append(h+ w*H)
  counth[h] += 1 
  countw[w] += 1
counth = deque(counth)
countw = deque(countw)

def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            #return mid
            return True
        if guess > item:
            high = mid -1
        else:
            low = mid + 1

    #return None
    return False


maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
for k in range(H):
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)

for k in range(W):
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)

ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)


if lenh*lenw > M:
  ans += 1
else:
  bomb.sort()
  kouho = []
  for i in range(lenh):
    h = index_h.pop()
    for j in range(lenw):
      w = index_w[j]
      kouho.append(h+ H*w)
  for K in kouho:
    if binary_search(bomb, K):
      continue
    else:
      ans += 1
      break
    
print(ans)
### BUGGY CODE ###

import bisect

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

AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append([A, B])

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(1, H+1):
  for a, b in AB:
    if h - a <= 0:
      cost = b
    else:
      cost = dp[h-a] + b
    dp[h] = min(dp[h], cost)

print(dp[H])

### FIXED CODE ###

import bisect

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

AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append([A, B])

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(1, H+1):
  for a, b in AB:
    if h - a <= 0:
      cost = b
    else:
      cost = dp[h-a] + b
    dp[h] = min(dp[h], cost)

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

import queue

def count(S, K):
    c = 0
    q = queue.Queue()
    q.put((S, 0, 0))
    s = []
    while(q.empty() == False):
        x, y, z = q.get()
        if x < 0:
            break
        if x <= K and y <= K and z <= K and (x, y, z) not in s:
            s.append((x, y, z))
            c += 1
        q.put((x-1, y+1, z))
        q.put((x-1, y, z+1))
    return c




if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    K = inp[0]
    S = inp[1]
    print(count(S, K))

### FIXED CODE ###

if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    K = inp[0]
    S = inp[1]
    c = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if z >= 0 and z <= K:
                c += 1
    print(c)
### BUGGY CODE ###

value = list(input())
res = 0
while len(value) != 1 and len(value) != 0:
    if value[0] == value[-1]:
        value.pop(0)
        value.pop()
    else:
        if value[0] != "x" and value[-1] != "x":
            res = -1
            break
        value.extend("x") if value[0] == "x" else value.insert(0, "x")
        value.pop(0)
        value.pop()
        res += 1
print(res)


### FIXED CODE ###

s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)
### BUGGY CODE ###

import numpy

N = int(input())
A,B = [],[]
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)


AA = list(numpy.argsort(A))[::-1]
BB = list(numpy.argsort(B))[::-1]
aans,bans = 0,0
while True:
    a = AA.pop(0)
    aans += A[a]
    if BB[0] == a:
        BB.pop(0)
    if not BB:
        break
    b = BB.pop(0)
    bans += B[b]
    if AA[0] == b:
        AA.pop(0)
    if not AA:
        break

print(aans - bans)


### FIXED CODE ###

import numpy
import collections
N = int(input())
arr = []
for i in range(N):
    a,b = map(int,input().split())
    arr.append([a+b,a,b])

arr = sorted(arr,reverse=True)
ansa,ansb = 0 , 0
for i in range(N):
    if i % 2 == 0:
        ansa += arr[i][1]
    else:
        ansb += arr[i][2]
print(ansa - ansb)