fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. import static java.lang.Character.isDigit;
  6.  
  7. class Ideone
  8. {
  9. public static void solve(Scanner sc, PrintStream out) {
  10. sc.forEachRemaining(line -> {
  11. StringBuilder sb = new StringBuilder();
  12.  
  13. line.chars().forEach(c -> {
  14. if (!isDigit(c)) return;
  15. int L = sb.length();
  16. if (L > 3 && L % 4 == 0) sb.insert(L - 1, '-');
  17. sb.append((char) c);
  18. });
  19.  
  20. int L = sb.length();
  21. if (L > 3 && L % 4 == 0) sb.insert(L - 2, '-');
  22.  
  23. out.println(sb);
  24. });
  25. }
  26.  
  27. public static void main (String[] args) throws java.lang.Exception
  28. {
  29. Scanner sc = new Scanner(System.in);
  30. sc.useDelimiter("\\n");
  31. solve(sc, System.out);
  32. sc.close();
  33. }
  34. }
Success #stdin #stdout 0.25s 321472KB
stdin
1
12
123
1234
12345
123TOP45KEK6
1234567
12-34-56-78
123456789FUCK YOU
9 - 33 2176--856
23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984r23897r3984gr29834g9824g894g58f48957egsugs89d7gy89e7t89375yt987459f859845982589f24gf986g9582g589fg298g948f58495f2896f98289f2g984r3984rsdfsdf2
stdout
1
12
123
12-34
123-45
123-456
123-45-67
123-456-78
123-456-789
933-217-68-56
238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-984-238-973-984-298-349-824-894-584-895-789-789-789-375-987-459-859-845-982-589-249-869-582-589-298-948-584-952-896-982-892-984-398-423-897-398-429-834-982-489-458-489-578-978-978-937-598-745-985-984-598-258-924-986-958-258-929-894-858-495-289-698-289-298-439-842-389-739-842-983-498-248-945-848-957-897-897-893-759-874-598-598-459-825-892-498-695-825-892-989-485-849-528-969-828-929-843-98-42