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

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

print(ans)

Submission status: Wrong Answer

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

if N==1 and M > 1:
    ans = M - 2
elif N==1 and M < 1:
    ans = N - 2
elif N==1 and M==1:
    ans = 1

print(ans)

Submission status: Wrong Answer

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

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:
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))

# 求解処理
result = max((N - 2) * (M - 2), 0)

# 結果出力
print(result)

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

Submission status: Wrong Answer

Solution code:
s = input()
res = [0] * (len(s)+1)

for i in range(len(s)):
  if s[i] == "<":
    res[i +1] = res[i] +1

for i in range(len(s)-1,-1,-1):
  if s[i] == ">":
    res[i] = max(res[i], res[i+1]+1)

print(sum(res))

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)
'''
input_map = [[1 for i in range(m)]for j in range(n)]

def checker(input_map,x,y):
    if 0<=x<=m-1 and 0<=y<=n-1:
        input_map[y][x]*=-1
    return input_map

check_li = [[0,0],[0,1],[1,0],[1,1],[-1,0],[0,-1],[-1,-1],[-1,1],[1,-1]]
for i in range(n):
    for j in range(m):
        for c in check_li:
            input_map = checker(input_map,j+c[0],i+c[1])

ans=0
for i in range(n):
    for j in range(m):
        if input_map[i][j]==-1:
            ans+=1
print(ans)
'''

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    ans=n**2
    ans-=n*k
    for i in range(k+1,n+1):
        temp=n//i
        temp*=k
        temp+=min(n%i,k-1,0)
        ans-=temp 
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    ans=n**2
    ans-=n*(k)
    for i in range(k+1,n+1):
        temp=n//i
        temp*=k
        temp+=min(n%i,k-1)
        #print(ans)
        ans-=temp 
    print(ans)
    

main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    ans=0
    
    for i in range(k,1+n):
        for j in range(k+1,n+1):
            if i%j>=k:
                ans+=1
    print(ans)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''

    N, M = [int(item) for item in input().split()]
    res_dict = {1:0, 2:0, 3:0, 5:0, 8:0}

    if N > M:
        N, M = M, N
    
    if N == 1:
        if M >= 2:
            res_dict[1] = 2
            res_dict[2] = M -2
    else:
        res_dict[3] = 4
        res_dict[5] = 2* (N - 2 + M - 2)
        res_dict[8] = M*N - (2*(N+M) -4)
    
    # print(res_dict)
    cnt = 0
    for i, v in res_dict.items():
        if i % 2 == 0:
            cnt += v

    print(cnt)            


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''

    N, M = [int(item) for item in input().split()]
    res_dict = {1:0, 2:0, 3:0, 5:0, 8:0}

    if N > M:
        N, M = M, N
    
    if N == 1:
        if M >= 2:
            res_dict[1] = 2
            res_dict[2] = M -2
        else:
            res_dict[1] = 1
    else:
        res_dict[3] = 4
        res_dict[5] = 2* (N - 2 + M - 2)
        res_dict[8] = M*N - (2*(N+M) -4)
    
    # print(res_dict)
    cnt = 0
    for i, v in res_dict.items():
        if i % 2 == 0:
            cnt += v

    print(cnt)            


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

total = N * M

sumi = 4
if N >= 2 and M >= 2:
    hen = (N-2) * 2 + (M-2) * 2
    ans = total - sumi - hen
elif N == 1 and M > 1:
    hen = M-2
    ans = hen
elif N > 1 and M == 1:
    hen = N - 2
    ans = hen
else:
    ans = 0


print(ans)

Submission status: Wrong Answer

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

total = N * M

sumi = 4
if N >= 2 and M >= 2:
    hen = (N-2) * 2 + (M-2) * 2
    ans = total - sumi - hen
elif N <= 2 and M > 2:
    hen = (M-2) * N
    ans = hen
elif N > 2 and M <= 2:
    hen = (N - 2) * M
    ans = hen
else:
    ans = 0


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

    if N == 2 or M == 2:
        print(N*M-4)
        return

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    if N > 2 and M > 2:
        print((N-2) * (M-2))
        return
    if N == 1 and M == 1:
        print(1)
        return
    if N == 1 or M >= 2:
        print(M-2)
        return
    if N >= 2 or M == 1:
        print(N-2)
        return
    print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    if N > 2 and M > 2:
        print((N-2) * (M-2))
        return
    if N == 1 and M == 1:
        print(1)
    if N == 1 or M >= 2:
        print(M-2)
        return
    if N >= 2 or M == 1:
        print(N-2)
        return
    print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
ans=0
if min(N,M)==1:
    print(max(N,M)-2)
    exit()
for h in range(N):
    for w in range(M):
        count=0
        if 1<=h<N-1 and 1<=w<M-1:
            count+=9
        else:
            count+=4
        if count%2==1:
            ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

N,M = map(int,input().split())
if(min(N,M)==1):
    if(max(N,M)>2):
        print(max(N,M)-2)
    else:
        print(0)
elif(min(N,M)==2):
    print(0)
else:
    print(N*M - (N*2+M*2 - 4))

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

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:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
if N > M: N, M = M, N
if N == 2: print(0)
elif N == 1 and (M == 2): print(0)
elif N == 1: print(max(0, M - 2))
else: print(max(0, (N - 2) * (M - 2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/arc091/tasks/arc091_a

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

peremeter = 0
if n == 1 or m == 1:
    peremeter += 2
else:
    if n - 1 > 0:
        peremeter += (n - 1) * 2
    if m - 1 > 0:
        peremeter += (m - 1) * 2
ans = n * m - peremeter
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a == 1 or b == 1:
    print(a * b - 2)
else:
    print((a - 2) * (b - 2))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
nn = min(n, m)
mm = max(n, m)

if nn == mm:
  if nn == 1:
    print(1)

  else:
    print(max(nn-2, 0) * max(mm-2, 0))
  
else:
  print(max(nn-2, 1) * max(mm-2, 1))

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
nn = min(n, m)
mm = max(n, m)

if nn == 1:
  print(1)

else:
  print(max(nn-2, 0) * max(mm-2, 0))

Submission status: Wrong Answer

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

if n == m:
  if n == 1:
    print(1)

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

Submission status: Wrong Answer

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

if n == m:
  if n == 1:
    print(1)

  else:
    print(max(n-2, 0) * max(m-2, 0))
  
else:
  print(max(n-2, 1) * max(m-2, 1))

Submission status: Wrong Answer

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

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

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

def flip(a,b):
    A = max(a,b)
    B = min(a,b)

    if B >= 2:
        return (A-2) * (B-2)

    if B == 1:
        if A >= 2:
            return (A-2)
        elif A == 1:
            return 0

a = flip (N, M)
print(a)

Submission status: Wrong Answer

Solution code:
H, W =[int(i) for i in input().split()]
if H==1 and W!=1:
  print(max(0, W-2))
elif W==1 and H!=1:
  print(max(0, H-2))
else:
  print(max(H-2, 0)*max(W-2, 0))

Submission status: Wrong Answer

Solution code:
H, W =[int(i) for i in input().split()]
print(max(H-2, 0)*max(W-2, 0))

Submission status: Wrong Answer

Solution code:
H, W =[int(i) for i in input().split()]
if H==1:
  print(max(0, W-2))
elif W==1:
  print(max(0, H-2))
else:
  print(max(H-2, 0)*max(W-2, 0))

Submission status: Wrong Answer

Solution code:
H, W =[int(i) for i in input().split()]
if H==1:
  print(min(0, W-2))
elif W==1:
  print(min(0, H-2))
else:
  print(min(H-2, 0)*min(W-2, 0))

Submission status: Wrong Answer

Solution code:
H, W =[int(i) for i in input().split()]
print(min(H-2, 0)*min(W-2, 0))

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 >= 3 and m==1:
    ans = n-2
elif m >= 3 and n==1:
    ans = m-2
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
  exit(0)

w = n - 2
h = m - 2
if w < 1 or h < 1:
  print(max(w, h))
  exit(0)
  
print(w*h)

Submission status: Wrong Answer

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

w = n - 2
h = m - 2
if w < 1 or h < 1:
  print(max(w, h))
  exit(0)
  
print(w*h)

Submission status: Wrong Answer

Solution code:
# import bisect
from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, m = list(map(int,ipti().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))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

NM = [int(x) for x in input().split()]
NM.sort()
N = NM[0]
M = NM[1]

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

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

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

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    if N == 1:
        print(M-2)
    elif M == 1:
        print(N-2)
    else:
        print((N-2) * (M-2))

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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


def solve(n: int, m: int):
    if n >= 2 and m >= 2:
        return n * m - 2 * (n + m - 2)
    return max(n - 2, 0) + max(m - 2, 0)


def main():
    N, M = map(int, input().split())
    print(solve(N, M))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# 四隅のカードが裏を向くか
fc=(N==1 and M==1) # 4箇所のうち1箇所(自分自身)にのみカードがある場合
# 左端及び右端（四隅を含まない。）のカードが裏を向くか(N>=3)
fs=(N>=3 and M==1) # 6箇所のうち3箇所にのみカードがある場合
# 上端及び下端（四隅を含まない。）のカードが裏を向くか(M>=3)
fu=(M>=3 and N==1) # 同上
# 内部のカードが裏を向くか(N>=3 and M>=3)
fi=(M>=3 and N>=3) # N>1 and M>1のとき内部のカードは全て裏を向く。9箇所にカードがあるので

ans=(4 if fc else 0)+(N-2 if fs else 0)+(M-2 if fu else 0)+((M-2)*(N-2) if fi else 0)

print(ans)

Submission status: Wrong Answer

Solution code:
# n,m = map(int,input().split())
n,m = 5,5
lis = [[0]*n for _ in range(m)]
for i in range(n):
  for j in range(m):
    if i == 0:
      if j == 0:
        lis[i][j] += 1
        lis[i][j+1] += 1
        lis[i+1][j] += 1
        lis[i+1][j+1] += 1
      elif j == m-1:
        lis[i][j] += 1
        lis[i][j-1] += 1
        lis[i+1][j] += 1
        lis[i+1][j-1] += 1
      else:
        lis[i][j] += 1
        lis[i][j-1] += 1
        lis[i+1][j] += 1
        lis[i+1][j-1] += 1
        lis[i][j+1] += 1
        lis[i+1][j+1] += 1
      
    elif i == n-1:
      if j == 0:
        lis[i][j] += 1
        lis[i][j+1] += 1
        lis[i-1][j] += 1
        lis[i-1][j+1] += 1
      elif j == m-1:
        lis[i][j] += 1
        lis[i][j-1] += 1
        lis[i-1][j] += 1
        lis[i-1][j-1] += 1
      else:
        lis[i][j] += 1
        lis[i][j-1] += 1
        lis[i-1][j] += 1
        lis[i-1][j-1] += 1
        lis[i][j+1] += 1
        lis[i-1][j+1] += 1
    else:
      if j == 0:
        lis[i][j] += 1
        lis[i][j+1] += 1
        lis[i+1][j] += 1
        lis[i+1][j+1] += 1
        lis[i-1][j] += 1
        lis[i-1][j+1] += 1

      elif j == m-1:
        lis[i][j] += 1
        lis[i][j-1] += 1
        lis[i-1][j] += 1
        lis[i-1][j-1] += 1 
        lis[i+1][j] += 1
        lis[i+1][j-1] += 1

      else:
        lis[i][j] += 1
        lis[i][j-1] += 1
        lis[i][j+1] += 1        
        lis[i-1][j] += 1
        lis[i-1][j-1] += 1
        lis[i-1][j+1] += 1        
        lis[i+1][j] += 1
        lis[i+1][j-1] += 1
        lis[i+1][j+1] += 1

#print(lis)
cnt = 0
for i in range(n):
    for j in range(m):
        if lis[i][j]%2 == 1:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
n=0
m=0
if(N!=1):
    n=2
if(M!=1):
    m=2
if((N==1)&(M==1)):
    print("0")
    exit()

print(N*M-N*m-M*n+n*m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split(' '))
    result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]
    if k == 0:
        print(sum(result)-n)
    else:
        print(sum(result))
main()

Submission status: Wrong Answer

Solution code:
import math
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N,M = map(int,input().split())
if N > 1 and M > 1:
    print((N-2)*(M-2))
else:
    print(max(0,N+M-3))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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