@@ -0,0 +1,1138 @@
+import java.util.*;%0Aimport java.io.*;%0A%0Aclass TwoTwo %7B%0A%0A%09static Map%3CString, Boolean%3E map;%0A%0A%09static %7B%0A%09%09String s = %221%22;%0A%09%09int max = 800;%0A%09%09map = new HashMap%3C%3E();%0A%09%09map.put(%221%22, true);%0A%09%09for(int i=0;i%3Cmax;i++)%7B%0A%09%09%09s = multiplyWith2(s);%0A%09%09%09map.put(s, true);%0A%09%09%7D%0A%09%7D%0A%0A    public static void main(String args%5B%5D) throws IOException %7B%0A%09%09BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A%09%09int t = Integer.parseInt(br.readLine());%0A%09%09StringBuilder ans = new StringBuilder();%0A%09%09while(t--!=0)%7B%0A%09%09%09String str = br.readLine();%0A%09%09%09char c%5B%5D = str.toCharArray();%0A%09%09%09int l = c.length;%0A%09%09%09String num;%0A%09%09%09int count = 0;%0A%09%09%09for(int i=0;i%3Cl;i++)%7B%0A%09%09%09%09if(c%5Bi%5D == '0') continue;%0A%09%09%09%09for(int j=i+1;j%3C=l;j++)%7B%0A%09%09%09%09%09num = str.substring(i, j);%0A%09%09%09%09%09if(map.containsKey(num)) count++;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09ans.append(count + %22%5Cn%22);%0A%09%09%7D%0A%09%09System.out.println(ans.toString());%0A%09%7D%0A%0A%09static String multiplyWith2(String s)%7B%0A%09%09int l = s.length();%0A%09%09int sum = 0, carry = 0;%0A%09%09String ans = %22%22;%0A%09%09for(int i=l-1;i%3E=0;i--)%7B%0A%09%09%09sum = carry + (s.charAt(i) - '0')*2;%0A%09%09%09carry = sum/10;%0A%09%09%09ans = (sum%2510) + ans;%0A%09%09%7D%0A%09%09if(carry!=0) ans = carry + ans;%0A%09%09return ans;%0A%09%7D%0A%7D

Add solution of TwoTwo problem in Strings