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 <string>
#include <set>

using namespace std;



int N, M;
string open="Opened by ", clsd="Closed by ", unk = "Unknown ";

int main() {
	cin >> N;
	
	set<string> users;
	for (int i=0; i<N; i++) {
		string user; cin >> user;
		users.insert(user);
	}
	
	cin >> M;
	bool opened = false;
	for (int i=0; i<M; i++) {
		string comes; cin >> comes;
		if (users.find(comes) != users.end()) {
			if (!opened) cout << open << comes << endl;
			else cout << clsd << comes << endl;
			opened = !opened;
		} else {
			cout << unk << comes << endl;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(void){
	int N,M;
	string s;
	bool locked=true;
	map<string,bool> ID;

	cin>>N;
	rep(i,N){
		cin>>s;
		ID[s]=true;
	}

	cin>>M;
	rep(i,M){
		cin>>s;
		if(ID[s]){
			cout<<(locked ? "Openned" : "Closed")<<" by "<<s<<endl;
			locked = !locked;
		}else {
			cout<<"Unknown "<<s<<endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<set>
#include<map>
using namespace std;
int main(){
	int n,m;
	string str;
	set<string>	st;
	map<string,int>	mp;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> str;
		mp[str]++;
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> str;
		if(mp[str]!=0){
			if(mp[str]>0){
				cout << "Opened by " << str << endl;
				mp[str]=mp[str]*(-1);
			}
			else{
				cout << "Closed by " << str << endl;
				mp[str]=mp[str]*(-1);
			}
		}
		else	cout << "Unknown " << str << endl;
	}
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

set<string> users;

int main(){ _;
  int n,m;
  string user;
  bool opened=false;
  cin>>n;
  REP(i,n){
    cin>>user;
    users.insert(user);
  }
  cin>>m;
  REP(i,m){
    cin>>user;
    if(users.count(user)==1){
      if(opened){
	cout<<"Closed by "<<user<<endl;
      }else{
	cout<<"Opened by "<<user<<endl;
      }
    }else{
      cout<<"Unknown "<<user<<endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	string ic[256],out;
	cin>>n;
	for(int i=0;i<n;i++)cin>>ic[i];
	cin>>m;
	for(int i=0,now=0,co=0;i<m;i++){
		cin>>out;
		for(int j=0;j<n&&co<1;j++)if(ic[j]==out)co=1;
		if(co==1&&now==0)cout<<"Opened by "+out<<endl;
		else if(co==1&&now==1)cout<<"Closed by "+out<<endl;
		else cout<<"Unknown "+out<<endl;
		now=(now+co)%2;
		co=0;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	map<string,int> mp;
	string s;
	for(int i=0;i<n;i++){
		cin >> s;
		mp[s]++;
	}
	int q; cin >> q;
	int t=0;
	while(q--){
		cin >> s;
		if(mp[s]==0){
			cout << "Unknown " << s << endl;
		}
		else{
			if(!t){
				cout << "Opened";
			}
			else{
				cout << "Closed";
			}
			cout << " " << "by " << s << endl;
			t^=1;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  string s;
  set<string> keys;
  cin>>n;
  rep(i,n){
    cin>>s;
    keys.insert(s);
  }
  cin>>n;
  bool now = true;
  rep(i,n){
    cin>>s;
    //    cout<<keys.find(s)<<endl;
    if(keys.find(s)!=keys.end()){
      if(now){
	cout<<"Opened by ";
      }else{
	cout<<"Closed by ";
      }
      now = !now;
    }else{
      cout<<"Unknown ";
    }
    cout<<s<<endl;
  }


}

C++: #include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    vector<string> v;
    for(int i=0; i<N; ++i){
        string str; cin >> str;
        v.push_back(str);
    }
    int cnt=0, M;
    cin >> M;
    for(int i=0; i<M; ++i){
        string str; cin >> str;
        auto res = find(v.begin(), v.end(), str);
        if(res==v.end()){
            cout << "Unknown " << str << endl;
        }else{
            if(cnt%2==0) cout << "Opened by " << str << endl;
            else cout << "Closed by " << str << endl;
            cnt++;
        } 
    }
    return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl

using namespace std;

int main() {
	int N,M;
	bool is_open=false;
	vector<string> ids;
	string id;

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

	cin >> M;
	bool is_id = false;
	rep(i,M) {
		cin >> id;
		is_id = false;
		rep(j,ids.size()) {
			if (ids[j] == id) {
				is_id = true;
				is_open = !is_open;
				break;
			}
		}

		if (is_id) { //IDがあるとき
			if (is_open) {
				cout << "Opened by " + id << endl;
			}
			else {
				cout << "Closed by " + id << endl;
			}
		}
		else {
			cout << "Unknown " + id << endl;
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int M;

vector<string> u,t;

set<string> id;

int main(){
  cin >> N;
  u.resize(N);
  rep(i,0,N - 1) cin >> u[i];
  rep(i,0,N - 1) id.insert(u[i]);
  cin >> M;
  string me[] = {"Opened by " , "Closed by "};
  int cou = 0;

  rep(i,0,M - 1){
    string s;
    cin >> s;
    if(!id.count(s)){
      cout << "Unknown " << s << endl;
    }
    else{
      cout << me[cou] << s << endl;
      cou = 1 - cou;
    }
  }
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

int main() {
	int n, m;
	cin >> n;
	priority_queue< string, vector<string>, greater<string> >pq;
	vector<string> data;
	string a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		pq.push(a);
	}
	for (int i = 0; i < n; i++) {
		data.push_back(pq.top());
		pq.pop();
	}
	cin >> m;
	bool hantei = false;
	bool hantei2;
	for (int i = 0; i < m; i++) {
		cin >> a;
		hantei2 = true;
		for (int i = 0; i < n; i++) {
			if (data[i] == a) {
				hantei2 = false;
				break;
			} else if (data[i] > a) {
				break;
			}
		}
		if (hantei2) {
			cout << "Unknown "  << a << endl;
		} else {
			if (hantei) {
				cout << "Closed by " << a << endl; 
				hantei = false;
			} else {
				cout << "Opened by " << a << endl;
				hantei = true;
			}
		}
	}
	return 0;
}