I am getting runtime error , but can't find out the reason, i have checked for many inputs and they are ok, but runtime error after submissioin.
code is...
Code: Select all
package setu_main;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
static void main(String[] args) throws IOException {
BufferedReader rd=new BufferedReader(new InputStreamReader(System.in));
String s=rd.readLine();
int x=Integer.parseInt(s);
long res=0;
for(int i=0;i<x;i++){
String k=rd.readLine();
if(k.substring(0,6).matches("report")){
System.out.println(res);
}
else{
String[] sp=k.split("\\s+");
long amount=Long.parseLong(sp[1]);
res+=amount;
}
}
}
}