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

import sys
input = sys.stdin.buffer.readline
N=int(input())
val=[list(map(int, input().split())) for i in range(N-1)]

arr=[set() for i in range(N)]
col=[set() for i in range(N)]
colarr=[0]*(N-1)
alen=[0]*N
coldict={}
for i in range(N-1):
    a=val[i][0]-1
    b=val[i][1]-1
    arr[a].add(b)
    arr[b].add(a)
    coldict[(a,b)]=i
colmax=0
flag=0
for i in range(N):
    alen[i]=len(arr[i])
    if len(arr[i])>colmax:
        colmax=len(arr[i])
        flag=i
colall=set(range(1,colmax+1))
coltemp=set(colall)
arrtemp=set(arr[flag])
for f in arrtemp:
    p=coltemp.pop()
    if flag<f:
        colarr[coldict[(flag,f)]]=p
    else:
        colarr[coldict[(f,flag)]]=p
    
    col[f].add(p)
    arr[f].remove(flag)
que=[set() for i in range(N)]
que[0]=que[0] | arr[flag]

for i in range(N-1):
    for t in que[i]:
        arrtemp=arr[t]
        if len(arrtemp)>0:
            C=set(range(1,alen[t]+1))
            coltemp=C^(C&col[t])
            que[i+1]=que[i+1] | arrtemp
            for f in arrtemp:
                p=coltemp.pop()
                col[f].add(p)
                arr[f].remove(t)
                if t<f:
                    colarr[coldict[(t,f)]]=p
                else:
                    colarr[coldict[(f,t)]]=p
print(colmax)
for i in range(N-1):
    print(colarr[i])

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
N=int(input())
val=[list(map(int, input().split())) for i in range(N-1)]

arr=[set() for i in range(N)]
col=[set() for i in range(N)]
colarr=[0]*(N-1)
coldict={}
for i in range(N-1):
    a=val[i][0]-1
    b=val[i][1]-1
    arr[a].add(b)
    arr[b].add(a)
    coldict[(a,b)]=i
colmax=0
flag=0
for i in range(N):
    if len(arr[i])>colmax:
        colmax=len(arr[i])
        flag=i
colall=set(range(1,colmax+1))
coltemp=1
arrtemp=set(arr[flag])
for f in arrtemp:
    p=coltemp
    coltemp+=1
    if flag<f:
        colarr[coldict[(flag,f)]]=p
    else:
        colarr[coldict[(f,flag)]]=p
    col[f].add(p)
    arr[f].remove(flag)
que=[set() for i in range(N)]
que[0]=que[0] | arr[flag]

for i in range(N-1):
    for t in que[i]:
        arrtemp=arr[t]
        if len(arrtemp)>0:
            coltemp=1
            que[i+1] |= arrtemp
            for f in arrtemp:
                while(1):
                    if coltemp not in col[t]:
                        break
                    coltemp+=1
                p=coltemp
                coltemp+=1
                col[f].add(p)
                arr[f].remove(t)
                if t<f:
                    colarr[coldict[(t,f)]]=p
                else:
                    colarr[coldict[(f,t)]]=p
print(colmax)
for i in range(N-1):
    print(colarr[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(m):
  b,c = map(int,input().split())
  for j in range(b):
    if a[j] < c:
      a[j] = c
    else:
      break
  a.sort()
print(sum(a))

### FIXED CODE ###

from operator import itemgetter
n,m = map(int,input().split())
*a,= map(int,input().split())
l = [tuple(map(int,input().split()))for _ in range(m)]
a.sort()
l.sort(key = itemgetter(1), reverse = True)
cmp = []
cnt = 0
for b,c in l:
	cmp += [c]*b
	cnt += b
	if cnt >= n:
		cnt = n
		break
cut = cnt
for i,(x,y) in enumerate(zip(a,cmp[:min(n,cnt+1)])):
	if x > y:
		cut = i
		break
print(sum(cmp[:cut] + a[cut:]))
### BUGGY CODE ###

N, P = map(int, input().split())
m = int(P**(1/N)+1)
while True:
  if P % m == 0:
    x = m**N
    if P % x == 0:
      break
  m -= 1
print(m)

### FIXED CODE ###

N, P = map(int, input().split())
if N >= 40:
  print(1)
else:
  m = int(P**(1/N))+1
  while True:
    if P % m == 0:
      x = m**N
      if P % x == 0:
        break
    m -= 1
  print(m)
### BUGGY CODE ###

N = int(input())
a = [ [str=="#" for str in input()]for _ in range(N)]
all_source = [(i,j) for j in range(N) for i in range(N)]

n =0

def f(i_,j_,A):
    global n
    n+=1
    A_copy =   [[ A[i][j] for j in range(N)]for i in range(N)]
    for i,val in enumerate([A[i_][j] for j in range(N) ]):
        A_copy[i][j_] =val
    return A_copy


def slow_solve(n,a):
    if n>5:
        return 99999
    if all(a[i][j]==True for i,j in all_source):
        return n
    min_val = 999999
    for i,j in all_source:
        a_copy = f(i,j,a)
        min_val = min(min_val,slow_solve(n+1,a_copy))
    return min_val


ans = (slow_solve(0,a))
if ans >100:
    ans = 6
if not any(a[i][j]==True for i,j in all_source):
    ans  = -1
print(ans)
#print(n)
"""


a =f(2,1,a)
a =f(2,0,a)
a =f(2,0,a)
a =f(2,1,a)
a =f(2,2,a)
print(a)

3
...
...
..#
"""

### FIXED CODE ###

N = int(input())
a = [ [str=="#" for str in input()]for _ in range(N)]
#all_source = [(i,j) for j in range(N) for i in range(N)]

n =0
ans =9999999999999
all_black_row = sum(all(a[i][j] for i in range(N)) for j in range(N))
black_count_line  = [(sum(a[i][j] for j in range(N))) for i in range(N)]
black_count_row = [(sum(a[i][j] for i in range(N))) for j in range(N)]
for line_no,blacks in enumerate(black_count_line):
    tmp_ans = N -  all_black_row
    if black_count_row[line_no] ==0:
        tmp_ans +=1
    tmp_ans += N-blacks
    ans = min(ans,tmp_ans)

if not any(black_count_line) and not any(black_count_row):
    ans = -1
print(ans)
### BUGGY CODE ###

import numpy as np
f=lambda:map(int,input().split())
R,C,K=f()
g=np.zeros((R+1,C+1),int)
for _ in range(K):
  r,c,v=f()
  g[r][c]=v
dp=np.zeros((R+2,C+2,4),int)
for i in range(1,R+1):
  for j in range(1,C+1):
    for k in range(3,-1,-1):
      if k: dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]+g[i][j])
      dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k])
      dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k])
print(max(dp[R][C]))

### FIXED CODE ###

f=lambda:map(int,input().split())
R,C,K=f()
g=[[0]*(R+1) for _ in range(C+1)]
for _ in range(K):
  r,c,v=f()
  g[c][r]=v
dp=[[0]*4 for _ in range(R+1)]
for i in range(1,C+1):
  for j in range(1,R+1):
    t=g[i][j]
    if t:
      for k in range(3,0,-1):
        dp[j][k]=max(dp[j][k],dp[j][k-1]+t)
      dp[j][1]=max(dp[j][k],max(dp[j-1])+t)
    dp[j][0]=max(dp[j][0],max(dp[j-1]))
print(max(dp[R]))
### BUGGY CODE ###

N,M=map(int,input().split())
A = list(map(int,input().split()))
min = min(A)
for i in range(M):
  B,C=map(int,input().split())
  if min < C:
    A = A + [C for j in range(B)]
    A.sort(reverse=True)
    A = A[0:N]
print(sum(A[0:N]))


### FIXED CODE ###

N,M=map(int,input().split())
A = list(map(int,input().split()))
bc = []

for i in range(N):
  bc.append( [1, A[i]])

for i in range(M):
  bc.append(list(map(int,input().split())))
bc = sorted( bc, key=lambda ii:ii[1], reverse=True)
p = []
tmp=0
for i in range(N):
  if bc[tmp][0] == 0:
    tmp +=1
  p.append( bc[tmp][1] )
  bc[tmp][0] -= 1
print( sum(p) )
### BUGGY CODE ###

from bisect import bisect_left
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]

u = [-s[A-i-1] for i in range(A)]
v = [-t[B-i-1] for i in range(B)]

for _ in range(Q):
    x = int(input())

    # x -> s -> t
    dist1, dist2 = 0, 0
    p1 = bisect_left(s, x)
    p2 = bisect_left(u, -x)
    x1, x2 = s[p1-1], -u[p2-1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(t, x1)
    p4 = bisect_left(v, -x1)
    x3, x4 = t[p3-1], -v[p4-1]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(t, x2)
    p4 = bisect_left(v, -x2)
    x3, x4 = t[p3-1], -v[p4-1]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_st = min(dist1, dist2)

    # x -> t -> s

    dist1, dist2 = 0, 0
    p1 = bisect_left(t, x)
    p2 = bisect_left(v, -x)
    x1, x2 = t[p1-1], -v[p2-1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(s, x1)
    p4 = bisect_left(u, -x1)
    x3, x4 = s[p3-1], -u[p4-1]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(s, x2)
    p4 = bisect_left(u, -x2)
    x3, x4 = s[p3-1], -u[p4-1]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_ts = min(dist1, dist2)

    print(min(dist_st, dist_ts))

### FIXED CODE ###

from bisect import bisect_left
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]+[10**15]
t = [int(input()) for _ in range(B)]+[10**15]

for _ in range(Q):
    x = int(input())

    # x -> s -> t
    dist1, dist2 = 0, 0
    p1 = bisect_left(s, x)
    x1, x2 = s[p1-1], s[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(t, x1)
    x3, x4 = t[p3-1], t[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(t, x2)
    x3, x4 = t[p3-1], t[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_st = min(dist1, dist2)

    # x -> t -> s

    dist1, dist2 = 0, 0
    p1 = bisect_left(t, x)
    x1, x2 = t[p1-1], t[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(s, x1)
    x3, x4 = s[p3-1], s[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(s, x2)
    x3, x4 = s[p3-1], s[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_ts = min(dist1, dist2)

    print(min(dist_st, dist_ts))
### BUGGY CODE ###

def my_index_multi(l, x):
    return [k for k, _x in enumerate(l) if _x == x]

h,w,m = map(int,input().split())
l_h = [0]*(h+1)
l_w = [0]*(w+1)
l_hw = [[] for _ in range(h+1)]

for _ in range(m):
    h,w = map(int,input().split())
    l_h[h] += 1
    l_w[w] += 1
    l_hw[h].append(w)

m_h = max(l_h)
m_w = max(l_w)

ans = m_h + m_w

l_h_2 = my_index_multi(l_h,m_h)
l_w_2 = my_index_multi(l_w,m_w)

for i in l_h_2:
    flag = False
    for j in l_w_2:
        if j not in l_hw[i]:
            flag = True
            break
    if flag:
        break
else:
    ans -= 1

print(ans)

### FIXED CODE ###

import sys
import itertools

input = sys.stdin.readline

def my_index_multi(l, x):
    return [k for k, _x in enumerate(l) if _x == x]

h,w,m = map(int,input().split())
l_h = [0]*(h+1)
l_w = [0]*(w+1)
l_b = set()

for _ in range(m):
    h,w = map(int,input().split())
    l_h[h] += 1
    l_w[w] += 1
    l_b.add((h,w))

m_h = max(l_h)
m_w = max(l_w)

l_h_2 = []
for i, x in enumerate(l_h):
    if x == m_h:
        l_h_2.append(i)

l_w_2 = []
for i, x in enumerate(l_w):
    if x == m_w:
        l_w_2.append(i)

ans = m_h + m_w

for i,j in itertools.product(l_h_2,l_w_2):
    if (i,j) not in l_b:
        break
else:
    ans -= 1

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

n, q = map(int, input().split())
s = input()
for i in range(q):
    tmp = s
    list_q = list(map(int, input().split()))
    list_q[0] = list_q[0] - 1
    list_q[1] = n - list_q[1]
    min_num = min(list_q)
    for j in range(min_num):
        tmp = tmp[1:]
        tmp = tmp[:-1]
    for k in range(list_q[0] - min_num):
        tmp = tmp[1:]
    for k in range(list_q[1] - min_num):
        tmp = tmp[:-1]
    tmp = tmp.split("AC")
    print(len(tmp) - 1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int,input().split())
S = list(input())[:-1]
list_Sum = [0]*(N+1)
for i in range(1, N):
    list_Sum[i+1] = list_Sum[i]
    if S[i-1] == "A" and S[i] == "C":
        list_Sum[i+1] += 1
for i in range(Q):
    l, r = map(int,input().split())
    print(list_Sum[r]-list_Sum[l])
### 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 = sorted(a)
b = sorted(b)
c = sorted(c)
memory = []
ai = x-1
bi = y-1
ci = z-1
p = 10**11
while k>0:
    ps = []
    abc = []
    for dx in range(-100,100):
        for dy in range(-100,100):
            for dz in range(-100,100):
                if not (ai+dx>=0 and ai+dx<x and bi+dy>=0 and bi+dy<y and ci+dz>=0 and ci+dz<z):
                    continue
                tmp = a[ai+dx]+b[bi+dy]+c[ci+dz]
                if p >= tmp and not (ai+dx,bi+dy,ci+dz) in memory:
                    ps.append(tmp) 
                    abc.append((ai+dx, bi+dy, ci+dz))
    p = max(ps)
    i = ps.index(p)
    memory.append(abc[i])
    print(p)
    k -= 1


### FIXED CODE ###

def main():
    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)

    T = []
    for a in A:
        for b in B:
            T.append(a + b)

    T = sorted(T, reverse=True)[:min(K, len(T))]

    res = []
    for t in T:
        for c in C:
            res.append(t + c)

    res = sorted(res, reverse=True)[:K]
    for r in res:
        print(r)

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

import math

x = int(input())

end = math.floor(x**0.2)

for i in range(1, x+1):
    if x % i == 0:
        for a in range(0,end,1):
            b = a - i
            if a**5 - b**5 == x:
                print(a, b)
                break

### FIXED CODE ###

import math

x = int(input())

divisors = []

for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        divisors.append(i)

        if i != x//i:
            divisors.append(x//i)


for i in divisors:
    for a in range(i//2,x,1):
        b = a - i
        if a**5 - b**5 == x:
            print(a, b)
            break
        elif a**5 - b**5 > x:
            break
### BUGGY CODE ###

def cul(a, b):
  return [i for i in range(1,min(a,b)+1) if a%i==0 and b%i==0]
a, b = list(map(int, input().split()))
cf = cul(a, b)
n = len(cf)
i = 1
while True:
  if n==1:
    print(1)
    break
  tmp = cf[i]
  for c in cf[i:]:
      if c==tmp:
        continue
      elif c%tmp==0:
        cf.remove(c)
  if cf[-1]==tmp:
    print(len(cf))
    break
  else:
    i += 1

### FIXED CODE ###

def prime_factorize(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    a.add(n)
    return a
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
a, b = list(map(int, input().split()))
x = gcd(a, b)
print(len(prime_factorize(x)))
### BUGGY CODE ###

N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans = r * g * b
for i in range(N-2):
    for j in range(i+1, N-1):
        if(S[i] != S[j] and 2 * j - i < N):
            if(S[i] != S[2 * j - i] and S[j] != S[2 * j - i]):
                ans -= 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans = r * g * b
for i in range(N-2):
    t = 1
    while i + 2 * t < N:
        if(S[i] != S[i+t] and S[i] != S[i+2*t] and S[i+t] != S[i+2*t]):
            ans -= 1
        t += 1
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
list=[0 for i in range(5*10**5+1)]
mod=10**9+7
list[0]=1
for i in range(len(list)-1):
  list[i+1]=list[i]*(i+1)%mod
def c(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)*pow(list[n],mod-2,mod)
  return a
def p(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)
  return a
ans=pow(p(M,N),2)
g=pow(list[M-N],mod-2,mod)
g2=pow(g,2,mod)
nn=list[N]
mm=list[M]
nmg=nn*mm*g2%mod
for i in range(1,N+1):
  ans+=nmg*pow(list[N-i],mod-2,mod)*pow(list[i],mod-2,mod)*list[M-i]*(-1)**i
  ans%=mod
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
list=[0 for i in range(5*10**5+1)]
mod=10**9+7
list[0]=1
for i in range(len(list)-1):
  list[i+1]=list[i]*(i+1)%mod
def c(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)*pow(list[n],mod-2,mod)
  return a
def p(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)
  return a
ans=pow(p(M,N),2)
g=pow(list[M-N],mod-2,mod)
g2=pow(g,2,mod)
nn=list[N]
mm=list[M]
nmg=nn*mm*g2%mod
for i in range(1,N+1):
  ans+=nmg*pow(list[N-i],mod-2,mod)*pow(list[i],mod-2,mod)*list[M-i]*(-1)**i
  ans%=mod
print(ans)
### BUGGY CODE ###

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

count = 0

for diff in range(1, N):
    for i in range(N-diff):
#        print(diff, i, i+diff)
        if i+diff < N and A[i] + A[i+diff] == diff:
            count += 1

print(count)


### FIXED CODE ###

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

count = 0

for i in range(N):
    l = i + A[i]
    r = i - A[i]
    if r in L.keys():
        count += L[r]
    if l in L.keys():
        L[l] += 1
    else:
        L[l] = 1
print(count)
### BUGGY CODE ###

s = input()
x,y = map(int, input().split())
dp = [[[0]*(len(s)*4+1) for _ in range(2)] for _ in range(2)]

dp[0][0][0] = 1
dp[0][1][0] = 1
#print(dp)
index = 0
while index < len(s) and s[index] == 'F':
  index += 1
x -= index
xy_axis = 1
dp_index = 1
i = index+1
while i < len(s):
  num = 0
  while i < len(s) and s[i] == 'F':
    num += 1
    i += 1
  #print(num)
  for j in range(-len(s), len(s)+1):
    dp[dp_index][xy_axis][j] = dp[(dp_index+1)%2][xy_axis][j-num] | dp[(dp_index+1)%2][xy_axis][j+num]
  xy_axis = (xy_axis+1) % 2
  if xy_axis == 1:
      dp_index = (dp_index+1) % 2
  i += 1

#print(dp)

if dp[(dp_index + 1) % 2][0][x] & dp[(dp_index + xy_axis) % 2][1][y] == 1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import datetime
s = input()
x, y = map(int, input().split())
#print(datetime.datetime.now())
 
num_of_f = 0
for c in s:
    if c == 'F':
        num_of_f += 1
dp = [[[False] * 32001 for _ in range(2)] for _ in range(2)]
 
dp[0][0][0] = True
dp[0][1][0] = True
# print(dp)
index = 0
while index < len(s) and s[index] == 'F':
    index += 1
x -= index
xy_axis = 1
dp_index = 1
i = index + 1
num_of_f = index
while i < len(s):
    num = 0
    while i < len(s) and s[i] == 'F':
        num += 1
        i += 1
    num_of_f += num
    for j in range(-1 * num_of_f, num_of_f + 1):
        dp[dp_index][xy_axis][j] = dp[(dp_index + 1) % 2][xy_axis][j - num] or dp[(dp_index + 1) % 2][xy_axis][j + num]
    xy_axis = (xy_axis + 1) % 2
    if xy_axis == 1:
        dp_index = (dp_index + 1) % 2
    i += 1
 
# print(dp)
 
if dp[(dp_index + 1) % 2][0][x] and dp[(dp_index + xy_axis) % 2][1][y]:
    print('Yes')
else:
    print('No')
#print(datetime.datetime.now())
### BUGGY CODE ###

n,k=map(int,input().split())
a=[]
b=[]
for i in range(n):
    ia,ib=map(int,input().split())
    a.append(ia)
    b.append(ib)
dp={0:0}
for i in range(n):
    dp2={}
    for key,val in dp.items():
        dp2[key]=val
    for key,val in dp.items():
        nk=(key|a[i])
        if nk<=k:
            if nk in dp:
                dp2[nk]=max(dp2[nk],val+b[i])
            else:
                dp2[nk]=val+b[i]
    for key,val in dp2.items():
        dp[key]=val
ret=0
for val in dp.values():
    ret=max(ret,val)
print(ret)

### FIXED CODE ###

n,k=map(int,input().split())
a=[]
b=[]
for i in range(n):
    ia,ib=map(int,input().split())
    a.append(ia)
    b.append(ib)
bit=0
while k>=(1<<bit):
    bit+=1
ret=0
for i in range(n):
    if k==k|a[i]:
        ret+=b[i]
for i in range(bit):
    if k&(1<<i):
        mask=((1<<bit)-1)^((1<<(i+1))-1)
        ok=(k&mask)|((1<<i)-1)
        tmp=0
        for j in range(n):
            if ok==ok|a[j]:
                tmp+=b[j]
        ret=max(ret,tmp)
print(ret)
### BUGGY CODE ###

# http://abc051.contest.atcoder.jp/tasks/abc051_b
K,N=map(int,raw_input().split())
count=0
for i in range(K+1):
	for j in range(K+1):
		for k in range(K+1):
			if i+j+k==N:
				count+=1
print count

### FIXED CODE ###

# http://abc051.contest.atcoder.jp/tasks/abc051_b
K,N=map(int,raw_input().split())
count=0
for i in range(K+1):
	for j in range(K+1):
		# print i,j,(N-(i+j))
		if 0<=(N-(i+j))<=K:
			count+=1
print count
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    point = [1] * (N)
    point[0] = A[0]

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

    ans = point[K - 1]
    for i in range(N - K):
        tmp = point[K + i] / point[i]
        if ans < tmp:
            print('Yes')
        else:
            print('No')
        ans = tmp


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = ['No'] * (N - K)
    for i in range(N - K):
        tmp = A[K + i] / A[i]
        if 1 < tmp:
            ans[i] = 'Yes'
    print("\n".join(ans))


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

import sys
from heapq import heappush, heappop, heapify
from collections import defaultdict

N,M=map(int, sys.stdin.readline().split())

reward=defaultdict(lambda: []) 

hq=[]
for _ in range(N):
	a,b=map(int, sys.stdin.readline().split())
	reward[a].append(-1*b)


hq=[]
ans=0
for day in range(M-1,-1,-1):
	hq+=reward[M-day]
	heapify(hq)
	if hq:
		t=heappop(hq)
		ans+=t*-1

print ans

### FIXED CODE ###

import sys
from heapq import heappush, heappop, heapify
from collections import defaultdict

N,M=map(int, sys.stdin.readline().split())

reward=defaultdict(lambda: []) 

hq=[]
for _ in range(N):
	a,b=map(int, sys.stdin.readline().split())
	reward[a].append(-1*b)


hq=[]
ans=0
for day in range(M-1,-1,-1):
	for r in reward[M-day]:
		heappush(hq,r)
	if hq:
		t=heappop(hq)
		ans+=t*-1

print ans
### BUGGY CODE ###

input()
A = list(map(int, input().split()))
A.sort()
while len(A)>0:
    A.append((A[0]+A[1])/2)
    del A[0:1]
    A.sort()
print(A)

### FIXED CODE ###

input()
A = list(map(int, input().split()))
A.sort()
while len(A)>1:
  b = A[0:2]
  c = sum(i for i in b)
  A.append(c/2)
  del(A[0:2])
  A.sort()
z = [str(a) for a in A]
z = ''.join(z)
print(z)
### BUGGY CODE ###

s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(2)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1

for i in range(1,len(s)):
  c = -1 if s[i]=='?' else int(s[i])
  for k in range(13):
    dp[i%2][k]=0
  for j in range(10):
    if c!=-1 and c!=j:
      continue
    for k in range(13):
      dp[i%2][(k*10+j)%13]+=dp[(i-1)%2][k]
  for j in range(13):
    dp[i%2][j]%=MOD

print(dp[(len(s)-1)%2][5])


### FIXED CODE ###

S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))
### BUGGY CODE ###

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

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            if i+j+l == s:
                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):
        if i+j<=s and i+j+k>=s:
            ans += 1

print(ans)