Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import itertools

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

#list = []
#for i in range(N+1):
#    list.append(i)

#print(list)

#print(range(N+1))

ans=0

i=K
while(i<=N+1):
    #comb=combinationListRecursive(list, i)
    comb = list(itertools.combinations(range(N+1), i))
    #print(comb)
    tmp=[]
    for com in comb:
        sum=0
        for co in com:
            sum = sum+co
        if sum in tmp:
            continue
        else:
            tmp.append(sum)
            ans = ans+1
    i=i+1


print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

import itertools

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

#list = []
#for i in range(N+1):
#    list.append(i)

#print(list)

#print(range(N+1))

ans=0

i=K
while(i<=N+1):
    #print("i:"+str(i))
    #comb=combinationListRecursive(list, i)
    #comb = list(itertools.combinations(range(N+1), i))
    #print(comb)
    #tmp=[]
    #min=0
    #max=0
    #j=0
    #while(j<=i-1):
        #min = min+j
        #max = max+(N-j)
        #j=j+1
    max=((N-i+1+N)*i)/2
    min=((0+i-1)*i)/2
    #print("max:"+str(max))
    #print("min:"+str(min))
    #print("diff:"+str(max-min+1))
    ans=ans+(max-min)+1

    i=i+1


print(int(ans)%1000000007)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def combinationListRecursive(data, r):
  if r == 0 or r > len(data):
    return []

  result = []
  _combinationListRecursive(data, r, 0, [], result)
  return result


def _combinationListRecursive(data, r, start, progress, result):
  if r == 0:
    result.append(progress)
    return

  for i in range(start, len(data)):
    #別解 _combinationListRecursive(listExcludedIndices(data, [i]), r - 1, i, progress + [data[i]], result)
    _combinationListRecursive(data, r - 1, i + 1, progress + [data[i]], result)

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

list = []
for i in range(N+1):
    list.append(i)

#print(list)

ans=0

i=K
while(i<=N+1):
    comb=combinationListRecursive(list, i)
    #print(comb)
    tmp=[]
    for com in comb:
        sum=0
        for co in com:
            sum = sum+co
        if sum in tmp:
            continue
        else:
            tmp.append(sum)
            ans = ans+1
    i=i+1


print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

import itertools

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

#list = []
#for i in range(N+1):
#    list.append(i)

#print(list)

#print(range(N+1))

ans=0

i=K
while(i<=N+1):
    #print("i:"+str(i))
    #comb=combinationListRecursive(list, i)
    #comb = list(itertools.combinations(range(N+1), i))
    #print(comb)
    #tmp=[]
    #min=0
    #max=0
    #j=0
    #while(j<=i-1):
        #min = min+j
        #max = max+(N-j)
        #j=j+1
    max=((N-i+1+N)*i)/2
    min=((0+i-1)*i)/2
    #print("max:"+str(max))
    #print("min:"+str(min))
    #print("diff:"+str(max-min+1))
    ans=ans+(max-min)+1

    i=i+1


print(int(ans)%1000000007)