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 <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> pii; // (cst, to)

int main() {
	int n, m;
	map<string, bool> IDs;
	scanf("%d", &n);
	for (int i = 0; n > i; i++) {
		char str[11];
		scanf("%s", str);
		IDs[string(str)] = true;
	}
	scanf("%d", &m);
	bool state = false;
	for (int i = 0; m > i; i++) {
		char str[11];
		scanf("%s", str);
		if (IDs[string(str)]) {
			state = 1 - state;
			printf("%sed by %s\n", state ? "Open" : "Clo", str);
		}
		else {
			printf("Unknown %s\n", str);
		}
	}

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	int n, m;
	cin >> n;
	set<string> a;
	rep(i,0,n) {
		string s; cin >> s;
		a.insert(s);
	}
	cin >> m;
	bool f = true;
	rep(i,0,m) {
		string s; cin >> s;
		auto it = a.find(s);
		if (it == a.end()) {
			cout << "Unknown " << s << endl;
		}
		else {
			if (f) {
				cout << "Opened by " << s << endl;
				f = false;
			}
			else {
				cout << "Closed by " << s << endl;
				f = true;
			}
		}
	}

	return 0;
}

C++: // 2016-11-30
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n, m;
	string u[256], t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u[i];
	}
	cin >> m;
	bool o = false;
	for (int i = 0; i < m; i++) {
		cin >> t;
		int j;
		for (j = 0; j < m; j++) {
			if (t == u[j]) {
				cout << (o ? "Closed by " : "Opened by ") << t << endl;
				o ^= true;
				break;
			}
		}
		if (j == m) {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

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

int main(){
  int n, m;
  string s,t;

  set<string> st;
  cin >> n;
  for( int i=0;i<n;i++ ){
    cin >> s;
    st.insert(s);
  }
  cin >> m;
  bool is_open=false;
  for( int i=0;i<m;i++ ){
    cin >> t;
    if( st.find(t) == st.end() ){
      cout << "Unknown " << t << endl;
    }else{
      is_open = !is_open;
      if( is_open )
	cout << "Opened by " << t << endl;
      else
	cout << "Closed by " << t << endl;
    }
  }


  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> pii; // (cst, to)

int main() {
	int n, m;
	map<string, bool> IDs;
	scanf("%d", &n);
	for (int i = 0; n > i; i++) {
		char str[11];
		scanf("%s", str);
		IDs[string(str)] = true;
	}
	scanf("%d", &m);
	bool state = false;
	for (int i = 0; m + i; i++) {
		char str[11];
		scanf("%s", str);
		if (IDs[string(str)]) {
			state = 1 - state;
			printf("%sed by %s\n", state ? "Open" : "Clo", str);
		}
		else {
			printf("Unknown %s\n", str);
		}
	}

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 1;
	while (kkt--) {
		int n; scanf("%d", &n);
		vector<string> vs(n); for (int i = 0; i < n; i++) cin >> vs[i];
		sort(vs.begin(), vs.end());
		int m; scanf("%d", &m);
		int cnt = 0;
		for (int i = 0; i < m; i++) {
			string s; cin >> s;
			if (binary_search(vs.begin(), vs.end(), s)) {
				if (cnt % 2 == 0) cout << "Opened by " << s << "\n";
				else cout << "Closed by " << s << "\n";
				cnt++;
			}else{
				cout << "Unknown " << s << "\n";
			}
		}
	}
	return 0;

}

C++: #include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    int n,m;
    set<string> ss;
    int state = 1;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        ss.insert(s);
    }
    cin >> m;
    rep(i,m){
        string s;
        cin >> s;
        if(ss.find(s) != ss.end()){
            if(state == 1) cout << "Opened by " << s << endl;
            else cout << "Closed by " << s << endl;
            state ^= 1;
        }else cout << "Unknown " << s << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M;
set<string> st;
bool mp;
string s;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        st.insert(s);
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> s;
        if (st.find(s) != st.end())
        {
            mp = !mp;
            cout << (mp ? "Opened " : "Closed ") << "by " + s << endl;
        }
        else
        {
            cout << "Unknown " + s << endl;
        }
    }
}