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 <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	char ID[11];
};

enum Door{
	CLOSE,
	OPEN
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

int main(){

	int N,M;
	bool FLG;
	scanf("%d",&N);
	Info info[N];

	for(int i = 0; i < N; i++)scanf("%s",info[i].ID);

	Door door = CLOSE;
	char tmp[11];

	scanf("%d",&M);

	for(int i = 0; i < M; i++){
		scanf("%s",tmp);
		FLG = false;
		for(int k = 0; k < N; k++){
			if(strCmp(tmp,info[k].ID)){
				FLG = true;
				break;
			}
		}
		if(FLG){
			if(door == CLOSE){
				printf("Opened by %s\n",tmp);
				door = OPEN;
			}else{
				printf("Closed by %s\n",tmp);
				door = CLOSE;
			}
		}else{
			printf("Unknown %s\n",tmp);
		}
	}

	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,n) for(int i=(int)(n-1);i>=0;--i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int N, M;
    cin >> N;
    vs registered(N);
    REP(i, N) cin >> registered[i];
    cin >> M;
    bool open = false;
    REP(i, M) {
        string s;
        cin >> s;
        if (find(ALL(registered), s) != registered.end()) {
            if (open) {
                cout << "Closed by ";
            } else {
                cout << "Opened by ";
            }
            open = !open;
        } else {
            cout << "Unknown ";
        }
        cout << s << endl;
    }
}

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

int main(){
	int n, m;
	string u[300];
	
	cin >> n;
	for(int i=0; i<n; ++i) cin >> u[i];
	cin >> m;
	
	bool open = false;
	for(int i=0; i<m; ++i){
		string t;	
		cin >> t;
		
		bool door=false;
		for(int j=0; j<n; ++j){
			if(t == u[j]){
				door=true;	
				break;
			}
		}
		
		if(!door) cout << "Unknown " << t <<endl;
		else if(door && open){
			cout << "Closed by " << t << endl;	
			open = false;
		}
		else if(door && !open){
			cout << "Opened by " << t << endl;	
			open = true;			
		}
	}
	
	return 0;
}

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

int main(){
	int n, m;
	string u[100010];
	string input;
	bool isOpen = false;

	cin >> n;
	for(int i=0; i < n; i++){
		cin >> u[i];
	}
	cin >> m;
	for(int i=0; i < m; i++){
		cin >> input;

		bool isExist = false;
		for(int j=0; j < n; j++){
			if(u[j] == input){
				isExist = true;
			}
		}
		if(isExist){
			if(isOpen){
				cout << "Closed by " << input << endl;
				isOpen = false;
			}
			else {
				cout << "Opened by " << input << endl;
				isOpen = true;
			}
		}
		else {
			cout << "Unknown " << input << endl;
		}
	}
}

C++: #include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

void solve(){
	int n;
	cin >> n;
	set<string> hoge;
	REP(i, n) {
		string a;
		cin >> a;
		hoge.insert(a);
	}
	int m;
	cin >> m;
	int now = 0;
	REP(i, m) {
		string s;
		cin >> s;
		if (hoge.count(s) == 0) {
			cout << "Unknown ";
		}
		else {
			now++;
			if (now % 2 == 1) {
				cout << "Opened by ";
			}
			else {
				cout << "Closed by ";
			}
		}
		cout << s << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    int n; cin >> n;
    
    set<string> s;
    while(n--){
        string u; cin >> u;
        s.insert(u);
    }

    int m; cin >> m;
    bool isO = false;
    while(m--){
        string t; cin >> t;
        if(s.find(t) != s.end()){
            if(isO){
                cout << "Closed by " << t << endl;
                isO = false;
            }
            else{
                cout << "Opened by " << t << endl;
                isO = true;
            }
        }
        else{
            cout << "Unknown " << t << endl;
        }
    }

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n;
	string u[n];
	for(int i=0;i<n;i++){
		cin >> u[i];
	}
	cin >> m;
	string t[m],kaku[m];
	int l=0;
	for(int i=0;i<m;i++){
		cin >> t[i];
		kaku[i]=t[i];
		for(int j=0;j<n;j++){
			l=0;
			for(int k=0;k<=i;k++){
				if(t[i]==kaku[k]){
					l++;
				}
			}
			cout << u[j] << endl;
			if((t[i]==u[j]) && (l%2==1)){
				cout << "Opened by " << t[i];
				break;
			}else if((t[i]==u[j]) && (l%2==0)){
				cout << "Closed by " << t[i];
				break;
			}
			if(j==n-1){
				cout << "Unknown" << t[i];
				break;
			}
		}
		cout << endl;
	}
}