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 <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=1<<30;
const double pi=acos(-1);

int n;
vi sosu;

int nibu(int s,int t,int x){
	if(t-s==1) return s;
	int k=(s+t)/2;
	if(sosu[k]>x) return nibu(s,k,x);
	else return nibu(k,t,x);
}

int main(){
	vector<bool> used(50005,1);
	for(int i=2;i<50000;i++){
		if(used[i]){
			sosu.push_back(i);
			for(int j=i+i;j<=50000;j+=i) used[j]=0;
		}
	}
	while(cin>>n){
		int tmp=nibu(0,sosu.size(),n);
		if(sosu[tmp]==n) cout<<sosu[tmp-1]<<' '<<sosu[tmp+1]<<endl;
		else cout<<sosu[tmp]<<' '<<sosu[tmp+1]<<endl;
	}
}

C++: #include <bits/stdc++.h>  

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define PRIM 50021

bool prim[50022];
int a_prime[50022];

int main(){
	memset(prim, true, sizeof(prim));
	int N;
	prim[0] = false;
	FOR(i, 1, sqrt(PRIM)) {
		if(prim[i]) {
			for(int j = (i + 1); (i + 1) * j <= PRIM; ++j) {
				prim[(i + 1) * j - 1] = false;
			}
		}
	}
	while(cin >> N) {
		repr(i, N - 2) {
			if(prim[i]){
				printf("%d ", i + 1);
				break;
			}
		}
		FOR(i, N, PRIM) {
			if(prim[i]) {
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int hyou[50100] = {1};
	for (int i = 1; i < 50100; i++) {
		if (hyou[i] == 0) {
			for (int j = 2; (i+1) * j < 50100; j++) {
				hyou[(i+1)*j-1] = 1;
			}
		}
	}
	while (cin >> n) {
		for(int i = n-2; i >= 0; i--) {
			if (hyou[i] == 0) {
				cout << i+1 << " ";
				break;
			}
		}
		for (int i = n; i < 50100; i++) {
			if (hyou[i] == 0) {
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;

}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int check[60000] = {0};

    int flg = 0;
    for(int i = 3;i <= 60000; i+=2){
        flg = 1;
        for(int j = 2;j*j <= i; j++){
            if(i%j == 0){
                flg = 0;
                break;
            }
        }
        if(flg == 1)check[i] = 1;
    }
    check[2] = 1;

    int n;
    while(scanf("%d",&n) != EOF){
        for(int i = n-1;i > 0;i--){
            if(check[i] == 1){
                printf("%d ",i);
                break;
            }
        }
        for(int i = n+1;i <= 60000;i++){
            if(check[i] == 1){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

void tamesiwari(int *table, int n){
	table[1] = 1;
	table[2] = 2;
	int count = 3;
	for(int i = 3; i < n; i += 2){
		bool ok = true;
		for(int j = 3; i >= (j * j); j += 2){
			if(i % j == 0) ok = false;
		}
		if(ok) table[count++] = i;
	}
}

int main(){
	int table[50000] = {0};
	tamesiwari(table, 50000);
	int n = 0;
	while(cin >> n){
		if(cin.eof()) break;
		
		for(int i = 0; i < 50000; i++){
			if(table[i] == n){
				cout << table[i - 1] << " " << table[i + 1] << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<string.h>

using namespace std;

int main(){

  int putin;
  int n;
  int i,j;
  int tap;
  int number[50000];

  for(i=0; i<50001; i++){
    number[i] = 1;
  }

  number[0]=0;
  number[1]=0;
  number[2]=0;

  for(i=2; i<50000; i++){
    for(j=2; j<50000; j++){
      tap=i*j;
      if(tap>=50000){
	break;
      } else {
	number[tap] = {0};
      }
    }
  }

  cin >> putin;

  for(n=putin-1; n>0; n--){
    if(number[n]!=0){
      cout << n << " ";
      break;
    }
  }

  for(n=putin+1; n<50000; n++){
    if(number[n]!=0){
      cout << n << endl;
      break;
    }
  } 
}

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(50001) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i=2; i<=50000; i++)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j=2*i; j<=50000; 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 <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

bool is_prime[50050];
int prime[50050];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i < 50050; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j < 50050; j += i)is_prime[j] = false;
		}
	}
	int n;
	while (cin >> n) {
		int i = lower_bound(prime, prime + p, n) - prime;
		cout << prime[i - 1] << ' ' << (prime[i] == n ? prime[i + 1] : prime[i]) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main() {
	bool RB[60000];int j,i;for (i=0;i<60000;RB[i++]=true);for (i=2;i*i<=60000;i++) if (RB[i]) for (j=i*i;j<=60000;j+=i) RB[j]=false;
	while (scanf("%d",&j)!=EOF) {for (i=j-1;!RB[i];i--);printf("%d ",i);for (i=j+1;!RB[i];i++);printf("%d\n",i);}return 0;}

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

int primemax(int m);
int primemin(int m);

int main() {
	int n;
	while (scanf("%d",&n) != EOF) {
		cout << primemax(n - 1) << " " << primemin(n + 1) << endl;
	}
}

int primemax(int m) {
	int result = 0;
		while (true) {
		for (int i = m; ; i--) {
			for (int j = sqrt(i)+1;; j--) {
				if ((i%j)==0)break;
				if (j == 2) { result = i; return result; }
			}
		}
	}
}


int primemin(int m) {
	int result = 0;
		while (1) {
			for (int i = m; ; i++) {
				for (int j = sqrt(i)+1; ; j--) {
					if ((i%j)==0)break;
					if (j == 2) { result = i; return result; }
				}
			}
		}
}