from functools import lru_cache
import sys
sys.setrecursionlimit(100000)
@lru_cache(10000)
def F(n):
if n==1: return 3
if n>1 and n%2==0: return F(n-1)+5*(n-1)
if n>1 and n%2!=0: return F(n-1)+7
print(F(8765))
школа 1747
from functools import lru_cache
import sys
sys.setrecursionlimit(100000)
@lru_cache(10000)
def F(n):
if n==1: return 3
if n>1 and n%2==0: return F(n-1)+5*(n-1)
if n>1 and n%2!=0: return F(n-1)+7
print(F(8765))