i can get correct answers in custom input but when i submit it shows wrong answers and if i run without custom input , it shows the above error
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
static Scanner scn = new Scanner(System.in);
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
String s = scn.next();
System.out.println( sub_pall(s));
}
public static int sub_pall(String args)
{
int len = args.length();
int ans = 0;
for(int i=1;i<2*(len);i++)
{
int l_idx = ((i-1)/2)-1;
int u_idx = ((i-1)/2)+1;
int nos = 1;
if(i%2==0)
{
nos = 0;
l_idx = ((i-1)-1)/2;
u_idx = ((i+1)-1)/2;
}
if(i%2!=0)
{
int r = Integer.parseInt(args.substring((i-1)/2,((i-1)/2)+1));
if(r%3!=0)
{
continue;
}
}
while(l_idx>=0 && u_idx<len)
{
if(args.charAt(l_idx)==args.charAt(u_idx))
{
int x = Integer.parseInt(args.substring(l_idx,u_idx+1));
if(x%3==0 && args.charAt(l_idx)!='0')
nos++;
l_idx--;
u_idx++;
}
else{
break;
}
}
ans+=nos;
}
return ans;
}
}