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:
n,m = map(int,input().split())

t = n * m
if n == 1:
  print(m - 2)
elif m == 1:
  print(n - 2)
else:  
  print(t - (n * 2 + m * 2 -4))

Submission status: Wrong Answer

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

t = n * m
print(t - (n * 2 + m * 2 -4))

Submission status: Wrong Answer

Solution code:
(rows, cols) = (int(tok) for tok in input().split())
res = 0

if rows > 1 and cols > 1:
  res = (rows - 2) * (cols - 2)
elif rows > 1 or cols > 1:
  res = max(rows, cols) - 2

print(res)

Submission status: Wrong Answer

Solution code:
import sys
from statistics import *
from collections import *
from operator import itemgetter
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, m = na()
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 = list(map(int, input().split()))
if n == 2 or m == 2:
    print(0)
elif n == 1 or m == 1:
    print(max(0,n*m-2))
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
if n == 1 or m == 1:
    print(max(0,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 = list(map(int, input().split()))
if n == 1 or m == 1:
    print(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 = list(map(int, input().split()))
if n>=3 and m>=3:
    print((n-2)*(m-2))
elif n == 1 or m == 1:
    print(n*m-2)
elif n == 2 or m == 2:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n, m = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n, m = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n, m = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    hasikko = [0]
    if M > 1:
        hasikko.append(M - 1)

    for i in hasikko:
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if M > 2 and N == 1:
        ans += M - 2

    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Submission status: Wrong Answer

Solution code:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0
    for i in [0, M - 1]:
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if M > 2 and N == 1:
        ans += M - 2

    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Submission status: Wrong Answer

Solution code:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0
    for i in [0, M - 1]:
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if M > 2 and N < 1:
        ans += M - 2

    # ans +=
    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Submission status: Wrong Answer

Solution code:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0
    for i in range(M):
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

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(max(n, m) * (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:
    if m == 1:
        print(1)
    else:
        print(m - 2)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
n, m = (int(i) for i in input().split())
if n == 1:
    print(max(m-2, 0))
elif m == 1:
    print(max(n-2, 0))
else:
    print(n*m - (n*2 + m*2) + 4)

Submission status: Wrong Answer

Solution code:
n, m = (int(i) for i in input().split())
if n == 1:
    print(max(m-2, 0))
elif m == 1:
    print(max(n-2, 0))
else:
    print(0)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if N == M == 1:
    print(1)
    exit()

if N < 3 and M < 3:
    print(0)
    exit()

ans = max(N - 2, 1) * max(M - 2, 1)
print(ans)

Submission status: Wrong Answer

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

if N < 3 and M < 3:
    print(0)
    exit()

ans = max(N - 2, 1) * max(M - 2, 1)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().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-1)-2*(m-1))

Submission status: Wrong Answer

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

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(n*m -2)

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

Submission status: Wrong Answer

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

if N >= 3 and M >= 3:
    ans = (N - 2) * (M - 2)
elif N == 2:
    ans = 0
elif M == 2:
    ans = 0
else:
    ans = max(N, M) - 2

print(ans)

Submission status: Wrong Answer

Solution code:


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

n,m = list(sorted(getints()))

if n == 1:
    res = m - 2
elif n == 2:
    res = 0
else:
    res = n * m - 2 * n - 2 * m + 4

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
print(0 if n==m==1 else abs(n-2)*abs(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 > 1 and m == 1:
    print(n - 2)
elif n == 2 and m > 1:
    print((m - 2) * 2)
elif n > 1 and m == 2:
    print((n - 2) * 2)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
if N>=3 and M>=3:
  answer=(M-2)*(N-2)
elif N==1 and M>=3:
  answer=M-2
elif M==1 and N>=3:
  answer=N-2
else:
  answer=0

print(answer)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
if N>3 and M>3:
  answer=(M-2)*(N-2)
elif N==1 and M>=3:
  answer=M-2
elif M==1 and N>=3:
  answer=N-2
else:
  answer=0

print(answer)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
if N>3 and M>3:
  answer=(M-2)*(N-2)
elif N==1 and M>3:
  answer=M-2
elif M==1 and N>3:
  answer=N-2
else:
  answer=0

print(answer)

Submission status: Wrong Answer

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

ans = 0
if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N, M = map(int, input().split())
    
    if N == 1 and M == 1:
        print(1)
        sys.exit()
    
    if N == 1:
        print(M-2)
        sys.exit()
        
    if M == 1:
        print(N-2)
        sys.exit()
        
    if N == 2 and M == 2:
        print(0)
        sys.exit()
    
    if N == 2 or M == 2:
        print(0)
        sys.exit()
        
    total = N*M
    total -= 2*N
    total -= 2*M + 4
    
    print(total)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n==1:
    print(max(m-2,0))
elif m==1:
    print(max(n-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)
elif 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:
    if M<=2:
        print(0)
    else:
        print(M-2)
else:
    if M==1:
        print(N-2)
    else:
        print((M-2) * (N-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if N < 3 and M < 3:
    if N == M == 1:
        print(0)
    else:
        print(0)
elif N < 3 and M >= 3:
    if N == 1:
        print((N-2)*M)
    else:
        print(0)
elif N >=3 and M < 3:
    if M == 1:
        print(M*(N-2))
    else:
        print(0)
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(0)
elif N < 3 and M >= 3:
    print(N*(M-2))
elif N >=3 and M < 3:
    print(M*(N-2))
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = [int(nm) for nm in input().split()]
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))

Submission status: Wrong Answer

Solution code:
N, M = [int(nm) for nm in input().split()]
if N>=3 and M>=3:
  print((N-2)*(M-2))
else:
  if {N, M}=={1, 1} or {N, M}=={1, 3}:
    print(1)
  else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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((m-2) * (n-2))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, M = (int(_) for _ in input().split())
    if N==1 or M==1:
        print(N*M - 2)
        return 
    print((N-2)*(M-2))
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from math import *
from itertools import *
from collections import *
from bisect import *


if __name__ == '__main__':
    n,m = map(int, input().split())

    if n == 1:
        if m == 1:
            print(1)
        else:
            print(m-2)
    elif m == 1:
        print(m-2)
    else:
        center = n*m - 2*n - 2*m + 4
        print(center)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
if n != 1 and m == 1:
    print(m-2)
if n == 1 and m != 1:
    print(n-2)
if n != 1 and m != 1:
    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 and m == 1:
    print(m-2)
if n == 1 and m != 1:
    print(n-2)
if n != 1 and m != 1:
    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 == 2:
  print(N-2)
else:
  print((M-2)*(N-2))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if N == 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 == M == 1:
    print(0)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-1)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
a, b =map(int, input().split())  #複数数値入力

if a == 1 or b == 1:
    print(max(a,b) - 2)
else:
    print(a * b - a*2 - b*2 + 4)

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((M - 2) * (N - 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

str = input().split()
N = int(str[0])
M = int(str[1])

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

Submission status: Wrong Answer

Solution code:
str = input().split()
N = int(str[0])
M = int(str[1])

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

Submission status: Wrong Answer

Solution code:
str = input().split()
N = int(str[0])
M = int(str[1])

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

Submission status: Wrong Answer

Solution code:

str = input().split()
N = int(str[0])
M = int(str[1])

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

Submission status: Wrong Answer

Solution code:

def solve(N, M):
    # 1 2
    # 3 4

    # 1 2
    # 3 4
    #
    # (0)    (1)
    # 1 2    1 2 3
    # 3 4    4 5 6
    # 5 6    7 8 9

    return max(0, N - 2) * max(0, (M - 2))

N, M = [int(x) for x in input().split()]
print(solve(N, M))

Submission status: Wrong Answer

Solution code:

def solve(N, M):
    # 1 2
    # 3 4
    #
    # (0)    (1)
    # 1 2    1 2 3
    # 3 4    4 5 6
    # 5 6    7 8 9

    return max(1, (N - 2)) * max(1, (M - 2))

N, M = [int(x) for x in input().split()]
print(solve(N, M))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if M < N:
    N, M = M, N

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

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())
print(abs((n - 2) * (n - 2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = [ int(v) for v in input().split() ]
print(n*m-2*n-2*m+4)

Submission status: Wrong Answer

Solution code:
n, m = [ int(v) for v in input().split() ]
print(2*n+2*m-4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

ans = max(N-2, 0) * max(M-2, 0)

if N == 1 and M == 1:
        ans = 0
elif N == 1:
    ans = M - 2
elif M == 1:
    ans = N - 2

print(ans)

Submission status: Wrong Answer

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    n, m = intin()

    if n == 1 or m == 1:
        print(max([n - 2, m - 2, 0]))
        return
    if n == 2 or m == 2:
        print(0)
        return

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

else:
    ans = max(N, M) - 2
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
grid = [[True for _ in range(m)] for _ in range(n)]
dict = (
    (-1, -1), (-1, 0), (-1, 1),
    (0, -1), (0, 0), (0, 1),
    (1, -1), (1, 0), (1, 1),
)

for i in range(0, n):
    for j in range(0, m):
        for d in dict:
            dy, dx = d
            y = i+dy
            x = j+dx
            if y >= 0 and y < n and x >= 0 and x < m:
                print(i, j, y, x)
                grid[y][x] = not grid[y][x]

f = sum(grid, [])
print(f.count(False))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ans=0
if n==1 or m==1:
	ans=max(0,max(m,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 >= M:
    if N == 1 and M == 1:
        print(1)
    elif N == 1 and M != 1:
        print(M-2)
    else:
        print((N-2)*(M-2))
else:
    if N == 1 and M == 1:
        print(1)
    elif N == 1 and 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((n-2)*(m-2))
elif n==1 and m==1:
	print(0)
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((n-2)*(m-2))
elif n==1 or m==1:
	print(max(n-2,m-2))
else:
	print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = list(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 in [1, 2] and not m in [1, 2]: print(abs(n-1) * max(1, m-2))
elif not n in [1, 2] and m in [1, 2]: print((n-2) * abs(n-2))
elif n in [1, 2] and m in [1, 2]: print(abs(n-2) * abs(m-2))
else: print((n-2) * (m-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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())
print((n-2)*(m-2) if n>1 and m>1 else max(n,m)-2)

Submission status: Wrong Answer

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

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

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:
N,M = map(int,input().split())
if N >=2 and M >= 2:
    print(N*M -((N-1)*2+(M-1)*2))
elif N ==1:
    print(M-2)
elif M ==1:
    print(N-2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N == 1 or M == 1:
    print(N*M-2)
else:
    print(N*M-2*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())

count = 0

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

print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N>=2 and M>=2:
    ans = (N-2)*(M-2)
else:
    ans = max(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-2)*(M-2))
else:
    print(N*M-2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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