/* Name of the class has to be “Main” only if the class is public. */
class Main
{
public static void main (String[] args) throws NumberFormatException,IOException
{
// your code goes here
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=0,r=0;
String s=br.readLine();
t=Integer.parseInt(s);
while(t>0)
{
String t1=br.readLine();
int c=0,m=0,d=0;
r=Integer.parseInt(t1);
while(r>0)
{
String temp=br.readLine();
String temp2=br.readLine();
int p1=Integer.parseInt(temp);
int p2=Integer.parseInt(temp2);
if(p1>9)
p1=digitCount(p1);
if(p2>9)
p2=digitCount(p2);
if(p1>p2)
c++;
else if(p1<p2)
m++;
else
d++;
–r;
}
if(c>m)
System.out.print(0+" “+c);
else if(c<m)
System.out.print(1+” “+m);
else
System.out.print(2+” "+d);
–t;
}
}
public static int digitCount(int n)
{
if(n<9)
return n;
int r=n%10+digitCount(n/10);
if(r>=10)
r=r%10+digitCount(r/10);
return r;
}
}
It shows:
Exception in thread “main” java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:542) at java.lang.Integer.parseInt(Integer.java:615) at Codechef.main(Main.java:17)