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 <string>

using namespace std;

int main(){
    while(true){
        // 1?????\???
        string s;
        getline(cin, s);

        // .??????????????????
        if(s == ".")
            return 0;

        // rb(round), sb(square)
        string stack = "";

        //??¨??????????????????
        for(auto &x:s){
            // ?????¬??§
            if(x == '(' || x == '[')
                // stack?????????
                stack.push_back(x);
            // ?????¬??§
            else if(x == ')' || x == ']'){
                // stack?????? ??? no
                if(stack.empty()){
                    stack.push_back('.');
                    break;
                // ??¬??§?????????????????????
                }else if(x == ')' && stack.back() == '('){
                    stack.pop_back();
                }else if(x == ']' && stack.back() == '['){
                    stack.pop_back();
                // no
                }else {
                    stack.push_back('.');
                    break;
                }
            }
        }

        // ??????0??????yes
        if(stack.empty())
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
void test(int );
int f,count,count1;
char ch[101]; 
int main(){
  while(1){
    int j=0;
    while(1){
      scanf("%c",&ch[j]);
      if(ch[j]=='.')break;
      j++; 
    }
    if(j==0)break;
    int count=0,count1=0;
    for(int i=0;i<j;i++){
      if(count1<0||count<0||f==1)break; 

      if(ch[i]=='[')count++;
      else if(ch[i]=='(')count1++;
      else if(ch[i]==']')test(i);
      else if(ch[i]==')')test(i);
    }
    if(count==0&&count1==0)cout<<"yes"<<endl;
    else cout<<"no"<<endl;  
    char a;
    scanf("%c",&a);
  }
  return 0;
}

void test(int x){
  f=0;
  int count2;
  if(ch[x]==')'){
    count1--;
    for(int i=x-1;i>=0;i--)
      if(ch[i]=='('){
	count2=0;
	for(int j=x-1;j>i;i++)
	  if(ch[i]=='[')count2++;
	  else if(ch[i]==']')count2--;
	if(count2>=1)f=1;
      }
  }
  else{
    count--;
    for(int i=x-1;i>=0;i--)
      if(ch[i]=='['){
	count2=0;
	for(int j=x-1;j>i;i++)
	  if(ch[i]=='(')count2++;
	  else if(ch[i]==')')count2--;
	if(count2>=1)f=1;
      }
  }
}

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<string>
#include<stack>
using namespace std;

int main(){
  stack<int> p;
  string str;
  bool a;
  while(1){
    getline(cin,str);
    a = true;
    if(str == ".") break;
    for(int i=0;i<str.length();i++){
      char ch = str[i];
      if(ch == '(') p.push(1);
      if(ch == '[') p.push(2);
      if(ch == ')'){
        if(p.empty()){
          a = false;
          break;
        }
        if(p.top() == 1){
          p.pop();
        } else{
          a = false;
          break;
        }
      }
      if(ch == ']'){
        if(p.empty()){
          a = false;
          break;
        }
        if(p.top() == 2){
          p.pop();
        }else{
          a = false;
          break;
        }
      }
    }
    cout << (a?"yes":"no");
    while(!p.empty()){
      p.pop();
    }
    cout << endl;
  }
  return 0;
}

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=2;j<=i;++j){
	if(j==i) count++;
	if(i%j==0) break;
      }
    }
    result.push_back(count);
  }
  
  for(auto i:result){
    cout<<i<<endl;
  }
}