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<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
using namespace std;

stack<char> st;

char str[514];
int slen;

int main() {
	int i;
	while( gets(str) ) {
		if ( str[0] == '.' && str[1] == '\0' )
			break;
		slen = strlen(str);
		for( i = 0; i < slen; i++ ) {
			if ( str[i] == '(' || str[i] == '[' )
				st.push(str[i]);
			if ( str[i] == ')' ) {
				if ( st.empty() || st.top() != '(' )
					break;
				st.pop();
			}
			if ( str[i] == ']' ) {
				if ( st.empty() || st.top() != '[' )
					break;
				st.pop();
			}
		}
		if ( i == slen && st.empty() )
			cout << "yes" << endl;
		else
			cout << "no" << endl;
		while(!st.empty())
			st.pop();
	}
	return 0;
}

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

int main()
{
	char str[101];
	bool flag;
	while (1){
		stack<int >st;
		cin.getline(str, 101);
		if (str[0] == '.')
			break;
		flag = true;
		for (int i = 0; i < 101; i++){
			if (str[i] == '.')
				break;
			if (str[i] == '(')
				st.push(0);
			if (str[i] == '[')
				st.push(1);
			if (str[i] == ')'){
				if (st.empty() || st.top() != 0){
					flag = false;
					break;
				}
				else
					st.pop();
			}
			if (str[i] == ']'){
				if (st.empty() || st.top() != 1){
					flag = false;
					break;
				}
				else
					st.pop();
			}
		}
		
			
		if (flag && st.empty())
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

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

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  string s;
  bool flag;
  while (getline(cin, s), s != ".") {
    flag = true;
    stack<char> kakko;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '(' || s[i] == '[') {
        kakko.push(s[i]);
      }
      if (s[i] == ')') {
        if (kakko.empty() || kakko.top() != '(') {
          flag = false;
          break;
        }
        kakko.pop();
      }
      if (s[i] == ']') {
        if (kakko.empty() || kakko.top() != '[') {
          flag = false;
          break;
        }
        kakko.pop();
      }
    }
    if (flag) cout << "yes" << el;
    else cout << "no" << el;
  }
}

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

int main(){
	
	string s ;
	
	while( getline( cin , s ) ){
		if( s[0] == '.' ) break ;
		
		stack<int> st ;
		int t = 0 ;
		
		for( int i=0 ; i<s.size() ; i++ ){
			if( s[i] == '(' ) st.push(1) ;
			if( s[i] == '[' ) st.push(2) ;
			
			if( s[i] == ')' ){
				if( st.size() > 0 && st.top() == 1 ){
					st.pop() ;
				}
				else t = 1 ;
			}
			if( s[i] == ']' ){
				if( st.size() > 0 && st.top() == 2 ){
					st.pop() ;
				}
				else t = 1 ;
			}
			
			if( t == 1 ) break ;
		}
		
		if( t == 0 ) cout << "yes" << endl ;
		else cout << "no" << endl ;
	}
	
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

const int MAXN = 300000;
int cum[MAXN];

void sieve() {
    for (int i = 0; i < MAXN; i++) cum[i] = 1;
    for (int i = 2; i < MAXN; i++) {
        if (cum[i]) {
            for (int j = 2 * i; j < MAXN; j += i) {
                cum[j] = 0;
            }
        }
    }
}

int main() {
    sieve();
    for (int i = 1; i < MAXN; i++) {
        cum[i] += cum[i - 1];
    }
    int n;
    while (cin >> n, n) {
        cout << cum[2 * n] - cum[n] << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;


char str[104];

int main(){
    while(1){
        stack<int> st;
        bool judge = true;

        for(int i=0;i<100;i++){
            cin >> str[i] ;
            if(str[i]== '.') break;
        }
        if(str[0]=='.')break;
    
        int i=0;
        while(str[i] != '.'){
            if(str[i]=='(' || str[i]=='['){
                st.push(str[i]);
            }else if(!st.empty()){
                if(str[i]==')'){
                    if(st.top() == '('){
                        st.pop();
                    }else{
                        judge = false;
                    }
                }else if(str[i]==']'){
                    if(st.top() == '['){
                        st.pop();
                    }else{
                        judge = false;
                    }
                }
            }
            if(judge==false){
                break;
            }
            i++;
        }
        if(!st.empty()){
            judge = false;
        }
        if(judge){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    while (true) {
        getline(cin, s);
//        cin.ignore();
        if (s == ".") break;

        stack<char> st;

        bool flag = true;
        for (auto e : s) {
            if (e == '[' || e == '(') {
                st.push(e);
            } else if (e == ']') {
                if (!st.empty() && st.top() == '[') {
                    st.pop();
                } else {
                    flag = false;
                    break;
                }
            } else if (e == ')') {
                if (!st.empty() && st.top() == '(') {
                    st.pop();
                } else {
                    flag = false;
                    break;
                }
            }
        }
        if(!st.empty()) flag = false;
        if (flag) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}