Problem:


Score : 400 points

Problem Statement

We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.

We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Constraints

1 \leq N \leq 2\times 10^5

1 \leq K \leq N+1

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible values of the sum, modulo (10^9+7).

Sample Input 1

3 2

Sample Output 1

10

The sum can take 10 values, as follows:

(10^{100})+(10^{100}+1)=2\times 10^{100}+1

(10^{100})+(10^{100}+2)=2\times 10^{100}+2

(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3

(10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4

(10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5

(10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3

(10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4

(10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5

(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6

(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6

Sample Input 2

200000 200001

Sample Output 2

1

We must choose all of the integers, so the sum can take just 1 value.

Sample Input 3

141421 35623

Sample Output 3

220280457



Sample input:
3 2


Sample output:
10

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
s=0
for i in range(k,n+1):
	#0+...+i-1
	l=i*(i-1)//2
	#n+(n-1)+...+(n-i+1)
	h=(2*n-i+1)*i//2
	s+=h-l+1
print(s)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

mod = 10 ** 9 + 7
ans = 0

for i in range(K, N+2):
  ans += ((N + 1) * i - i ** 2 + 1) % mod
  
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:

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)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
 
MAX = (N+1)*(N+2)//2
MIN = (K-1)*(K)//2
 
print((MAX-MIN)/(10**9+7))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

MAX = (N+1)*(N+2)//2
MIN = (K-1)*(K)//2

print((MAX-MIN)/10**9+7)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
b=0
c=0
ans=0

for i in range(0,K):
    b+=i
    c+=(N-1-i)
ans=c-b
    
for i in range(K,N+1):
    ans+=(c+i)-(b+(N-i))
    
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())


def sub_sum(l, r):
    return (l + r) * (r - l + 1) / 2


ans = 0

for i in range(K, N+2):
    l = sub_sum(0, i-1)
    r = sub_sum(N-i+1, N)
    ans += r - l + 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

A = [0 for _ in range(N+1)]
for i in range(1, N+1):
    A[i] = i * (i+1) // 2

ans = 0
for j in range(K, N+1):
    minSum = A[K-1]
    maxSum = A[N] - A[N-K]

    possibleSumPattern = (maxSum - minSum)
    ans += possibleSumPattern * K * 10**100 % (10**9+7)
ans %= (10**9 + 7)
print(ans)

Submission status: Wrong Answer

Solution code:
#amari = (10**100)%(10**9+7)
def sm(i):
    tmpp = 0
    for j in range(i):
        tmpp += j
    return tmpp,j

def bi(i,N):
    tmpp = 0
    for j in range(i):
        tmpp += N-j

    return tmpp,N-j

def main():
    N,K = map(int,input().split())
    ans = 0
    #loopnum = (N+1) - K + 1
    for i in range(K,N+2,1):
        if i == K:
            small,numsmall = sm(i)
            big,numbig = bi(i,N)
            print(numsmall,numbig)
        else:
            small += numsmall+1
            numsmall += 1
            big += numbig - 1
            numbig -= 1
        ans += big - small + 1

    return (ans%(10**9+7))

print(main())

Submission status: Wrong Answer

Solution code:
#amari = (10**100)%(10**9+7)
def sm(i):
    tmpp = 0
    for j in range(i):
        tmpp += j
    return tmpp,j

def bi(i,N):
    tmpp = 0
    for j in range(i):
        tmpp += N-j

    return tmpp,N-j

def main():
    N,K = map(int,input().split())
    ans = 0
    #loopnum = (N+1) - K + 1
    for i in range(K,N+2,1):
        if i == K:
            small,numsmall = sm(i)
            big,numbig = bi(i,N)
        else:
            small += numsmall+1
            numsmall += 1
            big += numbig - 1
            numbig -= 1 
        ans += big - small + 1

    return ans

print(main())

Submission status: Wrong Answer

Solution code:
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)
    

print(cnt)

Submission status: Wrong Answer

Solution code:
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):
    print(i,calc(i))
    cnt+=calc(i)
    

print(cnt)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
s = [0]
for i in range(1,n+1):
    s.append(s[i-1] + i)

ans = 0
for i in range(k,n+1):
    ans += ((s[n]-s[n-i]) - s[i-1])+ 1
print(ans+1)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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**2+n)//2 - (n**2-n*k+n-k-n*k+k**2)//2 - (k**2-k)//2 + 1
  #ans += (n**2+n - (n**2-n*k+n-k-n*k+k**2) -k**2 + k)//2 + 1
  #ans += (n**2 + n - n**2 + n*k - n + k + n*k - k**2 - k**2 + k)//2 + 1
  #ans += (2*n*k + 2*k - 2*k**2)//2 + 1
  ans += n*k - k**2 + k  + 1
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)
	ans %= MOD
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
for i in range(K, N+1):
  ans += i*(N-i+1)+1
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
count = 0
for i in range(K,N+2):
  min_1 = i*(i-1)//2
  max_1 = (2*N-i+1)*i//2
  num = max_1-min_1+1
  count += num
print(count)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
mod = pow(10, 9)+7
Cmin = 0
Cmax = N
ans = 1
for i in range(1, N-K+2):
    Cmin += i
    Cmax += (N-i)
    ans = (ans+Cmax-Cmin+1)

print(ans % mod)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())

a = 0

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

ans = a % (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
# 初期入力
NN,K = (int(x) for x in input().split())

#K個の和、初項と修項
p =10**9 + 7
seq =[i for i in range(NN+1)] #0-Nまでの数列
ans =[0] *(NN+1)
st =[0]*(NN+1)
fi =[0]*(NN+1)
st[0] =sum(seq[  :K])
fi[0] =sum(seq[-K: ])
ans[0] =fi[0] -st[0] +1
if NN==1:
    print(3)
else:
    for i in range(NN -K+1):
        st[i+1] =st[i] +seq[K+i]
        fi[i+1] =fi[i] +seq[-K-i-1]
        ans[i+1] =(fi[i+1] -st[i+1] +1)
    print(sum(ans) %p)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(range(n+1))
b = a[::-1]
ans = 0

min = sum(a[:k-1])
max = sum(b[:k-1])

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

print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

ans = 0


for i in range(K, N+2):
    mi = ((i-1)*i)//2
    ma = N*i-mi
    ans += ma-mi+1
    # print(mi, ma)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

ans = 0


for i in range(K, N+2):
    mi = (i-1)*i//2
    ma = N*i-mi
    ans += ma-mi+1
    # print(mi, ma)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

ans = 0


for i in range(K, N+2):
    mi = (i-1)*i//2
    ma = i*(2*N-i+1)//2
    ans += ma-mi+1
    # print(mi, ma)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

ans = 0


for i in range(K, N+2):
    mi = (i-1)*i//2
    ma = i*(2*N-i+1)//2
    ans += ma-mi+1
    print(mi, ma)

print(ans)

Submission status: Wrong Answer

Solution code:
N ,K = map(int, input().split()) 

lst = [i for i in range(N+1)]

P = 10**9 + 7
rlt = 0

mini = sum(lst[:K-1])
maxi = sum(lst[-K+1:])

for i in range(N -K + 2):
  mini += lst[K+i-1]
  maxi += lst[-K-i]
  rlt += maxi -mini + 1
  rlt %= P
  
print(rlt)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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(c)
print(ans)

Submission status: Wrong Answer

Solution code:
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 = (n+1)*n//2 - (n+1-i)*(n-i)//2
  ans += (max - min + 1)%mod
  print(ans%mod)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
number = N+1-K+1
W = 0
for i in range(number):
    min = (K+i)*(K+i-1)/2
    max = (K+i)*(2*N-K-i+1)/2
    W += (max-min+1)
print(int(W))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
counter = 0

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


print(counter)

Submission status: Wrong Answer

Solution code:
1

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [i for i in range(n+1)]
mod = 10**9+7
ans = 0
for i in range(k, n+1):
  L = i * (i - 1) / 2
  R = n * i - i * (i - 1) / 2
  ans += R - L + 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())

#k ... n の値を取りうる. mとする。
# 和としてあり得るものは、
# m*(2*0+(m-1))/2 ~ m*(2*n+(m-1)*-1)/2 までの値を取りうる
# よって
# m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 通りがありうる。
# 
# mはk~nまでとりうるので
ans=0
for m in range(k,n+1):
    print((m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 ))
    ans+= (m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 )
print(int(ans+1))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Max = [0]
Min = [0]
for i in range(1, N+2):
  Max.append(N-i+1+Max[i-1])
  Min.append(i-1+Min[i-1])
A = [mx-mn+1 for mx,mn in zip(Max,Min)]
B =[0]
for i in range(N+1):
  B.append(B[i]+A[i+1])
print(B[N+1]-B[K-1])

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
wa = 0
for i in range(K,N+2):
    min_s = i* (i-1)/2
    max_s = i * (N + N - i +1)/2
    wa += max_s -min_s +1
print(int(wa))

Submission status: Wrong Answer

Solution code:
n, r = input().split()

n = int(n)+1
r = int(r)
cou = 0
mod = 10 ** 9 + 7
g1 =[1,1]
g2 =[1,1]
inverse = [0, 1]
N = 10**6

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

if n-r == 0:
    print("1")
    exit()

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for x in range(n-r):
    cou += cmb(n, r, mod)
    r += 1

print(cou)

Submission status: Wrong Answer

Solution code:
import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,k = na()

if n==k-1:
    print(1)
    exit(0)

prev_min = sum([i for i in range(k)])
prev_max = sum([i for i in range(n, n-k, -1)])
prev_num = k-1
cnt = 0
for i in range(n-k+1):
    # print("{} {} {}".format(prev_min, prev_max, prev_num))
    cnt += prev_max-prev_min+1
    cnt %= mod
    
    prev_min += prev_num+1
    prev_max += n-prev_num
    prev_num += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ans = 0

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
cc=0
for i in range(k,n+1):
  mins=[t for t in range(i)]
  maxs=[n-s for s in range(i)]
  cc+=(sum(maxs)-sum(mins)+1)%(10e+9+7)
print(cc)

Submission status: Wrong Answer

Solution code:
def main():
    a, b = input().split()
    a = int(a)
    b = int(float(b) * 100)
    print(a * b // 100)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
for i in range(K, N+2):
    ans += i * (N-i+1) + 1
print(ans%(10**7+7))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
for i in range(K, N+2):
    ans += i * (N-i+1) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)
  
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
ans = 0
for k in range(K,N+1):
    ans += N*k-((k*(k-1))/2)-k+2
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
N += 1

res = 1
s = [i for i in range(N)]

minimum, maximum = 0, 0
if K != 1:
    minimum = sum(s[:K - 1])
    maximum = sum(s[-K + 1:])

for i in range(K, N):
    minimum += s[i]
    maximum += s[-i + 1]
    res = (res + (maximum - minimum + 1)) % (10 ** 9 + 7)

print(res)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
N += 1

res = 1
s = [i for i in range(N)]

minimum = sum(s[:K-1])
maximum = sum(s[-K+1:])
for i in range(K, N):
    minimum += s[i]
    maximum += s[-i+1]
    res = (res + (maximum - minimum + 1)) % (10**9 + 7)

print(res)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d))

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]

m, M, L = 0, 0, 0
for i in range(k,n+2):
    m = i *(i-1)//2
    M = (2*n-i+1)*i//2
    L = L+(M - m+1)
print(L)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

ans = 0
mod = pow(10,9)+7

for k in range(1, K+1):
  ans += sum(range(N-k+1, N+1)) - sum(range(0, k))
  
  
print(ans % mod)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())

ans = 0
for x in range(K, N+2, 1):
    a = (x*(x-1)//2)
    b = ((x*(2*N-x+1))//2)
    ans += b-a+1
print(ans)

Submission status: Wrong Answer

Solution code:
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 += 1
        elif i == 1:
            ans += 2

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

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())

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

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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))))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
import itertools

line=input()
n,k=map(int,line.split())
s=set(list(range(n+1)))
sums=list()
while k!=(n+2):
     koko=list()
     sub=list(itertools.combinations(s,k))
     #print(sub)
     for val in sub:
          soso=0
          for i in val:
               soso+=(i+(10**100))
               soso=(soso%(10**9))
          if soso not in sums:
               sums.append(soso)
          
               
          
     
     
     
     k+=1
print(len(sums))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

#全部選ぶときの和の個数は0+1+2+ ~ +nの1+(n+1)n/2個

#k個は好きな選び方ができる。
#k個以上の数を選ぶときに「絶対に満たせない和の値」を考える。
#その数は10**100 + 10**100+1 + ... + 10*100+k-1 -1 の(k-1)k/2である。

result_before_division = 1+(n+1)*n/2 - (k-1)*k/2

result = result_before_division % (10**9 + 7)

print(int(result))

Submission status: Wrong Answer

Solution code:
import math

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

#全部選ぶときの和の個数は0+1+2+ ~ +nの1+(n+1)n/2個

#k個は好きな選び方ができる。
#k個以上の数を選ぶときに「絶対に満たせない和の値」を考える。
#その数は10**100 + 10**100+1 + ... + 10*100+k-1 -1 の(k-1)k/2である。

result_before_division = 1+(n+1)*n/2 - (k-1)*k/2

result = result_before_division % (10**9 + 7)

print(result)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
mod = 1000000007
sum = 0
for i in range(k, n + 2):
    tempSum1 = (n * (n + 1)) / 2
    tempSum2 = ((n - i) * (n - i + 1)) / 2
    tempSum3 = (i * (i - 1)) / 2
    sum += (tempSum1 - tempSum2 - tempSum3 + 1) % mod
print(sum % mod)

Submission status: Wrong Answer

Solution code:
import itertools
def main():
    N,K = map(int, input().split())
    MOD = pow(10,9)+7

    # 和としてありうる種類数が知りたい
    # 10^100が非常に大きいので、選ぶ個数が異なる時、必ず和は異なる事が分かるので、
    # 10^100を取り除いて、0,1,2,...,N-1,N という要素数(N+1)の数列からm個とるときに、
    # ありうる和の種類数を求めて、K<=m<=N+1でシグマすると考えられる
    # ここで、数列からm個とる時の和でありうるのは、
    # 最小値: 小さい順にm個 -> 0+1+...+(m-1) = m*(m-1)/2
    # 最大値: 大きい順にm個 -> N+(N-1)+...+(N-m+1) = m*(2N-m+1)/2
    # さらに、最小値から最大値までは全ての数を作る事が可能なので、
    # (求める値) = Σ(K<=m<=N+1){(N-m+1)/m}

    ans  = 0
    for m in range(K,N+2):
        ans += (N-m+1)*m%MOD
    print(ans%MOD)


main()

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int, input().split())

ans = 0
for i in range(n-k+1):
    ans += math.factorial(n+1)//math.factorial(k+i)//math.factorial(n+1-k-i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=(N*(N+1)*(N+2)-(K*(K-1)*(3*N-2*K+4)))/6
print(a%(10**9+7))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
print(K*(N+1-K))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
print(K*(2*N+1-2*K)/2)

Submission status: Wrong Answer

Solution code:
N,K=list(map(int,input().split()))
src=[n for n in range(N+1)]
ans=0
M=sum(src[-K+1:])
m=sum(src[0:K-1])
for k in range(K,N+2):
  M+=src[-k]
  m+=src[k-1]
  ans+=M-m+1
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
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
if m < 0:
  m=0
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))

Submission status: Wrong Answer

Solution code:
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(int(ans%(10**9+7)))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
N,k=map(int,input().split())
ans=0
for i in range(k,N+2):
  m=(i-1)*i//2
  M=(i-1)*(2*N-i)//2+N
  comb = M-m+1
  ans+=comb

print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())

    num = 10*100
    nums = [num + i for i in range(0, n+1)]

    # sums = []
    total = 0
    for i in range(k, n+2):
        _min = int((nums[0]+nums[i-1])*(nums[i-1]-nums[0]+1)/2)
        _max = int((nums[-i]+nums[-1])*(nums[-1]-nums[-i]+1)/2)

        total += _max - _min + 1

    print(total)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

matrix = list(range(0,N+1))
cum_sum = np.cumsum(matrix)
matrix.reverse()
rev_cum_sum = np.cumsum(matrix)

ans = [0]*(N+1)

for i in range(K-1,N+1):
  ans[i-1] = rev_cum_sum[i] - cum_sum[i] +1 

print(ans)
print(sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
cnt = 0
MOD = 1000000007
for i in range(k, n+2):
    left = i*(i-1)//2
    right = i*(2*n-i+1)//2
    add = right - left + 1
    cnt += add%MOD
print(cnt)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
mod=10**9+7
def f(n):
  return n*(n-1)//2
ans=0
for i in range(k,n+2):
  a=f(n+1)-f(n-k-i)-f(k+i)+1
  ans+=a%mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

N, K = 141421, 35623

ans = 0
for i in range(K, N+2):
    minsum = int((0+i-1)*i/2)
    maxsum = int((N-i+1+N)*i/2)
    ans += maxsum - minsum + 1

print(ans % MOD)