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 main () {
	int n;
	cin >> n;
	set<string> registed;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		registed.insert(str);
	}
	bool state = false;
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		string str;
		cin >> str;
		if (registed.find(str) == registed.end()) {
			cout << "Unknown " << str << endl;
		}
		else {
			if (state) {
				cout << "Closed by " << str << endl;
			}
			else {
				cout << "Opened by " << str << endl;
			}
			state = !state;
		}
	}
	return 0;
}

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

int main(){
   int N, M;
   string U[300], T[300];
   cin>>N;
   for(int i=0;i<N;i++) cin>>U[i];
   cin>>M;
   for(int j=0;j<M;j++) cin>>T[j];
   
   int key=0,mes[300]; //key=0 before close
   for(int i=0;i<M;i++){
       for(int j=0;j<N;j++){
           if(U[j] == T[i] && key == 0){
                     mes[i]+=1;
           }
           else if(U[j] == T[i] && key == 1){
                     mes[i]+=300;
           
           }
           else mes[i]+=0;
        }
        if(mes[i]>299) key=0;
        else if(mes[i]>0) key=1;
        else key=key;
     }

    for(int i=0;i<M;i++){
          if(mes[i]>300) cout<<"Closed by "<<T[i]<<endl;
          else if(mes[i]>0) cout<<"Opened by "<<T[i]<<endl;
          else cout<<"Unknown "<<T[i]<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	set<string> st;
	rep(i, 0, n) {
		string s;
		cin >> s;
		st.insert(s);
	}
	int m;
	cin >> m;
	vs t(m);
	rep(i, 0, m) {
		cin >> t[i];
	}
	bool open = false;
	rep(i, 0, m) {
		if (st.count(t[i])) {
			if (!open) {
				cout << "Opened by ";
				open = true;
			}
			else {
				cout << "Closed by ";
				open = false;
			}
		}
		else {
			cout << "Unknown ";
		}
		cout << t[i] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;

    set<string> id;
    for(int i=0; i<n; ++i){
        string s;
        cin >> s;
        id.insert(s);
    }

    int m;
    cin >> m;

    bool open = false;
    for(int i=0; i<m; ++i){
        string s;
        cin >> s;
        if(id.find(s) == id.end()){
            cout << "Unknown " << s << endl;
        }else if(open){
            cout << "Closed by " << s << endl;
            open = false;
        }else{
            cout << "Opened by " << s << endl;
            open = true;
        }
    }

    return 0;
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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(){
int n;
cin>>n;
set<string> s;
for(int i=0;i<n;i++){
    string t={};
    cin>>t;
    s.insert(t);
}
int m;
cin>>m;
int open=1;
for(int i=0;i<m;i++){
    string t={};
    cin>>t;
    if(s.find(t)!=s.end()){
        if(open)cout<<"Opened by "<<t<<endl;
        else cout<<"Closed by "<<t<<endl;
        open^=1;
    }
    else cout<<"Unknown "<<t<<endl;
}
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int n,m,j=0;
	cin>>n;
	string u[n],t;
	for(int i=0;i<n;i++){
		cin>>u[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int a=0;
		cin>>t;
		for(int k=0;k<n;k++){
			if(u[k]==t){
				if(j==0){
					cout<<"Opened by "<<t<<endl;
					j=1;
				}
				else if(j==1){
					cout<<"Closed by "<<t<<endl;
					j=0;
				}
				a=1;
			}
		}
		if(a==0){
			cout<<"Unknown "<<t<<endl;
		}
	}
    return 0;
}

C++: ///
// File:  2440.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 15:06:25 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

enum status_t {
  Open,
  Close,
};

int32_t main()
{
  uint32_t N, U;
  cin >> N;

  vector<string> registered;
  for (uint32_t i = 0; i < N; i++) {
    string str;
    cin >> str;
    registered.push_back(str);
  }

  cin >> U;
  bool is_close = true;
  for (uint32_t i = 0; i < U; i++) {
    string str;
    cin >> str;
    uint32_t j = 0;
    for (; j < registered.size(); j++) {
      if (str == registered[j]) {
        if (is_close) {
          cout << "Opened by " << str << endl;
        } else {
          cout << "Closed by " << str << endl;
        }
        is_close = !is_close;
        break;
      }
    }

    if (j == registered.size()) {
      cout << "Unkown " << str << endl;
    }
  }

  return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string *registeredID = new string[n];
	for(int i=0;i<n;i++){
		cin >> registeredID[i];
	}
	sort(registeredID, registeredID+n);
	int m;
	cin >> m;
	string *cardID = new string[m];
	for(int i=0;i<m;i++){
		cin >> cardID[i];
	}
	bool isOpen = false;
	for(int i=0;i<m;i++){
		bool contains = binary_search(registeredID,registeredID+n, cardID[i]);
		if(contains==true){
			if(isOpen == true){
				cout << "Closed by " << cardID[i] << endl;
				isOpen = false;
			}else{
				cout << "Opened by " << cardID[i] << endl;
				isOpen = true;
			}
		}else{
			cout << "Unknown " << cardID[i] << endl;
		}
	}
	return 0;
}