Harryxun/stf_run huggingface dataset:
#coding: UTF-8

x = raw_input().split()

y = map(int, x)

a = y[0]
b = y[1]

c = a*b
d = (a+b)*2

print(c,d)



### FIXED CODE ###

a,b = [int(x) for x in input().split()]

s = a*b

p = 2*a+2*b

print(s,p)
n, m = map(int, input().split())

ac = [0]*n
wa = [0]*n

for i in range(m):
    p, s = input().split()

    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1

print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i,j in enumerete(ac) if j != 0]])))

### FIXED CODE ###

N, M = map(int, input().split())
 
ac, wa = [0]*N, [0]*N
 
for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1
print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))
s=input()
t=input()
a=0
for i in range (0,2):
    if s[i]=t[i]
    a=a+1
print(a)

### FIXED CODE ###

s=input()
t=input()
a=0
for i in range (0,3):
    if s[i]==t[i]:
        a=a+1
print(a)
import fractions
from functools import reduce
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // factions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                s=int(n[j]/t)
                if n[j] % t == 0 and s % 2 == 1:
                        n[j] = s
 
                else: return 0
        return int(t//2)
 
def mp(v):
        if v%2==1:v+=1
        return int(v//2)
 
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
n=sorted(set(n),reverse = True)
bs = n[0]//2
 
if len(n) > 1:
        c = chk(n[-1])
        if  c != 0:
                v = lcm_o()*c
                if v > M: print(0) 
 
                else: print(mp(M//v))
        
        else: print(0)
        
elif len(n)==1: 
        v = M//bs
        if v%2==1:
            v+=1
        print(int(v//2))

### FIXED CODE ###

import fractions
from functools import reduce
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
#print(n)
n=sorted(set(n),reverse = True)
bs = n[0]
#print(n)
#c=len(n)
 
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                if n[j] % t == 0 and (n[j] / t) % 2 == 1:
                        n[j] = int(n[j]/t)
                else: return 0
        return i-1
 
if len(n) > 1:
        
        c = chk(n[-1])
        
        if  c != 0:
                v = lcm_o()*(2**(c-1))
                
                if v > M:
                        print(0) 
                else:
                        v = M//v
                        if v%2==1: v+=1
                        print(int(v//2))
        
        else: print(0)
elif len(n)==1:
        v = int(bs*0.5)
        v = M//v
        if v%2==1: v+=1
        print(int(v//2))
a = int(input())
b = int(input())
h = int(input())
k = (a + b)* h /2
print(round(k)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
k = (a + b)* h /2
print(round(k))
import sys
s = sys.stdin.readlines()
N,M,Q = map(int,s[0].split())

Section = [[0]*N for _ in range(N)]
for L,R in (map(int, e.split()) for e in s[1:M+1):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for p,q in (map(int, e.split()) for e in s[M+1:]
    print(Ans[p-1][q-1])

### FIXED CODE ###

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

Section = [[0]*N for _ in range(N)]
for _ in range(M):
    L,R = map(int,input().split())
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for _ in range(Q):
    p,q = map(int,input().split())
    print(Ans[p-1][q-1])
A=input()
A=int(A)
B=input()
B=int(B)
C=input()
C=int(C)

if A+B >= C:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

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

           
if nums[0]+nums[1] >= nums[2]:
    print('Yes')
else:
    print('No')
a=int(input())
b=int(input())
if a==b:
  print(1)
  exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
  while abin[0]==bbin[0]:
    abin=abin[1:]
    bbin=bbin[1:]
  while abin[0]=="0":
    abin=abin[1:]
cbin=bbin[1:]
while cbin[0]=="0":
  cbin=cbin[1:]
c=2**(len(cbin))
a=int(abin,2)
lbnd=2**(lb-1)+c
hbnd=2**(lb-1)+a
if lbnd>=hbnd:
  print(2**(lb-1)-a)
else:
  print(2**(lb-1)-a+lbnd-a)

### FIXED CODE ###

a=int(input())
b=int(input())
if a==b:
  print(1)
  exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
  while abin[0]==bbin[0]:
    abin=abin[1:]
    bbin=bbin[1:]
  while len(abin)>1 and abin[0]=="0":
    abin=abin[1:]
cbin=bbin[1:]
while cbin and cbin[0]=="0":
  cbin=cbin[1:]
c=2**(len(cbin))-1
a=int(abin,2)
b=int(bbin,2)
lb=len(bbin)
lbnd=2**(lb-1)+c
hbnd=2**(lb-1)+a
if lbnd>=hbnd:
  print(2**lb-a)
else:
  print(2**(lb-1)-a+lbnd-a+1)
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev


def main():
	N, K = map(int, input().split(" "))
	A = input().split(" ")
	A = [int(s) for s in A]
	
	DP = [100000000000000000000000000000000 for _ in range(N)]
	DP[0] = 0
	
	for i, val in enumerate(A):
		if i == 0:
			continue
		tmp = 100000000000000000000000000000000
		
		for j in range(K):
			index = j+1
			if i >= index:
				tmp1 = DP[i-index] + abs(A[i-index] - val)
				tmp = min(tmp, tmp1)
			else:
				break
		DP[i] = min(DP[i], tmp)
		
	#print(DP)
	print(DP[N-1])
	
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	N, K = map(int, input().split(" "))
	H = input().split(" ")
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i in range(1, len(H)):
		paths = [DP[j] + abs(H[j] - H[i]) for j in range(max(0, i-K), i)]
		DP[i] = min(paths)
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
import collections
N = int(input())
A=sorted(list(map(int, input().split())))
a = collections.Counter(A)
ans = 0
y = 0
for i in a.keys():
    if a[i] >= 2:
        x = y*i
        y = i
    if a[i] >= 4:
        z = i**2
    ans = max(ans, x, z)
print(ans)

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
a = collections.Counter(A)
ans = [0, 0]
for i in a.keys():
    if a[i] >= 2:
        ans.append(i)
    if a[i] >= 4:
        ans.append(i)
ans.sort()
print(ans[-1]*ans[-2])
n=int(input())
l=list(map(int,input().split()))

ans=[]
for i in range(n):
  left=sum(l[:i+1])
  right=sum(l[i+1:])
  ans+=abs(left-right)
  
print(min(ans))

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))

ans=[]
left=0
right=0

for i in range(n):
  left=sum(l[:i+1])
  right=sum(l[i+1:])
  ans.append(abs(left-right))
  
print(min(ans))
N = int(input())
K = eval("*".join(map(str,[*range(1, N+1)])))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)

print(ans % (10**9 + 7))

### FIXED CODE ###

N = int(input())
K = eval("*".join(map(str, list(range(1, N+1)))))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)
print(ans % (10**9 + 7))
n = int(input())
L = list(map(int, input().split()))
L.sort().reverse()
if L[0] < sum(L[1:n]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
L = list(map(int, input().split()))
L.sort()
L.reverse()
if L[0] < sum(L[1:n]):
  print("Yes")
else:
  print("No")
n = int(input())
l = list(map(int, input().split()))
def memo(n) :
    me = [0]*(n+1)
    global l
    def f(n) :
        if n == 0 :
            return 0
        elif n == 1 :
            return abs(l[0] - l[1])
        else :
            if me[n] != 0 :
                return me[n]
            else :
                me[n] = min([f(n - 2) + abs(l[n - 2] - l[n]),f(n - 1) + abs(l[n - 1] - l[n])])
                return me[n]
    return f(n)
print(memo(n - 1))


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
def memo(n) :
    me = [0]*(n)
    global l
    me[0] = 0
    me[1] = abs(l[0] - l[1])
    def f(n) :
        for i in range(2, n) :
            me[i] = min([me[i - 2] + abs(l[i - 2] - l[i]),me[i - 1] + abs(l[i - 1] - l[i])])
        return me[n-1]
    return f(n)
print(memo(n))
a, b = map(int, input().split())

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

### FIXED CODE ###

a,b=map(int,input().split())
print("Even" if a*b%2==0 else "Odd")
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
cur = sum(p[:X]) + sum(q[:Y])

eat = p[:X] + q[:Y]
eat.sort()
for i in range(C):
    if r[i] > eat[i]:
        eat[i] = r[i]

ans = sum(eat)
print(ans)




### FIXED CODE ###

X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
cur = sum(p[:X]) + sum(q[:Y])

eat = p[:X] + q[:Y]
eat.sort()
for i in range(min(C,X+Y)):
    if r[i] > eat[i]:
        eat[i] = r[i]

ans = sum(eat)
print(ans)
Wethers={"Sunny":0,"Cloudy":1,"Rainy":2}
Wether=["Sunny","Cloudy","Rainy"]
S=input()[:-1]
S_id = Wethers[S]
print((S_id+1)%3)



### FIXED CODE ###

Wethers={"Sunny":0,"Cloudy":1,"Rainy":2}
Wether=["Sunny","Cloudy","Rainy"]
S=input()
S_id = Wethers[S]
print(Wether[(S_id+1)%3])
answers = []
while True:
    head = input()
    if head == "0 0 0":
        break
    nums = head.split(" ")
    num = int(nums[0])
    mini = int(nums[1])
    maxi = int(nums[2]) 

    scores = []

    gaps = []

    for _ in range(int(head[0])):
        scores.append(int(input()))
    
    for i in range(mini, maxi + 1):
        oks = scores[:i]
        ngs = scores[i:]
        gap = oks[-1] - ngs[0]
        gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(map(lambda x: x[1], gaps)), gaps))
    sorted(filtered,key=lambda x: x[0])
    answers.append(filtered[-1][0])

for i in answers:
    print(i)


### FIXED CODE ###

while True:
    num, mini, maxi = map(int, input().split())
    if num == 0: break
    scores = [ int(input()) for i in range(num) ]
    gap = 0
    ans = 0
    for i in range(mini, maxi + 1):
        gap = scores[i-1] - scores[i] if scores[i-1] - scores[i] >= gap else gap
        ans = i if scores[i - 1] - scores[i] >= gap else ans

    print(ans)
x, t = list(map(input().split()))
print(max([0, x - t])

### FIXED CODE ###

x, t = list(map(int, input().split()))
print(max([0, x - t]))
while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
　　　except:
      break


### FIXED CODE ###

while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
    except:
        break
from collections import Counter
n=int(input())
s=input()
B=True
if s=='.'*n:
    B=False
if B:
    num=list(s).index('#')
    if num!=n-1:
        for i in range(num,n-1):
            if s[i]=='.' and s[i+1]=='#':
                A=True
                l=n-i-1
        moji=s[num:]
        lst=dict(Counter(moji).items())
        a=lst['#'];b=lst['.']
        if a==0 or b==0:
            print(0)
        else:
            if s[-1]=='#':
                print(min(a-l,b))
            else:
                print(min(a,b))
    else:
        print(0)
else:
    print(0)


### FIXED CODE ###

n=int(input())
s=input()
bres=0
wres=0
blst=[]
wlst=[]
for i in range(n):
    if s[i]=='#':
        bres+=1
    blst.append(bres)
for i in range(n-1,-1,-1):
    if s[i]=='.':
        wres+=1
    wlst.append(wres)
wlst=wlst[::-1]
ans=10**9
blst.insert(0,0)
wlst.insert(n,0)
for i in range(n+1):
    ans=min(blst[i]+wlst[i],ans)
print(ans)
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = []
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h)&1:
                count[j] += 1
        a += rieki[j][count[j]]
    ans.append(a)
    
print("{}".format(max(ans)))

### FIXED CODE ###

N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))
input();a=list(map(int,input().split()))[::-1];print(a[0],sorted(a,key=lambda x:abs(a[0]-2*x))[0])

### FIXED CODE ###

a,b,x=map(int,input().split())
print("YES"if a+b>=x>=a else"NO")
# 100以下の素数を求める
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
pi_100 = len(primes)

mod = 10**9+7

prime_vector = [0]*pi_100

N = int(input())
for n in range(2,N+1):
    ret = (get_div_num(n)*ret)%mod
    # calc prime
    for i in range(pi_100):
        while n % primes[i] == 0:
            prime_vector[i] += 1
            n = n//primes[i]

ret = 1

# print(prime_vector)
for i in range(pi_100):
    ret = (ret * (prime_vector[i]+1)) % mod

print(ret)

### FIXED CODE ###

# 100以下の素数を求める
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
pi_100 = len(primes)

mod = 10**9+7

prime_vector = [0]*pi_100

N = int(input())
for n in range(2,N+1):
    # calc prime
    for i in range(pi_100):
        while n % primes[i] == 0:
            prime_vector[i] += 1
            n = n//primes[i]

ret = 1

# print(prime_vector)
for i in range(pi_100):
    ret = (ret * (prime_vector[i]+1)) % mod

print(ret)
import numpy

print("A = ")
A = input()

print("B = ")
B = input()

C = int(A) - int(B) * 2

if C < 0:
    print(0)
elif C > 100:
    print(100)
else:
    print(C)

### FIXED CODE ###

A,B = input().split()

C = int(A) - int(B) * 2

if C < 1:
    print(0)
elif C > 100:
    print(100)
else:
    print(C)
n, q = map(int,input().split())
cnt = [0] * (n+1)
import sys
sys.setrecursionlimit(10**6)
import numpy as np
tree = np.zeros((n+1, n+1))
child = [0] * (n+1)
for i in range(n-1):
    a, b = map(int,input().split())
    tree[a][b] = 1
    tree[b][a] = 1
def dfs(i):
    global child
    child[i] = []
    if np.all(tree[i] == 0):
        return
    for j in range(n+1):
        if tree[i][j] == 1:
            tree[j][i] = 0
            child[i].append(j)
            dfs(j)
    return

dfs(1)
#print(child)
for _ in range(q):
    p,x = map(int,input().split())
    cnt[p] += x
def plus(c):
    global cnt
    if child[c] == []:
        return
    for target in child[c]:
        cnt[target] += cnt[c]
        plus(target)
    return
plus(1)
print(*cnt[1:])

### FIXED CODE ###

n, q = map(int,input().split())
cnt = [0] * (n+1)
tree = [[] for _ in range(n+1)]
seen = [0] * (n+1)
todo = [1]
for i in range(n-1):
    a, b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
for _ in range(q):
    p,x = map(int,input().split())
    cnt[p] += x

while todo != []:
    i = todo.pop()
    seen[i] = 1
    for j in tree[i]:
        if seen[j] == 0:
            todo.append(j)
            cnt[j] += cnt[i]
print(*cnt[1:])
from math import gcd

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

g = 0
for i in a:
    g = gcd(g,i)
print(g)


### FIXED CODE ###

from fractions import gcd

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

g = 0
for i in a:
    g = gcd(g,i)
print(g)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

mod = 998244353
class Combination:
    """
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=998244353):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

n,m,k = inpl()
conb = Combination(100010)
res = 0
for i in range(k+1):
    x = n - i - 1
    res += conb(n-1,x) * n * pow(n-1,x)
    res %= mod
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

mod = 998244353
class Combination:
    """
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=998244353):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

n,m,k = inpl()
conb = Combination(300010)
res = 0
for i in range(k+1):
    x = n - i - 1
    res += conb(n-1,x) * m * pow(m-1,x,mod)
    res %= mod
print(res)
n=int(input())
l=list(map(int,input().split(" ")))
c=0
for i in range(n):
  for j in range(i+1,n):
    if l[i]+l[j]=j-i:
      c+=1
      
print(c)

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N = int(input())

A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()

ans = 0
for i in range(N):
	ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])

print(ans)
S=list(input())
ans=0

for i in range(len(S)):
    if ans=0 and S[i]="R":
        ans=1
for i in range(len(S)-1):
    if S[i]=="R" and S[i+1]=="R":
        ans+=1

print(ans)



### FIXED CODE ###

S=list(input())
ans=0

for i in range(len(S)):
    if ans==0 and S[i]=="R":
        ans=1
for i in range(len(S)-1):
    if S[i]=="R" and S[i+1]=="R":
        ans+=1

print(ans)
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    dp =[0]*(h+max(ab[0:n][0]))
    for i in range(1, h+1):
        dp[i] = min(dp[i-a]+b for a,b in ab)
    print(dp[h])
      
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    dp =[0]*(h+max(a for a,b in ab))
    for i in range(1, h+1):
        dp[i] = min(dp[i-a]+b for a,b in ab)
    print(dp[h])
      
if __name__ == '__main__':
    main()
while True:
    n, m = map(int, input().split())
    ls = []
    if n == 0: break
    for i in range(n):
        d, p = map(int, input().split())
        ls.append([d,p])
    ls.sort(key=lambda x:x[1], reverse=True)
    j = 0
    for i in range(m):
        ls[j][0] -= 1
        if ls[j][0] == 0:
            j += 1
    print(sum(x[0] * x[1] for x in ls))

### FIXED CODE ###

while True:
    n, m = map(int, input().split())
    ex = [0] * 11
    if n == 0: break
    for i in range(n):
        d, p = map(int, input().split())
        ex[p] += d
    ex.reverse()
    for i in range(len(ex)):
        m -= ex[i]
        if m <= 0:
            ex[i] = abs(m)
            break
        else:
            ex[i] = 0
    ex.reverse()
    ans = 0
    for i in range(len(ex)):
        ans += ex[i] * i
    print(ans)
from fractions import gcd
from math import gcd

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

total=0
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-1], A[N-1-i])

for i in range(N):
    total=max(total,gcd(left[i],right[i+1]))

print(total)

### FIXED CODE ###

from fractions import gcd


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

total=0
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-1-i])

for i in range(N):
    total=max(total,gcd(left[i],right[i+1]))

print(total)