NZEC in MULTHREE please help

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int T = Integer.parseInt(br.readLine());
    while (T > 0) {
        String[] input = br.readLine().split(" ");
        long K = Long.parseLong(input[0]);
        int d0 = Integer.parseInt(input[1]);
        int d1 = Integer.parseInt(input[2]);
        int S = d0 + d1;
        int [] cycle_mul = {2,4,8,6};
        long cycles = (K - 3) / 4;
        long remaining = (K - 3) % 4;
        long cycle_value = 0;

        if(K==2){
            if((d0+d1)%3==0){
                System.out.println("YES");

            }
            else{
                System.out.println("NO");
            }
            continue;
        }



        for(int i=0;i<cycle_mul.length;i++){
            cycle_value += (cycle_mul[i]* S)%10;
        }

        long ans = S + (S%10) + (cycles *(cycle_value));
        if(remaining>0){
            int i=0;
            for(int j=0;j<remaining;j++){
                ans+= (cycle_mul[j] * S)%10;
                
                
            }

        }
        if(ans%3==0){
            System.out.println("YES");


        }
        else{
            System.out.println("NO");

        }
        System.out.flush();
        T--;
    }
}

}

Refer to the JAVA code here: Competitive-Programming/multipleOfThree.java at master · strikersps/Competitive-Programming · GitHub

Maybe it will help you out.

I have used the same approach but its giving me NZEC i dont know why?
Although it passes the sample test cases

If your code give right answer to sample test cases does not mean your solution is correct.

You can run your program on several test cases I have provided in the above repository link.