Go: package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

const MAX = 60000
const ROOT = 250

var sc =  bufio.NewScanner(os.Stdin)

func main() {
    var isPrime [MAX]bool
    for i := 2;i < MAX; i++ {
        isPrime[i] = true
    }
    for i := 2;i < ROOT; i++ {
        if isPrime[i] {
            for j := i * i;j < MAX; j+=i {
                isPrime[j] = false
            }
        }
    }
    var minPrime [MAX]int
    var maxPrime [MAX]int
    min := -1
    for i := 0;i < MAX; i++ {
        minPrime[i] = min
        if isPrime[i] {
            min = i
        }
    }
    max := -1
    for i := MAX - 1; i >= 0; i-- {
        maxPrime[i] = max
        if isPrime[i] {
            max = i
        }
    }

    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Printf("%d %d\n", minPrime[n], maxPrime[n])
    }
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#define p(n) pow(n,2)
using namespace std;
int main(){
  int n,a,b;
  vector<int> v;
  bool f;
  v.push_back(2);
  for(int i=3;i<=50000;i+=2){
    f = true;
    for(int j=0;pow(v[j],2)<=i;j++){
	if(!(i%v[j])){f=false;break;}
    }
    if(f)v.push_back(i),cout<<i<<endl;
  }
  v.push_back(50021);
  while(cin>>n){
    if(cin.eof())return 0;
    vector<int>::iterator it = v.begin();
    while(it!=v.end()){
      if(n<*it){
	a=(n==*(it-1))?*(it-2):*(it-1);
	b=*it;
	cout<<a<<" "<<b<<endl;
	break;
      }
      it++;
    }
  }
}

C++: #include<bits/stdc++.h>
using namespace std;

#define MAX_N 50010

int prime[MAX_N];
bool is_prime[MAX_N + 1];

void sieve(int n){
	int p = 0;
	for(int i = 0; i <= MAX_N; i++) is_prime[i] = true;

	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= MAX_N; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2 * i; j <= MAX_N; j += i) is_prime[j] = false;
		}
	}


	for(int i = 0; i < MAX_N; i++){

		if(prime[i] >= n){
			cout << prime[i-1] << " ";
			i++;
		}
		if(prime[i] > n){
			cout << prime[i] << endl;
			break;
		}
	}
}

int main(){
	int n;
	while(cin >> n){
		sieve(n);
	}
}

C++: //Prime Number ?
#include<bits/stdc++.h>
using namespace std;

vector<int> p;

int main(){
  int n;
  p.push_back(2);
  for(int i=3; i<=60000; i+=2){
    bool flag=true;
    for(int j=0; j<p.size(); j++){
      if(i%p[j]==0){
        flag=false;
        break;
      }
    }
    if(flag) p.push_back(i);
  }
  while(cin>>n){
    int i;
    for(i=0; i<p.size(); i++){
      if(n<p[i])break;
    }
    cout<<(n==p[i-1] ? p[i-2] : p[i-1])<<' '<<p[i]<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 1000000;

#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)

typedef long long ll;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/


int prime[50000];
bool is_prime[50001];


void sieve(void)
{
	int p = 0;
	
	REP(60000) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i=2; i<60000; i++)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j=2*i; j<60000; j+=i) is_prime[j] = false;
		}
	}
}


int main()
{
	int n, less, more;
	
	sieve();
	
	while (cin >> n)
	{
		for (int i=0; i<50000; i++)
		{
			if (prime[i] > n)
			{
				more = prime[i];
				break;
			}
		}
		
		for (int i=0; i<50000; i++)
		{
			if (prime[i] >= n)
			{
				less = prime[i - 1];
				break;
			}
		}
		
		cout << less << " " << more << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


bool prime[50050];
vector <int> pri;

int main(){
	memset(prime,0,sizeof(prime));
	rep(i,50050){
		prime[i]=true;
	}
	prime[1]=false;
	prime[0]=false;
	for(int i=1;i*i<50050;i++){
		if(prime[i]){
			//cout<<i<<" ";
			for(int j=i*i;j<50050;j+=i){
				prime[j]=false;
			}
		}
	}
	rep(i,50050){
		if(prime[i]) pri.push_back(i);
	}
	int n;
	while(cin>>n){
		int smo,lar;
		rep(i,pri.size()){
			if(pri[i]<n){
			}
			else{
				if(prime[n]==true){
					smo=pri[i-1];
					lar=pri[i+1];
				}
				else{
					smo=pri[i-1];
					lar=pri[i];
				}
				break;
			}
		}
		cout<<smo<<" "<<lar<<endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;

int main(){
    int n[50001];
    memset(n,0,sizeof(n));
    for(int i=2;i<25001;i++)
        for(int j=i;i*j<50001;j++)
            n[j*i]=1;
    int f,i;
    while(cin>>f){
        for(i=f-1;n[i];i--);cout<<i<<" ";
        for(i=f+1;n[i];i++);cout<<i<<endl;
    }
}

C++: #include <iostream>
using namespace std;

bool f(int p) {
    for (int i=2; i*i<=p; i++) {
        if (p % i == 0) return false;
    }
    return true;
}

int main() {
    int N;
    while (cin >> N) {
        int p1, p2;
        for (p1=N-1; ; p1--) if (f(p1)) break;
        for (p2=N+1; ; p2++) if (f(p2)) break;
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = 50000;
bool p[MAX];
void isPrime(){
  fill(p,p + MAX,true);
  p[0] = p[1] = false;
  rep(i,MAX){
    if(p[i]){
      for(int j = i + i ; j < MAX ; j += i)
	p[j] = false;
    }
  }
} 

int main(void){
  isPrime();
  int n;
  while(cin>>n){
  int i = n-1;
  while(!p[i--]);
  cout<<++i<<' ';
  i = n + 1;
  while(!p[i++]);
  cout<<--i<<endl;
  }
  return 0;
}

C++: using System;
using System.Collections.Generic;

namespace _0044
{
    class Programｓ
    {
        static void Main(string[] args)
        {
            var primeList = new List<int>();
            for (int i = 1; i < 50022; i++)
            {
                if (IsPrime(i))
                {
                    primeList.Add(i);
                }
            }

            while (true)
            {
                var input = Console.ReadLine();

                if (string.IsNullOrEmpty(input)) { break; }

                var number = int.Parse(input);
                var previousPrimeNumber = 0;
                var nextPrimeNumber = 0;

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

                    if (nextPrimeNumber != 0)
                    {
                        break;
                    }
                }
                Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber);
            }
        }
        public 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;
        }
    }
}