I am new to codechef so please let me know if this is violating any rules.

The observed the pattern in numbers generated as-

case 1 : d0=5, d1=1 (d0+d1 even)

N = 5 1 6 2 4 8 6 2 4 8 …

case 2 : d0=3, d1=4 (d0+d1 odd)

N = 3 4 7 4 8 6 2 4 8 6 2 …

so if do+d1 is odd i generated d2 digit added to sum

then generated digits 1 to k%4 and added to sum

as digits 2,4,6,8 are repeated in some permutation so i added 20 * (k-2)/4; (used k-3 in case of odd d0+d1)

programmed the same logic as -

int d0,d1;

long long sum,k;

cin>>k>>d0>>d1;

sum = d0+d1;

k-=2;

if(k>0 && sum%2==1){

sum+=sum%10;

k–;

}

for(int i=0;i<k%4;i++) sum+=sum%10;

sum = sum + 20 * int(k/4);

if(sum%3==0) cout<<“YES”<<endl;

else cout<<“NO”<<endl;

please help me find error in my code