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 <bits/stdc++.h>
using namespace std;
void solve(vector<string> ids,vector<string> strs){
    bool s=false,st=false;
    for(string x:strs){
        st=s;
        for(string y:ids){
            if(x==y){
                if(s){
                    s=false;
                    cout<<"Closed by "<<y<<endl;
                }
                else{
                    s=true;
                    cout<<"Opened by "<<y<<endl; 
                }
            }
        }
        if(st==s){
            cout<<"Unknown "<<x<<endl; 
        }
    }
}



int main(void){
    int a;
    string str;
    vector<string> ids,strs;
    cin>>a;
    for(int i=0;i<a;i++){
        cin >> str;
        ids.push_back(str);
    }
    cin >> a;
    for(int i=0;i<a;i++){
        cin >> str;
        strs.push_back(str);
    }
    solve(ids,strs);
}

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

struct DOOR{
	string id;
};

int find_door(string id, vector<DOOR> doors) {
	for (int i = 0; i < doors.size(); i++) {
		if (id == doors[i].id)
			return i;
	}
	return -1;
}

int main(void) {
	int N;
	cin >> N;
	cin.ignore();
	vector<DOOR> door(N);
	for (int i = 0; i < N; i++) {
		getline(cin, door[i].id);
	}
	
	bool isOpen = false;
	int M;
	cin >> M;
	cin.ignore();
	for (int i = 0; i < M; i++) {
		string id;
		getline(cin, id);
		int index = find_door(id, door);
		if (index != -1) {
			if (isOpen) {
				cout << "Closed by " << id << endl;
				isOpen = false;
			}else {
				cout << "Opened by " << id << endl;
				isOpen = true;
			}
		}else {
			cout << "Unknown " << id << endl;
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;


signed main()
{
  int N;
  string S;
  set<string> st;
  
  cin >> N;

  Rep(i, N) {
    cin >> S;
    st.insert(S);
  }

  bool state = false;
  int M;
  cin >> M;
  while(M--) {
    cin >> S;
    if(st.find(S) != st.end()) {
      if(state) { cout << "Closed by "; state = false; }
      else { cout << "Opened by "; state = true; }
      cout << S << endl;
    } else {
      cout << "Unknown " << S << endl;
    }
  }

  return 0;
}

C++: #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

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


int main() {
  int N; cin >> N;
  map<string, bool> U;
  rep(i, N) {
    string s; cin >> s;
    U[s] = true;
  }

  bool closed = true;
  int M; cin >> M;
  rep(i, M) {
    string T; cin >> T;
    if (U[T] == false) {
      cout << "Unknown " << T << endl;
    }
    else {
      cout << (closed ? "Opened" : "Closed") << " by " << T << endl;
      closed ^= true;
    }
  }

  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int n,m,l=0,i;
    string id;
    string c;
    vector<string>vec;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>id;
        vec.push_back(id);
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>c;
        if(find(vec.begin(), vec.end(), c)!=vec.end()){
            cout<<((++l%2)==1?"Opened by ":"Closed by ")<<c<<endl;
        }
        else
            cout<<"Unknown "<<c<<endl;
    }
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	string u[n];
	for (int i = 0; i < n; ++i) cin>>u[i];
	int m;
	cin>>m;
	string t;
	bool open=0;
	for (int i = 0; i < m; ++i)
	{
		cin>>t;
		bool find=0;
		for (int j = 0; j < n; ++j) if(t==u[j]) find=1;
		if(find)
		{
			if(open) cout<<"Closed by "<<t<<endl,open=0;
			else cout<<"Opened by "<<t<<endl,open=1;
		}
		else cout<<"Unknown "<<t<<endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  int m;
  cin>>m;
  bool f=true;
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    if(mp.count(s)){
      if(f){
        cout<<"Opened by "<<s<<endl;
        f=false;
      }else{
        cout<<"Closed by "<<s<<endl;
        f=true;
      }
    }else{
      cout<<"Unknown "<<s<<endl;
    }
  }
}

C++: #include<iostream>
#include<map>
using namespace std;
map<string,bool>M;
main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;cin>>s;M[s]=1;
	}
	cin>>n;
	int a=1;
	for(int i=0;i<n;i++)
	{
		string s;cin>>s;
		if(M[s])
		{
			cout<<(a?"Opened by ":"Closed by ")<<s<<endl;
			a=!a;
		}
		else
		{
			cout<<"Unknown "<<s<<endl;
		}
	}
}

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 <bits/stdc++.h>
using namespace std;
int main(void){
int n,m;
string tmp;
bool opened=false;
vector<string>pass;
cin>>n;
for(int i=0;i<n;i++){
	cin>>tmp;
	pass.push_back(tmp);
}
cin>>m;
for(int i=0;i<m;i++){
	bool matched=false;
	cin>>tmp;
	for(int j=0;j<n;j++){
		if(pass[j]==tmp){
			if(opened)cout<<"Closed by "<<tmp<<endl;
			else cout<<"Opened by "<<tmp<<endl;
			opened=!opened;
			matched=true;
			break;
		}
	}
	if(!matched)cout<<"Unkown "<<tmp<<endl;
}
return 0;
}