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())

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# author:  Taichicchi
# created: 28.09.2020 23:24:54

import sys

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:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
if n == 1:
    print(m - 2)
    sys.exit(0)
if m == 1:
    print(n - 2)
    sys.exit(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

if n>=3 and m>=3:
  a=n*m
  b=n*2+m*2-4
elif n==1 or m==1:
  a=n*m
  b=2
elif n==2 or m==2:
  a=0
  b=0
  
print(a-b)

Submission status: Wrong Answer

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

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

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())
n, m = min(n,m),max(n,m)

if n == 1 and m == 1 or n == 2:
    print(0)
elif n == 1:
    print(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*m-(n+m)*2+4 if min(n,m)!=1 else (n*m)-2 )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, m = inm()
print(n*m - min(2, m) * n - (0 if n <= 2 else 2*m - 4))

Submission status: Wrong Answer

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

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

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(n*m - 2)
else:
    print(n*m - (n*2+m*2-4))

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())
N = max(_N, _M)
M = min(_N, _M)
if N >= 3 or M >= 3:
    long = max(1, N - 2)
    short = max(1, M - 2)
    print(long * short)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
_N, _M = map(int, input().split())
N = max(_N, _M)
M = min(_N, _M)
tate = max(0, N - 2)
yoko = max(0, M - 2)
if M == 1 and N > 2:
    print(N - 2)
    exit()
print(tate * yoko)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
if 2 < n and 2 < m:
    print((n-2)*(m-2))
elif 2 < n:
    print((n-2)*m)
elif 2 < m:
    print(n*(m-2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
if 2 < n and 2 < m:
    print((n-2)*(m-2))
elif 2 < n:
    print((n-2)*m)
elif 2 < m:
    print(n*(m-2))
else:
    print(n*m)

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

N, M = map(int, sys.stdin.readline().split())

if N > 1 and M > 1:
    four = 4
    six = (N - 2) * 2 + (M - 2) * 2
    nine = N * M - four - six
    print(nine)
elif N == 2 or M == 2:
    print(0)
else:
    two = 2
    three = N * M - two
    print(three)

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, sys.stdin.readline().split())

if N > 1 and M > 1:
    four = 4
    six = (N - 2) * 2 + (M - 2) * 2
    nine = N * M - four - six
    print(nine)
else:
    two = 2
    three = N * M - two
    print(three)

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    x = n*m
    if n < 2 or m < 2: # 4隅
        x -= 2
    else:
        x -= (2*m + 2*n)-4
    print(x)

if __name__ == "__main__":
    main()

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-1)
elif M == 1:
  print(N-1)
else:
  print(int(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(max(0,n-2)*max(0,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:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,m = I2()
    if n <= 2 or m <= 2:
        print(0)
    else:
        print(max(1, n - 2)*max(1, m - 2))

Submission status: Wrong Answer

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,m = I2()
    print(max(1, n - 2)*max(1, m - 2))

Submission status: Wrong Answer

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

n -= 2
m -= 2

ans = 0

if n == 0 or m == 0:
    ans = 0

elif n == -1 and m == -1:
    ans = 0

elif n == -1 or m == -1:
    ans = max(n, m)

else:
    ans = n * m

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
a = max(n, m)
b = min(n, m)
if b == 1:
    print((a - 2) if a > 2 else 0)
elif b == 2:
    print(0)
else:
    print((a - 2) * (b - 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(M-2)
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M=map(int, input().split())

# if N==1 and M==1:
#     print(0)
#     sys.exit()

# if N==1 and M==2:
#     print(2)
#     sys.exit()

# if N==2 and M==1:
#     print(2)
#     sys.exit()

# if N==1:
#     print(M-2)
#     sys.exit()

# if M==1:
#     print(N-2)
#     sys.exit()

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M=map(int, input().split())

if N==1 and M==1:
    print(0)
    sys.exit()

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

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M=map(int, input().split())

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

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    if n > m:
        n, m = n, m
    if n == 1:
        if m == 1:
            print(1)
        else:
            print(m-2)
    else:
        print((n-2)*(m-2))



    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    if n > m:
        n, m = n, m
    if n == 1:
        print(m-2)
    else:
        print((n-2)*(m-2))



    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""

Submission status: Wrong Answer

Solution code:
# これ灰difじゃないか？
# 各マス偶数回なら表 奇数回なら裏 -> 角は偶数回（4回）だし縁も偶数回（6回）だけどソレ以外は9回
# n, m = 1, 1の場合を忘れていて2WA ?
n, m = map(int, input().split())
if n == m == 1:
    print(0)
elif n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print(n * m - (n * 2 + (m - 2) * 2))

Submission status: Wrong Answer

Solution code:
# これ灰difじゃないか？
# 各マス偶数回なら表 奇数回なら裏 -> 角は偶数回（4回）だし縁も偶数回（6回）だけどソレ以外は9回
# n, m = 1, 1の場合を忘れていて1WA
n, m = map(int, input().split())
if n == 1 or m == 1:
    print(max(0, max(n, m) - 2))  # n, m = 1, 1の場合0
else:
    print(n * m - (n * 2 + (m - 2) * 2))

Submission status: Wrong Answer

Solution code:
# これ灰difじゃないか？
# 各マス偶数回なら表 奇数回なら裏 -> 角は偶数回（4回）だし縁も偶数回（6回）だけどソレ以外は9回
n, m = map(int, input().split())
if n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print(n * m - (n * 2 + (m - 2) * 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, m = LI()
if n == 1:
    print(max(0, m-2))
elif m == 1:
    print(max(0, n-2))
elif n == 2:
    print(0)
elif 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 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:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,m = iim()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,m=l()
if(n==1 and m==1):
    print(1)
    exit()
if(n==1 and m!=1):
    print(m-2)
    exit()
print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,m=l()
if(n==1 and m==1):
    print(1)
    exit()
if(n==1 and m!=1):
    print(m-2)
    exit()
if(n<=2 and m<=2):
    print(0)
    exit()
if(n==2):
    print((m-2)*2)
    exit()
if(m==2):
    print((n-2)*2)
    exit()
print(max(1,n-2)*max(1,m-2))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



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

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



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

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,m=l()
if(n<=2 and m<=2):
    print(0)
    exit()
if(n==2):
    print((m-2)*2)
    exit()
if(n==2):
    print((m-2)*2)
    exit()
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 and M == 1:
    print(0)
elif N == 1:
    print(M - 2)
else:
    print(N * M - 2 * N - 2 * M + 4)

Submission status: Wrong Answer

Solution code:
import math
import collections
import fractions
import itertools

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import math
import collections
import fractions
import itertools

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import math
import collections
import fractions
import itertools

def solve():
    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))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def solve():
    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))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

ret = 0

if (n >= 3) and (m >= 3):
    ret += (n-2) * (m-2)

if (n == 1) and (m >= 3):
    ret += m - 2

if (m == 1) and (n >= 3):
    ret += n - 2

print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import collections

def main():
    x, y = input_list()
    print((x-2) * (y-2))


def yogen(a, b, angle):
    coss = math.cos((angle/180)*math.pi)
    return math.sqrt(a**2 + b**2 - 2*a*b*coss)


def get_angle(hour, minute):
    h = (hour * 360) / 12 + (minute * 360) / (12 * 60)
    m = (minute * 360) / 60
    angle = abs(h-m)
    return min(angle, 360-angle)

def has(v, l):
    for vl in l:
        if v == vl:
            return True
    return False

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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())

n = min(N,M)
m = max(N,M)

if n*m == 1:
  print(1)
if n == 1:
  print(m-2)
  exit()
print((n-2)*(m-2))

Submission status: Wrong Answer

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

n = min(N,M)
m = max(N,M)

if n == 1 & m == 1:
  print(1)
  exit()
if n == 1:
  print(m-2)
  exit()
print((n-2)*(m-2))

Submission status: Wrong Answer

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

if (N==1) & (M > 1):
    ans = M - 2
elif (N==1) & (M < 1):
    ans = N - 2
elif (N==1) & (M==1):
    ans = 1
else:
    ans = ((N - 2) * (M - 2))

print(ans)