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 <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
const string STR[3] = {"Opend by ", "Closed by ", "Unknown "};

int main(void){
    string id;
    vs ids;
    int n, f = 1; cin >> n;
    while(n--){
        cin >> id;
        ids.pb(id);
    }
    int m; cin >> m;
    while(m--){
        cin >> id;
        if(find(ALL(ids), id) != ids.end()) cout << STR[f = !f];
        else cout << STR[2];
        cout << id << endl;
    }
 
    return 0;
}

C++: #define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
#include <set>
#include <iostream>
using namespace std;

inline int getInt(){ int s; scanf("%d", &s); return s; }
inline string getStr(){ char buff[256]; scanf("%s", buff); return buff; }

int main(){
  const int n = getInt();
  set<string> u;

  REP(i,n) u.insert(getStr());

  bool lock = true;

  const int m = getInt();

  REP(i,m){
    const string s = getStr();
    if(u.count(s)){
        if(lock){
          printf("Opened by ");
        }else{
          printf("Closed by ");
        }
        lock = !lock;
    }else{
        printf("Unknown ");
    }
    puts(s.c_str());
  }

  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int n;
  cin >> n;
  set<string > se;
  REP(i,n) {
    string s;
    cin >> s;
    se.insert(s);
  }
  int m;
  cin >> m;
  bool f = 1;
  REP(i,m) {
    string s;
    cin >> s;
    if (se.count(s)) {
      if (f) cout << "Opened by ";
      else cout << "Closed by ";
      f ^= 1;
    } else {
      cout << "Unknown ";
    }
    cout << s << endl;
  }
}

C++: #include "bits/stdc++.h"

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;cin>>n;
    vector<string> u(n);
    for(int i=0;i<n;i++) cin>>u[i];
    int m;cin>>m;
    int locked=1;
    for(int i=0;i<m;i++){
        string t;cin>>t;
        for(int j=0;j<n;j++){
            if(u[j]==t){
                if(locked) cout<<"Opened by "<<t<<endl;
                else cout<<"Closed by "<<t<<endl;
                locked=1-locked;
                goto done;
            }
        }
        cout<<"Unknown "<<t<<endl;
        done: continue;
    }
}

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

int main(){
	int n,m;
	vector<string> u;
	cin >> n;
	for(int i=0;i<n;i++){
		string U;
		cin >> U;
		u.push_back(U);
	}
	cin >> m;
	int ans=0;
	for(int i=0;i<m;i++){
		string T;
		cin >> T;
		int judge=0;
		for(int j=0;j<u.size();j++){
			if(T==u[j]){
				ans++;
				judge++;
			}
		}
		if(judge==0) cout << "Unknown " << T << endl;
		else if(ans%2==1) cout << "Opened by " << T << endl;
		else if(ans%2==0&&judge!=0) cout << "Closed by " << T << endl;
	}

}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n; cin >> n;
	vector<string>l;
	for (int i = 0; i < n; i++){
		string s; cin >> s;
		l.push_back(s);
	}
	cin >> n;
	bool b = false;//false->closed
	for (int i = 0; i < n; i++){
		string s; cin >> s;
		if (find(l.begin(), l.end(), s) != l.end()) {
			if (b){
				cout << "Closed by " << s << endl;
				b = false;
			}
			else{
				cout << "Opened by " << s << endl;
				b = true;
			}
		}
		else{
			cout << "Unknown " << s << endl;
		}
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
vector<string> t;
bool flag=true;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		string s;
		cin>>s; t.pb(s);
	}
	cin>>m;
	rep(i,m){
		string s;
		cin>>s;
		if(exist(t,s)){
			if(flag){
				cout<<"Opened by "<<s<<endl;
				flag=false;
			}else{
				cout<<"Closed by "<<s<<endl;
				flag=true;
			}
		}else{
			cout<<"Unknown "<<s<<endl;
		}
	}
	return 0;
}

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

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

map<string,int> ma;

int main(){
	int n,m;
	cin>>n;
	rep(i,n){
		string tmp;
		cin>>tmp;
		ma[tmp]=1;
	}
	cin>>m;
	int lock=0;
	rep(i,m){
		string tmp;
		cin>>tmp;
		if(ma[tmp]==1){
			if(lock==0){
				cout<<"Opened by ";
				lock=1;
			}
			else{
				cout<<"Closed by ";
				lock=0;
			}
		}
		else{
			cout<<"Unknown ";
		}
		cout<<tmp<<endl;
	}
}

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

int main(){
  int N, M;
  string s;
  set<string> key;
  
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> s;
    key.insert(s);
  }
  
  cin >> M;
  bool flag = false;
  for(int i = 0 ; i < M ; i++){
    cin >> s;
    if(key.find(s) == key.end()){
      cout << "Unknown " << s << endl;
    }
    else{
      if(!flag){
	flag = true;
	cout << "Opened by " << s << endl;
      }
      else{
	flag = false;
	cout << "Closed by " << s << endl;
      }
    }
  }
  return 0;
}