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<iostream>
#include<string>
using namespace std;
struct EE{string st;};

int main(){

int n,m;
while(cin>>n){
struct EE R[260];
for(int i=0;i<n;i++)
cin>>R[i].st;
cin>>m;string str;
bool f=true;
for(int i=0;i<m;i++)
{cin>>str;
for(int j=0;j<n;j++)
if(R[j].st==str&&f==false){
cout<<"Closed by "<<str<<endl;
f=true;break;
}
else if(R[j].st==str&&f==true){
cout<<"Opened by "<<str<<endl;
f=false;break;
}
else if(j==n-1){
cout<<"Unknown "<<str<<endl;
}
}
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <cstdio>

using namespace std;

int main() {
	map<string, int> reg;
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		string str; cin >> str;
		reg[str] = 0;
	}
	int k = 0;
	int M; cin >> M;
	for (int i = 0; i < M; ++i) {
		string str; cin >> str;
		if (reg.find(str) != reg.end()) {
			if (k == 0) {
				printf("Opened by %s\n", str.c_str());
				k = 1;
			}
			else {
				printf("Closed by %s\n", str.c_str());
				k = 0;
			}
		}
		else printf("Unknown %s\n", str.c_str());
	}
}

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

using namespace std;

int N, M;

int main()
{
    cin >> N;
    set<string> latte;
    for (int i = 0; i < N; i++)
    {
        string U;
        cin >> U;
        latte.insert(U);
    }
    cin >> M;
    bool state = false;
    for (int i = 0; i < M; i++)
{
        string T;
       cin >> T;
        if (latte.find(T) == latte.end())
        {
          cout << "Unknown " << T << endl;
            continue;
        }
        if (state) printf("Closed by ");
       else printf("Opened by ");
        cout << T << endl;
        state = !state;
}
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    set<string> st;
    cin >> n;
    rep(i, 0, n){
        string s;
        cin >> s;
        st.insert(s);
    }
    int cnt = 0;
    cin >> m;
    rep(i, 0, m){
        string s;
        cin >> s;
        if(st.count(s)){
            if(cnt % 2 == 0){
                cout << "Opened by " << s << endl;
            }else{
                cout << "Closed by " << s << endl;
            }
            cnt++;
        }else{
            cout << "Unknown " << s << endl;
        }
    }

}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, m;
  string tmp;
  vector<string> user;
  bool open = false;
  cin >> n;
  while (n--) {
    cin >> tmp;
    user.push_back(tmp);
  }
  cin >> m;
  while (m--) {
    cin >> tmp;
    if (find(user.begin(), user.end(), tmp) == user.end()) {
      cout << "Unknown " << tmp << el;
    }
    else {
      if (open) {
        open = false;
        cout << "Closed by " << tmp << el;
      } else {
        open = true;
        cout << "Opened by " << tmp << el;
      }
    }
  }
}

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




int main(){
  bool j=false;
  int n;
  cin>>n;
  string a[1000];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    string b;
    cin>>b;
    bool done=false;
    for(int t=0;t<n;t++){
      if(b==a[t]){
	cout<<(j==true? "Closed by ":"Opened by ")<<b<<endl;
	if(j){j=false;}
	else{j=true;}
	done=true;
	break;
      }
    }
    if(!done){cout<<"Unknown "<<b<<endl;}
  }

  
  return 0;
}

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);
  }

  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 <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int N;
    cin >> N;
    map<string,bool> U;
    rep(i,N){
        string u;
        cin >> u;
        U[u] = true;
    }
    int M;
    cin >> M;
    vector<string> T(M);
    rep(i,M) cin >> T[i];
    bool open = false;
    rep(i,M){
        string s = T[i];
        if(U.find(s) != U.end()){
            if(open){
                cout << "Closed by " << s << endl;
            }else{
                cout << "Opened by " << s << endl;
            }
            open = !open;
        }else{
            cout << "Unknown " << s << endl;
        }
    }
    return 0;
}

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

int main() {
  int n, m;
  string in;
  cin>>n;
  set<string> t;
  for (int i=0; i<n; ++i) {
    cin>>in; t.insert(in);
  }
  cin>>m;

  bool open = false;
  for (int i=0; i<m; ++i) {
    cin>>in;
    if (t.find(in) == t.end()) {
      cout<<"Unknown "<<in<<endl;
    } else {
      cout<<(open?"Closed":"Opened")<<" by "<<in<<endl;
      open ^= true;
    }
  }
}