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: Wrong Answer

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

num = 0
has_height_a = False
has_height_b = False
for i in range(1, 1000):
    num += i
    if(num > a and has_height_a == False):
        height_a = num
        has_height_a = True
        
    if(num > b and has_height_b == False):
        height_b = num
        has_height_a = True
    
    if(has_height_a and has_height_b):
        break
    
print(height_a - a)

Submission status: Wrong Answer

Solution code:
import re
st_in = input()
tmp_in = re.split(" ",st_in)

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

i_sum = 1
for i in range(2,999):
    i_sum += i
    if i_sum > b and i_sum - i > a:
        if i_sum - b == i_sum - i - a:
            print(i_sum-b)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
nl = 0
c = 0
for i in range(999):
    nl += i
    if nl > a:
        break
print(nl - a)

Submission status: Wrong Answer

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

n = b-a
num = 0

for i in range(n):
    num += i
else:
    print(num -b)

Submission status: Wrong Answer

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

print(sumn-b)

Submission status: Wrong Answer

Solution code:
sums = set()
cur = 0
for i in range(1, 1000):
    cur += i
    sums.add(cur)

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

for i in range(1, 500000):
    if a + i in sums and b + i in sums:
        print (i)
        break

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a, b = [int(x) for x in input().split()]

print(a, b)

diff = b - a
b_height = diff * (diff + 1) / 2
snow_height = int(b_height - b)

print(snow_height)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]
    diff = b - a

    tower = 0
    ts = []
    for add in range(1, 1000):
        tower += add
        ts.append(tower)

    for snow in range(1, 99999999):
        if a + snow in ts and b + snow in ts:
            print(snow)
            break

main()

Submission status: Wrong Answer

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

h = 0
i = 0
while h < a:
    i += 1
    h += i

print(h-a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

t = 0
for i in range(1, 1000):
    t += i
    if a < t:
        print(t-a)
        break

Submission status: Wrong Answer

Solution code:
def triangle(n):
    return (n*(n+1))//2

firsttriangles = []
for i in range(1,1000):
    firsttriangles.append(triangle(i))

ins = input().split(' ')
a = int(ins[0])
b = int(ins[1])

for i in range(0,999):
    if firsttriangles[i] > a:
        print(abs(a-firsttriangles[i]))
        break

Submission status: Wrong Answer

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

counter = 0
for i in range(999):
    if i == b - a:
        print(counter-a)
        exit()
    counter += i

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
cnt = 1
i = 2
while cnt < min(a, b):
    cnt += i
    i += 1
    
print(cnt - min(a, b))

Submission status: Wrong Answer

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

s = 0
for i in range(1,1000):
    s += i
    if a<=s:
        print(s-a)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
lst = input().split()
a = int(lst[0])
b = int(lst[1])

def height(n):
   return sum(range(1, n + 1))

poles = []
for i in range(1, 1000):
   poles.append(height(i))

for i in range(1, 499500):
   for j in range(997):
      if ((a + i) == poles[j]) and ((b + i) == poles[j + 1]):
         print(i)
         exit()

Submission status: Time Limit Exceeded

Solution code:

[a,b] = list(map(int,input().split()))

tou = []
dam=0
for i in range(1,1000):
    dam +=i
    tou.append(dam)
# print(tou[-1])

for ans in range(1,5000000):
    west, east = a+ans, b+ans
    for j in range(998):
        if west==tou[j] and east==tou[j+1]:
            # print("west,wast,j,ans", west,east,j,ans)
            out=ans
            break
print(out)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
lis=[1]
for i in range(2,1000):
    lis.append(lis[-1]+i)
i=0
while True:
    if a in lis and lis[lis.index(a)+1]==b:
        print(i)
        break
    a+=1
    b+=1
    i+=1

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
H=[0]*1000

i=1
while i<=999:
    H[i]=i+H[i-1]
    i+=1

ans=0
while True:
    if (A+ans in H)and(B+ans==H[H.index(A+ans)+1] in H):
        break
    else:
        ans+=1
    
print(ans)

Submission status: Time Limit Exceeded

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

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

def tower(i):
    h = 0
    for i in range(1, i+1):
        h += i
    return h

notFound = True
i = 0
while(notFound):
    i += 1
    for j in range(1,1000):
        if (tower(j)-i==a )and(tower(j+1)-i==b):
#            print("Found")
            notFound = False
print(i)

Submission status: Time Limit Exceeded

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

for j in range(snowless[-1]):
    if a + j in snowless and b + j in snowless:
        ans = j

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
tower_list = [[1,3]]
for i in range(3,999):
    tower_list.append([tower_list[i-3][1],tower_list[i-3][1]+i])
i=0
while(True):
    ab_list = [a+i,b+i]
    if(ab_list in tower_list):
        print(i)
        exit()
    i += 1

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
tower = [1]
tower_kai = []
for i in range(2,999):
    tower.append(tower[i-2]+i)
for i in range(len(tower)-1):
    tower_kai.append([tower[i],tower[i+1]])
i = 0
while(True):
    ab_list = [a+i,b+i]
    if(ab_list in tower_kai):
        print(i)
        exit()
    i+=1

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
for n in range(1, 1000):
    h1 = n*(n+1)//2
    h2 = (n+1)*(n+2)//2
    for x in range(1, h2+1):
        if h1 - x == a and h2 - x == b:
            print(x)
            exit(0)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
y = []
p = 0

for i in range(1, 1000):
    p += i
    y.append(p)

for x in range(1, 499501):
    for i in range(1, 999):
        if y[i] == b + x and y[i - 1] == a + x:
            print(x)
            break
    else:  # 内側のforのelse節は内側ループが全部まわり切ったら実行される、つまり前の行のbreakで抜けた場合ここは実行されない
        continue  # 外側のforに対応するcontinue文、ここが実行されたら次の行のbreakには処理がいかず、外側のforの次のループにジャンプする
    break  # 外側のforを抜ける"

Submission status: Time Limit Exceeded

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

"""z = []
for i in range(499500):
    z.append([])
for i in range(499500):
    z[i] = list(map(lambda k: k - i - 1, y))"""

for h in range(1, 499501):
    y = [y1 - w1 for (y1, w1) in zip(y, w)]
    for i in range(999):
        if i != 0:
            if b == y[i] and a == y[i - 1]:
                print(h)
                break
    else:  # 内側のforのelse節は内側ループが全部まわり切ったら実行される、つまり前の行のbreakで抜けた場合ここは実行されない
        continue  # 外側のforに対応するcontinue文、ここが実行されたら次の行のbreakには処理がいかず、外側のforの次のループにジャンプする
    break  # 外側のforを抜ける

Submission status: Time Limit Exceeded

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

for n in range(1, 999):
    for x in range(1, 499500):
        if a == (1/2)*n*(n+1)-x and b == (1/2)*(n+1)*(n+2)-x:
            print(x)
            break

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
l = []
t = 0
i = 1
while i <= 999:
  t += i
  l.append(t)
  i += 1

def f():
  for i in range(1, 499500):
    for j in range(len(l)-1):
      if a + i == l[j] and b + i == l[j+1]:
        return i

print(f())

Submission status: Time Limit Exceeded

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

n = 0
an = 0
r_an = 0
while True:
    an = (n * (n+1))/2

    if an > a:
        r_an = an - a
        break
    else:
        n+=1

n = 0
an = 0
while True:
    an = (n * (n+1))/2

    if r_an == (an - b):
        print an - b
        break
    else:
        n+=1

Submission status: Time Limit Exceeded

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

n = 0
an = 0
r_an = 0
while True:
    an = (n * (n+1))/2

    if an > a:
        r_an = an - a
        break
    else:
        n+=1

n = 0
an = 0
while True:
    bn = (n * (n+1))/2

    if r_an == (an - b):
        print an - b
        break
    else:
        n+=1

Submission status: Time Limit Exceeded

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

n = 0
an = 0
r_an = 0
while True:
    an = (n * (n+1))/2

    if an > a:
        r_an = an - a
        break
    else:
        n+=1

m = 0
bn = 0
while True:
    bn = (m * (m+1))/2

    if r_an == (bn - b):
        print bn - b
        break
    else:
        m+=1

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split( ))
ans = 0
ans2 = 0
i = 1
while a > ans:
    ans = ans + i
    i += 1
ans2 = ans + (i)
while True:
    if (ans-a) == (ans2-b):
        print(ans-a)
        break
    else:
        ans = ans-(i-1)
        ans2 = ans-i

Submission status: Time Limit Exceeded

Solution code:
#Stone Monument
a,b = map(int, input().split())
M = []
ans = []
for i in range(1,1000,1):
	n = 1/2*i*(i+1)
	M.append(n)
for i in range(0,999,1):
	n = int(i*(i+1)/2)
	for j in range(0,n,1):
		if (a + j == M[i]) and (b + j == M[i+1]):
			print(j)
			exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]
    diff = b - a

    cur_tower = 1
    ts = []
    for add in range(2, 1000):
        next_tower = cur_tower + add
        ts.append((cur_tower, next_tower))

        cur_tower = next_tower

    for snow in range(1, 499951):
        if (a + snow, b + snow) in ts:
            print(snow)
            break

main()

Submission status: Time Limit Exceeded

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

t = [1,]
flag = 0

for i in range(1000):
    t.append((i+2)+ t[i])

for j in range(len(t)):
    for k in range(499500):
        if t[j] - k == a and t[j+1] - k == b:
            print(k)
            flag = 1
        if flag == 1:break
    if flag == 1: break

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]
    diff = b - a

    tower = 0
    ts = []
    for add in range(1, 1000):
        tower += add
        ts.append(tower)

    for snow in range(1, 499951):
        if a + snow in ts:
            if b + snow == ts[ts.index(a + snow) + 1]:
                print(snow)
                break

main()

Submission status: Accepted

Solution code:
def answer(a: int, b: int) -> int:
    return sum(range(1, b - a + 1)) - b


def main():
    a, b = map(int, input().split())
    print(answer(a, b))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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())
ans=0
for num in range(1,b-a):
    ans+=num
print(ans-a)

Submission status: Accepted

Solution code:
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b = Input()
    towers = [1] * 999
    for i in range(1, 999):
        towers[i] = towers[i-1] + i + 1
    n = b - a
    ans = 0
    for i in range(998):
        if towers[i+1] - towers[i] == n:
            ans = towers[i] - a
    print(ans)


main()

Submission status: Accepted

Solution code:

[a,b] = list(map(int,input().split()))

tou = []
dam=0
for i in range(1,1000):
    dam +=i
    tou.append(dam)
# print(tou)

X = b-a
print(tou[X-1] - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(i for i in range(1, d)) - a)

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 = list(map(int, input().split()))

diff = b - a

x = 1
y = 3
i = 3

while True:
  if y - x == diff:
    break
  
  x = y
  y = y + i
  i = i + 1

print(y - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def su(p):
  c = 0
  for i in range(p+1):
    c += i
  return c

l = m - n

print(su(l-1) - n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
d = B-A
s = sum([x for x in range(1, d)])
print(s-A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = b - a - 1
an = (n*(n+1))//2
print(an-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
ans = 0
for i in range(c):
  ans += i
  
print(ans - a)

Submission status: Accepted

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

n = b - a
he = n * (n + 1) / 2
x = he - b
print(int(x))

Submission status: Accepted

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

d=0

for i in range(c):
  d+=i
  
print(d-a)

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:
a,b = map(int,input().split())
c = b-a
wa = c*(c+1)//2
print(wa-b)

Submission status: Accepted

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

print(d-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b = M()
print((b-a) * (b-a+1)//2 - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
m = b - a # [m-1] と [m]
t = 0
for i in range(m):
  t += i
print(t - a)

Submission status: Accepted

Solution code:
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
a, b = [int(num) for num in lines.pop(0).split(" ")]
dif = b - a
height = dif * (dif - 1)  // 2
print(height - a)

Submission status: Accepted

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

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:
m,n = map(int,input().split())
#lis = list(map(int,input().split()))
h = sum([i for i in range(1,n-m+1)])
print(h-n)

Submission status: Accepted

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

bt = sum([i for i in range(1,m-n+1)])
print(bt-m)

Submission status: Accepted

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

Submission status: Accepted

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

print(real_b - b)

Submission status: Accepted

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

h = 0
p = 1
li = []

for i in range(999):
    h +=p
    p +=1
    li.append(h)

for i in range(len(li)):
    for k in range(len(li)):
        if (a[0]-li[i])==(a[1]-li[k]) and k == i+1:
            print(abs(a[0]-li[i]))

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())
print((b - a) * (b - a - 1) // 2 - a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = b-a
for i in range(1,999):
    x= (i+1)*i//2
    y= (i+2)*(i+1)//2
    if y-x == c:
        print(x-a)
        break

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for n in range(0, 1000):
    west = ((n*(n-1))/2)-a
    east = ((n*(n+1))/2)-b

    if west == east:
        print(int(east))
        exit()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
x = b-a
cnt = 0
for i in range(x+1):
    cnt += i
print(cnt - 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:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())

    x = b - a
    y = x * (x - 1) // 2

    print(y - a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(d-a)

Submission status: Accepted

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

c = b - a
s = 0
for i in range(c + 1):
    s += i

print(s - b)

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, input().split())
    diff = b - a
    high_a = sum(list(range(1, diff)))
    print(high_a - a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, input().split())
    distance = b - a
    high_a = sum(list(range(1, distance)))
    print(high_a - a)


if __name__ == '__main__':
    main()

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())
c = 0
for i in range(1, b - a + 1):
  c += i
  
print(c - 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 = map(int, input().split())
print((((b-a)**2)-(a+b))//2)

Submission status: Accepted

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

for i in range(N+1):
  c=c+i

print(c-b)

Submission status: Accepted

Solution code:
from itertools import accumulate
import sys
a,b=map(int,input().split())
n = 500000
l=[]
for i in range(n):
    l.append(i)
    tmp = sum(l)
    if abs(abs(a+tmp) - abs(b+tmp)) == i:
        print(tmp -b)
        sys.exit()

Submission status: Accepted

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

Submission status: Accepted

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

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())
n = b - a
print(n*(n+1)//2 - b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ab = list(map(lambda x: int(x), input().split(" ")))
a = ab[0]
b = ab[1]

n = b - a - 1

x = n * (n + 1) // 2 - a

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

tower_height = 0
tower_height_list = []
for i in range(1,999+1):
    tower_height += i
    tower_height_list.append(tower_height)
    i += 1

for i in range(len(tower_height_list)):
    if tower_height_list[i] - b == tower_height_list[i-1] - a:
        print(tower_height_list[i] - b)

Submission status: Accepted

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

ans = (b-a)*(b-a+1)//2 - b

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
A=[]
c=1
for i in range(2,1001):
    A.append(c)
    c+=i
d=b-a
print(A[d-2]-a)

Submission status: Accepted

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

for i in range(1,c+1):
  ans+=i
  
print(ans-b)

Submission status: Accepted

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

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

Submission status: Accepted

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

d = b - a

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

Submission status: Accepted

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

c = b-a
res = sum(i for i in range(c))
print(res-a)

Submission status: Accepted

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

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

ans = s - a
print(ans)

Submission status: Accepted

Solution code:
def Gauss_sum(n):
  return n*(n+1)//2
a,b=map(int,input().split())
for i in range(999):
  if Gauss_sum(i+1)-a == Gauss_sum(i+2)-b:
    print(Gauss_sum(i+1)-a)
    break

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = sum - a
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    a, b = [int(i) for i in input().strip().split()]
    towers = [0] * 1000
    dif = b - a
    for i in range(1, 1000):
        towers[i] = i + towers[i - 1]
    for i in range(1, 999):
        if towers[i + 1] - towers[i] == dif:
            ans = towers[i + 1] - b
            print(ans)
            break
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(range(1, b - a)) - a)

Submission status: Accepted

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

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

tmp = 1
for i in range(2, 1000):
    if i == (b-a):
        # print(tmp, tmp+i)
        print(tmp-a)
    tmp += i

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b = nm()
    print(sum(range(1, b - a)) - a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(tall - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
ls = []
a = 0
for i in range(1,1000):
    a += i
    ls.append(a)
sa = B-A
ans = ls[sa-1] - B
print(ans)

Submission status: Accepted

Solution code:
LI = lambda: list(map(int, input().split()))

a, b = LI()


def main():
    f = lambda x: x * (x + 1) // 2
    ans = f(b - a - 1) - a
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

Submission status: Accepted

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

num = tmp*(tmp+1)//2

ans = num-b

print(ans)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

n = b - a

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b = map(int, readline().split())

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

M = sum(range(b-a))

print(M - a)

Submission status: Accepted

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

Submission status: Accepted

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