Problem:


Score : 200 points

Problem Statement

In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.

It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.

Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.

Assume also that the depth of the snow cover is always at least 1 meter.

Constraints

1 \leq a < b < 499500(=1+2+3+...+999)

All values in input are integers.

There is no input that contradicts the assumption.

Input

Input is given from Standard Input in the following format:

a b

Output

If the depth of the snow cover is x meters, print x as an integer.

Sample Input 1

8 13

Sample Output 1

2

The heights of the two towers are 10 meters and 15 meters, respectively.
Thus, we can see that the depth of the snow cover is 2 meters.

Sample Input 2

54 65

Sample Output 2

1



Sample input:
8 13


Sample output:
2

Submission status: Accepted

Solution code:
a,b = (int(T) for T in input().split())
Left = 0
Right = 1
for Leng in range(1,1000):
    Left += Leng
    Right += Leng+1
    if (Right-Left)==(b-a):
        print(Left-a)
        break

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, input().split())
    A = 0
    B = 1
    for i in range(1, 1000):
        A += i
        B += i + 1 
        if b - a == B - A:
            print(A - a) 
main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
l = [i for i in range(1, 1000)]
L = []
for i in range(999):
    L.append(sum(l[:i+1]))


for i in range(998):
    if (L[i] - a) == (L[i+1] - b):
        print(L[i]- a)

Submission status: Accepted

Solution code:
a, b = list(map(lambda x : int(x), input().split(" ")))
print(int((b - a) * (b - a - 1) / 2) - a)

Submission status: Accepted

Solution code:
a,b=map(int,input().split());print((b-a)*(b-a+1)//2-b)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
t = b-a
print(t*(t+1)//2-b)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B = map(int, readline().split())
    ans = (B-A)*(B-A+1)//2-B
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b=(int(i) for i in input().strip().split(" "))
n=b-a
k=(n*(n+1))//2
print(k-b)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
n=b-a
print(n*(n+1)//2-b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

bh = (b - a) * (b - a + 1) // 2
print(bh - b)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
n = b-a
B = ((1+n)*n)//2
print(B-b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

N = b - a - 1

print(N * (N + 1) // 2 - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b=map(int,input().split())
c=b-a
print((c*(1+c))//2-b)

Submission status: Accepted

Solution code:
def MAP(): return map(int, input().split())
a, b = MAP()
n = b - a
print(n * (n + 1) // 2 - b)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())

c = b-a

x = (c*(c+1))/2

print(int(x-b))

Submission status: Accepted

Solution code:
s = input().split()

a = int(s[0])
b = int(s[1])

height = []
p = 1
for i in range(999):
    height.append(p)
    p += 1

c = b - a
sum_num = 0

for i in range(c):
    sum_num += height[i]

answer = sum_num - b

print(answer)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    a, b = LI()

    d = b - a

    ans = (1 + d) * d // 2 - b
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    a,b = map(int, input().split())
    sum = 0
    
    for height in range(1,1000):
        sum += height
        if b-a == height:
            print(sum-b)
            break;
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
s = B - A
t = 0
for i in range(1,s + 1):
    t += i
ans = t - B
print(ans)

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

a,b = MI()
c = b-a
print(c*(c+1)//2-b)

Submission status: Accepted

Solution code:
a,b=map(int, input().split())
print(((b-a)**2-b-a)//2)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
a_all = 0

for i in range(1,(b-a)):
    a_all+=i
    
print(a_all-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
e = 0
for i in range(b - a):
  e += i
print(e - a)

Submission status: Accepted

Solution code:
n=list(map(int, input().split()))
ans=0
diff=n[1]-n[0]
for i in range(diff):
  ans=i+ans
yuki=ans-n[0]
print(yuki)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    n = b - a - 1
    return n * (n + 1) // 2 - a

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    print(solve(a, b))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
h = 0
d = b - a 

for i in range(1, 1000):
  h += i
  if i == d:
    print(h - b)
    exit()

Submission status: Accepted

Solution code:
a,b = map(int, raw_input().split())
og = b - a - 1
print og * (og + 1) / 2 - a

Submission status: Accepted

Solution code:
a, b = list(map(int, input().split()))

a_height = 0
b_height = 0
sa = abs(a - b)

for i in range(1, sa):
    a_height += i
    
# for i in range(1, sa + 1):
#     b_height += i
    
# print(a_height)
# print(b_height)

print(a_height - a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

for i in range(1, 1000):
    if abs(b-a)==i:
        print(int((i-1)*i/2) - a)
        break

Submission status: Accepted

Solution code:
import itertools

n, m = map(int, input().split())
l = list(itertools.accumulate(range(1, 1000)))
print(l[m-n-1]-m)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
List = []
A = 0
for i in range(1,1000):
  A +=i
  List.append(A)
K = b - a -1
east = List[K]
res = east - b
print(res)

Submission status: Accepted

Solution code:
MM = input().split()
a = int(MM[0])
b = int(MM[1])
ans = (b -a )*(b-a+1)*0.5 -b
print(int(ans))

Submission status: Accepted

Solution code:
a,b=map(int,input().split());print(sum(range(b-a))-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = b - a
print((c * (c + 1)) // 2 - b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
dif = b-a
print(dif*(dif+1)//2 - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

k = (b-a) - 1
print(int(k*(k+1)/2 - a))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = b-a
right = sum(list(range(1,n+1)))
print(right - b)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = b-a-1
h = sum(x for x in range(n+1))
print(h-a)

Submission status: Accepted

Solution code:
# B - Stone Monument
a, b = map(int, input().split())
diff = b - a

height = (1 + diff) * diff // 2

print(height - b)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
n = b-a
print(((n*(n-1))//2)-a)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = map(int, readline().split())
n = b - a
ans = n*(n+1)//2 - b
print(ans)

Submission status: Accepted

Solution code:
a , b = map(int,input().split())
t = b - a
print(t*(t-1)//2 - a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
d = b - a
a0 = d * (d - 1) // 2 
print(a0-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
X = b - a
ans = 0
for i in range(X):
    ans += i
print(ans-a)

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
table=[]
a=0
for i in range(1000):
  a+=i
  table.append(a)
print(table[y-x]-y)

Submission status: Accepted

Solution code:
tower = [0]*(999)
tower[0]=1
for i in range(1,999,1):
    tower[i]=tower[i-1]+(i+1)

a,b = map(int,input().split())
print(tower[b-a-1]-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
print(round((b - a) * (b - a + 1) / 2) - b)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

# 等差数列の和
h_b = sum(range(1, b - a + 1))

print(h_b - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
num = b-a
print(num*(num-1)//2-a)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
T = 0

for n in range(1,b-a+1):
  T+=n

print(T-b)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b = il()
    print((b-a)*(b-a+1)//2 - b)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b = il()
    t = [0] * 1000
    t[0] = 1
    for n in range(2, 1000):
        t[n-1] = t[n-2] + n
    for n in range(1000):
        if t[n] - a == t[n+1] - b:
            print(t[n]-a)
            exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    a, b = map(int, input().split())
    d = b - a
    sumb = 0
    for i in range(d):
        sumb += i + 1
    print(sumb - b)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b = i_map()

    print((b-a)*(b-a+1)//2-b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
def main():
  a,b = list(map(int,input().split()))
  number=b-a
  ans=0
  for i in range(1,number):
    ans+=i
  print(ans-a)
main()

Submission status: Accepted

Solution code:
sumA=0
diff={}
for i in range(1,1000):
  sumA+=i
  diff[i]=sumA
#print(diff)
a,b=[int(i) for i in input().split()]
print(diff[b-a]-b)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
ret = b-a
ans = ret*(ret+1)//2
print(ans-b)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

a,b=list(map(int,input().split()))
n=b-a
print((n)*(n-1)//2-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

Tcum = [0] * (1000)
for i in range(999):
    Tcum[i+1] = Tcum[i] + (i+1)

print(Tcum[b-a]-b)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
print((b-a)*(b-a-1)//2-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
n = b - a
ans = n * (n + 1) // 2 - b
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

for n in range(999):
  if n*(n+1)/2 - a == (n+1)*(n+2)/2 - b:
    print(int(n*(n+1)/2 - a))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = b - a
k = 0

for i in range(c):
    k += i

print(k - a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b = map(int, input().split())
n = b - a
n = n*(n-1)//2
print(n-a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	a,b = map(int,input().split())
	idx = b - a
	ans = 0
	for i in range(idx):
		ans += i
	ans -= a
	print(ans)
	

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
n=b-a
ans=n*(n-1)//2-a
print(ans)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
all=[i*(i+1)//2 for i in range(1,1000)]
diff=b-a-1
print(all[diff]-b)

Submission status: Accepted

Solution code:
import sys
a,b = map(int,input().split())

if not (1 <= a <= b <= 499500):
    sys.exit()

b_hight = 0
for I in range(1,(b - a + 1)):
    b_hight += I

print(b_hight - b)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    a, b = map(int, input().split())
    height = sum(list(range(b-a)))
    print(height - a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b=map(int, input().split())

dif=b-a
sum=0

for i in range(1,dif):
    sum+=i
    
print(sum-a)

Submission status: Accepted

Solution code:
A, B = map(int, input().split())

print(int((B - A )*( B - A +1)/2 - B ))

Submission status: Accepted

Solution code:
a,b=map(int, input().split())
tall=0
for i in range(b-a):
  tall+=i
print(tall-a)

Submission status: Accepted

Solution code:
def total_n(n):
    total = 0
    for i in range(n+1):
        total += i
    return total

a, b = map(int, input().split())
print(total_n(b-a)-b)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
x = (b-a)*(b-a+1)//2-b
print(x)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
ans = (1+(b-a))*(b-a)/2 - b
print(int(ans))

Submission status: Accepted

Solution code:
a,b=map(int,input().split());c=b-a;print((c*c+c)//2-b)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = b-a
print(n*(n+1)//2-b)

Submission status: Accepted

Solution code:
height=[]
for i in range(1,1000):
    height.append((1+i)*i//2)

a,b=map(int,input().split())
for i in range(998):
    if height[i+1]-height[i]==b-a:
        print(height[i]-a)

Submission status: Accepted

Solution code:
def actual(a, b):
    towers = [1]
    for x in range(2, 999 + 1):
        towers.append(towers[-1] + x)

    for i in range(len(towers)):
        west_tower_height = towers[i]
        east_tower_height = towers[i + 1]

        assert east_tower_height > west_tower_height

        diff = east_tower_height - west_tower_height

        if diff == (b - a):
            return east_tower_height - b

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b = map(int, input().split())
    c = b - a
    print(c * (c + 1) // 2 - b)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a,b = I()
d = b-a
print((1+d)*d//2-b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

t = b - a

total = 0
for i in range(1,t+1):
    total += i
    
print(total - b)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
h=sum([i for i in range(1,b-a+1)])
print(h-b)

Submission status: Accepted

Solution code:
a , b = map(int, input().split())

d = b - a
s = 0
for i in range(1,d):
  s += i
  
print(s-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
d = b - a - 1
print(d*(d+1)//2 - a)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
d=b-a

def A(n):
  hoge = int(n*(((n-1)/2)+1))
  return hoge

B=A(d)
print(B-b)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())

heightl=[]
height=0
for i in range(1,1000):
    height+=i
    heightl.append(height)
#print(heightl)
for i in range(1000):
    cur=heightl[i]
    nex=heightl[i+1]
    if cur>a:
        if nex-b==cur-a:
            ans=cur-a
            break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

y = b - a

ans = sum(list(range(1, y))) - a
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
print(((b-a-1)*(b-a))//2-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
temp = 0
bar_heights = []
for i in range(1, 1000):
    temp += i
    bar_heights.append(temp)

for i in range(1, 499501):
    if (a + i) in bar_heights and \
       (b + i) == bar_heights[bar_heights.index(a + i) + 1]:
        print(i)
        break

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
check=0
for i in range(1,(b-a)+1):
  check+=i
print(check-b)

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b=map(int,input().split())
sa=b-a
print(sum(range(1,sa))-a)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
# ----------------------------------------------------------- #

a, b = (int(x) for x in input().split())
d = b - a
ans = d * (d + 1) // 2 - b
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

res = 0
for i in range(b-a):
    res += i
print(res - a)

Submission status: Accepted

Solution code:
a,b = list(map(int, input().split()))
diff = b-a
print(diff * (diff + 1) // 2 - b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    diff = a[1]-a[0]
    count =0
    for i in range(diff):
        count+=i

    print(count-a[0])

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
n=b-a

print(n*(n+1)//2-b)

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
ta = 0
for i in range(b-a):
  ta += i
print(ta - a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
print((b-a)*(b-a+1)//2 - b) # 三角数の公式より

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
t = 0
for i in range(b-a):
    t += i
print(t-a)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())

d = b - a
x = [1]
for i in range(1,1000):
  x.append(i+1+x[i-1])
  if x[i] - x[i-1] == d:
    break
    
print(x[-1] - b)

Submission status: Accepted

Solution code:
import bisect

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

towers = []
last = 0
for i in range(1, 1000):
    towers.append(last+i)
    last += i

diff = b - a

print(towers[diff-1] - b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = (int(i) for i in input().split())
ans = (b-a-1)*(b-a)/2 - a
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)

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

def h(x:int):
    if x == 1:
        return 1
    else:
        return h(x-1)+x

print (h(d)-b)

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
 
diff = B - A
height_A = diff * (diff - 1) // 2
 
ans = height_A - A
 
print(ans)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = b-a

print(int(n*(n+1)/2) - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
print((b - a) * (b - a - 1) // 2 - a)

Submission status: Accepted

Solution code:
A, B = map(int, input().split())

diff = B - A
height_A = diff * (diff - 1) // 2

ans = height_A - A

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    a, b = map(int, input().split())
    ans = 0
    for i in range(b-a):
        ans += i+1
    print(ans-b)
resolve()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = b - a
lb = 0
for i in range(1, c + 1):
  lb += i
print(lb - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = b - a
lb = 0
for i in range(1, c + 1):
  lb += i
print(lb - b)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
x=b-a
c=(1+x)*x//2
print(c-b)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
k=b-a
n=k*(k+1)//2
s=n-b
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = b-a
h = n*(n+1)//2
snow = h-b
print(snow)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = b-a - 1
h = n*(n+1)//2
snow = h-a
print(snow)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B = map(int,input().split())

d = B-A
H = d*(d+1)//2
print(H-B)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
li = []
for i in range(1,1000):
    li.append(i*(i+1)//2)
difference = b-a
print(li[difference - 2] - a)

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a,b = nm()

s = 0

for i in range(1000):

  if b-a == i:
    print(s-a)
    break

  s+=i

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B = lr()
diff = B - A
x = diff - 1
answer = x * (x+1) // 2 - A
print(answer)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
x = abs(b-a)
sum = 0
for i in range(x):
    sum += i+1
print(sum-b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
diff = b - a
print((1 + diff) * diff // 2 - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
nb = b - a
lb = nb*(nb + 1)//2
print(lb - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
ans = (b - a) * (b - a - 1) / 2 - a
print(int(ans))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = b - a
t = [1]
for i in range(1100):
    t.append(t[i]+i+2)
idx = 0
for i in range(1000):
    if t[i+1] - t[i] == c:
        idx = i + 1
        break

print(idx * (idx+1)//2-a)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
temp=b-a
k=0
for i in range(temp):
  k=k+i
print(k-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

sum = 0
for i in range(b-a):
    sum += i

print(sum - a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
n = b-a-1
num = 0
for i in range(1,n+1):
    num += i

print(num-a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

High = [1]
for i in range(998):
    High.append(High[-1] + i+2)

A = []
for h1, h2 in zip(High, High[1:]):
    A.append(h2 - h1)
    if h2 - h1 == b - a:
        print(h1-a)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
v = []
sums = 1
for i in range(2,1010):
    v.append(sums)
    sums += i
a,b = map(int,input().split())
for i in range(1000):
    if v[i] - a == v[i+1] - b:
        print(v[i] - a)
        break

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
x = b-a
y = 0
for i in range(x):
    y += i+1
print(y-b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
x = b - a
east = 0
for i in range(1, x+1):
    east += i

ans = east - b
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

towers = [0 for _ in range(999)]
towers[0] = 1

for i in range(1, 999):
  towers[i] = towers[i-1] + (i+1)

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

ans = -1
for i in range(998):
  if towers[i] - a == towers[i+1] - b:
    ans = towers[i]-a
    if ans >= 0:
      break

print(ans)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())

temp = 0
dif = b - a

for i in range(1,1000):
    temp += i
    if i == dif:
        ans = temp - b
        print(ans)
        exit(0)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
summ = 0

for i in range(1,b-a+1):
  summ=summ+i
print(summ-b)