Language: C++

using System;
using System.Collections.Generic;

namespace _0044
{
    class Programｓ
    {
        readonly static int MAX_NUMBER = 50022;

        static void Main(string[] args)
        {
            List<int> primeList = new List<int>();
            for (int i = 1; i < MAX_NUMBER; i++)
            {
                if (IsPrime(i))
                {
                    primeList.Add(i);
                }
            }

            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                int number = int.Parse(input);
                int previousPrimeNumber = 0;
                int nextPrimeNumber = 0;

                foreach (var primeNumber in primeList)
                {
                    if (primeNumber < number)
                    {
                        previousPrimeNumber = primeNumber;
                    }
                    else if (primeNumber > number)
                    {
                        nextPrimeNumber = primeNumber;
                    }

                    if (nextPrimeNumber != 0)
                    {
                        break;
                    }
                }
                Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber);
            }
        }

        static bool IsPrime(int number)
        {
            if (number <= 1)
            {
                return false;
            }
            else if (number <= 3)
            {
                return true;
            }
            else if ((number % 2) == 0)
            {
                return false;
            }
            else
            {
                for (int i = 3; i <= (int)Math.Sqrt(number); i += 2)
                {
                    if (number % i == 0)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}



/*
 * 
 * ・最小の素数 2
 * ・最大の素数 50022
 * 
 */

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:8:9: error: 'readonly' does not name a type
    8 |         readonly static int MAX_NUMBER = 50022;
      |         ^~~~~~~~
a.cc:10:26: error: 'string' has not been declared
   10 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:10:35: error: expected ',' or '...' before 'args'
   10 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:75:6: error: expected ';' after class definition
   75 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)':
a.cc:12:13: error: 'List' was not declared in this scope
   12 |             List<int> primeList = new List<int>();
      |             ^~~~
a.cc:12:18: error: expected primary-expression before 'int'
   12 |             List<int> primeList = new List<int>();
      |                  ^~~
a.cc:13:33: error: 'MAX_NUMBER' was not declared in this scope
   13 |             for (int i = 1; i < MAX_NUMBER; i++)
      |                                 ^~~~~~~~~~
a.cc:17:21: error: 'primeList' was not declared in this scope
   17 |                     primeList.Add(i);
      |                     ^~~~~~~~~
a.cc:23:17: error: 'var' was not declared in this scope
   23 |                 var input = Console.ReadLine();
      |                 ^~~
a.cc:24:21: error: 'string' was not declared in this scope
   24 |                 if (string.IsNullOrEmpty(input)) { break; }
      |                     ^~~~~~
a.cc:24:42: error: 'input' was not declared in this scope; did you mean 'int'?
   24 |                 if (string.IsNullOrEmpty(input)) { break; }
      |                                          ^~~~~
      |                                          int
a.cc:25:30: error: expected primary-expression before 'int'
   25 |                 int number = int.Parse(input);
      |                              ^~~
a.cc:29:30: error: expected ')' before 'primeNumber'
   29 |                 foreach (var primeNumber in primeList)
      |                              ^~~~~~~~~~~
a.cc:29:25: note: to match this '('
   29 |                 foreach (var primeNumber in primeList)
      |                         ^
a.cc:29:17: error: 'foreach' was not declared in this scope
   29 |                 foreach (var primeNumber in primeList)
      |                 ^~~~~~~
a.cc:45:17: error: 'Console' was not declared in this scope
   45 |                 Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber);
      |                 ^~~~~~~
a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)':
a.cc:65:43: error: 'Math' was not declared in this scope
   65 |                 for (int i = 3; i <= (int)Math.Sqrt(number); i += 2)
      |                                           ^~~~