Error always occuring

while this program works fine elsewhere it is not running here

Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Piremoval.main(Main.java:5)

here is my code

import java.util.*;
class Piremoval {
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
for(int i=1;i<=n;i++)
{
String z=in.nextLine();
System.out.println(sol(z,0,""));
}

}
public static String sol(String q,int i,String result)
{
	
	if(i>=q.length())
	return result;
	if(q.substring(i,i+2)=="pi")
	{
	    result=q.substring(0,i)+"3.14"+q.substring(i+2);
	return(sol(q,i+4,result));
	}
	else
	return(sol(q,i+1,result));
	

}

}

Hi Sankalp
This error is mainly because of No input in Sample Input Box during Run.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.