int main () {
int n;
cin>>n;
int a=1, b=2, c=0;
for (int i = 3; i <=n ; ++i) {
c=(a+b)%mod;
a=b%mod;
b=c;
}
cout<<c;
return 0;
}
int main () {
int n;
cin>>n;
int a=1, b=2, c=0;
for (int i = 3; i <=n ; ++i) {
c=(a+b)%mod;
a=b%mod;
b=c;
}
cout<<c;
return 0;
}
Actually I forgot case where n=2 or 1. Taking int is not a problem.