fork download
  1. import java.util.*;
  2. import java.io.*;
  3. //Solution Credits: Taranpreet Singh
  4. class Editorial{
  5. //SOLUTION BEGIN
  6. void solve(int TC) throws Exception{
  7. int n = ni(), ans = 0;
  8. for(int i = 1; i<= n; i++){
  9. int start = ni(), end = ni();
  10. //If Expected ending time < actual end time, submission is judged late.
  11. if(start+5<end)ans++;
  12. }
  13. pn(ans);
  14. }
  15. //SOLUTION ENDS
  16. boolean multipleTC = true;
  17. FastReader in;PrintWriter out;
  18. void run() throws Exception{
  19. in = new FastReader();
  20. out = new PrintWriter(System.out);
  21. for(int i = 1, T = (multipleTC)?ni():1; i<= T; i++)solve(i);
  22. out.flush();
  23. out.close();
  24. }
  25. public static void main(String[] args) throws Exception{
  26. new Editorial().run();
  27. }
  28. void p(Object o){out.print(o);}
  29. void pn(Object o){out.println(o);}
  30. void pni(Object o){out.println(o);out.flush();}
  31. String n(){return in.next();}
  32. String nln(){return in.nextLine();}
  33. int ni(){return Integer.parseInt(in.next());}
  34. long nl(){return Long.parseLong(in.next());}
  35. double nd(){return Double.parseDouble(in.next());}
  36. class FastReader{
  37. public FastReader(){
  38. }
  39.  
  40. public FastReader(String s) throws Exception{
  41. br = new BufferedReader(new FileReader(s));
  42. }
  43.  
  44. String next(){
  45. while (st == null || !st.hasMoreElements()){
  46. try{
  47. st = new StringTokenizer(br.readLine());
  48. }catch (IOException e){
  49. e.printStackTrace();
  50. }
  51. }
  52. return st.nextToken();
  53. }
  54.  
  55. String nextLine(){
  56. String str = "";
  57. try{
  58. str = br.readLine();
  59. }catch (IOException e){
  60. e.printStackTrace();
  61. }
  62. return str;
  63. }
  64. }
  65. }
Success #stdin #stdout 0.04s 2184192KB
stdin
1
5
1 3
4 4
4 10
1 11
2 7
stdout
2