AtCoder Beginner Contest 121 - White Cells

There are H rows and W columns of white square cells.
You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.
How many white cells will remain?
It can be proved that this count does not depend on what rows and columns are chosen.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq H, W \leq 20
 - 1 \leq h \leq H
 - 1 \leq w \leq W

-----Input-----
Input is given from Standard Input in the following format:
H W
h w

-----Output-----
Print the number of white cells that will remain.

-----Sample Input-----
3 2
2 1

-----Sample Output-----
1

There are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.

Difficulty: EASY

Starter code:

Solutions:
(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
B = (H - h) * (W - w)
print(B)


(h, w) = map(int, input().split())
(h1, w1) = map(int, input().split())
print((h - h1) * (w - w1))


(h, w) = map(int, input().split())
(a, b) = map(int, input().split())
h -= a
w -= b
print(h * w)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
v = h * w
print(H * W - (h * W + w * H - v))


(H, W) = list(map(int, input().split()))
(h, w) = list(map(int, input().split()))
print(H * W - h * W - w * H + h * w)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
X = H - h
Y = W - w
Z = X * Y
print(Z)


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


(a, b) = map(int, input().split())
(s, k) = map(int, input().split())
print((a - s) * (b - k))


(a, b) = map(int, input().split())
(a1, b1) = map(int, input().split())
print((a - a1) * (b - b1))


(A, B) = map(int, input().split())
(a, b) = map(int, input().split())
x = A - a
y = B - b
print(int(x * y))


(h1, w1) = map(int, input().split())
(h2, w2) = map(int, input().split())
print((h1 - h2) * (w1 - w2))


(h, w) = map(int, input().split())
(H, W) = map(int, input().split())
print(abs(h - H) * abs(w - W))


(hh, ww) = map(int, input().split())
(h, w) = map(int, input().split())
print((hh - h) * (ww - w))


(x, y) = map(int, input().split())
(h, w) = map(int, input().split())
print((x - h) * (y - w))


(h, w) = map(int, input().split())
(n, m) = map(int, input().split())
print((h - n) * (w - m))


(A, B) = map(int, input().split())
(C, D) = map(int, input().split())
print(abs(A - C) * abs(B - D))


(H, W, h, w) = map(int, open(0).read().split())
print((H - h) * (W - w))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
print(max(H * W - h * W - w * (H - h), 0))


(n1, k1) = map(int, input().split())
(n2, k2) = map(int, input().split())
print((n1 - n2) * (k1 - k2))


(a, b) = map(int, input().split())
(n, m) = map(int, input().split())
print(a * b - a * m - b * n + n * m)


(h, w) = map(int, input().split())
(s, t) = map(int, input().split())
print(h * w - s * w - t * h + s * t)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
a = (H - h) * (W - w)
print(a)


(A, B) = map(int, input().split())
(h, w) = map(int, input().split())
print(A * B - A * w - B * h + h * w)


(a, b) = list(map(int, input().split()))
(a_l, b_l) = list(map(int, input().split()))
ans = (a - a_l) * (b - b_l)
print(ans)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
D = H * W
K = h * W + w * H - h * w
print(D - K)


(h, w) = map(int, input().split())
(h0, w0) = map(int, input().split())
print((h - h0) * (w - w0))


(x, y) = map(int, input().split())
(a, b) = map(int, input().split())
print(x * y - (a * y + b * x - a * b))


(H, W) = tuple(map(int, input().split()))
(h, w) = tuple(map(int, input().split()))
print((H - h) * (W - w))


(h, w) = map(int, input().split())
(n, k) = map(int, input().split())
print((h - n) * (w - k))


(H, W) = map(int, input().split(' '))
(h, w) = map(int, input().split(' '))
black = H * w + W * h - h * w
print(H * W - black)


(h, w, a, b) = map(int, open(0).read().split())
print(h * w - a * w - b * h + a * b)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
ans = H * W - h * W - w * (H - h)
print(ans)


(a, b, c, d) = map(int, open(0).read().split())
print((a - c) * (b - d))


def main():
	(H, W) = list(map(int, input().split()))
	(h, w) = list(map(int, input().split()))
	print((H - h) * (W - w))

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
(x, y) = map(int, input().split())
print(n * m - x * m - y * n + x * y)


f = lambda : map(int, input().split())
(H, W) = f()
(h, w) = f()
print((H - h) * (W - w))


(a, i) = map(int, input().split())
(b, j) = map(int, input().split())
print((a - b) * (i - j))


def lcm(a, b):
	return a * b // math.gcd(a, b)
MOD = 10 ** 9 + 7
(H, W) = list(map(int, input().split()))
(h, w) = list(map(int, input().split()))
print((H - h) * (W - w))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
S = H * W
print(S - h * W - w * H + h * w)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
ka = h * w
print(H * W - h * W - w * H + ka)


(h, w) = map(int, input().split())
(t, u) = map(int, input().split())
print((h - t) * (w - u))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
b = 0
b = (H - h) * (W - w)
print(b)


(H, W) = map(int, input().split())
(Hs, Ws) = map(int, input().split())
print((H - Hs) * (W - Ws))


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

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

def main():
	(H, W) = Input()
	(h, w) = Input()
	print(H * W - (H * w + W * h - h * w))
main()


(lh, lw) = map(int, input().split())
(h, w) = map(int, input().split())
print((lh - h) * (lw - w))


(H, W) = map(int, input().split())
(hi, wi) = map(int, input().split())
print(W * H - W * hi - H * wi + hi * wi)


(H, W) = map(int, input().split())
(a, b) = map(int, input().split())
print(H * W - H * b - W * a + a * b)


(a, b) = [list(map(int, input().split())) for _ in range(2)]
print((a[0] - b[0]) * (a[1] - b[1]))


def lcm(a, b):
	return a * b // math.gcd(a, b)
(H, W) = list(map(int, input().split()))
(h, w) = list(map(int, input().split()))
print((H - h) * (W - w))


(H, W) = input().split()
(h, w) = input().split()
a = int(H) - int(h)
b = int(W) - int(w)
print(a * b)


(hn, wn) = map(int, input().split())
(h, w) = map(int, input().split())
print(hn * wn - (h * wn + w * hn - h * w))


(h, w) = list(map(int, input().split()))
(i, j) = list(map(int, input().split()))
print((h - i) * (w - j))


(H, M) = map(int, input().split())
(h, m) = map(int, input().split())
print((H - h) * (M - m))


(H, W) = input().split()
print(eval('(' + H + '-' + input().replace(' ', ')*(' + W + '-') + ')'))


(H1, W1) = map(int, input().split())
(H2, W2) = map(int, input().split())
print((W2 - W1) * (H2 - H1))


(H, W) = list(map(int, input().split()))
(h, w) = list(map(int, input().split()))
a = H - h
b = W - w
print(a * b)


(H, W) = input().split()
(h, w) = input().split()
x = int(H) - int(h)
y = int(W) - int(w)
print(x * y)


(A, B) = map(int, input().split())
(a, b) = map(int, input().split())
print((A - a) * (B - b))


I = lambda : map(int, input().split())
(H, W) = I()
(h, w) = I()
print((H - h) * (W - w))


[print((H - h) * (W - w)) for (H, W, h, w) in [map(int, open(0).read().split())]]


(H, W) = list(map(int, input().split()))
(h, w) = [int(i) for i in input().split()]
n = (H - h) * (W - w)
print(n)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
A = (H - h) * (W - w)
print(A)


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


(rows, columns) = list(map(int, input().split()))
(black_rows, black_columns) = list(map(int, input().split()))
area = rows * columns
black_space = black_columns * rows + black_rows * columns - black_rows * black_columns
print(area - black_space)


(lh, lw, h, w) = map(int, open(0).read().split())
print((lh - h) * (lw - w))


(h, w, x, y) = map(int, open(0).read().split())
print((h - x) * (w - y))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
t = H * W
o = h * W + w * H
c = h * w
diff = o - c
print(t - diff)


(n, k) = map(int, input().split())
(a, b) = map(int, input().split())
print((n - a) * (k - b))


(h1, w1, h2, w2) = map(int, open(0).read().split())
print((h1 - h2) * (w1 - w2))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
X = (H - h) * (W - w)
print(X)


(N, W) = map(int, input().split())
(n, w) = map(int, input().split())
print((N - n) * (W - w))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
HW = []
for i in range(H):
	sublist = []
	for j in range(W):
		sublist.append(0)
	HW.append(sublist)
for i in range(h):
	for j in range(W):
		HW[i][j] = 1
for i in range(w):
	for j in range(H):
		if HW[j][i] == 1:
			continue
		HW[j][i] = 1
cnt = 0
for i in range(H):
	for j in range(W):
		if HW[i][j] == 0:
			cnt += 1
print(cnt)


import sys
(a, b, c, d) = map(int, sys.stdin.read().split())
print((a - c) * (b - d))


import numpy as np
import math
from numba import njit
from scipy.special import perm
from scipy.special import comb

def lcm(a, b):
	return a * b // math.gcd(a, b)
MOD = 10 ** 9 + 7
(H, W) = list(map(int, input().split()))
(h, w) = list(map(int, input().split()))
print((H - h) * (W - w))


(H, W) = map(int, input().split())
(y, x) = map(int, input().split())
print((H - y) * (W - x))


(H, W) = map(int, input().split())
(hh, ww) = map(int, input().split())
print((H - hh) * (W - ww))


(H, M) = map(int, input().split())
(h, w) = map(int, input().split())
print((H - h) * (M - w))


(x, y) = map(int, input().split())
(X, Y) = map(int, input().split())
print((x - X) * (y - Y))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
lw = H * W - (h * W + H * w - h * w)
print(lw)


(w, h) = map(int, input().split())
(W, H) = map(int, input().split())
print(str((W - w) * (H - h)))


(h, w) = map(int, input().split())
(q, a) = map(int, input().split())
print((h - q) * (w - a))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
x = H * W - h * W - H * w + h * w
print(x)


(h, w) = map(int, input().split())
(l, m) = map(int, input().split())
print((h - l) * (w - m))


(A, B) = list(map(int, input().split()))
(C, D) = list(map(int, input().split()))
print((A - C) * (B - D))


def input2():
	return map(int, input().split())
(H, W) = input2()
(h, w) = input2()
ans = (H - h) * (W - w)
print(ans)


(H, W) = map(int, input().split())
(h_b, w_b) = map(int, input().split())
print((H - h_b) * (W - w_b))


(H1, W1) = map(int, input().split())
(H2, W2) = map(int, input().split())
H = H1 - H2
W = W1 - W2
print(H * W)


(H, W) = map(int, input().split())
(A, B) = map(int, input().split())
print(H * W - H * B - A * W + A * B)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
n = h * W + w * (H - h)
print(H * W - n)


import numpy as np
import math

def lcm(a, b):
	return a * b // math.gcd(a, b)
(H, W) = list(map(int, input().split()))
(h, w) = list(map(int, input().split()))
print((H - h) * (W - w))


(uh, uw) = map(int, input().split())
(h, w) = map(int, input().split())
print((uh - h) * (uw - w))


(a, b) = [int(x) - int(y) for (x, y) in zip(*[input().split() for _ in [0, 0]])]
print(a * b)


(r, l) = map(int, input().split())
(n, m) = map(int, input().split())
print((r - n) * (l - m))


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
seki = H * W
print(seki - (h * W + w * H - h * w))


(h, w) = map(int, input().split())
(ah, aw) = map(int, input().split())
print((h - ah) * (w - aw))


(a, s) = map(int, input().split())
(f, g) = map(int, input().split())
print((a - f) * (s - g))


(N, M) = map(int, input().split())
(A, B) = map(int, input().split())
X = (N - A) * (M - B)
print(X)


(H, W) = map(int, input().split())
(h, w) = map(int, input().split())
sum = H * W - H * w - W * h + w * h
print(sum)