Problem:
Problem D:
IkaNumber
数直線上の整数座標に, ねこの Taro の家, にんじん, うさぎの Hanako の家がこの順に並んでいる. 点 $x$ にいるイカは, 一回のジャンプで $x + 1$ または $x + 2$ に移動することができる.
あなたは, イカが Taro の家から Hanako の家までにんじんの置かれている座標に止まらずに行く経路が何通りあるか求めようとしたが, Taro の家, にんじん, Hanako の家の座標を知らないので
求めることができなかった. そこで, 代わりに経路の数として考えられる数をすべて列挙することにした.
ある Taro の家, にんじん, Hanako の家の配置に対してイカの経路数となる整数をイカ数と呼ぶことにする. $K$ 番目に小さいイカ数 (1-indexed) を mod 1,000,000,007 で求めよ.
Constraints
$K$ will be between 1 and 1,000,000,000,000,000,000, inclusive.
Input
入力はイカの形式で与えられる:
$K$
Output
$K$ 番目に小さいイカ数を 1,000,000,007 で割った余りを 1 行に出力せよ.
Sample Input 1
5
Sample Output 1
5
Sample Input 2
8
Sample Output 2
9

Submitted solutions:

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


template<int m>
struct mint {
    int x;
    mint(ll x = 0) : x(((x % m) + m) % m) {}
    mint operator-() const { return x ? m-x : 0; }
    mint &operator+=(mint r) {
        if ((x += r.x) >= m) x -= m;
        return *this;
    }
    mint &operator-=(mint r) {
        if ((x -= r.x) < 0) x += m;
        return *this;
    }
    mint &operator*=(mint r) {
        x = ((ll)x * r.x) % m;
        return *this;
    }
    mint inv() const { return pow(m-2); }
    mint &operator/=(mint r) { return *this *= r.inv(); }

    friend mint operator+(mint l, mint r) { return l += r; }
    friend mint operator-(mint l, mint r) { return l -= r; }
    friend mint operator*(mint l, mint r) { return l *= r; }
    friend mint operator/(mint l, mint r) { return l /= r; }
    mint pow(ll n) const {
        mint ret = 1, tmp = *this;
        while (n) {
            if (n & 1) ret *= tmp;
            tmp *= tmp, n >>= 1;
        }
        return ret;
    }
    friend bool operator==(mint l, mint r) { return l.x == r.x; }
    friend bool operator!=(mint l, mint r) { return l.x != r.x; }
    friend ostream &operator<<(ostream &os, mint a) {
        return os << a.x;
    }
    friend istream &operator>>(istream &is, mint& a) {
        ll x; is >> x; a = x; return is;
    }
};


template<typename T>
struct Combination {
    int _n = 1;
    vector<T> _fact{1}, _rfact{1};

    void extend(int n) {
        if (n <= _n) return;
        _fact.resize(n);
        _rfact.resize(n);
        for (int i = _n; i < n; ++i) _fact[i] = _fact[i - 1] * i;
        _rfact[n - 1] = 1 / _fact[n - 1];
        for (int i = n - 1; i > _n; --i) _rfact[i - 1] = _rfact[i] * i;
        _n = n;
    }

    T fact(int k) {
        extend(k + 1);
        return _fact.at(k);
    }

    T rfact(int k) {
        extend(k + 1);
        return _rfact.at(k);
    }

    T P(int n, int r) {
        if (r < 0 or n < r) return 0;
        return fact(n) * rfact(n - r);
    }

    T C(int n, int r) {
        if (r < 0 or n < r) return 0;
        return fact(n) * rfact(r) * rfact(n - r);
    }

    T H(int n, int r) {
        return (n == 0 and r == 0) ? 1 : C(n + r - 1, r);
    }
};


struct UnionFind {
    vector<int> par, sz;

    UnionFind(int n) : par(n), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return sz[root(x)];
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    //const int n = 10;

    //vi fib(n, 1);
    //FOR(i, 2, n) {
    //    fib[i] = fib[i-1] + fib[i-2];
    //}

    //REP(i, n) {
    //    REP(j, n) {
    //        printf("%4d ", fib[i] * fib[j]);
    //    }
    //    printf("\n");
    //}

    ll K; cin >> K;
    ll l = 0;
    if (K > 100) {
        l = sqrt(K)-2;
    }
    for(;; ++l) {
        if (K <= l*(l+1)) break;
    }
    assert(l*(l-1) < K and K <= l*(l+1));

    ll rem = K - l*(l-1);

    ll x = 2*l, y = -1;
    if (rem <= l) {
        x -= 1;
    }
    if (rem > l) {
        rem -= l;
    }

    if (rem <= (l+1)/2) {
        y = (rem-1)*2;
    } else {
        y = -2*rem + 2*l + 1;
    }

    ll ans = 1;
    int f0 = 1, f1 = 1, f2;
    FOR(i, 2, x+1) {
        f2 = f1 + f0;
        if (f2 >= MOD) f2 -= MOD;
        f0 = f1;
        f1 = f2;
        if (i == x-y) ans *= f2;
        if (i == y+1) ans *= f2;
    }

    ans %= MOD;
    cout << ans << endl;

    return 0;
}
accuracy: 1
time_ms: 2050
memory_kb: 3188
final_rank: 3

code_snippet: #include <bits/stdc++.h>
#define int long long
using namespace std;
typedef vector<int>vec;
typedef vector<vec>mat;
const int M=1000000007;
mat mul(mat A,mat B){
    mat C(A.size(),vec(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int j=0;j<B[0].size();j++){
            for(int k=0;k<A[0].size();k++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%M;
            }
        }
    }
    return C;
}
 
mat matpow(mat A,int k){
    mat B(A.size(),vec(A.size()));
    for(int i=0;i<A.size();i++)B[i][i]=1;
    while(k){
        if(k&1)B=mul(B,A);
        A=mul(A,A);
        k>>=1;
    }
    return B;
}
 
int sol(int n){
    mat A(2,vec(2));
    A[0][0]=1;A[0][1]=1;
    A[1][0]=1;A[1][1]=0;
    A=matpow(A,n);
    return A[1][0];
}

void out(int x,int y){
    cout<<(sol(x+1)*sol(y+1))%M<<endl;
    exit(0);
}

signed main(){
    int K;
    cin>>K;
    int l=0,r=(1e9)*4;
    while(l<r){
        int mid=(l+r)/2;
        if(mid*(mid+1)>=K)r=mid;
        else l=mid+1;
    }
    l--;
    int cnt=0;
    K-=l*(l+1);
    int x=r*2-1,p=0;
    if(K>r)K-=r,x++,p++;
    int y=1;
    while(x>=y){
        cnt++;
        if(cnt==K)out(x,y);
        x-=2;y+=2;
    }
    x+=2;
    y-=2;
   // cout<<r<<endl;
   // cout<<x<<' '<<y<<endl;
    if(!p){
        if((x==r+1&&y==r-1))x--,y++;
        else x++,y--;
    }
    else{
        if(x==y+x/2)x++,y--;
        else x--,y++;
    }
    //cout<<x<<' '<<y<<endl;

    while(1){
        cnt++;
        if(cnt>=2000000000)exit(1);
        if(cnt==K)out(x,y);
        x+=2;y-=2;
    }
    //cout<<K<<' '<<l<<endl;
}
accuracy: 1
time_ms: 400
memory_kb: 3156
final_rank: 2

code_snippet: #include <bits/stdc++.h>
#define int long long
using namespace std;
typedef vector<int>vec;
typedef vector<vec>mat;
const int M=1000000007;
mat mul(mat A,mat B){
    mat C(A.size(),vec(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int j=0;j<B[0].size();j++){
            for(int k=0;k<A[0].size();k++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%M;
            }
        }
    }
    return C;
}
 
mat matpow(mat A,int k){
    mat B(A.size(),vec(A.size()));
    for(int i=0;i<A.size();i++)B[i][i]=1;
    while(k){
        if(k&1)B=mul(B,A);
        A=mul(A,A);
        k>>=1;
    }
    return B;
}
 
int sol(int n){
    mat A(2,vec(2));
    A[0][0]=1;A[0][1]=1;
    A[1][0]=1;A[1][1]=0;
    A=matpow(A,n);
    return A[1][0];
}

void out(int x,int y){
    cout<<(sol(x+1)*sol(y+1))%M<<endl;
    exit(0);
}

signed main(){
    int K;
    cin>>K;
    int l=0,r=(1e9)*4;
    while(l<r){
        int mid=(l+r)/2;
        if(mid*(mid+1)>=K)r=mid;
        else l=mid+1;
    }
    l--;
    int cnt=0;
    K-=l*(l+1);
    int x=r*2-1,p=0;
    if(K>r)K-=r,x++,p++;
    int y=1;
    while(x>=y){
        cnt++;
        if(cnt==K)out(x,y);
        x-=2;y+=2;
    }
    x+=2;
    y-=2;
   // cout<<r<<endl;
   // cout<<x<<' '<<y<<endl;
    if(!p){
        if((x==r+1&&y==r-1))x--,y++;
        else x++,y--;
    }
    else{
        if(x==y+x/2)x++,y--;
        else x--,y++;
    }
    //cout<<x<<' '<<y<<endl;

    while(1){
        cnt++;
        if(cnt==K)out(x,y);
        x+=2;y-=2;
    }
    //cout<<K<<' '<<l<<endl;
}
accuracy: 1
time_ms: 220
memory_kb: 3160
final_rank: 1

code_snippet: #include <bits/stdc++.h>
#define int long long
using namespace std;
typedef vector<int>vec;
typedef vector<vec>mat;
const int M=1000000007;
mat mul(mat A,mat B){
    mat C(A.size(),vec(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int j=0;j<B[0].size();j++){
            for(int k=0;k<A[0].size();k++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%M;
            }
        }
    }
    return C;
}
 
mat matpow(mat A,int k){
    mat B(A.size(),vec(A.size()));
    for(int i=0;i<A.size();i++)B[i][i]=1;
    while(k){
        if(k&1)B=mul(B,A);
        A=mul(A,A);
        k>>=1;
    }
    return B;
}
 
int sol(int n){
    mat A(2,vec(2));
    A[0][0]=1;A[0][1]=1;
    A[1][0]=1;A[1][1]=0;
    A=matpow(A,n);
    return A[1][0];
}

void out(int x,int y){
    cout<<(sol(x+1)*sol(y+1))%M<<endl;
    exit(0);
}

signed main(){
    int K;
    cin>>K;
    int l=0,r=(1e9)*4;
    while(l<r){
        int mid=(l+r)/2;
        if(mid*(mid+1)>=K)r=mid;
        else l=mid+1;
    }
    l--;
    int cnt=0;
    K-=l*(l+1);
    int x=r*2-1,p=0;
    if(K>r)K-=r,x++,p++;
    int y=1;
    while(x>=y){
        cnt++;
        if(cnt==K)out(x,y);
        x-=2;y+=2;
    }
    x+=2;
    y-=2;
   // cout<<x<<' '<<y<<endl;
    if(!p){
        if(x!=y+x/2)x--,y++;
        else x++,y--;
    }
    else{
        if(x==y+x/2)x++,y--;
        else x--,y++;
    }
    //cout<<x<<' '<<y<<endl;

    while(1){
        cnt++;
        if(cnt==K)out(x,y);
        x+=2;y-=2;
    }
    //cout<<K<<' '<<l<<endl;
}
accuracy: 0.75
time_ms: 210
memory_kb: 3160
final_rank: 12

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
ld eps=1e-9;



const int mod = 1000000007;
struct Mod {
public:
	int num;
	Mod() : Mod(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) {
		static_assert(mod<INT_MAX / 2, "mod is too big, please make num 'long long int' from 'int'");
	}
	Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	assert(b.num != 0);
	return Mod(a) * inv(b);
}
Mod operator/=(Mod &a, const Mod b) {
	assert(b.num != 0);
	return a = a * inv(b);
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init() {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < MAX_MOD_N - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}
template<typename T>
vector<vector<T>> keisann(const vector<vector<T>>l, const vector<vector<T>>r) {
	vector<vector<T>>ans(l.size(), vector<T>(r[0].size()));
	assert(l[0].size() == r.size());
	for (unsigned int h = 0; h < l.size(); ++h) {
		for (unsigned int i = 0; i < r.size(); ++i) {
			for (unsigned int w = 0; w < r[0].size(); ++w) {

				ans[h][w] += l[h][i] * r[i][w];
			}
		}
	}
	return ans;
}

template<typename T>
vector<vector<T>>powgyou(vector<vector<T>>a, const long long int n) {
	assert(a.size() == a[0].size());
	if (!n) {
		vector<vector<T>>e(a.size(), vector<T>(a[0].size()));
		for (unsigned int i = 0; i < a.size(); ++i) {
			e[i][i] = 1;
		}
		return e;
	}
	if (n == 1)return a;
	else {
		vector<vector<T>>ans(a.size(), vector<T>(a[0].size(), 0));
		ans = powgyou(a, n / 2);
		ans = keisann(ans, ans);
		if (n % 2) {
			ans = keisann(ans, a);
		}
		return ans;
	}
}
int getans(long long int from,long long int to) {
	vector<vector<Mod>>gyou(2, vector<Mod>(2));
	gyou[0][0] = 1;
	gyou[0][1] = 1;
	gyou[1][0] = 1;
	gyou[1][1] = 0; 
	Mod left, right;
	{
		const vector<vector<Mod>>start(2, vector<Mod>(1, 1));
		vector<vector<Mod>> l = powgyou<Mod>(gyou, from-1);
		l = keisann(l, start);
		left = l[0][0];
	}
	{
		const vector<vector<Mod>>start(2, vector<Mod>(1, 1));
		vector<vector<Mod>> r = powgyou<Mod>(gyou, to-1);
		 r= keisann(r, start);
		 right = r[0][0];
	}
	Mod ans = left*right;
	cout << ans << endl;
	return 0;
}
int main() {
	long long int K; cin >> K;
	long long int num = max(0,int(sqrt(K)-2));
	while (1) {
		if (num*(num+1) < K) {
			num++;
		}
		else {
			num--;
			break;
		}
	}
	//(1,7),(3,5),(
	int sum = num*2 + 2;
	int count = K- num*(num + 1);
	bool ok = false;
	long long int from = 1;
	long long int to = sum - from;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < (sum / 2 + 1) / 2; ++j) {
			count--;
			if (count == 0) {
				getans(from, to);
				return 0;
			}
			from += 2;
			to -= 2;
		}
		if ((sum/2) % 2) {
			from -= 3;
			to += 3;
		}
		else {
			from -= 1;
			to += 1;
		}
		for (int j = 0; j < (sum / 2) / 2; ++j) {
			count--;
			if (count == 0) {
				getans(from, to);
				return 0;
			}
			from -= 2;
			to += 2;
		}
		from = 1;
		to = sum;
	}
	
	return 0;
}
accuracy: 1
time_ms: 450
memory_kb: 11088
final_rank: 11

code_snippet: #include<bits/stdc++.h>
#define M 1000000007
using namespace std;long long k,I,A,xy,x[2],fib[2],a,i;double D;int dp[3],h;int main(){cin>>k;a=sqrt(k)/16;xy=(long long)(2*sqrt(k-a-0.01))-1;A=(xy+2)*(xy+2)/4;I=(xy+1)*(xy+1)/4+1;D=1.0*(A+I)/2;if(k<=D){x[1]=(k-I)*2;}else{x[1]=(A-k)*2+1;}x[0]=xy-x[1];for(h=0;h<2;h++){if(x[h]<3){fib[h]=x[h]+1;}else{dp[0]=1;dp[1]=2;dp[2]=3;for(i=3;i<=x[h];i+=3){dp[0]=(dp[1]+dp[2])%M;dp[1]=(dp[2]+dp[0])%M;dp[2]=(dp[0]+dp[1])%M;}fib[h]=dp[x[h]%3];}}cout<<(fib[0]*fib[1])%M<<endl;}
accuracy: 1
time_ms: 7410
memory_kb: 1156
final_rank: 10

code_snippet: // Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2Div2!!!!

#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline long long mod_fibonacci_numberDiv2(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_yDiv2 = 2 * sqrt(K - sqrt(K / 100) - 0.01) - 1; // x + y

	long long min_Div2 = ((x_yDiv2 + 1) * (x_yDiv2 + 1) / 4) + 1;
	long long max_Div2 = ((x_yDiv2 + 2) * (x_yDiv2 + 2) / 4);

	long long x, y;

	if (2 * K <= min_Div2 + max_Div2)
	{
		y = (K - min_Div2) * 2;
	}
	else
	{
		y = (max_Div2 - K) * 2 + 1;
	}

	x = x_yDiv2 - y;

	cout << (mod_fibonacci_numberDiv2(x + 2) * mod_fibonacci_numberDiv2(y + 2)) % 1000000007 << endl;

	return 0;
}
accuracy: 1
time_ms: 5590
memory_kb: 3092
final_rank: 4

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline long long mod_fibonacci_numberDiv2(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_yDiv2 = 2 * sqrt(K - sqrt(K / 100) - 0.01) - 1; // x + y

	long long min_Div2 = ((x_yDiv2 + 1) * (x_yDiv2 + 1) / 4) + 1;
	long long max_Div2 = ((x_yDiv2 + 2) * (x_yDiv2 + 2) / 4);

	long long x, y;

	if (2 * K <= min_Div2 + max_Div2)
	{
		y = (K - min_Div2) * 2;
	}
	else
	{
		y = (max_Div2 - K) * 2 + 1;
	}

	x = x_yDiv2 - y;

	cout << (mod_fibonacci_numberDiv2(x + 2) * mod_fibonacci_numberDiv2(y + 2)) % 1000000007 << endl;

	return 0;
}
accuracy: 1
time_ms: 5770
memory_kb: 3092
final_rank: 6

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline long long mod_fibonacci_number(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_y = 2 * sqrt(K - sqrt(K / 100) - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << mod_fibonacci_number(x + 2) * mod_fibonacci_number(y + 2) << endl;

	return 0;
}
accuracy: 0.53125
time_ms: 5720
memory_kb: 3092
final_rank: 17

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline long long fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_y = 2 * sqrt(K - sqrt(K / 100) - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.53125
time_ms: 5720
memory_kb: 3092
final_rank: 17

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline int fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_y = 2 * sqrt(K - sqrt(K / 100) - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.53125
time_ms: 5640
memory_kb: 3092
final_rank: 15

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline int fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_y = 2 * sqrt(K - sqrt(K / 5) - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.53125
time_ms: 5670
memory_kb: 3092
final_rank: 16

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline int fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_y = 2 * sqrt(K - sqrt(K / 3) - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.53125
time_ms: 5600
memory_kb: 3092
final_rank: 13

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline int fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	long long x_y = 2 * sqrt(K - sqrt(K / 4) - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.53125
time_ms: 5620
memory_kb: 3092
final_rank: 14

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

inline int fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	int x_y = 2 * sqrt(K - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.3125
time_ms: 5510
memory_kb: 3076
final_rank: 19

code_snippet: #include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

int fibonacci(int n)
{
	if (n < 3)
	{
		return n == 0 ? 0 : 1;
	}

	int dp[3] = { 1, 1, 2 };

	for (int i = 3; i < n; i += 3)
	{
		dp[0] = (dp[1] + dp[2]) % 1000000007;
		dp[1] = (dp[2] + dp[0]) % 1000000007;
		dp[2] = (dp[0] + dp[1]) % 1000000007;
	}

	return dp[(n - 1) % 3];
}

long long K;

int main()
{
	cin >> K;

	int x_y = 2 * sqrt(K - 0.01) - 1; // x + y

	long long min_ = ((x_y + 1) * (x_y + 1) / 4) + 1;
	long long max_ = ((x_y + 2) * (x_y + 2) / 4);

	long long x, y;

	if (2 * K <= min_ + max_)
	{
		y = (K - min_) * 2;
	}
	else
	{
		y = (max_ - K) * 2 + 1;
	}

	x = x_y - y;

	cout << fibonacci(x + 2) * fibonacci(y + 2) << endl;

	return 0;
}
accuracy: 0.3125
time_ms: 5530
memory_kb: 3092
final_rank: 20

code_snippet: #include<bits/stdc++.h>
#define M 1000000007
using namespace std;long long k,I,A,xy,x[2],fib[2],a,i;double D;int dp[3],h;int main(){cin>>k;a=sqrt(k)/16;xy=(long long)(2*sqrt(k-a-0.01))-1;A=(xy+2)*(xy+2)/4;I=(xy+1)*(xy+1)/4+1;D=1.0*(A+I)/2;if(k<=D){x[1]=(k-I)*2;}else{x[1]=(A-k)*2+1;}x[0]=xy-x[1];
for(h=0;h<2;h++){
if(x[h]<3){fib[h]=x[h]+1;}
else{
dp[0]=1;dp[1]=2;dp[2]=3;
for(i=3;i<=x[h];i+=3){
dp[0]=(dp[1]+dp[2])%M;
dp[1]=(dp[2]+dp[0])%M;
dp[2]=(dp[0]+dp[1])%M;
}
fib[h]=dp[x[h]%3];
}
}
cout<<(fib[0]*fib[1])%M<<endl;}
accuracy: 1
time_ms: 5850
memory_kb: 3092
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;
long long k,I,A,x_y,x[2],fib[2],a,i;double D;
#define MOD 1000000007
int dp[3];
int main(){
    cin>>k;
    a=sqrt(k)/16;
    x_y=(long long)(2*sqrt(k-a-0.01))-1;
    A=(x_y+2)*(x_y+2)/4;
    I=(x_y+1)*(x_y+1)/4+1;
    D=1.0*(A+I)/2;
    if(k<=D){x[1]=(k-I)*2;}
    else{x[1]=(A-k)*2+1;}
    x[0]=x_y-x[1];
    
    for(int h=0;h<2;h++){
    if(x[h]<3){
        fib[h]=x[h]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[h];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[h]=dp[x[h]%3];
    }
    }
    cout<<(fib[0]*fib[1])%MOD<<endl;
}
accuracy: 1
time_ms: 5980
memory_kb: 3092
final_rank: 9

code_snippet: #include<bits/stdc++.h>
using namespace std;
long long k,_min,_max,x_y,x[2],fib[2],a,i;double mid;
#define MOD 1000000007
int dp[3];
int main(){
    cin>>k;
    a=sqrt(k)/16;
    x_y=(long long)(2*sqrtl(k-a-0.01))-1;
    _max=(x_y+2)*(x_y+2)/4;
    _min=(x_y+1)*(x_y+1)/4+1;
    mid=1.0*(_max+_min)/2;
    if(k<=mid){x[1]=(k-_min)*2;}
    else{x[1]=(_max-k)*2+1;}
    x[0]=x_y-x[1];
    
    for(int h=0;h<2;h++){
    if(x[h]<3){
        fib[h]=x[h]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[h];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[h]=dp[x[h]%3];
    }
    }
    
    /*if(x[1]<3)
    {
        fib[1]=x[1]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[1];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[1]=dp[x[1]%3];
    }*/
 
    cout<<(fib[0] * fib[1])%MOD<<endl;
}
accuracy: 1
time_ms: 5860
memory_kb: 3092
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;
long long k,_min,_max,x_y,x[2],fib[2],a,i;double mid;
#define MOD 1000000007
int dp[3];
int main(){
    cin>>k;
    a=sqrt(k)/16;
    x_y=(long long)(2*sqrtl(k-a-0.01))-1;
    _max=(x_y+2)*(x_y+2)/4;
    _min=(x_y+1)*(x_y+1)/4+1;
    mid=1.0*(_max+_min)/2;
    if(k<=mid){x[1]=(k-_min)*2;}
    else{x[1]=(_max-k)*2+1;}
    x[0]=x_y-x[1];
    
    if(x[0]<3){
        fib[0]=x[0]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[0];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[0]=dp[x[0]%3];
    }
    if(x[1]<3)
    {
        fib[1]=x[1]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[1];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[1]=dp[x[1]%3];
    }
 
    cout<<(fib[0] * fib[1])%MOD<<endl;
}
accuracy: 1
time_ms: 5710
memory_kb: 3092
final_rank: 5