Harryxun/stf_run huggingface dataset:
def resolve():
    '''
    code here
    '''
    S = input()

    memo = 1
    new_list = []
    
    prev = S[0]
    cnt = 0

    for i in range(len(S)-1):
        if S[i+1] == prev:
            memo += 1
        else:
            new_list.append(memo)
            memo = 1
        prev = S[i+1]
    else:
        new_list.append(memo)

    # print(new_list)

    res = []
    for i in range(len(new_list)//2):

        a = new_list[i*2]
        b = new_list[i*2 +1]
        cond = (10_000_000_000*10 - (a+b))%(a+b)

        if (a+b)%2 ==1:
            if cond % 2 == 1:
                res += [0 for _ in range(new_list[i*2])]
                res[-1] = new_list[i*2+1]
                res += [new_list[i*2]]
                res += [0 for _ in range(new_list[i*2+1]-1)]
            else:
                res += [0 for _ in range(new_list[i*2])]
                res[-1] = new_list[i*2]
                res += [new_list[i*2+1]]
                res += [0 for _ in range(new_list[i*2+1]-1)]
        else:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a + b) // 2
            res += [(a + b ) // 2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
    print(*res)




if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    S = input()

    memo = 1
    new_list = []
    
    prev = S[0]
    cnt = 0

    for i in range(len(S)-1):
        if S[i+1] == prev:
            memo += 1
        else:
            new_list.append(memo)
            memo = 1
        prev = S[i+1]
    else:
        new_list.append(memo)

    # print(new_list)

    res = []
    for i in range(len(new_list)//2):

        a = new_list[i*2]
        b = new_list[i*2 +1]

        if (a+b)%2 == 1:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a+1)//2 + b//2
            res += [a//2 + (b+1)//2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
        else:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a + b) // 2
            res += [(a + b ) // 2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
    print(*res)




if __name__ == "__main__":
    resolve()
class Solution:
    def isEven(self, a, b):
        if (a * b) % 2 == 0:
            print("Even")
        else:
            print("Odd")


if __name__ == "__main__":
    a, b = input(), input()
    solution = Solution()
    solution.isEven(a, b)


### FIXED CODE ###

class Solution:
    def isEven(self, a: int, b: int):
        if (a * b) % 2 == 0:
            print("Even")
        else:
            print("Odd")


if __name__ == "__main__":
    a, b = map(int, input().split())
    solution = Solution()
    solution.isEven(a, b)
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)

### FIXED CODE ###

H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(H):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)
N, M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]

b = [0]*N

ans = 0
for i in range(N):
    if b[A[i][0]-1] ==0:
        b[A[i][0]-1] = A[i][1]
    elif b[A[i][0]-1] == A[i][1]:
        pass
    else:
        ans = -1
        break

s = ''.join([str(N) for N in b])

if ans == 0:
    print(s)
else:
    print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
    if len(str(i))==n:
        x=str(i)
        for b,c in a:
            if int(x[b-1])!=c:
                break
        else:
            print(i)
            exit()
print(-1)
K, T = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)

print(max(0, A[0] - 1 - sum(A[1:]))

### FIXED CODE ###


K, T = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)

print(max(0, A[0] - 1 - sum(A[1:])))
N = int(input())
list=list(max(int, input().split()))
list.sort()
print(list[-1]-list[0])

### FIXED CODE ###

N = int(input())
list=list(map(int, input().split()))
list.sort()
print(list[-1]-list[0])
a = [int(i) for i in input().split()] 
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (a[i]%10 +1)*10-a[i];
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
    else:
      sum = sum+a[i]+temp
print(sum)
  

### FIXED CODE ###

a2, b, c, d, e= [int(input()) for i in range(5)]
a=[a2,b,c,d,e]
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (int(a[i]/10) +1)*10-a[i];
    #print(temp)
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
     # print(sum)
    else:
      sum = sum+a[i]+temp
      #print(sum)
print(int(sum))
A,B,C,K = map(int,input().split())
answer = 0
if K <= A:
    print(K)
elif K > A:
    answer = A
    K = K - A
if K <= B , K > 0 :
    print(answer)
elif K > B:
    K = K - B
if K <= C,K > 0:
    answer = answer - K
    print(answer)

### FIXED CODE ###

A,B,C,K = map(int,input().split())
answer = 0
if K <= A:
    print(K)
    K = 0
elif K > A:
    answer = A
    K = K - A
if K <= B and K > 0 :
    print(answer)
    K = 0
elif K > B:
    K = K - B
if K <= C and K > 0:
    answer = answer - K
    print(answer)
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero((arr == mask) & (arr == 1),axis=1)

        sum = 0
        for _i in range(n):
            sum = sum + prr[_i][s[_i]]

        brr.append(sum)


    return brr

result = calculate(N, ARR, PRR)
print(max(result))



### FIXED CODE ###

n = int(input())

frr = []

for i in range(n):
    frr.append([int(s) for s in input().split(" ")])

prr = []

for i in range(n):
    prr.append([int(s) for s in input().split(" ")])

# n = 2
#
# frr = [
#     [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
#     [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
# ]
#
# prr = [
#     [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
#     [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]
# ]


res = []
for i in range(1,2 ** 10):
    count = [0 for s in range(n)]

    mask = []
    for j in range(10):
        m =  i >> j & 1
        mask.append(m)
        if m == 1:
            for k in range(n):
                if frr[k][j] == 1:
                    count[k] = count[k] + 1

    mm = []
    for index,c in enumerate(count):
        mm.append(prr[index][c])

    res.append(sum(mm))

print(max(res))
import math
a, b = map(int, input().split())

print((a*b)//math.gcd(a, b))

### FIXED CODE ###

from fractions import gcd
a, b = map(int, input().split())

lcm = a * b / gcd(a, b)
print(int(lcm))
import sys
input = sys.stdin.buffer.readline
n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
def lcm(x,y):
  return (x*y)//gcd(x,y)
l = 1
mod = 10**9+7
for i in range(n):
  l = lcm(l, a) % mod
ans = 0
for i in range(n):
  ans += l // a[i]
  ans %= mod
print(ans)


### FIXED CODE ###

if eval(input().replace(' ','==')):
  print('Yes')
else:
  print('No')
s = input()
t = input()

def z_algorithm(s):
    a = [0] * len(s)
    i = 1
    j = 0
    a[0] = len(s)
    while i < len(s):
        while i + j < len(s) and s[j] == s[i+j]:
            j += 1
        a[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < len(s) and k + a[k] < j:
            a[i+k] = a[k]
            k += 1
        i += k
        j -= k
    return a

def solve(i, li):
    ans = 0
    while True:
        if i < 0 or len(li) <= i or visited[i]:
            break
        if li[i] < len(t):
            visited[i] = True
            break
        if li[i] >= len(t):
            visited[i] = True
            ans += 1
            i += len(t)
    return ans

if len(s) == 1:
    aa = [0]
    print(a[1])
  
  
#sを伸ばす
new_s = s
while True:
    if len(new_s) > len(t):
        s = new_s
        break
    new_s += new_s

s = s*3
li = z_algorithm(t + s)[len(t):]
visited = [False] * len(li)
ans1 = 0
for i in range(len(li)):
    ans1 = max(ans1, solve(i, li))

s += s
li = z_algorithm(t + s)[len(t):]
visited = [False] * len(li)
ans2 = 0
for i in range(len(li)):
    ans2 = max(ans2, solve(i, li))

if ans1 == ans2:
    print(ans1)
else:
    print(-1)


### FIXED CODE ###

s = input()
t = input()

def z_algorithm(s):
    a = [0] * len(s)
    i = 1
    j = 0
    a[0] = len(s)
    while i < len(s):
        while i + j < len(s) and s[j] == s[i+j]:
            j += 1
        a[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < len(s) and k + a[k] < j:
            a[i+k] = a[k]
            k += 1
        i += k
        j -= k
    return a

def solve(i, li):
    ans = 0
    while True:
        if i < 0 or len(li) <= i or visited[i]:
            break
        if li[i] < len(t):
            visited[i] = True
            break
        if li[i] >= len(t):
            visited[i] = True
            ans += 1
            i += len(t)
    return ans

#sを伸ばす
new_s = s
while True:
    if len(new_s) > len(t):
        s = new_s
        break
    new_s += new_s

s = s*3
li = z_algorithm(t + s)[len(t):]
visited = [False] * len(li)
ans1 = 0
for i in range(len(li)):
    ans1 = max(ans1, solve(i, li))

s += s
li = z_algorithm(t + s)[len(t):]
visited = [False] * len(li)
ans2 = 0
for i in range(len(li)):
    ans2 = max(ans2, solve(i, li))

if ans1 == ans2:
    print(ans1)
else:
    print(-1)
import numpy as np
a = list(map(int,input().split()))

x = a[0]
n = a[1]
d = list(map(int,input().split()))

if (n == 0):
    print(x)
else:
    min_int = d[np.argmin(d)]
    max_int = d[np.argmax(d)]

    p = []
    for var in range(min_int,max_int):
        if var not in d:
            p.append(var)
        else:
            continue




    ans = []

    for pp in p:
        ans.append(np.abs(pp - x))
    ans = np.array(ans)
    print(p[np.argmin(ans)])


### FIXED CODE ###

import numpy as np
a = list(map(int,input().split()))

x = a[0]
n = a[1]

if (n == 0):
    print(x)
else:
    d = list(map(int,input().split()))
    min_int = d[np.argmin(d)]
    max_int = d[np.argmax(d)]
    if (x < min_int or max_int < x):
        print(x)
    else:
        p = []
        for var in range(min_int - 10,max_int + 10):
            if var not in d:
                p.append(var)
            else:
                continue
        ans = []
        for pp in p:
            ans.append(np.abs(pp - x))
        ans = np.array(ans)
        print(p[np.argmin(ans)])
n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

for i in v:
	res += dict[sum]
	sum += i
	dict[sum] -= 1

print res


### FIXED CODE ###

n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

if sum in dict:
	res += dict[sum]

sum += v[0]

for i in range(1, n):
	sum += v[i]
	dict[sum] -= 1
	res += dict[sum]

print res
N = int(input())
heights = map(int, input().split())


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))


### FIXED CODE ###

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


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools


def main():
  r = (99, 2, 5, 5, 4, 5, 6, 3, 7, 6)
  n, _ = list(map(int, input().split()))
  ps = list(map(int, input().split()))

  cs = [(p, r[p]) for p in ps]
  cs.sort(key=lambda x: x[1])
  a = []
  s, b = cs[0]

  while n - b > 0:
    a.append(s)
    n -= b

  cs.sort(key=lambda x:-x[0])
  cs = [(p, c - b) for p, c in cs if c != b]
  ds = None

  for i in range(1, len(cs) + 1):
    for ps in itertools.product(range(len(cs)), repeat=i):
      if sum(cs[p][1] for p in ps) == n:
        ds = [cs[p][0] for p in ps]
        break

    if ds is not None:
      break

  uds = [d for d in ds if d >= s]
  lds = [d for d in ds if d < s][::-1]

  # if len(uds) > 0:
  #  a = uds + a[len(uds):]
  # if len(lds) > 0:
  #  a = a[:-len(lds)] + lds

  print(''.join(str(v) for v in a), flush=True)


if __name__ == '__main__':
  main()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

COSTS = (99, 2, 5, 5, 4, 5, 6, 3, 7, 6)


def gen(base_digit, base_cost, base_length, digits, remain):
  number = [base_digit] * base_length
  remain -= base_cost * base_length

  if remain == 0:
    print(''.join(str(d) for d in number), flush=True)
    return True

  digits = [(d, c - base_cost) for d, c in digits if d != base_digit and c - base_cost <= remain]

  if len(digits) == 0:
    return False

  max_repeat = min(remain // min(digits, key=lambda x: x[1])[1], len(number))
  numbers = []

  for repeat in range(1, max_repeat + 1):
    for idxs in itertools.product(range(len(digits)), repeat=repeat):
      if sum(digits[i][1] for i in idxs) != remain:
        continue

      replaces = [digits[i][0] for i in idxs]
      uppers = [d for d in replaces if d > base_digit]
      lowers = [d for d in replaces if d < base_digit]

      num = number[:]

      if len(uppers) > 0:
        num = uppers + num[len(uppers):]

      if len(lowers) > 0:
        num = num[:-len(lowers)] + lowers

      numbers.append(num)

  if len(numbers) == 0:
    return False

  number = max(numbers)

  print(''.join(str(d) for d in number), flush=True)

  return True


def main():
  remain, _ = list(map(int, input().split()))

  digits = {}

  for d in map(int, input().split()):
    if COSTS[d] not in digits or digits[COSTS[d]] < d:
      digits[COSTS[d]] = d

  digits = [(d, c) for c, d in digits.items()]
  base_digit, base_cost = min(digits, key=lambda x: x[1])

  for length in range(remain // base_cost, -1, -1):
    if gen(base_digit, base_cost, length, digits, remain):
      break


if __name__ == '__main__':
  main()
n=input()
if n[0]=="0"ans=1/0
l=len(n)
k=int(input())
if l<6:
  n=int(n)
  ans=0
  for i in range(1,n+1):
    if len(str(i))-str(i).count("0")==k:ans+=1
  print(ans)
  exit()
if k==1:
  ans=((l-1)*9)+int(n[0])
  print(ans)
if k==2:
  ans=((l-1)*(l-2)//2)*81
  ans+=(int(n[0])-1)*((l-1)*9)
  ans+=int(n[1])
  ans+=(l-2)*9
  print(ans)
if k==3:
  ans=int(n[2])+(l-3)*9
  ans+=(int(n[1])-1)*((l-2)*9)
  ans+=((l-2)*(l-3)//2)*81
  ans+=(int(n[0])-1)*((l-1)*(l-2)//2)*81
  ans+=((l-1)*(l-2)*(l-3)//6)*9*9*9
  print(ans)

### FIXED CODE ###

n=input()
k=int(input())
dp=[[(k+1)*[0]for _ in range(2)]for _ in range(len(n))]
#dp[i][flag][j]...i文字目までみて0以外がj個あるパターン数
#flag...True(n[])
dp[0][0][0]=1
dp[0][1][1]=1
dp[0][0][1]=int(n[0])-1
for i in range(1,len(n)):
  for j in range(k+1):dp[i][1][j]=dp[i-1][1][j]
  if n[i]!="0":dp[i][1]=[0]+dp[i][1][:k]
  for j in range(k+1):dp[i][0][j]=dp[i-1][0][j]
  for j in range(k):
    dp[i][0][j+1]+=dp[i-1][0][j]*9
    if n[i]!="0":
      dp[i][0][j+1]+=dp[i-1][1][j]*(int(n[i])-1)
      dp[i][0][j+1]+=dp[i-1][1][j+1]
print(dp[-1][0][-1]+dp[-1][1][-1])
#for i in dp:print(*i)
n = int(input())
a_list = []
max_num = 0
sub_max = 0
all_max = False
if n == 2:
    a_list.append(int(input))
    print(a_list[1])
    print(a_list[0])
else:
    for i in range(n):
        a = int(input())
        a_list.append(a)
        if sub_max < a:
            if max_num < a:
                sub_max = max_num
                max_num = a
                idx = i
            else:
                sub_max = a
        elif max_num == a:
            max_num = a
            all_max = True
    if all_max:
        for i in range(n):
            print(max_num)
    else:
        for i in range(n):
            if i == idx:
                print(sub_max)
            else:
                print(max_num)


### FIXED CODE ###

n = int(input())
a = []
max_num = -1
for i in range(n):
    ipt = int(input())
    if ipt > max_num:
        max_num = max(ipt, max_num)
        idx = i
    a.append(ipt)
a = sorted(a)
if a[-1] == a[-2]:
    for i in range(n):
        print(max_num)
else:
    for i in range(n):
        if i == idx:
            print(a[-2])
        else:
            print(max_num)
n=int(input())
sum=1
f=0
f2=0
for i in range(1,n):
	a=(input())
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>10**18):
		sum=-1
                break
}
if f2==1: 
	print(0)
else:
	print(sum)

### FIXED CODE ###

N=int(input())
 
A=list(map(int,input().split()))
 
if 0 in A:
    print(0)
else:
    result=1
    for a in A:
        result=result*a
        if result>10**18:
            result=-1
            break
    print(result)
s=input()
k=int(input())
x=s[k-1]
y=x.lower()
print(s.replace(x,y))

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(*s,sep="")
X,K = int(input())

if K >== 500*X:
    print("yes")
else:
    print("No")

### FIXED CODE ###

K,X = map(int,input().split())

if X <= 500*K:
    print("Yes")
else:
    print("No")
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    if h_n >= 1:
        x.append(x_n)
        y.append(y_n)
        h.append(h_n)

def all_same(a):
    if all(a[i]==a[i+1] for i in range(0,len(a)-1)):
        return True
    else:
        return False

for C_x in range(101):
    for C_y in range(101):
        H=[]
        for i in range(len(x)):
            H.append(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y))
        H.sort()
        if all_same(H):
            print(C_x,C_y,H[0])


### FIXED CODE ###

N=int(input())
if N==1:
    print("Hello World")
if N==2:
    A=int(input())
    B=int(input())
    print(A+B)
from collections import deque
from bisect import *
from copy import deepcopy
n = int(input())
a = list(map(int, input().split()))

result = [-1 for _ in range(n)]
tree = [[] for _ in range(n)]
for _i in range(n-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    tree[u].append(v)
    tree[v].append(u)

dp = [float('inf') for _i in range(n)]
q = [[0, dp]]
q = deque(q)
while q:
    p, d = q.popleft()
    i = bisect_left(d, a[p])
    d[i] = a[p]
    result[p] = d.index(float('inf')-1)
    for i in tree[p]:
        if result[i] < 0:
            q.append([i, deepcopy(d)])

for i in result:
    print(i)

### FIXED CODE ###

from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
a = list(map(int, input().split()))

result = [-1 for _ in range(n)]
tree = [[] for _ in range(n)]
for _i in range(n-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    tree[u].append(v)
    tree[v].append(u)
INF = float('inf')
dp = [INF for _i in range(n+1)]


def dfs(p, x):
    i = bisect_left(dp, a[p])
    old = dp[i]
    dp[i] = a[p]
    result[p] = bisect_left(dp, INF)
    for j in tree[p]:
        if j != x:
            dfs(j, p)
    dp[i] = old
    

dfs(0, -1)

for i in result:
    print(i)
s = raw_input()
count = 0
a = 0
for j in range(len(s))
	if s[j] == 'R':
		count +=1
	else:
		count = 0
	a = max(count, a)
print 

### FIXED CODE ###

s = raw_input()
count = 0
a = 0
for j in range(len(s)):
	if s[j] == 'R':
		count +=1
	else:
		count = 0
	a = max(count, a)
print a
def fcd(a , b):
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return int(a*b/fcd(a , b))


n = int(input())
t_list = []
for i in range(n):
    t_list.append(int(input()))
    
    
for i in range(len(t_list)):
    if i == 0:
        continue
    elif i == 1:
        ans_list.append(lcm(t_list[0] , t_list[1]))
    
    else:
        ans_list.append(lcm(ans_list[i-2],t_list[i]))

### FIXED CODE ###

def fcd(a , b):
    
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return a*b//fcd(a , b)


n = int(input())
t_list = []
ans_list = []
for i in range(n):
    t_list.append(int(input()))
    
    
for i in range(len(t_list)):
    if i == 0:
        ans_list.append(t_list[0])
        continue
    if i == 1:
        ans_list.append(lcm(t_list[0] , t_list[1]))
    
    if i >=2:
        ans_list.append(lcm(ans_list[-1],t_list[i]))
print(ans_list[-1])
a, b = map(int, input().split())
pritn((a-1)*(b-1))

### FIXED CODE ###

a, b = map(int, input().split())
print((a-1)*(b-1))
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S_ = S()
    T = S()
    a = len(S_)
    b = len(T)
    cnt_list = []

    if a == b:
        cnt = 0
        for i in range(b):
            if S_[i] == T[i]:
                cnt += 1

    else:
        for i in range(a - b + 1):
            cnt = 0
            S_1 = S_[i:i + b]
            for i in range(b):
                if S_1[i] == T[i]:
                    cnt += 1
            cnt_list.append(cnt)

    ans = b - max(cnt_list)
    print(ans)



if __name__ == "__main__":
    main()




### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S_ = S()
    T = S()
    a = len(S_)
    b = len(T)
    cnt_list = []

    for i in range(a - b + 1):
        cnt = 0
        S_1 = S_[i:i + b]
        for j in range(b):
            if S_1[j] == T[j]:
                cnt += 1
        cnt_list.append(cnt)

    ans = b - max(cnt_list)
    print(ans)



if __name__ == "__main__":
    main()
num = a*b
if num % 2 == 0:
    print "Even"
else:
    print "Odd"

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')
N, Q = map(int, input().split())
S = input()
acc = []
for i in range(1, Q+2):
    acc.append(S[0:i].count("AC"))

for i in range(Q):
    l, r = map(int, input().split())
    print(acc[r] - acc[l-1])


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
acc = [0] * (N+1)
for i in range(0, N):
    acc[i+1] = acc[i] + (i+1 < N and S[i+1] == "C" and S[i] == "A")
for i in range(Q):
    l, r = map(int, input().split())
    print(acc[r-1] - acc[l-1])