Problem:


Score : 300 points

Problem Statement

There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.
The front and back sides of these cards can be distinguished, and initially every card faces up.

We will perform the following operation once for each square contains a card:

For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.

It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.
Find the number of cards that face down after all the operations.

Constraints

1 \leq N,M \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of cards that face down after all the operations.

Sample Input 1

2 2

Sample Output 1

0

We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.

Sample Input 2

1 7

Sample Output 2

5

After all the operations, all cards except at both ends face down.

Sample Input 3

314 1592

Sample Output 3

496080



Sample input:
2 2


Sample output:
0

Submission status: Wrong Answer

Solution code:
# WIP
N, M = map(int, input().split())

if N == 1:
    print(M - 2 if M > 2 else 0)
elif M == 1:
    print(N - 2 if N > 2 else 0)
elif N == 1 and M == 1:
    print(1)
elif N > 2 and M > 2:
    print((N - 2) * (M - 2))
else:
    print(0)

"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

Submission status: Wrong Answer

Solution code:
# WIP
N, M = map(int, input().split())

if N == 1:
    print(M - 2 if M > 2 else 0)
elif M == 1:
    print(N - 2 if N > 2 else 0)
elif N == 1 and M == 1:
    print(1)
else:
    print(0)

    
"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

Submission status: Wrong Answer

Solution code:
# WIP
N, M = map(int, input().split())

if N == 1:
    print(M - 2 if M > 2 else 0)
elif M == 1:
    print(N - 2 if N > 2 else 0)
elif N == 1 and M == 1:
    print(1)
else:
    # Number of cards appearing "back"
    # = (N-2)*(M-2)
    print((N - 2) * (M - 2))
    
"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

Submission status: Wrong Answer

Solution code:
# WIP
N, M = map(int, input().split())

if N == 1:
    print(max(M - 2, 0))
elif M == 1:
    print(max(N - 2, 0))
elif N == 1 and M == 1:
    print(1)
else:
    # Number of cards appearing "back"
    # = (N-2)*(M-2)
    print(max((N - 2) * (M - 2), 0))
    
"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

Submission status: Wrong Answer

Solution code:
# WIP
N, M = map(int, input().split())

if N == 1:
    print(max(M - 2, 0))
elif M == 1:
    print(max(M - 2, 0))
elif N == 1 and M == 1:
    print(1)
else:
    # Number of cards appearing "back"
    # = (N-2)*(M-2)
    print(max((N - 2) * (M - 2), 0))

"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

Submission status: Wrong Answer

Solution code:
# WIP
N, M = map(int, input().split())

if N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
elif N == 1 and M == 1:
    print(1)
else:
    # Number of cards appearing "back"
    # = (N-2)*(M-2)
    print((N - 2) * (M - 2))

"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(0)
elif N == 1 and M != 1:
    print(M - 2)
elif M == 1 and N != 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n <= 2 and m <= 2:
    print(0)
else:
    if 2 < n:
        n -= 2
    elif n <= 2:
        n = 1
    if 2 < m:
        m -= 2
    elif m <= 2:
        m = 1

    print(n*m)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n <= 2 and m <= 2:
    print(0)
else:
    n -= 2
    m -= 2
    if n <= 0:
        n = 1
    if m <= 0:
        m = 1
    print(n*m)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n <= 2 and m <= 2:
    print(0)
else:
    if 1 < n:
        n -= 2
    elif n == 1:
        n = 1
    if 1 < m:
        m -= 2
    elif m == 1:
        m = 1

    print(n*m)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n <= 2 and m <= 2:
    print(0)
else:
    if 1 < n:
        n -= 2
    elif n == 1:
        n = 1
    if 1 < m:
        m -= 2
    elif m == 1:
        m == 1

    print(n*m)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
"""
mat = [[0]*M for _ in range(N)]
dx = [-1,0,1,-1,0,1,-1,0,1]
dy = [1,1,1,0,0,0,-1,-1,-1]
for i in range(N):
    for j in range(M):
        for k in range(9):
            if 0 <= i+dy[k] <= (N-1) and 0 <= j+dx[k] <= (M-1):
                mat[i+dy[k]][j+dx[k]] += 1
print(mat)
"""
if N == 1 or M == 1:
    print(N*M-2)
else:
    print(N*M-2*(N+M-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

if n>=2 and m>=2:
    n-=2
    m-=2
    print(n*m)

else:
    print(max(n,m)-2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
n-=2
m-=2
print(n*m)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
n-=1
m-=1
print(n*m)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 2 or M == 2:
    print(0)
elif N == 1 or M == 1:
    print(max(N, M)-2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:


n,m = map(int, input().split())
ans = n*m
tmp = n + m - 2
print(ans - tmp * 2)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[0]==1 or a[1]==1:
    print(max(max(a)-2, 0))
    exit()
print((a[0]-2)*(a[1]-2))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())

if(N>=2 and M>=2):
    print((N-2)*(M-2))
elif((N>=2 and M==1) or (N==1 and M>=1)):
    print(N*M-2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())

ANS = 0
if N != 1 and M != 1:
  ANS = N * M - (2 * N + 2 * M -4)
else:
  ANS = N * M - 2
print(ANS)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 1:
    if M == 1:
        ans = 1
    else:
        ans = M - 2
else:
    ans = (N - 2) * (M - 2)

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1 and m == 1:
  print(1)
elif n == 1:
  print(m - 2)
else:
  print((n - 2)*(m - 2))

Submission status: Wrong Answer

Solution code:
# 一般に偶奇のパリティで解ける
# 接するカードの数が奇数ならそのカードは表に偶数なら裏になる
# つまり接するカードの数が偶数となるカードを数え上げればよい
n,m = map(int,input().split())
# 3行3列以上の場合
# 全体 - (行の外枠) - (列の外枠) + 4(引きすぎた4隅を足す)
# さらに考察すると下になる
# 全体(n * m) - (2 * 列の数) - (行の数 * 2) + 4
if n >= 3 and m >= 3:
  print(n * m - (2 * m) - (n * 2) + 4)
# 1行の場合は両端のカード以外は偶数のカードと接するので列数 - 2が解
elif n == 1:
  print(m - 2)
# 2行の場合は全てのカードが奇数のカードと接するので答えは0
elif n == 2:
  print(0)
elif n >= 3 and m == 1:
  print(n - 2)
elif n >= 3 and m == 2:
  print(0)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

ans = (n-2) * (m-2)
if n == m == 1:
    ans = 0
elif n == 1:
    ans = m - 2
elif m == 1:
    ans = n - 2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
if N == 2 or M == 2:
    print(0)
elif N == 1 and M == 1:
    print(N * M)
elif N == 1:
    print((N * M)- M + 2)
elif M == 1:
    print((N * M) - N + 2)
else:
    print(((N-2) * (M-2)))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n == 1 or m == 1:
	print (max(max(n,m)-2,0))
elif n == 2 or m == 2:
	print (0)
else:
	print ((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
if n==1:
    print(max(0,m-2))
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
x, y = map(int, input().split())
if y == 1:
    print(max(x-2, 0))
elif x == 1:
    print(max(y-2, 0))
else:
    print((x-2)*(y-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

#角、辺、内部の3つ分けて考える
#角は4flip -> 表
#辺は6flip -> 表
#内部は9flip -> 裏

if n >= 2 and m >= 2:
    ans = n*m - 2*m -2*n + 4
elif n == 1:
    ans = max(0, m-2)
elif m == 1:
    ans = max(0, n-2)
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if N>=2 and M>=2:
  print((N-2)*(M-2))
else:
  print(N*M-2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1 or m == 1:
    ans = n*m
elif n == 2 or m == 2:
    ans = 0
else:
    ans = (n-2)*(m-2)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1 or m == 1:
    ans = n*m-2
elif n == 2 or m == 2:
    ans = 0
else:
    ans = (n-2)*(m-2)
print(ans)

Submission status: Wrong Answer

Solution code:
N , M = map(int,input().split())
if N == 1 and M == 1:
    print("0")
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N==1 and M==1:
  print(1)
elif N==1:
  print(M-2)
elif M==1:
  print(N-2)
else:
  print(max(M-2,1)*max(N-2,1))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
print(max(M-2,1)*max(N-2,1))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(0)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

if N == 2 or M==2:
    print(0)
elif N == 1 and M == 1:
    print(0)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N >= 2 and M >= 2:
    print(N*M - (N*2 + M*2 - 4))
else:
    print(N*M - 2)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and m != 1:
    print(m-2)
elif n >= 2 and m >=2 :
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif (n == 1 and m != 1) or (n != 1 and m == 1):
    print(m-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and m != 1:
    print(m-2)
else :
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and m != 1:
    print(m-2)
elif n >= 2 :
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and not m == 1:
    print(m-2)
elif n >= 2 :
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and m > 1:
    print(m-2)
elif n >= 2 :
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M - 2)
elif M == 1 and N != 1:
    print(M - 2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(M-2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 or M == 1:
    print(M - 2)
elif N == 1 and M == 1:
    print(1)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 or M == 1:
    print(M - 2)
elif N == 1 and M == 1:
    print(1)
else:
    print(N*M-(2*M+2*(N-2)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
print(N*M-(2*M+2*(N-2)))

Submission status: Wrong Answer

Solution code:
def examC():
    NM = LI(); NM.sort()
    if NM[0]>=2:
        ans = (NM[0]-2)*(NM[1]-2)
    else:
        ans = max(0,NM[1]-2)
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N >= 3 and M >= 3:
    print(N * M - 2 * (N + M) + 4)

if N == 2 or M == 2:
    print(0)

if N == 1:
    if M >= 3:
        print(M - 2)
    elif M == 1:
        print(0)

if M == 1:
    if N >= 3:
        print(N - 2)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if N == 1:
  ans = M-2
elif M == 1:
  ans = N-2
  if N == 1 and M == 1:
    ans = 1
else:
  ans = (M-2)*(N-2)
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if (N == 1) or (M == 1):
  if max(N, M) <= 2:
    ans = 0
  else:
    ans = max(N, M) - 2
elif (N == 2) or (M == 2):
  ans = 0
else:#N, M共に3以上
  ans = (N - 2) * (M - 2)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n!=1 and m!=1:
  print(n*m-2*m-2*n+4)
else:
  if n==1:
    print(m-2)
  else:
    print(n-2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

# 端を構成しているカードは常にオモテ
# 内部を構成しているカードは常にウラ
if N >= 2  and M >= 2:
    ans = (N - 2) * (M - 2) 
elif N == 1 or M == 1:
    ans = max(N, M) - 2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    if n == 1 or m == 1:
        print(n * m - 2)
    elif n == 2 or m == 2:
        print(0)
    else:
        print(n * m - 2 * n - 2 * m + 4)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N, M = [int(x) for x in input().split()]
if N == M == 1:
  print(1)
if N == 1 or M == 1:
  print(max(0, N - 2) + max(0, M - 2))
else:
  print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
N, M = [int(x) for x in input().split()]
if N == 1 or M == 1:
  print(max(0, N - 2) + max(0, M - 2))
else:
  print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())

if n-2>=0 and m-2>=0:
    print((n-2)*(m-2))
elif n-2<0:
    n = 0
    m = m-2
    print(n+m)
elif m-2<0:
    m = 0
    n = n-2
    print(n+m)
else:
    pass

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())

if n-2>=0 and m-2>=0:
    print((n-2)*(m-2))
elif n-2<0:
    n = 1
    m = m-2
    print(n*m)
elif m-2<0:
    m = 1
    n = n-2
    print(n*m)
else:
    pass

Submission status: Wrong Answer

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-06 21:30:22(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    n, m = (int(x) for x in sys.stdin.read().split())
    if n == 1 and m == 1:
        ans = 0
    elif n == 1:
        ans = m - 2
    elif m == 1:
        ans = n - 2
    else:
        ans = (n - 2) * (m - 2)
    
    print(ans)

if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Wrong Answer

Solution code:
s = input()
a,b = map(int,s.split(' '))
if a==1 and b == 1:
    print(0)
else:
    if a==1:
        print(b-2)
    elif b==1:
        print(a-2)
    else:
        print((a-2)*(b-2))

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':

	n,m = list(map(int,input().split()))

	ans = 0
	if n == 1 and m == 1:
		ans = 0
	if n == 1:
		ans = m - 2
	elif m == 1:
		ans = n - 2
	elif ( n == 2 or m == 2 ):
		ans = 0
	else:
		ans = (n - 2) * (m - 2)

	print(ans)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':

	n,m = list(map(int,input().split()))

	ans = 0
	if n == 1:
		ans = m - 2
	elif m == 1:
		ans = n - 2
	elif ( n == 2 or m == 2 ):
		ans = 0
	else:
		ans = (n - 2) * (m - 2)

	print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 1:
	print(M - 2)
elif M == 1:
	print(N - 2)
else:
	print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
m, n = (int(x) for x in input().split())
if m > n:
    c = n
    n = m
    m = c
if m == 1:
    if n <= 2:
        print(0)
    else: print(n-2)
elif n == 2 or m == 2: print(0)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

#周辺に3マス：4枚：4回ひっくり返される：

#周辺に5マス：((n-2)+(m-2))*2枚：6回ひっくり返される：

#周辺に8マス：(n-2)*(m-2)枚：9回ひっくり返される：

n = max((n-2), 1)
m = max((m-2), 1)

print(n*m)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

#周辺に3マス：4枚：4回ひっくり返される：

#周辺に5マス：((n-2)+(m-2))*2枚：6回ひっくり返される：

#周辺に8マス：(n-2)*(m-2)枚：9回ひっくり返される：

n = max((n-2), 0)
m = max((m-2), 0)

print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

#周辺に3マス：4枚：4回ひっくり返される：

#周辺に5マス：((n-2)+(m-2))*2枚：6回ひっくり返される：

#周辺に8マス：(n-2)*(m-2)枚：9回ひっくり返される：

print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
if A == 1:
  if B == 1:
    print(1)
  else:
    print(B-2)
else:
  print((A-2)*(B-2))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
if A == 1 and B == 1:
  print(1)
elif A == 1 and B!= 1:
  print(B-2)
else:
  print((A-2)*(B-2))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
if A == 1 and B == 1:
  print(1)
elif A == 1 and B!= 1:
  print(B-2)
else:
  print((A-2)*(B-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

if n == 1 and m ==1:
  print(1)
elif n == 2 or m ==2 or n== 1 or m ==1:
  print((max(n,m)-2)*min(n,m))
else:
  print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

if n == 1 and m ==1:
  print(1)
elif n <= 2 and m <= 2:
  print(0)
elif n == 1 or m ==1:
  print(max(1,(n-2))*max(1,(m-2)))
elif n == 2 or m ==2:
  print(max(2,(n-2))*max(2,(m-2)))
else:
  print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

if n == 1 and m ==1:
  print(1)
elif n <= 2 and m <= 2:
  print(0)
else:
  print(max(1,(n-2))*max(1,(m-2)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N>M:
    N, M = M, N

if N==1:
    if M==1:
        ans = 0
    else:
        ans = M - 2

elif N==2:
    ans = 0
else:
    ans = (N - 2)*(M - 2)

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

if N==1 or M==1:
    print(max((max(N,M)-2),0))

else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
if n == 1 and m == 1:print(1);exit()
elif n == 2 or m == 2:print(0);exit()
elif n == 1 or m == 1:print(m-2);exit()
else:print((n*m) - (m*2 + (n-2)*2))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
if n == 1 or m == 1:print(m-2);exit()
elif n == 2 or m == 2:print(0);exit()
else:print((n*m) - (m*2 + (n-2)*2))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
if n == 1:print(m-2);exit()
elif n == 2:print(0);exit()
else:print((n*m) - (m*2 + (n-2)*2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n==1 and m==1:
    print(1)
if n==1 or m==1:
    print(max(n,m)-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n==1 and m==1:
    print(0)
if n==1 or m==1:
    print(max(n,m)-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n==1 or m==1:
    print(max(n,m)-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
ls=[int(s) for s in input().split()]
ls.sort()
if ls[1]==1:
  print(1)
elif ls[0]==1:
  print(ls[0]-2)
else:
  print((ls[0]-2)*(ls[1]-2))

Submission status: Wrong Answer

Solution code:
import itertools
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M = inputs()
if N>=2 and M>=2:
    print((N-2)*(M-2))
    exit()
else:
    if N==1 and M==1:
        print(0)
        exit()
    print(max(N-2,M-2,))

Submission status: Wrong Answer

Solution code:
import itertools
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M = inputs()
if N>=2 and M>=2:
    print((N-2)*(M-2))
    exit()
else:
    print(max(N-2,M-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(0)
elif n == 1 or m == 1:
    print(max(n, m)-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())

if N>1 and M>1:
    print((N-2)*(M-2))
elif max(N,M)>2:
    print(max(N,M)-2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n*m==1:
  print(1)
if n==1:
  print(m-2)
if m==1:
  print(n-2)
else:
  print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n==1:
  print(m-2)
if m==1:
  print(n-2)
else:
  print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n*m==1:
  print(1)
if n*m==2:
  print(0)
if n*m==3:
  print(1)
if n==2 and m==2:
  print(0)
elif n*m==4:
  print(2)
if n*m==5:
  print(3)
if n==2 and m==3:
  print(0)
if n==3 and m==2:
  print(0)
elif n*m==6:
  print(4)
if n*m==7:
  print(5)
if n==2 and m==4:
  print(0)
if n==4 and m==2:
  print(0)
elif n*m==8:
  print(6)
if n==3 and m==3:
  print(1)
elif n*m==9:
  print(7)
else:
  print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n >=3 and m>=3:
    print((n-2)*(m-2))
elif n==1 and m==1:
    print(1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

if N == 1 and M == 1:
    print(0)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print(N*M - 2*(N+M) + 4)

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, input().split())
if N < 2 and M < 2:
    print(0)
    sys.exit()

if N == 1 or M == 1:
    print(max(N, M) - 2)
    sys.exit()

ans = (N * M) - (2 * N) - (2 * (M - 2))
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 1 or M == 1:
    print(max(0, max(N, M)-2))
elif N == 2 or M == 2:
    print(0)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
else:
    print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
N = max(1, N - 2)
M = max(1, M - 2)
if N == M == 1:
    print(0)
else:
    print(N * M)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().strip().split(' '))

if N == 1 or M == 1:
  print(N*M-2)
else:
  print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

first = N*M
ans = 0

if N >= 3:
    if M >= 3:
        ans = (N-2)*(M-2)
    else:
      if M == 2:
        ans=0
      else:
        ans=N-2

else:
    if N == 2:
      ans=0
    else:
      if M == 2:
        ans=0
      else:
        ans=M-2
print(ans)

Submission status: Wrong Answer

Solution code:
sq = list(map(int, input().split()))
sq.sort()

if sq[0] == 1 and sq[1] == 1:
    print(1)
elif sq[0] == 1:
    print(sq[1] - 2)
elif sq[0] == 2 and sq[1] == 2:
    print(0)
elif sq[0] == 2:
    print(2 * (sq[1] - 2))
else:
    print((sq[0] - 2) * (sq[1] - 2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

ans = max(n - 2, 0) * max(m - 2, 0)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())

if n>=2 and m>=2:
    ura=(n-2)*(m-2)
else:
    ura=max(n,m)-2
print(ura)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n > m:
  n, m = m, n
if n == 1:
  if m == 1:
    print(1)
  elif m == 2:
    print(0)
  else:
    print(m - 2)
elif n == 2:
  print(0)
else:
  print((n - 2) * (m - 2))
print(abs(n -2) * abs(m - 2))

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if N <= 2 and M <= 2:
        print(0)
    elif M == 1 or N == 1:
        print(max(M - 2, N - 2))
    else:
        print((M-2) * (N-2))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if N <= 2 or M <= 2:
        print(0)
    elif M == 1 or N == 1:
        print(max(M - 2, N - 2))
    else:
        print((M-2) * (N-2))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(N, M)-2)
    exit()

print( (N-2)*(M-2) )

Submission status: Wrong Answer

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(M-2)
    exit()

print( (N-2)*(M-2) )

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M-2)
    exit()

print( (N-2)*(M-2) )

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

if N == 1 and M != 1:
    print(M-2)
    exit()

print( (N-2)*(M-2) )

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

if N == 1:
    print(M-2)
    exit()
elif M == 1:
    print(N-2)
    exit()

print( (N-2)*(M-2) )