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++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
while(1){
    int main(){
        int N;
        cin>> N;
        vector<string>U(N);
        for(auto &a : U){
            cin >>a;
        }
        int M;
        cin >>M;
        int flag=0,auth;
        for(int i=0;i<M;i++){
            string s;
            cin >>s;
            auth=0;
            for(int j=0;j<N;j++){
                if(U[j]==s){
                    if(flag==0){
                        cout<<"Opened by "<<s<<endl;
                        flag=1;
                    }
                    else{
                        cout<<"Closed by "<<s<<endl;
                        flag=0;
                    }
                    auth=1;
                    break;
                }
                if(auth)break;
            }
            if(auth==0)cout<<"Unknown "<<s<<endl;
        }
        return 0;
    }
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  string msg[3] = {
	"Opened by ",
	"Closed by ",
	"Unknown "
  };
  int t = 0;
  set<string> s;
  int N, M; cin >> N;
  REP(i,N){ string x; cin >> x; s.insert(x);}
  cin >> M;
  REP(i,M){
	string in; cin >> in;
	if(s.find(in) != s.end()){
	  cout << msg[t] << in << endl;
	  t = 1 - t;
	}
	else
	  cout << msg[2] << in << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string str[100];
	for(int i = 0; i < n; i++){
		cin >> str[i];
	}
	int m;
	cin >> m;
	int cnt=0;
	for(int j = 0; j < m; j++){
		string str2;
		cin >> str2;
		for(int k = 0; k < n; k++){
			if(str[k] == str2){
				cnt++;
				if(cnt % 2 == 1) cout << "Opened by " << str2 << endl;
				else cout << "Closed by " << str2 << endl;
				break;
			}
			if(k == n-1){
				cout << "Unknown " << str2 << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
using namespace std;
string mes[2] = {"Closed by ","Opened by "};
int main(){
  int n,m;
  cin >> n;
  vector<string> u(n);
  set<string> U;
  for(int i = 0;i < n;i++){
    cin >> u[i];
    U.insert(u[i]);
  }
  cin >> m;
  vector<string> t(m);
  int current = 0;//しまっている
  for(int i = 0;i < m;i++){
    cin >> t[i];
    if(U.find(t[i]) == U.end()){
      cout << "Unknown " << t[i] << endl;
    }else{
      current = (current + 1)%2;
      cout << mes[current] << t[i] << endl;
    }
  }
 
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int n, m;
string id[1000];

int main()
{
	cin >> n;
	REP(i, n) cin >> id[i];
	cin >> m;
	string s;
	bool rock = false;
	REP(i, m)
	{
		bool flag = false;
		cin >> s;
		REP(i, n) if (s == id[i]) flag = true;
		if (flag)
		{
			if (rock == false) cout << "Opened by ";
			else cout << "Closed by ";
			cout << s << endl;
			rock = !rock;
		}
		else cout << "Unknown " << s << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n, m;
	// door[id] := id があるときは true を返す.
	// idが存在するかどうかのチェックは door.count(id)
	map<string,bool> door;
	// is_open := ドアが開いているかどうか.
	bool is_open = false;
	cin >> n;
	for(int i = 0 ; i < n ; i++ ){
		string u;
		cin >> u;
		door[u] = true;
	}
	cin >> m;
	for(int i = 0 ; i < m ; i++ ){
		string t;
		cin >> t;
		
		if( door.count(t) ){ // id が存在するとき
			if( is_open ){ // ドアが開いているときは施錠される
				cout << "Closed by " << t << endl;
				is_open = false;
			}else{
				cout << "Opened by " << t << endl;
				is_open = true;
			}
		}else{ // id が存在しないとき
			cout << "Unknown " << t << endl;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  int m;
  cin>>m;
  bool ans=false;
  string str;
  rep(i,m){
    cin>>str;
    rep(j,n)if(str==s[j]){
      if(ans){
	cout<<"Closed by "<<str<<endl;
	ans=false;
	goto END;
      }else{
	cout<<"Opened by "<<str<<endl;
	ans=true;
	goto END;
      }
    }
    cout<<"Unknown "<<str<<endl;
  END:;
  }
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string str;
	for(int i = 0; i < n; i++){
		string str1;
		cin >> str1;
		str += '#';
		str += str1;
	}
	int m;
	cin >> m;
	int cnt=0;
	for(int j = 0; j < m; j++){
		string str2;
		cin >> str2;
		if(str.find(str2) != -1){
			cnt++;
			if(cnt % 2 == 1) cout << "Opened by " << str2 << endl;
			else cout << "Closed by " << str2 << endl;
		} else {
			cout << "Unknown " << str2 << endl;
		}
	}
	return 0;
}