Buggy python submission (verdict: Runtime Error):

# your code goes here
n,a,b,k= map(int,input().split())

w = [1]
for i in range(0,n//2):
    w.append(w[-1]*(n-i)//(i+1))
if n %2 ==0:
    for i in range(0,n//2):
        w.append(w[(n-2)//2-i])
else:
    for i in range(0,n//2):
    	w.append(w[(n-3)//2-i])


c = 0
if k//a >= n:
    x = n
else:
    x = k //a

if k == 0:
    c = 1
else:
    for h in range(0,x+1):
        i = (k-a*h)/b

        if i == int(i) and n >= i:
            c += w[h]*w[int(i)]

print(c%998244353)

Fixed submission:
mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)

Buggy python submission (verdict: Time Limit Exceeded):
# cook your dish here
import math
n,a,b,k= map(int,input().split())



w = [1]
for i in range(0,n):
    w.append(w[-1]*(n-i)//(i+1))
#コンビネーションw[i] = nCi


c = 0
if k//a >= n:
    x = n
else:
    x = k //a

if k == 0:
    c = 1
else:
    for h in range(0,x+1):
        i = (k-a*h)/b

        if i == int(i) and n >= i:
            c = w[h]*w[int(i)]%998244353+c

print(c%998244353)

Fixed submission:
mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)

Buggy python submission (verdict: Time Limit Exceeded):

import math
n,a,b,k= map(int,input().split())	
w = []


w = [1]
for i in range(0,n):
    w.append(w[-1]*(n-i)//(i+1))
#コンビネーション


c = 0
if k//a >= n:
    x = n
else:
    x = k //a

if k == 0:
    c = 1   
else:
    for h in range(0,x+1):
        i = (k-a*h)/b
    
        if i == int(i) and n >= i:
            c = w[h]*w[int(i)]%998244353+c

print(c%998244353)

Fixed submission:
mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)

Buggy python submission (verdict: Time Limit Exceeded):

import math
n,a,b,k= map(int,input().split())	
def w(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#コンビネーション


c = 0
if k//a >= n:
    x = n
else:
    x = k //a

if k == 0:
    c = 1   
else:
    for h in range(0,x+1):
        i = (k-a*h)/b
    
        if i == int(i) and n >= i:
            c = w(n,h)*w(n,int(i))%998244353+c

print(c%998244353)

Fixed submission:
mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)

Buggy python submission (verdict: Runtime Error):

import math
n,a,b,k= map(int,input().split())	
def w(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#コンビネーション


c = 0
if k//a >= n:
    x = n
else:
    x = k //a
for h in range(0,x+1):
    i = (k-a*h)/b
    
    if 2*n >= h + int(i) and i == int(i):
        c = w(n,h)*w(n,int(i))+c
if c == 0:
    c = 1
print(c%998244353)

Fixed submission:
mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)

Buggy python submission (verdict: Time Limit Exceeded):

import math

li = list(map(int,input().split()))
n = li[0]
k = li[3]
a = max(li[1:3:])
b = min(li[1:3:])
def w(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#コンビネーション


c = 0

for h in range(0,k//(a+b)+1):
    for i in range(0,(k-(a+b)*h)//a+1):
        j = (k-(a+b)*h-a*i)/b
        if j == int(j) and j >= 0 and n >= h+i+j:
            c = c + w(n,h)*w(n-h,i)*w(n-h-i,j)
if c == 0:
    c = 1

print(c%9982443535)

Fixed submission:
mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)