Problem:


Score : 100 points

Problem Statement

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 1

3 2
2 1

Sample Output 1

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.

Sample Input 2

5 5
2 3

Sample Output 2

6

Sample Input 3

2 4
2 4

Sample Output 3

0



Sample input:
3 2
2 1


Sample output:
1

Submission status: Runtime Error

Solution code:
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,j] = array[:,i] * 0
print(array[array==1].sum())

Submission status: Runtime Error

Solution code:
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,i] = array[:,i] * 0
print(array[array==1].sum())

Submission status: Runtime Error

Solution code:
HW = list(map(int, input().split))
hw = list(map(int, input().split))

print(HW[0]*HW[1] - hw[0]*HW[1] - HW[0]*hw[1] + hw[0]*hw[1])

Submission status: Runtime Error

Solution code:
import numpy as np


N, M = map(int, input().split())
A, B = list(), list()
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = np.array(A)
B = np.array(B)

n_bins = 0
cost = 0
indices = np.argsort(A)
for idx in indices:
    print(idx, B[idx], A[idx] * B[idx])
    # enough bins @idx
    if n_bins + B[idx] > M:
        cost += A[idx] * (M - n_bins)
        break
    # buy all bins
    else:
        n_bins += B[idx]
        cost += A[idx] * B[idx]
print(cost)

Submission status: Runtime Error

Solution code:
H, W = int(input()), int(input())
h, w = int(input()), int(input())
print((H - h) * (W - w))

Submission status: Runtime Error

Solution code:
H,W=input().split()
h,w=input().split()
print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
H, W = list(map(int, input()))
h, w = list(map(int, input()))

total = H * W
black = h * W + H * w - h * w
white = total - black
print(white)

Submission status: Runtime Error

Solution code:
N, M, C = map(int, input().split())
B = []
A = []

B.append(map(int, input().split()))
for i in range(N):
	A.append(list(map(int, input().split())))


sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j]
		sum += B[j]
	sum += C
	if sum > 0:
		count += 1

print(sum)

Submission status: Runtime Error

Solution code:
H,W=map(int,input(),split())
h,w=map(int,input().split())
math=H*W
black=h*w+H*w-h*w
white=math-black
print(white)

Submission status: Runtime Error

Solution code:
H,W=map(int,inout(),split())
h,w=map(int,inout().split())
all=H*W
black=h*w+H*w-h*w
white=all-black
purint(white)

Submission status: Runtime Error

Solution code:
H,W = input().split(" ")
h,w = input().spplit(" ")

print((H-h) * (W-w))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
total_cost = 0

N, M = (map(int, input().split()))

AB_list = []
for i in range(N):
    AB_list.append((list(map(int, input().split()))))

AB_list = sorted(AB_list)

for i in range(N):
    if AB_list[i][1]<M:
        M = M - AB_list[i][1]
        total_cost =  total_cost + AB_list[i][0] * AB_list[i][1]
    else:
        total_cost = total_cost + M * AB_list[i][0]
        break
print(total_cost)

Submission status: Runtime Error

Solution code:

total_cost = 0

N, M = (map(int, input().split()))

AB_list = []
for i in range(N):
    AB_list.append((list(map(int, input().split()))))

AB_list.sort()

for i in range(N):
    if AB_list[i][1]<M:
        M = M - AB_list[i][1]
        total_cost =  total_cost + AB_list[i][0] * AB_list[i][1]
    else:
        total_cost = total_cost + M * AB_list[i][0]
        break
print(total_cost)

Submission status: Runtime Error

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

import numpy as np

H,W=int(input().split())
h,w=int(input().split())

mat=np.ones((H,W))
mat[0:h,:]=0
mat[:,0:w]=0

print(np.sum(mat))

Submission status: Runtime Error

Solution code:
import numpy as np

H,W=input().split()
h,w=input().split()

mat=np.ones((H,W))
mat[0:h,:]=0
mat[:,0:w]=0

print(np.sum(mat))

Submission status: Runtime Error

Solution code:
### coding: UTF-8
import sys

head = sys.stdin.readline()
[n, m] = head.split(" ")
n = int(n)  # 店の件数
m = int(m)  # 購入本数

amount = 0

# 店の件数分読み込み
rows = [sys.stdin.readline() for _ in range(n)]
rows.sort()
for row in rows:
    [a, b] = row.strip().split(" ")
    an = int(a) # 金額
    bn = int(b) # 購入可能な数量
    # 購入可能な最大数まで買う
    x = bn if m >= bn else m
    amount += an * x
    m -= x
    if m == 0:
        break

print amount

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import numpy as np

N_s, M_s, C_s = input().split()
N = int(N_s)
M = int(M_s)
C = int(C_s)

B = [int(i) for i in input().split()]
A = []
for rows in range(0,N):
    tmp = [int(i) for i in input().split()]
    A.append(tmp)

B_array = np.array(B)
A_array = np.array(A)

val = np.dot(A_array, B_array) + C
print(np.sum(val>0))

Submission status: Runtime Error

Solution code:
H,W=int(input())
h,w=int(input())
print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
H, W = input().split()
h, w = input().split()

total = H * W
num_del = h * W + H * w - h * w
print(total - num_del)

Submission status: Runtime Error

Solution code:
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

def whiecells(H, W, h, w):
	ans = H * W -(h*W + w*(H-h))
	return ans

print(ans)

Submission status: Runtime Error

Solution code:
H, W, h, w = (int(i) for i in input().split())

def whiecells(H, W, h, w):
	ans = H * W - (h*W + w*(H-h))
	return ans

print(ans)

Submission status: Runtime Error

Solution code:
HW = input().split()
hw = input().split
print((HW[0]-hw[0])*(HW[1]-hw[1]))

Submission status: Runtime Error

Solution code:
H,W = list(map(int, input().split(' '))
h,w = list(map(int, input().split(' '))
print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
H,W = list(map(int, input().split(' ')
h,w = list(map(int, input().split(' ')
pritn((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
X = []
for i in range(N):
	X.append(list(map(int, input().split())))

#Sorted by first element
X.sort(key=lambda x:x[0])
i = 0
total = 0
ans = 0

while i <= N-1:
	total += X[i][1]
	ans += X[i][0] * X[i][1]
	if total > M:
		ans -= X[i][0] * (total-M)
		break
	i += 1
print(ans)

Submission status: Runtime Error

Solution code:
N, M, C = map(int, input().split())
B = [int(_) for _ in input().split()]
for i in range(1, N + 1):
    Ai = [int(_) for _ in input().split()]
right = 0
for i in range(1,N + 1):
    for j in range(M):
        a = 0
        a += Ai[j] * B[j]
    if a + C > 0:
        right += 1
print(right)

Submission status: Runtime Error

Solution code:
H, W = map(int, input())
h, w = map(int, input())

print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
HW = list(map(int, input().split()))
hw = list(map(int, input().split()))

H = HW[0]
W = HW[1]

h = hw[0]
w = hw[1]

return H * W - (H * h + (W - h) * w)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [input() for i in range(N)]
print(a)

Submission status: Runtime Error

Solution code:
N, M, C = map(int, input().split())
a = []
for i in range(N+1):
    a.append(list(map(int, input().split())))

count = 0
sum = 0
for i in range(1, N+1):
    for j in range(M):
        sum += int(a[0][j]) * int(a[i][j])
    if sum + int(C) > 0:
        count += 1
        sum = 0
    else:
        sum = 0

print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
M=np.zeros((H,W))
H,W=[int(x) for x in input().split()]
h,w=[int(x) for x in input().split()]

for n in range(h):
    print
    M[n]=1
for m in range(w):
        M.T[m]=1
        
print(len(M[M==0]))

Submission status: Runtime Error

Solution code:
import numpy as np
M=np.zeros((H,W))
H,W=[int(x) for x in input().split()]
h,w=[int(x) for x in input().split()]

for n in range(h):
    print
    M[n]=1
for m in range(w):
        M.T[m]=1
        
len(M[M==0])

Submission status: Runtime Error

Solution code:
[H,W] = map(int, input().split(" "))
[h,w] = map(int, input().split(" "))
print max(H*W - h*W-w*H+h*w,0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for d in range(n)]
ans=0
for i in range(n):
  C=c
  for j in range(m):
    C=C+a[i][j]*b[j]
    if C>0:
      ans=ans+1
print(ans)

Submission status: Runtime Error

Solution code:
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  C=c
  for j in range(m):
    C=C+a[i][j]*b[j]
    if C>0:
      ans=ans+1
print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split(' '))
cost = 0
count = 0

mlist = list()
for i in range(n):
  mlist.append(list(map(int,input().split(' '))))
mlist.sort(key=lambda x: x[0])

for i in range(n):
  ablist = mlist[i]
  if count+ablist[1] <= m:
    count += ablist[1]
    cost += ablist[0]*ablist[1] 
  else:
    for j in range(ablist[1]):
      count += 1
      if count <= m:
        cost += ablist[0]
      else:
        break_t = True
        break
    if break_t:
      break
print(cost)

Submission status: Runtime Error

Solution code:
H,W = map(input().spilt())
w,h = map(input().spilt())
print((H - h) * (W - w))

Submission status: Runtime Error

Solution code:
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
 
print(np.sum(A.dot(B) > -C))

Submission status: Runtime Error

Solution code:
from operator import itemgetter

N_shop, M_required_drink  = map(int, raw_input().split())

shop_list = []
for tmp_shop in range(N_shop):
  shop_list.append(map(int, raw_input().split()))

total_money = 0
got_drink = 0
for i in sorted(shop_list, key=itemgetter(0)):
  limit_at_shop = i[1]
#  print(i)

  while got_drink < M_required_drink and limit_at_shop > 0:
    total_money = total_money + i[0]
    got_drink   = got_drink + 1
    limit_at_shop = limit_at_shop - 1
#    print("  %s %s %s" % (total_money, got_drink, limit_at_shop))

print(total_money)

Submission status: Runtime Error

Solution code:
    a, b = map(int, input().split())
    c, d = map(int, input().split())
    if (a*b)==(c*d):
     print((a*b)-(c*d))
    elif (a*b) > (c*d):
     print(c*d)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
else if (a*b) > (c*d):
 print(c*d)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
else if (a*b) > (c*d):
 print((c*d))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print("0")
else if (a*b ) > (c*d):
  print(c*d)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
else if (a*b ) > (c*d):
  print((c*d))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
elseif (a*b ) > (c*d):
  print((c*d))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
[print("0") if (a*b)=(c*d) else print(c*d)]

Submission status: Runtime Error

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

print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

N, M = (int(i) for i in input().split()) 
AB=[list(map(int,input().split())) for _ in range(N)]
# print(AB)
AB.sort()
# print(AB)

money = 0
for a, b in AB:

    # print(M) 
    if M==0:
        break
    elif b < M:
        # print(a*xb)
        money += a*b
        M -= b
    elif b >= M:
        # print(M)
        money += M*a
        M = 0
    # print(M, money)
print(money)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split)
h,w = map(int,input().split)

print((H-h)*(W-w))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
H,W,h,w=[map(int, input().split()) for _ in range(2)]
print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
import numpy as np

N, M = map(int, input().split())
A = []
B = []

for i in range(0, N):
    a, b = np.array(list(map(float, input().split())))
    A.append(a)
    B.append(b)

cnt = 0
sum = 0
flag = 0
inf = float('inf')
arrayA = np.array(A)
arrayB = np.array(B)
for j in range(0, N):
    idx = A.index(min(arrayA))
    pay = arrayA[idx]
    num = arrayB[idx]
    arrayA[idx]=inf
    if cnt + num < M :
        cnt += num
        sum += pay*num
    else :
        diff = int(M - cnt)
        for t in range(0, diff):
            sum += pay
            cnt += 1
            if cnt == M :
                flag = 1
                print(int(sum))
                break
    if flag == 1:
        break

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = map(int,input().split())
A_s = []
for _ in range(N):
  A_s.append(list(map(int,input().split())))
## Aiの順にsortする
A_s = sorted(A_s,key=lambda x:x[0])
money = 0
num = 0
pre_num = 0
for a_s in A_s:
  num += a_s[1]
  if num <= M:
    money += a_s[1] * a_s[0]
    pre_num += a_s[1]
  else:
    money += (M-pre_num) * a_s[0]
    break
  #print(money)
print(money)

Submission status: Runtime Error

Solution code:
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input().rstrip()  # ignore trailing spaces
 
n, m = na()
ab = []
for i in range(n):
    ab.append(na())
ab.sort(key=lambda x: x[0])
 
rem = m
ans = 0
for v in ab:
    buy = min(rem, v[1])
    ans += buy * v[0]
    rem -= buy
print(ans)

Submission status: Runtime Error

Solution code:
n,m = [int(x) for x in input().split()]
l = [list(map(int,input().split())) for _ in range(n)]
l.sort()
cost = 0
for x in range(n):
    if m == 0:
        exit()
    if l[x][1] <= m:
        cost += l[x][0]*l[x][1]
    else:
        cost += l[x][0]*m
    m -= l[x][1]
print(cost)

Submission status: Runtime Error

Solution code:
val1 = input().split(" ")
H = int(val1[0])
W = int(val1[1])

val2 = input().split(" ")
h = int(val2[0])
w = int(val2[1])

if w == W or h == H:
	print(0)
elif W == 1 or H == 1:
	print(0)
elif W == 20 or H == 20:
	print(0)
else:

	arr = [["○" for i in range(W)] for j in range(H)]

	for k in range(H):
		arr.pop(k)


	result = 0
	for a in arr:
		for l in range(W):
			a.pop(l)
		result += len(a)

	print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
A,B = map(int,input().split())
b = np.arange(A,B+1)
def bin2np(a):
  return list(map(int,list(bin(a)[2:])))
# 1番長い二進数の配列を知る
max_length = len(bin2np(b[-1]))
## ここから、足りない分だけ前に挿入していく
bin2list = []
for a in b:
  c = bin2np(a)
  for _ in range(max_length-len(c)):
    c.insert(0,0)
  #print(c)
  bin2list.append(c)
bin2list = np.array(bin2list)
bin2s = list(map(str,np.where(np.sum(bin2list,axis=0)==1,1,0)))
print(int("".join(bin2s),2))

Submission status: Runtime Error

Solution code:
val1 = input().split(" ")
H = int(val1[0])
W = int(val1[1])

val2 = input().split(" ")
h = int(val2[0])
w = int(val2[1])

if w == W or h == H:
	print(0)
elif W == 1 or H == 1:
	print(0)
elif W == 20 or H == 20:
	print(0)
else:

	arr = [["○" for i in range(W)] for j in range(H)]

	for k in range(h):
		arr.pop(k)


	result = 0
	for a in arr:
		for l in range(w):
			a.pop(l)
		result += len(a)

	print(result)

Submission status: Runtime Error

Solution code:
val1 = input().split(" ")
H = int(val1[0])
W = int(val1[1])

val2 = input().split(" ")
h = int(val2[0])
w = int(val2[1])

if w == W or h == H:
	print(0)
else:

	arr = [["○" for i in range(W)] for j in range(H)]

	for k in range(h):
		arr.pop(k)


	result = 0
	for a in arr:
		for l in range(w):
			a.pop(l)
		result += len(a)

	print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
N, M, C= map(int, input().split())
B = []
B.append(list(map(int, input().split())))
arrB = np.array(B)
#A = np.array()
#for i in range(N):
#    A[i] = input()


#a = list()
#for i in range(M):
#    a.append(map(int, input().split()))

#a = list(a)

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

arrA = np.array(A)

D = np.empty((0,M), int)
for i in range(N):
    D = np.append(D, arrB*arrA[i], axis=0)
#    C.append(arrB*arrA[i])


F = np.empty((0,N), int)
for i in range(N):
    F = np.append(F, np.sum(D[i]))

E = F + C
t=0
for i in range(N):
    if E[i]>0:
        t = t+1
    else:
        t =t



#print(arrB)
#print(arrA)
#print(D)
#print(E)
#print(F)
print(t)

Submission status: Runtime Error

Solution code:
val1 = input().split(" ")
H = int(val1[0])
W = int(val1[1])

val2 = input().split(" ")
h = int(val2[0])
w = int(val2[1])

if w == W:
	print(0)
else:

	arr = [["○" for i in range(W)] for j in range(H)]

	for k in range(h):
		arr.pop(k)


	result = 0
	for a in arr:
		for l in range(w):
			a.pop(l)
		result += len(a)

	print(result)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
money = 0
count = 0
count1 = 0
count2 = 0

for i in range(N):
    AB = list(map(int, input().split()))
    numlist.append(AB)

numlist.sort()

while count < M:
    while numlist[count1][1] > count2:
        money = money + numlist[count1][0]
        count = count + 1
        count2 = count2 + 1
        if count == M:
            break
    count1 = count1 + 1
    count2 = 0
    
print(money)

Submission status: Runtime Error

Solution code:
NM=input().split()
N=int(NM[0])
M=int(NM[1])#必要な本数
A=[]
B=[]
for i in range(N):
  AB=input().split()
  A.append(int(AB[0]))
  B.append(int(AB[1]))
money=0
while A!=[]:
  if M>B[A.index(min(A))]:
    money+=min(A)*B[A.index(min(A))]
    #消す
    ai=A.index(min(A))
    A.remove(min(A))
    B.remove(B[ai])
  elif M<B[A.index(min(A))]:
    money+=min(A)*M
    break
  elif M==B[A.index(min(A))]:
    money+=min(A)*M
    break
  else:
    pass
print(str(money))

Submission status: Runtime Error

Solution code:
import numpy as np

from sys import exit

def main():
  A, B = map(int, input().split(' '))
  values = range(A, B+1)
  # values = []

  # for n in N:
  #   values.append('{:043b}'.format(n))

  values = np.array(values)
  for i, value in enumerate(values):
    if i == 0:
      result = value
    else:
      result = np.bitwise_xor(result, value)
  print(int(result))
    
  # if len(values) == 1:
  #   print(int(values[0], 2))
  #   return

  # result = ''

  # if len(values) % 2 == 1:
  #   for n in range(43):
  #     num_zero = 0
  #     for value in values:
  #       if value[n] == '0':
  #         num_zero += 1

  #     if num_zero % 2 == 0:
  #       result += '1'
  #     else:
  #       result += '0'

  # else:
  #   for n in range(43):
  #     num_zero = 0

  #     for value in values:
  #       if value[n] == '0':
  #         num_zero += 1

  #     if num_zero % 2 == 0:
  #       result += '0'
  #     else:
  #       result += '1'
  # print(int(result, 2))
  
main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
money = 0
count = 0
count1 = 0
count2 = 0

for i in range(N):
    AB = list(map(int, input().split()))
    numlist.append(AB)

numlist.sort()

while count <= M:
    while numlist[count1][1] >= count2:
        money = money + numlist[count1][0]
        count = count + 1
        count2 = count2 + 1
        if count == M:
            break
    count1 = count1 + 1
    count2 = 0
    
print(money)

Submission status: Runtime Error

Solution code:
val1 = input().split(" ")
H = int(val1[0])
W = int(val1[1])

val2 = input().split(" ")
h = int(val2[0])
w = int(val2[1])

arr = [["○" for i in range(W)] for j in range(H)]

for k in range(h):
	arr.pop(k)


result = 0
for a in arr:
	for l in range(w):
		a.pop(l)
	result += len(a)

print(result)

Submission status: Runtime Error

Solution code:
s=[int(input()) for i in range(4)]

ans=s[1]*s[2]-s[2]*s[3]-s[1]*s[4]+s[3]*s[4]
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = []
B = []
r = 0
for i in range(N):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
while M > 0:
  cnt = 1000000001
  cnt2 = 0
  for i in range(N):
    if (A[i] < cnt) and (B[i] != 0):
      cnt = A[i]
      cnt2 = i
  M -= B[cnt2]
  r += A[cnt2]*B[cnt2]
  B[cnt2] = 0
  if M < 0:
    r -= abs(M)*A[cnt2]
  A[cnt2] = 0
print(r)

Submission status: Runtime Error

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

ba = B - A 
if A % 2 == 0:
	ja = "j0"
else:
	ja = "j1"

if B % 2 == 0:
	jb = "j0"
else:
	jb = "j1"

a = A
b = B
a2 = ""
b2 = ""

if a == 0:
	a2 = "0"
else:
	while True:
		if a % 2 == 0:
			a2 += "0"
		else:
			a2 += "1"
		a = int(a // 2)
		if a == 1:
			a2 += "1"
			break
if b == 0:
	b2 = "0"
else:
	while True:
		if b % 2 == 0:
			b2 += "0"
		else:
			b2 += "1"
		b = int(b // 2)
		if b == 1:
			b2 += "1"
			break

a2 += "0" * (len(b2) - len(a2))
c2 = 0

if a2[0] == "0":
	if ba % 4 == 2 or ba % 4 == 1:
		c2 += 1
	else:
		c2 += 0

if a2[0] == "1":
	if ba % 4 <= 1:
		c2 += 1
	else:
		c2 += 0

for i in range(1, len(a2)):
	n = 0
	if a2[i] == "1":
		if ja == "j1":
			n += 1

	if b2[i] == "1":
		if jb == "j0":
			n += 1

	if n % 2 == 0:
		c2 += 0
	else:
		c2 += 2 ** i

print(c2)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
drink = []
cost = 0
count = 0
d_count = 0
rest = 0


for _ in range(N):
    Drink = list(map(int, input().split()))
    drink.append(Drink)
    drink.sort()

for i in range(N):
    cost += drink[i][0] * drink[i][1]
    d_count += drink[i][1]
    count += 1
    if d_count > M:
      break
      
cost -= drink[count-1][0] * drink[count-1][1]
d_count -= drink[count-1][1]
rest = M - d_count
cost += rest * drink[count-1][0]
print(cost)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split(" "))
A_list = []
B_list = []
total = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    A_list.append(A)
    B_list.append(B)

z = list(zip(A_list, B_list))
z.sort()

for a, b in z:
    if b > M:
        total += M * a
        break
    else:
        total += b * a
        M -= b

print(total)

Submission status: Runtime Error

Solution code:
import numpy as np

N, M, C = map(int, input().split())
M=[int(x) for x in input().split()]
nlist=[]

for i in range(N):
    nlist.append([int(x) for x in input().split()])

nlist=np.array(nlist)
M= np.array(M)
ans=(nlist*M+C).sum(axis=1)
print((ans>0).sum())

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	temp1, temp2 = map(int, input().split())
	#temp1 = 1
	#temp2 = 1
	l1.append(temp1)
	l2.append(temp2)

while True:
	min_index = l1.index(min(l1))
	ans += (min(l1) * l2[min_index])
	rest -= l2[min_index]
	if rest <= 0:
		break
	l1.pop(min_index)

print(ans)

Submission status: Runtime Error

Solution code:
n,m,c = map(int,input().split())
input_b = map(int,input().split())
a_list=[input() for i in range(n)]
aa_list=map(int,a_list.split())
for i in range(n):
  answer = c
  count = 0
  lista_item = aa_list[i]
  for j in range(m):
    answer += input_b[m] * lista_item[m]
  if answer > 0
    count+=1
print count

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
h, w = map(int, input().split())

List = []
for i in range(H):
    l = []
    for j in range(W):
        l.append(1)
    List.append(l)

for i in range(h):
    del List[i]

for j in range(w):
    for i in range(len(List)):
        del List[i][j]

count = 0
for i in range(len(List)):
    count = count + len(List[i])

print(count)

Submission status: Runtime Error

Solution code:
lh, lw = input().split()
h, w = input().split()

print(lh * lw - lh * w - lw * h + h + w)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
l1 = []
l2 = []
ans = 0
rest = M
for i in (N+1):
	l1[i],l2[i]  = map(int, input().split())

while true:
	min_index = l1.index(min(l1))
	ans += (min(l1) * l2[min_index])
	rest -= l2[min_index]
	if rest == 0:
		break
	l1.pop(min_index)

print(ans)

Submission status: Runtime Error

Solution code:
s = [input().split() for i in range(2)]
print(s)

sum_cells_count = s[0][0] * s[0][1]
row_cells_count = s[0][1] * s[1][0]
col_cells_count = s[0][0] - s[1][0]

filled_cells_count = row_cells_count + col_cells_count

return sum_cells_count - filled_cells_count

Submission status: Runtime Error

Solution code:
H=input(), W=input()
H=int(H),W=int(W)
h=input(),w=input() 
h=int(h),w=int()
print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
n,m,c = map(int,input().split())
input_b = map(int,input().split())
while True:
  try:
    list_a=list(map(int,input().split()))
    answer = c
    count = 0
    for i in range(len(list_a)):
    answer += input_b[i] * list_a[i]
    if answer > 0
      count+=1
    print count
  except:
    break;

Submission status: Runtime Error

Solution code:
H=input()
H=int(H)
h=input()
h=int(h)
W=input()
W=int(W)
w=input()
w=int(w)
print((H-h)*(W-w))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
lst=[list(map(int,input().split()))]
for i in range(n-1):
    a=list(map(int,input().split()))
    x=0
    for j in range(len(lst)):
        if x > m :break
        if lst[j][0] > a[0]:
            lst.insert(j,a)
            break
        x+=lst[j][1]
        
ans=0
num=0
for i in lst:
    if i[1]+num>=m:
        ans+=i[0]*(m-num)
        break
    ans+=i[0]*i[1]
    num+=i[1]
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
lst=[list(map(int,input().split()))]
for i in range(n-1):
    a=list(map(int,input().split()))
    x=0
    for j in range(len(lst)):
        if x > m :break
        if lst[j][0] > a[0]:
            lst.insert(j,a)
            break
        x+=lst[j][1]
        
ans=0
num=0
for i in lst:
    if i[1]+num>=m:
        ans+=i[0]*(m-num)
        break
    ans+=i[0]*i[1]
    num+=i[1]
print(ans,lst)

Submission status: Runtime Error

Solution code:
H=input()
h=input()
W=input()
w=input()
x=(int(H)-int(h))*(int(W)-int(w))
ptint(x)

Submission status: Runtime Error

Solution code:
H=input()
h=input()
W=input()
w=input()
x=(int(H)-int(h))*(int(W)-int(w))

Submission status: Runtime Error

Solution code:
math_line = list(map(int,input().split()))
input_line = list(map(int,input().split()))

area = math_line[0]*math_line[1]　

black_cell = math_line[0]*input_line[1] + math_line[1]*input_line[0] 
duplicate =  black_cell - input_line[0]*input_line[1]

white_cell = area - duplicate

print(white_cell)

Submission status: Runtime Error

Solution code:
a = int(input().split())
b = int(input().split())
c = a[0] * b[1]
d = a[1] * b[0]
print(a[0] * a[1] - (c + d - b[0] * b[1]))

Submission status: Runtime Error

Solution code:
num_shops, target_drinks = map(int, input().split())
sell = {}

for _ in range(num_shops):
    a,b = map(int, input().split())

    try:
        sell[a] += b
    except:
        sell[a] = b

ans, bought = 0, 0

for price in sorted(sell):

    selling = sell[price]

    if bought + selling < target_drinks:
        ans += price * selling    
        bought += selling
    else:
        ans += price * (target_drinks - bought)
        break

print(ans)

Submission status: Runtime Error

Solution code:
x=(W-w)*(H-h)

Submission status: Runtime Error

Solution code:
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for a in A:
  ans=C
  for i in range(M):
    ans+=a[i]*B[i]
  if ans>0:
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
x=(H-h-)*(W-w)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
h, w = map(int, input().split())

List = []
for i in range(H):
    l = []
    for j in range(W):
        l.append(1)
    List.append(l)

for i in range(h):
    del List[0]

for j in range(w):
    for i in range(len(List)):
        del List[i][j]

count = 0
for i in range(len(List)):
    count = count + len(List[i])

print(count)

Submission status: Runtime Error

Solution code:
kai=H*W-h*W-w*H+h*w

print(kai)

Submission status: Runtime Error

Solution code:
a = input().split()
b = input().split()
c = a[0] * b[1]
d = a[1] * b[0]
print(a[0] * a[1] - (c + d - b[0] * b[1]))

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main()
{
	int H,W,h,w,ans;
	scanf("%d %d",&H,&W);
	scanf("%d %d",&h,&w);
	
	ans=(H-h)*(W-w);
	printf("%d",ans);
	return 0;
}

Submission status: Runtime Error

Solution code:
input_lines = sys.stdin.read()

[H W] = input_lines[0].split()
[h w] = input_lines[1].split()

ans = H*W-h*W-H*w+h*w
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

b = a[1]*a[2] - (a[3]*a[2] + a[4]*(a[1]-1[3]))
print(b)

Submission status: Runtime Error

Solution code:
from functools import reduce
N, M, C = map(int, input().split())
B = map(int, input().split())
count = 0
for _ in range(N):
    if 0 < C + reduce(lambda p: p[0]*p[1], zip(map(int, input().split()), B)):
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
h,w = list(map(int,input().split())
h1,w1 = list(map(int,input().split())

print((h-h1)*(w-w1))

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
h,w = map(int,input().split())
print(H*W-h*W-wH+h*w)

Submission status: Runtime Error

Solution code:
h,w = list(map(int,input().split())
h1,w1 = list(map(intinput().split())

print((h-h1)*(w-w1))

Submission status: Runtime Error

Solution code:
A,B = input().split()
a,b = input().split()
print(A*B-a*B-b*A+a*b)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
h, w = mao(int, input().split())

print(W*h + H*w -(h+w-1))