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:
#!/usr/bin/env python3

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b = mi()
    diff = b - a
    print(diff * (diff+1) // 2 - b)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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())

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

print(ans)

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())
d = b - a
r = (d * (d + 1)) // 2
print(r - 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())
s=0
for i in range(b-a):
    s+=i
print(s-a)

Submission status: Accepted

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


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    solve(a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
a, b = map(int, input().split())

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

Submission status: Accepted

Solution code:
def resolve():
    a, b = map(int, input().split())
    n = b - a
    print(n*(n-1)//2 - a)
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())
m = b-a
print(m*(m+1)//2-b)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

a,b = inputIL()

d = b-a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
d=b-a
tree=[]
tr=0
for i in range(1,1000):
    tr+=i
    tree.append(tr)
#print(tree)
#print(tree[d-1])
print(tree[d-1]-b)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def solve(a, b):
    n = b - a - 1
    A = sum(list(range(1, n + 1)))
    return A - a

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
ab = input().split()
a,b = int(ab[0]),int(ab[1])
d = []
z = b - a 
if ((z-1)*z)/2 >a and ((z+1)*(z+2))/2 > b:
    x,y = ((z-1)*z)/2, ((z+1)*(z+2))
print(int(x - a))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(int(sum - b))

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:
import sys

input = sys.stdin.readline


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

    # N(N+1)/2 - X = a
    # (N+1)(N+2)/2 - X = b
    for i in range(1, 999):
        Xa = i * (i + 1) // 2 - a
        Xb = (i + 1) * (i + 2) // 2 - b
        if Xa == Xb:
            ans = Xa
            break

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000) 
def f(n):
    if n == 0:
        return 0
    else:
        return n + f(n-1)
a, b = list(map(int,input().split()))
i1 = 1
i2 = 2
while True:
    if b - a == f(i2) - f(i1):
        break
    i1 += 1
    i2 += 1
print(f(i1) -a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
h = 0
hs = []
for i in range(1, 1000):
    h += i
    hs.append(h)
for i in range(998):
    if (hs[i] - a) == (hs[i + 1] - b):
        print(hs[i] - a)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A_x = (B-A)-1

print(sum(list(range(A_x+1)))-A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
a, b = ri_()
print((b - a - 1) * (b - a) // 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:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    a, b = readInts()
    print(int((b - a) * (b - a + 1)//2 - b))
if __name__ == '__main__':
  main()

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())

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

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
H = [i * (i + 1) // 2 for i in range(1, 1001)]

for l, r in zip(H, H[1:]):
    if r - l == B - A:
        print(r - B)
        exit()

Submission status: Accepted

Solution code:


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

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

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
print(ans-a)

Submission status: Accepted

Solution code:
import numpy as np
a, b = map(int, input().split())

num = [i+1 for i in range(999)]

tower = np.cumsum(num)

for j in range(len(tower) - 1):
    if tower[j] - a == tower[j+1] - b:
        print(tower[j] - a)
        break
    else:
        continue

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc099/tasks
# 15:00-


def main():
    a, b = map(int, input().split())
    dif = b - a
    
    return dif * (dif-1) // 2 - a


print(main())

Submission status: Accepted

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

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

gap = b-a

def sum_m(a):
    l=0
    for i in range(1,a+1):
        l+=i
    return l

n_b = sum_m(gap)
print(n_b-b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

val = [0] * 1000
for i in range(1, 1000):
    val[i] = val[i - 1] + i

n = b - a - 1
ans = val[n] - a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

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())
l=[0]*999
for i in range(1,1000):
    l[i-1]=(i*(i+1)//2)
#print(l)
for i in range(998):
    if (b-a)==l[i+1]-l[i]:
        ans=l[i]-a
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
snow = b - a
h = []
tmp = 0
for i in range(1,1000):
    tmp += i
    h.append(tmp)
x =[h[j+1] - h[j] for j in range(998)]
y = x.index(snow)
print(h[y] - a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

for i in range(diff):
    h += i + 1

ans = h - b

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

tmp = 0
for i in range(1, 499501):
    tmp += i
    if i == b-a: print(tmp-b)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b =map(int,input().split())
# b-aが、高さの差 2であれば左から1つめと2つめ nであればn-1つめとnつめ
n=b-a
print(int(0.5*n*(n+1)-b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int, input().split())
print('{:.0f}'.format((b-a)*(b-a+1)/2-b))

Submission status: Accepted

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

for i in range(2,1000):
    tmp_a = sum(range(1,i)) - a
    tmp_b = sum(range(1,i+1)) - b
    if tmp_a == tmp_b:
        print(tmp_a)
        break

Submission status: Accepted

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

n = b - a -1
ans = - a

for i in range(1, n+1):
    ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
sum=0
l=[]
for i in range(1,1000):
  sum+=i
  l.append(sum)
for j in range(998):
  if l[j]-a==l[j+1]-b:
    print(l[j]-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, input().split())
    t = 0
    r = -10**9
    for i in range(1, 1000):
        t += i
        if t <= i:
            continue
        if r == t - b:
            return r
        r = t - a

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

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())
diff = abs(b-a)
r = 0

for i in range(1,diff+1):
    r += i
print(r-b)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    import sys
    a,b=map(int,input().split())
    for i in range(1,999):
        isum=(i*(i+1))//2-a
        for j in range(i,1000):
            jsum=(j*(j+1))//2-b
            if jsum==isum and 1<=jsum and j==i+1:
                print(jsum)
                sys.exit()

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())
H=[0]*1000

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

print(H[B-A]-B)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def s(N):
    c = 0
    for i in range(1,N+1):
        c += i
    return c

print(s(b-a)-b)

Submission status: Accepted

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

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:
a,b=map(int, input().split())
d=b-a
t=0
while d>0:
  t+=d
  d-=1
print(t-b)

Submission status: Accepted

Solution code:
# solution
import io

nim, mike = map(int, input().split())
k = mike - nim
print(k * (k + 1) // 2 - mike)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a, b = nm()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

diff = b - a
for n in range(1000):
    if diff == n + 1:
        ans = n * (n + 1) // 2 - a
        print(ans)

# a = n * (n + 1) // 2
# b = (n * 1) * (n + 2) // 2

# b - a = (n**2 + 3 * n + 2 - N** 2 - n) // 2
# b - a = (2 * n + 2) // 2
# b - a = n + 1

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:
# ABC 099: B – Stone Monument
a, b = map(int, input().split())
print(sum(list(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())

n = b - a

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

Submission status: Accepted

Solution code:
x, y = map(int,input().split())
z = y - x
ans = 0

for i in range(1,z):
  ans += i

print(ans-x)

Submission status: Accepted

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

diff = b-a

def tower_height(x):
    return x * (x+1) // 2

west_tower = tower_height(diff-1)
east_tower = tower_height(diff)

print(west_tower-a)

Submission status: Accepted

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

for j in range(5*(10**6)):
    if ((a+j) in A) and ((b+j) in A):
        if A.index(a+j)+1==A.index(b+j):
            print(j)
            exit()

Submission status: Accepted

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

Ha = (B-A-1)*(B-A)//2

for x in range(1,Ha):
  if Ha-x == A:
    print(x)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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