peterverebics/CodeNet_Python_118 huggingface dataset:
N,K = map(int,input().split())
Mod = 10**9+7

ans = 0

for i in range(K,N+2):
  Min = i*(i-1)/2
  Max = i*(2*N-i+1)/2
  ans += Max-Min+1
print(ans%Mod)
N, K = map(int, input().split())
MOD = 1000000007
small = 0
large = 0
res = 0

for i in range(K-1):
  small += i
  large += N-i

for i in range(K, N+2):
  small += i-1
  large += N - i +1
  gap = large - small +1
  res += gap

print(res)
n, k = map(int,input().split())

goukei = 0

for j in range(k,n+2):
    goukei += ((2*n-j)*(j+1)/2) - ((j-1)*j/2) + 1
    
print(goukei)
N,K=map(int,input().split())
a=0
for i in range(K,N+2):
  minn=0
  maxx=0
  minn=int((1/2)*(i-1)*i)
  maxx=int(((1/2)*N*(N+1))-((1/2)*(N-i)*(N-i+1)))
  
  a+=maxx-minn+1
  
print(a)
N, K = map(int, input().split())
MOD = 10**9+7

fact = [0] * (N+2)
fact[0] = fact[1] = 1

def comb_init():
	global fact
	for i in range(2, N+2):
		fact[i] = i * fact[i-1]

def comb(n, r):
	global fact
	x = fact[n] % MOD
	y = pow(fact[r], -1, MOD)*pow(fact[n-r], -1, MOD)
	return (x*y)%MOD

ans = 0
comb_init()
for i in range(K, N+2):
	ans += comb(N+1, i)
print(ans%MOD)
n,k=map(int,input().split())
sum=0
for i in range(k,n+2):
    sum=sum+((2*n-i+1)*i)/2-(i*(i-1))/2+1
print(int(sum))
a,b=map(int,input().split())

print(2**(a+1) - 2**(a-b+1))
import itertools

N,K = [int(s) for s in input().split(" ") ]

l = list(range(0,N+1))

num = 0
for i in list(range(K, N+1)):
  num += len(list(itertools.combinations(l, i)) )

print(num)
n,k = map(int,input().split())
mod = 10**9+7
answer = 0

for i in range(k,n+1):
  max_value = sum(range(n-i+1,n+1))
  lowest_value = sum(range(1,i+1))
  answer = answer + max_value - lowest_value + 1
 
print(answer % mod)
a = list(map(int,input().split()))
n = a[0]
k = a[1]

count = 0

#10^100の係数のリスト作成,bは係数の個数。
b=n+1-k+1
keisu=[0]*b
for i in range(b):
  keisu[i]=k+i

#係数毎に個数を求める,iは係数。
for i in keisu:
  mn = (i-1)*i/2
  mx = (2*(n-i+1)+(i-1))*i/2
  count += mx-mn+1
  
print(count%(10^9+7))
nk = input('').split(' ')
n = int(nk[0])+1
k = int(nk[1])

x=1
mod = 10 ** 9 + 7

for i in range(k,n+1):
    p=1
    for j in range(k,i+1):
        p*=j
        p%=mod
    p/=i
    x+=p

print(x)
n,k = map(int,input().split())
mod = (10 ** 9) + 7
count= 0
t = []
for i in range(n+1):
    t.append(i)

if n + 1 == k:
    print(1)
else:
    for i in range(k,n+1):
        r = t[:k]
        l = t[k:]
        count += sum(l)-sum(r)+1
    print(count % mod)
n,k = map(int,input().split())
ans = 0
for i in range(k,n+2):
    ans += (n-i+1)*i+1
print(ans)
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

LOW, HIGH = 0, N
ans = 0

for i in range(2, N + 2):
    LOW += i - 1
    HIGH += N - i + 1
    LOW %= MOD
    HIGH %= MOD
    if i >= K:
        ans += (HIGH - LOW + 1)
        ans %= MOD

print(ans)
n,k=map(int,input().split())

s=0
for i in range(k,n+2):
    s+=(n-i+1)*i+1
    
    
print(s)
import numpy as np
from numba import jit

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

ary = np.array([i for i in range(n+1)])
print(ary)

@jit
def lr(l,r): # 等差数列の'l'から'r'の和_mean*number
    return (l+r)*(r-l+1)//2

ans = 0
for j in range(k,n+2):
    l = lr(0, j-1)
    r = lr(n+1-j, n)
    ans += r-l+1
    ans %= 10**9+7
    
print(ans)
import numpy as np
import math

def conbination(n, r):
    bunsi = math.factorial(n) // math.factorial(n - r)
    bunbo = math.factorial(r)
    return bunsi // bunbo

N, K = (int(x) for x in input().split())
sum = 0

for i in range(K,N+2):
    sum = sum + conbination(N+1, i)
    print(N+1, i ,conbination(N+1, i))

print(sum)
N,K = map(int,input().split())
num2 = 0
for i in range(K,N+2): 
    num2 += i*N-i*(i-1)/2-i*(i-1)/2+1
print(num2%(10**9+7))
# -*- coding: utf-8 -*-
from scipy import special

N,K=(int(x) for x in input().split())
count = 0

for i in range(K, N + 1):
    y = special.comb(N + 1, i, True)
    count += y
print(count)
N,K = map(int,input().split())
counter = 0

for k in range(K,N+2): 
    counter += k*(N-k+1) + 1


print(counter)
N,K=(int(x) for x in input().split())
counter=int()
counter=0
for k in range(K,N+1):
    max=(k*N*2-k*k+k)/2
    min=(k*k-k)/2
    counter+=max-min+1
print(counter+1)
n,k=map(int,input().split())
ans=0
x=list(range(n+1))
for i in range(k,n+1):
  if n%2==1:
    if (n//2)+1 >= i:
      A=sum(x[n-i:n+1])
      B=sum(x[0:i])
    else:
      A=sum(x[i:n+1])
      B=sum(x[0:n-i])
  else:
    if n//2>=i:
      A=sum(x[n-i+1:n+1])
      B=sum(x[0:i])
    else:
      A=sum(x[i:n+1])
      B=sum(x[0:n-i+1])
  ans+=A-B+1
print(ans)
N,K=map(int,input().split())
mod=pow(10,9)+7
numbers=[a for a in range(0,N+1)]
if N+1==K:
    print(1)
else:
    answer=0
    for a in range(K,N+1):
        kotae=(sum(numbers[N-a:])-sum(numbers[:a])+1)%mod
        answer+=kotae
    print(answer%mod)
n, k = map(int, input().split())
MOD = 10**9+7
ans = 0
for i in range(k, n+2):
    ans += (2*n-k+1)*k//2-(k+1)*k//2+1
    ans %= MOD
print(ans % MOD)
n, k = map(int, input().split())
mod = 1000000007
ans = 0
for i in range(n-k+1):
  k_num = ( k*n - 2 * (k * (k-1) / 2) + 1 ) % mod
  ans += k_num
  ans %= mod

print(int(ans))

'''
1ko 0 -- n nko
2ko 1 -- 2n-1 2n-1ko
3ko 3 -- 3n-3 3n-5 ko
4ko 6 -- 4n-6 4n-11 ko
k-ko sigma 1 - (k-1) -- k*n - sigma(1 - (k-1))
(sigma 1 - (k-1)) = k * (k-1) / 2
k-ko ippannsiki -> k*n - 2 * (k * (k-1) / 2) + 1
'''
n, k = map(int,input().split())
MOD = 10**9+7
A = list(range(n+1))
ans = 0
suma = sum(A[-k+1:])
for i in range(k,n+2):
  suma += A[-i]
  ans += suma - (i-1)*i//2+1
  
print(ans%MOD)
n,k = list(map(int, input().split()))
ans = 0
sum_n = (n+1)*n/2

for i in range(k, n+2):
    tmp_b = (i)*(i-1)/2
    tmp_a = sum_n - (n-i+1)*(n-i)/2
    ans += tmp_a - tmp_b + 1
print(ans)
n,k = map(int,input().split())
mod = 10**9+7
print((-(2*(n+1)**3+3*(n+1)**2+n+1)//6)+(n*(n+1)**2+n*(n+1))//2+((n+1)**2+n+1)//2-((k-1)*n+(k-1)**2*n)//2+n+(k+2*(k-1)**3+3*(k-1)**2-1)//6-(k+(k-1)**2-1)//2-k+2 % mod)
date=input().rstrip().split(" ")
N=int(date[0])
K=int(date[1])
result=0
for i in range(K-1,N+1):
  num0=0
  num1=0
  for j in range(i):
    num0+=N-j
    num1+=j
  result+=num0-num1
print(result)
n,k=map(int,input().split())
print(((n+1)*(n+1+k)*(n-k+2)//2-(n+1)*(n+2)*(2*n+3)//6+k*(k-1)*(2*k-1)//6)%(10**9+7))
def resolve():
    from itertools import combinations

    N, K = map(int, input().split())
    s = set()
    for x in range(K, N + 1):
        for c in combinations(range(N + 1), 2):
            s.add(sum(map(int, c)))

    print(len(s))


if __name__ == '__main__':
    resolve()
n, k = map(int, input().split())
M = (n+1)*(1/2)*(n+1)*(n+2)-(1/6)*(n+1)*(n+2)*(n*2+3)+n+1
m = (n+1)*(1/2)*(k-1)*k-(1/6)*(k-1)*k*(2*k-1)+k-1
ans = M-m
print(int(ans%(10**9+7)))
n, k = map(int, input().split())

pattern = 0

for i in range(k, n + 2):
    min = (0 + i - 1) // 2 * i
    print("min",min)
    max = ((n - i) + (1 + n)) // 2 * i
    print("max",max)
    pattern += max - min + 1
    
pattern %= 10 ** 9 + 7

print(pattern)
N, K = map(int, input().split(' '))
count = 0
for n in range(K, N+2):
    count += n*(N-n+1) + 1

print(count)
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(2*n-i+1)+1
print(s%(1000000007))
a,b=(int(x) for x in input().split())
z=0
for i in range(b,a+2):
  z=(z+(a-i+1)*i+1)%(1e9+7)
print(z)
def sum_part(N, k):
  return k*(2*N-k+1)/2-k*(k-1)/2+1
  
N, K = map(int, input().split())
ans = 0
for k in range(K,N+2):
  ans += sum_part(N, k)
  
ans = ans % (10**9 + 7)
  
print(ans)
import sys
import os
import math

def file_input():
    f = open('input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()

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

    sum=0
    min=0
    max=0
    for i in range(K,N+2):
        # print(i)
        max=(N+N-i+1)*i/2
        min=(i-1)*i/2
        sum+=max-min+1
        # print("i="+str(i)+"min="+str(min)+"max="+str(max))

    print(int(sum))

if __name__ == '__main__':
    main()
n,k=map(int,input().split())
ans = 0
for i in range(k,n+2):
    ans += (2*n-i+1)*i//2 - i*(i-1)//2 + 1
print(ans)
n,K = list(map(int,input().split()))

ans = 0
for k in range(K,n+2):
  #ans += (n+1)*n//2 -(n+1-k)*(n-k)//2-k*(k-1)//2 + 1
  ans += n*k+k-k**2+1
print(ans)
n, k = (int(x) for x in input().split())

num = 0
for x in range(k, n + 1):
    print(x)
    minnum = sum(i for i in range(k))
    maxnum = sum (i for i in range(n - k + 1,n + 1))
    num += maxnum - minnum + 1

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

ans = 0

for k in range(1, K+1):
  ans += sum(range(N-k+1, N+1)) - sum(range(0, k))
  
  
if ans > 0:
  print(ans)
else:
  print(1)
n,k = list(map(int, input().split()))
ans = 0
sum_n = (n+1)*n/2

for i in range(k, n+2):
    tmp_b = (i)*(i-1)/2
    tmp_a = sum_n - (n-i+1)*(n-i)/2
    ans += tmp_a - tmp_b + 1
print(int(ans))
n, k = map(int, input().split())
sumX = (n+0)*(n+1)/2

if n+1 == k:
    print(1)
else:
    i = k
    sumA = 0
    while i <= n+1:
        sumA+=(((n+i)//2)*(n+1-i)+1)%(10**9+7)
        sumA %= (10**9+7)
        i+=1
    print(sumA)
N, K = map(int, input().split())
ans = 1

for i in range(K, N+1):
    ans += 1/2*N*(N+1) - 1/2*(N-i)*(N-i+1) - 1/2*i*(i-1) +1
print(int(ans))
import math
n, k = map(int,input().split())
total = 0
max = (n*(n+1)) //2  # 6 in ex.1
for a in range(k,n+1): # from 3 to 4 in ex.1
    high = (max-(n-a)) # 6-1 = 5, 6-0 = 6
    low = (a*(a-1)) //2  # 1, 3
    total += high - low + 1 # 5, 4
    total = total%(10**9 + 7)
total += 1 # choice all

total = total%(1000000007)
print(total)
N,K = map(int,input().split())
a =0
for i in range(K,N+2):
    a = a + ((N+N-i+1)*i/2-(i-1)*(i)/2+1)
print(int(a%10**9+7))
N, K = map(int, input().split())
MOD = 10**9 + 7
nac = [0] * (N + 2)
ninv = [0] * (N + 2)
inv = [0] * (N + 2)
nac[0],nac[1] = 1,1
inv[1] = 1
ninv[0],ninv[1] = 1,1
N = N + 1
for i in range(2, N + 1):
    nac[i] = (nac[i-1] * i % MOD)
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD
    ninv[i] = int(ninv[i - 1] * inv[i] % MOD)

ret = 0
for i in range(K,N+1):
    ret += int(nac[N] / nac[i] / nac[N - i])
print(int(ret))
n,k = map(int, input().split())
t = 0
for i in range(k, n+2):
  up = i*(2*n +1 -i)/2
  down = i*(i-1)/2
  s= up - down + 1 
  t += s
print(int(t))
N, K = map(int,input().split())
ans = 0
for i in range(K,N+2):
  ans = ans +(2*N+3-i)*i/2-i*(i+1)/2+1
print(int(ans))
n, k = map(int, input().split())
if n < k:
    print(1)
    exit(0)

MOD = pow(10, 9) + 7
count = 0
while n+1 >= k:
    minv = k * (k-1) // 2
    maxv = ((n+1) * n // 2) - ((n-k) * (n-k+1) // 2)

    count += (maxv - minv + 1)
    count %= MOD
    k += 1

    print(count)
n,k = map(int,input().split())
ans = 0

for i in range(k,n+2):
    tmpans = 0
    s1 = (0+i-1)*i/2
    s2 = (n-i+1 + n)*i/2
    tmpans = s2-s1+1
    ans += tmpans
print(max(1,ans%(10**9+7)))
n,k = map(int, input().split())
ls = [j for j in range(n+1)]
a = 1
for i in range(k,n+1):
    if (n + 1) -2*i >= 0:
        a += sum(ls[n+1-i:]) - sum(ls[:i]) + 1
    else:
        a += sum(ls[i:]) - sum(ls[:n-i+1]) + 1
print(a)
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

ans = 0
for i in range(k,n+1):
    tmp = combinations_count(n+1,i)
    ans += tmp
    print(tmp)

print(ans%(10**9+7))
N,K=map(int,input().split())
num_list=[x for x in range(3+1)]
answer=0
count=N-K+2
for y in range(K,N+2):
    min=sum(num_list[:y])
    max=sum(num_list[-y:])
    answer+=max-min+1

print(answer%(10**9+7))
n, k = map(int, input().split())

MOD = 10**9+7

dp = [0] * (n+1)

dp[1] = n+1

for i in range(2, n+1):
    dp[i] = dp[i-1] * (n + 1 - (i-1)) % MOD * pow(i, MOD-2, MOD) % MOD

print(sum(dp[k:]) % MOD)
n,k = list(map(int, input().split()))
ans = 0
sum_n = (n+1)*n/2

for i in range(k, n+2):
    tmp_b = (i)*(i-1)/2
    tmp_a = sum_n - (n-i+1)*(n-i)/2
    ans += tmp_a - tmp_b + 1
    print(tmp_a - tmp_b + 1)
print(ans)
import math
n,k = map(int,input().split()) 
ans = 0

bikkuri_n1 = math.factorial(n+1) % (10**9+7)

bikkuri_k = math.factorial(k) % (10**9+7)
for i in range(k,n+2):
  
    small = i*(i-1)//2
    big = i*(2*n-i+1)//2
    
    ans += big-small+1
    
  
    
print(ans)
import sys

input = sys.stdin.readline
MOD = 1000000007

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


res = 0

if N <= K:
    print(1)
    exit()

_min=0
_max=0
for i in range(K):
    _min += i
    _max += (N-i)

res = 0

for i in range(K,N+2):
    if i != K:
       _min+=i-1
       _max+=(N+1 -i)

    #print(_min,_max)
    
    res +=(_max-_min+1)

print(res%MOD)
import math
def comb(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
n,k=map(int,input().split())
count=0
for i in range(k,n+2):
    count+=comb(n+1,i)
    if (n+1-i)<=2 and 2<=i:
        if (n+1-i)%2==0:
            count=count-comb((n+1)//2,i//2)+1
        else:
            count=count-comb(n//2,i//2)+1
print(count)
N, K = map(int, input().split())
ans = 0
for i in range(K,N+2):
    ans += N*i -i**2 +i +1
print(ans)
# -*- coding: utf-8 -*-
import numpy as np
import itertools
import time
n, k = list(map(int, input().split()))

result = 0
for _k in range(k, n + 2):
    # print('選ぶ数', _k)
    min_value = ((_k-1)+1)*(_k-1)/2
    max_value = (n + n - (_k-1)) * (_k)/2
    # print(min_value, max_value)
    result += max_value - min_value + 1
print(int(result))
n, k = map(int, input().split())
sum = 0
for i in range(k, n + 2):
    sum += i * (n + 1) - ((i + 1)**2 - 1)

print(sum % (10**9 + 7))
n, k = map(int, input().split())

n += 1
ans = 0
for i in range(k, n+1):
    p = i*(2*n - (i-1)) // 2
    m = i*(2 + i-1) // 2
    ans += p - m + 1
    ans %= 10**9+7
    # print(p, m, ans)
print(ans % 10**9+7)
n,k=map(int,input().split())
cc=0
for i in range(k,n+2):
  cc+=n*i-2*int(i*(i-1)/2)+1
print(cc)
N,K=map(int,input().split())
M=N+1
L=K-1
print((M*(M*M+5)/6+L*(L*L*2+L*3-5-M*(L+1)*3)/6)%(10**9+7))
N,K = map(int,input().split())
ans = 0
temp_max = N
temp_min = 0
for i in range(2,N+2):
  temp_max += N-i+1
  temp_min += i-1
  if i >= K:
    ans += (temp_max - temp_min + 1)
print(ans%(10**9+7))
n,k = map(int,input().split())

# k個選ぶときからn-1個選ぶとき
ans = 0
for i in range(k, n+1):
  min = 1/2 * (i-1) * i
  max = 1/2 * (n-i+1+n) * (n-(n-i+1)+1)
  ans += max - min + 1
print(int(ans + 1))
N, K = map(int, input().split())
MOD = 10**9 + 7
nac = [0] * (N + 2)
ninv = [0] * (N + 2)
inv = [0] * (N + 2)
nac[0],nac[1] = 1,1
inv[1] = 1
ninv[0],ninv[1] = 1,1
N = N + 1
for i in range(2, N + 1):
    nac[i] = (nac[i-1] * i % MOD)
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD
    ninv[i] = ninv[i - 1] * inv[i] % MOD

ret = 0
for i in range(K,N+1):
    ret += (nac[N] *( ninv[i] * ninv[N - i] % MOD) % MOD) % MOD
print(int(ret))
import itertools

n, k = map(int, input().split())
inicial = (10**100) % (10**9 + 7)
listN = list(range(n+1))
count = 0

for i in range(k, n+2):
    count += len(list(itertools.combinations(listN, i)))
    
print(count)
N,K = map(int,input().split())
ans = 0
for i in range(K,N+1):
    ans += N*K-((K*(K-1))/2)-K+2
print(ans)
n, k = map(int, input().split())
s_1 = 0
s_2 = 0
s_3 = 0
mod = 1000000007
ans = 0
for i in range(k, n + 2):
    s_1 = (n + n + 1 - i) * i / 2
    s_2 = (0 + i - 1) * i / 2
    s_3 += s_1 + 1 - s_2
ans = s_3 % 1000000007
print('{:g}'.format(ans))
s=list(map(int,input().split()))
mod=10**9+7
a=s[0]
b=s[1]
if a==1:
  print(1)
else:
  e=0
  if b==1:
    b+=1
    e+=(a+1)
  c=sum(range(0,b))
  d=sum(range(a+1-b,a+1))
  for i in range(b,a+2):
    if i!=b:
      c+=(i-1)
      d+=(a-i+1)
    e+=(d-c+1)
    e%=mod
  print(e)
p = 10 ** 9 + 7
n, k = map(int, input().split())
n += 1
upper = 1
lower = 1
for i in range(1, n - k + 1):
    upper *= n - i + 1
    upper %= p
    lower *= i
    lower %= p
print(upper * pow(lower, p - 2, p) % p)
N, K = map(int, input().split())
mod = 10**9 + 7 
ans = 0 
for i in range(K, N + 2): 
        l = N - i + 1 
        ans += ((N + l) * (N - l + 1) // 2) - ((i - 1)*i // 2)
print(ans % mod)
N, K = map(int, input().split())

sum = 0
for i in range(N - K + 1):
    sum += K * (N - K + 1) + 1
print(sum % (pow(10, 9) + 7))
n,k=map(int,input().split())
count=0
for i in range(n+1):
    if i<k:
        continue
    elif i>=k:
        mini=i*(i-1)//2
        a=n*(n+1)//2
        b=(n-i)*(n-i+1)//2
        maxi=a-b
        total=maxi-mini+1
        count+=total
print(count%(10**9+7))
n,k=map(int,input().split())
ans=0
mod=10**9+7
for i in range(k,n+2):
  mi=(i*(i-1)//2)%mod
  ma=((2*n-i+1)*i//2)%mod
  ans+=(ma-mi+1)%mod
print(ans)
n,k=map(int,input().split())
sum=0
for i in range(k,n+2):
  sum=sum+i*(n-i+1)+1
print(sum)
n, k = map(int, input().split())
MOD = 1e9+7

a = [0] * (n+2)
s = [0] * (n+2)
a[1] = (n+1)
s[1] = a[1]
for i in range(2,n+2):
    a[i] = a[i-1] + n - 2 * (i-1)

    add = (s[i-1] + a[i]) % MOD
    if add < 0:
        add += MOD

    s[i] = add

print(int(s[n+1] - s[k-1]))
n,k = map(int, input().split())

ans = 0
for i in range(k, n+2):
    print(i)
    smin = int(0.5*i+(2*0+(i-1)*1))
    smax = int(0.5*(n+2-i)+(i-1)*1)
    s = smax - smin
    ans+=s
    ans%=7+10**9
print(ans)
N, K = map(int, input().split())
 
MAX = (N+1)*(N+2)//2
MIN = (K-1)*(K)//2
 
print((MAX-MIN)/(10**9+7))
n,k = map(int,input().split())

ans = 0
for i in range(n-k+1):
    a = 0
    b = 0
    for j in range(i+1):
        a += n+1-j
        b += i
    ans += a-b
    #print(ans)

print(ans+1)
def main():
    a, b = input().split()
    a = int(a)
    b = int(float(b) * 100)
    print(a * b // 100)


if __name__ == '__main__':
    main()
if __name__ == "__main__":
    n, k = map(int, input().split())
    m = 10 ** 9 + 7

    f = (n + 1) * ((n + 1) * (n + 2) % m - (k - 1) * k % m) % m / 2
    s = n - k + 2
    t = ((n + 1) * (n + 2) % m * (2 * n + 3) % m - (k - 1) * k % m * (2 * k - 1)% m) % m / 6

    ans = f + s - t

    print(int(ans))
N,K=map(int,input().split())
wa=0
for i in range(N+1-K):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa+1


wa=wa+1
wa=wa%(10**9+7)
print(wa)
n, k = map(int, input().split())
ans = 0

for i in range(k, n+2):
  minsum = sum(range(0, i))
  maxsum = sum(range(n+1-i ,n+1))
  print(i,minsum, maxsum)
  ans += maxsum - minsum + 1

print(ans)
n,k=[int(i) for i in input().split()]

s = 0
for i in range(k, n+2):
    s = s + n*i - i*(i-1) + 1
q = s % (10^9+7)
print(q)
n, k = map(int, input().split())
ans = 0

for i in range(k - 1, n + 1):
    ans += ((i + 1)*(n + n - i)//2)
for i in range(k - 1, n + 1):
    ans -= (i + 1)*i//2
ans += n + 2 - k
print(ans)
n,k=map(int,input().split())

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

result = 0
for j in range(k, n+2):
    result += cmb(n,j,p)

print(result)
N,K=map(int,input().split())
ans=0
for i in range(K,N+2):
    c=(i-1)*i/2
    d=(N+N-i+1)*i/2
    ans+=int(d-c+1)
print(ans)
import itertools

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

ans = 0

for k in range(K, N):
  ans += len(set(map(sum, itertools.combinations(range(N), k))))

print(ans)
ls = list(map(int,input().split()))

input_n = ls[0]

input_k = ls[1]


sum_num = 0

sum_min = 0

sum_max = 0

for num in range(1, input_n + 2):
    sum_min = sum_min + num - 1
    sum_max = sum_max + input_n + 1 - num
    if num >= input_k :
        sum_num = sum_num + sum_max - sum_min + 1
    # print(num)
    
    # print(sum_min)
    # print(sum_max)
    # print(sum_num)

print(sum_num % (10^9 + 7))
import numpy as np

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
ref = np.array(list(range(n + 1)), dtype='int64')

max_sum = np.sum(ref[-k + 1:])
min_sum = np.sum(ref[:k - 1])
if k == 1:
    max_sum = ref[n]
ans = 0

for i in range(k, n + 2):
    min_sum += ref[i - 1]
    max_sum += ref[-i]
    ans += max_sum - min_sum + 1
    ans %= MOD

print(ans)
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
for k in range(K, N + 2):
    ans = (ans + k * (2 * N - k + 1) / 2 - (k - 1) * k / 2 + 1)
    ans %= MOD
print(ans)
if __name__ == '__main__':
    a,b= map(int,input().split())
    maxnum =0
    minnum =0
    diff = 10**9 +7

    for i in range(0,b):
        minnum+=i
    for i in range(0,b):
        maxnum+=(a-i)
    ans = maxnum-minnum
    ans = int(ans*(ans+1)/2)
    ans = ans %diff
    if ans ==0:
        ans =1

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

ans = 0
MOD = 10**9 + 7


def sum(a, b):
    return (b - a + 1) * (a + b) / 2


for i in range(K, N + 2):
    min = sum(0, i - 1)
    max = sum(N - (i - 1), N)
    ans += max - min + 1

print(ans % MOD)
from sys import stdin
import math

N, K = list(map(int, stdin.readline().rstrip().split()))

n = [i for i in range(0, N+1)]

amount_min = 0
for j in range(K):
    amount_min += n[j]

#print(amount_min)

amount_max = 0
for k in range(N+1):
    amount_max += k

#print(amount_max)

count = 0
if N + 1 == K:
    count = 1
elif N == K:
    count = 3
else:
    count += 1
    count += 1
    count += 2 * (amount_max - amount_min - 1)

#print(count)
print(count % (10**9+7))
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
for k in range(K, N + 2):
    ans = (ans + k * (2 * N - k + 1) / 2 - (k - 1) * k / 2 + 1) % MOD
print(ans)
import math
nk = list(map(int,input().split()))
n, k = nk[0], nk[1]
def wa(a,b):
    return (b*(b+1)//2)-(a*(a-1)//2)
s = [0] * (n+1)
s[0] = 0
for i in range(n):
    s[i+1] = s[i] + n*(i+2) - 2*wa(0,i+1) + 1
ans = s[n] - s[k-2]
while ans >= 10**9 + 7:
    ans -= (10**9 + 7)
print(ans)
n, k  = map(int, input().split())
x = 0
for k in range(k, n+2):
  a =k * (k-1)//2
  b = k * (2*n+1-k)//2

  x += b- a +1
  
  
  
print(x)
N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    sum_min = 1/2*K*(K-1)
    sum_max = 1/2*K*(2*N-K+1)
    diff += sum_max - sum_min
    K+= 1
diff = diff % mod
print(int(diff))
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce
from functools import lru_cache

# input = sys.stdin.readline

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

@lru_cache(maxsize=None)
def get_factorial(num):
    return(math.factorial(num) % (10**9 + 7))
  
cnt = 0
c = get_factorial(n+1)
for i in range(k, n+2):
    cnt += c / (get_factorial(i) *  get_factorial(n+1-i))
    print(cnt)
print(int(cnt))
n,k=map(int,input().split())
res=0
for i in range(k,n+2):
  res+=(2*n-i+1)/2*i-(i/2*(i-1))+1
  print(res)
print("{}".format(int(res%(10**9+7))))
a = list(map(int,input().split()))
N = a[0]
k = a[1]
n = N-k+2
w = int((-n*(n+1)*(2*n+1)+(N-2*k+3)*n*(n+1))/2+n*((k-1)*(N-k+2)+1))
print(w)
import itertools

n, k = map(int, input().split())
arr = [i for i in range(n+1)]

a = 0
for i in range((n+1)-(k-1)):
    tmp = set()
    for group in itertools.combinations(arr, i+k):
        tmp.add(sum(group))
    print(tmp)
    a += len(tmp)

print(a)
N,K=map(int,input().split())
mod = (10**9) +7

def counts(n,k):
    if k==1:
        return N
    else:
        return k*N -k*(k-1) +1

total =0
for k in range(K,N+2):
    total += int(counts(N,k))

print(total%mod)
a = list(map(int,input().split()))
n = a[0]
k = a[1]

count = 0

#10^100の係数のリスト作成,bは係数の個数。
b=n+1-k+1
keisu=[0]*b
for i in range(b):
  keisu[i]=k+i

#係数毎に個数を求める,iは係数。
for i in keisu:
  mn = (i-1)*i/2
  mx = ((n-i+1)+n)*i/2
  count += (mx-mn+1)
  count %= (10^9+7)
  
print(int(count))
import math
n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
for i in range(k, n + 2):
    ans += (- i **2  + (n + 1) * i + 1 ) %mod
print(ans)
n,m = map(int, input().split())
x = n+1
ans = 0
from itertools import combinations
for i in range(m,n+2):
    ans = ans + len(list(combinations(range(x),i)))
print(ans)
N,K=map(int,input().split())
r=0
md=10*9+7
for k in range(K,N+2):
  r += ((N+N-k+1)*k//2)%md
  r -= (k*(k-1)//2)%md
  r += 1
  
print(r%md)
import numpy as np


mod = 10 ** 9 + 7

n, k = map(int, input().split())
k_np = np.arange(k, n + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = n * k_np - low
cnt = high - low + 1
print(cnt.sum() % mod)
def main():
    nk = list(map(int, input().split()))

    c = 0
    mii = sum(range(nk[1]))
    maa = sum(range(nk[0]-nk[1]+1, nk[0]+1))
    for i in range(nk[1], nk[0]+2):
        c += maa-mii+1
        mii += i
        maa += nk[0]-i

    print(c)

if __name__ == '__main__':
    main()