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:
N = int(input())
L = [0] * 87  # 制約から
L[0] = 2
L[1] = 1
if N >= 2:
	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())
def lucas(x):
    a = 2
    b = 1
    for i in range(x):
        a,b = b,a+b
    return a
print(lucas(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())

pre = 2
ans = 1
for i in range(n-1):
    temp = ans
    ans = pre + ans
    pre = temp
    
print(ans)

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())
def func(n):
    a=2
    b=1
    for i in range(n):
        a,b=b,a+b
    return a
print(func(n))

Submission status: Accepted

Solution code:
def Lucas(n):
    if len(l)>n:return l[n]
    l.append(Lucas(n-1)+Lucas(n-2))
    return l[-1]

l=[2,1]
print(Lucas(int(input())))

Submission status: Accepted

Solution code:
n = int(input())

a = 2
b = 1
l = 1
for i in range(n+1):
    if i == 0 or i == 1:
        a = 2
        b = 1
    else:
        l = a + b
        a = b
        b = l

print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
M=[0]*100
M[0]=2
M[1]=1

def Lucas(i):
  if M[i]!=0:
    return M[i]
  else:
    M[i]=Lucas(i-1)+Lucas(i-2)
    return M[i]
  
print(Lucas(int(input())))

Submission status: Accepted

Solution code:
N = int(input())

L = [2, 1]

if N == 1:
    print(1)
else:
    for i in range(N-1):
        L.append(L.pop(0) + L[0])
    print(L[-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:
RN = [2, 1]
for i in range(2, 86 + 1):
	RN += [RN[i-1] + RN[i-2]]
print(RN[int(input())])

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())
l=[2,1]
for i in range(2,90):
    l.append(l[i-1]+l[i-2])

print(l[n])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 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())
list=[0]*(n+1)
list[0]=2
list[1]=1
for i in range(2,n+1):
  list[i]=list[i-1]+list[i-2]
print(list[n])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(raw_input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
L0 = 2; L1 = 1
if n == 1:
	print L1
else:
	for i in range(n - 1):
		L2 = L1 + L0
		L0 = L1
		L1 = L2
	print L2

Submission status: Accepted

Solution code:
N = int(input())

luca = [2,1]

while len(luca) <= N:
    luca.append(luca[-2] + luca[-1])

print(luca[N])

Submission status: Accepted

Solution code:
def solve():
    L=[0]*90
    L[0]=2
    L[1]=1
    for i in range(2,87):
        L[i]=L[i-1]+L[i-2]
    N=int(input())
    return L[N]

print(solve())

Submission status: Accepted

Solution code:
N = int(input())

L = [2, 1]
for i in range(2, N+2):
    L.append(L[i-1]+L[i-2])
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, 87):
    l[i] = l[i-1] + l[i-2]
print(l[n])

Submission status: Accepted

Solution code:
N = int(input())

if N==0:
    print(2)
elif N == 1:
    print(1)
else:
    a = 2
    b = 1
    for i in range(2, N+1):
        c = b + a
        b, a = c, b
    print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
L=[2,1] 
for i in range(N-1) :
  A=L[i]+L[i+1]
  L.append(A)
print(L[-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())

l_i = 0
l_i_1 = 1
l_i_2 = 2

if n == 1:
  print("1")
else:
  for i in range(n-1):
    l_i = 0
    l_i = l_i_1 + l_i_2
    l_i_2 = l_i_1
    l_i_1 = l_i
  print(l_i)

Submission status: Accepted

Solution code:
n = int(input())

l1 = 2
l2 = 1
l3 = 3

if n >= 2:
    for i in range(n - 1):
        t = l1 + l2
        l1 = l2
        l3 = t
        l2 = l3
    print(l3)
else:
    if n == 1:
        print(l2)
    else:
        print(l1)

Submission status: Accepted

Solution code:
N = int(input())

L0 = 2
L1 = 1

i = N
while i-1 > 0:
    Ln = L0 + L1
    i -= 1
    L0 = L1
    L1 = Ln

if N == 0:
    print(2)
elif N == 1:
    print(1)
else:
    print(Ln)

Submission status: Accepted

Solution code:
n = int(input())
l = [0] * 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())
L = [2,1]
for i in range(100):
    L.append(L[-1]+L[-2])
print(L[n])

Submission status: Accepted

Solution code:
from functools import lru_cache

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

print(lucas(int(input())))

Submission status: Accepted

Solution code:
N = int(input())

l = [2] + [0] * N
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())
L = [2, 1]
for i in range(2, N+2):
    Li = L[i-1] + L[i-2]
    L.append(Li)
print(L[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[N])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

d_l = {0: 2, 1: 1}
def l(n):
    if n in d_l:
        return d_l[n]
    d_l[n] = l(n - 2) + l(n - 1)
    return d_l[n]

print(l(N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(string):
    lucas = [2, 1]
    for i in range(2, 87):
        lucas.append(sum(lucas[-2:]))
    return str(lucas[int(string)])


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
L={0:2,1:1}
N=int(input())
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):
    tmp = l1
    l1 = l1 + l0
    l0 = tmp

print(l0)

Submission status: Accepted

Solution code:
from sys import stdin
from functools import lru_cache
n = int(stdin.readline().rstrip())
@lru_cache(maxsize=86)
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:
def solve(n):
    L=[2,1]
    for i in range(2,n+1):
        tmp=L[i-2]+L[i-1]
        L=L+[tmp]
    return L[n]

N=int(input())
print(solve(N))

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:
N = int(input())

dp = [0] * (N+10)
dp[0] = 2
dp[1] = 1

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

print(dp[N])

Submission status: Accepted

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

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

Submission status: Accepted

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

n = int(input())

lucas = [0] * 100
lucas[0] = 2
lucas[1] = 1

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

if n == 1:
    print(1)

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 - 1] + L[i - 2])
print(L[N])

Submission status: Accepted

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

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

print(hoge[n])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

lucas_memo = {}
def lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        if n-1 in lucas_memo:
            ln1 = lucas_memo[n-1]
        else:
            ln1 = lucas(n-1)
            lucas_memo[n-1] = ln1
        if n-2 in lucas_memo:
            ln2 = lucas_memo[n-2]
        else:
            ln2 = lucas(n-2)
            lucas_memo[n-2] = ln2
        return ln1 + ln2

print(lucas(N))

Submission status: Accepted

Solution code:
n = int(input())
memo = [0] * (n+1)
def luca(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    if memo[n] != 0:
        return memo[n]
    memo[n] = luca(n-1) + luca(n-2)
    return memo[n]


print(luca(n))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 079 B

N = int(input())
ans=[]
for i in range(N+1):
    if i==0:
        ans.append(2)
    elif i==1:
        ans.append(1)
    else:
        ans.append(ans[i-2]+ans[i-1])
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[N])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
if N==1:
    print(1)
else:
    L1 = 2
    L2 = 1
    L3 = L1+L2
    while N!=2:
        L1 = L2
        L2 = L3
        L3 = L1+L2
        N-=1
    print(L3)

Submission status: Accepted

Solution code:
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

N = I()
print(Luca(N))

Submission status: Accepted

Solution code:
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

N = I()
print(Luca(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

d2 = 2
d1 = 1
if N == 1:
    print(1)
else:
    for i in range(N):
        x = d1
        d1 += d2
        d2 = x
    print(d2)

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[n])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

ans = Ls[-1]

print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc079/tasks/abc079_b

import itertools
import collections
import bisect

def main():
    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def lucas_number(N: int) -> int:
    l0, l1 = 2, 1
    if N == 0:
        return l0
    if N == 1:
        return l1

    l = 0
    for _ in range(1, N):
        l = l1 + l0
        l1, l0 = l, l1
    return l


if __name__ == "__main__":
    N = int(input())
    ans = lucas_number(N)
    print(ans)

Submission status: Accepted

Solution code:
a,b=2,1;exec('a,b=b,a+b;'*int(input()));print(a)

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[N])

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    if N == 0:
        print(2)
        return 0
    if N == 1:
        print(1)
        return 0

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

    print(lucas[N])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
a=[2,1]
for i in range(87):
    a.append(a[i]+a[i+1])  
print(a[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())
L = {-1: -1, 0: 2}
for i in range(1, 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, l1 = 2, 1
    for i in range(n-1):
        l2 = l1 + l0
        l0, l1 = l1, l2
    print(l2)

Submission status: Accepted

Solution code:
n = int(input())

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

print(a[-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=2
B=1
i=1
for i in range(N):
    C=A+B
    A=B
    B=C
    i+=1
print(A)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
	N = int(input())
	nums = [0 for _ in range(N)]
	
	if N == 0:
		print(2)
		sys.exit()
	if N == 1:
		print(1)
		sys.exit()
		
	nums[0] = 2
	nums[1] = 1
	for i in range(N):
		if i < 2:
			continue
		nums[i] = nums[i-1] + nums[i-2]
	
	print(nums[N-1] + nums[N-2])
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
def main():
    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[N])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
lucas = [0]*(N+1)
lucas[0] = 2
lucas[1] = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if(N >= 2):
  for i in range(N-1):
    Lucas.append(Lucas[i] + Lucas[i+1])

print(Lucas[N])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
if n==1:print(1)
elif n==2:print(3)
else:
    ans=3
    befor=1
    for i in range(n-2):
        a=befor
        befor=ans
        ans+=a
    print(ans)

Submission status: Accepted

Solution code:

INF=1e18
MOD=1e9+7

N=int(input())

l=[0]*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:
# coding: utf-8
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())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


if N > 1:
    for i, n in enumerate(lc()):
        if i == N - 2:
            print(n)
            break
else:
    print(1)

Submission status: Accepted

Solution code:
first=2
second=1
cnt=1
n=int(input())
while cnt<n:
    first,second=second,first+second
    cnt+=1
print(second)

Submission status: Accepted

Solution code:
n=int(input())

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

print(X[n])

Submission status: Accepted

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

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

print(l[n])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int( input() )
memo = [-1] * (N+1)

def LucasNumber( i ):
    if i == 0: return 2
    if i == 1: return 1
    if memo[i] == -1:
        memo[i] = LucasNumber( i-1 ) + LucasNumber( i-2 )
    return memo[i]

print( LucasNumber(N) )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

A = [0, 2, 1]

for i in range(3,88) :
    A.append(A[i-1] + A[i-2])

print(A[n+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[-1])

Submission status: Accepted

Solution code:

num=int(input())

def lucas(n):
    lus = [2, 1]
    for idx in range(n+1):
        if idx > 1:
            lus.append(lus[-2]+lus[-1])
    return lus[-1]
            
print(lucas(num))

Submission status: Accepted

Solution code:
N = int(input())
cache = {}
def culc(n):
    if n == 0:
        c = 2
    elif n == 1:
        c = 1
    else:
        if n-1 not in cache:
            cache[n-1] = culc(n-1)
        a = cache[n-1]
        if n-2 not in cache:
            cache[n-2] = culc(n-2)
        b = cache[n-2]
        c = a + b
    return c

print(culc(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
memo = [0]*87
def f(i):
    if memo[i]:
        return memo[i]
    if i==0:
        return 2
    elif i==1:
        return 1
    else:
        memo[i] = f(i-1)+f(i-2)
        return memo[i]
print(f(n))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
    print(1)
    exit()

i = 2
L = [0]*(n+1)
L[0] = 2
L[1] = 1
while i != n:
    L[i] = L[i-1]+L[i-2]
    i+=1

print(L[n-1]+L[n-2])

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n+1):
    if i==0:
        l=2
    elif i==1:
        l=1
        s1=1
        s2=2
    else:
        l=s1+s2
        s2=s1
        s1=l
print(l)

Submission status: Accepted

Solution code:
from functools import lru_cache
N = int(input())
@lru_cache(maxsize=1000)
def luca(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)
print(luca(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l0,l1,t=2,1,0
if n==1:print(1);exit()
for s in range(n):
  t=l1
  l1=l0+l1
  l0=t
print(l0)

Submission status: Accepted

Solution code:
N = int(input())

L0 = 2
L1 = L = 1

for i in range(N-1):
    L = L0 + L1
    L0 = L1
    L1 = L

print(L)

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, 1]
for i in range(2, N+1):
    l[2] = l[0] + l[1]
    l[0] = l[1]
    l[1] = l[2]

print(l[2])

Submission status: Accepted

Solution code:
N = int(input())
l, m, n = 2, 1, 1
for i in range(2, N+1):
    n = l + m
    l = m
    m = n

print(n)

Submission status: Accepted

Solution code:
N = int(input())
L = [0] * 87
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())
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:
""" AtCoder """

N = int(input())

l = [2, 1]

for _ in range(85):
    l.append(l[-1] + l[-2])

print(l[N])

Submission status: Accepted

Solution code:
N = int(input())

cur = 1
pre = 2

for i in range(N - 1):
  cur, pre = cur + pre, cur

print(cur)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


n = ip()                              #入力整数1つ
#left,n= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)



#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def getLucas(N):
    if N == 0:
        return 2
    if N == 1:
        return 1

    l = [2, 1]

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

    return l[N]


N = int(input())
print(getLucas(N))

Submission status: Accepted

Solution code:
def luca(n, a=1, b=2):
  if n <= 1:
    return a
  return luca(n-1, a+b, a)

a = int(input())
print(luca(a))

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-1] + L[i-2])
print(L[N])

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:
def lucas(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]
n = int(input())
print(lucas(n))

Submission status: Accepted

Solution code:
def lucas(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]
n = int(input())
print(lucas(n))

Submission status: Accepted

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

Submission status: Accepted

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

print(Ryuka[N])

Submission status: Accepted

Solution code:
N = int(input())
if N == 0:
    print(2)
    exit()
if N == 1:
    print(1)
    exit()

lucas = [0 for _ in range(N+1)]
lucas[0], lucas[1] = 2, 1
for n in range(2, N+1):
    lucas[n] = lucas[n-1] + lucas[n-2]
print(lucas[n])

Submission status: Accepted

Solution code:
N=int(input()) 
tmpb=2 
tmpa=1 
num=0 
for i in range(N-1): 
    num=tmpb+tmpa 
    tmpb=tmpa 
    tmpa=num 
if N==1:
    num=1
print(num)

Submission status: Accepted

Solution code:
N = int(input())
L = [0]*87
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 = 87
m = int(input())
dp =[0]*(n+1)
dp[0]=2
dp[1]=1

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

Submission status: Accepted

Solution code:
int_n = int(input())

array = [2, 1]

for i in range(int_n - 1):
    array.append(array[i] + array[i+1])

print(array[-1])

Submission status: Accepted

Solution code:
n = int(input())
a = []
a.append(2)
a.append(1)

for i in range(n-1):
        a.append(a[i]+a[i+1])

print(a[n])

Submission status: Accepted

Solution code:
n = int(input())
a = []
a.append(2)
a.append(1)

for i in range(n-1):
    if n==1 or n==0:
        break
    else:
        a.append(a[i]+a[i+1])

print(a[n])

Submission status: Accepted

Solution code:
n = int(input())
a = []
a.append(2)
a.append(1)

for i in range(n):
    if n==1 or n==0:
        break
    else:
        a.append(a[i]+a[i+1])

print(a[n])

Submission status: Accepted

Solution code:
n = int(input())
a = []
a.append(2)
a.append(1)

for i in range(n+1):
    if n==1 or n==0:
        break
    else:
        a.append(a[i]+a[i+1])

print(a[n])

Submission status: Accepted

Solution code:
def lucas(n):
  if n==1:return 1
  l=[""]*(n+1)
  l[0]=2
  l[1]=1
  for i in range(2,n+1):
    l[i]=l[i-2]+l[i-1]
  return l[n]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

@memoize
def ans(N):
    if N==0:
        return 2
    elif N==1:
        return 1
    else:
        return ans(N-1)+ans(N-2)

N=int(input())
print(ans(N))

Submission status: Accepted

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

for _ in range(n-1):
    Table.append(sum(Table))
    Table.pop(0)
print(Table[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import lru_cache
N=int(input())

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

print(generate_lucas(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:
a=int(input())
b=[2,1]
for i in range(a-1):
	b.append(b[i]+b[i+1])
#print(b)
print(b[a])