Harryxun/stf_run huggingface dataset:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
from itertools
import queue
import copy
from scipy import linalg
import scipy
import numpy as np
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])

def main():
    s = input()
    NG = 1
    NP = 0
    did = ["g"]
    point = 0
    for i in range(1,len(s)):
        if s[i] == "g":
            if NP + 1 <= NG:
                did.append("p")
                NP += 1
                point += 1
            else:
                did.append("g")
                NG += 1
        else:
            if NP + 1 <= NG:
                did.append("p")
                NP += 1
            else:
                did.append("g")
                NG += 1
                point -= 1
    print(point)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])

def main():
    s = input()
    NG = 1
    NP = 0
    did = ["g"]
    point = 0
    for i in range(1,len(s)):
        if s[i] == "g":
            if NP + 1 <= NG:
                did.append("p")
                NP += 1
                point += 1
            else:
                did.append("g")
                NG += 1
        else:
            if NP + 1 <= NG:
                did.append("p")
                NP += 1
            else:
                did.append("g")
                NG += 1
                point -= 1
    print(point)

if __name__ == "__main__":
    main()
import math
a, b, c, d = map(int, input().split())
div_c = b//c + (-a//c) + 1
div_d = b//d + (-a//d) + 1
div_cd = b//(c*d//math.gcd(c, d)) + (-a//(c*d//math.gcd(c,d))) + 1
print(b-a+1 - div_c - div_d + div_cd)


### FIXED CODE ###

import fractions
a, b, c, d = map(int, input().split())
div_c = b//c + (-a//c) + 1
div_d = b//d + (-a//d) + 1
div_cd = b//(c*d//fractions.gcd(c, d)) + (-a//(c*d//fractions.gcd(c,d))) + 1
print(b-a+1 - div_c - div_d + div_cd)
N = int(input())
X = list(input())
P = X.count("1")
P1 = 0
P2 = 0
for i in range(N):
    if X[i] == "1":
        P1 += pow(2,N-i-1,P-1)
        P1 %= P-1
        P2 += pow(2,N-i-1,P+1)
        P2 %= P+1
for i in range(N):
    count = 1
    if X[i] == "0":
        cur = P2+pow(2,N-i-1,P+1)
        cur %= P+1
    else:
        cur = P1-pow(2,N-1-i,P-1)
        cur %= P-1
    while cur > 0:
        mod = bin(cur).count("1")
        cur %= mod
        count += 1
    print(count)

### FIXED CODE ###

N = int(input())
X = list(input())
P = X.count("1")
if P != 1:
    P1 = 0
    P2 = 0
    for i in range(N):
        if X[i] == "1":
            P1 += pow(2,N-i-1,P-1)
            P1 %= P-1
            P2 += pow(2,N-i-1,P+1)
            P2 %= P+1
    for i in range(N):
        count = 1
        if X[i] == "0":
            cur = P2+pow(2,N-i-1,P+1)
            cur %= P+1
        else:
            cur = P1-pow(2,N-1-i,P-1)
            cur %= P-1
        while cur > 0:
            mod = bin(cur).count("1")
            cur %= mod
            count += 1
        print(count)
else:
    P2 = 0
    for i in range(N):
        if X[i] == "1":
            P2 += pow(2,N-i-1,P+1)
    for i in range(N):
        count = 1
        if X[i] =="1":
            print(0)
        else:
            cur = P2+pow(2,N-i-1,P+1)
            cur %= P+1
            while cur > 0:
                mod = bin(cur).count("1")
                cur %= mod
                count += 1
            print(count)
n, x = list(map(int, input()))
m = [i for i in int(input())]
rem_donut = x - sum(m)
add_donut = rem_donut // min(m)
print(add_donut + n)

### FIXED CODE ###

n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
rem_donut = x - sum(m)
add_donut = rem_donut // min(m)
print(add_donut + n)
def f(a, b, c, k):
    abc = sorted([a, b, c])
    abc[2] *= 2 * k
    print(sum(abc))


f(map(int, input().split()), int(input()))


### FIXED CODE ###

def f(a, b, c, k):
    abc = sorted([a, b, c])
    if k != 0:
        abc[2] *= 2 ** k
    print(sum(abc))

a, b, c = map(int, input().split())
k = int(input())
f(a, b, c, k)
i=0
while True:
    x=int(input())"文字列なのでint()でキャスト"
    if(x==0) break
    print(f"Case {i}:{x}")
    i=i+1



### FIXED CODE ###

i=0
while True:
    x=int(input()) 
    if(x==0):
        break 
    i=i+1
    print(f"Case {i}: {x}")
input = open(0).readline
s = {}
s['A'] = list(input().strip())
s['B'] = list(input().strip())
s['C'] = list(input().strip())

play_order = {'A':'B', 'B':'C', 'C':'A'}

def play(player):
    
    if  len(s[player]) == 0:
        play(play_order[player])
    
    next_play = s[player].pop()
    if len(s[player]) == 0:
        print(player)
        return player
    #print(next_play)
    play(next_play.upper())
        
play('A')
        
        




### FIXED CODE ###

input = open(0).readline

x = [0]*3
for i in range(3):
    x[i] = int(input().strip())
a, b, h = x[0], x[1], x[2]
ans = int(((a + b) * h)/2)
print(ans)
# -*- coding:utf-8 -*-

import math

N = int(input())

type_dict = {}
for _ in range(N):
    s = input()
    counts = (
        s.count('a'), s.count('b'), s.count('c'), s.count('d'),
        s.count('e'), s.count('f'), s.count('g'), s.count('h'),
        s.count('i'), s.count('j'), s.count('k'), s.count('l'),
        s.count('m'), s.count('n'), s.count('o'), s.count('p'),
        s.count('q'), s.count('r'), s.count('s'), s.count('t'),
        s.count('u'), s.count('v'), s.count('w'), s.count('x'),
        s.count('y'), s.count('z')
    )
    if counts in type_dict:
        type_dict[counts] = type_dict[counts] + 1
    else:
        type_dict[counts] = 1


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(sum([combinations_count(x, 2) for x in type_dict.items() if x > 1]))


### FIXED CODE ###

# -*- coding:utf-8 -*-

import math

N = int(input())

type_dict = {}
for _ in range(N):
    s = input()
    counts = (
        s.count('a'), s.count('b'), s.count('c'), s.count('d'),
        s.count('e'), s.count('f'), s.count('g'), s.count('h'),
        s.count('i'), s.count('j'), s.count('k'), s.count('l'),
        s.count('m'), s.count('n'), s.count('o'), s.count('p'),
        s.count('q'), s.count('r'), s.count('s'), s.count('t'),
        s.count('u'), s.count('v'), s.count('w'), s.count('x'),
        s.count('y'), s.count('z')
    )
    if counts in type_dict:
        type_dict[counts] = type_dict[counts] + 1
    else:
        type_dict[counts] = 1


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(sum([combinations_count(x, 2) for x in type_dict.values() if x > 1]))
Books,Cost,X=None,None,None
DP={}

def getUnderstanding(prev,curr):
    global Books
    L=[]
    for i in range(len(prev)):
        L.append(prev[i]+Books[curr][i])
    return L
def isUnderstandingReached(prev):
    global X
    for u in prev:
        if u<X:
            return False
    return True

def F(curr,prev):
    global Books,Cost,X,DP
    if (curr,tuple(prev)) in DP:
        return DP[(curr,prev)]
    if isUnderstandingReached(prev):
        return 0
    if curr==len(Books):
        return float('inf')
    DP[(curr,tuple(prev))]=min(Cost[curr]+F(curr+1,getUnderstanding(prev,curr)),F(curr+1,prev))
    return DP[(curr,tuple(prev))]

N,M,X=map(int,input().strip().split())
Books=[]
Cost=[]
for i in range(N):
    L=list(map(int,input().strip().split()))
    Books.append(L[1:])
    Cost.append(L[0])
print(F(0,[0]*len(Books[0])))

### FIXED CODE ###

Books,Cost,X=None,None,None
DP={}

def getUnderstanding(prev,curr):
    global Books
    L=[]
    for i in range(len(prev)):
        L.append(prev[i]+Books[curr][i])
    return L
def isUnderstandingReached(prev):
    global X
    for u in prev:
        if u<X:
            return False
    return True

def F(curr,prev):
    global Books,Cost,X,DP
    #if (curr,tuple(prev)) in DP:
    #    return DP[(curr,prev)]
    if isUnderstandingReached(prev):
        return 0
    if curr==len(Books):
        return float('inf')
    DP[(curr,tuple(prev))]=min(Cost[curr]+F(curr+1,getUnderstanding(prev,curr)),F(curr+1,prev))
    return DP[(curr,tuple(prev))]

N,M,X=map(int,input().strip().split())
Books=[]
Cost=[]
for i in range(N):
    L=list(map(int,input().strip().split()))
    Books.append(L[1:])
    Cost.append(L[0])
res=F(0,[0]*len(Books[0]))
if res==float('inf'):
    print(-1)
else:
    print(res)
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N=int(input())
div=make_divisors(N)

from math import sqrt

tmpmin=10*10
for i in range(len(div)):
  if tmpmin>abs(sqrt(N)-div[i]):
    tmpmin=abs(sqrt(N)-div[i])
    minidx=i

a=div[minidx]
b=N//a

print(a-1+b-1)


### FIXED CODE ###

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N=int(input())
div=make_divisors(N)

from math import sqrt

tmpmin=10**16
for i in range(len(div)):
  if tmpmin>abs(sqrt(N)-div[i]):
    tmpmin=abs(sqrt(N)-div[i])
    minidx=i

a=div[minidx]
b=N//a

print(a-1+b-1)
x, y = map(int, input().split())
ans = False

for i in range(101):
  for j in range(101):
    if i+j == x and 2*i + 4*j == y:
		ans = True

if ans:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x, y = map(int, input().split())
ans = False
 
for i in range(101):
	for j in range(101):
		if i+j == x and 2*i+4*j == y:
			ans = True
if ans:
	print("Yes")
else:
	print("No")
a = int(input())
if a[1] == 7 or a[2] == 7 or a[3] == 7 :
  print(Yes)
else :
  print(No)

### FIXED CODE ###

a = input()
if a[0] == '7' or a[1] == '7' or a[2] == '7' :
  print("Yes")
else :
  print("No")
a,b=map(int,input().split())
s=a//b
r=a%b
f=a/b
print(s,r,double(f))


### FIXED CODE ###

a,b=map(int,input().split())
print(a//b,a%b,"{0:10.20f}".format(a/b))
N, M, Q = map(int, input().split())
B = [tuple(int(i) for i in input().split()) for i in range(Q)]

A = [1]*N
def recur(A=A, index=0, lim=M):
    if index>len(A)-2:
        return
    while A[index] <= lim-1:
        A[index] += 1
        yield A[::-1]
        yield from recur(A[:], index+1, A[index])
    return

def get_point(A):
    return sum((A[b[1]-1]-A[b[0]-1]==b[2])*b[3] for b in B)

print(max(get_point(A), *(get_point(i) for i in recur())))


### FIXED CODE ###

N, M, Q = map(int, input().split())
B = [tuple(int(i) for i in input().split()) for i in range(Q)]

A = [1]*N
def recur(A=A, index=0, lim=M):
    if index>len(A)-2:
        return
    while A[index] <= lim-1:
        A[index] += 1
        yield A[::-1]
        yield from recur(A[:], index+1, A[index])
    return

def get_point(A):
    return sum((A[b[1]-1]-A[b[0]-1]==b[2])*b[3] for b in B)

print(max(0, get_point(A), *(get_point(i) for i in recur())))
n = int(input())
ls = [0]*n
param_list = [0]*2**n
for i in range(2**n):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & (2 ** id_r) >0:
            l[id_r] = True
    param_list[i] = l 
#1print(param_list)
"""
for i in range(2**(n-1)):
    l = [True]+[False]*(n-1)
    for id_r, row in enumerate(ls):
        if i & id_r >0:
            l[id_r] = True
    param_list[i+2**(n-1)] = l 
print()
print(len(param_list))
print(param_list)
a_list = get_unique_list(param_list)
print(len(a_list))
print(a_list)"""

for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in a_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            else:
                new_param.append(d)
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans, d.count(True))
print(ans)

### FIXED CODE ###

n = int(input())
ls = [0]*n
param_list = [0]*2**n
for i in range(2**n):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & (2 ** id_r) >0:
            l[id_r] = True
    param_list[i] = l 


for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in param_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            else:
                new_param.append(d)
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans, d.count(True))
print(ans)
from itertools import accumulate
from math import factorial as fc

def cmb_2(n):
    return n*(n-1)//2

N,K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A = [i-1 for i in A]

sumA = list(accumulate(A))
sumA = [0]+[i % K for i in sumA]
x = sumA[:K]
modmap = [0]*K
for i in x:
    modmap[i] += 1

ans = 0
for i in range(K):
    ans += cmb_2(modmap[i])

for i in range(N-K+1):
    modmap[sumA[K+i]] += 1
    modmap[sumA[i]] -= 1
    ans += modmap[sumA[K+i]]-1

print(ans)

### FIXED CODE ###

import sys
from itertools import accumulate
from collections import defaultdict
input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [i-1 for i in a]
suma = [0]+list(accumulate(a))
suma = [i%k for i in suma]
rem = defaultdict(int)
ans = 0
if k > n:
    for i in range(n+1):
        x = suma[i]
        rem[x] += 1
    for s in rem.values():
        ans += s*(s-1)//2
    print(ans)
    exit()
for i in range(k):
    x = suma[i]
    rem[x] += 1
for s in rem.values():
    ans += s*(s-1)//2
for i in range(n-k+1):
    rem[suma[i]%k] -= 1
    rem[suma[i+k]%k] += 1
    ans += rem[suma[i+k]] -1
print(ans)
n = int(input())
a = [int(input()) for _ in range(n)]
a1 = sorted(a)
if a1[n-1]==a1[n-2]:
  flag = True ## true = have repeat
  1max = a1[n-1]
else:
  flag = False ## false = no repeat
  1max = a1[n-1]
  2max = a1[n-2]
for i in range(n):
  if a[i]==1max and flag==True: print(1max)
  elif a[i]==1max and flag==False: print(2max)
  elif a[i]!=1max: print(1max)


### FIXED CODE ###

n = int(input())
num = []
maxnum = 0
count = 1
for i in range(n):
  a = int(input())
  if a>maxnum:
    maxnum = max(maxnum,a)
    count = 1
  elif a==maxnum:
    count += 1
  num.append(a)
  
for i in range(n):
  if count>1:
    print(maxnum)
  else:
    if num[i]!=maxnum:
      print(maxnum)
    else:
      subnum = num[0:i] + num[i+1:n]
      subnum = sorted(subnum)
      print(subnum[n-2])
import bisect

n,k=map(int,input().split())
x=list(map(int,input().split()))

zero_ind=bisect.bisect_left(x,0)
"""
print("max",0,k-zero_ind-1)
print("min",k,n-zero_ind)
print("max",1,k-n+zero_ind-1)
print("min",k,zero_ind+2)
"""
v,w=10**9,10**9
if(n-zero_ind >= k):v=abs(x[zero_ind+k-1])
if(zero_ind >= k):w=abs(x[zero_ind-k])

y=[10**9]
z=[10**9]

if(zero_ind != 0 and zero_ind != n):
    y=[abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]) for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind))]
    z=[abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]) for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2))]

"""
for i in range(k):
    print(abs(x[zero_ind+i]))
    print(x[zero_ind-(k-i)+1])

for i in range(1,k):
    print(abs(x[zero_ind-i]))
    print(x[zero_ind+(k-i)-1])
"""
print(min([v,w]+y+z))
"""
print(y)
print(z)
"""

### FIXED CODE ###

import bisect

n,k=map(int,input().split())
x=list(map(int,input().split()))

zero_ind=bisect.bisect_left(x,0)
"""
print("max",0,k-zero_ind-1)
print("min",k,n-zero_ind)
print("max",1,k-n+zero_ind-1)
print("min",k,zero_ind+2)
"""
v,w=10**9,10**9
if(n-zero_ind >= k):v=abs(x[zero_ind+k-1])
if(zero_ind >= k):w=abs(x[zero_ind-k])

y=[10**9]
z=[10**9]

if(zero_ind != 0 and zero_ind != n):
    for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind)):
        if(zero_ind+i<0 or zero_ind+i>=n or zero_ind-(k-i)+1<0 or zero_ind-(k-i)+1>=n):continue
        y.append(abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]))
    for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2)):
        if(zero_ind-i<0 or zero_ind-i>=n or zero_ind+(k-i)-1<0 or zero_ind+(k-i)-1>=n):continue
        z.append(abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]))
    """
    y=[abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]) for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind))]
    z=[abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]) for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2))]
    """

"""
for i in range(k):
    print(abs(x[zero_ind+i]))
    print(x[zero_ind-(k-i)+1])

for i in range(1,k):
    print(abs(x[zero_ind-i]))
    print(x[zero_ind+(k-i)-1])
"""
print(min([v,w]+y+z))
"""
print(y)
print(z)
"""
a = input().split()
b = int(a[0] + a[1])
c = -1
for(i = 1; i < 100100; i=(i+1)*(i+1))
  if(b == i) c = b;
if(c != -1) :
  print('yes')
else :
  print('no')

### FIXED CODE ###

a = input().split()
b = int(a[0] + a[1])
c = -1
i = 0
j = 0
while(j < 100100):
  if(b == j):
    c = b
  i+=1
  j = i*i
if(c != -1) :
  print('Yes')
else :
  print('No')
N = int(input())
Numbers = list(map(int, input().split()))

from math import gcd
from functools import reduce
import sys

def get_gcd(number_list):
    return reduce(gcd, number_list)

gcd_list = []
for i in range(N):
    tmp_list = Numbers[:i] + Numbers[i + 1:]
    gcd_list.append(get_gcd(tmp_list))
print(int(max(gcd_list)))


### FIXED CODE ###

from functools import reduce
from itertools import combinations
from fractions import gcd

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


Left = [0] * (N + 1)
Right = [0] * (N + 1)

for i in range(N):
    Left[i + 1] = gcd(Left[i], A[i])
    Right[N - i - 1] = gcd(Right[N - i], A[N - i - 1])
ans = 0
for i in range(N):
    ans = max(ans, gcd(Left[i], Right[i + 1]))
    
print(ans)
a, b, c, k = map(int, input().split())


def actual(a, b, c, k):
    if a >= k:
        return k
    else:
        k -= a

    if b >= k:
        return a
    else:
        k -= b

    return a - k


print(actual(a, b, c, k))


### FIXED CODE ###

s = input()
t = input()

if s == t[:-1]:
	print('Yes')
else:
  	print('No')
import numpy as np
n=int(input())
ans=[]
for i in range(n):
    qw=input()
    ans.append(np.zeros(10))
    for j in range(10):
        ans[i][j]=qw[j]
    ans[i].sort()

ans.sort()
a=0
for i in range(n-1):
    for j in range(n-1-i):
        if ans[i]==ans[i+j+1]:
            a+=1
        else:
            break

print(int(a))


### FIXED CODE ###

n=int(input())
ans=[]
for i in range(n):
    qw=input()
    ans.append([0,0,0,0,0,0,0,0,0,0])
    for j in range(10):
        ans[i][j]=qw[j]
    ans[i].sort()

lis=[]
for i in range(n):
    lis.append(ans[i][0])
    for j in range(9):
        lis[i]+=ans[i][j+1]

a=0
#print(lis)

dic={lis[0]:1}
for i in range(n-1):
    if lis[i+1] in dic.keys():
        a+=dic[lis[i+1]]
        dic[lis[i+1]]+=1
    else:
        dic[lis[i+1]]=1

print(int(a))
a = int(input())
s  = str(input())
if n >= 3200:
  print(s)
else:
  print('red')

### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print('red')
N ,M = list(map(int,input()))
if N == 2 or M == 2:
  print(0)
elif N == 1 or M == 1:
  print(abs(max(N,M)-2))
else:
  print((N-2) * (M-2))

### FIXED CODE ###

k = list(map(int,input().split()))
N, M = k[0],k[1]
if N == 2 or M == 2:
  print(0)
elif N == 1 or M == 1:
  print(abs(max(N,M)-2))
else:
  print((N-2) * (M-2))
import sys

n=int(input())
a=list(int(x) for x in input().split())

count=0
z=True
j=0

if  1 not in a:
    print(-1)
    sys.exit(1)

for k in range(j,n):
    if a[k]==count+1:
        j=k
        count=count+1

print(n-count)

### FIXED CODE ###

n=int(input())
a=list(int(x) for x in input().split())

count=0
z=True
j=0

if  1 not in a:
    print(-1)
else:
    for k in range(j,n):
        if a[k]==count+1:
            j=k
            count=count+1

    print(n-count)
N,M=map(int,input().split())
N=N-M
if =0<N:
   print(N)
else:
   print(-1)

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=0
for i in A:
    B=B+i       
N=N-B
if 0<=N:
    print(N)
else:
    print(-1)
n = int(input())
arr = list(map(int, input().split()))
for i in range(n, 1, -1):
  if(arr[i-1] <= arr[i]):
    a = 1
  else:
    if(arr[i-1] - 1 > arr[i]):
      print("No")
      exit()
    else:
      arr[i-1] = arr[i - 1] - 1
if(sorted(arr) == arr):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))
for i in range(n-1, 1, -1):
  if(arr[i-1] <= arr[i]):
    a = 1
  else:
    if(arr[i-1] - 1 > arr[i]):
      print("No")
      exit()
    else:
      arr[i-1] = arr[i - 1] - 1
if(sorted(arr) == arr):
  print("Yes")
else:
  print("No")
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort()
    return a

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

f = factorization(M)
f = np.array(f)
print(np.max(f[f<=M/N]))

### FIXED CODE ###

import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort(reverse=True)
    return a

N,M = map(int,input().split())
f = factorization(M)
for i in f:
    if i <= M/N:
        print(i)
        exit()
x=int(input())
for i in range(-118, 120):
  if x-pow(i, 5)>=0:
    if pow((x-pow(i, 5)), 0.2).is_integer():
      b=pow((x-pow(i, 5)), 0.2)
      print(a, b)
      break
  else:
    if pow(-(x-pow(i, 5)), 0.2).is_integre():
      b=pow(-(x-pow(i, 5)), 0.2)
      print(a, b)
      break

### FIXED CODE ###

import sys
x=int(input())
for i in range(-118, 120):
  for j in range(-119, 118):
    if pow(i, 5)-pow(j, 5)==x:
      print(i, j)
      sys.exit()
s = input()
ans = Felse
if s[0] == s[1] and s[2] == s[3] :
  ans = True
if s[0] == s[2] and s[1] == s[3] :
  ans = True
if s[0] == s[3] and s[0] == s[2] :
  ans = True
if ans :
  print('Yse')
else:
  print('No')

### FIXED CODE ###

s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and s[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')