Why does my code give WA?
Problem: CodeChef: Practical coding for everyone
public static void main (String[]args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
int t = in.nextInt ();
in.nextLine();
for (int i = 0; i < t; i++)
{
String s = in.nextLine();
int l = s.length();
int streak=1;
int sum=1;
for (int j=1;j<l;j++)
{
if (s.charAt(j)==s.charAt(j-1))
{
streak++;
}
else
{
sum++;
if (streak<10)
{
sum++;
}
else if (streak>=10)
{
sum+=2;
}
else if (streak>=100)
{
sum+=3;
}
else if (streak>=1000)
{
sum+=4;
}
streak=1;
}
if (j==l-1)
{
if (streak<10)
{
sum++;
}
else if (streak>=10)
{
sum+=2;
}
else if (streak>=100)
{
sum+=3;
}
else if (streak>=1000)
{
sum+=4;
}
}
}
if (sum<l) System.out.println("YES");
else System.out.println("NO");
}
}