Go: package main

import "fmt"

func main() {
    var n, m int
    fmt.Scan(&n)

    u := make([]string, 300)

    for i := 0; i < n; i++ {
        fmt.Scan(&u[i])
    }

    fmt.Scan(&m)

    is_lock := true
    for i := 0; i < m; i++ {
        var t string
        fmt.Scan(&t)

        is_include := false
        for j := 0; j < n; j++ {
            if t == u[j] {
                is_include = true
                break
            }
        }
        if is_include == false {
            fmt.Printf("Unknown %s\n", t)
        } else if (is_lock) {
            fmt.Printf("Opened by %s\n", t)
            is_lock = false
        } else {
            fmt.Printf("Closed by %s\n", t)
            is_lock = true
        }
    }
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2440

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int output(int isLock, string id, vector<string> id_list)
{
	bool flag=false;

	rep(i,id_list.size()){
		if(id_list[i] == id){flag=true;}
	}

	if(flag){
		if(isLock < 0){
			cout << "Opened by " << id << endl;
			return isLock*-1;
		}else{
			cout << "Closed by " << id << endl;
			return isLock*-1;
		}
	}else{
		cout << "UnKnown " << id << endl;
		return isLock;
	}

}

int main() {
	
	int N,M;
	int isLock=-1;
	vector<string> id_list;

	cin >> N;
	string id;
	rep(i,N){
		cin >> id;
		id_list.push_back(id);
	}

	cin >> M;
	rep(i,M){
		cin >> id;
		isLock = output(isLock, id, id_list);
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#define OPEN 1
#define CLOSE 0
using namespace std;

int main() {
  int n;
  cin >> n;
  string u[n];
  for (int i = 0; i < n; i++)
    cin >> u[i];

  int m;
  cin >> m;
  int status = CLOSE;
  for (int i = 0; i < m; i++) {
    string t;
    cin >> t;
    int j;
    for (j = 0; j < n; j++) {
      if (t == u[j]) {
	if (status == CLOSE) {
	  cout << "Opened by " << t << endl;
	  status = OPEN;
	} else {
	  cout << "Closed by " << t << endl;
	  status = CLOSE;
	}
	break;
      }
    }
    if (j == n)	cout << "Unknown " << t << endl;
  }
}

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

enum State {
  Opened,
  Closed
};

int main(int argc, char const* argv[])
{
  int N;
  std::cin >> N;
  std::vector<std::string> members(N);
  for (int i = 0; i < N; ++i)
    std::cin >> members[i];
  int M;
  std::cin >> M;
  State st = Closed;
  for (int i = 0; i < M; ++i) {
    std::string s;
    std::cin >> s;
    if (std::find(members.begin(), members.end(), s) == members.end()) {
      std::cout << "Unknown " << s << std::endl;
    } else {
      if (st == Closed) {
        std::cout << "Opened by " << s << std::endl;
        st = Opened;
      } else {
        std::cout << "Closed by " << s << std::endl;
        st = Closed;
      }
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int registered_num,enter_num;
  while(~scanf("%d",&registered_num)){
    map<string,bool> table;
    for(int i=0;i<registered_num;i++){
      string key;
      cin >> key;
      table[key] = true;
    }
    scanf("%d",&enter_num);
    int count = 0;
    for(int i=0;i<enter_num;i++){
      string key;
      cin >> key;
      if(table.find(key) == table.end()){
	// Unknown abcc
	printf("%s %s\n","Unknown",key.c_str());
      }
      else{
	// Opened by abcd
	// Closed by efgh	
	printf("%s by %s\n",(count % 2 == 0) ? "Opened" : "Closed",key.c_str());
	count++;
      }
    }
  }
}

C++: #include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
#include <cstring>
using namespace std;

const int INF = 1 << 30;
const double EPS = 1e-10;

int main()
{
  int N;
  while (cin >> N) {
    set<string> U;
    for (int i = 0; i < N; ++i) {
      string s;
      cin >> s;
      U.insert(s);
    }

    int M;
    cin >> M;
    bool open = false;
    for (int i = 0; i < M; ++i) {
      string T;
      cin >> T;
      
      if (U.find(T) == U.end()) {
        cout << "Unknown " << T << endl;
      } else {
        if (open) {
          cout << "Closed by ";
          open = false;
        } else {
          cout << "Opened by ";
          open = true;
        }
        cout << T << endl;
      }
    }


  }
  return 0;
}

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

int main(){
	int n,m;
	cin>>n;
	
	vector<string>v;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		v.push_back(s);
		}
		
		cin>>m;
		int flg=0;
		for(int j=0;j<m;j++){
			string s;
			cin>>s;
			int match=0;
			for(int i=0;i<n;i++){
				if(s==v[i]){
					match=1;
					break;
					}
				}
				
			if(match==0)cout<<"Unknown "<<s<<endl;
			else{
				if(flg==0){
					cout<<"Opened by "<<s<<endl;
					flg=1;
					}
				else{
					cout<<"Closed by "<<s<<endl;
					flg=0;
					}	
				}	
			}
			return 0;
	}

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



int main(){
	
	int n,m;
	map <string,int>mp;
	int o=0;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]=1;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		string s;
		cin>>s;
		if(mp[s]){
			if(o==0){
				o=1;
				cout<<"Opened by "<<s<<endl;
			}else{
				o=0;
				cout<<"Closed by "<<s<<endl;
			}
			
		}else cout<<"Unknown "<<s<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n,m;
  bool open;

  cin >> n;
  string tou[200];
  REP(i,n){
	cin >> tou[i];
  }
  cin >> m;
  string kita;
  REP(i,m){
	cin >> kita;
	REP(j,n){
	  if(kita == tou[j]){
		if(open){
		  cout<<"Opened by "<<kita<<endl;
		  open = (not open);
		  break;
		}else{
		  cout<<"Closed by "<<kita<<endl;
		  open = (not open);
		  break;
		}
	  }
	  if(j==n-1)  cout<<"Unknown "<<kita<<endl;
	}
  }
}