Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b. 

Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes according to the following rules: the first move increases the tiredness by 1, the second move increases the tiredness by 2, the third — by 3 and so on. For example, if a friend moves first to the left, then to the right (returning to the same point), and then again to the left his tiredness becomes equal to 1 + 2 + 3 = 6.

The friends want to meet in a integer point. Determine the minimum total tiredness they should gain, if they meet in the same point.


-----Input-----

The first line contains a single integer a (1 ≤ a ≤ 1000) — the initial position of the first friend. 

The second line contains a single integer b (1 ≤ b ≤ 1000) — the initial position of the second friend.

It is guaranteed that a ≠ b.


-----Output-----

Print the minimum possible total tiredness if the friends meet in the same point.


-----Examples-----
Input
3
4

Output
1

Input
101
99

Output
2

Input
5
10

Output
9



-----Note-----

In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.

In the second example the first friend should move by one to the left, and the second friend should move by one to the right. Then they meet in the point 100, and the total tiredness becomes 1 + 1 = 2.

In the third example one of the optimal ways is the following. The first friend should move three times to the right, and the second friend — two times to the left. Thus the friends meet in the point 8, and the total tiredness becomes 1 + 2 + 3 + 1 + 2 = 9.

Difficulty: EASY
Tags: Mathematics

Complete search

Implementation

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	a = read_int()
	b = read_int()
	d = abs(a - b)
	steps = d // 2
	total = steps * (steps + 1)
	if d % 2:
		total += steps + 1
	print(total)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


import sys

def solve(a, b):
	d = abs(a - b)
	d1 = d // 2
	d2 = d - d1
	s = (d1 + 1) * d1 // 2 + (d2 + 1) * d2 // 2
	return s
(a, b) = [int(v) for v in sys.stdin.readlines()]
res = solve(a, b)
print(res)


a = int(input())
b = int(input())
c = (a + b) // 2
x = abs(a - c)
y = abs(b - c)
print(x * (x + 1) // 2 + y * (y + 1) // 2)


a = int(input())
b = int(input())
x = (a + b) // 2
t = 0
if a < b:
	for i in range(1, x + 1 - a):
		t = t + i
	for j in range(1, b - x + 1):
		t = t + j
else:
	for i in range(1, a + 1 - x):
		t = t + i
	for j in range(1, x + 1 - b):
		t = t + j
print(t)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
c = (a + b) // 2
res = 0
i = 0
while a < c:
	i = i + 1
	a = a + 1
	res = res + i
i = 0
while c < b:
	i = i + 1
	c = c + 1
	res = res + i
print(res)


a = int(input())
b = int(input())
c = (a + b) // 2
d = 0
e = 1
if a < c:
	for i in range(a, c):
		d = d + e
		e = e + 1
else:
	for i in range(c, a):
		d = d + e
		e = e + 1
e = 1
if b < c:
	for i in range(b, c):
		d = d + e
		e = e + 1
else:
	for i in range(c, b):
		d = d + e
		e = e + 1
print(d)


def fun(x):
	return x * (x + 1) // 2
n = int(input())
m = int(input())
k = abs(n - m)
p = k // 2
if k % 2 == 0:
	d = 0
else:
	d = p + 1
l = 2 * fun(p) + d
print(l)


a = int(input())
b = int(input())
c = 0
i = 1
while a != b:
	if a < b:
		a += 1
		c += i
		if a < b:
			b -= 1
			c += i
	else:
		b += 1
		c += i
		if a > b:
			a -= 1
			c += i
	i += 1
print(c)


x = int(input())
y = int(input())
t = abs(y - x) // 2
c = t * (t + 1)
if abs(y - x) % 2 == 0:
	print(c)
else:
	print(c + t + 1)


a = int(input())
b = int(input())
s1 = 0
s2 = 0
tot = 0
for i in range(1, 10000):
	if a == b:
		tot = s1 + s2
		break
	if a < b:
		a += 1
		s1 = s1 + i
		if a != b:
			b -= 1
			s2 = s2 + i
		elif a == b:
			tot = s1 + s2
			break
		continue
	if a > b:
		b += 1
		s2 = s2 + i
		if b != a:
			a -= 1
			s1 = s1 + i
		elif a == b:
			tot = s1 + s2
			break
print(tot)


a = int(input())
b = int(input())
mid = (a + b) // 2
a = abs(mid - a)
b = abs(mid - b)
print(a * (a + 1) // 2 + b * (b + 1) // 2)


a = int(input())
b = int(input())
c = (a + b) // 2
print((c - min(a, b)) * (c - min(a, b) + 1) // 2 + (max(a, b) - c) * (max(a, b) - c + 1) // 2)


a = int(input())
b = int(input())
if a < b:
	small = a
	large = b
	d = b - a
else:
	small = b
	large = a
	d = a - b
center = small + d // 2
s1 = 0
s2 = 0
for i in range(1, d // 2 + 1):
	s1 += i
for i in range(1, large - center + 1):
	s2 += i
print(s1 + s2)


(a, b) = (int(input()), int(input()))
r = abs(a - b)
print((r - 1) // 2 * ((r - 1) // 2 + 1) + ((r - 1) % 2 + 1) * ((r - 1) // 2 + 1))


a = int(input())
b = int(input())
d = abs(a - b)
half = d // 2
miss = d % 2
tired = 0
for i in range(1, half + 1 + miss):
	tired += i
for i in range(1, half + 1):
	tired += i
print(tired)


import sys
from collections import *
from math import *
import re

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

def inp():
	return map(int, input().split())

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

def even(n):
	return [False, True][0 if n % 2 else 1]
max_int = sys.maxsize
mod = 10 ** 9 + 7

def solver(n):
	return int(n * (n + 1) / 2)
(a, b) = (int(input()), int(input()))
n = abs(a - b)
print(solver(ceil(n / 2)) + solver(floor(n / 2)))


a = input()
b = input()
diff = abs(int(a) - int(b))
if diff % 2 == 0:
	print(str((1 + diff // 2) * (diff // 2)))
else:
	print(str(diff // 2 + 1 + (1 + diff // 2) * (diff // 2)))


n = int(input())
m = int(input())
a = (n + m) // 2
print(abs(a - n) * (abs(a - n) + 1) // 2 + abs(a - m) * (abs(a - m) + 1) // 2)


import math
a = int(input())
b = int(input())
c = 0
if abs(a - b) % 2 == 0:
	for i in range((a + b) // 2 - min(a, b)):
		c = c + i + 1
	print(2 * c)
else:
	for i in range(abs(a - b) // 2):
		c = c + i + 1
	print(2 * c + abs(a - b) // 2 + 1)


z = input
n = int(z())
n1 = int(z())
from math import *
t = ceil((n + n1) / 2)
(t1, t2) = (abs(n - t), abs(n1 - t))
s1 = t1 / 2 * (t1 + 1)
s2 = t2 / 2 * (t2 + 1)
print(int(s1 + s2))


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
nsum = lambda x: x * (x + 1) // 2
a = I()
b = I()
d = abs(a - b)
(d0, d1) = (d // 2, (d + 1) // 2)
print(nsum(d0) + nsum(d1))


__author__ = 'RaldenProg'
x1 = int(input())
x2 = int(input())
y1 = 0
y2 = 0
z1 = 0
z2 = 0
while x1 != x2:
	if x1 < x2:
		x1 += 1
		y1 += 1
		z1 += y1
		if x1 < x2:
			x2 -= 1
			y2 -= 1
			z2 -= y2
	if x2 < x1:
		x2 += 1
		y2 += 1
		z2 += y2
		if x2 < x1:
			x1 -= 1
			y1 -= 1
			z1 -= y1
print(z1 + z2)


a = int(input())
b = int(input())
n = abs(b - a)
p = n // 2
if n % 2 == 1:
	print(p * (p + 1) + p + 1)
else:
	print(p * (p + 1))


n = int(input())
m = int(input())
a = abs(n - m)
q1 = a // 2 + a % 2
q2 = a // 2
print(q1 * (q1 + 1) // 2 + q2 * (q2 + 1) // 2)


import math
n = int(input())
l = int(input())
h = max(l, n) - min(l, n) - 1
if h % 2 == 0:
	h = math.floor(h / 2)
	l = math.floor(h * (h + 1) / 2)
	t = math.floor((h + 1) * (h + 2) / 2)
	t = t + l
	print(t)
else:
	h = math.floor(h / 2) + 1
	h = math.floor(h * (h + 1))
	print(h)


def minSteps(a, b):
	diff = abs(a - b)
	n = diff // 2
	if diff % 2 == 0:
		return n * (n + 1)
	else:
		return n * (n + 1) // 2 + (n + 1) * (n + 2) // 2
a = int(input())
b = int(input())
print(minSteps(a, b))


a = int(input())
b = int(input())
x = abs(b - a)
y = x // 2
if x == 1:
	print('1')
elif x % 2 == 0:
	print(y * (y + 1))
else:
	print((y + 1) ** 2)


a = int(input())
b = int(input())
if a > b:
	tmp = a
	a = b
	b = tmp
c = b - a
k = int(c / 2)
if c % 2:
	print((k + 1) ** 2)
else:
	print(k ** 2 + k)


a = int(input())
b = int(input())
x = abs(a - b)
s = 0
if x % 2 == 0:
	for i in range(1, x // 2 + 1):
		s = s + i
	print(s * 2)
else:
	for i in range(1, x // 2 + 1):
		s = s + i
	print(s * 2 + x // 2 + 1)


import sys, math
input = sys.stdin.readline
L = lambda : list(map(int, input().split().strip()))
M = lambda : map(int, input().split())
a = int(input())
b = int(input())
k = abs(a - b)
if k % 2 == 0:
	k = k // 2
	print(k * (k + 1))
else:
	k //= 2
	print((k + 1) ** 2)


n = int(input())
m = int(input())
a = max(n, m)
b = min(n, m)
if (a - b - 1) % 2 == 0:
	l = int((a - b - 1) / 2)
	sum1 = 0
	for i in range(1, l + 1):
		sum1 += i
	print(2 * sum1 + l + 1)
else:
	sum1 = 0
	l = int((a - b + 1) / 2)
	for i in range(1, l + 1):
		sum1 += i
	print(2 * sum1)


a = int(input())
b = int(input())
c = [a, b]
c.sort()
x = c[1] - c[0]
if x % 2 == 0:
	print(int(x * (x + 2) / 4))
else:
	p = x / 2 + 0.5
	q = x / 2 - 0.5
	r = p * (p + 1) / 2
	s = q * (q + 1) / 2
	print(int(r + s))


f = lambda x: x * (x + 1) // 2
(a, b) = sorted([int(input()), int(input())])
res = float('inf')
for c in range(a, b + 1):
	res = min(res, f(c - a) + f(b - c))
print(res)


class CodeforcesTask931ASolution:

	def __init__(self):
		self.result = ''
		self.a = 0
		self.b = 0

	def read_input(self):
		self.a = int(input())
		self.b = int(input())

	def process_task(self):
		dist = abs(self.a - self.b)
		if dist % 2:
			tire1 = dist // 2
			tire2 = dist // 2 + 1
		else:
			tire1 = dist // 2
			tire2 = dist // 2
		tiredness = sum([x + 1 for x in range(tire1)])
		tiredness += sum([x + 1 for x in range(tire2)])
		self.result = str(tiredness)

	def get_result(self):
		return self.result
Solution = CodeforcesTask931ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
p = int(input())
if abs(n - p) % 2 == 0:
	kam = abs(n - p) // 2
	printt = sum(list(range(1, kam + 1)))
	print(printt * 2)
else:
	kam = abs(n - p) // 2
	tod = sum(list(range(1, kam + 1)))
	tod *= 2
	print(kam + 1 + tod)


a = int(input())
b = int(input())
c = abs(a - b)
ans = 0
for i in range(c // 2 + 1):
	ans += 2 * i
if c % 2 == 1:
	ans += i + 1
print(ans)


a = int(input())
b = int(input())
mid = int((a + b) / 2)
vermoeidheid = 0
if b > a:
	hoeveelvoora = int(mid - a)
	hoeveelvoorb = int(b - mid)
	for i in range(1, hoeveelvoora + 1):
		vermoeidheid += int(i)
	for j in range(1, hoeveelvoorb + 1):
		vermoeidheid += int(j)
if a > b:
	hoeveelvoora = int(a - mid)
	hoeveelvoorb = int(mid - b)
	for i in range(1, hoeveelvoora + 1):
		vermoeidheid += int(i)
	for j in range(1, hoeveelvoorb + 1):
		vermoeidheid += int(j)
print(vermoeidheid)


pos_a = int(input())
pos_b = int(input())
jarak_a = int(abs(pos_b - pos_a) / 2)
c = abs(pos_b - pos_a) % 2
if pos_a != pos_b and 1 <= pos_a <= 1000 and (1 <= pos_b <= 1000):
	if c == 0:
		tired1 = int(jarak_a ** 2 + jarak_a)
		print(tired1)
	elif c == 1:
		tired2 = int(jarak_a ** 2 + 2 * jarak_a + 1)
		print(tired2)


a = int(input())
b = int(input())
n = 0
m = 0
if a > b:
	n = (a - b) / 2
	m = a - b - n
else:
	n = (b - a) / 2
	m = b - a - n
print(round(n * (n + 1) / 2 + m * (m + 1) / 2))


import math
(a, b) = (int(input()), int(input()))
dist = abs(b - a)
print((dist // 2 + 1) * (dist // 2) + dist % 2 * math.ceil(dist / 2))


n = int(input())
m = int(input())
c = abs(m - n)
d = c // 2
e = d + c % 2
print((1 + e) * e // 2 + (1 + d) * d // 2)


def addnums(num):
	return num * (num + 1) // 2
a = int(input())
b = int(input())
diff = abs(a - b)
print(addnums(diff // 2) + addnums(diff - diff // 2))


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
fans = 1e+18
for i in range(a, b + 1):
	d = i - a
	e = b - i
	ans = d * (d + 1) // 2 + e * (e + 1) // 2
	fans = min(ans, fans)
print(fans)


a = int(input())
b = int(input())
id_end = round((a + b) / 2)
hunger_a = 0
hunger_b = 0
if a < b:
	i = 0
	while a != id_end:
		i += 1
		hunger_a += i
		a += 1
	i = 0
	while b != id_end:
		i += 1
		hunger_b += i
		b -= 1
else:
	i = 0
	while a != id_end:
		i += 1
		hunger_a += i
		a -= 1
	i = 0
	while b != id_end:
		i += 1
		hunger_b += i
		b += 1
print(hunger_a + hunger_b)


Xa = int(input())
Xb = int(input())
if Xa < 1 or Xa > 1000 or Xb < 1 or (Xb > 1000) or (Xa == Xb):
	exit()
if Xa > Xb:
	range = Xa - Xb
else:
	range = Xb - Xa
if range % 2 == 0:
	tiredness = range / 2 * (range / 2) + range / 2
	tiredness = round(tiredness)
	print(tiredness)
else:
	tiredness = ((range - 1) / 2 + 1) * ((range - 1) / 2 + 1)
	tiredness = round(tiredness)
	print(tiredness)


a = int(input())
b = int(input())
c = abs(a - b)
x = 0
if c % 2 == 0:
	x = c // 2
	print(x * (x + 1))
else:
	x = c // 2
	print(x * (x + 1) + c // 2 + 1)


def tr(x):
	c = 0
	for i in range(x):
		c += i + 1
	return c

def mintr(a, b):
	dif = abs(a - b)
	if dif % 2 == 0:
		return 2 * tr(int(dif / 2))
	else:
		return tr(dif // 2) + tr(dif // 2 + 1)
a = int(input())
b = int(input())
print(mintr(a, b))


x = int(input())
y = int(input())
d = abs(x - y)
c = d // 2
r = c * (c + 1)
if d % 2 == 0:
	print(r)
else:
	print(r + (d + 1) // 2)


first = int(input())
second = int(input())
subtract = abs(first - second)
if subtract == 1:
	print('1')
else:
	count = 0
	k = subtract // 2 + 1
	i = 1
	while subtract > 0:
		subtract = subtract - 1
		count = count + i
		subtract = subtract - 1
		count = count + i
		i = i + 1
	if subtract % 2 == 0:
		print(count)
	else:
		print(count - k)


freind1 = int(input())
freind2 = int(input())
meetpoint = (freind1 + freind2) // 2
sum = 0
for i in range(meetpoint - min(freind1, freind2)):
	sum = sum + i + 1
for i in range(max(freind1, freind2) - meetpoint):
	sum = sum + i + 1
print(sum)


a = int(input())
b = int(input())
if abs(a - b) <= 2:
	print(abs(a - b))
else:
	final_num = (a + b) // 2
	steps_1 = abs(final_num - a)
	steps_2 = abs(final_num - b)
	cost = steps_1 * (steps_1 + 1) / 2 + steps_2 * (steps_2 + 1) / 2
	print(int(cost))


(a, b) = (int(input()), int(input()))
if a > b:
	(a, b) = (b, a)
(k, d) = ((b - a) // 2, b - a - (b - a) // 2)
print(k * (k + 1) // 2 + d * (d + 1) // 2)


a = int(input())
b = int(input())
k = 0
if a > b:
	k = a - b
else:
	k = b - a
(i, j) = (0, 0)
total_iter = 0
for m in range(1, k // 2 + 1):
	i += m
	total_iter = m
total = 2 * i
if k % 2 != 0:
	total += k - total_iter
print(total)


f1 = int(input())
f2 = int(input())
x = max(f1, f2)
y = min(f1, f2)
z = x - y
a = 0
b = 0
if z % 2 == 0:
	w = int(z / 2)
	for i in range(1, w + 1):
		b = b + i
	print(2 * b)
else:
	w = int(z / 2)
	for i in range(1, w + 1):
		a = a + i
	for i in range(1, w + 2):
		b = b + i
	print(a + b)


import math
a = int(input())
b = int(input())
c = abs(a - b)
if c % 2 == 0:
	d = c / 2
	e = d * (d + 1)
	print(int(e))
else:
	t = (c - 1) / 2
	h = t + 1
	f = t * (t + 1) / 2
	i = h * (h + 1) / 2
	print(int(f + i))


(a, b, asum) = (int(input()), int(input()), lambda x: (1 + x) * x // 2)
(a, b) = (abs(a - b) // 2, abs(a - b) - abs(a - b) // 2)
print(asum(a) + asum(b))


a = int(input())
b = int(input())
p = abs(a - b)
if p == 1:
	print(1)
elif p > 1:
	if p % 2 == 0:
		q = p // 2
		print(2 * (q * (q + 1) // 2))
	else:
		q = p // 2
		e = q + 1
		print(q * (q + 1) // 2 + e * (e + 1) // 2)


a = int(input())
b = int(input())
dist = abs(b - a)
d1 = dist // 2
d2 = dist - d1
u1 = (d1 + 1) * d1 // 2
u2 = (d2 + 1) * d2 // 2
print(u1 + u2)


a = int(input())
b = int(input())
y = abs(a - b)
count = 0
z = 0
if y % 2 == 0:
	for i in range(1, y // 2 + 1):
		count = count + i
	count = 2 * count
else:
	for i in range(1, y // 2 + 1):
		count = count + i
		z = i
	count = count * 2
	count = count + z + 1
print(count)


class Amigo:

	def __init__(self, posicao, direcao):
		self.posicao = int(posicao)
		self.cansaco_passo = 0
		self.cansaco_total = 0
		self.direcao = direcao

	def move(self):
		self.cansaco_passo += 1
		if self.direcao == -1:
			self.posicao -= 1
		else:
			self.posicao += 1
		self.cansaco_total += self.cansaco_passo
a = int(input())
b = int(input())
if a < b:
	direcao_a = 1
	direcao_b = -1
else:
	direcao_a = -1
	direcao_b = 1
amigo_1 = Amigo(a, direcao_a)
amigo_2 = Amigo(b, direcao_b)
aux = 0
while amigo_1.posicao != amigo_2.posicao:
	if aux % 2 == 0:
		amigo_1.move()
	else:
		amigo_2.move()
	aux += 1
cansaco = amigo_1.cansaco_total + amigo_2.cansaco_total
print(cansaco)


a = int(input())
b = int(input())
c = abs(b - a)
y = c // 2
z = c % 2 + y
print(y * (y + 1) // 2 + z * (z + 1) // 2)


a = int(input())
b = int(input())
c = abs(b - a)
if c % 2 == 1:
	c = int(c // 2)
	print(c * c + c + c + 1)
else:
	c = int(c / 2)
	print(c * c + c)


fa = int(input())
fb = int(input())
mid = (fa + fb) // 2
cntA = abs(fa - mid)
cntB = abs(fb - mid)
cnt = 1
suA = 0
for i in range(cntA):
	suA += cnt
	cnt += 1
cnt = 1
sub = 0
for i in range(cntB):
	sub += cnt
	cnt += 1
print(suA + sub)


from math import floor, ceil
a = int(input())
b = int(input())
c = floor(abs(a - b) / 2)
d = ceil(abs(a - b) / 2)
res = int((c + 1) / 2 * c + (d + 1) / 2 * d)
print(res)


from math import ceil, floor

def solve(n):
	return n * (n + 1)
a = int(input())
b = int(input())
n = abs(a - b) / 2
print((solve(ceil(n)) + solve(floor(n))) // 2)


a = int(input())
b = int(input())
k = 0
for i in range(1, abs(a - b) // 2 + 1):
	k += 2 * i
if abs(a - b) % 2 != 0:
	k += abs(a - b) // 2 + 1
print(k)


a = int(input())
b = int(input())
d = abs(a - b)
mov = int(d / 2)
ans = int(mov * (mov + 1) / 2)
if d % 2 == 1:
	mov = mov + 1
ans = ans + int(mov * (mov + 1) / 2)
print(ans)


a = int(input())
b = int(input())
meio = (a + b) // 2
d1 = abs(a - meio)
d2 = abs(b - meio)
s1 = sum(range(d1 + 1))
s2 = sum(range(d2 + 1))
print(s1 + s2)


def I():
	return int(input())

def IL():
	return [int(i) for i in input().split()]

def IM():
	return map(int, input().split())

def IS():
	return input()
a = I()
b = I()
(a, b) = (min(a, b), max(a, b))
diff = b - a
a = diff // 2
b = diff // 2 + diff % 2
print(a * (a + 1) // 2 + b * (b + 1) // 2)


a = int(input())
b = int(input())
steps = abs(a - b) // 2
remaining = abs(a - b) % 2
total = int(steps / 2 * (1 + steps) * 2 + (steps + 1) * remaining)
print(total)


import math
a = int(input())
b = int(input())
k = abs(a - b)
c = k // 2
d = k - c
ans = 0
ans = c * (c + 1) // 2 + d * (d + 1) // 2
print(ans)


a = int(input())
b = int(input())
dif = abs(b - a)
if (b - a) % 2 == 0:
	n = dif // 2
	ans = n * (n + 1)
else:
	n = dif // 2
	ans = n * (n + 1)
	ans += n + 1
print(ans)


a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
sum1 = 0
sum2 = 0
if (b - a) % 2 == 0:
	st1 = int((b - a) * 0.5) + 1
	st2 = int((b - a) * 0.5) + 1
else:
	st1 = int((b - a) * 0.5 + 1.5)
	st2 = int((b - a) * 0.5 + 0.5)
for i in range(1, st1):
	sum1 += i
for i in range(1, st2):
	sum2 += i
print(sum1 + sum2)


a = int(input())
b = int(input())
if 1 <= a <= 1000 and 1 <= b <= 1000:
	if a > b:
		n = a - b
	else:
		n = b - a
	m = n // 2
	if n % 2 == 0:
		c = m * (m + 1)
	else:
		c = m * (m + 1) // 2 + (m + 1) * (m + 2) // 2
print(c)


c = 1
l = []
for i in range(1000):
	l.append(c)
	l.append(c)
	c += 1
a = int(input())
b = int(input())
d = abs(a - b)
print(sum(l[:d]))


A = int(input())
B = int(input())
X = abs(A - B)
ans = 0
if X % 2 == 0:
	X = int(X / 2)
	print(X * (X + 1))
else:
	X = int(X / 2)
	print(X * (X + 1) + X + 1)


def cost(a, b):
	n = abs(a - b)
	return n * (n + 1) // 2
a = int(input())
b = int(input())
c = (a + b) // 2
print(cost(a, c) + cost(c, b))


a = int(input())
b = int(input())
dest = abs(a - b)
cel = dest // 2
ost = dest % 2
print((1 + cel) * cel + ost * (cel + 1))


a = int(input())
b = int(input())
diff = abs(b - a)
s_a = diff // 2
s_b = diff - s_a
print((s_a * (s_a + 1) + s_b * (s_b + 1)) // 2)


a = int(input())
b = int(input())
x = abs(b - a) // 2
ans = 0
ans += x * (x + 1)
if abs(b - a) % 2 == 1:
	ans += x + 1
print(ans)


a = int(input())
b = int(input())
d = abs(a - b)
(q, r) = divmod(d, 2)
tireness = (1 + q) * q
if r == 1:
	tireness += q + 1
print(tireness)


a = int(input())
b = int(input())
meetingPoint = (a + b) // 2
moves1 = moves2 = 0
if a < b:
	while a != meetingPoint:
		a += 1
		moves1 += 1
	while b != meetingPoint:
		b -= 1
		moves2 += 1
else:
	while a != meetingPoint:
		a -= 1
		moves1 += 1
	while b != meetingPoint:
		b += 1
		moves2 += 1
print(moves1 * (moves1 + 1) // 2 + moves2 * (moves2 + 1) // 2)


a = int(input())
b = int(input())
f = lambda x: (x + 1) * x // 2
m = (a + b) // 2
print(f(abs(m - a)) + f(abs(m - b)))


a = int(input())
b = int(input())
g = (a + b) // 2
aa = int(abs(a - g))
bb = int(abs(b - g))
ans = int(aa * (aa + 1) / 2 + bb * (bb + 1) / 2)
print(ans)


x1 = int(input())
x2 = int(input())
minimum = 1000000000000

def distance(p, x1, x2):
	dx1 = 0
	dx2 = 0
	for i in range(1, abs(x1 - p) + 1):
		dx1 += i
	for i in range(1, abs(x2 - p) + 1):
		dx2 += i
	return dx1 + dx2
for i in range(1000):
	t = distance(i + 1, x1, x2)
	minimum = min(minimum, t)
print(minimum)


a = int(input())
b = int(input())
if a < b:
	(i, j) = (1, 1)
	(sum1, sum2) = (0, 0)
	while a != b:
		sum1 += i
		a += 1
		i += 1
		if a != b:
			sum2 += j
			b -= 1
			j += 1
		else:
			break
	print(sum1 + sum2)
else:
	(a, b) = (b, a)
	(i, j) = (1, 1)
	(sum1, sum2) = (0, 0)
	while a != b:
		sum1 += i
		a += 1
		i += 1
		if a != b:
			sum2 += j
			b -= 1
			j += 1
		else:
			break
	print(sum1 + sum2)


a = int(input())
b = int(input())
mn = 10 ** 9
(a, b) = (min(a, b), max(a, b))
for i in range(a, b + 1):
	mn = min(mn, (i - a) * (i - a + 1) // 2 + (b - i) * (b - i + 1) // 2)
print(mn)


a = int(input())
b = int(input())
n = abs(a - b) // 2
n2 = abs(a - b) % 2
n * (n + 1) + n
print((n + 1) * (n + n2))


a = int(input())
b = int(input())
diff = abs(a - b)
n1 = diff // 2
n2 = n1 + 1
if diff % 2 == 0:
	print((1 + n1) * n1)
else:
	print((1 + n1) * n1 // 2 + (1 + n2) * n2 // 2)


a = int(input())
b = int(input())
if a > b:
	j = a - b
else:
	j = b - a
if j % 2 == 0:
	k = j // 2
	l = k * (k + 1) // 2
	print(2 * l)
else:
	k = j // 2
	m = k * (k + 1) // 2
	print(m * 2 + (j // 2 + 1))


a = int(input())
b = int(input())
if abs(b - a) % 2 == 0:
	w = abs(b - a) // 2
	p = w * (w + 1)
	print(p)
else:
	w = abs(b - a) // 2
	p = w * (w + 1)
	print(p + w + 1)


__author__ = 'Dilshod'
n = int(input())
m = int(input())
a = abs(n - m)
if a % 2:
	b = a // 2 * (a // 2 + 1) // 2 * 2 + (a // 2 + 1)
	print(b)
else:
	b = a // 2 * (a // 2 + 1) // 2 * 2
	print(b)


a = int(input())
b = int(input())
mayor = max(a, b)
menor = min(a, b)
derecha = 0
izquierda = 0
for i in range(1, mayor):
	mayor = mayor - 1
	derecha = derecha + i
	if mayor == menor:
		print(derecha + izquierda)
		break
	else:
		menor = menor + 1
		izquierda = izquierda + i
		if mayor == menor:
			print(derecha + izquierda)
			break


n = int(input())
m = int(input())
x = (m + n) // 2
n = abs(n - x)
m = abs(m - x)
print(abs(n * (n + 1) // 2) + abs(m * (m + 1) // 2))


a = int(input())
b = int(input())
c = (a + b) // 2
a = abs(a - c)
b = abs(b - c)
print((1 + a) * a // 2 + (1 + b) * b // 2)


def sum(n):
	return n / 2 * (1 + n)
a = int(input())
b = int(input())
c = abs(a - b)
if c % 2 == 1:
	print(int(2 * sum(int(c / 2)) + int(c / 2 + 1)))
else:
	print(int(2 * sum(int(c / 2))))


def calculate_tiredness(start, end):
	distance = abs(end - start)
	return int(distance * (distance + 1) / 2)

def main():
	a = int(input())
	b = int(input())
	middle = (a + b) // 2
	print(calculate_tiredness(a, middle) + calculate_tiredness(b, middle))
main()


x1 = int(input())
x2 = int(input())
dist = abs(x1 - x2)
if dist % 2 == 0:
	dist //= 2
	print((dist + 1) * dist)
else:
	dist //= 2
	print((dist + 1) * dist + dist + 1)


a = int(input())
b = int(input())
z = max(a, b) - min(a, b)
if z % 2 == 0:
	print(int(z / 2 * (z / 2 + 1)))
else:
	k = z // 2
	a = k * (k + 1) / 2
	b = (k + 1) * (k + 2) / 2
	print(int(a + b))


a = int(input())
b = int(input())
d = abs(a - b)
n = d // 2
s = n * (n + 1)
if d % 2 != 0:
	s += n + 1
print(s)


a = int(input())
b = int(input())
d = abs(a - b)
ans = (d // 2 + d % 2) * (d // 2 + 1)
print(ans)


a = int(input())
b = int(input())
dist = abs(a - b)
x = dist // 2
energy = x * (x + 1)
if dist % 2 == 1:
	energy += x + 1
print(energy)


p = abs(int(input()) - int(input()))
tired = 0
n = 1
while p > 0:
	if p > 1:
		tired += n * 2
		p -= 2
	else:
		tired += n
		p -= 1
	n += 1
print(tired)


a = int(input())
b = int(input())
n = abs(a - b)
f = 0
ft = 0
m = n
if n % 2 > 0:
	m = n + 1
for i in range(1, m // 2 + 1):
	f = 2 * i
	ft = ft + f
if n % 2 > 0:
	ft = ft - f // 2
print(ft)


def factorial(n):
	if n == 0:
		return 0
	elif n == 1:
		return 1
	else:
		return n + factorial(n - 1)
friend1 = int(input())
friend2 = int(input())
if friend1 > friend2:
	(friend1, friend2) = (friend2, friend1)
mid = (friend2 - friend1) / 2
if not mid.is_integer():
	tiredness = factorial((friend2 - friend1) // 2) + factorial((friend2 - friend1) // 2 + 1)
else:
	tiredness = 2 * factorial((friend2 - friend1) // 2)
print(tiredness)


a = int(input())
b = int(input())
if a > b:
	n = (a - b) // 2
	if (a - b) % 2 == 0:
		k = n * (n + 1)
	else:
		k = n * (n + 1) + n + 1
else:
	n = (b - a) // 2
	if (b - a) % 2 == 0:
		k = n * (n + 1)
	else:
		k = n * (n + 1) + n + 1
print(k)


a = int(input())
b = int(input())
c = 0
turn = 0
while a != b:
	turn += 1
	if a > b:
		a -= 1
		c += turn
		if b < a:
			b += 1
			c += turn
	elif b > a:
		b -= 1
		c += turn
		if a < b:
			a += 1
			c += turn
print(c)


from math import *
n = int(input())
m = int(input())
diff = abs(m - n)
count = 0
i = 0
diff1 = diff // 2
for i in range(1, diff1 + 1):
	count = count + 2 * i
if diff % 2 != 0:
	count = count + i + 1
print(count)


a = int(input())
b = int(input())
c = abs(a - b)
sum1 = 0
sum2 = 0
a1 = 1
a2 = 1
for i in range(c):
	if i < c // 2:
		sum1 += a1
		a1 += 1
	else:
		sum2 += a2
		a2 += 1
print(sum1 + sum2)


a = int(input())
b = int(input())
y = 0
t = 0
if b > a:
	z = b - a
	if z % 2 == 0:
		d = z // 2
		for i in range(1, d + 1):
			y = y + i
		p = 2 * y
		print(p)
	else:
		o = (b - a - 1) // 2
		e = (b - a + 1) // 2
		for i in range(1, o + 1):
			y = y + i
		for w in range(1, e + 1):
			t = t + w
		print(y + t)
elif b < a:
	z = a - b
	if z % 2 == 0:
		d = z // 2
		for i in range(1, d + 1):
			y = y + i
		p = 2 * y
		print(p)
	else:
		o = (a - b - 1) // 2
		e = (a - b + 1) // 2
		for i in range(1, o + 1):
			y = y + i
		for w in range(1, e + 1):
			t = t + w
		print(y + t)
else:
	print('0')


def summation(n):
	return n * (n + 1) // 2
a = int(input())
b = int(input())
diff = abs(a - b)
print(summation(diff // 2) + summation(diff - diff // 2))


def main():
	(a, b) = (int(input()), int(input()))
	c = max(a, b) - min(a, b)
	steps = c // 2
	additional = c % 2
	s = (steps + 1) * steps
	if additional:
		s += additional * (steps + 1)
	print(s)
main()


from math import ceil
a = int(input())
b = int(input())
k = abs(b - a)
n = k // 2
ans = 0
if k % 2 == 0:
	ans = n * (n + 1)
	print(ans)
else:
	ans = n * (n + 1)
	ans += ceil(k / 2)
	print(ans)


import math
a = int(input())
b = int(input())
diff = abs(a - b)
energy = 0
for i in range(0, diff // 2 + 1):
	energy += 2 * i
	last = i
if diff % 2 != 0:
	energy += 1 * (last + 1)
print(energy)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
i = 1
k = 0
while a != b:
	a += 1
	k += i
	if a != b:
		b -= 1
		k += i
	i += 1
print(k)


a = int(input())
b = int(input())
resul = 0
dif = abs(a - b)
i = 0
for i in range(1, dif // 2 + 1):
	resul += 2 * i
if dif % 2 == 1:
	resul += i + 1
print(resul)


a = int(input())
b = int(input())
z = (a + b) // 2
s = 0
for i in range(abs(z - a)):
	s += i + 1
for j in range(abs(z - b)):
	s += j + 1
print(s)


a = int(input())
b = int(input())
dist = abs(a - b)
half = dist // 2
if dist % 2 == 0:
	print(half * (half + 1))
else:
	print(half * (half + 1) // 2 + (half + 1) * (half + 2) // 2)


aa = int(input())
bb = int(input())
t = [aa, bb]
b = max(t)
a = min(t)
c = (b + a) // 2
ca = c - a
cb = b - c
s = ca * (ca + 1) / 2 + cb * (cb + 1) / 2
print(int(s))


x = int(input())
y = int(input())
dis = abs(x - y)
a = dis // 2
b = dis - a
print(a * (a + 1) // 2 + b * (b + 1) // 2) if dis > 1 else print(1)


a = int(input())
b = int(input())
r = abs(a - b)
ca = 1
cb = 1
ans = 0
while r > 0:
	r = r - 1
	ans = ans + ca
	ca = ca + 1
	if r <= 0:
		break
	r = r - 1
	ans = ans + cb
	cb = cb + 1
print(ans)


a = int(input())
b = int(input())
if abs(b - a) % 2 == 0:
	some = 0
	for i in range(1, 1 + abs(b - a) // 2):
		some += i
	print(2 * some)
else:
	some = 0
	prev = 0
	for i in range(1, 1 + abs(b - a) // 2):
		some += i
		prev = i
	i = prev
	print(some + some + (i + 1))


a = int(input())
b = int(input())
weakness = 0
i = 1
r = abs(a - b)
while r >= 2:
	weakness += 2 * i
	r -= 2
	i += 1
if r == 1:
	weakness += i
print(weakness)


a = int(input())
b = int(input())
d = abs(a - b)
r = d // 2
res = r * (r + 1) // 2
if d % 2 == 0:
	res *= 2
else:
	res += (r + 1) * (r + 2) // 2
print(res)


a = int(input())
b = int(input())
if a > b:
	t = a
	a = b
	b = t
c = (a + b) // 2
t1 = (1 + c - a) * (c - a) // 2
t2 = (1 + b - c) * (b - c) // 2
print(t1 + t2)


from math import ceil
a = int(input())
b = int(input())
n = abs(b - a)
c = n // 2
d = ceil(n / 2)
print(c * (c + 1) // 2 + d * (d + 1) // 2)


import math
a1 = 0
b1 = 0
n = int(input())
m = int(input())
a = math.ceil(abs(n - m) / 2)
b = math.floor(abs(n - m) / 2)
for i in range(1, a + 1):
	a1 += i
for j in range(1, b + 1):
	b1 += j
print(a1 + b1)


a = int(input())
b = int(input())
c = abs(a - b)
if c % 2 == 0:
	t = c // 2
	print((1 + t) * t)
else:
	t = c // 2
	r = t * (1 + t)
	print(r + t + 1)


a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
p = (b + a) // 2
s1 = p - a
s2 = b - p
s = s1 * (s1 + 1) // 2 + s2 * (s2 + 1) // 2
print(s)


a = int(input())
b = int(input())
c = (a + b) // 2
d = 0
g = 0
e = 1
f = 1
if a - b == 1 or b - a == 1:
	print(1)
elif a < b:
	for i in range(a, c):
		d = d + e
		e = e + 1
	for j in range(c, b):
		g = g + f
		f = f + 1
	print(d + g)
else:
	for i in range(b, c):
		d = d + e
		e = e + 1
	for j in range(c, a):
		g = g + f
		f = f + 1
	print(d + g)


import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
a = int(input())
b = int(input())
temp = (a + b) // 2
final_sum = 0
point1 = abs(a - temp)
point2 = abs(b - temp)
final_sum += point1 * (point1 + 1) // 2
final_sum += point2 * (point2 + 1) // 2
print(final_sum)


x = int(input())
y = int(input())
s = int((y - x) / 2)
if y > x:
	a = y
	b = x
else:
	a = x
	b = y
if (a - b) % 2 == 1:
	s = int((a - b + 1) / 2)
	sum1 = int(s * (s - 1) / 2)
	sum2 = int(s * (s + 1) / 2)
	print(sum1 + sum2)
else:
	s = int((a - b) / 2)
	sum1 = int(s * (s + 1))
	print(sum1)


a = int(input())
b = int(input())
n = abs(b - a)
t = n // 2
if n % 2:
	print(2 * t * (t + 1) // 2 + (t + 1))
else:
	print(2 * t * (t + 1) // 2)


a = int(input())
b = int(input())
first = 1
second = 1
tired = 0
while a != b:
	if a < b:
		if first <= second:
			first += 1
			tired += first - 1
			a += 1
		else:
			second += 1
			tired += second - 1
			b -= 1
	elif first <= second:
		first += 1
		tired += first - 1
		a -= 1
	else:
		second += 1
		tired += second - 1
		b += 1
print(tired)


x1 = int(input())
x2 = int(input())
medium_point = (x1 + x2) // 2
dx1 = abs(x1 - medium_point)
dx2 = abs(x2 - medium_point)
t1 = (1 + dx1) * dx1 / 2
t2 = (1 + dx2) * dx2 / 2
print(int(t1 + t2))


a = int(input())
b = int(input())
diff = abs(b - a)
sumVal = 0
if diff % 2:
	num = int(diff / 2)
	for i in range(1, num + 1):
		sumVal = sumVal + i
	ans = sumVal * 2 + num + 1
else:
	num = int(diff / 2)
	for i in range(1, num + 1):
		sumVal = sumVal + i
	ans = sumVal * 2
print(ans)


import math
a = int(input())
b = int(input())
f = int(math.fabs(a - b) // 2)
s = int(math.fabs(a - b) // 2)
f1 = 0
s1 = 0
if math.fabs(a - b) % 2 != 0:
	f += 1
for i in range(f + 1):
	f1 += i
for i in range(s + 1):
	s1 += i
print(s1 + f1)


n1 = int(input())
n2 = int(input())
sub = abs(n1 - n2)
c = 1
s = 0
for i in range(sub // 2):
	s += c
	c += 1
c = 1
for i in range(sub - sub // 2):
	s += c
	c += 1
print(s)


a = int(input())
b = int(input())
if abs(a - b) % 2 == 0:
	print(abs(a - b) // 2 * (abs(a - b) // 2 + 1))
else:
	print(abs(a - b) // 2 * (abs(a - b) // 2 + 1) + abs(a - b) // 2 + 1)


a = int(input())
b = int(input())
d = max(a, b) - min(a, b)
m = int(d / 2)
if d % 2 == 0:
	print(int(2 * (m * (m + 1) / 2)))
else:
	print(int(2 * (m * (m + 1) / 2)) + m + 1)


a = int(input())
b = int(input())
mini = 1000000
for i in range(min(a, b), max(a, b) + 1):
	mini = min(mini, (i - min(a, b)) * (i - min(a, b) + 1) // 2 + (max(a, b) - i) * (max(a, b) - i + 1) // 2)
print(mini)


a = int(input())
b = int(input())
c = abs(a - b)
d = c // 2
e = c - d
k = 0
for i in range(1, d + 1):
	k = k + i
for j in range(1, e + 1):
	k = k + j
print(k)


a = int(input())
b = int(input())
print(int(abs(a - b) / 2) * int(1 + int(abs(a - b) / 2)) + (abs(a - b) % 2 != 0) * (int(abs(a - b) / 2) + 1))


x = int(input())
y = int(input())
n = abs(x - y)
m = n // 2
if n % 2 == 0:
	c = m * (m + 1)
else:
	c = m * (m + 1) // 2 + (m + 1) * (m + 2) // 2
print(c)


a = int(input())
b = int(input())
diff = abs(a - b)
odd = False
if diff & 1 == 1:
	odd = True
diff = diff // 2
first = diff * (diff + 1) // 2
if odd:
	diff += 1
	second = diff * (diff + 1) // 2
	print(first + second)
else:
	print(first * 2)


def main():
	a = int(input())
	b = int(input())
	middle = (a + b) // 2
	a = abs(a - middle)
	b = abs(b - middle)
	tiredness = lambda x: x * (x + 1) // 2
	t = tiredness(min(a, b)) * 2
	if a != b:
		t += max(a, b)
	print(t)
main()


s = [0]
for i in range(1, 2000):
	s.append(s[-1] + i)
(a, b) = (int(input()), int(input()))
x = abs(a - b)
print(s[x // 2] + s[x - x // 2])


def solve():
	(a, b) = (int(input()), int(input()))
	m = abs(a - b)
	numbers = list(range(1, m + 1))
	ans = sum(numbers)
	for i in range(1, m):
		ans = min(ans, sum(numbers[0:m - i]) + sum(numbers[0:i]))
	print(ans)
solve()


from math import ceil

def solve(a, b):
	x = ceil(abs(a - b) / 2)
	y = abs(a - b) // 2
	if x != y:
		return (1 + y) * y // 2 + (x + 1) * x // 2
	else:
		return (1 + y) * y

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


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
i = 1
r = 0
while True:
	if a == b:
		print(r)
		break
	if b - a == 1:
		r += i
		print(r)
		break
	r += 2 * i
	i += 1
	b -= 2


(a, b) = (int(input()), int(input()))
if a > b:
	(a, b) = (b, a)
print(((b - a) // 2 + 1) ** 2 - (1 - (b - a) % 2) * ((b - a) // 2 + 1))


import math
n = int(input())
m = int(input())
if n == m:
	print(0)
elif n + 1 == m:
	print(1)
else:
	d = abs(m - n)
	if d % 2 == 0:
		e = d // 2
		sum = 0
		for i in range(1, e + 1):
			sum = sum + i
		print(sum * 2)
	elif d % 2 != 0:
		e = d // 2
		f = e + 1
		sum = 0
		for i in range(1, f + 1):
			sum = sum + i
		print(sum + (sum - f))


import sys
I = sys.stdin.readline
a = int(I())
b = int(I())
tired = 0
n = abs(a - b)
a = 1
c = 0
while n != 0:
	tired += a
	n -= 1
	c += 1
	if c == 2:
		c = 0
		a += 1
print(tired)


def suma(q):
	sump = 0
	for i in range(1, q + 1):
		sump = sump + i
	return sump
a = int(input())
b = int(input())
c = (a + b) // 2
c1 = abs(c - a)
c2 = abs(c - b)
print(suma(c1) + suma(c2))


a = int(input())
b = int(input())
r = abs(b - a)
r1 = r // 2
r2 = r - r1
sum1 = 0
for i in range(1, r1 + 1):
	sum1 = sum1 + i
for i in range(1, r2 + 1):
	sum1 = sum1 + i
print(sum1)


import math
a = int(input())
b = int(input())
if a > b:
	tmp = a
	a = b
	b = tmp
if (a + b) / 2 == (a + b) // 2:
	point = (a + b) // 2
else:
	point = math.ceil((a + b) / 2)
ans = (point - a) * (point - a + 1) / 2
ans += (b - point) * (b - point + 1) / 2
print(int(ans))


def sumOneToN(n):
	return int(n * (n + 1) / 2)

def main():
	a = int(input())
	b = int(input())
	d = abs(a - b)
	if d & 1 == 0:
		print(2 * sumOneToN(d / 2))
	else:
		d -= 1
		print(sumOneToN(d / 2) + sumOneToN(d / 2 + 1))
main()


n = int(input())
m = int(input())
s = abs(m - n)
f = (s - s % 2) // 2
ans = 2 * int((1 + f) / 2 * f)
if s % 2:
	ans += f + 1
print(ans)


a = int(input())
b = int(input())
d = (max(a, b) - min(a, b)) // 2
s = 0
g = 1
for i in range(d):
	s += g * 2
	g += 1
if (max(a, b) - min(a, b)) % 2 != 0:
	s += g
print(s)


import sys

def cal(n1, n2):
	t = 0
	t1 = 1
	t2 = 1
	i = min(n1, n2)
	j = max(n1, n2)
	while i <= j:
		if i == j:
			return t
		i += 1
		t += t1
		t1 += 1
		if i == j:
			return t
		j -= 1
		t += t2
		t2 += 1
		if i == j:
			return t
	return t

def main():
	n1 = int(input())
	n2 = int(input())
	x = cal(n1, n2)
	print(x)
main()


n = int(input())
m = int(input())
x = abs(m - n)
y = x % 2
x = x // 2
ans = (1 + x) * x + y * (x + 1)
print(ans)


a = int(input())
b = int(input())
if a > b:
	temp = a
	a = b
	b = temp
temp = i = j = 0
for i in range(b):
	i += 1
	a += 1
	if a == b:
		print(temp + i)
		exit()
	temp += i
	b -= 1
	if a == b:
		print(temp + i)
		exit()
	temp += i
print(temp)


import math

def f(n):
	return sum(list(range(n + 1)))
a = int(input())
b = int(input())
middle = (a + b) // 2
dist1 = int(math.fabs(a - middle))
dist2 = int(math.fabs(b - middle))
print(f(dist1) + f(dist2))


a = int(input())
b = int(input())
d = abs(a - b)
if d == 1:
	print(1)
elif d % 2 == 1:
	n = d // 2
	s1 = n * (n + 1) // 2
	s2 = (n + 1) * (n + 2) // 2
	print(s1 + s2)
else:
	n = d // 2
	s1 = n * (n + 1) // 2
	print(s1 + s1)


a = int(input())
b = int(input())
s = max(a, b) - min(a, b)
print(sum([i + 1 for i in range(s // 2)]) * 2 + (s // 2 + s % 2 if s % 2 == 1 else 0))


a = int(input())
b = int(input())
diff = max(a - b, b - a)
p1 = int(diff / 2)
p2 = int((diff + 1) / 2)
cost = int(p1 * (p1 + 1) / 2 + p2 * (p2 + 1) / 2)
print(cost)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
ans = 100000000000000000000000000
for i in range(a, b + 1):
	x = (i - a) * (i - a + 1) // 2
	y = (b - i) * (b - i + 1) // 2
	ans = min(ans, x + y)
print(ans)


a = int(input())
b = int(input())
d = abs(a - b)
cntA = d // 2
cntB = d - cntA
Ta = cntA * (cntA + 1) // 2
Tb = cntB * (cntB + 1) // 2
print(Ta + Tb)


f1 = int(input())
f2 = int(input())
countMaior = 0
countMenor = 0
iMenor = 0
iMaior = 0
if f1 > f2:
	maior = f1
	menor = f2
else:
	maior = f2
	menor = f1
while menor != maior:
	if countMaior > countMenor:
		menor += 1
		iMenor += 1
		countMenor += iMenor
	else:
		maior -= 1
		iMaior += 1
		countMaior += iMaior
print(countMaior + countMenor)


a = int(input())
b = int(input())
c = 0
d = 1
if a < b:
	while a < b:
		b -= 1
		c += d
		if a < b:
			b -= 1
			c += d
			d += 1
		else:
			break
else:
	while a > b:
		b += 1
		c += d
		if a > b:
			b += 1
			c += d
			d += 1
		else:
			break
print(c)


a = int(input())
b = int(input())
middle = (a + b) // 2
d1 = abs(a - middle)
d2 = abs(b - middle)
print(d1 * (d1 + 1) // 2 + d2 * (d2 + 1) // 2)


(A, B) = (int(input()), int(input()))
res = 0
curA = 1
curB = 1
(A, B) = (min(A, B), max(A, B))
while A != B:
	A += 1
	res += curA
	curA += 1
	if A == B:
		break
	B -= 1
	res += curB
	curB += 1
print(res)


f1 = int(input())
f2 = int(input())
d = abs(f2 - f1)
d1 = d // 2
d2 = d - d1
(n1, n2) = (d1 * (d1 + 1) // 2, d2 * (d2 + 1) // 2)
print(n1 + n2)


a = int(input())
b = int(input())
c = int((a + b) / 2)
if a > b:
	(a, b) = (b, a)
n = c - a
m = b - c
ans = n * (n + 1) + m * (m + 1)
print(int(ans / 2))


a = int(input())
b = int(input())
sum = 0
for i in range(abs(a - b) // 2):
	sum += i + 1
if abs(a - b) % 2 == 0:
	for i in range(abs(a - b) // 2):
		sum += i + 1
else:
	for i in range(abs(a - b) // 2 + 1):
		sum += i + 1
print(sum)


a = int(input())
b = int(input())
acount = 0
bcount = 0
aturn = True
total = 0
if a < b:
	t = a
	a = b
	b = t
while a != b:
	if aturn:
		a -= 1
		acount += 1
		total += acount
	else:
		b += 1
		bcount += 1
		total += bcount
	aturn = not aturn
print(total)


from math import ceil as c
a = int(input())
b = int(input())
n = abs(a - b)
tire = 0
if n % 2 == 0:
	k = n // 2
	for i in range(1, k + 1):
		tire += 2 * i
else:
	k = c(n / 2)
	for i in range(1, k + 1):
		if i == k:
			tire += i
		else:
			tire += 2 * i
print(tire)


(a, b) = (int(input()), int(input()))
(mi, ma) = (min(a, b), max(a, b))
meet = (mi + ma) // 2
print(sum(list(range(meet + 1 - mi))) + sum(list(range(ma + 1 - meet))))


def func(num):
	res = 0
	for i in range(1, 1 + num):
		res += i
	return res
a = int(input())
b = int(input())
d = abs(b - a)
print(func(d // 2) + func(d // 2 + d % 2))


a = int(input())
b = int(input())
res = (a + b) // 2
count = 0
j = 1
if abs(b - a) == 0:
	print(0)
elif abs(b - a) == 1:
	print(1)
elif (a + b) % 2 == 0:
	for i in range(min(a, b), res):
		count += j
		j += 1
	print(2 * count)
else:
	for i in range(min(a, b), res):
		count += j
		j += 1
	t = 1
	for i in range(max(a, b), res, -1):
		count += t
		t += 1
	print(count)


(a, b) = (int(input()), int(input()))
d = min(a, b) + abs(a - b) // 2
tiredness = 0
for i in range(1, abs(d - a) + 1):
	tiredness += i
for i in range(1, abs(d - b) + 1):
	tiredness += i
print(tiredness)


a = int(input())
b = int(input())
if a > b:
	x = a
	a = b
	b = x
m = 10 ** 10
for i in range(a, b + 1):
	m = min(m, (i - a) * (i - a + 1) // 2 + (b - i) * (b - i + 1) // 2)
print(m)


a = int(input())
b = int(input())
mn = 1e+18
for i in range(1, 1001):
	mn = min(mn, abs(i - a) * (abs(i - a) + 1) // 2 + abs(i - b) * (abs(i - b) + 1) // 2)
print(mn)


a = int(input())
b = int(input())
print((abs(a - b) + 1) ** 2 // 4)


x = int(input())
y = int(input())
if x > y:
	(x, y) = (y, x)
ans = 2000000000.0
for i in range(x, y + 1):
	ans = min(ans, (i - x) * (i - x + 1) // 2 + (y - i) * (y - i + 1) // 2)
print(ans)


a = int(input())
b = int(input())
d = abs(a - b)

def dis(x):
	h = 0
	for i in range(1, x + 1):
		h += i
	return h
if d % 2 == 0:
	print(dis(d // 2) * 2)
else:
	print(dis(d // 2) + dis(d - d // 2))


a = int(input())
b = int(input())
s1 = 0
s2 = 0
t = (a + b) // 2
for i in range(1, abs(t - a) + 1):
	s1 += i
for i in range(1, abs(t - b) + 1):
	s2 += i
print(s1 + s2)


m = int(input())
n = int(input())
mid = (m + n) // 2
a = abs(mid - m)
b = abs(mid - n)
res = a * (a + 1) // 2
res += b * (b + 1) // 2
print(res)


n1 = int(input())
n2 = int(input())
power = 0
total = 0
if n1 > n2:
	temp = n1
	n1 = n2
	n2 = temp
while n2 - n1 > 1:
	power += 1
	n1 += 1
	n2 -= 1
	total += 2 * power
if n2 - n1 == 1:
	power += 1
	total += power
print(total)


a = int(input())
b = int(input())
if abs(a - b) <= 2:
	print(abs(a - b))
else:
	dis = abs(a - b)
	if dis % 2 == 0:
		dis = dis // 2
		ans = dis * (dis + 1) // 2
		print(2 * ans)
	else:
		dis = dis // 2
		ans = dis * (dis + 1) // 2
		dis += 1
		ans += dis * (dis + 1) // 2
		print(ans)


import math
n = int(input())
m = int(input())
j = abs(n - m)
ans = j / 2
ans1 = j - j / 2
ans2 = ans * (ans + 1) / 2
ans3 = ans1 * (ans + 1) / 2
print(math.ceil(ans2 + ans3))


a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
c = (a + b) // 2
print(sum(range(1, c - a + 1)) + sum(range(1, b - c + 1)))


a = int(input())
b = int(input())
if abs(a - b) % 2 == 0:
	tengah = int((a + b) / 2)
else:
	tengah = int((a + b + 1) / 2)
a1 = abs(a - tengah)
b1 = abs(b - tengah)
i = 1
j = 0
tiredness = 0
while j < a1:
	tiredness += i
	i += 1
	j += 1
j = 0
i = 1
while j < b1:
	tiredness += i
	i += 1
	j += 1
print(tiredness)


def f(n):
	return n * (n + 1) // 2
a = int(input())
b = int(input())
dist = abs(a - b)
aMoves = (dist + 1) // 2
bMoves = dist // 2
print(f(aMoves) + f(bMoves))


(a, b) = (int(input()), int(input()))
(a, b) = (min(a, b), max(a, b))
m = (a + b) // 2
i = m - a
j = b - m
ans = (i + 1) * i // 2
ans += (j + 1) * j // 2
print(ans)


a = int(input())
b = int(input())
res = 0
diff = abs(a - b)
res = sum((x for x in range(1, diff // 2 + 1))) * 2
if diff % 2 == 1:
	res += diff // 2 + 1
print(res)


a = int(input())
b = int(input())
ab = abs(b - a)
n = ab // 2
ans = n * (n + 1)
if ab % 2 == 1:
	ans += n + 1
print(ans)


(a, b) = (int(input()), int(input()))
diff = abs(a - b)
n1 = diff // 2
n2 = diff - n1
ans = n1 * (n1 + 1) // 2 + n2 * (n2 + 1) // 2
print(ans)


a = int(input())
b = int(input())
d = abs(a - b)
s = 0
c = 0
if d % 2 == 0:
	s += d // 2
	for i in range(1, s + 1):
		c += i
	print(c * 2)
	exit()
else:
	s += d // 2
	k = 0
	for i in range(1, s + 1):
		c += i
		k = i
	c = c * 2
	c += k + 1
	print(c)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
if b - a == 1:
	print(1)
else:
	n = (b - a) // 2
	x = (1 + n) * n / 2
	x *= 2
	if (b - a) % 2 != 0:
		x += n + 1
	print(int(x))


R = lambda : map(int, input().split())
a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
m = (a + b) // 2
d = lambda x: x * (x + 1) // 2
print(d(m - a) + d(b - m))


a = int(input())
b = int(input())
diff = abs(a - b)
odd = diff % 2
half = int(diff / 2)
ret = half * (half + 1) + (half + 1) * odd
print(ret)


def dist(x):
	return x * (x + 1) // 2
a = int(input())
b = int(input())
d = abs(b - a)
d1 = d // 2
print(dist(d1) + dist(d - d1))


x = int(input())
y = int(input())
n = abs(x - y)
tired = 0
a = n // 2
tired = tired + a * (a + 1)
if n % 2 == 0:
	print(tired)
else:
	tired = tired + (a + 1)
	print(tired)


import math
a = int(input())
b = int(input())
len = abs(a - b)
frndA = math.ceil(len / 2)
frndB = len - frndA
print(int(frndA * (frndA + 1) / 2 + frndB * (frndB + 1) / 2))


import sys

def compute_sum(n):
	s = 0
	for i in range(1, n + 1):
		s += i
	return s

def main():
	a = int(sys.stdin.readline())
	b = int(sys.stdin.readline())
	(low, high) = (min(a, b), max(a, b))
	total = (high - low) // 2
	friend1 = compute_sum(total)
	friend2 = friend1
	if (high - low) % 2 == 1:
		friend2 += total + 1
	print(friend1 + friend2)
main()


a = int(input())
b = int(input())
d = abs(a - b)
t = 0
c = 1
if d % 2 == 0:
	m = d // 2
	while m > 0:
		t += c
		c += 1
		m -= 1
	print(2 * t)
else:
	m = d // 2
	while m > 0:
		t += c
		c += 1
		m -= 1
	print(2 * t + c)


a = int(input())
b = int(input())
b = abs(b - a)
a = 0
A = b // 2
B = b - A
q = 0
for i in range(1, A + 1):
	q += i
for i in range(1, B + 1):
	q += i
print(q)


def problem():
	in1 = int(input())
	in2 = int(input())
	moves = abs(in2 - in1)
	each = moves // 2
	cost = each * (each + 1) + moves % 2 * (each + 1)
	return cost
print(problem())


import re
import math
import decimal
import bisect
a = int(input())
b = int(input())
dist = abs(a - b)
aDist = dist // 2
bDist = dist - aDist
print(aDist * (aDist + 1) // 2 + bDist * (bDist + 1) // 2)


n = int(input())
m = int(input())
mid = (n + m) // 2
a = abs(mid - n)
b = abs(m - mid)
sum = 0
for i in range(1, b + 1):
	sum += i
for i in range(1, a + 1):
	sum += i
print(sum)


a = int(input())
b = int(input())
d = abs(a - b)
h = d // 2
t = lambda n: n * (n + 1) // 2
print(t(h) + t(d - h))


from math import ceil as c
d = abs(int(input()) - int(input()))
print(c(d / 2) * (c(d / 2) + 1) // 2 + d // 2 * (d // 2 + 1) // 2)


n = int(input())
m = int(input())
a = abs(n - m)
b = a // 2
c = a - b
print(b * (b + 1) // 2 + c * (c + 1) // 2)


(a, b) = (int(input()), int(input()))
print(sum(range(abs(a - (a + b) // 2) + 1)) + sum(range(abs(b - (a + b) // 2) + 1)))


a = int(input())
b = int(input())
gap = abs(a - b)
n = gap // 2
m = gap - n
print(n * (n + 1) // 2 + m * (m + 1) // 2)


(c1, c2) = (1, 1)
k = 1
s = 0
a = int(input())
b = int(input())
for i in range(abs(a - b)):
	if k % 2 == 1:
		s += c1
		c1 += 1
	else:
		s += c2
		c2 += 1
	k += 1
print(s)


a = int(input())
b = int(input())
dis = abs(b - a)
i = 1
s = 0
energy = 0
while dis - dis % 2 > s:
	s += 2
	energy += 2 * i
	i += 1
if s != dis:
	energy += i
print(energy)


def tired(a, b):
	t = abs(a - b)
	if t % 2 == 0:
		r = t // 2
		return r * (r + 1)
	(t1, t2) = (t // 2, t // 2 + 1)
	return t1 * (t1 + 1) // 2 + t2 * (t2 + 1) // 2
A = int(input())
B = int(input())
print(tired(A, B))


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	a = I()
	b = I()
	x = abs(a - b)
	if x % 2 == 0:
		y = x // 2
		return 2 * (y * (1 + y) // 2)
	else:
		y = x // 2
		return 2 * (y * (1 + y) // 2) + (y + 1)
print(main())


a = int(input())
b = int(input())
count = 0
if a > b:
	dist = a - b
	x = dist // 2
	for i in range(1, x + 1):
		count += i
	y = dist - x * 2
	if y == 0:
		count = 2 * count
	else:
		count = 2 * count + x + 1
	print(count)
else:
	dist = b - a
	x = dist // 2
	for i in range(1, x + 1):
		count += i
	y = dist - x * 2
	if y == 0:
		count = 2 * count
	else:
		count = 2 * count + x + 1
	print(count)


(a, b) = (int(input()), int(input()))
len = abs(abs(a) - abs(b))
if len == 1:
	res = len
else:
	len1 = len // 2
	len2 = len - len1
	res = (1 + len1) / 2 * len1 + (1 + len2) / 2 * len2
print(int(res), end='')


(a, b) = [int(input()) for _ in [0, 0]]
x = abs(b - a)
y = x // 2
print(y * (y + 1) - -x // 2 * (x % 2))


n = int(input())
m = int(input())
ans1 = abs(n - m)
if ans1 % 2 == 0:
	p = ans1 // 2
	print((1 + p) * p)
else:
	p = ans1 // 2 + 1
	print((1 + p) * p - p)


a = int(input())
b = int(input())
s = min(a, b)
l = max(a, b)
d = l - s
t = 0
for i in range(1, d + 1):
	if l - s == 0:
		break
	s += 1
	t += i
	if l - s != 0:
		l = l - 1
		t += i
print(t)


a = int(input())
b = int(input())
if b == min(a, b):
	(a, b) = (b, a)
c = (a + b) // 2
d = c - a
e = b - c
s = 0
p = 0
for i in range(1, d + 1):
	s = s + i
for j in range(1, e + 1):
	p = p + j
print(s + p)


a = int(input())
b = int(input())
t = [0] * 1001
for i in range(1, len(t)):
	t[i] = t[i - 1] + i
meet = (a + b) // 2
print(t[abs(a - meet)] + t[abs(b - meet)])


x1 = int(input())
x2 = int(input())
if x1 > x2:
	(x1, x2) = (x2, x1)
amount_between = x2 - x1
n = amount_between // 2
rem = amount_between % 2
res = (n + 1) * n + rem * (n + 1)
print(res)


class encontro_dos_parcas:

	def __init__(self):
		self.resposta = ''
		self.entrada_1 = 0
		self.entrada_2 = 0

	def leitura(self):
		self.entrada_1 = int(input())
		self.entrada_2 = int(input())

	def solucao(self):
		distancia = abs(self.entrada_1 - self.entrada_2)
		if distancia % 2:
			amigo_1 = distancia // 2
			amigo_2 = distancia // 2 + 1
		else:
			amigo_1 = distancia // 2
			amigo_2 = distancia // 2
		cansaco_geral = sum([x + 1 for x in range(amigo_1)])
		cansaco_geral += sum([x + 1 for x in range(amigo_2)])
		self.resposta = str(cansaco_geral)

	def resultado(self):
		return self.resposta
questao = encontro_dos_parcas()
questao.leitura()
questao.solucao()
print(questao.resultado())


a = int(input())
b = int(input())
r = abs(a - b)
if r % 2:
	n = r // 2
	print((1 + n) * n + n + 1)
else:
	n = r // 2
	print((1 + n) * n)


a = int(input())
b = int(input())
f = abs(a - b)
(z, o) = (f // 2, f % 2)
g = (2 + (z - 1)) * z
if o:
	g += 1 + z
print(g)


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	a = int(inp())
	b = int(inp())
	m = abs(a - b)
	n = m // 2
	print(n * (n + 1) + [0, n + 1][m % 2])
solve()


a = int(input())
b = int(input())
x = abs(a - b)
if x % 2 == 1:
	n = x // 2
	m = x // 2 + 1
	print(n * (n + 1) // 2 + m * (m + 1) // 2)
else:
	n = x // 2
	m = x // 2
	print(n * (n + 1) // 2 + m * (m + 1) // 2)


a = int(input())
b = int(input())
s = a + b
if s % 2 == 0:
	s = s // 2
	if a < b:
		p = s - a
	else:
		p = s - b
	ans = p * (p + 1) // 2
	print(ans * 2)
else:
	s = s // 2
	if a < b:
		p = s - a
	else:
		p = s - b
	ans = p * (p + 1) // 2
	ans = ans * 2
	print(ans + p + 1)


a = int(input())
b = int(input())
c = abs(a - b)
r = 0
if c % 2 != 0:
	c += 1
	r = 1
n = c // 2
f = n * (n + 1)
if r == 1:
	f -= n
print(f)


a = int(input())
b = int(input())
d = abs(a - b)
n = d // 2
if d % 2 == 0:
	solution = n * ((n + 1) / 2) * 2
else:
	solution = n * ((n + 1) / 2) * 2 + n + 1
print(int(solution))


a = int(input())
b = int(input())

def t(x):
	return x * (x + 1) // 2
m = (a + b) // 2
d1 = abs(a - m)
d2 = abs(b - m)
print(t(d1) + t(d2))


def sumArif(a1, n):
	return (2 * a1 + n - 1) / 2 * n
a = int(input())
b = int(input())
minn = 0
maxx = 0
if a > b:
	maxx = a
	minn = b
else:
	maxx = b
	minn = a
delta = maxx - minn
if delta % 2 == 1:
	print(int(sumArif(1, delta // 2) * 2 + delta // 2 + 1))
else:
	print(int(sumArif(1, delta // 2) * 2))


n = int(input())
m = int(input())
s = 0
ss = (n + m) / 2 - min(n, m)
if ss % 1 != 0:
	s = int(ss) + 1
else:
	s = 0
ss = int(ss)
for i in range(1, ss + 1):
	s += 2 * i
print(s)


a = int(input())
b = int(input())
steps = 0
d = (a + b) // 2
if a > b:
	tmp = a
	a = b
	b = tmp
for i in range(a, d):
	steps += i - a + 1
for j in range(d, b):
	steps += j - d + 1
print(steps)


a = int(input())
b = int(input())
c = abs(a - b) / 2
z = int(c)
res = 2 * z * (z + 1) / 2
if z != c:
	res += z + 1
print(int(res))


def main():
	a = int(input())
	b = int(input())
	if (b - a) % 2 == 0:
		d = abs(b - a) // 2
		r = d * (d + 1)
	else:
		d = abs(b - a) // 2
		r = d * (d + 1) // 2
		r += (d + 1) * (d + 2) // 2
	print(r)
main()


n = int(input())
m = int(input())
if m - n == 1 or n - m == 1:
	print(1)
else:
	x = abs(n - m)
	if x % 2 == 0:
		x = x // 2
		print(x * x + x)
	else:
		x = x // 2 + 1
		print(x * x)


a = int(input())
b = int(input())
diff = max(a, b) - min(a, b)
ans = 0
for i in range(1, 100000):
	if diff >= 2:
		diff -= 2
		ans += 2 * i
	else:
		diff -= 1
		ans += i
	if diff == 0:
		break
print(ans)


a = int(input())
b = int(input())
tmn = 0
tmx = 0
cmx = 0
cmn = 0
if a > b:
	max = a
	min = b
else:
	max = b
	min = a
if a == b:
	t = 0
elif a - b == 1 or b - a == 1:
	t = 1
else:
	while True:
		max -= 1
		cmx += 1
		tmx += cmx
		if max == min:
			t = tmx + tmn
			break
		min += 1
		cmn += 1
		tmn += cmn
		if max == min:
			t = tmx + tmn
			break
print(t)


a = int(input())
b = int(input())
if abs(a - b) == 1:
	print('1')
else:
	n = abs(a - b)
	h = n // 2
	s = h * (h + 1) // 2
	if n % 2 == 0:
		print(2 * s)
	else:
		r = 2 * s + (h + 1)
		print(r)


a = int(input())
b = int(input())
(a_steps, b_steps) = (0, 0)

def get_tiredness(s):
	t = 0
	for i in range(1, s + 1):
		t += i
	return t
if b - a > 1:
	while b - a > 1:
		a_steps += 1
		b_steps += 1
		a += 1
		b -= 1
elif a - b > 1:
	while a - b > 1:
		a_steps += 1
		b_steps += 1
		a -= 1
		b += 1
if a - b == 1 or b - a == 1:
	a_steps += 1
	a = b
print(get_tiredness(a_steps) + get_tiredness(b_steps))


from functools import reduce

def s(n):
	n = reduce(lambda x, y: x + y, range(1, n + 1))
	return n
x = abs(int(input()) - int(input()))
if x == 1:
	print(1)
	exit()
if x % 2 == 0:
	print(2 * s(x // 2))
else:
	print(2 * s(x // 2) + (1 + x // 2))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	a = I()
	b = I()
	s = abs(a - b)
	t = s // 2
	u = s - t
	r = t * (t + 1) // 2
	r += u * (u + 1) // 2
	return r
print(main())


n = int(input())
m = int(input())
sub = abs(n - m)
div = round(sub / 2)
cnt = 0
if sub == 1:
	for i in range(1, sub + 1):
		cnt += i
else:
	for i in range(1, div + 1):
		cnt += i
	for j in range(1, sub - div + 1):
		cnt += j
print(cnt)


a = int(input())
b = int(input())
if b > a:
	(a, b) = (b, a)
d = a - b
if d % 2 == 0:
	print(int(2 * (d / 2 * (d / 2 + 1) / 2)))
else:
	print(int(2 * (d // 2 * (d // 2 + 1) / 2) + (d // 2 + 1)))


list1 = []
list2 = []
a = int(input())
b = int(input())
tt = 0
t1 = 0
t2 = 0
c = abs(a - b)
while len(list1) < c:
	t1 = t1 + 1
	list1.append(t1)
	t2 = t2 + 1
	list1.append(t2)
if len(list1) > c:
	list2 = list1[0:-1]
else:
	list2 = list1
print(sum(list2))


(a, b) = (int(input()), int(input()))
da = abs(a - b) // 2
db = abs(a - b) - da
print(da * (da + 1) // 2 + db * (db + 1) // 2)


a = int(input())
b = int(input())
x = max(a, b)
y = min(a, b)
z = (a + b) // 2
h = z - y
j = h * (h + 1) / 2
l = x - z
t = l * (l + 1) / 2
o = int(j + t)
print(o)


def dist(x, y):
	return abs(x - y)

def tired(x):
	return x * (x + 1) // 2
dyn_sum = [1000000000 for i in range(1000)]
a = int(input())
b = int(input())
for i in range(1, 1001):
	dyn_sum[i - 1] = tired(dist(a, i)) + tired(dist(i, b))
print(min(dyn_sum))


dist = abs(int(input()) - int(input()))
print(dist // 2 * (dist // 2 + 1) + dist % 2 * (dist + 1) // 2)


a = int(input())
b = int(input())
c = abs(a - b) // 2
if abs(a - b) % 2 == 0:
	print(2 * sum([x for x in range(c + 1)]))
else:
	print(2 * sum([x for x in range(c + 1)]) + c + 1)


n = int(input())
m = int(input())
if n - m == 1 or n - m == -1:
	print(1)
else:
	i = 1
	s = 0
	while n != m:
		if n > m:
			n -= 1
			s += i
			if n == m:
				break
			m += 1
			s += i
		else:
			n += 1
			s += i
			if n == m:
				break
			m -= 1
			s += i
		i += 1
	print(s)


def f(x):
	return int(x * (x + 1) / 2)
a = int(input())
b = int(input())
m = int((a + b) / 2)
print(f(abs(m - a)) + f(abs(b - m)))


n = abs(int(input()) - int(input())) - 1
a = 2
b = -2 * n - 2
c = n ** 2 + 3 * n + 2
e = -b // (2 * a)
if e <= 0:
	e = 1
r = (a * e ** 2 + b * e + c) // 2
print(r)


a = int(input())
b = int(input())
d = max(a - b, b - a)
if d % 2 == 0:
	y = int(d / 2)
else:
	y = int(d / 2) + 1
f1 = 0
for i in range(1, int(d / 2) + 1):
	f1 += i
f2 = 0
for i in range(1, y + 1):
	f2 += i
if d == 1:
	print(1)
else:
	print(f1 + f2)


import sys
a = int(sys.stdin.readline().strip())
b = int(sys.stdin.readline().strip())

def tri(d):
	return d * (d + 1) // 2
d = abs(a - b)
if d % 2 == 0:
	tide = 2 * tri(d // 2)
else:
	tide = tri((d - 1) // 2) + tri((d + 1) // 2)
print(tide)


boy1 = int(input())
boy2 = int(input())
distance = abs(boy1 - boy2)
remainder = distance % 2
if remainder == 0:
	distance1 = distance // 2 + 1
	distance2added = 0
	mySum = 0
	for i in range(1, distance1):
		mySum += i
	totalSum = mySum * 2
	print(totalSum)
elif remainder == 1:
	distance1 = distance // 2 + 1
	distance2added = 1
	mySum = 0
	for i in range(1, distance1):
		mySum += i
	totalSum = mySum * 2 + distance1
	print(totalSum)


a = int(input())
b = int(input())
m = (a + b) // 2
s = 0
for i in range(abs(m - a)):
	s += i + 1
for i in range(abs(b - m)):
	s += i + 1
print(s)


p = int(input())
q = int(input())
print((abs(p - q) + 1) ** 2 // 4)


a = int(input())
b = int(input())
dis = abs(a - b)

def getSum(a):
	a = int(a)
	if a <= 1:
		return a
	else:
		return (1 + a) * a / 2
if dis % 2 == 0:
	ans = getSum(dis / 2) * 2
else:
	ans = getSum(dis / 2) + getSum(dis / 2 + 1)
print(int(ans))


a = int(input())
b = int(input())
difference = abs(a - b)
move1 = int(difference / 2)
move2 = difference - move1
result = int(move1 * (move1 + 1) / 2 + move2 * (move2 + 1) / 2)
print(result)


a = int(input())
b = int(input())
a_tired = 0
b_tired = 0
tired = 0
while a != b:
	if a < b:
		a += 1
		a_tired += 1
		tired += a_tired
		if a == b:
			break
		else:
			b -= 1
			b_tired += 1
			tired += b_tired
	elif a > b:
		b += 1
		b_tired += 1
		tired += b_tired
		if a == b:
			break
		else:
			a -= 1
			a_tired += 1
			tired += a_tired
print(tired)


a = int(input())
b = int(input())
d = abs(a - b)
if d % 2 == 0:
	tmp = d // 2
	print(2 * (1 + tmp) * tmp // 2)
else:
	tmp = d // 2
	first = (1 + tmp + 1) * (tmp + 1) // 2
	second = (tmp + 1) * tmp // 2
	print(first + second)


a = int(input())
b = int(input())
pasos = 0
puntodellegada = abs(a - b)
pasos = puntodellegada / 2 * (puntodellegada / 2) + puntodellegada / 2
print(round(pasos))


a = int(input())
b = int(input())
dist = abs(a - b)
t1 = dist // 2
t2 = (dist + 1) // 2
print(t1 * (t1 + 1) // 2 + t2 * (t2 + 1) // 2)


n = int(input())
m = int(input())
x = abs(m - n)
a = x // 2
b = x - a
print(a * (a + 1) // 2 + b * (b + 1) // 2)


def sumOfNum(n):
	return n * (n + 1) / 2
a = int(input())
b = int(input())
dist = abs(a - b)
tired1 = dist // 2
tired2 = dist - tired1
TotalTired = sumOfNum(tired1) + sumOfNum(tired2)
print(int(TotalTired))


a = int(input())
b = int(input())
c = int()
k = 0
m = 0
if a > b:
	c = a - b
else:
	c = b - a
if c % 2 == 0:
	c = c // 2
	for i in range(0, c + 1):
		k = k + i
	for i in range(c, 0, -1):
		m = m + i
else:
	c = c // 2
	for i in range(0, c + 1):
		k = k + i
	for i in range(c + 1, 0, -1):
		m = m + i
print(k + m)


a = int(input())
b = int(input())
c = a - b
d = int(abs(c))
k = d // 2
if d % 2 == 0:
	print(int(d * (d // 2 + 1) // 2))
else:
	print(int(k * (k + 1) // 2) + int((k + 1) * (k + 2) // 2))


a = int(input())
b = int(input())
x = (a + b) // 2
p = abs(a - x)
q = abs(b - x)
ans = (p * (p + 1) + q * (q + 1)) // 2
print(ans)


n = abs(int(input()) - int(input()))
print((n + 1) // 2 * ((n + 2) // 2))


qi = lambda : int(input())
qs = lambda : input().split()
n = qi()
m = qi()
print(sum(range(1, abs(m - n) // 2 + 1)) + sum(range(1, abs(m - n) - abs(m - n) // 2 + 1)))


a = int(input())
b = int(input())
health = 0
i = 1
if a > b:
	x = (a - b) // 2 + b
	while a != b:
		if a != x:
			a -= 1
			health += i
		if b != x:
			b += 1
			health += i
		i += 1
else:
	x = (b - a) // 2 + a
	while a != b:
		if a != x:
			a += 1
			health += i
		if b != x:
			health += i
			b -= 1
		i += 1
print(health)


t = list(map(int, input().split()))
n = list(map(int, input().split()))
a = (t[0] + n[0]) // 2
q = abs(a - t[0])
w = abs(a - n[0])
print(w * (w + 1) // 2 + q * (q + 1) // 2)


import math
a = int(input())
b = int(input())
if a > b:
	temp = a
	a = b
	b = temp
else:
	pass
point = math.ceil((b + a) / 2)
if b - a == 1 or a - b == -1:
	print(1)
else:
	distance1 = point - a
	distance2 = b - point
	tired1 = distance1 * (distance1 + 1) / 2
	tired2 = distance2 * (distance2 + 1) / 2
	print(int(tired2 + tired1))


a = int(input())
b = int(input())
d = abs(a - b)
h = d // 2
i = 1
res = 0
for ind in range(h):
	res += i
	i += 1
res = 2 * res
if d % 2 == 1:
	res += i
print(res)


n = int(input())
m = int(input())
c = (n + m) // 2
l = 0
for i in range(abs(c - n)):
	l += i + 1
for j in range(abs(m - c)):
	l += j + 1
print(l)


a = int(input())
b = int(input())
x = abs(a - b) // 2
s = x * (1 + x) // 2
s *= 2
if abs(a - b) % 2 == 1:
	s += x + 1
print(s)


a = int(input())
b = int(input())
sredn = (a + b) // 2
(r_a, r_b) = (abs(a - sredn), abs(b - sredn))
(c_a, c_b) = (r_a * (r_a + 1) / 2, r_b * (r_b + 1) / 2)
print(int(c_a + c_b))


a = int(input())
b = int(input())
x = abs(b - a) // 2
n = 0
for k in range(x + 1):
	n += 2 * k
if abs(b - a) % 2 == 1:
	n += x + 1
print(n)


def PA(x):
	return (1 + x) * x / 2
a = int(input())
b = int(input())
diz = abs(b - a)
if diz % 2 == 0:
	print(int(PA(diz // 2) * 2))
else:
	print(int(PA(diz // 2) + PA(diz // 2 + 1)))


a = int(input())
b = int(input())
len = abs(a - b)
if len % 2 == 0:
	moves = len // 2 * (len // 2 + 1)
else:
	moves = len // 2 * (len // 2 + 2) + 1
print(moves)


x = int(input())
y = int(input())
tired = 1
total = 0
a = max(x, y)
b = min(x, y)
while a != b:
	if a - b >= 2:
		b += 2
		total += tired * 2
		tired += 1
	else:
		b += 1
		total += tired
print(total)


def sum_seq(n):
	ans = 0
	for i in range(1, n + 1):
		ans += i
	return ans
a = int(input())
b = int(input())
if abs(a - b) % 2 == 0:
	print(2 * sum_seq(abs(a - b) // 2))
else:
	print(2 * sum_seq(abs(a - b) // 2) + abs(a - b) // 2 + 1)


a = int(input())
b = int(input())
n = abs(b - a)
e = 0
c = 0
if n % 2 != 0:
	nt = int(n / 2 + 0.5)
else:
	nt = int(n / 2)
for i in range(nt + 1):
	e = e + 2 * i
if n % 2 != 0:
	c = e - nt
else:
	c = e
print(c)


a = int(input())
b = int(input())
m = (a + b) // 2 + (a + b) % 2
(a, b) = (min(a, b), max(a, b))
a1 = 0
b1 = 0
for i in range(a, m + 1):
	a1 += i - a
for i in range(m, b):
	b1 += b - i
if b - a == 1:
	print(1)
else:
	print(a1 + b1)


a = int(input())
b = int(input())
x = (a + b) // 2
n1 = abs(a - x)
res1 = n1 * (n1 + 1) // 2
n2 = abs(b - x)
res2 = n2 * (n2 + 1) // 2
print(res1 + res2)


x1 = int(input())
x2 = int(input())
ust = 1
ans = 0
s = abs(x2 - x1)
while s > 1:
	s -= 2
	ans += ust * 2
	ust += 1
if s == 1:
	ans += ust
print(ans)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
mid = int((a + b) // 2)
x = mid - a
y = b - mid
print(int(x * (x + 1) // 2 + y * (y + 1) // 2))


a = int(input())
b = int(input())
d = abs(a - b)
s = (1 + d // 2) * (d // 2)
if d % 2 == 1:
	s += d // 2 + 1
print(s)


n = int(input())
m = int(input())
a = abs(m - n)
if a == 1:
	print(1)
else:
	c = 0
	for i in range(1, a // 2 + 1):
		c += i
	if a % 2 == 0:
		print(2 * c)
	else:
		print(2 * c + a // 2 + 1)


a = int(input())
b = int(input())
diff = abs(a - b)
sum1 = 0
if diff == 1:
	print(1)
elif diff % 2 == 0:
	for i in range(1, diff // 2 + 1):
		sum1 += 2 * i
	print(sum1)
else:
	for i in range(1, diff // 2 + 1):
		sum1 += 2 * i
	sum1 += diff // 2 + 1
	print(sum1)


a = int(input())
b = int(input())
r = max(a, b)
l = min(a, b)
step = 0
ll = 1
rr = 1
ans = 0
while r != l:
	if step % 2 == 0:
		ans += ll
		ll += 1
		l += 1
	else:
		ans += rr
		rr += 1
		r -= 1
	step += 1
print(ans)


a = int(input())
b = int(input())
dif = abs(b - a)
f1 = dif // 2
sum1 = f1 * (f1 + 1) // 2
f2 = dif - f1
sum2 = f2 * (f2 + 1) // 2
print(sum1 + sum2)


x = int(input())
y = int(input())
print((abs(x - y) + 1) ** 2 // 4)


def main():
	a = int(input())
	b = int(input())
	diff = abs(a - b)
	amount = diff // 2
	parity = diff % 2
	print((1 + amount) * amount + parity * (amount + 1))
main()


x1 = int(input().strip())
x2 = int(input().strip())
d = abs(x1 - x2)
n = d // 2
rem = d % 2
result = (1 + n) * n
result += rem * (n + 1)
print(result)


import sys
import math
import bisect

def main():
	a = int(input())
	b = int(input())
	d1 = abs(a - b) // 2
	d2 = (abs(a - b) + 1) // 2
	ans = 0
	for i in range(1, d1 + 1):
		ans += i
	for i in range(1, d2 + 1):
		ans += i
	print(ans)
main()


def s(n):
	sum = 0
	for i in range(1, n + 1):
		sum += i
	return sum
a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
step = b - a
if step % 2 == 0:
	print(s(step // 2) * 2)
else:
	print(s(step // 2) * 2 + (step + 1) // 2)


f1 = int(input())
f2 = int(input())
middle = (f1 + f2) // 2
t = 1
total = 0
for i in range(abs(f1 - middle)):
	total += t
	t += 1
t = 1
for i in range(abs(f2 - middle)):
	total += t
	t += 1
print(total)


def soma(n):
	soma = 0
	for i in range(1, n + 1):
		soma += i
	return soma
a = int(input())
b = int(input())
dist = abs(a - b)
paraCada = dist // 2
if dist % 2 == 0:
	ans = soma(paraCada) * 2
else:
	ans = soma(paraCada) + soma(paraCada + 1)
print(ans)


a = int(input())
b = int(input())
m = (a + b) // 2
sum1 = 0
sum2 = 0
if a == m:
	print(abs(m - b))
if b == m:
	print(abs(m - a))
if a != m and b != m:
	z = abs(m - a)
	for i in range(1, z + 1):
		sum1 = sum1 + i
	q = abs(m - b)
	for j in range(1, q + 1):
		sum2 = sum2 + j
	print(sum1 + sum2)


a = int(input())
b = int(input())
d = abs(a - b)
if d % 2 == 0:
	n = d // 2
	s = n * (n + 1) // 2
	print(2 * s)
else:
	n = d // 2
	s1 = n * (n + 1) // 2
	s2 = (d - n) * (d - n + 1) // 2
	print(s1 + s2)


import math
a = int(input())
b = int(input())
c = abs(a - b)
c1 = math.ceil(c / 2)
c2 = math.floor(c - c / 2)
for i in range(1, c1 + 1):
	for j in range(1, c2 + 1):
		pass
	print(math.ceil(c1 * (c1 + 1) / 2 + c2 * (c2 + 1) / 2))
	break


a = int(input())
b = int(input())
tbc = (a + b) // 2
print((abs(a - tbc) + 1) * abs(a - tbc) // 2 + (abs(b - tbc) + 1) * abs(b - tbc) // 2)


def som(n):
	if n == 1:
		sum = 1
	else:
		sum = n / 2 * (2 + (n - 1))
	return int(sum)
x = int(input())
y = int(input())
tire = 0
mean = (x + y) // 2
if x == y + 1 or y == x + 1:
	u = 0
	v = 1
else:
	a = mean - x
	b = y - mean
	if a < 0:
		a = -1 * a
		b = -1 * b
	if a == 1 and b == 1:
		u = 1
		v = 1
	else:
		u = som(a)
		v = som(b)
tire = u + v
print(tire)


a = int(input())
b = int(input())
r = abs(a - b) // 2
r1 = abs(a - b) - r
s = r * (r + 1) // 2
s += r1 * (r1 + 1) // 2
print(s)


n = int(input())
m = int(input())
t = 0
w = (abs(m - n) - 1) // 2
t += w * (w + 1)
if (m - n - 1) % 2 != 0:
	t += (w + 1) * 2
else:
	t += w + 1
print(t)


a = int(input())
b = int(input())
x = (a + b) // 2
print(abs(a - x) * (abs(a - x) + 1) // 2 + abs(b - x) * (abs(b - x) + 1) // 2)


a = int(input())
b = int(input())
c = max(a, b) - min(a, b)
d = 0
i = 0
b = []
while d < c:
	d += 1
	if len(b) % 2 == 0:
		i += 1
	b.append(i)
print(sum(b))


a = int(input())
b = int(input())
c = (a + b) // 2
if b > a:
	x = 0
	y = 0
	for n in range(1, b - c + 1):
		x = x + n
	for n in range(1, c - a + 1):
		y = y + n
	z = x + y
	print(z)
elif a > b:
	x = 0
	y = 0
	for n in range(1, a - c + 1):
		x = x + n
	for n in range(1, c - b + 1):
		y = y + n
	z = x + y
	print(z)


a = int(input())
b = int(input())
n = 0
k = 0
f = 0
s = 0
l = 0
n = abs(b - a) // 2
f = (1 + n) * n // 2
l = abs(b - a) - n
s = (1 + l) * l // 2
k = s + f
print(k)


a = [0] * 1001
for i in range(1, 1001):
	a[i] = a[i - 1] + i
n = int(input())
m = int(input())
print(a[abs(n - m) // 2] + a[(abs(n - m) + 1) // 2])


a1 = int(input())
b1 = int(input())
result = 0
plus = 1
diff = abs(a1 - b1)
while diff > 0:
	result += plus
	diff -= 1
	if diff == 0:
		break
	result += plus
	diff -= 1
	plus += 1
print(result)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def main():
	a = GI()
	b = GI()
	d = abs(a - b)
	(div, mod) = divmod(d, 2)
	l = [div + mod, div]
	print(int(sum((n * (n + 1) / 2 for n in l))))
main()


a = int(input())
b = int(input())
minval = min(a, b)
maxval = max(a, b)
diff = abs(a - b)
cnt = 0
for i in range(1, diff + 1):
	if minval == maxval:
		break
	minval += 1
	cnt += i
	if minval == maxval:
		break
	maxval -= 1
	cnt += i
print(cnt)


a = int(input())
b = int(input())
if a > b:
	dis = a - b
	if dis % 2 == 1:
		dis = int(dis / 2)
		dis = dis * (dis + 1) + (dis + 1)
	else:
		dis = int(dis / 2)
		dis = dis * (dis + 1)
else:
	dis = b - a
	if dis % 2 == 1:
		dis = int(dis / 2)
		dis = dis * (dis + 1) + (dis + 1)
	else:
		dis = int(dis / 2)
		dis = dis * (dis + 1)
print(dis)


def solve(first, second):
	result = 0
	first_tired = 1
	second_tired = 1
	swing = True
	if first > second:
		(first, second) = (second, first)
	while first < second:
		if swing:
			first += 1
			result += first_tired
			first_tired += 1
			swing = not swing
		else:
			second -= 1
			result += second_tired
			second_tired += 1
			swing = not swing
	return result
first_friend = int(input())
second_friend = int(input())
print(solve(first_friend, second_friend))


a = int(input())
b = int(input())
x = abs(a - b)
temp = 0
if x == 1:
	print(1)
elif x == 2:
	print(2)
elif x % 2 == 0:
	for i in range(1, x // 2 + 1):
		temp += i
	print(temp * 2)
else:
	for i in range(1, x // 2 + 1):
		temp += i
	print(temp * 2 + i + 1)


a = int(input())
b = int(input())
diff = abs(a - b)
half_diff = diff // 2
if half_diff % 2 == 0:
	tiredness = 2 * (half_diff + 1) * half_diff // 2
elif half_diff == 1:
	tiredness = 2
else:
	tiredness = 2 * (half_diff + 1) * half_diff // 2
if diff % 2 != 0:
	tiredness += half_diff + 1
print(tiredness)


x1 = int(input())
x2 = int(input())
d = abs(x1 - x2)
base = d // 2
rem = d % 2
ans = base * (base + 1)
if rem:
	ans += base + 1
print(ans)


a = int(input())
b = int(input())
tiredness1 = 0
tiredness2 = 0
steps = 1
if a < b:
	while a != b:
		a += 1
		tiredness1 += 1 * steps
		if a != b:
			b -= 1
			tiredness2 += 1 * steps
		steps += 1
elif a > b:
	while a != b:
		b += 1
		tiredness2 += 1 * steps
		if a != b:
			a -= 1
			tiredness1 += 1 * steps
		steps += 1
print(tiredness1 + tiredness2)


n = int(input())
m = int(input())
dfr = abs(n - m) + 1
s = dfr // 2
print((s + dfr % 2) * s)


a = int(input())
b = int(input())
result = 0
contA = 0
contB = 0
while a != b:
	if contA > contB:
		if b > a:
			b -= 1
		else:
			b += 1
		contB += 1
		result += contB
	else:
		if a < b:
			a += 1
		else:
			a -= 1
		contA += 1
		result += contA
print(result)


t = int(input())
p = int(input())
if t - p == 1:
	print(1)
elif p - t == 1:
	print(1)
else:
	final = abs(p - t)
	if final % 2 == 0:
		print(int(final * (final + 2) // 4))
	else:
		print(int((final - 1) * (final - 1 + 2) // 4) + final // 2 + 1)


import math
a = int(input())
b = int(input())
dist = abs(b - a)
total = 0
posa = posb = 0
while posa + posb != dist:
	posa += 1
	total += posa
	if posa + posb == dist:
		break
	posb += 1
	total += posb
print(total)


x = int(input())
y = int(input())

def f(n):
	a = n * (n + 1)
	return a
if y > x:
	c = y - x
else:
	c = x - y
n = c // 2
if c % 2 == 0:
	print(f(n))
else:
	print(f(n) + n + 1)


a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
c1 = (a + b) // 2
c2 = (a + b + 1) // 2
ans = (1 + c1 - a) * (c1 - a) / 2
ans += (1 + b - c2) * (b - c2) / 2
if c1 != c2:
	ans += min(c2 - a, b - c1)
print(int(ans))


a = int(input())
b = int(input())
k = max(a, b)
p = min(a, b)
d = k - p
if d % 2 == 0:
	n = d // 2
	t = n * (n + 1)
	print(t)
else:
	n = d // 2
	m = n + 1
	t = n * (n + 1) + m
	print(t)


first = int(input())
second = int(input())
fn = 0
sn = 0
z = abs(first - second)
mas = []
while True:
	if z > 0:
		z = z - 1
		sn = sn + 1
		mas.append(sn)
		if z > 0:
			z = z - 1
			fn = fn + 1
			mas.append(fn)
	else:
		break
print(sum(mas))


a = int(input())
b = int(input())

def fact(a):
	ans = 0
	for i in range(a, 0, -1):
		ans = ans + i
	return ans
d = abs(a - b)
if d == 1:
	print('1')
elif d % 2 == 0:
	a = fact(d // 2)
	a = a * 2
	print(a)
else:
	a = fact(d // 2)
	b = fact((d + 1) // 2)
	print(a + b)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
tire = 0
tempA = 1
tempB = 1
turn = 0
while a < b:
	if turn == 0:
		a += 1
		tire += tempA
		turn = 1
		tempA += 1
	else:
		b -= 1
		tire += tempB
		turn = 0
		tempB += 1
print(tire)


a = int(input())
b = int(input())
diff = abs(a - b)
if diff % 2 == 0:
	d = diff // 2
	ans = d * (d + 1)
else:
	d = diff // 2
	ans = d * (d + 1)
	ans += d + 1
print(ans)


a = int(input())
b = int(input())
move = b - a if b - a > 0 else a - b
if move % 2 == 0:
	one_move = move // 2
	print(int(2 * ((1 + one_move) * (one_move / 2))))
else:
	one_move = (move - 1) // 2
	print(int(2 * ((1 + one_move) * (one_move / 2)) + (one_move + 1)))


a = int(input())
b = int(input())
d = 0
diff = abs(a - b)
if not diff % 2:
	diff //= 2
	while diff:
		d += 2 * diff
		diff -= 1
	print(d)
else:
	p1 = diff // 2
	p2 = diff // 2 + 1
	while p2:
		d += p1 + p2
		p1 -= 1
		p2 -= 1
	print(d)


a = int(input())
b = int(input())
best = 10 ** 18

def dist(a, b):
	l = max(a - b, b - a)
	if l == 0:
		return 0
	return l * (l + 1) // 2
for x in range(1, 2000):
	best = min(best, dist(x, a) + dist(x, b))
print(best)


a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
s = (a + b) // 2
d = (a + b) % 2
x = sum(range(s - a + 1))
y = sum(range(b - s + 1))
print(x + y)


a = int(input())
b = int(input())
len = abs(a - b)
ma = len // 2
mb = len - ma
print(int(ma * (ma + 1) / 2 + mb * (mb + 1) / 2))


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
s = 0
c1 = 1
c2 = 1
i = 1
while True:
	if a == b:
		break
	if i % 2 != 0:
		a = a + 1
		s = s + c1
		c1 = c1 + 1
	else:
		b = b - 1
		s = s + c2
		c2 = c2 + 1
	i = i + 1
print(s)


import math
x = int(input().strip())
y = int(input().strip())

def test_1(y, x):
	a = y - x + 1
	if x == 0:
		return 'No'
	if x == 1 and y != 0:
		return 'No'
	if a < 0:
		return 'No'
	else:
		b = a / 2 + 1
		if round(b / round(b), 10) == 1.0:
			return 'Yes'
		else:
			return 'No'

def test_2(y, x):
	n = abs(x - y)
	if n % 2 == 1:
		n = n // 2 + 1
		a1 = n * (n - 1) / 2
		a2 = n * (n + 1) / 2
		a = a1 + a2
	else:
		n = n // 2
		a = n * (n + 1)
	return int(a)
aa = test_2(y, x)
print(aa)


from math import ceil
a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
mid = (a + b) // 2
counter = 1
first = 0
for i in range(a, b):
	first += counter
	counter += 1
second = 0
counter = 1
for i in range(min(mid - a, b - mid)):
	second += counter
	counter += 1
second *= 2
if mid - a != b - mid:
	second += counter
print(min(first, second))


a = int(input())
b = int(input())
(a, b) = (min(a, b), max(a, b))
c = round((a + b) / 2)
ans = 0
ans += round((c - a + 1) * (c - a) / 2)
ans += round((b - c + 1) * (b - c) / 2)
print(ans)


a = int(input())
b = int(input())
y = (a + b) // 2
a = abs(y - a)
b = abs(y - b)
print(a * (a + 1) // 2 + b * (b + 1) // 2)


a = int(input())
b = int(input())
x = 0
for i in range(abs(a - int((a + b) / 2)) + 1):
	x += i
for i in range(abs(b - int((a + b) / 2)) + 1):
	x += i
print(x)


import math
a = int(input())
b = int(input())
if a > b:
	temp = b
	b = a
	a = temp
a_moves = math.ceil((b - a) / 2)
b_moves = math.floor((b - a) / 2)
a_tiredness = 0
b_tiredness = 0
for i in range(0, a_moves):
	a_tiredness += i + 1
for j in range(0, b_moves):
	b_tiredness += j + 1
print(a_tiredness + b_tiredness)


a = int(input())
b = int(input())
d = abs(a - b)
if d == 0 or d == 1:
	print(d)
	exit(0)
if d % 2 == 0:
	n = d // 2
	print(n * (n + 1))
else:
	n = d // 2
	m = n + 1
	print(n * (n + 1) // 2 + m * (m + 1) // 2)


def solution(x1, x2):
	d = abs(x1 - x2)
	c1 = int(d / 2)
	c2 = int(d / 2) + d % 2
	return int((c1 * (c1 + 1) + c2 * (c2 + 1)) / 2)

def answer():
	x1 = int(input())
	x2 = int(input())
	print(solution(x1, x2))
answer()


a = int(input())
b = int(input())
m = abs(a - b) // 2
if 2 * m != abs(a - b):
	print(m + 1 + m * (m + 1))
else:
	print(m * (m + 1))


a = int(input())
b = int(input())
e = 0
if abs(a - b) % 2 == 0:
	for i in range(1, abs(a - b) // 2 + 1):
		e += i * 2
elif abs(a - b) == 1:
	e += 1
else:
	for i in range(1, abs(a - b) // 2 + 1):
		e += i * 2
	e += abs(a - b) // 2 + 1
print(e)


def okaj(xxx):
	xxx = int(xxx)
	j = 0
	jog = 0
	li = []
	for i in range(1, 1001):
		if i % 2 == 1:
			j += 1
		jog += j
		li.append(jog)
	return li[xxx - 1]
a = int(input())
b = int(input())
c = abs(a - b)
print(okaj(c))


ac = int(input())
bc = int(input())
l = abs(ac - bc)
ma = l // 2
mb = l - ma
print(int(ma * (ma + 1) / 2 + mb * (mb + 1) / 2))


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
(ans, cur) = (0, 1)
while b - a >= 2:
	ans += cur * 2
	cur += 1
	b -= 1
	a += 1
if a != b:
	ans += cur
print(ans)


a = int(input())
b = int(input())
total = abs(a - b)
aWalk = total // 2
bWalk = abs(total - aWalk)
aTired = aWalk * (aWalk + 1) // 2
bTired = bWalk * (bWalk + 1) // 2
print(aTired + bTired)


import math
a = int(input())
b = int(input())
c = abs(a - b) / 2
d = math.floor(c)
e = math.ceil(c)
f = int(d / 2 * (1 + d))
g = int(e / 2 * (1 + e))
print(f + g)


n = int(input())
m = int(input())
if n > m:
	(n, m) = (m, n)
cnt = 0
tr1 = tr2 = 1
while True:
	if n == m:
		break
	if tr1 > tr2:
		m -= 1
		cnt += tr2
		tr2 += 1
	else:
		n += 1
		cnt += tr1
		tr1 += 1
print(cnt)


def abs(x):
	if x > 0:
		return x
	return -x
n = int(input())
m = int(input())
print((abs(m - n) + 1) // 2 * (abs(m - n) // 2 + 1))


a = int(input())
b = int(input())
c = min(a, b) + abs(a - b) // 2
sa = 0
sb = 0
for i in range(abs(a - c)):
	sa += i + 1
for i in range(abs(b - c)):
	sb += i + 1
print(sa + sb)


import sys

def main():
	(a, b) = map(int, sys.stdin.read().strip().split())
	d = abs(b - a)
	return (1 + d // 2) * (d // 2 + d % 2)
print(main())


a = int(input())
b = int(input())
u = 0
if a < b:
	s = 1
else:
	s = -1
d1 = 1
d2 = 1
while a != b:
	if d1 <= d2:
		a += s
		u += d1
		d1 += 1
	elif d1 > d2:
		b -= s
		u += d2
		d2 += 1
print(u)


a = int(input())
b = int(input())
d = int(abs(b - a))
S = 0
if d % 2 == 0:
	for i in range(int(d / 2) + 1):
		S = S + i
	print(2 * S)
else:
	for i in range(int((d - 1) / 2) + 1):
		S = S + i
	print(2 * S + int((d - 1) / 2) + 1)


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
m = int((b - a) / 2)
k = b - a - m
c = int(m * (m + 1) / 2 + k * (k + 1) / 2)
print(c)


a = int(input())
b = int(input())
c = abs(b - a)
e = c // 2
d = c % 2
print(e * (e + 1) + d * (d + e))


a = int(input())
b = int(input())
dif = abs(a - b)
m1 = dif // 2
m2 = dif - m1
print(m1 * (m1 + 1) // 2 + m2 * (m2 + 1) // 2)


a = int(input())
b = int(input())
l = int((a + b) / 2)
c = 0
for i in range(1, abs(l - a) + 1):
	c += i
for i in range(1, abs(l - b) + 1):
	c += i
print(c)


a = int(input())
b = int(input())
k = abs(a - b) % 2
n = abs(a - b) // 2
sum = (2 + n * 2) // 2 * n
sum += (1 + n) * k
print(sum)


a = int(input())
b = int(input())
aF = 1
bF = 1
allF = 0
if b < a:
	(a, b) = (b, a)
while a != b:
	a += 1
	allF += aF
	aF += 1
	if a != b:
		b -= 1
		allF += bF
		bF += 1
print(allF)


import math
a = int(input())
b = int(input())
bar = 0
foo = 0
k = 0
c = max(abs(a), abs(b)) - min(abs(a), abs(b))
if c % 2 == 0:
	k = int(c / 2 + 1)
	for i in range(1, k):
		bar += i
	bar *= 2
if c % 2 != 0:
	for i in range(1, math.ceil(c / 2) + 1):
		bar += i
	for i in range(1, math.floor(c / 2) + 1):
		foo += i
	bar += foo
print(bar)


a = int(input())
b = int(input())
d = abs(b - a)
if d == 1:
	print(1)
elif d == 0:
	print(0)
elif d % 2 == 0:
	p = d // 2
	s = p * (p + 1) // 2
	print(s * 2)
else:
	p = d // 2
	s = p * (p + 1) // 2
	print(s * 2 + (p + 1))


n = int(input())
m = int(input())
c = (n + m) // 2
if n <= c:
	t = c - n
else:
	t = n - c
if m <= c:
	k = c - m
else:
	k = m - c
h = t * (t + 1) // 2
g = k * (k + 1) // 2
print(h + g)


import math
a = int(input())
b = int(input())
if abs(b - a) == 1:
	print(1)
	exit(0)
if (a + b) % 2 == 0:
	m = (a + b) // 2
	n = abs(a - m)
	res = n * (n + 1)
	print(res)
else:
	m = (a + b) // 2
	if a < b:
		n = abs(a - m)
	else:
		n = abs(b - m)
	res = n * (n + 1) // 2 + (n + 1) * (n + 2) // 2
	print(res)


(a, b) = (int(input()), int(input()))
c = (a + b) // 2
d = 0
(e, f) = (abs(a - c), abs(b - c))
for i in range(1, e + 1):
	d += i
for i in range(1, f + 1):
	d += i
print(d)


a = int(input())
b = int(input())
ust = 0
if a > b:
	s = a - b
else:
	s = b - a
if s > 1:
	if s % 2 == 0:
		shagi = s // 2
		for i in range(1, shagi + 1):
			ust += 2 * i
	else:
		shagi = s // 2 + 1
		for i in range(1, shagi + 1):
			ust += 2 * i
		ust -= shagi
else:
	ust = 1
print(ust)


l = []
l.append(int(input()))
l.append(int(input()))
l.sort()
n = l[0]
m = l[1]
t = 1
tot = 0
while n != m:
	n += 1
	tot += t
	if n == m:
		print(tot)
		exit()
	m -= 1
	tot += t
	if n == m:
		print(tot)
		exit()
	t += 1


import sys
import itertools as it
a = int(sys.stdin.readline())
b = int(sys.stdin.readline())
if a > b:
	(a, b) = (b, a)
m = (a + b) // 2
r = sum(range(0, m + 1 - a)) + sum(range(0, b + 1 - m))
print(r)


a = int(input())
b = int(input())
c = (a + b) // 2
s1 = abs(a - c)
s2 = abs(b - c)
print(s1 * (s1 + 1) // 2 + s2 * (s2 + 1) // 2)


def get_natural_sum(n):
	return n * (n + 1) // 2
a = int(input())
b = int(input())
(n1, n2) = (max(a, b), min(a, b))
dist_a = (n1 - n2) // 2
dist_b = n1 - n2 - dist_a
print(get_natural_sum(dist_a) + get_natural_sum(dist_b))


d = abs(int(input()) - int(input()))
print(d // 2 * (d // 2 + 1) + ((d + 1) // 2 if d & 1 else 0))


a = int(input())
b = int(input())
res = (a + b) // 2
fin1 = abs(res - a) * (abs(res - a) + 1) // 2
fin2 = abs(res - b) * (abs(res - b) + 1) // 2
print(fin1 + fin2)


def form(a):
	return (a ** 2 + a) // 2
x = int(input())
y = int(input())
if x > y:
	(x, y) = (y, x)
meet = (x + y) // 2
print(form(y - meet) + form(meet - x))


n = int(input())
m = int(input())
A = []
if n > m:
	s = n - m
else:
	s = m - n
if s % 2 == 0:
	g = s // 2
	print(g * (g + 1))
else:
	g = s // 2
	print(g * (g + 1) + g + 1)


print((lambda x, y: abs(x - y) // 2 * (abs(x - y) // 2 + 1) // 2 + (abs(x - y) - abs(x - y) // 2) * (abs(x - y) - abs(x - y) // 2 + 1) // 2)(int(input()), int(input())))


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
res = 0
mid = (a + b) // 2
res += (mid - a) * (mid - a + 1) // 2
res += (b - mid) * (b - mid + 1) // 2
print(int(res))


a = int(input())
b = int(input())
m = (a + b) // 2
s1 = abs(a - m)
s2 = abs(b - m)
s1 = s1 * (s1 + 1) // 2
s2 = s2 * (s2 + 1) // 2
print(int(s1 + s2))


from math import *

def fun(n):
	return n * (n + 1) // 2
a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
print(fun((b - a) // 2) + fun(ceil((b - a) / 2)))


from math import ceil
a = int(input())
b = int(input())
g = ceil((a + b) / 2)
f = abs(g - a)
h = abs(g - b)
cnt = 0
d = 0
for i in range(f + 1):
	cnt += i
for i in range(h + 1):
	d += i
print(cnt + d)


import math
a = int(input())
b = int(input())
d = abs(a - b)
d1 = math.floor(d / 2)
d2 = math.ceil(d / 2)
total = int(d1 * (d1 + 1) / 2 + d2 * (d2 + 1) / 2)
print(total)


from math import ceil
a = int(input())
b = int(input())
x = ceil((a + b) / 2)
q = abs(a - x)
p = abs(b - x)
print(q * (q + 1) // 2 + p * (p + 1) // 2)


a = int(input())
b = int(input())
n = abs(a - b)
k = n - n // 2
n = n // 2
res = n * (n + 1) // 2 + k * (k + 1) // 2
print(res)


a = int(input())
b = int(input())
m = (a + b) // 2
da = abs(m - a)
db = abs(m - b)
ans = da * (da + 1) // 2 + db * (db + 1) // 2
print(ans)


from math import ceil
n = int(input())
t = int(input())
x = ceil((n + t) / 2)
y = abs(x - n)
z = y * (y + 1) // 2
yy = abs(x - t)
zz = yy * (yy + 1) // 2
print(zz + z)


import math
a_tired = 0
b_tired = 0
a = int(input())
b = int(input())
point = (a + b) // 2
b_route = abs(b - point)
a_route = abs(a - point)
for i in range(1, a_route + 1):
	a_tired += i
for i in range(1, b_route + 1):
	b_tired += i
total = a_tired + b_tired
print(str(total))


from math import ceil
n = int(input())
k = int(input())
a = abs(n - k)
c = 0
if a == 1:
	print(1)
elif a % 2 == 0:
	for i in range(1, int(a / 2) + 1):
		c += i * 2
	print(c)
else:
	for i in range(1, int(a / 2) + 1):
		c += i * 2
	print(c + ceil(a / 2))


a = int(input())
b = int(input())
diff = abs(a - b) - 1
if diff % 2 == 1:
	d_a = diff // 2 + 1
	d_b = d_a
	ans = d_a * (d_a + 1)
else:
	d_a = diff // 2
	d_b = d_a + 1
	ans = d_a * (d_a + 1) // 2 + d_b * (d_b + 1) // 2
print(ans)


a = int(input())
b = int(input())
s = abs(a - b)
q = s // 2
w = s - q
ans = 0
ans += q + q * (q - 1) // 2
ans += w + w * (w - 1) // 2
print(ans)


def sum_upto(n):
	x = 0
	for i in range(0, n + 1):
		x += i
	return x
a = int(input())
b = int(input())
x = (a + b) // 2
print(sum_upto(abs(x - a)) + sum_upto(abs(x - b)))


a = int(input())
b = int(input())
tmp = abs(a - b)
step = tmp // 2 * (tmp // 2 + 1) + tmp // 2 + 1 if tmp % 2 == 1 else tmp // 2 * (tmp // 2 + 1)
print(step)


x1 = int(input())
x2 = int(input())
t = 0
k = 1
fatigue1 = 0
fatigue2 = 0
delta = x2 - x1 if x2 > x1 else x1 - x2
while delta > 0:
	if t % 2 == 0:
		fatigue1 = fatigue1 + k
	else:
		fatigue2 = fatigue2 + k
		k = k + 1
	t = t + 1
	delta = delta - 1
print(fatigue1 + fatigue2)


import math
a = int(input())
b = int(input())
z = math.fabs(a - b) // 2
n = 0
for i in range(int(math.fabs(a - b) - z) + 1):
	n += i
for i in range(int(z) + 1):
	n += i
print(n)


def main():
	x = abs(int(input()) - int(input()))
	print(x * (x + 1) // 2 - x // 2 * (x - x // 2))
main()


a = int(input())
b = int(input())
dis = abs(b - a)
if dis % 2 == 0:
	dis //= 2
	g = dis * (dis + 1) // 2
	print(g * 2)
else:
	dis //= 2
	g1 = dis * (dis + 1) // 2
	g2 = (dis + 1) * (dis + 2) // 2
	print(g1 + g2)


n1 = int(input())
n2 = int(input())
if n1 > n2:
	c = n1
	n1 = n2
	n2 = c
c = 0
p1 = 0
p2 = 0
s = 0
while n1 < n2:
	if c % 2 == 0:
		n1 += 1
		p1 += 1
		s = s + p1
	else:
		n2 -= 1
		p2 += 1
		s = s + p2
	c += 1
print(s)


x1 = int(input())
x2 = int(input())
m1 = abs(x1 - x2) // 2
m2 = abs(x1 - x2) - m1
print(int(m1 * (m1 + 1) / 2 + m2 * (m2 + 1) / 2))


a = int(input())
b = int(input())
if abs(b - a) % 2 == 0:
	n = abs(b - a) / 2
	m = abs(b - a) / 2
	value = n * (n + 1) / 2 + m * (m + 1) / 2
	value = int(value)
	print(value)
if abs(b - a) % 2 != 0 and abs(b - a) != 1:
	n = abs(b - a + 1) / 2
	m = abs(b - a - 1) / 2
	value = n * (n + 1) / 2 + m * (m + 1) / 2
	value = int(value)
	print(value)
if abs(b - a) == 1:
	print(1)


a = int(input())
b = int(input())
l = abs(a - b)
ma = l // 2
mb = l - ma
print(int(ma * (ma + 1) / 2 + mb * (mb + 1) / 2))


a = int(input())
b = int(input())
if b < a:
	(b, a) = (a, b)
m = 0

def tiredness(n):
	sum = 0
	for i in range(1, n + 1):
		sum += i
	return sum
diff = abs(a - b)
if diff == 1:
	print(1)
	exit()
m = diff // 2
if diff % 2 == 0:
	print(tiredness(abs(a - (a + m))) + tiredness(abs(b - (b - m))))
else:
	print(tiredness(abs(a - (a + m))) + tiredness(abs(b - (b - m - 1))))


a = int(input())
b = int(input())
k = abs(a - b)
a = k // 2 * (k // 2 + 1)
if k % 2 == 1:
	a += (k + 1) // 2
print(a)


a = int(input())
b = int(input())
n = abs(b - a)
if not n % 2:
	n = n // 2
	print(n * (n + 1))
else:
	n //= 2
	print(n * (n + 1) + (n + 1))


a = int(input())
b = int(input())
n = (a + b) // 2
l = abs(a - n)
r = abs(b - n)
count = 0
for x in range(1, l + 1):
	count = count + x
for y in range(1, r + 1):
	count = count + y
print(count)


def get_sum(end):
	if end == 0:
		return 0
	return (1 + end) * end / 2
i1 = int(input())
i2 = int(input())
a1 = min(i1, i2)
a2 = max(i1, i2)
m = (a1 + a2) // 2
res1 = get_sum(m - a1)
res2 = get_sum(a2 - m)
print(int(res1 + res2))


def main():
	A = int(input())
	B = int(input())
	n = abs(A - B)
	(x, y) = divmod(n, 2)
	y += x
	tired = x * (x + 1) // 2 + y * (y + 1) // 2
	print(tired)
main()


a = int(input())
b = int(input())
c = abs(a - b)
if c == 1:
	ans = 1
elif c == 2:
	ans = 2
else:
	q = c // 2
	w = c - q
	a1 = q * (q + 1) / 2
	a2 = w * (w + 1) / 2
	ans = a1 + a2
print(int(ans))


a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
r = (b - a) // 2
print((1 + r) * r + (r + 1) * int((b - a) % 2 != 0))


a = int(input())
b = int(input())
dist = abs(a - b)
tierd = 0
c = dist // 2
for i in range(c + 1):
	tierd = tierd + 2 * i
if dist % 2 != 0:
	tierd = tierd + c + 1
print(tierd)


a = int(input())
b = int(input())
mid = int((a + b) / 2)
d1 = abs(mid - a)
d2 = abs(b - mid)
ans = d1 * (d1 + 1) / 2 + d2 * (d2 + 1) / 2
print(int(ans))


def calc(x):
	return x * (x + 1) // 2
a = int(input())
b = int(input())
if a > b:
	(a, b) = (b, a)
mid = a + b >> 1
print(calc(mid - a) + calc(b - mid))


a = int(input())
b = int(input())
l = abs(a - b)
l1 = l // 2
l2 = l - l1
print(l1 * (l1 + 1) // 2 + l2 * (l2 + 1) // 2)


x = int(input())
y = int(input())
dist = abs(x - y)
x = dist // 2
y = dist - x
t1 = x * (x + 1) // 2
t2 = y * (y + 1) // 2
print(t1 + t2)


a = int(input())
b = int(input())
mn = min(a, b)
mx = max(a, b)
res = mn * (mn + 1) // 2 + mx * (mx + 1) // 2
for i in range(mn, mx + 1):
	res = min(res, (mx - i) * (mx - i + 1) // 2 + (i - mn) * (i - mn + 1) // 2)
print(res)


a = int(input())
b = int(input())
c = b - a if b - a >= 0 else a - b
print(c * (c + 2) // 4 if c % 2 == 0 else (c - 1) * (c + 1) // 4 + (c + 1) // 2)


a = int(input())
b = int(input())
dist1 = abs(a - b) // 2
dist2 = abs(a - b) - abs(a - b) // 2
sum = 0
for i in range(1, dist1 + 1 if dist1 >= dist2 else dist2 + 1):
	if i == (dist1 if dist1 >= dist2 else dist2) and dist1 != dist2:
		sum += i
	else:
		sum += i * 2
print(sum)


import math
a = int(input())
b = int(input())
(x, y) = (max(a, b), min(a, b))
d = x - y
sum = 0
if d % 2 == 0:
	for i in range(1, d // 2 + 1):
		sum = sum + i * 2
else:
	for i in range(1, d // 2 + 1):
		sum = sum + i * 2
	sum = sum + math.ceil(d / 2)
print(sum)


a = int(input())
b = int(input())
diff = abs(a - b)
tired = sum(2 * list(range(1, diff // 2 + 1))) + diff % 2 * (diff - diff // 2)
print(tired)


a = int(input())
b = int(input())
tired = 0
distA = (max(a, b) - min(a, b)) // 2
distB = max(a, b) - min(a, b) - distA
print(distA * (distA + 1) // 2 + distB * (distB + 1) // 2)


import math

def not_factorial(x):
	result = x
	for i in reversed(range(x)):
		result += i
	return result
a = int(input())
b = int(input())
distance = abs(a - b)
a = not_factorial(math.floor(distance / 2))
b = not_factorial(math.ceil(distance / 2))
print(a + b)


a = int(input())
b = int(input())
k = min(a, b)
sum1 = 0
sum2 = 0
l = max(a, b)
z = l + k
x = z // 2
sum1 = (x - k) / 2 * (x - k + 1)
sum2 = (l - x) / 2 * (l - x + 1)
result = int(sum1 + sum2)
print(result)


a = int(input())
b = int(input())
point = int(a / b)
tired = 0
i = 1
j = 1
while a != b:
	if a < b:
		if i < j:
			a += 1
			tired += i
			i += 1
		else:
			b -= 1
			tired += j
			j += 1
	elif i < j:
		a -= 1
		tired += i
		i += 1
	else:
		b += 1
		tired += j
		j += 1
print(tired)


a = int(input())
b = int(input())
l = abs(a - b)
aa = l // 2
bb = l - aa
print(aa * (aa + 1) // 2 + bb * (bb + 1) // 2)


a = int(input())
b = int(input())
if a > b:
	k = a - b
else:
	k = b - a
if k % 2 == 0:
	j = k // 2
	x = 0
	for v in range(0, j + 1):
		x = x + v
	y = 0
	for v in range(j, 0, -1):
		y = y + v
	print(x + y)
else:
	j = k // 2
	x = 0
	for s in range(0, j + 1):
		x = x + s
	y = 0
	for s in range(j + 1, 0, -1):
		y = y + s
	print(x + y)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
a = get_int()
b = get_int()
d = (a + b) // 2
first = abs(d - a)
second = abs(b - d)
print(first * (first + 1) // 2 + second * (second + 1) // 2)


a = int(input())
b = int(input())
c = abs(a - b)
if c == 1:
	print(1)
elif c % 2 == 0:
	d = c // 2
	d = d * (d + 1) // 2
	print(d * 2)
else:
	d = c // 2
	e = c // 2 + 1
	d = d * (d + 1) // 2
	e = e * (e + 1) // 2
	print(d + e)


n = int(input())
m = int(input())
diff = abs(n - m)
t1 = diff // 2
t2 = diff - t1
t1 = t1 * (t1 + 1) // 2
t2 = t2 * (t2 + 1) // 2
print(t1 + t2)


(a, b) = (int(input()), int(input()))
k = (max(a, b) - min(a, b)) // 2
h = (max(a, b) - min(a, b)) % 2
print(k * (k + 1) + h * (k + 1))


a = int(input())
b = int(input())
c = (a + b) // 2
ma = abs(a - c)
mb = abs(b - c)
ea = sum(range(ma + 1))
eb = sum(range(mb + 1))
print(ea + eb)


from collections import Counter
a = int(input())
b = int(input())
p = abs(a - b)
if p == 1:
	print(1)
else:
	q = p // 2
	m = p - q * 2
	print(q * (q + 1) + (q + 1 if p % 2 != 0 else 0))


n = int(input())
m = int(input())
l = abs(m - n) // 2
a = l
b = abs(m - n) - l
ans = 0
for i in range(a + 1):
	ans += i
for i in range(b + 1):
	ans += i
print(ans)


a = int(input(''))
b = int(input(''))
c = a - b
p = 0
if c < 0:
	c = c * -1
s = c // 2
p = s * (s + 1)
if c % 2 != 0:
	p = p + s + 1
print(p)


a = int(input())
b = int(input())
d = a - b
t = a - b
if d < 0:
	d = -d
	t = -t
d = d // 2
s = 2 * (d * (d + 1) / 2)
if t % 2 != 0:
	s += d + 1
print(int(s))


import sys
I = sys.stdin.readline
a = int(I())
b = int(I())
tired = 0
a_tired = 0
b_tired = 0
if a > b:
	flag = 0
else:
	flag = 1
while a != b:
	if a > b:
		if flag == 0:
			a_tired += 1
			tired += a_tired
			a -= 1
			flag = 1
		else:
			b_tired += 1
			tired += b_tired
			b += 1
			flag = 0
	elif flag == 0:
		a_tired += 1
		tired += a_tired
		a += 1
		flag = 1
	else:
		b_tired += 1
		tired += b_tired
		b -= 1
		flag = 0
print(tired)


def tired(a, b):
	diff = abs(a - b)
	if diff & 1 == 0:
		diff //= 2
		ans = diff * (diff + 1) // 2
		return 2 * ans
	x = diff // 2
	y = x + 1
	ans = x * (x + 1) // 2 + y * (y + 1) // 2
	return ans
a = int(input())
b = int(input())
print(tired(a, b))


def sn(x):
	return x * (x + 1) // 2
a = int(input())
b = int(input())
c = (a + b) // 2
s = sn(abs(c - a)) + sn(abs(c - b))
print(s)


import math
a = int(input())
b = int(input())
s = math.fabs(b - a)
r = s / 2
s = int(s)
r = int(r)
t = 0
n = 0
f = 0
e = r + 1
w = 0
q = 0
if s % 2 != 0:
	for i in range(r):
		n += i + 1
	for j in range(r + 1):
		t += j + 1
	print(n + t)
if s % 2 == 0:
	if s == 0:
		print('0')
	for i in range(r):
		n += i + 1
	print(n * 2)