Source Code
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <queue>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>
#include <deque>
#include <iomanip>
#include <stack>
#include <cassert>
using namespace std;
using ll = long long;
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ain(x,n) for(int i=0;i<n;i++)cin>>x[i];
#define aout(x,n) for(int i=0;i<n;i++)cout<<x[i]<<" ";
#define pii pair<int,int>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

//#define endl '\n'
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
int power(int x,  int y, int p)
{
    int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int dp[100005];
int rec(int i)
{
    if(i == 0)return 1;
    if(i< 0)return 0;
    if(dp[i]!=-1)return dp[i];
    return dp[i]=((rec(i-1)+rec(i-2))%mod);
}
void solve(int tccc)
{

    int n;
    cin>>n;
    cout<<rec(n)%mod<<endl;
}

int32_t main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cin>>t;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=t;i++)
    {

        solve(i);
    }

}
Copy
Study Schedule MrPie
GNU G++17
314 ms
4.2 MB
Runtime Error