Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
MOD = 998244353

ans = 0
d = 1
b = 1
for i in range((N//2)):
    ans += d * b
    b *= 2
    b %= MOD
    ans %= MOD
    d = ((N-i)*d)%MOD
    d = (d*pow(i+1,MOD-2,MOD))%MOD

print((pow(3,N,MOD)-ans*2)%MOD)

Fixed submission:
N = int(input())
MOD = 998244353

list_size = 10000010

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)


def conv(n,r):
    if r == 0:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

ans = 0
for i in range((N//2)):
    ans += conv(N,i) * pow(2,i,MOD)
    ans %= MOD

print((pow(3,N,MOD)-ans*2)%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
MOD = 998244353
def func(x):
    a = [23,26]
    out = 1
    for i in range(30):
        if not i in a:
            out = (out*x)%MOD
        x *= x
        x %= MOD
    return out

def func2(x):
    x = bin(x)[2:]
    out = 1
    b = 3
    for i in range(len(x)):
        if x[-1-i] == "1":
            out *= b
            out %= MOD
        b *= b
        b %= MOD
    return out

ans = 0
d = 1
b = 1
for i in range((N//2)):
    ans += d * b
    b *= 2
    b %= MOD
    ans %= MOD
    d = ((N-i)*d)%MOD
    d = (d*func(i+1))%MOD

print((func2(N)-ans*2)%MOD)

Fixed submission:
N = int(input())
MOD = 998244353

list_size = 10000010

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)


def conv(n,r):
    if r == 0:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

ans = 0
for i in range((N//2)):
    ans += conv(N,i) * pow(2,i,MOD)
    ans %= MOD

print((pow(3,N,MOD)-ans*2)%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
MOD = 998244353
def func(x):
    a = [23,26]
    out = 1
    for i in range(30):
        if not i in a:
            out = (out*x)%MOD
        x *= x
        x %= MOD
    return out

def func2(x):
    x = bin(x)[2:]
    out = 1
    b = 3
    for i in range(len(x)):
        if x[-1-i] == "1":
            out *= b
            out %= MOD
        b *= b
        b %= MOD
    return out

ans = 0
d = 1
for i in range((N//2)):
    ans += d * 2**i
    ans %= MOD
    d = ((N-i)*d)%MOD
    d = (d*func(i+1))%MOD

print((func2(N)-ans*2)%MOD)

Fixed submission:
N = int(input())
MOD = 998244353

list_size = 10000010

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)


def conv(n,r):
    if r == 0:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

ans = 0
for i in range((N//2)):
    ans += conv(N,i) * pow(2,i,MOD)
    ans %= MOD

print((pow(3,N,MOD)-ans*2)%MOD)