Problem:


Score : 200 points

Problem Statement

It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.

You are given an integer N. Find the N-th Lucas number.

Here, the i-th Lucas number L_i is defined as follows:

L_0=2

L_1=1

L_i=L_{i-1}+L_{i-2} (i≥2)

Constraints

1≤N≤86

It is guaranteed that the answer is less than 10^{18}.

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the N-th Lucas number.

Sample Input 1

5

Sample Output 1

11

L_0=2

L_1=1

L_2=L_0+L_1=3

L_3=L_1+L_2=4

L_4=L_2+L_3=7

L_5=L_3+L_4=11

Thus, the 5-th Lucas number is 11.

Sample Input 2

86

Sample Output 2

939587134549734843



Sample input:
5


Sample output:
11

Submission status: Accepted

Solution code:
d = {}


def func(n):
    if n == 0:
        return 2
    if n == 1:
        return 1

    if d.get(n - 1):
        r1 = d.get(n - 1)
    else:
        r1 = func(n - 1)
        d[n - 1] = r1

    if d.get(n - 2):
        r2 = d.get(n - 2)
    else:
        r2 = func(n - 2)
        d[n - 2] = r2
    return r1 + r2


def main():
    n = int(input())
    print(func(n))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ABC 077
def getInt(): return int(input())
def zeros(n): return [0]*n

N = getInt()
l = zeros(N+1)
l[0],l[1] = 2,1
for i in range(2,N+1):
    l[i] = l[i-1]+l[i-2]
print(l[N])

Submission status: Accepted

Solution code:
n = int(input())
a = 2
b = 1
if n == 1:
    print(b)
else:
    for i in range(n-1):
        c = a+b
        a = b
        b = c
    print(c)

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(2, n + 1):
    l.append(l[i - 2] + l[i - 1])
    
print(l[n])

Submission status: Accepted

Solution code:
L_a,L_b = 1,2
N = int(input())
for i in range(N-1):
    L_a,L_b = L_a+L_b,L_a
print(L_a)

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))

luka = [0] * 100
luka[0] = 2
luka[1] = 1
for i in range(2, 100):
    luka[i] = luka[i-1] + luka[i-2]

print(luka[int(input())])

Submission status: Accepted

Solution code:
cache = {}

def f(x):
    if x == 0:
        return 2
    if x == 1:
        return 1
    
    if not x in cache:
        cache[x] = f(x - 1) + f(x - 2)
    return cache[x]


n = int(input())
print(f(n))

Submission status: Accepted

Solution code:
N = int(input())

dp = [0]*87
dp[0],dp[1] = 2,1

for i in range(2,87):
    dp[i] = dp[i-1]+dp[i-2]

print(dp[N])

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(2, n+1):
    l.append(l[-1] + l[-2])
print(l[n])

Submission status: Accepted

Solution code:
n = int(input())

L = [2,1]

if n>=2:
    for i in range(2,n+1):
        L.append(L[i-2]+L[i-1])

print(L[n])

Submission status: Accepted

Solution code:
n=int(input())
p=[2,1]
for i in range(n-1):
    p.append(p[i]+p[i+1])
print(p[-1])

Submission status: Accepted

Solution code:
N = int(input())
ans = [2,1]
for i in range(2,87):
    ans.append(ans[i-1] + ans[i-2])
print(ans[N])

Submission status: Accepted

Solution code:
n=int(input())

l=[2,1]
for i in range(2,87):
  l.append(l[i-1]+l[i-2])

print(l[n])

Submission status: Accepted

Solution code:
N=int(input())
L=[2,1]
for i in range(2,N+1):
  L.append(L[-1]+L[-2])
print(L[N])

Submission status: Accepted

Solution code:
n = int(input())
L = [2,1]
for i in range(86):
 something = L[i]+L[i+1]
 L.append(something)
print (L[n])

Submission status: Accepted

Solution code:
N = int(input())
l = [2, 1]
for i in range(N + 1):
    if i != 0 and i != 1:
        l.append(l[i-2] + l[i - 1])
print(l[N])

Submission status: Accepted

Solution code:
import numpy as np
a = int(input())
p =[0]*(a+1)
def cal(n):
    if p[n] !=0:return p[n]
    if n==0:res =  2
    elif n == 1:res = 1
    else: res =  cal(n-1)+cal(n-2)
    p[n] = int(res)
    return p[n]
print(int(cal(a)))

Submission status: Accepted

Solution code:
n=int(input())
l=[2,1]
for i in range(n-1):
  l.append(l[i]+l[i+1])
print(l[n])

Submission status: Accepted

Solution code:
memo=[0]*100
memo[0]=2
memo[1]=1
for i in range(2,100):
    memo[i]=memo[i-1]+memo[i-2]

n=int(input())
print(memo[n])

Submission status: Accepted

Solution code:
a, b = 2, 1
for i in range(int(input()) - 1):
    tmp = a
    a = b
    b += tmp
print(b)

Submission status: Accepted

Solution code:
N = int(input())
L0 = 2
L1 = 1


def progression(L_, L__, i):
    if i <= N-1:
        L = L_ + L__
        i += 1
        return progression(L, L_, i)

    else:
        return L_


print(progression(L1, L0, 1))

Submission status: Accepted

Solution code:
a=[0]*100
a[0],a[1]=2,1
n=int(input())
for i in range(2,n+1):
    a[i]=a[i-1]+a[i-2]
print(a[n])

Submission status: Accepted

Solution code:
N = int(input())
A = [2, 1]
for i in range(87):
    ans = A[i]+A[i+1]
    A.append(ans)
print(A[N])

Submission status: Accepted

Solution code:
N = int(input())

L = [0] * (N+1)
L[0], L[1] = 2, 1

for i in range(2,N+1):
  x = L[i-2] + L[i-1]
  L[i] = x
print(L[-1])

"""
L = [0] * (N+1)
L[0], L[1] = 2, 1
def luka(n):
  for i in range(2,n+1):
    x = L[i-2] + L[i-1]
    L[i] = x
  return L[-1]
luka(N)
"""

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
a = 2
b = 1

for _ in range(N):
    a, b = b, a+b
print(a)

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
L0 = 2
L1 = 1

if N == 1:
    print(L1)
else:
    for _ in range(N-1):
        L = L0 + L1
        L0 = L1
        L1 = L
    print(L)

Submission status: Accepted

Solution code:
n = int(input())

a, b = 1, 2
i = 2
while i <= n:
  a, b = a + b, a
  i += 1

print(a)

Submission status: Accepted

Solution code:
def abc079_b():
    n = int(input())
    if n == 1:
        print(1)
    else:
        l = [0] * (n + 1)
        l[0] = 2
        l[1] = 1
        for i in range(2, n + 1):
            l[i] = l[i - 1] + l[i - 2]
        print(l[n])


abc079_b()

Submission status: Accepted

Solution code:
N = int(input())

L = [0] * (N + 1)
L[0] = 2
L[1] = 1
if N == 1:
    print(L[1])
else:
    for i in range(2, N + 1):
        L[i] = L[i - 1] + L[i - 2]
    print(L[N])

Submission status: Accepted

Solution code:
buf=[-1 for i in range(90)]
def ryuka(N):
    global buf
    if buf[N]!=-1:
        return buf[N]
    else:
        if N==1:
            return 1
        elif N==0:
            return 2
        else:
            buf[N]=ryuka(N-1)+ryuka(N-2)
            return ryuka(N-1)+ryuka(N-2)

N=int(input())
print(ryuka(N))

Submission status: Accepted

Solution code:
n = int(input())

def luca(n):
    a = [None] * (n+1)
    a[0] = 2
    a[1] = 1
    for i in range(2, n+1):
        a[i] = a[i-1] + a[i-2]
    return a[n]
 
if __name__ == "__main__":
    print(luca(n))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())

    save = [2, 1]
    for _ in range(n-1):
        dum = save[-1] + save[-2]
        save.append(dum)

    print(save[-1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
l = [2,1]
if N == 0 or N == 1:
    print(l[N])
    exit()
for i in range(2,N+1):
    l.append(l[i-2] + l[i-1])
print(l[N])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ls = (2, -1)
    for _ in range(1, n + 1):
        ls = (ls[0] + ls[1], ls[0])
    print(ls[0])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = [0 for _ in range(100)]
l[0] = 2
l[1] = 1
for i in range(2, n + 1):
    l[i] = l[i-1] + l[i-2]
print(l[n])

Submission status: Accepted

Solution code:
n = int(input())
l0 = 2
l1 = 1
for i in range(n):
    l = l0 + l1
    l0 = l1
    l1 = l
print(l0)

Submission status: Accepted

Solution code:
n = int(input())
l0 = 2
l1 = 1
for i in range(n-1):
    l = l0 + l1
    l0 = l1
    l1 = l
if n == 1:
    print(l1)
else:
    print(l)

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1
c=0
if n==0:
    c=2
elif n==1:
    c=1
else:
    for i in range(n-1):
        c=a+b
        a=b
        b=c
print(c)

Submission status: Accepted

Solution code:
n = int(input())
l_list = [2,1]
if n == 1:
    print(1)
else:
    for i in range(n-1):
        ans = l_list[i] + l_list[i+1]
        l_list.append(ans)
    print(l_list[n])

Submission status: Accepted

Solution code:
import sys

def solve(n):
    l = [2,1]
    for i in range(n):
        l.append(l[i]+l[i+1])
    print(l[n])


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    return (n,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()

Submission status: Accepted

Solution code:
N=int(input())

L1=2
L2=1

for i in range(1,N,2):
    L3=L1+L2
    L4=L2+L3
    L1=L3
    L2=L4
if(N==1):
    print("1")
elif(N%2==0):
    print(L3)
else:
    print(L4)

Submission status: Accepted

Solution code:
import sys

def solve(n):
    print(luca(n))
    # print(luca_other(n))

def luca(n):
    result = [0 for i in range(n+1)]
    result[0] = 2
    result[1] = 1
    for i in range(2,n+1):
        result[i] = result[i-1] + result[i-2]
    return result[n]

def luca_other(n):
    if n == 0:
        return 2
    (x, y) = (2, 1)
    for i in range(n-1):
        (x, y) = (y, x + y)
    return y

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    return (n,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()

Submission status: Accepted

Solution code:
N = int(input())
L0 = 2
L1 = 1
lst = [L1,L0]
for i in range(N-1):
    lst.insert(0,lst[0]+lst[1])

print(lst[0])

Submission status: Accepted

Solution code:
A=[2,1]
n=int(input())
for i in range(n-1):
  A.append(A[i]+A[i+1])
print(A[-1])

Submission status: Accepted

Solution code:
n=int(input())
if n==0:
  print(2)
  exit()
if n==1:
  print(1)
  exit()
l=[0]*87
l[0]=2
l[1]=1
for i in range(2,n+1):
  l[i]=l[i-1]+l[i-2]
print(l[n])

Submission status: Accepted

Solution code:
n = int(input())

L = []
L.append(2)
L.append(1)

for i in range(2, n + 1):
	L.append(L[i-2] + L[i - 1])

print(L[n])

Submission status: Accepted

Solution code:
N = int(input())
a = [0]*(N+1)
a[0] = 2
a[1] = 1
for i in range(2,N+1):
        a[i] = a[i-1]+a[i-2]
print(a[N])

Submission status: Accepted

Solution code:
n = int(input())

a,b = 2,1
for i in range(1,n):
    a,b = b,a+b
print(b)

Submission status: Accepted

Solution code:
def lucas(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    current = 0
    n_1 = 1
    n_2 = 2
    for i in range(n - 1):
        current = n_1 + n_2
        n_2 = n_1
        n_1 = current
    return current

n = int(input())
print(lucas(n))

Submission status: Accepted

Solution code:
N = input()
L = [2, 1]
for i in range(N - 1):
    L.append(L[-1] + L[-2])
print L[N]

Submission status: Accepted

Solution code:
N = int(input())

a,b,c = 2,1,3

for i in range(N) :
	a,b,c = b,c,b+c

print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = 2
b = 1
for i in range(n-1):
    a, b = b, a + b
print(b)

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1

for i in range(n-1):
    tmpa=b
    b+=a
    a=tmpa
print(b)

Submission status: Accepted

Solution code:
N = int(input())
d0 = 2
d1 = 1
for i in range(1, N):
    d0, d1 = d1, d0 + d1
print(d1)

Submission status: Accepted

Solution code:
N = int(input())
def rk(n, memo):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    if memo[n] != 0:
        return memo[n]
    else:
        memo[n] = rk(n-1,memo) + rk(n-2,memo)
        return memo[n]
memo = [0 for i in range(87)]
print(rk(N, memo))

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
    print(1)
else:
    ans = [2,1]
    for i in range(n-1):
        ans.append(ans[-1]+ans[-2])
    print(ans[-1])

Submission status: Accepted

Solution code:
N = int(input())

lucas_list = [2,1]
while len(lucas_list) <= N:
    i = len(lucas_list)
    lucas_list.append(lucas_list[i-2]+lucas_list[i-1])
print(lucas_list[N])

Submission status: Accepted

Solution code:
a = int(input())
ar = [2,1]
count = 2
if a == 1:
    print(1)
else:
    while count != a:
        count += 1
        ar.append(sum(ar))
        del ar[0]
    print(sum(ar))

Submission status: Accepted

Solution code:
N = int(input())

L = [0 for i in range(87)]
L[0] = 2
L[1] = 1
for i in range(2,87):
    L[i] = L[i-1] + L[i-2]

print(L[N])

Submission status: Accepted

Solution code:
n = int(input())
l0 = 2
l1 = 1
s = 0
for i in range(n - 1):
  s = l0 + l1
  l0 = l1
  l1 = s

if n == 1:
  print(l1)
else:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())

Lucas_array = [2,1]
count = 0

while True:
    item = Lucas_array[count] + Lucas_array[count+1]
    if item < 10**18:
        Lucas_array.append(item)
        count += 1
    else:
        break

print(Lucas_array[n])

Submission status: Accepted

Solution code:
def Lucas(n):
	a, b = 2, 1
	
	for i in range(n):
		a, b = b, a + b
	return b
	
n = int(input())

if n == 0:
	print(2)
else:
	print(Lucas(n-1))

Submission status: Accepted

Solution code:
N=int(input())
Lyuka=[2,1]
n=2
while n<=N:
  Lyuka.append(Lyuka[n-1]+Lyuka[n-2])
  n+=1
print(Lyuka[N])

Submission status: Accepted

Solution code:
a = int(input())
b = [2,1]

for i in range(a):
  b.append(b[i]+b[i+1])
  
print(b[a])

Submission status: Accepted

Solution code:
N = int(input())

L = [2,1]

for i in range(2,N+1):
    L.append(L[i-2]+L[i-1])

print(L[N])

Submission status: Accepted

Solution code:
el_before = 2
el = 1
ans = 1
for i in range(2,int(input())+1):
    ans = el + el_before
    el_before = el
    el = ans
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
lucas = [2, 1]
for i in range(2, n+1):
    lucas.append(lucas[i - 2] + lucas[i - 1])
print(lucas[n])

Submission status: Accepted

Solution code:
n = int(input())

L = []
for i in range(n+1):
  if i == 0:
    L.append(2)
  elif i == 1:
    L.append(1)
  else:
    L.append(L[i-1]+L[i-2])

print(L[-1])

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(1)
elif N == 2:
    print(3)
else:
    L1 = 2
    L2 = 1
    L = 0
    for i in range(N-1):
        L = L1 + L2
        L1 = L2
        L2 = L
    print(L)

Submission status: Accepted

Solution code:
n = int(input())
x = 2
y = 1
z = 1
for i in range(1, n):
    z = x + y
    x = y
    y = z
print(z)

Submission status: Accepted

Solution code:
L = [0] * 87

for n, l in enumerate(L):
    if n == 0:
        L[0] = 2
    elif n == 1:
        L[1] = 1
    else:
        L[n] = L[n-1] + L[n-2]

N = int(input())

print(L[N])

Submission status: Accepted

Solution code:
n = int(input())
a, b = 1, 2
for _ in range(n - 1):
  a, b = a + b, a
print(a)

Submission status: Accepted

Solution code:
N = int(input())

nums = {}
nums[0] = 2
nums[1] = 1
for i in range(2, 87):
    nums[i] = nums[i-1]+nums[i-2]
print(nums[N])

Submission status: Accepted

Solution code:
n = int(input())
l =[2,1]
for i in range(2,n+1):
    l.append(l[i-2]+l[i-1])
print(l[-1])

Submission status: Accepted

Solution code:
import functools

N = int(input())

@functools.lru_cache(maxsize = None)
def L(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return L(n-1) + L(n-2)

print(L(N))

Submission status: Accepted

Solution code:
def luka(n):
  global lk
  if n==0:
    return 2
  if n==1:
    return 1
  if lk[n] != -1:
    return lk[n]
  lk[n] = luka(n-1)+luka(n-2)
  return lk[n]

lk = [-1]*100
n = int(input())
print(luka(n))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())


m = []

m = [2,3]
for i in range(2,87):
  m.append(m[i-2]+m[i-1])


def lucasnumber(n):
  if n == 0:
    return 2
  if n == 1:
    return 1
  if n == 2:
    return 3
  if n == 3:
    return 4
  return int(2*m[n-4]+m[n-3])

print(lucasnumber(n))

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> None:
    n = int(next_str())
    lucas = [2, 1]

    for i in range(2, n + 1):
        lucas[i % 2] = sum(lucas)

    print(lucas[n % 2])


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
lucas = [2, 1] 
for i in range(2, n+1):
    lucas.append(lucas[i-1] + lucas[i-2])
print(lucas[n])

Submission status: Accepted

Solution code:
N = int(input())
v = [2, 1]
for i in range(N):
	v.append(v[i]+v[i+1])
print(v[N])

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n+1):
    if i==0:
        a.append(2)
    elif i==1:
        a.append(1)
    else:
        a.append(a[i-1]+a[i-2])
print(a[n])

Submission status: Accepted

Solution code:
N = int(input())
lucas = [0 for i in range(N+1)]
def luca(a):
    if a == 0:
        return 2
    elif a == 1:
        return 1
    else:
        if lucas[a] != 0:
            return lucas[a]
        else:
            lucas[a] = luca(a-1) + luca(a-2)
            return lucas[a]
print(luca(N))

Submission status: Accepted

Solution code:
n = int(input())
memo={}

def ryuka(n):
  if n ==0:
    return 2
  if n == 1:
    return 1
  elif n not in memo:
    memo[n] = ryuka(n-1)+ryuka(n-2)
  return memo[n]

print(ryuka(n))

Submission status: Accepted

Solution code:
n = int(input())
x = [2, 1]
for i in range(n-1):
    x.append(sum((x[-1],x[-2])))

print(x[-1])

Submission status: Accepted

Solution code:
def get_new_lucas(l_i_1, l_i_2):
    """
    get a new Lucas number L_i

    l_i_1: L_(i-1),
    l_i_2: L_(i-2)
    """
    return l_i_1 + l_i_2


def main():
    n = int(input())
    tmp_l_i_1 = 1
    tmp_l_i_2 = 2
    for i in range(n):
        if i == 0:
            new_lucas_num = 1
        if i >= 1:
            new_lucas_num = get_new_lucas(tmp_l_i_1, tmp_l_i_2)
            tmp_l_i_2 = tmp_l_i_1
            tmp_l_i_1 = new_lucas_num
        
    print(new_lucas_num)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
l_2 = 2
l_1 = 1
l_0 = 0

if n == 0:
    l_0 = l_2
elif n == 1:
    l_0 = l_1
else:
    for i in range(2,n+1):
        l_0 = l_2 + l_1
        l_2 = l_1
        l_1 = l_0
print(l_0)

Submission status: Accepted

Solution code:
memo = {0: 2, 1: 1}
def luca(n):
    if n in memo:
        return memo[n]
    memo[n] = luca(n - 1) + luca(n - 2)
    return memo[n]
print(luca(int(input())))

Submission status: Accepted

Solution code:
l = [2,1]
for i in range(100):
    l.append(l[-2]+l[-1])
print(l[int(input())])

Submission status: Accepted

Solution code:
n = int(input())

L = [2,1]

for i in range(n+2):
	if i ==0 or i ==1:
		continue
	L.append(L[i-2]+L[i-1])
print(L[n])

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]
if N == 1 :
    print(1)
elif N > 1 :
    for i in range(N+1) :
        L.append(sum(L))
        if i == (N-2) :
            print(L[-1])
            break
        else :
            L.pop(0)

Submission status: Accepted

Solution code:
n = int(input())

a = [2, 1]
for i in range(2, 87):
    num = a[i-1] + a[i-2]
    a.append(num)

print(a[n])

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

l = []
l.append(2)
l.append(1)

if n > 1:
    for i in range(2,n+1):
        l.append(l[-1]+l[-2])
        
print(l[n])

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]
while len(L) <= N:
    L.append(L[-2] + L[-1])
print(L[-1])

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 1]
for i in range(87):
    L.append(L[i]+L[i+1])
print(L[N])

Submission status: Accepted

Solution code:
N = int(input())

def Lucas(N):
  L0 = 2
  L1 = 1
  for _ in range(N-1):
    L = L0 + L1
    L0 = L1
    L1 = L
  
  return L

if N == 1:
  print(1)
else:
  print(Lucas(N))

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 1]

for i in range(N):
    L.append(L[-1] + L[-2])

print(L[N])

Submission status: Accepted

Solution code:
n = int(input())

luca_nums = [2, 1]

while len(luca_nums)-1 < n:
    luca_nums.append(luca_nums[-1] + luca_nums[-2])

print(luca_nums[-1])

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1
if n==1:
    print(b)
else:
    for i in range(2,n):
        if i%2==0:
            a=a+b
        else:
            b=a+b
    print(a+b)

Submission status: Accepted

Solution code:
x = int(input())
def func(n):
    a,b = 2, 1
    while n > 1:
        a, b = b, a+b
        n -= 1
    return b
print(func(x))

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]
for i in range(2,87):
  L_i = L[i-2] + L[i-1]
  L.append(L_i)
print(L[N])

Submission status: Accepted

Solution code:
n = int(input())
a = 2
b = 1
for i in range(1,n):
  c = a
  a = b
  b += c
print(b)

Submission status: Accepted

Solution code:
n = int(input())

l = []

for i in range(n + 1):
    if i == 0:
        l.append(2)

    elif i == 1:
        l.append(1)

    else:
        l.append(l[i - 1] + l[i - 2])


print(l[len(l) - 1])

Submission status: Accepted

Solution code:
n = int(input())
sumL = [2, 1]
index=0
while index < n-1:
    sumL.append(sumL[index]+ sumL[index+1])
    index+=1

print(sumL[n])

Submission status: Accepted

Solution code:
n = int(input())
a = [0]*(n+1)
a[0] = 2
a[1] = 1
for i in range(2,n+1):
    a[i] = a[i-1] + a[i-2]
print(a[n])

Submission status: Accepted

Solution code:
n = int(input())
luca = []
luca.append(2)
luca.append(1)
count = 2
while count <= n:
    luca.append(luca[count-2] + luca[count-1])
    count += 1
print(luca[n])

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 1]

for i in range(2, N+1):
    L_i = L[i-1] + L[i-2]
    L.append(L_i)
print(L[N])

Submission status: Accepted

Solution code:
n = int(input())
L = [2, 1]

for i in range(2, n+1):
    L_i =  L[i-1] + L[i-2]
    L.append(L_i)
print(L[n])

Submission status: Accepted

Solution code:
a0 = 2
a1 = 1

for _ in range(int(input())-1):
	a0, a1 = a1, a0 + a1

print(a1)

Submission status: Accepted

Solution code:
N = int(input())

Lucas = []
Lucas.append(2)
Lucas.append(1)

for i in range(2, 90):
    Lucas.append(Lucas[i - 2] + Lucas[i - 1])

print(Lucas[N])

Submission status: Accepted

Solution code:
N = int(input())
L = []
L.append(2)
L.append(1)
for i in range(86) :
    l = L[-1]+L[-2]
    L.append(l)
print(L[N])

Submission status: Accepted

Solution code:
n=int(input())
a=2;b=1
for i in range(n):
 if i%2==0:a=a+b
 else:b=a+b
if n%2==0:print(a)
else:print(b)

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]
for i in range(N):
  L.append(L[i]+L[i+1])
print(L[N])

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

L = [2,1]

for i in range(2,87):
    tmp = L[i-2] + L[i-1]
    L.append(tmp)


print(L[N])

Submission status: Accepted

Solution code:
n = int(input())

l = [0]*87
l[0] = 2
l[1] = 1
for i in range(2, n+1):
    l[i] = l[i-1]+l[i-2]
print(l[n])

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
    print(1)
else:
    l0 = 2
    L = []
    L.append(l0)
    L.append(1)
    for i in range(N):
        L.append(L[-2]+L[-1])
    print(L[N])

Submission status: Accepted

Solution code:
n = int(input())

lucas = [2, 1]
for i in range(2, n+1):
    lucas.append(lucas[i-1] + lucas[i-2])
print(lucas[-1])

Submission status: Accepted

Solution code:
N=int(input())
a=2
b=1
for i in range(N):
    a,b=b,a+b
print(a)

Submission status: Accepted

Solution code:
N = int(input())

L_list = [2, 1]
for i in range(2, N+1):
    L_list.append(L_list[i-1]+L_list[i-2])

print(L_list[N])

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1
if n==1:
    print(1)
    exit()
else:
    for i in range(2,n+1):
        c=a+b
        a,b=b,c
print(c)

Submission status: Accepted

Solution code:
N = int(input())
if N ==1:
    res = 1
else:
    L1 = 1
    L2 = 2
    for i in range(2,N+1):
        res = L1 + L2
        L2 = L1
        L1 = res
print(res)

Submission status: Accepted

Solution code:
n = int(input())
l0 = 2
l1 = 1
if n == 0:
    print(l0)
    exit()
if n == 1:
    print(l1)
    exit()

l_prev = l0
l_next = l1

i = 2
while True:
    l_new = l_prev + l_next
    if n == i:
        print(l_new)
        break
    l_prev = l_next
    l_next = l_new
    i += 1

Submission status: Accepted

Solution code:
n = int(input())

l = [2, 1]
for i in range(2, n+1):
    l.append(l[i - 2] + l[i - 1])
print(l[n])

Submission status: Accepted

Solution code:
N=int(input())

dp=[-1 for _ in range(N+1)]
def Lu(n):
    if n==0:
        rec=2
    elif n==1:
        rec=1
    elif dp[n]!=-1:
        return dp[n]
    else:
        rec=Lu(n-1)+Lu(n-2)
    dp[n]=rec
    return rec
print(Lu(N))

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    dp = [0] * 100
    dp[0] = 2
    dp[1] = 1
    for i in range(2, 100):
        dp[i] = dp[i - 1] + dp[i - 2]
    print(dp[N])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
if N==0:
    print(2)
    exit()
elif N==1:
    print(1)
    exit()
else:
    L=[0 for i in range(N+1)]
    L[0]=2
    L[1]=1
    for i in range(2,N+1):
        L[i]=L[i-1]+L[i-2]
    print(L[N])

Submission status: Accepted

Solution code:
n = int(input())

l = [2, 1]
for i in range(2, n+1):
    num = l[i-1] + l[i-2]
    l.append(num)

print(l[n])

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]
for i in range(N):
    L.append(L[-1]+L[-2])
print(L[N])

Submission status: Accepted

Solution code:
L = [2, 1]
N = int(input())
for i in range(N-1):
    last_L = L[i] + L[i+1]
    L.append(last_L)
print(L[-1])

Submission status: Accepted

Solution code:
N = int(input())

A = [0] * 87

A[0] = 2
A[1] = 1

for i in range(2,87):
  A[i] = A[i-1] + A[i-2]

print(A[N])

Submission status: Accepted

Solution code:
a,b=2,1
for i in[0]*input():a,b=b,a+b
print a

Submission status: Accepted

Solution code:
a,b=2,1
for i in[0]*int(input()):a,b=b,a+b
print(a)

Submission status: Accepted

Solution code:
from functools import lru_cache

n = int(input())

@lru_cache(maxsize=1000)
def lucas(n):
  if n == 0:
    return 2
  elif n == 1:
    return 1
  else:
    return lucas(n - 1) + lucas(n - 2)

print(lucas(n))

Submission status: Accepted

Solution code:
#79b
n=int(input())
ans=[]
ans.append(2)
ans.append(1)
for i in range(2,n+1):
    ans.append(ans[i-1]+ans[i-2])
    
print(ans[n])

Submission status: Accepted

Solution code:
L = [2, 1]
for i in range(2, 87):
    L.append(L[i - 1] + L[i - 2])
N = int(input())
print(L[N])

Submission status: Accepted

Solution code:
N = int(input())
if N == 0:
	print(2)
elif N == 1:
	print(1)
else:
	L0,L1 = 2,1
	for i in range(N-1):
		L2 = L0 + L1
		L0,L1 = L1,L2
	print(L2)

Submission status: Accepted

Solution code:
n=int(input())

l = [2,1]

for i in range(0,n):
    l.append(l[i]+l[i+1])

print(l[n])

Submission status: Accepted

Solution code:
N = int(input())
l = []
l.append(2)
l.append(1)

for i in range(2, 87):
    l.append(l[i-2]+l[i-1])
print(l[N])

Submission status: Accepted

Solution code:
N = int(input())
a = 2
b = 1
if N == 1:
    print(1)
else:
    for _ in range(N-1):
        a, b = b, a + b
    print(b)

Submission status: Accepted

Solution code:
l=[0 for _ in range(87)]
l[0]=2
l[1]=1
for i in range(2,87):
  l[i]=l[i-1]+l[i-2]
N=int(input())
print(l[N])

Submission status: Accepted

Solution code:
N = int(input())
ans = [2,1]
while len(ans) <= N:
  ans.append(ans[-1]+ans[-2])
print(ans[-1])

Submission status: Accepted

Solution code:
N = int(input())
L = [0] * (N + 1)
L[0] = 2
L[1] = 1
for i in range(2, N+1):
    L[i] = L[i-1] + L[i-2]
print(L[-1])

Submission status: Accepted

Solution code:
N = int(input())
a=2
b=1
c=0
if N==1 :
    print(1)
else :
    for i in range(N-1) :
        #print(i,a,b,c)
        c = a + b
        a = b
        b = c
    print(c)

Submission status: Accepted

Solution code:
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    l1 = 2
    l2 = 1
    l3 = 1

    if n != 1:
        for _ in range(n - 1):
            l3 = luca(l1, l2)
            l1 = l2
            l2 = l3

    print(l3)


def luca(l1, l2):
    return l1 + l2


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

luca = [0] * 87
luca[0] = 2
luca[1] = 1
for i in range(2, 87):
    luca[i] = luca[i -1] + luca[i-2]

print(luca[N])

Submission status: Accepted

Solution code:
N = int(input())
L = [0 for i in range(87)]
L[0] = 2
L[1] = 1
for i in range(2, 87):
  L[i] = L[i - 2] + L[i - 1]
print(L[N])

Submission status: Accepted

Solution code:
N = int(input())

import functools

@functools.lru_cache(maxsize=None)
def L(n):
  if n == 0: return 2
  if n == 1: return 1
  return L(n - 1) + L(n - 2)

print(L(N))

Submission status: Accepted

Solution code:
lucas=[2,1]
n=int(input())
for i in range(2,n+1):
    lucas.append(lucas[i-2]+lucas[i-1])
print(lucas[n])

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

def main():
    n = int(input())
    dp = [2, 1]

    for i in range(n -1):
        dp.append(dp[-1] + dp[-2])
    
    print(dp[-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(2, 86 + 1):
    l.append(l[i-1]+l[i-2])
print(l[n])

Submission status: Accepted

Solution code:
N = int(input())

a = [2,1]
i=0
while N-1>0:
        a.append(a[i+1]+a[i])
        N-=1
        i+=1
print(a[-1])

Submission status: Accepted

Solution code:
n = int(input())
a, b = 2, 1
def lucas(a, b):
    return b, a+b
for i in range(n):
    a, b = lucas(a, b)
print(a)

Submission status: Accepted

Solution code:
l=[2,1]
for i in range(85):
    l.append(l[-1]+l[-2])
n=int(input())
print(l[n])

Submission status: Accepted

Solution code:
n = int(input())

l=[2]+[1]+[0]*(n-1)
i=2

while i<=n:
    l[i]=l[i-1]+l[i-2]
    i +=1

print(l[n])

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 1]
for i in range(87):
	x = L[i] + L[i + 1]
	L.append(x)
print(L[N])

Submission status: Accepted

Solution code:
N = int(input())
l=[2,1]
if N==1:
	print(l[1])
else:
	for i in range(2, N+1):
		l.append(l[i-1]+l[i-2])
	print(l[N])

Submission status: Accepted

Solution code:
n = int(input())
lucas = [0]*90
lucas[0], lucas[1] = 2, 1
for i in range(2, 90):
  lucas[i] = lucas[i-1]+lucas[i-2]
print(lucas[n])

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
init = np.expand_dims(np.array([2, 1]), 0)
to_next = np.array([
    [1, 1],
    [1, 2],
])
for i in range(n // 2):
    init = init.dot(to_next)
print(init[0][n & 1])