Go: // AOJ ALDS1_10_A: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A

package main

import (
	"fmt"
)

func fibonacci(n int) int64 {
	f := []int64{1, 1}
	for i := 2; i <= n; i++ {
		f = append(f, f[i-2] + f[i-1])
	}
	return f[n]
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Println(fibonacci(n))
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl dp(45,0);
    dp[0]=1;
    dp[1]=1;
    rep(i,43){
        dp[i+2]=dp[i+1]+dp[i];
    }
    cout << dp[n] <<endl;
}

C++: #include <iostream>
using namespace std;
static const int MAX = 45;
int F[MAX];

int fib(int n)
{
    if (F[n] != 0) return F[n];
    if (n == 0) F[n] = 1;
    if (n == 1) F[n] = 1;
    if (n >= 2) F[n] = fib(n-2) + fib(n-1);
    return F[n];
}

int main()
{
    for (int i = 0; i != MAX; ++i)
    {
        F[i] = 0;
    }
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}

C++: #include <iostream>

using namespace std;

int fib(int n);

int main() {
    int n;
    int dp[45];

    //?????????
    /* ??????3-1 */
    dp[0]=1;
    /* ??????3-2 */
    dp[1]=1;
    //??\???
    cin >> n;

    //DP
    for (int i = 2; i <= n; i++) {
        /* ??????3-3 */
      dp[i]=dp[i-1]+dp[i-2];
    }

    //??????
    cout << dp[n] << endl;

    return 0;
}

C++: 
f = [-1 for i in range(45)]
f[0] = f[1] = 1

def fib(n):
    global f
    for i in range(2,n+1):
        f[i] = f[i - 1] + f[i - 2]
        #print(i,f[i])
    return f[n]

if __name__ == "__main__":
    n = input("input number: ")
    n = int(n)
    #print(type(n))
    print(fib(n))

C++: #include <bits/stdc++.h>
using namespace std;
long long memo[50];
long long f(long long x){
  if(x==0||x==1)return memo[x]=1;
  if(memo[x]!=0)return memo[x];
  return memo[x]=f(x-1)+f(x-2);
}
int main() {
  int n;
  cin >>n;
  long long kotae=f(n);
  cout<<kotae<<endl;
}

C++: #include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
ll dp[201];
int main(){
  ll a;cin>>a;
  dp[0]=1;
  dp[1]=1;
  for(ll i=2;i<=a;i++){
    dp[i]=dp[i-1]+dp[i-2];
  }
  cout<<dp[a]<<endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int n,i;
	cin>>n;
	vl dp(n+1);
	dp[0]=dp[1]=1;
	loop(i,2,n+1){
		dp[i]=dp[i-1]+dp[i-2];
	}
	cout<<dp[n]<<endl;
}

C++: #include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

const int NIL = -1;
const int MAX_N = 50;
vector<ll> fib(MAX_N);

int fibonach(vector<ll> &fib, int i){
    if(i == 0) return fib[0];
    if(i == 1) return fib[1];
    if(fib[i] != NIL) return fib[i];
    fib[i] = fibonach(fib, i-1) + fibonach(fib, i-2);
    return fib[i];
}

int main()
{
    int n; cin >> n;
    rep(i, MAX_N) fib[i] = NIL;
    fib[0] = 1;
    fib[1] = 1;
    ll res = fibonach(fib, n);
    cout << res << endl;
}

C++: #include <cstdio>

using namespace std;

int sum = 0, dp[50];

int fib( int n ){

    if( n == 0 || n == 1 ){

        return dp[n] = 1;

    } else if( dp[n] != -1 ){

        return dp[n] ;        

    } else{

        return dp[n] = fib( n - 1 ) + fib( n - 2 );

    }

}

int main(){

    int n;

    scanf("%d", &n);

    for( int i = 0; i < 50; i++ ) dp[i] = -1;

    int ans = fib(n);

    printf("%d\n", ans);

}

C++: #include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i = 2; i <= n; i++)F[i] = F[i -1] + F[i - 2];
        cout << F[n] << endl;
    return 0;
}

C++: #include<iostream>
using namespace std;

int main()
{
	int x = 1, y = 1, n, value = 0;
	cin >> n;

	if (n == 0 || n == 1) value = 1;
	else
	{
		while (n > 1)
		{
			value = x + y;
			x = y;
			y = value;
			n--;
		}
	}
	cout << value << endl;

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	long f[45];
	f[0] = f[1] = 1;
	cin >> n;
	for (int i = 2; i <= n; i++){
		f[i] = f[i - 1] + f[i - 2];
	}
	cout << f[n];
	return 0;
}

C++:  #include<iostream>
 #include<vector>
 using namespace std;
 int main(int arg, char* argv[]) {
    int n = 0;
    cin >> n;
    vector<int> f(45,0);
    f[0] = 1; f[1] = 1;
    for(int i = 2; i <= n; i++){
      f[i] = f[i-1] + f[i-2];
    }
   cout << f[n] << endl;
 }