Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Buffer(make([]byte, 0), 1000000009)

	for {
		var s string
		s = nextString()
		if s == "." {
			break
		}
		var st []byte
		is_valid := true

		for _, value := range s {
			if value == '(' {
				st = append(st, byte(value))
			}
			if value == '[' {
				st = append(st, byte(value))
			}
			if value == ')' {
				if len(st) == 0 || st[len(st)-1] != '(' {
					is_valid = false
					break
				} else {
					st = st[:len(st)-1]
				}
			}
			if value == ']' {
				if len(st) == 0 || st[len(st)-1] != '[' {
					is_valid = false
					break
				} else {
					st = st[:len(st)-1]
				}
			}
		}
		if len(st) != 0 {
			is_valid = false
		}
		if is_valid {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	string in = "";
	while (getline (cin, in ) && in != "." ){
		stack<char> kakko;
		bool ok = true;
		rep (i, in.size() ){
			if (in[i] == '[' || in[i] == '(' ){
				kakko.push(in[i] );
			}else
			if (in[i] == ']' ){
				if (!kakko.empty() && kakko.top() == '[' ){
					kakko.pop();
				}else{
					ok = false;
				} // end if
			}else
			if (in[i] == ')' ){
				if (!kakko.empty() && kakko.top() == '(' ){
					kakko.pop();
				}else{
					ok = false;
				} // end if
			} // end if
		} // end rep

		if (!kakko.empty() ) ok = false;

		if (ok ){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		} // end if

	} // end while	
		
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <stack>

using namespace std;

bool ok (string s)
{
    stack<char> stk;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i]=='(') stk.push('(');
        if (s[i]=='[') stk.push('[');
        if (s[i]==')')
        {
            if (stk.empty()) return false;
            else if (stk.top()!='(') return false;
            else stk.pop();
        }
        if (s[i]==']')
        {
            if (stk.empty()) return false;
            else if (stk.top()!='[') return false;
            else stk.pop();
        }
    }
    if (stk.empty()) return true;
    else return false;
}

int main()
{
    vector<bool> f;
    string t;
    while (1)
    {
        getline(cin, t);
        if (t==".") break;
        f.push_back(ok(t));
    }
    for (int i=0; i<f.size(); i++) cout<<(f[i]? "yes\n" : "no\n");
    return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	
	while(1){
		string str;
		getline(cin , str);
		stack<char> s;
		int cnt=0,cnt2=0,flag=1;
		
		if(str=="."){
			break;
		}

		for(int i=0;i<str.size();i++){
			if(str[i]=='('||str[i]=='['){
				s.push(str[i]);
				cnt++;
			}

			if(str[i]==')'){
				if(cnt==0){
					flag=0;
					break;
				}
				if(s.top()=='('){
					cnt2++;
					s.pop();
				}else{
					flag=0;
					break;
				}
			}

			if(str[i]==']'){
				if(cnt==0){
					flag=0;
					break;
				}
				if(s.top()=='['){
					cnt2++;
					s.pop();
				}else{
					flag=0;
					break;
				}
			}
		}

		if(cnt==cnt2&&flag==1){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}	
	}
	return 0;
}

C++: #include <iostream>
#include <stack>
#include <string>

using namespace std;

const string Terminater = ".";

bool isOK(string& str)
{
	stack<char> st;
	for (char& c : str)
	{
		if (c == '(' || c == '[')
			st.push(c);

		if (c == ')')
		{

			if ( !st.empty() && '(' == st.top())
				st.pop();
			else
				return false;
		}
		else if (c == ']')
		{
			if (!st.empty() && '[' == st.top())
				st.pop();
			else
				return false;
		}
	}

	if (st.empty())
		return true;

	return false;
}

int main()
{
	while (1)
	{
		string str;
		getline(cin, str);

		if (str == Terminater)
			break;

		if (isOK(str))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<stack>

using namespace std;

int main() {
    while(1) {
        string s;
        getline(cin, s);

        if (s == ".") break;
        string b = "";
        for (int i = 0; i < s.size(); ++i) {
            char c = s[i];
            if (c == '(' || c == ')' || c == '[' || c == ']') {
                b.push_back(c);
            }
        }
        
        stack<char> stack;
        bool ok = true;
        //cout << b << endl;
        for (int i = 0; i < b.size(); ++i) {
            switch(b[i]) {
                case '(':
                case '[':
                    stack.push(b[i]);
                break;
                case ')':
                    if (stack.empty()) {ok = false; break;}
                    if (stack.top() == '(') stack.pop();
                    else ok = false;
                break;
                case ']':
                    if (stack.empty()) {ok = false; break;}
                    if (stack.top() == '[') stack.pop();
                    else ok = false;
                break;
            }

            if (!ok) break;
            //cout << stack.size() << endl;
        }

        ok = ok && (stack.size() == 0);

        cout << (ok ? "yes" : "no") << endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  vector<int> a(250000, 1);
  a[0] = a[1] = 0;
  for(int i = 2;i*i < 250000; ++i)
    if (a[i])
      for(int j = i*i; j < 250000; j+=i)
        a[j] = 0;
  vector<int> b(124000);
  int sum = 0;
  for (int i = 1; i < 124000; ++i) {
    sum += a[2*i] + a[2*i-1];
    sum -= a[i];
    b[i] = sum;
  }
  while(1) {
    int n;
    cin >> n;
    if(!n) break;
    cout << b[n] << endl;
  }
  return 0;
}