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 <cstdlib>
#include <vector>
#include <string>

int main(void) {
    int N;
    int M;
    std::string target;
    bool discovery; 
    bool door = false;

    std::cin >> N;
    std::vector<std::string> U(N);
    for (int i = 0; i < N; i++) {
        std::cin >> U[i];
    }
    std::cin >> M;
    for (int i = 0; i < M; i++) {
        discovery = false;
        std::cin >> target;
        for (int j = 0; j < N; j++) {
            if (target == U[j]) {
               discovery = true; 
               break;
            }
        }

        if (discovery == true && door == false) {
            std::cout << "Opened by " << target << std::endl;
            door = true;
        } else if (discovery == true && door == true){
            std::cout << "Closed by " << target << std::endl;
            door = false;
        } else {
            std::cout << "Unknown " << target << std::endl;
        }
    }
    
    return EXIT_SUCCESS;
}

C++: #include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;


int main(){
  int n,m;
  cin>>n;
  vector<string> user(n);
  rep(i,n)cin>>user[i];
  cin>>m;
  vector<string> t(m);
  rep(i,m)cin>>t[i];
  int key=1;
  rep(i,m){ 
    rep(j,n){
      if(t[i]==user[j]){
	cout<<(key>0?"Opened by":"Closed by")<<" "<<t[i]<<endl;
	key*=-1;
	break;
      }
      if(j==n-1){
	cout<<"Unknown"<<" "<<t[i]<<endl;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N;
	vector<string> U(N);
	REP(i, N) {
		cin >> U[i];
	}
	cin >> M;
	bool lock = true;
	REP(i, M) {
		string T;
		cin >> T;
		if (find(ALL(U), T) != U.end()) {
			if (lock) {
				cout << "Opened by " << T << endl;
				lock = false;
			}
			else {
				cout << "Closed by " << T << endl;
				lock = true;
			}
		}
		else {
			cout << "Unknown " << T << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

int main(void){
	int n; cin >> n;
	vector<string> u(n);
	rep(i,n) cin >> u[i];
	int m; cin >> m;
	bool opened = false;
	rep(i,m) {
		string t; cin >> t;
		if(find(u.begin(), u.end(), t) != u.end()) {
			opened ^= true;
			if(opened) {
				cout << "Opened by " << t << endl;
			}
			else {
				cout << "Closed by " << t << endl;
			}
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}

	return 0;
}

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

int main(void){
        int i,j,n,m;
        string input;
        bool door = true, user_search;

        cin >> n;
        vector<string> id(n);
        for(i = 0; i < n; i++){
                cin >> id[i];
        }   

        cin >> m;
        for(i = 0; i < m; i++){
                user_search = false;
                cin >> input;
                for(j = 0; j < n; j++){
                        if(input == id[j]){
                                if(door){
                                        cout << "Opened by " << input << endl;
                                        door = !door;
                                }else{
                                        cout << "Closed by " << input << endl;
                                        door = !door;
                                }   
                                user_search = true;
                        }   
                }   
                if(!user_search){
                        cout << "Unknown " << input << endl;
                }   
        }   
        return 0;
}

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

int main(){
    int N,M,openflag=0,flag = 0;
    string baf_U,baf_T;
    string U[256];
    string T[256];
    cin >> N;
    for(int i= 0;i<N;i++){
        cin >> baf_U;
        U[i] = baf_U;
    }
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> baf_T;
        T[i] = baf_T;
    }
    for(int i=0;i<M;i++){
        for(int k = 0;k<N;k++){
            if(U[k]==T[i]){
                flag = 1;
            }
        }
        if(flag ==1){
            if(openflag==0){
                cout <<"Opened by "<<T[i]<<endl;
                openflag = 1;
            }else{
                cout <<"Closed by "<<T[i]<<endl;
                openflag = 0;
            }
        }else{
            cout <<"Unknown "<<T[i]<<endl;
        }
        flag = 0;
    }
    exit(0);
}

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

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

	cin >> m;
	bool f = false;
	for(int i = 0; i < m; ++i){
		cin >> u;
		if( st.find(u) == st.end() ){
			cout << "Unknown ";
		}
		else if( f ){
			f = false;
			cout << "Closed by ";
		}
		else{
			f = true;
			cout << "Opened by ";
		}
		cout << u << '\n';
	}
}