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>
using namespace std;

int main(){
  int n;
  vector<int> result;

  while(1){
    int count=0;
    cin>>n;
    if(n==0) break;  

    for(int i=n+1;i<=2*n;++i){
      for(int j=3;j<=i;++j){
	if(j==i) count++;
	if(i%j==0) break;
      }
    }
    result.push_back(count);
  }
  
  for(auto i:result){
    cout<<i<<endl;
  }
}

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

bool isYes(char input[]);

int main()
{
	char Input[1000];bool yesno[1000000];
	int i=0;
	while(true){
		cin.getline(Input, sizeof(Input));
		yesno[i] = isYes(Input);
		if(Input[0] == '.') break;
		i++;
	}
	for(int j=0; j<i; j++){
		if(yesno[i]){
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	cin.get();
	return 0;
}

bool isYes(char Input[])
{
	int prep[50], prepnum=0, p=3;
	for(int i=0; Input[i]!='.'; i++){
		if(Input[i] == '('){
			if(p != 3){
				prep[prepnum] = p;
				prepnum++;
			}
			p=0;
		} else if(Input[i] == '['){
			if(p != 3){
				prep[prepnum] = p;
				prepnum++;
			}
			p=1;
		} else if(Input[i] == ')'){
			if(p!=0){
				return false;
			} else {
				if(prepnum==0) p=3;
				else {
					p = prep[prepnum-1];
					prepnum--;
				}
			}
		} else if(Input[i] == ']'){
			if(p!=1){
				return false;
			} else {
				if(prepnum==0) p=3;
				else {
					p = prep[prepnum-1];
					prepnum--;
				}
			}
		}
	}
	return true;
}

C++: #include<string>
#include<stack>
#include<iostream>
using namespace std;
int main(){
	string s;
	while(getline(cin,s),!(s[0]=='.'&&s.size()==1)){
		int a=0,b=0;
		stack<int> t;
		bool flag=true;
		for(int i=0;i<s.size();i++){
			if(s[i]=='('){
				t.push(s[i]);
			}else if(s[i]==')'){
				if(t.empty()||t.top()!='('){
					flag=false;
				}else
				t.pop();
			}else if(s[i]=='['){
				t.push(s[i]);
			}else if(s[i]==']'){
				if(t.empty()||t.top()!='['){
					flag=false;
				}else
				t.pop();
			}
		}
		
		
		if(flag&&!t.size())
		cout<<"yes"<<endl;
		else
		cout<<"no"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

string s;

int main(){
	while(cin>>s,s!="."){
		stack<int> S;
		int ok=1;
		rep(i,s.sz){
			if(s[i]=='(')S.push(0);
			if(s[i]=='[')S.push(1);
			if(s[i]==')'){
				if(!S.sz||S.top()==1){ok=0;break;}
				S.pop();
			}
			if(s[i]==']'){
				if(!S.sz||S.top()==0){ok=0;break;}
				S.pop();
			}
		}
		cout<<(ok&&!S.sz?"yes":"no")<<endl;
	}
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<stack>

using namespace std;

#define INF 999999999

int main(){
	int i, j;
	char s[101];
	stack<int> st;
	int flag;
	
	while(1){
		fgets(s, 101, stdin);
		if(s[0]=='.')break;
		flag = 1;
		while(!st.empty()) st.pop();
		
		for(i=0;s[i]!='\0';i++){
			if(s[i]=='(') st.push(1);
			else if(s[i]=='[') st.push(2);
			else if(s[i]==')'){
				if(!st.empty()&&st.top()==1){
					st.pop();
				}
				else {
					flag = 0;
					break;
				}
			}
			else if(s[i]==']'){
				if(!st.empty()&&st.top()==2){
					st.pop();
				}
				else {
					flag = 0;
					break;
				}
			}
		}
		
		if(flag && st.empty()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cctype>
#include <complex>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1<<30;
const int EPS = 1e-15;
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int > Pii;
int main(){
	while(true){
		string str;
		getline(cin,str);
		if(str.size() == 1 && str == ".")break;
		stack<char> state;
		bool flg = true;
		rep(i,str.size()){
			if(str[i] == '(' || str[i] == '['){
				state.push(str[i]);
			}
			else if(str[i] == ')'){
				if(state.size()==0 || state.top() != '('){
					flg =  false;
					break;
				}
				else{
					state.pop();
				}
			}
			else if(str[i] == ']'){
				if(state.size()==0 || state.top() != '['){
					flg =  false;
					break;
				}
				else{
					state.pop();
				}
			}
		}
		if(state.size() != 0)flg = false;
		flg ? puts("yes") : puts("no");
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	while(1){
		string str;
		bool ok=true;
		getline(cin, str);
		//debug(str);
		if (str.length()==1 && str[0]=='.') break;
		stack<int> po;
		for (int i=0; i<str.length(); i++){
			if (str[i]=='(') po.push(0);
			else if (str[i]=='[') po.push(1);
			else if (str[i]==')'){
				if (po.size()>0 && po.top()==0){
					po.pop();
				}else{
					printf("no\n");
					ok = false;
					break;
				}
			}else if (str[i]==']'){
				if (po.size()>0 && po.top()==1){
					po.pop();
				}else{
					printf("no\n");
					ok = false;
					break;
				}
			}
		}
		
		if (po.size()>0){
			printf("no\n");
			ok = false;
		}
		if (ok) printf("yes\n");
		
	}
	return 0;
}