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 <algorithm>
#include <cstring>

using namespace std;

int main(){
	int n;
	cin >> n;
	char registeredID[256][11];
	for(int i=0;i<n;i++){
		cin >> registeredID[i];
	
	}
	int m;
	cin >> m;
	char cardID[256][11];
	for(int i=0;i<m;i++){
		cin >> cardID[i];
	}
	bool isOpen = false;
	for(int i=0;i<m;i++){
		bool contains = false;
		for(int j=0;j<n;j++){
			if(strcmp(cardID[i], registeredID[j])==0){
				//一致している
				contains = true;
				break;
			}
		}
		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;
}

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

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<cassert>
#include<queue>
#define F first
#define S second
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;


int main(){
  int N,M;
  string s;
  map<string,bool> Lock;

  cin >> N;
  rep(i,N){
    cin >> s;
    Lock[s] = true;
  }
  cin >> M;
  bool state = false;
  rep(i,M){
    cin >> s;
    if(!Lock[s])cout << "Unknown " << s << endl;
    else if(Lock[s] && state){
      cout << "Closed by " << s << endl;
      state = false;
    }
    else if(Lock[s] && !state){
      cout << "Opened by " << s << endl;
      state = true;
    }
  }


  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n,m,i,j,o[256],s;
    char* u[256],t;
    cin>>n;
    for (i=0;i<n;i++){
        cin>>u[i];
    }
    cin>>m;
    s=0;
    for (j=0;j<m;j++){
        cin>>t;
        o[j]=0;
        for (i=0;i<n;i++){
            if (t==*u[i]) {
                o[j]=1;
                if (s==0) {
                    cout<<"Opened by "<<u[i]<<"\n";
                    s=1;
                }
                if (s==1) {
                    cout<<"Closed by "<<u[i]<<"\n";
                }
            }
        }
        if (o[j]==0){
            cout<<"Unknown "<<t<<"\n";
        }
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;



int main(){
    int n,m;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string tmp;
        cin >> tmp;
        mp[tmp] = 1;
    }
    cin >> m;
    int cnt = 1;
    rep(i,m){
        string tmp;
        cin >> tmp;
        if(mp[tmp] == 0) {
            cout << "Unknown " << tmp << endl;
        }else{
            cnt++;
            if(cnt % 2 == 0) {
                cout << "Opened by " << tmp << endl;
            }else{
                cout << "Closed by " << tmp << endl;
            }
        }
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvll = vector <vector<ll>>;

#define inf(T) (numeric_limits<T>::max() / 2)
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n; cin >> n;
    map<string,bool> key;
    REP(i, n) {
        string s; cin >> s;
        key[s] = 1;
    }
    int m; cin >> m;
    int opened = 0;
    REP(i, m) {
        string s; cin >> s;
        if (key.count(s)) {
            if (opened) {
                cout << "Closed by " << s << endl;
                opened = 0;
            } else {
                cout << "Opened by " << s << endl;
                opened = 1;
            }
        } else {
            cout << "Unknown " << s << endl;
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	string ic[256],out,log[3]={"Opened by ","Closed by ","Unknown "};
	cin>>n;
	for(int i=0;i<n;i++)cin>>ic[i];
	cin>>m;
	for(int i=0,now=0,co=0;i<m;i++){
		cin>>out;
		for(int j=0;j<n&&co<1;j++)if(ic[j]==out)co=1;
		if(co==1)cout<<log[now]+out<<endl;
		else cout<<log[2]+out<<endl;
		now=(now+co)%2;
		co=0;
	}
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    bool state = false;
    int N; cin >> N;
    set<string> st;
    rep(i, N){
        string S; cin >> S;
        st.insert(S);
    }
    int M; cin >> M;
    rep(i, M){
        string S; cin >> S;
        if(st.count(S) == 1){
            if(state) cout << "Closed by " << S << endl;
            else cout << "Opened by " << S << endl;
            state = !state;
        }
        else cout << "Unknown " << S << endl;
    }
    return 0;
}