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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    int n,m;
    cin >> n;
    map<string, int> u;
    rep(i, n){
        string a;
        cin >> a;
        u[a]=1;
    }
    cin >> m;
    bool open=false;
    rep(i, m){
        string a;
        cin >> a;
        if (u[a]==1) {
            if (open) {
                open = false;
                cout << "Closed by "<<a<<endl;
            }else{
                open = true;
                cout << "Opend by "<<a<<endl;
            }
            continue;
        }else{
            cout << "Unknown "<<a<<endl;
        }
    }
}

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

vector<string> usr_name;

int main(){
  vector<string>::iterator it;
  int n,m,i = 0,j = 0;
  bool k = 0;
  string tmp;
  cin >>n;
  cin.ignore();
  for(i = 0;i < n;i++){
    cin >>tmp;
    usr_name.push_back(tmp);
    cin.ignore();
  }
  cin >> m;
  cin.ignore();
  for(i = 0; i<m;i++){
    j = 0;
    cin >> tmp;
    it = usr_name.begin();
    while(it != usr_name.end()){
      it++;
      if(tmp == usr_name[j]){
	if(k == 0){
	  cout << "Open by "<<tmp<<endl;
	  k = !k;
	}else{
	  cout << "Closed by "<<tmp<<endl;
	  k = !k;
	}
	j = -1;
	break;
      }
      j++;
    }
    if(j != -1)
      cout <<"Unknown "<<tmp<<endl;
  }
    return 0;
  }

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

using namespace std;

typedef long long ll;
typedef long double real;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
static inline ll mod_inv(ll a, ll p){ return pow_mod(a,p-2,p); }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int Mod = 1000000000;

int main()
{
  int n, m;
  set<string> cnt;
  cin >> n;
  for (int i = 0; i < n; i++) cnt.insert(instr());
  cin >> m;
  bool is_opened = false;
  for (int i = 0; i < m; i++){
    string s = instr();
    if (cnt.count(s)){
      if (is_opened) cout << "Closed";
      else cout << "Opened";
      cout << " by " << s << "\n";
      is_opened = !is_opened;
    }
    else {
      cout << "Unknown " << s << "\n";
    }
  }
  return (0);
}

// priority_queue queue deque first second front top push pop map set stringstream max_element min_element insert count find

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N;
    cin >> N;
    set<string> ids;
    for(int i=0; i<N; i++){
        string id;
        cin >> id;
        ids.insert(id);
    }
    
    int M;
    bool locked = true;
    cin >> M;
    while(M--){
        string id;
        cin >> id;
        if(ids.count(id)){
            if(locked)
                cout << "Opened by " << id << endl;
            else
                cout << "Closed by " << id << endl;
            locked ^= true;
        }else{
            cout << "Unknown " << id << endl;
        }
    }
    
    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;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

const bool Closed = false;
const bool Open = true;

int main() {
  int N, M;
  cin >> N;
  set<string> ids;
  REP(i, N) {
    string id;
    cin >> id;
    ids.insert(id);
  }

  bool door = Closed;
  
  cin >> M;
  REP(i, M) {
    string card;
    cin >> card;
    if (ids.find(card) == ids.end()) {
      cout << "Unknown " << card << endl;
    } else if (door == Closed) {
      cout << "Opened by " << card << endl;
      door = Open;
    } else {
      cout << "Closed by " << card << endl;
      door = Closed;
    }
  }
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

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

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m;
map<string,int> ma;
string str;
typedef pair<bool,string> p;
int main(){
	queue<p> que;
	cin>>n;
	bool flag = true;
	for(int i = 0;i < n;i++){
		cin>>str;
		ma[str]=1;
	}
	cin>>m;
	for(int i =0;i <m;i++){
		cin>>str;
		if(ma[str]==1){
			que.push(p(true,str));
		}else{
			que.push(p(false,str));
		}
	}
	while(!que.empty()){
		if(que.front().first){
			if(flag){
				cout <<"Opened by "<<que.front().second;
				flag =false;
			}
			else{
				cout <<"Closed by "<<que.front().second;
				flag =true;
			}
		}else{
			cout <<"Unknown "<<que.front().second;
		}
		que.pop();
		cout<<endl;
	}
	return 0;
}