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:
import sys

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

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

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

print(N*M)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

print(N*M)

Submission status: Wrong Answer

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

if n > n:
    n,m = m,n

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

Submission status: Wrong Answer

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

# flip odd or even
# check concatinated mass
# if that odd, it will back. if even, be opposite.
ans=0
for i in range(n):
    for j in range(m):
        c=0
        for h in range(-1,2):
            for w in range(-1,2):
                if 0<i+h<n-1 and 0<j+w<m-1:
                    c+=1
        if c%2==1:
            ans+=1
print(ans, flush=True)

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-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:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,m = i_map()
    if n == 1 or m == 1:
        print(n*m - 2)
        exit()

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



if __name__=="__main__":
    main()

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 ==2 or m ==2:
    ans = 0
elif n == 1:
    ans = m-2
else:
    ans = n-2

print(ans)

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 <2 and m <2:
    ans = 0
elif n == 1:
    ans = m-2
else:
    ans = n-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())
#N<=Mとして一般性を失わない
N = min(N,M)
M = max(N,M)

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
#N>=Mとして一般性を失わない
if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((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)
  exit()
if n==2 or m==2:
  print(0)
  exit()
print((m-2)*(n-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
from itertools import accumulate
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def floor(a, b): return -(-a // b)


def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True


N, M = zz()
next1, next2, next3, next4, next5, next6, next7, next8 = 0, 0, 0, 0, 0, 0, 0, 0
if (N == 1 and M == 1):
    print(1)
    exit()
elif (N == 1 or M == 1):
    next1 = 2
    next2 = (N*M)-2
elif (M == 2 or N == 2):
    next3 = 4
    next5 = (N*M)-4

else:
    next1 = 0
    next2 = 0
    next3 = 4
    next4 = 0
    next5 = (M-2)*2 + (N-2)*2
    next6 = 0
    next8 = (N-1)*(M-1)

print(next2 + next4 + next6 + next8)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if N > M:
        N, M = M, N

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if N > M:
        N, M = M, N

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if n and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-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 and m == 1:
    print(1)
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:
    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=[int(i) for i in input().split()]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b=map(int, input().split())
array=[]
for i in range(a+2):
  array2=[]
  for j in range(b+2):
    array2.append(True)
  array.append(array2)
for i in range(1,a+1):
  for j in range(1,b+1):
    meguru=[[0,0],[0,1],[1,0],[1,1],[0,-1],[-1,0],[-1,1],[1,-1],[-1,-1]]
    for k in meguru:
      if array[i+k[0]][j+k[1]]==True:
        array[i+k[0]][j+k[1]]=False
      else:
        array[i+k[0]][j+k[1]]=True
counter=0
for i in range(1,a):
  for j in range(1,b):
    if array[i][j]==False:
      counter+=1
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if min(N,M)>1:
  print(N*M-N*2-M*2)
elif max(N,M)==1:
  print(1)
elif min(N,M)==1:
  print(max(N,M)-2)

Submission status: Wrong Answer

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

if n*m == 1:
    print(0)
elif m*n == 4:
    print(0)
else:
    print(abs((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,max(N,M)-2))
else:
    Four = 4
    Six  = 2*(N+M-4)
    Nine = N*M-(Four+Six)
    print(Nine)

Submission status: Wrong Answer

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

#四つ角：4回
#辺上：6回
#内側：9回

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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


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)
else:
  ans = N + M - 3
print(ans)

Submission status: Wrong Answer

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

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

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 * m == 1:
  print(1)
elif n == 1 or m == 1:
  print(n + m - 1)
else:
  print((n - 2) * (m - 2))

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-2,m-2))
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 and M != 1:
  print((N-2)*(M-2))
elif N == 1:
  print(M-2)
else:
  print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, m = MI()
    if n*m == 1 or n == 2 or m == 2:
        print(0)
        sys.exit()
    h = max(n-2, 1)
    w = max(m-2, 1)
    print(h*w)

if __name__ == '__main__':
    main()

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:
# input
N, M = map(int, input().split())

# check
if 2 in [M, N] or N == M == 1:
    print(0)
elif 1 in [M, N]:
    print(N * M - 2)
else:
    print(N * M - (2 * (N + M) - 4))

Submission status: Wrong Answer

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

# check
if 2 in [M, N]:
    print(0)
elif 1 in [M, N]:
    print(N * M - 2)
else:
    print(N * M - (2 * N + 2 * M - 4))

Submission status: Wrong Answer

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

# check
if 2 in [M, N]:
    print(0)
elif 1 in [M, N]:
    print(2)
else:
    print(N * M - (2 * N + 2 * M - 4))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
for b in range(k+1,n+1):
  ans+=(b-k)*(n//b)+max(0,n%b-k+1)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
for b in range(k+1,n+1):
  if n>=n//b*b+k:
    ans+=(b-k)*(n//b)+n-(n//b*b+k)+1
  else:
    ans+=(b-k)*n//b
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
ans=0
for b in range(k+1,n+1):
  ans+=(b-k)*(n//b)+n-(b*n//b+k)+1
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
ans=0
for b in range(k+1,n+1):
  ans+=(b-k)*(n//b)+n-b*n//b+k+1
  
print(ans)

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 or m==1:
  print(n*m-2)
else:
  print(0)

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 or m==1:
  print(n*m-2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__ == "__main__":
    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:
    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)
else:
    print(abs(N-2)*(M-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

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

C = (N+M-2)*2
print(N*M-C)

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==1:
    print(m-2)

elif m==1:
    print(n-2)

Submission status: Wrong Answer

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

n = (n + 3) if n < 2 else n
m = (m + 3) if m < 2 else m
print((n - 2) * (m - 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1

#############
# Main Code #
#############

N,M = IL()
P(max(1,(N-2))*max(1,(M-2)))

Submission status: Wrong Answer

Solution code:
N,M = (int(x) for x in input().split())
if N == 1:
    if M < 3:
        print('0')
    else:
        print(M-2)
elif M == 1:
    if N < 3:
        print('0')
    else:
        print(N-2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n, m = map(int, input().split())
  if n == 1 and m == 1:
    print(1)
  if n == 1 or m == 1:
    print(max(n-2, m-2))
  else:
    print(n*m-2*(n+m)+4)
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))
######################################################################################################


H,W=map(int,input().split())



ans=(H-2)*(W-2)
print(ans)

Submission status: Wrong Answer

Solution code:
print(2)
exit()
print(3)

Submission status: Wrong Answer

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

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:
N, M = map(int, input().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(' '))

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 00:52:36 2020

@author: shinba
"""

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

ans = 0

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    if N==1 or M==1:
        ans=N*M-2
    else:
        ans=(N-2)*(M-2)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
H,W = map(int, input().split())
if H == 1 or W == 1:
    print (max(W,H)-2)
    exit()
if H == W == 1:
    print(1)
    exit()
print(W*H - (2*H+2*W-4))

Submission status: Wrong Answer

Solution code:
H,W = map(int, input().split())
if H == 1 or W == 1:
    print (max(W,H)-2)
    exit()
print(W*H - (2*H+2*W-4))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
 
if n == 1 or m == 1:
    ans = max(n, 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 or m == 1:
    ans = max(n, m) - 2
else:
    ans = n * m - 2 * n - 2 * m + 4

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if n == 1 or m == 1:
    ans = max(n, m) - 2
else:
    ans = n * m - 2 * n - 2 * m + 4
    print(ans)

print(ans)

Submission status: Wrong Answer

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

    if n == 1 or m == 1:
        ans = max(0, max(n, m) - 2)
        print(ans)
        return
    else:
        x = max(0, n - 2)
        y = max(0, m - 2)
        ans = x * y
        print(ans)
        return


if __name__ == '__main__':
    main()