Language: C++

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1");
            WillReturn.Add("3 7");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("13 13");
            WillReturn.Add("7 11");
            WillReturn.Add("7 11");
            WillReturn.Add("2017 2017");
            //1
            //0
            //0
            //1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("1 53");
            WillReturn.Add("13 91");
            WillReturn.Add("37 55");
            WillReturn.Add("19 51");
            WillReturn.Add("73 91");
            WillReturn.Add("13 49");
            //4
            //4
            //1
            //1
            //1
            //2
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static int[] mSosuuArr;

    //エラトステネスの篩
    static void Eratosthenes(int pJyougen)
    {
        var IsSosuuArr = new System.Collections.BitArray(pJyougen + 1);

        for (int I = 2; I <= IsSosuuArr.Count - 1; I++) {
            IsSosuuArr[I] = true;
        }
        for (int I = 2; I * I <= IsSosuuArr.Count - 1; I++) {
            if (I != 2 && I % 2 == 0) continue;

            if (IsSosuuArr[I]) {
                for (int J = I * 2; J <= IsSosuuArr.Count - 1; J += I) {
                    IsSosuuArr[J] = false;
                }
            }
        }
        var SosuuList = new List<int>();
        for (int I = 2; I <= IsSosuuArr.Count - 1; I++)
            if (IsSosuuArr[I]) SosuuList.Add(I);

        mSosuuArr = SosuuList.ToArray();
    }

    struct IRInfoDef
    {
        internal int I;
        internal int R;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        var IRList = new List<IRInfoDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            IRInfoDef WillAdd;
            WillAdd.I = wkArr[0];
            WillAdd.R = wkArr[1];
            IRList.Add(WillAdd);
        }

        int RMax = IRList.Max(X => X.R);
        Eratosthenes(RMax);

        //累積和の配列
        int[] RuisekiwaArr = new int[RMax + 1];
        int Ruisekiwa = 0;
        for (int I = 0; I <= RuisekiwaArr.GetUpperBound(0); I++) {
            if (Is2017Like(I)) Ruisekiwa++;
            RuisekiwaArr[I] = Ruisekiwa;
        }

        foreach(IRInfoDef EachIRInfo in IRList){
            int FromInd = EachIRInfo.I - 1;
            int ToInd = EachIRInfo.R;
            Console.WriteLine(RuisekiwaArr[ToInd] - RuisekiwaArr[FromInd]);
        }
    }

    //2017Likeな数かを判定
    static bool Is2017Like(int pInt)
    {
        if (pInt % 2 == 0) return false;
        if (Array.BinarySearch(mSosuuArr, pInt) < 0) return false;
        if (Array.BinarySearch(mSosuuArr, (pInt + 1) / 2) < 0) return false;
        return true;
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:7:12: error: 'string' does not name a type
    7 |     static string InputPattern = "InputX";
      |            ^~~~~~
a.cc:9:12: error: 'List' does not name a type
    9 |     static List<string> GetInputList()
      |            ^~~~
a.cc:51:15: error: expected unqualified-id before '[' token
   51 |     static int[] mSosuuArr;
      |               ^
a.cc:79:9: error: 'internal' does not name a type
   79 |         internal int I;
      |         ^~~~~~~~
a.cc:80:9: error: 'internal' does not name a type
   80 |         internal int R;
      |         ^~~~~~~~
a.cc:81:6: error: expected ';' after struct definition
   81 |     }
      |      ^
      |      ;
a.cc:126:2: error: expected ';' after class definition
  126 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Program::Eratosthenes(int)':
a.cc:56:9: error: 'var' was not declared in this scope
   56 |         var IsSosuuArr = new System.Collections.BitArray(pJyougen + 1);
      |         ^~~
a.cc:58:30: error: 'IsSosuuArr' was not declared in this scope
   58 |         for (int I = 2; I <= IsSosuuArr.Count - 1; I++) {
      |                              ^~~~~~~~~~
a.cc:61:34: error: 'IsSosuuArr' was not declared in this scope
   61 |         for (int I = 2; I * I <= IsSosuuArr.Count - 1; I++) {
      |                                  ^~~~~~~~~~
a.cc:70:13: error: expected ';' before 'SosuuList'
   70 |         var SosuuList = new List<int>();
      |             ^~~~~~~~~
a.cc:71:30: error: 'IsSosuuArr' was not declared in this scope
   71 |         for (int I = 2; I <= IsSosuuArr.Count - 1; I++)
      |                              ^~~~~~~~~~
a.cc:72:32: error: 'SosuuList' was not declared in this scope
   72 |             if (IsSosuuArr[I]) SosuuList.Add(I);
      |                                ^~~~~~~~~
a.cc:74:9: error: 'mSosuuArr' was not declared in this scope
   74 |         mSosuuArr = SosuuList.ToArray();
      |         ^~~~~~~~~
a.cc:74:21: error: 'SosuuList' was not declared in this scope
   74 |         mSosuuArr = SosuuList.ToArray();
      |                     ^~~~~~~~~
a.cc: In static member function 'static void Program::Main()':
a.cc:85:9: error: 'List' was not declared in this scope
   85 |         List<string> InputList = GetInputList();
      |         ^~~~
a.cc:85:14: error: 'string' was not declared in this scope
   85 |         List<string> InputList = GetInputList();
      |              ^~~~~~
a.cc:85:22: error: 'InputList' was not declared in this scope
   85 |         List<string> InputList = GetInputList();
      |                      ^~~~~~~~~
a.cc:85:34: error: 'GetInputList' was not declared in this scope
   85 |         List<string> InputList = GetInputList();
      |                                  ^~~~~~~~~~~~
a.cc:87:12: error: structured binding declaration cannot have type 'int'
   87 |         int[] wkArr = { };
      |            ^~
a.cc:87:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:87:12: error: empty structured binding declaration
a.cc:87:15: error: expected initializer before 'wkArr'
   87 |         int[] wkArr = { };
      |               ^~~~~
a.cc:88:9: error: 'Action' was not declared in this scope
   88 |         Action<string> SplitAct = pStr =>
      |         ^~~~~~
a.cc:88:24: error: 'SplitAct' was not declared in this scope
   88 |         Action<string> SplitAct = pStr =>
      |                        ^~~~~~~~
a.cc:88:35: error: 'pStr' was not declared in this scope
   88 |         Action<string> SplitAct = pStr =>
      |                                   ^~~~
a.cc:88:41: error: expected primary-expression before '>' token
   88 |         Action<string> SplitAct = pStr =>
      |                                         ^
a.cc:89:13: error: 'wkArr' was not declared in this scope
   89 |             wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
      |             ^~~~~
a.cc:89:44: error: 'X' was not declared in this scope
   89 |             wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
      |                                            ^
a.cc:89:47: error: expected primary-expression before '>' token
   89 |             wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
      |                                               ^
a.cc:89:49: error: expected primary-expression before 'int'
   89 |             wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
      |                                                 ^~~
a.cc:91:9: error: 'var' was not declared in this scope
   91 |         var IRList = new List<IRInfoDef>();
      |         ^~~
a.cc:92:25: error: expected ')' before 'EachStr'
   92 |         foreach (string EachStr in InputList.Skip(1)) {
      |                         ^~~~~~~
a.cc:92:17: note: to match this '('
   92 |         foreach (string EachStr in InputList.Skip(1)) {
      |                 ^
a.cc:92:9: error: 'foreach' was not declared in this scope
   92 |         foreach (string EachStr in InputList.Skip(1)) {
      |         ^~~~~~~
a.cc:100:20: error: 'IRList' was not declared in this scope
  100 |         int RMax = IRList.Max(X => X.R);
      |                    ^~~~~~
a.cc:100:34: error: expected primary-expression before '>' token
  100 |         int RMax = IRList.Max(X => X.R);
      |                                  ^
a.cc:104:12: error: structured binding declaration cannot have type 'int'
  104 |         int[] RuisekiwaArr = new int[RMax + 1];
      |            ^~
a.cc:104:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:104:12: error: empty structured binding declaration
a.cc:104:15: error: expected initializer before 'RuisekiwaArr'
  104 |         int[] RuisekiwaArr = new int[RMax + 1];
      |               ^~~~~~~~~~~~
a.cc:106:30: error: 'RuisekiwaArr' was not declared in this scope; did you mean 'Ruisekiwa'?
  106 |         for (int I = 0; I <= RuisekiwaArr.GetUpperBound(0); I++) {
      |                              ^~~~~~~~~~~~
      |                              Ruisekiwa
a.cc:111:27: error: expected primary-expression before 'EachIRInfo'
  111 |         foreach(IRInfoDef EachIRInfo in IRList){
      |                           ^~~~~~~~~~
a.cc: In static member function 'static bool Program::Is2017Like(int)':
a.cc:122:13: error: 'Array' was not declared in this scope
  122 |         if (Array.BinarySearch(mSosuuArr, pInt) < 0) return false;
      |             ^~~~~
a.cc:122:32: error: 'mSosuuArr' was not declared in this scope
  122 |         if (Array.BinarySearch(mSosuuArr, pInt) < 0) return false;
      |                                ^~~~~~~~~
a.cc:123:13: error: 'Array' was not declared in this scope
  123 |         if (Array.BinarySearch(mSosuuArr, (pInt + 1) / 2) < 0) return false;
      |             ^~~~~
a.cc:123:32: error: 'mSosuuArr' was not declared in this scope
  123 |         if (Array.BinarySearch(mSosuuArr, (pInt + 1) / 2) < 0) return false;
      |                                ^~~~~~~~~