Go: package main

import (
	"fmt"
)

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

	return fmt.Sprintf("%d", f[n])
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(answer(n))
}

C++: #include<iostream>
#include<algorithm>
#define Max 44
#define null (-1)
using namespace std;
int f[Max];
int fib(int a){
	if(a==0 || a==1)
	return f[a]=1;
	if(f[a]!=null)
	return f[a]; 
	return f[a]=fib(a-1)+fib(a-2);
	
}
main(){
	int n;
	cin>>n;
	for(int i=0;i<=n;i++)
	f[i]=null;
	cout<<fib(n)<<endl;
	return 0;
}

C++: object Main extends App {
  val fibs: Array[Option[Int]] = Array.fill(45)(None)
  val n: Int = io.StdIn.readInt()
  fibs(0) = Some(1); fibs(1) = Some(1)
  println(fib(n))

  def fib(n: Int): Int = fibs(n) match {
    case None =>
      val fibN: Int = fib(n-1) + fib(n-2)
      fibs(n) = Some(fibN)
      fibN
    case Some(x) => x
  }
}

C++: #include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
int dp[100];

ll f(int n) {
    if (n <= 1) return 1;
    if (dp[n] != INF) return dp[n];
    ll ret = f(n - 1) + f(n - 2);
    dp[n] = ret;
    return ret;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    cin >> N;
    REP(i, 100) dp[i] = INF;
    cout << f(N) << endl;
    return 0;
}

C++: // Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
using namespace std;

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

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

int main() {
  int fib[45];
  fib[0]=1;
  fib[1]=1;
  for(int i=2;i<45;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }

  int n;
  scanf("%d",&n);

  printf("%d\n",fib[n]);
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(void)
{
    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;

#define MAX 44

int F[MAX];

int main() {
    int n;
    cin >> n;
    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;

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 44;

int n;

int dp[MAX_N];

int main() {
    cin >> n;
    dp[0] = 1, dp[1] = 1;
    REP2(i, 2, n+1) dp[i] = dp[i-1] + dp[i-2];
    PRINT(dp[n]);
    return 0;
}

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

const int Max = 50;
int F[Max];

int Fib(int n)
{
    F[0] = 1;
    F[1] = 1;
    if(n==0 || n==1) return F[n];
    if(!F[n-1])
        F[n-1] = Fib(n-1);
    if(!F[n-2])
        F[n-2] = Fib(n-2);
    return F[n-1]+F[n-2];
}
int main()
{
    int n;
    cin >> n;
    memset(F, 0, sizeof(F));
    cout << Fib(n) << endl;
}

C++: #include <iostream>

using namespace std;
int fib(int n){
    int dp[50];
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2; i < 45; ++i){
        dp[i] = dp[i-1] + dp[i-2];
    }
    return dp[n];
}

int main(){
    int n;
    cin >> n;
    cout << fib(n) << endl;
}

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>

#define MAX 1000000

using namespace std;

int fib[MAX];

int solve(int a){
    if(fib[a])return fib[a];
    if(!fib[a-2])fib[a-2] = solve(a-2);
    if(!fib[a-1])fib[a-1] = solve(a-1);
    return fib[a-1]+fib[a-2];
}

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    fill(fib, fib+MAX, 0);
    fib[0] = 1;
    fib[1] = 1;
    int num; cin >> num;
    cout << solve(num) << endl;
    
    return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int sum;
    if(n==0){
        sum=1;
    } else if(n==1){
        sum=1;
    } else{
        int older=1, oldest=1;
        sum=0;
        for(int i=2; i<=n; i++){
            sum=older+oldest;
            oldest=older;
            older=sum;
        }
    }
    printf("%d\n", sum);
    return 0;
}

C++: #include <stdlib.h>
#include <stdio.h>

int fib(int n){
int i;
int a[25];
a[0]=a[1]=1;
for(i=2;i<n;i++){
a[i]=a[i-1]+a[i-2];
   }
return a[i];
}

int main(){

int x;
scanf("%d",&n);
x=fib(n);
printf("%d",x);

return 0;
}

C++: #include <iostream>
using namespace std;
int fib(int n) {
    if(n==1) 
        return 1;
    else if(n==2)
        return 2;
    else
        return fib(n-1) + fib(n-2);
}
int main(void){
    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] = dp[1] = 1;
    /* ??????3-2 */

    //??\???
    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++: #include<iostream>
using namespace std;
int nrec(int n){
    int a[44];
    a[0]=a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];  
    }
    return a[n];
}

int main(){
    int n;
    cin>>n;
    cout<<nrec(n)<<endl;
    return 0;
}

C++: #include <iostream>
#include <vector>

uint32_t fib(uint32_t n, std::vector<uint32_t>& result) {
  if (n == 0 || n == 1) return 1;
  if (result[n - 1] != 0) return result[n - 1];
  result[n - 1] = fib(n - 1, result) + fib(n - 2, result);
  return result[n - 1];
}

int main() {
  uint32_t n = 0;
  std::cin >> n;

  std::vector<uint32_t> result(n, 0);
  std::cout << fib(n, result) << std::endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

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

C++: #include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

#define MAX 100005
#define INF INT_MAX

typedef long long ll;
typedef pair<int, int> P;

int main(int, char**)
{
    int n;
    cin >> n;

    vector<int> a(n+1);
    rep(i,n+1) {
        if (i <= 1) {
            a[i] = 1;
            continue;
        }
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;
    return 0;
}

C++: #include<iostream>

using namespace std;
int fib(int n);
int main() {
  int n;

  //入力
  cin >> n;

  //出力
  cout << fib(n) << endl;

  return 0;
}

int fib(int n){
  if(n==0 || n == 1){
    return 1;
  }else{
    return fib(n-1) + fib(n-2);
  }
}