Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

r,g,b,n=map(int,input().split())
ans=0
for i in range(n//b+1):
    bi=b*i
    for j in range(n//g+1):
        gj=g*j
        if gj+bi>n:
            break
        elif gj+bi==n:
            ans=ans+1
            break
        elif (n-(gj+bi))%r==0:
            ans=ans+1
print(ans)

### FIXED CODE ###

r,g,b,n=map(int,input().split())
ans=0
for i in range(n//b+1):
    bi=b*i
    for j in range(n//g+1):
        gj=g*j
        if gj+bi>n:
            break
        elif gj+bi==n:
            ans=ans+1
            break
        elif (n-(gj+bi))%r==0:
            ans=ans+1
print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] + L[j] > L[k]:
                ans += 1
            else:
                break

print(ans)


### FIXED CODE ###

import sys
from bisect import bisect_left
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        search = L[i] + L[j]
        k = bisect_left(L, search)
        ans += k - j - 1
print(ans)
### BUGGY CODE ###

import numpy as np
n = int(input())
s = list(input())
cr = [0] * n
cg = [0] * n
cb = [0] * n
for i in range(n):
    if i == 0:
        if s[i] == 'R':
            cr[i] += 1
        elif s[i] == 'G':
            cg[i] += 1
        else:
            cb[i] += 1
    else:
        cr[i] = cr[i-1]
        cg[i] = cg[i-1]
        cb[i] = cb[i-1]
        if s[i] == 'R':
            cr[i] += 1
        elif s[i] == 'G':
            cg[i] += 1
        else:
            cb[i] += 1
# cr = np.cumsum(r)
# cg = np.cumsum(g)
# cb = np.cumsum(b)
ans = 0
for i in range(n-2):
    a = s[i]
    for j in range(i+1, n-1):
        b = s[j]
        if a == b:
            continue
        diff = j - i
        c = {'R', 'G', 'B'} - {a, b}
        c = list(c)[0]
        if c == 'R':
            ans += cr[-1] - cr[j]
        elif c == 'G':
            ans += cg[-1] - cg[j]
        else:
            ans += cb[-1] - cb[j]
        if j + diff < n:
            if s[j + diff] == c:
                ans -= 1
print(ans)

### FIXED CODE ###


n = int(input())
s = list(input())
cr = [0] * n
cg = [0] * n
cb = [0] * n
for i in range(n):
    if i == 0:
        if s[i] == 'R':
            cr[i] += 1
        elif s[i] == 'G':
            cg[i] += 1
        else:
            cb[i] += 1
    else:
        cr[i] = cr[i-1]
        cg[i] = cg[i-1]
        cb[i] = cb[i-1]
        if s[i] == 'R':
            cr[i] += 1
        elif s[i] == 'G':
            cg[i] += 1
        else:
            cb[i] += 1
ans = 0
for i in range(n-2):
    a = s[i]
    for j in range(i+1, n-1):
        b = s[j]
        if a == b:
            continue
        diff = j - i
        c = list({'R', 'G', 'B'} - {a, b})[0]
        if c == 'R':
            ans += cr[-1] - cr[j]
        elif c == 'G':
            ans += cg[-1] - cg[j]
        else:
            ans += cb[-1] - cb[j]
        if j + diff < n:
            if s[j + diff] == c:
                ans -= 1
print(ans)
### BUGGY CODE ###

from collections import Counter

N, P = map(int, input().split())
S = input()

sum = 0
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            sum += i+1
    print(sum)
    exit()

m = []
for i in range(N):
    m.append(int(S[i:]) % P)
    
mc = Counter(m)

for v in mc.values():
    if v > 1:
        sum += v*(v-1)//2

sum += mc[0]

print(sum)

### FIXED CODE ###

from collections import Counter

N, P = map(int, input().split())
S = input()

sum = 0
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            sum += i+1
    print(sum)
    exit()

m = []
t = 1
q = 0
for i in range(N,0,-1):
    q = ((int(S[i-1]) % P) * t + q) % P
    m.append(q)
    t = (10 * t) % P
    
mc = Counter(m)

for v in mc.values():
    if v > 1:
        sum += v*(v-1)//2

sum += mc[0]

print(sum)
### BUGGY CODE ###

def canMakeNumber(k, s):
    k = str(k).zfill(3)
    dic = {0: False, 1: False, 2: False}
    rep = False
    for t in s:
        if dic[0] is False:
            if t == k[0]:
                dic[0] = True
        else:
            if dic[1] is False:
                if t == k[1]:
                    dic[1] = True
            else:
                if dic[2] is False:
                    if t == k[2]:
                        dic[2] = True
                else:
                    continue
    if dic[0] == dic[1] == dic[2] == True:
        rep = True
    return rep


N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
    if canMakeNumber(i, str(S)):
        ans += 1
print(ans)


### FIXED CODE ###

def canMakeNumber(k, s):
    k = str(k).zfill(3)
    dic = {0: False, 1: False, 2: False}
    rep = False
    for t in s:
        if dic[0] is False:
            if t == k[0]:
                dic[0] = True
        else:
            if dic[1] is False:
                if t == k[1]:
                    dic[1] = True
            else:
                if dic[2] is False:
                    if t == k[2]:
                        dic[2] = True
                else:
                    continue
    if dic[0] == dic[1] == dic[2] == True:
        rep = True
    return rep


N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
    if canMakeNumber(i, str(S)):
        ans += 1
print(ans)
### BUGGY CODE ###

a=int(input())
b=[int(input()) for i in range(a)]
b.sort()
ans=0
while ans==0:
	for i in range(a):
		if b[i]%10!=0 and sum(b)%10==0:
			ans=sum(b)-b[i]
			break
print(ans)

### FIXED CODE ###

a=int(input())
b=[int(input()) for i in range(a)]
b.sort()
ans=sum(b)
d=0
for i in range(a):
	if b[i]%10!=0 and sum(b)%10==0 :
		ans=sum(b)-b[i]
		d=1
		break
if d==1 or ans%10!=0:
	print(ans)
else:
	print(0)
### BUGGY CODE ###

import sys
import itertools as it

N = int(input()) 

def prime_judge(N):
    if N == 2 or N == 3:
        return True
    if N % 2 == 0 or N % 3 ==0:
        return False
    for i in range(4,N):
        if N % i == 0:
            return False
            break
    return True

a = []
n = 0
p = 2

while True:
    if prime_judge(p):
        if len(a) >= N:
            a_c = list(it.combinations(a, N-1))
            for a_p in a_c:
                a_p = list(a_p)
                a_p.append(p)
                a_p5 = list(it.combinations(a_p, 5))
                t_sum = 0
                for a_p5i in a_p5:
                    if not(prime_judge(sum(a_p5i))):
                        t_sum += 1
                if t_sum == len(a_p5):
                    a_p = list(a_p)
                    a2 = [str(i) for i in a_p]
                    print(" ".join(a2))
                    sys.exit()
        a.append(p)
    p += 1

### FIXED CODE ###

import sys

N = int(input()) 

def prime_judge(N):
    if N % 2 == 0 or N % 3 ==0:
        return False
    for i in range(4,N):
        if N % i == 0:
            return False
            break
    if N % 5 == 1 :
        return True
    else: False

a = []
n = 0
p = 2

while True:
    if prime_judge(p):
        if len(a) == N:
            a2 = [str(i) for i in a]
            print(" ".join(a2))
            sys.exit()
        a.append(p)
    p += 1
### BUGGY CODE ###

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

C=0

for i in range(N):
	for n in range(N):
	  if A[i]==A[n]:
	  	C=C+1
	  else:
	  	C=C+0

if C==N:
	print('YES')
else:
	print('NO')


### FIXED CODE ###

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

C=0

A.sort()

for i in range(N-1):
    if A[i] == A[i+1]:
        C = C+1
    else:
        C = C

if C == 0:
	print('YES')
else:
	print('NO')
### BUGGY CODE ###

S = input()
Q = int(input())
reverse = 0
head = []
tail = []
for i in range(Q):
    s = input().split()
    if int(s[0]) == 1:
        reverse = (reverse + 1) % 2
    else:
        if int(s[1]) == 1:
            if reverse == 1:
                tail.append(s[2])
            else:
                head.insert(0, s[2])
        else:
            if reverse == 1:
                head.insert(0, s[2])
            else:
                tail.append(s[2])
head = ''.join(head)
tail = ''.join(tail)
S = head + S + tail
if reverse == 1:
    print(S[::-1])
else:
    print(S)

### FIXED CODE ###

def main():
    from sys import stdin
    from collections import deque
    S = input()
    Q = int(input())
    reverse = 0
    head = []
    tail = []
    head_deque = deque(head)
    tail_deque = deque(tail)
    
    for _ in [0] * Q:
        readline = stdin.readline
        s = readline().split()
        if int(s[0]) == 1:
            if reverse == 1:
                reverse = 0
            else:
                reverse = 1
        else:
            if int(s[1]) == 1:
                if reverse == 1:
                    tail.append(s[2])
                else:
                    head_deque.appendleft(s[2])
            else:
                if reverse == 1:
                    head_deque.appendleft(s[2])
                else:
                    tail.append(s[2])
    head = list(head_deque)
    head = ''.join(head)
    tail = ''.join(tail)
    if reverse == 1:
        print(tail[::-1]+S[::-1]+head[::-1])
    else:
        print(head+S+tail)
        
main()
### BUGGY CODE ###

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

count = 0

for j in range(N):
    target = P_list[j]
    if min(P_list[:j+1]) >= target:
        count += 1

print(count)

### FIXED CODE ###

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

count = 1
temp = P_list[0]

for j in range(1, N):
    if P_list[j] == min(P_list[j], temp):
        count += 1
        temp = P_list[j]

print(count)
### BUGGY CODE ###

S = input()
N = len(S)

Data = list(S)
Data = list(map(int,Data))

delnum = 1

while delnum != 0:
    i = 0
    delnum = 0
    while i < N:
        while i < N and Data[i] == -1:
            i += 1
        if i >= N:
            break

        c = Data[i]
        #
        c1_pos = i
        j = i + 1
        c1_count = 1 
        while j < N and (Data[j] == c or Data[j]==-1):
            if Data[j] == c:
                c1_count += 1
            j += 1
        #
        c2_pos = j
        c2_count = 0
        k = j
        while k < N and (Data[j] == (1-c) or Data[j] == -1):
            if Data[k] == 1-c:
                c2_count += 1
            k += 1

        i = k

        delnum = min(c1_count,c2_count)
        d = 0
        ii = 0

        while d < delnum:
            if Data[c1_pos+ii] == c:
                Data[c1_pos+ii]= -1
                d += 1
            ii += 1
        d = 0
        ii = 0
        while d < delnum:
            if Data[c2_pos+ii] == 1-c:
                Data[c2_pos+ii] = -1
                d += 1
            ii += 1
        
ans = 0
for n in Data:
    if n == -1:
        ans += 1
print(ans)


### FIXED CODE ###

S = input()
n0 = S.count('0')
n1 = S.count('1')
print(len(S)-abs(n0-n1))
### BUGGY CODE ###

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

cnt = 1
for i in range(a,b+1):
    if cnt <= k:
        print(i)
    elif cnt > b-a+1 - k:
        print(i)
    cnt += 1



### FIXED CODE ###

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

cnt = 1
for i in range(a,b+1):
    if cnt <= k:
        print(i)
    elif cnt > b-a+1 - k:
        print(i)
    cnt += 1
### BUGGY CODE ###

from itertools import permutations
import sys

N, M, R = map(int, sys.stdin.readline().split())
r = [i - 1 for i in map(int, sys.stdin.readline().split())]

d = [[float('inf')] * N for _ in range(N)]

for i in range(N):
    d[i][i] = 0
    
for i in range(M):
    a, b, c = map(int,sys.stdin.readline().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

ans = 10**12

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        t_dis += d[each[i]][each[i+1]]  
    
    ans = min(ans, t_dis)

print(ans)

### FIXED CODE ###

from collections import defaultdict
from itertools import permutations
import heapq

INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
memo = [[INF for _ in range(N)] for _ in range(N)]

Adj_list = defaultdict(set)

for i in range(M):
    a, b, c = map(int, input().split())
    if memo[a-1][b-1]:
        memo[a-1][b-1] = min(memo[a-1][b-1], c)
        
    Adj_list[a-1].add((b-1, memo[a-1][b-1]))
    Adj_list[b-1].add((a-1, memo[a-1][b-1]))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF
t_dis = 0

table = {}
for i in r:
    table[i-1] = dijkstra(N, i-1)

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        t_dis += table[each[i]-1][each[i+1]-1]
    #print(each, t_dis)
    ans = min(ans, t_dis)

print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
L = []
Ans = 0
for i in range(N):
  s = S[i]
  a = 0
  b = 0
  for j in range(i+1,N):
    t = S[j]
    if s != t:
      K = ["R","G","B"]
      K.remove(s)
      if t == K[0]:
        a +=1
      else:
        b +=1
  Ans += a*b

for i in range(N):
  for j in range(i+1,N):
    s = S[i]
    t = S[j]
    k = 2*j-i
    if j < k <= N-1:
      if s != t and t != S[k] and S[k] != s:
        Ans -=1
print(Ans)

### FIXED CODE ###

N = int(input())
S = input()

L = [0,0,0]
for i in range(N):
    if S[i] == "R":
        L[0] +=1
    elif S[i] == "G":
        L[1] +=1
    else:
        L[2] +=1

Ans = L[0]*L[1]*L[2]

for i in range(N):
  s = S[i]
  n = min(N, (N+i)//2 + 1)
  for j in range(i+1,n):
    t = S[j]
    if s != t:
      k = 2*j-i
      if k <= N-1:
        u = S[k]
        if t != u and u != s:
          Ans -=1
print(Ans)
### BUGGY CODE ###

import bisect

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort();B.sort();C.sort()
AB=[0 for i in range(N)]
BC=[0 for i in range(N)]

def find_gt(a,x):
    i = bisect.bisect_right(a,x)
    if i != len(a):
        return N-i
    else:
        return 0

for i in range(N):
    AB[i]=find_gt(B,A[i])
    BC[i]=find_gt(C,B[i])

ans=0
for i in range(N):
    ans+=sum(BC[N-AB[i]:])
print(ans)

### FIXED CODE ###

import bisect

N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
ans=0

for i in range(N):
    a=bisect.bisect_left(A,B[i])
    c=N-bisect.bisect_right(C,B[i])
    ans+=a*c

print(ans)
### BUGGY CODE ###

from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

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

POINT = [[-10**12 for i in range(n)] for j in range(k)]
PLACE = [[0 for i in range(n)] for j in range(k)]
for i in range(n):
  POINT[0][i] = C[P[i]-1]  
  PLACE[0][i] = P[i]-1 #P[i]は1スタートなのでずれる
  #A[0][i] = C[P[i]]
#print(PLACE)
#print(POINT)

tempmax= max(POINT[0])

for j in range(1,k): #日付
  for i in range(n):
    PLACE[j][i]=P[PLACE[j-1][i]]-1
    POINT[j][i]=POINT[j-1][i] + C[PLACE[j][i]]
    tempmax = max(tempmax,POINT[j][i])

#print(PLACE)
#print(POINT)
print(tempmax)

### FIXED CODE ###

from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
#P = list(map(int,input().split()))
P = list(map(lambda x : int(x) - 1, input().split())) #ひとつづつずらす
C = list(map(int,input().split()))
SCORE = [0]*(n+1)

max_score = -10**12
for i in range(n):
  x = i
  TEMPMAX = [-10**9] * (n+1)
  for j in range(1, n+1):
    SCORE[j] = SCORE[j-1] + C[P[x]]
    TEMPMAX[j]= max(TEMPMAX[j-1], SCORE[j])
    x = P[x]
    if x == i:
      break
  if j >= k:
    max_score = max(max_score,TEMPMAX[k])
  elif SCORE[j] < 0:
    max_score = max(max_score, TEMPMAX[j])
  else:
    m = k//j
    a = SCORE[j] *(m-1) + TEMPMAX[j]
    b = SCORE[j] *m + TEMPMAX[k % j]
    max_score = max(max_score, a, b)
print(max_score)
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
P.sort(reverse=True)
a = 0
b = 0
for i in range(N-1):
    if P[i] > 0:
        if a == 0:
            if P.count(P[i]) >= 2:
                a = P[i]
                P[i] = -i
                P[i+1] = -i -1
        elif b == 0:
            if P.count(P[i]) >= 2:
                b = P[i]
                P[i] = -i
                P[i+1] = -i -1
        else:
            break
    else:
        continue
ans = a * b
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
P.sort(reverse=True)
a = 0
b = 0
for i in range(N-1):
    if P[i] > 0:
        if a == 0:
            if P[i] == P[i+1]:
                a = P[i]
                P[i] = -i
                P[i+1] = -i -1
        elif b == 0:
            if P[i] == P[i+1]:
                b = P[i]
                P[i] = -i
                P[i+1] = -i -1
        else:
            break
    else:
        continue
ans = a * b
print(ans)
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(n):
    lFlag=True
    for j in range(i):
        if (p[i]>p[j]):
            lFlag=False
            break
    if lFlag:
        c=c+1
print(c)


### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
c=0
min=2*10**5
for i in range(n):
    if (p[i]<=min):
        c=c+1
    if p[i]<min:
        min=p[i]
print(c)
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
from functools import lru_cache
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]


def main():
    N = I()
    a = LI()
    t = [0, 0, 0]
    for ai in a:
        t[ai-1] += 1
    A, B, C = t
    E = B+C

    dp = [[[0 if ((i==0) and (j==0) and (k==0)) else N/(i+j+k) for k in range(C+1)] for i in range(B+C+1)] for j in range(A+B+C+1)]

    for k in range(C+1):
        for j in range(E+1):
            for i in range(N+1):
                if (i==0) and (j==0) and (k==0):
                    continue
                d = dp[i][j][k]
                if (i<N):
                    dp[i+1][j][k] += (i+1)*d/(i+1+j+k)
                if (i>0) and (j<E):
                    dp[i-1][j+1][k] += (j+1)*d/(i+j+k)
                if (j>0) and (k<C):
                    dp[i][j-1][k+1] += (k+1)*d/(i+j+k)

    print(dp[A][B][C])

main()

### FIXED CODE ###

import sys

def I(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    N = I()
    a = LI()
    t = [0, 0, 0]
    for ai in a:
        t[ai-1] += 1
    A, B, C = t
    E = B+C

    dp = [[0 if (i+j==0) else N/(i+j) for j in range(E+1)] for i in range(N+1)]

    for k in range(C+1):
        for i in range(N+1):
            dp[i][E] = 0 if (i+E+k==0) else N/(i+E+k)
        for j in range(E+1):
            for i in range(N+1):
                z = i+j+k
                if (not z):
                    continue
                d = dp[i][j]
                if (i<N):
                    dp[i+1][j] += (i+1)*d/(z+1)
                if (i>0) and (j<E):
                    dp[i-1][j+1] += (j+1)*d/z
                if (j>0) and (k<C):
                    dp[i][j-1] = (k+1)*d/z + N/z

    print(dp[A][B])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import math
n=int(input())
for i in range(1,n+1):
    p=int(math.sqrt(i))
    k=0
    for x in range(1,p+1):
        for y in range(x,p+1):
            for z in range(y,p+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    s=len(set([x,y,z]))
                    if s==1:
                        k+=1
                    if s==2:
                        k+=3
                    if s==3:
                        k+=6
    print(k)

### FIXED CODE ###

import math
n=int(input())
j=int(math.sqrt(n))
k=[0]*n
for x in range(1,j+1):
     for y in range(1,j+1):
        for z in range(1,j+1):
            p=x**2+y**2+z**2+x*y+y*z+z*x
            if p<=n:
                k[p-1]+=1
[print(i)for i in k]
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
INF = 10 ** 9


N, X, Y = map(int, input().split())
X -= 1
Y -= 1

G = [[abs(i - j) for i in range(N)] for j in range(N)]
G[X][Y] = 1
G[Y][X] = 1

for i in range(N):
    for j in range(N):
        G[i][j] = min(G[i][j], G[i][X] + G[Y][j] + 1, G[i][Y] + G[X][j] + 1)

ans = [0] * (N)
for i in range(N - 1):
    for j in range(i + 1, N):
        ans[G[i][j]] += 1
    
print (*ans[1:], sep = '\n')
        
# print (*G, sep = '\n')

### FIXED CODE ###



N, X, Y = map(int, input().split())

DP = [[abs(i - j) for i in range(N)] for j in range(N)]

DP[X - 1][Y - 1] = 1
DP[Y - 1][X - 1] = 1

# que = deque()
# que.append((X - 1, Y - 1))
# while que:
#     tmp = que.popleft()
#     x, y = tmp[0], tmp[1]

x = X - 1
y = Y - 1
for i in range(N - 1):
    for j in range(i + 1, N):
        DP[i][j] = min(DP[i][j], DP[i][x] + DP[y][j] + 1, DP[i][y] + DP[x][j] + 1)

lst = [0] * N
for i in range(N - 1):
    # tmp = list(ans[i,:])
    # print (tmp)
    for j in range(i + 1, N):
        lst[DP[i][j]] += 1
    
print (*lst[1:], sep = '\n')
### BUGGY CODE ###

def main():
    def comb(a, b):
        numerator = 1
        denominator = 1
        if a-b < 0:
            return None
        b = min(a-b, b)
        for i in range(a-b+1, a+1):
            numerator *= i
        for i in range(1, b+1):
            denominator *= i
        return numerator//denominator


    n, m, k = map(int, input().split())
    MAX = 998244353
    ans = 0
    pattern = lambda x: (comb(n-1, x)*m*(((m-1)**(n-1-x))%MAX))%MAX
    for i in range(k+1):
        ans += pattern(i)
        ans %= MAX
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    ans = 0
    m1 = [None]*(n+1)
    kaizyo = [None]*(n+1)
    nm1 = 1
    kai = 1
    for i in range(n+1):
        m1[i] = nm1
        nm1 *= m-1
        nm1 %= mod
        kaizyo[i] = kai
        kai *= i+1
        kai %= mod
    
    def comb(a, b):
        return (kaizyo[a]*fermat(kaizyo[a-b]*kaizyo[b], mod))%mod

    for i in range(k+1):
        ans += m*m1[n-i-1]*comb(n-1, i)
        ans %= mod
    
    print(ans)

def fermat(x, p):
    """
    1/x (mod p) を返す
        x**(p-1) ≡ 1    [if gcd(x, p) == 1]
        x**(p-2) ≡ 1/x
        繰返し二乗法 
            ex: x**50  = (x**25)**2
                x**25  = (x**12)**2 * x
                x**12  = (x**6)**2
                x**6   = (x**3)**2
    """
    times = []
    mod = p
    p -= 2
    while p > 1:
        times.append(p%2)
        p //= 2
    x %= mod
    out = x
    for i in times[::-1]:
        if i:
            out = (x*pow(out, 2, mod))%mod
        else:
            out = pow(out, 2, mod)
    return out



if __name__ == "__main__":
    main()