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<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<string> key(n);
  for(int i = 0; i < n; i++)cin >> key[i];

  int m;
  cin >> m;
  bool locked = true;
  bool change;
  string in;
  for(int i = 0; i < m; i++){
    change = false;
    cin >> in;
    for(int j = 0; j < n; j++){
      if(in == key[j]){
        locked = !locked;
        change = true;
        break;
      }
    }
    if(change){
      if(locked)cout << "Closed by " << in << endl;
      else cout << "Opened by " << in << endl;
    }else{
      cout << "Unknown " << in << endl;
    }
  }

}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 10e9

int main()
{
	int N, M;
	string U[260], T[260];
	cin >> N;
	REP(i, 0, N) cin >> U[i];
	cin >> M;
	REP(i, 0, M) cin >> T[i];
	
	bool open = false;
	REP(i, 0, M) {
		REP(j, 0, N) {
			if (T[i] == U[j] && !open) {
				cout << "Opened by " << T[i] << endl;
				open = true;
				break;
			}
			else if (T[i] == U[j] && open) {
				cout << "Closed by " << T[i] << endl;
				open = false;
				break;
			}

			if (j == N - 1) cout << "Unknown " << T[i] << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <map>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N, M;
string S;
map<string, bool> p;
bool s;

int main(void) {
  cin >> N;
  REP(i, 0, N) {
    cin >> S;
    p[S] = false;
  }
  cin >> M;
  s = false;
  REP(i, 0, M) {
    cin >> S;
    if(p.count(S)) {
      if(s == false) {
        cout << "Opend by " << S << endl;
        s = true;
      } else {
        cout << "Closed by " << S << endl;
        s = false;
      }
    } else {
      cout << "Unknown " << S << endl;
    }
  }
}

C++: #include <iostream>
#include <set>
#include <string>

using namespace std;

string message[] = {"Opened by ", "Closed by "};
int cnt;
int n, m;
set<string> registered;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        registered.insert(str);
    }

    cin >> m;
    for (int i = 0; i < m; i++) {
        string str;
        cin >> str;
        if (registered.count(str)) {
            cout << "Unknown " << str << endl;
        } else {
            cout << message[cnt % 2] << str << endl;
            cnt++;
        }
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {

	int n;
	cin >> n;
	vector<string> u(n);
	rep(i, n) cin >> u[i];
	int m;
	cin >> m;
	bool open = 0;
	rep(i, m){
		string t;
		cin >> t;
		bool exist = false;
		rep(i, n) if(t == u[i]) exist = true;
		if(!exist) cout << "Unknown " << t << endl;
		else{
			if(open) cout << "Closed by " << t << endl;
			else cout << "Opened by " << t << endl;
			open = !open;
		}
		
	}
	
	
	return 0;
}

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

using namespace std;

int main(){
    int n,m;cin >> n;
    vector<string> u(n);
    for(int i = 0; i < n; i++)cin >> u[i];
    sort(u.begin(), u.end());
    bool isopen = false;
    cin >> m;
    for(int i = 0; i < m; i++){
        string m;cin >> m;
        bool find = false;
        for(int j = 0; j < n; j++) if(u[j] == m){
            find = true;
            break;
        }
        if(find){
            if(isopen){
                cout << "Closed by " << m << endl;
            }
            else{
                cout << "Opened by " << m << endl;
            }
            isopen = !isopen;
        }
        else{
            cout << "Unknown " << m << endl;
        }
    }
	return 0;
}

C++: #include <stdio.h>
#include <math.h>

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2204 : Kagisys **/
int main()
{
	set<string> s;
	int N, M; bool open=false;
	cin>>N;
	rep(i, N) {
		string st;
		cin>>st;
		s.insert(st);
	}
	cin>>M;
	rep(i, M) {
		string st;
		cin>>st;
		if (s.count(st)) {
			if (!open)
				cout << "Opened by " << st << endl;
			else
				cout << "Closed by " << st << endl;
			open = !open;
		} else {
			cout << "Unknown " << st << endl;
		}
	}
}

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

string u[256];
bool lock = true;
int n, m;

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> u[i];
	cin >> m;
	for(int i = 0; i < m; i++){
		bool ok = true;
		string t;
		cin >> t;
		for(int j = 0; j < n; j++){
			if(u[j] == t){
				ok = false;
				if(lock) cout << "Opened by " << t << endl;
				else cout << "Closed by " << t << endl;
				lock = (lock+1)%2;
				break;
			}
		}
		if(ok) cout << "Unknown " << t << endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <set>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<string> st;
	int n, m;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cin >> m;
	bool opened = false;
	REP(i, m) {
		string t;
		cin >> t;
		if (st.count(t)) {
			if (opened) {
				cout << "Closed by ";
			}
			else {
				cout << "Opened by ";
			}
			opened = !opened;
			cout << t << endl;
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}