Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.

A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.

More formally, if a game designer selected cells having coordinates (x_1, y_1) and (x_2, y_2), where x_1 ≤ x_2 and y_1 ≤ y_2, then all cells having center coordinates (x, y) such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x_2 - x_1 is divisible by 2.

Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.

Help him implement counting of these units before painting.

 [Image] 


-----Input-----

The only line of input contains four integers x_1, y_1, x_2, y_2 ( - 10^9 ≤ x_1 ≤ x_2 ≤ 10^9,  - 10^9 ≤ y_1 ≤ y_2 ≤ 10^9) — the coordinates of the centers of two cells.


-----Output-----

Output one integer — the number of cells to be filled.


-----Examples-----
Input
1 1 5 5

Output
13

Source: codeforces | Difficulty: HARD
Tags: Mathematics


Solutions:
(a, b, c, d) = map(int, input().split())
e = (c - a) // 2 + 1
print((2 * e - 1) * ((d - b) // 2 + 1) - (e - 1) * int(not (d - b) % 2))


q = input().split()
x1 = int(q[0])
y1 = int(q[1])
x2 = int(q[2])
y2 = int(q[3])
print(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)


(x1, y1, x2, y2) = input().split()
(dx, dy) = (int(x2) - int(x1), int(y2) - int(y1))
if dy % 2 != 0:
	print((dy + 1) // 2 * (dx + 1))
else:
	print((dy // 2 + 1) * (dx // 2 + 1) + dy // 2 * dx // 2)


(x1, y1, x2, y2) = map(int, input().split())
x2 -= x1
y2 -= y1
x1 = 0
y1 = 0
odd_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 0 and x2 % 2 == 0 else 0)
odd_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 0 and y2 % 2 == 0 else 0)
even_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 1 and x2 % 2 == 1 else 0)
even_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 1 and y2 % 2 == 1 else 0)
print(odd_x * odd_y + even_x * even_y)


(t, y1, x2, y2) = map(int, input().split())
print(((y2 - y1) // 2 + 1) * (x2 - t + 1) - (x2 - t) // 2)


import math
(a, b, c, d) = map(lambda x: int(x), input().split(' '))
h = 0
w = c - a + 1
h += (d - b + 1) // 2
summ = h * w
if (a + b) % 2 == 0:
	if (d - b) % 2 == 0:
		summ += w // 2 + w % 2
elif (d - b) % 2 == 0:
	summ += w // 2 + w % 2
print(summ)


def main():
	(x1, y1, x2, y2) = map(int, input().split())
	print((y2 - y1 + 2) // 2 * (x2 - x1 + 1) - (x2 - x1) // 2)
main()


(x1, y1, x2, y2) = [int(x) for x in input().split()]
a = (y2 - y1 + 1) // 2 + 1
b = a - 1
print((x2 - x1 + 1) // 2 * (a + b) + a)


(x1, y1, x2, y2) = map(int, input().split())
ans = ((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2
print(ans)


(x1, y1, x2, y2) = [int(i) for i in input().split()]
dx = x2 - x1 + 1
dy = (y2 - y1) // 2 + 1
if dx % 2 == 1:
	ans = dy * (dx // 2 + 1) + (dy - 1) * (dx // 2)
else:
	ans = dx * dy
print(ans)


(x1, y1, x2, y2) = map(int, input().split(' '))
b = int((y2 - y1 + 1) / 2) + 1
s = b - 1
l = x2 - x1 + 1
ans = b * int((l + 1) / 2) + s * int(l / 2)
print(ans)


ln = input().split(' ')
x1 = int(ln[0])
y1 = int(ln[1])
x2 = int(ln[2])
y2 = int(ln[3])
h = y2 - y1
h = int(h / 2) + 1
w = x2 - x1
w = int(w / 2)
ans = (w + 1) * h + w * (h - 1)
print(ans)


import os, sys, pdb
import time, calendar, datetime
import math, itertools
import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom
(x1, y1, x2, y2) = list(map(int, input().split()))
print(((x2 - x1 + 1) * (y2 - y1 + 1) + 1) // 2)


(x1, y1, x2, y2) = input().split()
x1 = int(x1)
y1 = int(y1)
x2 = int(x2)
y2 = int(y2)
x = int(x2 - x1)
y = int(y2 - y1)
if x % 2 == 0:
	if y % 2 == 1:
		n = int(int(x + 1) * int(y + 1) / 2)
	elif x * y > 1000000:
		t0 = int(x * y) + int(x) + int(y)
		t1 = int(t0) // 2
		n = int(t1) + 1
	elif x * y <= 1000000:
		n = int(int(x * y + x + y) / 2) + 1
else:
	n = int((x + 1) / 2 * (y + 1))
print(n)


import math
(x1, y1, x2, y2) = map(int, input().split())
h = (x2 - x1) // 2
w = (y2 - y1) // 2
print((h + 1) * (w + 1) + h * w)


(a, b, c, d) = map(int, input().split(' '))
dy = (d - b) // 2 + 1
dx = c - a + 1
print(dy * dx - dx // 2)


(x1, y1, x2, y2) = map(int, input().split())
if (y1 + y2) % 2 == 0:
	ans = ((y2 - y1) // 2 + 1) * ((x2 - x1) // 2 + 1) + (y2 - y1) // 2 * ((x2 - x1) // 2)
else:
	ans = ((y2 - y1) // 2 + 1) * (x2 - x1 + 1)
print(int(ans))


(x1, y1, x2, y2) = map(int, input().split())
s = (x2 - x1 + 1) * ((y2 - y1 + 1) // 2) + (x2 - x1 + 2) // 2 * ((y2 - y1 + 1) % 2)
print(s)


(x1, y1, x2, y2) = map(int, input().split())
xlen = (x2 - x1) // 2
(nature, innature) = (xlen + 1, xlen)
baseheight = 1 + (y2 - y1) // 2
print(nature * baseheight + innature * (baseheight - 1))


(x1, y1, x2, y2) = (int(s) for s in input().split())
x = x2 - x1
y = y2 - y1
print((x + 1) * (y // 2 + 1) - (not y % 2) * (x // 2))


(x1, y1, x2, y2) = map(int, input().split())
(a, b) = ((x2 - x1) // 2, (y2 - y1) // 2)
print(a * b + (a + 1) * (b + 1))


(x1, y1, x2, y2) = [int(i) for i in input().split()]
odd = (y2 - y1) // 2 + 1
cnt = (x2 - x1) // 2
print(odd * (x2 - x1 + 1) - cnt)


(x, y, x1, y1) = list(map(int, input().split()))
res1 = (y1 - y + 1) // 2
res2 = y1 - y + 1 - res1
resx1 = (x1 - x + 1) // 2
resx2 = x1 - x + 1 - resx1
print(res1 * resx1 + res2 * resx2)


(xo, yo, xk, yk) = map(int, input().split())
print((xk - xo + 1) * (yk - yo + 1) // 2 + 1)


import math

def cnt(l, r):
	if l % 2 != 0:
		l += 1
	if r % 2 != 0:
		r -= 1
	l //= 2
	r //= 2
	if l <= r:
		return r - l + 1
	return 0

def count(x, l, r):
	if x % 2 == 0:
		return cnt(l, r)
	else:
		return r - l + 1 - cnt(l, r)
line = input()
line = line.split()
x1 = int(line[0])
y1 = int(line[1])
x2 = int(line[2])
y2 = int(line[3])
print(((x2 - x1 + 1) * (y2 - y1 + 1) + 1) // 2)


(x1, y1, x2, y2) = map(int, input().split())
n = (y2 - y1) // 2 + 1
k = x2 - x1 + 1
print(n * (k // 2 + 1) + (n - 1) * (k // 2))


ch = input()
d = ch.split(' ')
x1 = int(d[0])
y1 = int(d[1])
x2 = int(d[2])
y2 = int(d[3])
nby = (y2 - y1) // 2 + 1
nbx = (x2 - x1) // 2 + 1
print(nby * nbx + (nby - 1) * (nbx - 1))


(x1, y1, x2, y2) = map(int, input().split(' '))
x2 -= x1 - 1
y2 -= y1 - 1
x1 = 1
y1 = 1
xo = (x2 - x1 + 1) // 2 + (1 if abs(x1) % 2 == 1 and abs(x2) % 2 == 1 else 0)
xe = (x2 - x1 + 1) // 2 + (1 if abs(x1) % 2 == 0 and abs(x2) % 2 == 0 else 0)
yo = (y2 - y1 + 1) // 2 + (1 if abs(y1) % 2 == 1 and abs(y2) % 2 == 1 else 0)
ye = (y2 - y1 + 1) // 2 + (1 if abs(y1) % 2 == 0 and abs(y2) % 2 == 0 else 0)
print(xo * yo + xe * ye)


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


[x1, y1, x2, y2] = list(map(int, input().split()))
tot = (x2 - x1) // 2
y = (y2 - y1) // 2
bigy = y + 1
sol = tot * y + (tot + 1) * bigy
print(sol)


import re
st = input()
s = re.split('[\\s]', st)
x1 = int(s[0])
y1 = int(s[1])
x2 = int(s[2])
y2 = int(s[3])
s = ((y2 - y1) // 2 + 1) * ((x2 - x1) // 2 + 1) + (y2 - y1) // 2 * (x2 - x1) // 2
print(s)


s = input().split(' ')
a = int(s[2]) - int(s[0])
b = int(s[3]) - int(s[1])
c = a * b + a + b + 1
print((c + 1) // 2)


(x1, y1, x2, y2) = list(map(int, input().split()))
print(((y2 - y1) // 2 + 1) * ((x2 - x1 + 2) // 2) + ((y2 - y1) // 2 + (y2 - y1) % 2) * ((x2 - x1 + 1) // 2))


(x, u, y, v) = map(int, input().split())
(N, M) = (y - x + 1, v - u + 1)
(n, m) = ((N >> 1) * (N & 1), (M >> 1) * (M & 1))
print((N - n) * (M - m) + n * m)


(x1, y1, x2, y2) = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
A = dx // 2 + 1
B = dy // 2 + 1
print(A * B + dx // 2 * ((dy + 1) // 2))


(x1, y1, x2, y2) = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
resx = int(dx / 2 + 1)
resy = int(dy / 2 + 1)
total = resx * resy + (resx - 1) * (resy - 1)
print(total)
exit()
if ux or uy:
	total -= 1
	if ux:
		total -= dy / 2
	if uy:
		total -= dx / 2
print(int(total))


(x1, y1, x2, y2) = map(int, input().split())
xdif = x2 - x1
ydif = y2 - y1
print(xdif // 2 * ydif // 2 + (xdif // 2 + 1) * (ydif // 2 + 1))


import os, 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))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
import decimal

def fun():
	(x1, y1, x2, y2) = iia()
	ans = (y2 - y1) // 2 + 1
	ans *= x2 - x1 + 1
	ans -= (x2 - x1) // 2
	print(ans)
fun()


(x1, y1, x2, y2) = map(int, input().split())
len_y = (abs(y1 - y2) + 1) // 2 + (abs(y1 - y2) + 1) % 2
len_x = abs(x1 - x2) + 1
print(len_x * len_y - len_x // 2)


import math
l = [int(s) for s in input().split(' ')]
x1 = int(l[0])
y1 = int(l[1])
x2 = int(l[2])
y2 = int(l[3])
maxX = (x2 - x1) // 2 + 1
dy = y2 - y1 + 1
yy = (dy + 1) // 2
print(int(maxX * yy + (maxX - 1) * (dy - yy)))


(x1, y1, x2, y2) = map(int, input().split())
t = (y2 - y1) // 2 + 1
r = x2 - x1 + 1
print((r + 1) // 2 * t + r // 2 * (t - 1))


(a, b, c, d) = map(int, input().split(' '))
f = (c - a + 1) * (d - b + 1)
print((f + 1) // 2)


(x, y, a, b) = map(int, input().split(' '))
result = (a - x + 1) * ((b - y) // 2 + 1) - (a - x) // 2
print(result)


(x1, y1, x2, y2) = map(int, input().split())
x = (x2 - x1) // 2
y = (y2 - y1) // 2
print(2 * x * y + x + y + 1)


(x1, y1, x2, y2) = [int(x) for x in input().split()]
print((x2 - x1 + 1) * (y2 - y1 + 1) // 2 + ((y2 - y1) % 2 == 0))


(a, b, x, y) = map(int, input().split())
v = x - a + 1
h = (y - b) // 2 + 1
if v % 2 == 0:
	m = v // 2
	n = v // 2
else:
	m = v // 2 + 1
	n = v - m
print(m * h + n * (h - 1))


(x1, y1, x2, y2) = map(int, input().split())
Y = y2 - y1
cnt_odd = (x2 - x1) // 2
cnt_even = x2 - x1 + 1 - cnt_odd
odd = Y // 2
even = Y + 1 - odd
print(cnt_odd * odd + cnt_even * even)


def get_len(x, y1, y2):
	if x % 2 == 1:
		if y1 % 2 != 0:
			y1 -= 1
		if y2 % 2 != 0:
			y2 += 1
	else:
		if y1 % 2 == 0:
			y1 -= 1
		if y2 % 2 == 0:
			y2 += 1
	return (y2 - y1) // 2
(x1, y1, x2, y2) = map(int, input().split())
if x1 % 2 != y1 % 2:
	y1 += 1
	y2 += 1
(fs, sc, cnt) = (0, 0, 0)
cnt = x2 - x1 + 1
fs = get_len(x1, y1, y2)
sc = get_len(x1 + 1, y1, y2)
print((fs + sc) * (cnt // 2) + fs)


(x1, y1, x2, y2) = [int(i) for i in input().split()]
t = y2 - y1 + 1
h = (x2 - x1 + 2) // 2
print(t // 2 * (h - 1) + (t // 2 + t % 2) * h)


(x1, y1, x2, y2) = [i + 10000000000.0 for i in list(map(int, input().split()))]
deltax = 10000000000.0 - x1
deltay = 10000000000.0 - y1
x1 -= deltax
x2 -= deltax
y1 -= deltay
y2 -= deltay
print((int(y2 / 2) - int((y1 - 1) / 2)) * (int(x2 / 2) - int((x1 - 1) / 2)) + (int((y2 + 1) / 2) - int(y1 / 2)) * (int((x2 + 1) / 2) - int(x1 / 2)))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(x1, y1, x2, y2) = iia()
print(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)


a = input().split(' ')
x1 = int(a[0])
y1 = int(a[1])
x2 = int(a[2])
y2 = int(a[3])
total = 0
ylen = y2 - y1
xlen = x2 - x1
total += (int(xlen / 2) + 1) * (int(ylen / 2) + 1)
total += int(xlen / 2) * int(ylen / 2)
print(int(total))


(x1, x2, y1, y2) = list(map(int, input().split()))
s1 = y1 - x1 + 1
s2 = y2 - x2 + 1
d = max(s1 - s1 // 2, s1 // 2)
o = max(s2 - s2 // 2, s2 // 2)
r = min(s1 - s1 // 2, s1 // 2)
a = min(s2 - s2 // 2, s2 // 2)
print(d * o + r * a)


import sys
import math

def main():
	(x1, y1, x2, y2) = map(int, sys.stdin.readline().strip().split()[:4])
	print(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)
main()


from sys import stdin
(x1, y1, x2, y2) = map(int, stdin.readline().split())
dx = x2 - x1
dy = y2 - y1
result = ((dx + 1) * (dy + 1) + 1) // 2
print(result)


import math

def main():
	(x1, y1, x2, y2) = map(int, input().split())
	(y, x) = (y2 - y1, (x2 - x1) // 2)
	ans = 0
	ans += (1 + x) * (y // 2 + 1)
	ans += x * math.ceil(y / 2)
	print(ans)
main()


def calc(y1, y2, r):
	if y1 % 2 != r:
		y1 -= 1
	if y2 % 2 != r:
		y2 += 1
	return (y2 - y1) // 2
(x1, y1, x2, y2) = map(int, input().split())
(x2, y2, x1, y1) = (x2 - x1, y2 - y1, 0, 0)
xlen = x2 - x1 + 1
(odd, even) = (xlen // 2, xlen // 2)
if xlen % 2 == 1:
	if x1 % 2 == 1:
		odd += 1
	else:
		even += 1
print(odd * calc(y1, y2, 0) + even * calc(y1, y2, 1))


(x1, y1, x2, y2) = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
ans = 0
ans += (dx + 2) // 2 * ((dy + 2) // 2)
ans += (dx + 1) // 2 * (dy // 2)
print(ans)


(a, b, c, d) = list(map(int, input().split()))
if (d - b) % 2 == 0:
	print((c - a + 1) * (d - b + 2) // 2 - (c - a) // 2)
else:
	print((c - a + 1) * ((d - b + 1) // 2))


(x1, y1, x2, y2) = map(int, input().rstrip().split())
width = x2 - x1 + 1
height = (y2 - y1) // 2 + 1
a = width // 2
print((a + 1) * height + a * (height - 1))


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


(x1, y1, x2, y2) = map(int, input().split())
ans1 = ((x2 - x1) // 2 + 1) * ((y2 - y1) // 2 + 1)
x1 += 1
y1 += 1
x2 -= 1
y2 -= 1
ans2 = 0
if x1 <= x2 and y1 <= y2:
	ans2 = ((x2 - x1) // 2 + 1) * ((y2 - y1) // 2 + 1)
print(ans1 + ans2)


(x1, y1, x2, y2) = map(int, input().split())
res = (x2 - x1 + 1) * ((y2 - y1) // 2 + 1) - (x2 - x1) // 2
print(res)