Harryxun/stf_run huggingface dataset:
import sys
n, k = map(int, sys.stdin.readline().split())
S = sys.stdin.readline()

score = 0
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        score+=1
#print(S)
idx = []
for i in range(n):
    if S[i] == 'R':
        idx.append(i)
idx.append(-10)

s =-1
e =-1
ten = []
for i in range(len(idx)-1):
    if s ==-1:
        s = idx[i]
    if idx[i]+1 != idx[i+1]:
        e = idx[i]
        if e-s == n-1:
            pass
        elif s ==-1 or e==-1:
            pass
        elif s ==0 or e ==n-1:
            ten.append(1)
        else:
            ten.append(2)
        s =-1
ten = sorted(ten, reverse=True)
#print(score, ten)
print(score+ sum(ten[0:k]))

### FIXED CODE ###

import sys
import itertools
n = int(sys.stdin.readline())
L = [i for i in range(1,n+1)]
a = list(itertools.product(L, repeat=3))
print(len(a))
n = int(input())
A = [[0]*10 for i in range(12)] 

for _ in range(n):
    b, f, r, v = map(int, input().split())
    A[(b-1)*3 + (f-1)][r-1] = v
for i, v in enumerate(A, 1):
    print(' '.join([str(p) for p in v]))
    if i % 3 == 0 and i != n
        print('####################')


### FIXED CODE ###

n = int(input())
A = [[0]*10 for i in range(12)] 

for _ in range(n):
    b, f, r, v = map(int, input().split())
    A[(b-1)*3 + (f-1)][r-1] += v
for i, v in enumerate(A, 1):
    print(' ' + ' '.join([str(p) for p in v]))
    if i == 3 or i == 6 or i == 9:
        print('####################')
n = int(input(), 10)
a = list(map(int, input().split()))
greatCDlist = []

for i in range(n):
  pop = a.pop(i)
  greatCD = 1
  for j in range(n):
    if j == 0:
		greatCD = gcd(a[0], a[1])
    else:
      greatCD = gcd(greatCD, a[j])
  a.insert(i, pop)
  greatCDlist.append(greatCD)

maxg = 1
for i in range(n):
  if maxg > greatCDlist[i]:
    maxg = greatCDlist[i]

print(maxg)


def gcd(m, n):
  if m < n:
    m ^= n
    n ^= m
    m ^= n
  if n == 0:
    return m
  else:
    return gcd(n, n % m)

### FIXED CODE ###

n = int(input(), 10)
a = list(map(int, input().split()))
greatCDlist = []


def gcd(m, n):
    if m < n:
        m ^= n
        n ^= m
        m ^= n
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


left = [0 for i in range(n+1)]
right = [0 for i in range(n+1)]

for i in range(n):
    left[i+1] = gcd(left[i], a[i])


for i in range(n-1, -1, -1):
    right[i] = gcd(right[i+1], a[i])


result = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    result = max(result, gcd(l, r))

print(result)
a1 = int(input())
a2 = int(input())
a3 = int(input())


result = a1 + a2 + a3
if result >= 22:
    print("bust")
else:
    print("win")

### FIXED CODE ###


a = input().split()
# print(a)

result = int(a[0]) + int(a[1]) + int(a[2])
if result >= 22:
    print("bust")
else:
    print("win")
n=int(input())
array=list(map(int,input().split()))
list2=[]
for i in range(n):
  for j in range(i+1,n):
    list2.append(array[i]*array[j])
a=n*(n-1)
ans=0
for m in range(a):
  ans=ans+list2[m]
  if ans>10**9+7:
    ans=ans-10**9+7
print(ans//10**9+7)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=sum(a)*sum(a)
for i in range(n):
  ans-=a[i]*a[i]
ans//=2
mod=10**9+7
ans%=mod
print(ans)
a, b, c=map(int, input().split())
print(total(a,b,c)-max(a, b, c))

### FIXED CODE ###

a, b, c=map(int, input().split())
print((a + b+ c)-max(a, b, c))
N = int(input())

ans_1 = 0
for i in range(N):
  str_i = str(i)
  length = len(str_i)
  if str_i[0] == str_i[length-1]:
    ans_1 += 1

ans_2 = 0
half = N // 2
for i in range(half):
  if i <= 9:
    j = 0
    tmp_num =int(str(i)+str(j)+str(i))
    while tmp_num <= N:
      ans_2 += 1
      j += 1
      tmp_num =int(str(i)+str(j)+str(i))
   
  else:
    j = 0
    tmp_num =int(str(i[-1])+str(j)+str(i[0]))
    while tmp_num <= N:
      ans_2 += 1
      j += 1
      tmp_num =int(str(i[-1])+str(j)+str(i[0]))

print(ans_1+2*ans_2)
    
      


### FIXED CODE ###

N = int(input())

c = [[0 for i in range(10)] for j in range(10)]
for i in range(N+1):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += c[i][j]*c[j][i]

print(ans)
a, b = map(int, input())
print(a * b - (a + b -1))

### FIXED CODE ###

a, b = map(int, input().split())
print(a * b - (a + b -1))
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

# lcm = lambda x, y: (x * y) // math.gcd(x, y)
lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    T = [ii() for _ in range(N)]

    ret = lcm(T[0], T[1])
    for t in T:
        ret = lcm(ret, t)
    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

# lcm = lambda x, y: (x * y) // math.gcd(x, y)
lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    T = [ii() for _ in range(N)]

    ret = lcm(T[0], T[1]) if len(T) > 1 else T[0]
    for t in T:
        ret = lcm(ret, t)
    print(ret)


if __name__ == '__main__':
    main()
a = input().splitlines()

N = int(a[0])
S = a[1]

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

### FIXED CODE ###

a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)
# -*- coding: utf-8 -*-

N = int(input())

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

if 0 in A:
    print(0)
    exit(-1)

mul = A[0]
for i in A[1:]:
    mul *= i
    
    if mul > 1000000000000000000:
        print(-1)
        exit(-1)

if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

### FIXED CODE ###

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

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))

if 0 in A:
    print(0)
    exit(0)

mul = A[0]

if np.sum(A < 0) % 2 == 1:
    for i in A[1:]:
        mul *= i
else:
    for i in A[1:]:
        if 1000000000000000000 / i < mul:
            print(-1)
            exit(0)
        mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)
for i in list(range(1,10))
  for ii in list(range(1,10))
    print('%d x %d = %d' % (i, ii, i*ii))

### FIXED CODE ###

for x in range(1,10):
    for y in range(1,10):
        print("%dx%d=%d" % (x, y, x*y))
n=int(input())
kyori=sorted([list(map(int,input().split())) for i in range(n)])
ans=[0]*n

for i in range(n):
  C=kyori[i-1][0]
  if kyori[i-1][2]%2==0:
    ans[kyori[i-1][1]-1]=C
  else:
    ans[kyori[i-1][1]-1]=1-C
    
for i in range(n):
  print(ans[i])

### FIXED CODE ###

import copy ; import sys ; sys.setrecursionlimit(11451419)
n=int(input())
color=[-1 for i in range(n)]
color[0]=1
G=[[] for i in range(n)]
for i in range(n-1):
  a,b,d=map(int,input().split())
  G[a-1].append([b-1,d])
  G[b-1].append([a-1,d])
  
def dfs(x):
  
  for i,dis in G[x]:
    
    if color[i] != -1: continue
    if dis %2==1:
      color[i]=1-color[x]
    else:
      color[i]=color[x]
    dfs(i)
dfs(0)
for i in range(n):
  print(color[i])
import numpy as np

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

result = np.inf
for i in range(len(x) - k):
    tmp1 = np.abs(x[i+k-1] - x[i]) + np.abs(x[i])
    tmp2 = np.abs(x[i+k-1] - x[i]) + np.abs(x[i+k-1])
    result = np.min([tmp1, tmp2, result])

print(int(result))

### FIXED CODE ###

import numpy as np

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

result = np.inf
for i in range(len(x) - k +1):
    tmp1 = np.abs(x[i+k-1] - x[i]) + np.abs(x[i])
    tmp2 = np.abs(x[i+k-1] - x[i]) + np.abs(x[i+k-1])
    result = np.min([tmp1, tmp2, result])

print(int(result))
A, B, M = map(int, input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
value = min(a) + min(b)
for i in range(M):
    x,y,c = list(map(int, input().split()))
    if A[x-1] + B[y-1] - c < value:
        value = A[x-1] + B[y-1] - c

print(value)


### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
value = min(a) + min(b)
for i in range(M):
    x,y,c = list(map(int, input().split()))
    if a[x-1] + b[y-1] - c < value:
        value = a[x-1] + b[y-1] - c

print(value)
import numpy as np

N = int(input())
A = np.array(map(int, input().split()))
if len(A[A<0])%2 == 0:
    ans = sum(abs(A))
else:
    A = sorted(abs(A))
    ans = sum(A[1:])-A[0]
print(ans)



### FIXED CODE ###

n = int(input())
*a, = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))
import math

a, b = list(map(int, input().split()))

ans = int(a * b / math.gcd(a, b))

print(ans)


### FIXED CODE ###

def calc_gcd(a, b):
    r = a % b
    while (r != 0):
        a = b
        b = r
        r = a % b

    return b

a, b = list(map(int, input().split()))

if a < b:
    tmp = a
    a = b
    b = tmp

gcd = calc_gcd(a, b)
ans = int(a * b / gcd)

print(ans)
#E
import sys
input=sys.stdin.readline
mod=1000003
m=mod-1
def modinv(n):
    return pow(n,mod-2,mod)
Fact=[1] #階乗
for i in range(1,m+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(m+1) #階乗の逆元
Finv[-1]=modinv(Fact[-1])
for i in range(m-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod
def comb(n,r):
    if n<r:
        return 0
    return Fact[n]*Finv[r]*Finv[n-r]%mod
q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    f=Fact[n]
    r=((x*modinv(d))+n-1)%mod
    c=comb(r,n)
    p=pow(d,n,mod)
    print((f*c*p)%mod)

### FIXED CODE ###

import sys
input=sys.stdin.readline
mod=1000003
m=mod-1
def modinv(n):
    return pow(n,mod-2,mod)
Fact=[1]
for i in range(1,m+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(m+1)
Finv[-1]=modinv(Fact[-1])
for i in range(m-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod

def query(x,d,n):
    if x==0:
        return 0
    if d==0:
        return pow(x,n,mod)
    k=(x*modinv(d))%mod
    if k+n-1>=mod:
        return 0
    ans=Fact[k+n-1]*Finv[k-1]%mod
    ans*=pow(d,n,mod)
    ans%=mod
    return ans

q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    print(query(x,d,n))
s = input()
if s == "SUN":
    print 7
if s == "MON":
    print 6
if s == "TUE":
    print 5       
if s == "WED":
    print 4
if s == "THU":
    print 3        
if s == "FRI":
    print 2    
if s == "SAT":
    print 1   

### FIXED CODE ###

s = input()
if s == "SUN":
    print(7)
if s == "MON":
    print(6)
if s == "TUE":
    print(5)
if s == "WED":
    print(4)
if s == "THU":
    print(3)
if s == "FRI":
    print(2)
if s == "SAT":
    print(1)
def writeSC(s,i):
    if s in SC[i] :
        i = writeSC(s,i+1)
        # print(i,SC[i])
        return(i)
    else:
        SC[i].append(s)
        return(i)

n=int(input())

SC=[[] for i in range(n)] 

maxr=0
for i in range(n):
    s=input()
    res = writeSC(s,0)
    if maxr<res :
        maxr=res

SC[maxr].sort()
# print(maxr, SC[maxr])
for i in range(len(SC[maxr])):
    print(SC[maxr][i])

### FIXED CODE ###

n=int(input())

S={}
maxr=0
for i in range(n):
    s=input()
    if s in S:
        S[s]+=1
    else:
        S[s]=1

maxc = max(S.values())

ans=[]
for s in S:
    if S[s]==maxc :
        ans.append(s)

ans.sort()
for s in ans:
    print(s)
n,m=map(int,input().split())
L=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
A=[0]+[-1]*(n-1)
B=[[0,L[0]]]
def wfs(A,B):
    C=[]
    f=False
    for b in B:
        for l in b[1]:
            if A[l]==-1:
                A[l]=b[0]
                C.append([l,L[l]])
                f=True
    if f:
        return wfs(A,C)
    else:
        print('Yes')
        for a in A[1:]:
            print(a+1)
wfs(A,B)

### FIXED CODE ###

import sys
sys.setrecursionlimit(9**9)
n,m=map(int,input().split())
L=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
A=[0]+[-1]*(n-1)
B=[[0,L[0]]]
def wfs(A,B):
    C=[]
    f=False
    for b in B:
        for l in b[1]:
            if A[l]==-1:
                A[l]=b[0]
                C.append([l,L[l]])
                f=True
    if f:
        return wfs(A,C)
    else:
        print('Yes')
        for a in A[1:]:
            print(a+1)
wfs(A,B)
primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

while True:
    n = int(input())
    if n == 0:
        break
    for i in range(5, n+1)[::-1]:
        if primes[i-8] & primes[i-6] & primes[i-2] & primes[i]):
            print(i)
            break

### FIXED CODE ###

import bisect


primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

values = [i for i, v in enumerate(primes) if v]
while True:
    n = int(input())
    if n == 0:
        break
    index = bisect.bisect(values, n)
    for i in range(2, index)[::-1]:
        if all(primes[values[i]-j] for j in [0, 2, 6, 8]):
            print(values[i])
            break
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))

# n, m = (20, 4)
# a = [3, 7, 8, 4]

# n,m = (15, 3)
# a = [5, 4, 6]

a.sort()
table = {1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}

dp = ["" for i in range(n + 1)]
for x in a:
    dp[table[x]] = str(x)

def str_max(maxstrs):
    maxstrlen = max(map(lambda x:len(x), maxstrs))
    maxstr = max(filter(lambda x:len(x) == maxstrlen, maxstrs))
    return maxstr


for i in range(n + 1):
    for x in a:
        tmpstr = str(x)
        tmprest = i - table[x]
        if tmprest < 0:
            tmpstr = ""
        if 0 <= tmprest:
            # load dp
            tmp = dp[tmprest]
            if tmp == "":
                tmpstr = ""
            else:
                tmpstr = tmp + str(x)
        # print("{} {} : {} : {}".format(i, x, tmpstr, tmprest))
        # print(dp)
        dp[i] = str_max([dp[i], tmpstr])
        # print(dp)
    # print("")

print(dp[-1])


### FIXED CODE ###

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

# n,m = [2, 9]
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

a.sort()
table = {1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}

dp = ["" for i in range(max(n + 1, m+1))]
for x in a:
    dp[table[x]] = str(x)


def str_max(maxstrs):
    maxstrlen = max(map(lambda x:len(x), maxstrs))
    maxstr = max(filter(lambda x:len(x) == maxstrlen, maxstrs))
    return maxstr


for i in range(n + 1):
    for x in a:
        tmpstr = str(x)
        tmprest = i - table[x]
        if tmprest < 0:
            tmpstr = ""
        if 0 <= tmprest:
            # load dp
            tmp = dp[tmprest]
            if tmp == "":
                tmpstr = ""
            else:
                tmpstr = tmp + str(x)
        dp[i] = str_max([dp[i], tmpstr])

print(dp[n])
N,M = map(int,input().split())
PY = [[int(py) for py in input().split()] for _ in range(M)]

for i in range(1,M+1):
    PY[i-1].append(i)

PY.sort(key=lambda x:x[1])

count = [1 for _ in range(M)]

ans = []

for cell in PY:
    row = '{0:06d}'.format(cell[0]) + '{0:06d}'.format(count[cell[0]-1])
    ans.append([row,cell[2]])
    count[cell[0]-1] += 1


ans.sort(key=lambda x:x[1])

for row in ans:
    print(row[0])

### FIXED CODE ###

N,M = map(int,input().split())
PY = [[int(py) for py in input().split()] for _ in range(M)]

for i in range(1,M+1):
    PY[i-1].append(i)

PY.sort(key=lambda x:x[1])

count = [1 for _ in range(N)]

ans = []

for cell in PY:
    row = '{0:06d}'.format(cell[0]) + '{0:06d}'.format(count[cell[0]-1])
    ans.append([row,cell[2]])
    count[cell[0]-1] += 1


ans.sort(key=lambda x:x[1])

for row in ans:
    print(row[0])
a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a):
  if ar[i] < ar[i-1] and ar > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar > ar[i-1]:
    count += 1
print(count)

### FIXED CODE ###

a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a-1):
  if ar[i] < ar[i-1] and ar[i] > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar[i] > ar[i-1]:
    count += 1
print(count)
N,Q = map(int,input().split())
S = list(input())
count = 0
ans = []
for i in range(Q):
  r,l = map(int,input().split())
  S_parted = S[r-1:l]
  for k in range(len(S_parted)-1):
    if S_parted[k] == 'A' and S_parted[k+1] == 'C':
      count += 1
  ans.append(count)
  count = 0
for j in range(len(ans))
  print(ans[j])

    

### FIXED CODE ###

N,Q = map(int,input().split())
S = list(input())
R = [0]*N
ans = []
temp = 0
for i in range(1,N):
  if S[i-1] == 'A' and S[i] == 'C':
    temp += 1
  R[i] = temp
for k in range(Q):
  l,r = map(int,input().split())
  ans.append(R[r-1]-R[l-1])
for j in range(len(ans)):
  print(ans[j])
A=int(input())
B=int(input())
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')

### FIXED CODE ###

s1,s2,s3 = map(str, input().split())
print(s1.upper()[0]+s2.upper()[0]+s3.upper()[0])
a=input()
b=reverse(a);
if a==b:
 print('Yes')
else:
 print('No')

### FIXED CODE ###

a=input()
b=''.join(reversed(a))
if(a==b):
  print('Yes')
else:
  print('No')
A=list(map(int,input().split()))
if( sum(A) == 2*max(A) ) print("Yes")
else print( "No" )

### FIXED CODE ###

A=list(map(int,input().split()))
if( sum(A) == 2*max(A) ):
  print("Yes")
else:
  print( "No" )
n=int(input())
abc='abcdefghijklmnopqrstuvwxyz'
ans=''
for x in abc:
  z=100
  v=100
  for i in range(n):
    s=input()
    z=s.count(x)
    v=min(z,v)
  ans+=x*v   
print(ans)

### FIXED CODE ###

n=int(input())
#t=list(input())
#t.sort()
abc='abcdefghijklmnopqrstuvwxyz'
c=0
y=''
a=[0 for i in range(len(abc))]
'''
for i in range(len(abc)):
  a[i]=t.count(abc[i])
print(a,t)
'''
s=['' for i in range(n)]
for i in range(n):
  s[i]=input()

ans=''
for x in abc:
  z=100
  v=100
  for w in s:
    z=w.count(x)
    v=min(z,v)
  ans+=x*v
    
print(ans)
S=input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
 else:
  print("Good")

### FIXED CODE ###

s = input()
a = 13
c = 0
for i in s:
  if int(i) == a:
    c = 1
    break 
  a = int(i)
 
if c==1:
  print("Bad")
else:
  print("Good")
a,b=map(int,input().split())
c=xprint((a-1)*(b-1))

### FIXED CODE ###

a,b=map(int,input().split())
print((a-1)*(b-1))
import sys
read = sys.stdin.read
n, k = map(int, read().split())


def count(digit, k):
    elif k == 0:
        return 1
    elif k == 1:
        return digit
    elif k == 2:
        return digit * (digit - 1) // 2
    else:
        return digit * (digit - 1) * (digit - 2) // 6


def solve(n, k):
    if k == 0:
        return 1
    digit = len(str(n))
    res = 0
    if digit > k:
        res += count(digit - 1, k) * (9 ** k)
    pow10 = 10 ** (digit - 1)
    d, mod = n // pow10, n % pow10
    res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)
    res += solve(mod, k - 1)
    return res


print(solve(n, k))


### FIXED CODE ###

import sys
read = sys.stdin.read

n, k = map(int, read().split())


def count(d, k):
  if k == 0:
    return 1
  elif k == 1:
    return d
  elif k == 2:
    return d * (d - 1) // 2
  else:
    return d * (d - 1) * (d - 2) // 6


def solve(n, k):
  digit = len(str(n))
  if digit == 0 and k > 0:
    return 0
  if k == 0:
    return 1
  res = 0
  if digit > k:
    res += count(digit - 1, k) * (9 ** k)
  a = 10 ** (digit - 1)
  d, mod = n // a, n % a
  res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)
  res += solve(mod, k - 1)
  return res


print(solve(n, k))
h1,m1,h2,m2,k = int(input()).split()
print((h2-h1)*60+(m2-m1+k))

### FIXED CODE ###

h1,m1,h2,m2,k = input().split()
s = (int(h2)-int(h1))*60 +(int(m2)-int(m1)) -int(k)
print(s)
N = input()
x = N[-3]+N[-2]+N[-1]
print (1000 - int(x))


### FIXED CODE ###

N = input()
if int(N) < 1001:
    x = N
elif int(N[-3]+N[-2]+N[-1]) == 0:
    x = 1000
else:
    x = N[-3]+N[-2]+N[-1]
print (1000 - int(x))
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
d=sum(B)
for i in range(n-1):
  if A[i+1]-A[i]==1:
    d+=C[A[i]-1]
print(d)

### FIXED CODE ###

n=int(input())
print(n**3)
x,a = map(int,input.split())
if x < a:
    print("0")
else:
    print("10")

### FIXED CODE ###

x,a = map(int,input().split())
if x < a:
    print("0")
else:
    print("10")
N, M = map(int, input().split())
Digit = [0] * N
Count = 0
for i in range(M):
    s, c = map(int, input().split())
    if Digit[s - 1] == c or Digit[s - 1] == 0:
        Digit[s - 1] = c
        Count += 1
    else:
        print("-1")
        exit()
if Digit[0] == 0:
    if Digit[1] == 0:
        if Digit[2] == 0 and Count == 0:
            print("".join(map(str,Digit)))
            exit()
        else:
            print("-1")
            exit()
    else:
        print("-1")
        exit()
print("".join(map(str,Digit)))

### FIXED CODE ###

N, M = map(int, input().split())
st = 1 * 10 ** (N-1)
en = st * 10
SC = []
for i in range(M):
    sc = list(map(int,input().split()))
    SC.append(sc)
if N == 1:
    for i in range(0, 10):
        t = str(i)
        judge = True
        for j in range(M):
            if t[SC[j][0] - 1] != str(SC[j][1]):
                judge = False
        if judge:
            print(i)
            exit()
    print("-1")
    exit()
    
for i in range(st,en):
    t = str(i)
    judge = True
    for j in range(M):
        if t[SC[j][0]-1] != str(SC[j][1]):
            judge = False
    if judge:
        print(i)
        exit()
print("-1")
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for i in range(N):
        if params[i][2] != max(h - abs(params[k][0] - cxi) - abs(params[k][1] - cyi), 0)
            break
    
    else:
        print(cxi, cyi, hight)

### FIXED CODE ###

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi in range(101):
    for cyi in range(101):
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

        for k in range(N):
            if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0):
                break
        
        else:
            print(cxi, cyi, hight)