peterverebics/CodeNet_Python_118 huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

MOD = 10 ** 9 + 7


def sum_up_to_n(n):
    return n * (n + 1) // 2


def main():
    N, K = [int(x) for x in input().split()]

    ans = 0
    b = sum_up_to_n(N)
    for i in range(K, N + 2):
        a = sum_up_to_n(i - 1)
        aa = sum_up_to_n(N - i)
        ans += (b - aa) - a + 1
        ans = ans % MOD

    print(ans)


if __name__ == '__main__':
    main()
N,K=map(int,input().split())
s=0
while K<=N+1:
    s+=(K*(N-K+1)+1)%(10**9+7)
    s%=(10**9+7)
    K+=1
print(s)
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(int(ans%Mod))
n,k=map(int,input().split())

counter=0
for i in range(k,n+2):
  r=(2*n-i+1)*(i)//2
  l=i*(i-1)//2
  counter+=(r-l+1)
print(counter%(10**9+7))
n, k = map(int, input().split())

cnt = 0
mod = 10 ** 9 + 7

for i in range(k, n + 2):
    cnt += i * n - (1 + i - 1) * (i - 1) + 1
    cnt %= mod
print(cnt)
n, k= map(int, input().split())
s = 0
for i in range(k,n+2):
	s  += i*(2*n-(i-1))/2 - i*(i-1)/2 +1
s = int(s%(10**9+7))
print(s)
N, K = map(int, input().split())

ans = 0
first = sum(list(range(K)))
end = sum(list(range(N, N-K, -1)))
for i in range(K, N+2):
  if i != K:
    first += (i-1)
    end += (N-i+1)
  ans += (end - first + 1)

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

ans=0

for i in range(k,n+2):
    ans+=(n+1-i)*i+1

ans%=10**9+7
print(ans)
N,K=map(int,input().split())
MOD=10**9+7

def calc(a):
  smallest=(a-1)*a//2
  largest=(2*N-a+1)*a//2
  return largest-smallest+1

ans=0
for i in range(K,N+2):
  ans+=calc(i)
ans%=MOD  
print(ans)
N, K = map(int,input().split())
mod = 10**9+7
ans = 0
for i in range(K,N+2):
    ans += i*(N+1-i)+1
print(ans%mod)
n,k=map(int,input().split())
L=list(range(n+1))

cnt=0
ans=0

def calc(i):
    smallest=(i-1)*i//2
    largest=(2*n-i+1)*i//2
    return largest-smallest+1


for i in range(k,n+2):
    cnt+=calc(i)
    cnt%=(10**9+7)
    

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

for i in range(k, n+2):
  a = 0.5* i* (i-1)
  b = 0.5* n* (n+1) - 0.5* (n-i)* (n-i+1)
  ans += int(b-a+1)
  
print(ans%(10**9+7))
n, k = list(map(int, input().split()))
cnt = 0

for i in range(k, n + 2):
    minimum = (i - 1) * i // 2
    maximum = (2 * n - i + 1) * i // 2
    cnt += maximum - minimum + 1
    cnt %= 10 ** 9 + 7

print(cnt)
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 * i * (2 * (n + 1 - i) + (i - 1) * 1))
    s = smax - smin + 1
    # print("s", s)
    ans += s
    ans = ans % (7 + 10 ** 9)
print(ans)
N , K = map(int,input().split())

N = N + 1
S = 0
for i in range(K , N + 1) :
  t = (i * (N - i) + 1) % (10**9+7)
  S += t
print(S % (10**9+7))
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]

    res = 0

    for i in range(K, N+2):
        a = (i-1)*i//2
        c = N-i
        b = N*(N+1)//2 - c*(c+1)//2
        # print(a, b)
        res += b - a +1

    print(res % (10**9 +7))

if __name__ == "__main__":
    resolve()
N, K = map(int, input().split())
r = 0
for k in range(K, N+1+1):
  r = (r+(2*N-k+1)*k//2-(k-1)*k//2+1)%1000000007
  #print(r)
print(r)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,k = iim()
ans = 0
mod = 1000000007
for i in range(k,n+2):
    ans += n*(n+1)//2 - i*(i-1)//2 - (n-i)*(n-i+1)//2 + 1
    ans = ans%mod

print(ans)
def main():
    MOD = 10**9+7
    N, K = [int(x) for x in input().split()]
    ans = 0
    for k in range(K, N+2):
        ans += k*N - k*(k-1)+1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  n += 1
  cnt = 0
  for ik in range(k, n+1):
    cnt += ik * (n - ik) + 1
    cnt %= (10**9 + 7)
  print(cnt)

if __name__=='__main__':
  main()
n, k = [int(m) for m in input().split()]
mod = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    ans += (n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2) - i * (i - 1) // 2 + 1
    ans %= mod

print(ans)
import numpy as np

n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7
arr = np.arange(n+1)
a = np.cumsum(arr)
b = np.cumsum(arr[::-1])

for i in range(k, n+1+1):
    ans += b[i-1] - a[i-1] + 1
print(ans%mod)
n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
a = [i for i in range(n+1)]  # 1~nまで
ans = 0
mod = pow(10, 9)+7
sum_min = sum(a[:k])  # 前からkコの和
sum_max = sum(a[-k:])  # 後ろからkコ
for i in range(k, n+1):
    ans += sum_max-sum_min+1
    ans %= mod
    sum_min += a[i]  # 足してく
    sum_max += a[-i-1]
ans += 1  # 全部選んだ時
print(ans % mod)
N,K=map(int,input().split())
N = N+1
a = N - K
ans = 0

MM = 10**9 +7

for i in range(K,K+a):
  start = int( ( (i)*(i-1)/2 ) % MM )
  fin = int( ( (N+(N-1)-i)*(i)/2+1 ) % MM )
  ans = int( ( ans + (fin - start) ) % MM )

ans += 1
print(ans)
# from math import pi
# a = int(input())
# # a = [int(i) for i in input().split()]

# print(2*pi*a)

n, k = [int(i) for i in input().split()]
res = 0
for i in range(k, n + 2):
    res += (2 * n - 2 * i + 2) * i // 2 + 1


print(res%(10**9+7))
mod = 10**9+7
mod2 = 998244353
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
n,k = map(int,input().split())
ans = 0
for i in range(k,n+2):
  ans += n*(n+1)//2-(n-i)*(n-i+1)//2-i*(i-1)//2+1
  ans %= mod
print(ans)
N, K = [int(a) for a in input().split()]
numbers = list(range(0, N+1))
MOD = 1000000007

ans = 0
for k in range(K, N+2):
    min_ = (numbers[0] + numbers[k-1])*k//2
    max_ = (numbers[(N+1)-k] + numbers[-1])*k//2
    ans = (ans + max_ - min_ + 1) % MOD

print(ans)
N,K = map(int,input().split(' '))
num_list = list(reversed(range(N+1))) 
sum_list_reversed = [num_list[0]]
for i in range(1,N+1):
    sum_list_reversed.append(sum_list_reversed[i-1] + num_list[i])
num_list = list(range(N+1))
sum_list = [num_list[0]]
for i in range(1,N+1):
    sum_list.append(sum_list[i-1] + num_list[i])
ans = 0

for i in range(K-1,N+1):
    current_sum = sum_list_reversed[i] - (sum_list[i] -1)
    ans += current_sum
    ans = ans%(10**9+7)
print(ans)
# Problem D - Sum of Large Numbers

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

# initialization
mae_list = [i for i in range(N+1)]
ushiro_list = [i for i in range(N, -1, -1)]
ans = 0
MOD = 10**9 + 7

# count
for i in range(1, N+1):
    mae_list[i] += mae_list[i-1]
    ushiro_list[i] += ushiro_list[i-1]

for k in range(K-1, N+1):
    ans += (ushiro_list[k] - mae_list[k] + 1)%MOD

# output
print(ans%MOD)
if __name__ == "__main__":
    n, k = map(int, input().split())
    n += 1
    sum_ = 0
    sums = [0]

    for i in range(1, n):
        sums.append(sums[-1] + i)

    for i in range(k, n + 1):
        if i == n:
            sum_ += 1
            continue
        up = (sums[-1] - sums[-i - 1])
        low = sums[i - 1]
        tmp = up - low + 1
        sum_ += tmp

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

ans = 0

for i in range(k, n+2):
    ans += (i * (2 * n - i + 1) / 2) - (i * (i - 1) / 2) + 1


print(int(ans % (10 ** 9 + 7)))
N, K = map(int, input().split())
MOD = 10**9 + 7

cum = [0]
for x in range(1, N+1):
    cum.append(cum[-1]+x)

ans = 0
for k in range(K, N+2):
    ans += (cum[N] - cum[max(0,N-k)]) - cum[k-1] + 1
    ans %= MOD

print(ans)
n, K = map(int, input().split())
MOD = 10**9+7
ans = 0
for k in range(K, n+2):
    L = k*(k-1)//2
    R = (n+n-k+1)*k//2
    ans += (R-L+1)%MOD
    ans %= MOD
print(ans)
N,K = (int(x) for x in input().split())
N1 = N + 1
K1 = K - 1
setN = (((N1*N1*(N1+1))//2) - (N1*(N1+1)*(2*N1+1)//6) + N1) % 1000000007
setK = (((N1*K1*(K1+1))//2) - (K1*(K1+1)*(2*K1+1)//6) + K1) % 1000000007
print((setN-setK)%1000000007)
def main(N=None, K=None):
    if not N:
        N, K = map(int, input().split())
    ans = (K-N-2)*(2*K*K-K*(N+2)-N*N-N-6)//6
    ans %= 10**9+7
    print(ans)
    return ans


if __name__ == "__main__":
    # assert main(3, 2) == 10
    # assert main(200000, 200001) == 1
    # assert main(141421, 35623) == 220280457
    main()
N, K = map(int, input().split())
ans = 0
MOD = 10**9+7
f = lambda x:x*(x+1)//2
for i in range(K, N+2):
    ans += f(N)-f(N-i)-f(i-1)+1
    ans %= MOD
print(ans)
n,k = (int(num) for num in input().split())
MOD = 10 ** 9 + 7
ans = 0
for i in range(k,n+2):
    ans = (ans + i*(n-i+1) + 1) % MOD
    
print(ans % MOD)
N, K = map(int, input().split())
""""""
ans = 0
for k in range(K, N+2):
    mx = (2*N-k+1)*k/2
    mn = k*(k-1)/2
    ans += (mx-mn+1)
ans = ans %(10**9+7)
print(int(ans))
N,K = map(int,input().split())
n = [i for i in range(N+1)]
M,m = sum(n[-K:]),sum(n[:K])
c = M-m+1
for i in range(K+1,N+2):
  M += n[-i]
  m += n[i-1]
  c += (M-m+1)
print(c%(10**9+7))
n,k= map(int,input().split())
ans=0
for i in range(k,n+2):
  ans +=i*n-i*(i-1)+1
print(ans%(10**9+7))
N, K = list(map(int, input().split()))
ans = 0
for i in range(K, N+2):
    ans+=(((N*i%(10e8+7)+i%(10e8+7)-i*i%(10e8+7))+1))
print(int(ans%(10e8+7)))
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)))
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(int(ans))
#ABC163d
n, k = input().split()
n = int(n)
k = int(k)

mod = 10**9 + 7
# s = (10**100%mod)*(k%mod) # 10**100*kをmod化
ips = []
for i in range(k,n+2):
    t = i*n - (i-1)*i + 1
    ips.append(t)
print(sum(ips)%mod)
n,k = map(int,open(0).read().split())
mod = 10**9+7
ans = 0
for i in range(k,n+2):
  ans += 1 + i*(n+1-i)
print(ans%mod)
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline

N, K = map(int, read().split())
mod = 10 ** 9 + 7
answer = 0
cnt = list(accumulate(range(N + 1)))
for i in range(K, N + 1):
    tmp = cnt[N] - cnt[N - i] - cnt[i] + 1
    answer = (answer + cnt[N] - cnt[N - i] - cnt[i - 1] + 1) % mod

answer += 1
print(answer)
# coding: utf-8

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

ans = 0
for i in range(k, n+2):
    mini = (0+(i-1))*i/2
    maxi = ((n)+(n-i+1))*i/2
    ans += maxi-mini+1
    
print(int(ans%z))
N, K = map(int, input().split())

MINL = [0]
for i in range(1, N+1):
    MINL.append(i + MINL[i-1])

MAXL = [N]
j = 1
for i in range(N-1, -1, -1):
    MAXL.append(i + MAXL[j-1])
    j += 1

ans = 0
for i in range(K-1, N+1):
    ans += MAXL[i] - MINL[i] + 1
    ans = ans % (10 ** 9 + 7)
print(ans)
import math

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

a, b = map(int, input().split())

sum = 0
for i in range(b, a+1):
  sum += combinations_count(a+1, i)
  
print(sum)
import itertools
n, k = map(int, input().split())
data = list(x for x in range(n+1))
ans = 0
if n <= k :
    ans +=1
else:
    for i in range(k, n+1):
        j = list(itertools.combinations(data, i))
        ans += len(j)

print(ans)
# coding: utf-8
# Your code here!

line= list(map(int,input().split()))
N = line[0]
K = line[1]
#0~Nの連続した整数から
#kこ以上選ぶ
answer = 0
for i in range (K,N+2):
    minit = i*(i-1)/2
    maximum = (2*N-i+1)*i/2
    
    num = maximum-minit+1
    answer += num
    
print(int(answer))
if __name__ == '__main__':
    a,b= map(int,input().split())
    maxnum =0
    minnum =0

    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)

    print(ans)
n,k=map(int,input().split())
a=[0]*200099
for i in range(200099):
  a[i]=i
s=1
for i in range(n,k-1,-1):
  s+=sum(a[i:n+1])-sum(a[0:n-i+1])+1
print(s)
N,K = map(int, input().split())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7))
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))
from scipy.special import comb
a, b = map(int, input().split())
 
def coun(x, y):
  a = comb(x, y, exact=True)
  return a
 
if(a+1== b):
  print(1)
else:
  count = 0
  for i in range(a-b+2):
    count += coun(a+1,i+b)
  print(count)
list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

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

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(s)
N,K=map(int,input().split())
ans=0
for k in range(K,N+2):
  ans+= (k*(2*N+1-k)//2) - (k*(k-1)//2) +1
print(ans)
n,k = map(int,input().split())
if(k >= n):
    print(1)
else:
    t = 0
    for i in range(k,n+2):
        d = n - i
        s1 = i * (i - 1) // 2
        s2 = n * (n + 1) // 2 - d * (d + 1) // 2
        t += s2 - s1 + 1
        t %= 10**9+7
    print(t)
# n, k = 0
n, k = map(int, input().split())
# 0,1,2,3,,,,,,n
# k個選んだ時の最小値と最大値の差をk,k+1,k+2,,,,nと積算する

iResult = 0  # 答え
for i in range(k, n + 2):
#	print(i)
	#	min = 0
	#	max = 0
	#	for j in range(0, i):
	#		print('    ' + str(j))
	#		min = min + j
	#		max = max + n - j
	iResult = iResult + i * (n - i + 1) + 1

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

ans = 0

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

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

w = list(range(n + 1))
a = [0 for _ in range(n)]

mx = sum(w[(n // 2) + 1:]) - sum(w[:(n // 2) + 1]) + 1
a[(n // 2)] = mx

cnt = 1
prev = mx
for i in range((n // 2) - 1, -1, -1):
    a[i] = prev - cnt
    a[n - i - 1] = prev - cnt
    cnt += 2
    prev = a[i]

print(sum(a[k - 1:]) + 1)
if __name__ == "__main__":
    # 1 <= N <= 2 * 10^5
    # 1 <= K <= N + 1
    N, K = map(int, input().split(" "))

    total_num = 0
    for k in range(K, N+2):
        # NからN-(k-1)までの和
        sum_max = k*(2*N - k + 1) / 2
        # 0から(k-1)までの和
        sum_min = k*(k-1) / 2
        # 個数を計上
        total_num += sum_max - sum_min + 1
        total_num %= 1000000007
    
    print(total_num)
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n+n-(i-1))/2+1-(i*(i-1))/2
print(s%(1000000007))
import itertools

n,i = map(int,input().split())
a = [i + 10**100 for i in range(n+1)]
#a = [i + 10**1 for i in range(n+1)]
ans = {}
s = 0
m = i
print(i,n)
while i <= n+1:
  wrk = list(itertools.combinations(a,i))
  for l in wrk:
    s = sum(l)
    if s not in ans:
      ans[s] = int(1)
    else:
      ans[s] += int(1)
  i += 1
print(len(ans))
N , K =map(int,input().split())
MOD=10**9+7
ans=0
if N<=K:
    print(1)
else:
    tmp_low = sum(range(K))
    tmp_high = sum(range(N-K+1,N+1))
    r=tmp_high-tmp_low+1
    ans+=r
    ans%=MOD
    for sel in range(K+1,N+2):
        tmp_low += sel-1
        tmp_high += N-sel+1
        r= tmp_high-tmp_low+1
        ans+=r
        ans%=MOD
    print(ans%MOD)
def culc(n, k):
    return k*(-2*k**2+3*n*k+(3*n+8))//6

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

MOD = 10**9 + 7
print(culc(N, N+1)-culc(N, K-1)%MOD)
mod=100000007
n,k=list(map(int,input().split(" ")))
sum=0
for i in range(k,n+2):
  sum=sum+i*(n-i+1)+1
print(sum%mod)
N, K = map(int, input().split())
ans = 0
for k in range(K, N+1):
  mi = k*(k-1)//2
  ma = k*(2*N-k+1)//2
  ans += ma - mi + 1
  ans %= 1000000007
print(ans)
N, K = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
tmp = 0
for i in range(K-1):
  tmp += i
for i in range(K, N + 1):
  tmp += K - 1
  ans += K * N - tmp * 2 + 1
  ans = ans % mod
print(ans)
N,K=map(int,input().split())
M=N+1;L=K-1
print((M**3+5*M+2*L**3+3*(1-M)*L**2-(5+3*M)*L)/6%1000000007)
import math
n,k = map(int,input().split())
if(k>n):
	print("1")
else:
	ans=(pow(n+1,2,1000000007))
	ans2=-(pow(k,2,1000000007))-1
	print(ans2)
	for i in range(k+1,n+1):
		ans -= math.floor((i-1)/2)
	print(ans)
a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i+1)/2
  max = a*(a+1)/2 - (a-i)*(a-i+1)/2
  return max - min + 1

count = 0
for i in range(a-b+1):
  count += cal(a,i+b)
print(count % mod)
N,K=map(int,input().split())
L=[i for i in range(N+1)]
p=10**9 + 7
L_min=sum(L)
L_max=L_min
ans=0
for i in range(N,K-1,-1):
  L_min=L_min-L[i]-1
  L_max=L_max-L[-i-1]
  ans += (L_max-L_min)%p
print(ans%p)
import math
import itertools

N, K = map(int, input().strip().split())
L = math.pow(10, 10)

values = [0] * (N + 1)
for i in range(N + 1):
    values[i] = i

amount = 0
for comb_no in range(K, N + 2):
    possible_values = set()
    for combination in itertools.combinations(values, comb_no):
        possible_values.add(sum(combination))
    print(len(possible_values))
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, K = mapint_inp()
MOD = 10*9+7

ans = 0
for i in range(K, N+2):
    mn = i*(i-1) // 2
    mx = i*(2*N-i+1) // 2
    ans += mx - mn + 1

print(ans%MOD)
def solution():
    n, k = map(int, input().split())
    ans = 0
    for i in range(k, n+2):
        smallest = (i-1) * i / 2
        largest = (n-i+1) * i + smallest
        ans += largest - smallest + 1
    ans %= 10 ** 9 + 7
    print(ans)

solution()
n,k = map(int,input().split())
cnt = 0
for i in range(k,n+2):
    cnt += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1
print(cnt % (10 ** 9 + 7))
n,k = map(int, input().split())

ans = 0
for i in range(k,n+2):
    if n != 1:
        if i > 2:
            ans += n*(n+1)//2 - (n-i)*(n-i+1)//2 - (i-1)*i//2 + 1
        elif i == 2:
            ans += n*(n+1)//2 - i + 1
        elif i == 1:
            ans += n+1
    else:
        if i == 2:
            ans += 2
        elif i == 1:
            ans += 1

print(ans%(10**9+7))
N, K = map(int,input().split())
ans = 0
MOD = 10**9+7
for i in range(K,N+1):
  num = ((2*N-i+1)*i)//2 - ((i-1)*i)//2
  ans+=num%MOD
ans%=MOD
print(ans)
N,K=list(map(int,input().split()))
src=[n for n in range(N+1)]
t=sum(src[-K+1:])
m=sum(src[:K-1])-1
ans=0
for n in range(N+2-K):
  t+=src[-K-n]
  m+=src[K+n-1]
  a=t-m
  ans+=a
print(ans%(10**9+7))
N,K=map(int,input().split())
cnt=0
for k in range(K,N+2):
    MIN=k*(k-1)//2
    MAX=(2*N-k+1)*k//2
    cnt+=MAX-MIN+1
print(cnt)
#D
N,K=map(int,input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans=0
for i in range(K,N+1):
    ans+=combinations_count(N+1, i)
    
print(ans)
line=input()
n,k=map(int,line.split())
sums=0
while k!=(n+2):
     if k==1:
          mini=1
     if k>=2:
          mini=(((k)*(k-1))/2)%((10**9)+7)
     maxi=( (((n+1)*(n)) - ((n+1-k)*(n-k)) )/2  )%((10**9)+7)
     sums+=(maxi-mini+1)
     sums=sums%((10**9)+7)
     k+=1
print(int(sums))
n, k = map(int, input().split())
 
ans = 0
 
for i in range(k, n+2):
    ans += (i*(n - i + 1) + 1) %(10**9+7)
 
 
    
print(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%=10**9+7

wa=wa+1
print(wa)
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)
from itertools import combinations
def calc(a,b,l):
    if b - a ==1:
        return 1
    c =  0
    ll = []
    for i in range(b, a + 1):
        p = list(combinations(l,i))
        for j in p:
            s = sum(list(j))
            if s not in ll:
                c +=1
    return c
l = []
a,b = map(int, input().split())
for k in range(a+1):
    l.append(k)
print(calc(a, b , l))
mod=10**9+7
n,k=map(int,input().split())
ans=(n+1)*( (n+k+1)*(n-k+2)/2 - (n+2)*(2*n+3)/6 )+k*(k-1)*(2*k-1)/6+(n-k+2)
ans=int(ans%mod)
print(ans)
N, K = list(map(int,input().split()))
S = []
if N <= K:
  print(1)
  exit(0)
for i in range(K,N+2):
  S.append(i*N - (i-1)*i + 1)
print(sum(S))
list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

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

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(s % (10**9+7))
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
  mi=i*(i-1)//2
  ma=(2*n-i-1)*i//2
  ans+=ma-mi+1
print(ans)
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, len(l)+1)):
  num += len(list(itertools.combinations(l, i)) )

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

m = 10 ** 9 + 7

def foo(x):
  r=1
  for i in range(1,x):
    r *= i
    r %= m
  return r

def in_foo(x):
  return pow( foo(x), m-2, m)

def bn(x, y):
  r = foo(x)
  r *= in_foo(y)
  r *= in_foo(x-y)
  return r % m

ans = 0
for i in range(K, N+2):
  ans += bn(N+1, i)
  ans %= m

print(ans)
import sys
input = sys.stdin.readline

def main():
   N, K = map(int, input().split()) 
   NUM = [i for i in range(N+1)]
   LOWER = 0
   UPPER = 0
   CNT = 0
   for j in range(K):
       LOWER += NUM[j]
       UPPER += NUM[N-j]
   for i in range(N+1):
       if i + K >= N+1:
           CNT += 1
           break
       CNT += UPPER -LOWER + 1
       LOWER += NUM[K+i]
       UPPER += NUM[N-(K+i)]
   print(CNT)

if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline

def main():
  n, k = map(int,input().split())
  result = 0
  for i in range(k, n+2):
    min = (i-1) * (1+(i-2)*0.5)
    max = (n * i) - min
        
    result += (max-min+1)
    
  return int(result)

if __name__ == '__main__':
  print(main())
n, k = map(int, input().split())
mod = pow(10, 9) + 7
ans = 0
for i in range(k, n+1):
    #小さい方からi個選ぶ
    mini = n*(n-1)//2
    maxa = (2*n-k+1)*n//2
    ans = (ans + (maxa - mini + 1))% mod

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

a = 0

for i in range(K,N+2):
  a += i*(2*N-i+1)//2 - i*(i-1)//2 + 1
  
print(a)
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
  mi=i*(i-1)//2
  ma=(2*n-i+1)*i//2
  c=(ma-mi+1)%(10**9+7)
  ans+=c
print(ans)
import sys
input = lambda: sys.stdin.readline().strip("\r\n")

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

mod = 10**9 + 7
# 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) % mod
print(int(ans + 1))
from typing import NoReturn


def main() -> NoReturn:
    n, k = map(int, input().split())  # type: int, int

    p: int = 10 ** 9 + 7

    answer = 0

    for i in range(k, n + 1):
        min_val: int = sum(range(i))
        max_val: int = sum(range(n - i + 1, n + 1))
        answer += max_val - min_val + 1

    print(answer % p)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
cnt = 0
mod = 10**9+7
for i in range(k,n+2):
    sum_min = i*(i-1) // 2
    sum_max = i*(2*n-i+1) // 2
    #print((sum_max - sum_min + 1))
    cnt = cnt +  (sum_max - sum_min + 1)%mod
print(cnt)
import itertools
x =(input()).split(" ")
N = int(x[0])+1
K = int(x[1])
l = []
p =0
for i in range(N):
	l.append(p)
	p+=1
p = 0
while K<=N:
	c_list = list(itertools.combinations(l, K))
	K+=1
	p+=len(c_list)
print(p)
N, K = map(int, input().split())

base = 10 ** 100
modu = (10 ** 9) + 7

nums = [(base + i) % modu for i in range(N+1)]

saw = []

for i in range(2**(N+1)):
    _sum = 0
    count = 0
    for j in range(N+1):
        if (i >> j) & 1:
            count += 1
            _sum += nums[j]

    if (_sum % modu not in saw) and count >= 2:
        saw.append(_sum % modu)

print(len(saw))
n,k = map(int,input().split())
p = 10 ** 9 + 7

ans = 0
max=0
min=0

a=[0]*(n+1)
b=[0]*(n+2)

for i in range(n+1):
    a[i]=i
    b[i+1]=a[i]+b[i]

if n>k:
    for i in range(k,n+2):
        min=b[i]
        max=b[n+1]-b[n+1-i]
        ans=ans+max-min+1
else:
    ans=1

ans = ans % p

print(ans)