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;

bool isRegistered(string id, vector<string>::iterator registered_id_begin, vector<string>::iterator registered_id_end){

  for(vector<string>::iterator i = registered_id_begin; i != registered_id_end; i++){
    if(id == *i)
      return true;
  }
  return false;
}

int main(void){
  int N;
  cin >> N;
  vector<string> registered_id;
  for(int i=0; i < N; i++){
    string tmp; cin >> tmp;
    registered_id.push_back(tmp);
  }
  int M;
  cin >> M;
  vector<string> touched_id;
  for(int i=0; i < M; i++){
    string tmp; cin >> tmp;
    touched_id.push_back(tmp);
  }

  for(int i=0; i < M; i++){
    cout << touched_id[i] << endl;
  }

  bool locked = true;
  for(int i=0; i < M; i++){
    if(isRegistered(touched_id[i], registered_id.begin(), registered_id.end())){
      if(locked){
	cout << "Opened by " << touched_id[i] << endl;
	locked = false;
      }else{
	cout << "Closed by " << touched_id[i] << endl;
	locked = true;
      }
    }else{
      cout << "Unknown " << touched_id[i] << endl;
    }
  }
  return 0;
}

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

int main(){
	string id[256];
	bool kagisys = true;	//true:lock false:open
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> id[i];
	}	//input

	int m;
	int unknown = 0;
	cin >> m;
	for(int i = 0; i < m; i++){
		string name;
		cin >> name;
		for(int j = 0; j < n; j++){
			if(id[j] == name){
				switch(kagisys){
				case true:
					cout << "Opened by " << name << endl;
					kagisys = false;
					unknown ++;
					break;
				case false:
					cout << "Closed by " << name << endl;
					kagisys = true;
					unknown ++;
					break;
				}
			}
		}
		if (unknown == 0){
			cout << "Unknown " << name << endl;
		}
		unknown = 0;
	}

	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
  vector<string> u;
  int N, M;
  cin>>N;
  rep(i,N){
    string tmp;
    cin>>tmp;
    u.push_back(tmp);
  }
  cin>>M;
  bool open=false;
  rep(i,M){
    string t;
    cin>>t;
    bool known=false;
    rep(j,N)if(u[j]==t){known=true; break;}
    if(!known)cout<<"Unknown "<<t<<endl;
    else if(open){cout<<"Closed by "<<t<<endl; open=false;}
    else{cout<<"Opened by "<<t<<endl; open=true;}
  }
  return 0;
}

C++: #include<iostream>
#include<set>
#include<string>
using namespace std;
set<string>data;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		data.insert(str);
	}
	int m;
	cin>>m;
	int now=1;
	for(int i=0;i<m;i++){
		string str;
		cin>>str;
		if(data.find(str)!=data.end()){
			if(now==1)cout<<"Opened by "<<str<<endl;
			else cout<<"Closed by "<<str<<endl;
			now*=-1;
		}
		else cout<<"Unknown "<<str<<endl;
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  map<string, bool> t;
  rep(i, n) {
    string s;
    cin >> s;
    t[s] = true;
  }
  int m;
  cin >> m;
  bool d = false;
  rep(i, m) {
    string s;
    cin >> s;
    if (t.count(s)) {
      d ^= 1;
      cout << (d ? "Opened" : "Closed") << " by " << s << endl;
    } else {
      cout << "Unknown " << s << endl;
    }
  }
}

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

using namespace std;

int main()
{
    int n, m;
    string u[260], t;
    bool fnd, dor=false;
    cin>>n;
    for (int i=0; i<n; i++) cin>>u[i];
    cin>>m;
    for (int i=0; i<m; i++)
    {
        fnd=false;
        cin>>t;
        for (int j=0; j<n; j++) if (t==u[j]) fnd=true;
        if (fnd && dor) { cout<<"Closed by "; dor=false; }
        else if (fnd && !dor) { cout<<"Opened by "; dor=true; }
        else cout<<"Unknown ";
        cout<<t<<'\n';
    }
    return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    map<string,int>mp;
    rep(i,n){string gotiusa_is_god; cin>>gotiusa_is_god;mp[gotiusa_is_god]++;}
    int ujimatsu_tiya; cin>>ujimatsu_tiya;
    bool gotiusa=true;
    rep(i,ujimatsu_tiya){
        string rize; cin>>rize;
        if(!mp[rize]){cout<<"Unknown "<<rize<<endl; continue;}
        if(gotiusa)cout<<"Opend by "<<rize<<endl;
        else cout<<"Closed by "<<rize<<endl;
        if(gotiusa)gotiusa=false;
        else gotiusa=true;
    }
}

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

set<string> ids;
bool open = false;
int main(){
  int N,M;
  cin >> N;
  for(int i = 0;i < N;i++){
    string str;
    cin >> str;
    ids.insert(str);
  }
  cin >> M;
  for(int i = 0;i < M;i++){
    string str;
    cin >> str;
    if(ids.find(str) == ids.end()){
      cout << "Unknown " << str << endl;
    }
    else{
      if(open){
	cout << "Closed by " << str << endl;
      }
      else{
	cout << "Opened by " << str << endl;
      }
      open = !open;
    }
  }
  return 0;
}