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++: //Name: Expression
//Level: 3
//Category: ツ全ツ探ツ催オ,ツ青板篠ョ
//Note:

/*
 * ツ古」ツ置ツ記ツ法ツづ構ツ青ャツつオツつスツ青板篠ョツづーツ全ツ探ツ催オツつキツづゥツ。
 */

#include <iostream>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;

const char *opchr = "+-*";

int eval(int lhs, int op, int rhs) {
    switch(op) {
        case 0: return lhs+rhs;
        case 1: return lhs-rhs;
        case 2: return lhs*rhs;
    }
    return 0;
}

int main() {
    while(true) {
        int ns[4];
        for(int i = 0; i < 4; ++i) cin >> ns[i];
        if(!ns[0] && !ns[1] && !ns[2] && !ns[3]) break;

        sort(ns, ns+4);
        do {
            for(int pat = 0; pat < 27; ++pat) {
                int oppos[6] = {0};
                oppos[3] = oppos[4] = oppos[5] = 1;
                do {
                    int opn = 0;
                    int div = 1;
                    stack<int> s;
                    stack<string> hist;
                    for(int i = 0; i < 4; ++i) {
                        s.push(ns[i]);
                        string numstr;
                        numstr += ns[i]+'0';
                        hist.push(numstr);
                        for(int j = 0; j < i; ++j)
                            if(oppos[opn+j]) {
                                if(s.size() < 2) goto next_patperm;
                                int lhs = s.top(); s.pop();
                                int rhs = s.top(); s.pop();
                                s.push(eval(lhs, pat/div%3, rhs));
                                string lhse = hist.top(); hist.pop();
                                string rhse = hist.top(); hist.pop();
                                hist.push("(" + lhse + opchr[pat/div%3] + rhse + ")");
                                div *= 3;
                            }
                        opn += i;
                    }
                    if(s.top() == 10) {
                        cout << hist.top() << endl;
                        goto next;
                    }
next_patperm:
                    ;
                } while(next_permutation(oppos, oppos+6));
            }
        } while(next_permutation(ns, ns+4));
        cout << 0 << endl;
next:
        ;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
#define Int int
using namespace std;

const int MAX_NUM = 500000;
bool prime_number[MAX_NUM];
 
void isPrime() {
    fill(prime_number, prime_number + MAX_NUM, true);
    prime_number[0] = prime_number[1] = false;
 
    for(int i = 2; i < MAX_NUM; i++) {
        if(prime_number[i])
        for(int j = 2; i*j < MAX_NUM; j++) {
            prime_number[i*j] = false;
        }
    }
}
int main(void){
  int n;
  isPrime();
  while(cin>>n){
    int i;

    for(i = (!prime_number[n]?n:n-1) ; !prime_number[i] ; i --);
    cout<<i<<" ";
    for(i = (!prime_number[n]?n:n+1) ; !prime_number[i] ; i ++);
    cout<<i<<endl;
  }
}

C++: //Name: Puzzle
//Level: 2
//Category: V~[V,[³DæTõ,STõ
//Note:

/*
 * ÌÒ¿»èB
 * »ê¼êÌvðÁ¦ÄÝÄAðÉÈé©»è·êÎæ¢B
 * »èÍªðÅÉæÁÄAÉ4ñqAqÌæè©½ðSTõ·éB
 */
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool rec(vector<int> &v, int level) {
    if(level == 5) return true;
    //ª
    if(level == 0) {
        for(int i = 0; i < v.size(); ++i) {
            if(v[i] >= 2) {
                v[i] -= 2;
                if(rec(v, level+1)) return true;
                v[i] += 2;
            }
        }
    }
    else {
        //q
        for(int i = 0; i < v.size()-2; ++i) {
            if(v[i] >= 1 && v[i+1] >= 1 && v[i+2] >= 1) {
                v[i]--; v[i+1]--; v[i+2]--;
                if(rec(v, level+1)) return true;
                v[i]++; v[i+1]++; v[i+2]++;
            }
        }
        //q
        for(int i = 0; i < v.size(); ++i) {
            if(v[i] >= 3) {
                v[i] -= 3;
                if(rec(v, level+1)) return true;
                v[i] += 3;
            }
        }
    }
    return false;
}

bool check(const vector<int> &v) {
    vector<int> tmp = v;
    return rec(tmp, 0);
}


int main() {
    string line;
    while(cin >> line) {
        vector<int> cnt(9, 0);
        for(int i = 0; i < line.size(); ++i)
            cnt[line[i]-'1']++;
        vector<int> v;
        for(int i = 1; i <= 9; ++i) {
            if(cnt[i-1] == 4) continue;
            cnt[i-1]++;
            if(check(cnt)) v.push_back(i);
            cnt[i-1]--;
        }
        if(v.size() == 0) v.push_back(0);
        for(int i = 0; i < v.size(); ++i) {
            if(i > 0) cout << ' ';
            cout << v[i];
        }
        cout << endl;
    }
    return 0;
}

C++: //0044 Prime Number II

#include<cstdio>
#include<cmath>
using namespace std;

bool isPrime(int x)
{
	if(x <= 3)
		return true;
	if((x&1) == 0)
		return false;
	for(int i = 3; i*i <= x; i++)
	{
		if(x%i==0)
			return false;
	}
	return true;
}

int main(void)
{
	int n;
	int i;
	while(scanf("%d", &n) == 1)
	{
		for(i = n-1; i>= 2; i--)
		{
			if(isPrime(i))
			{
				printf("%d ", i);
				break;
			}
		}
		for(i = n+1; ; i++)
		{
			if(isPrime(i))
			{
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

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

bool is_prime(int n){
  if(n<=1)
    return false;

  for(int i=2; i*i<=n; i++){
    if(n%i==0){
      return false;
    }
  }

  return true;
}


int main(){
  while(true){
    int next=0;
    int prev=0;

    int n;
    cin >> n;

    if(cin.eof())
      break;

    for(int i=n+1; i<=50023; i++){
      if(is_prime(i)){
        next=i;
        break;
      }
    }
    for(int i=n-1; i>=2; i--){
      if(is_prime(i)){
        prev=i;
        break;
      }
    }

    cout << prev << ' ' << next <<endl;
  }

  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;
	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[i] = i;
	}
}

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

		for(int i = n + 1; i < 60000; i++){
			if(table[i] != 0){
				cout << table[i] << endl;
				break;
			}
		}
	}

	return 0;
}