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<queue>
#include<algorithm>
#include<complex>
#include<string>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> ivv;

vector<string> v;

int main()
{
	int n,m;
	bool flag = true;
	
	cin >> n;
	
	REP(i,n)
	{
		string tmps;
		cin >> tmps;
		v.PB(tmps);
	}
	
	cin >> m;
	
	REP(i,m)
	{
		bool con = false;
		string tmp;
		cin >> tmp;
		
		REP(j,n)
		{
			if(v[j] == tmp)
			{
				if(flag)
				{
					cout << "Opened by " << tmp << endl;
					flag = !flag;
					con = true;
					break;
				}
				else
				{
					cout << "Closed by " << tmp << endl;
					flag = !flag;
					con = true;
					break;
				}
			}
		}
		
		if(!con)
			cout << "Unknown " << tmp << endl;
		
	}
			
	
	return 0;
}

C++: // AOJ 2440 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2440)
#include<iostream>
#include<set>
#include<string>
#define rep(i,a) for(int i=0;i<(a);++i)

int N, M;
std::set<std::string> s;
bool key = true;

int main()
{
	std::cin >> N;
	rep( i, N )
	{
		std::string U;
		std::cin >> U;

		s.insert(U);
	}

	std::cin >> M;
	rep( i, M )
	{
		std::string T;
		std::cin >> T;
			
		if( s.count(T) )
		{
			key ^= true;
			std::cout << (key?"Closed by ":"Opened by ");
		}
		else
			std::cout << "Unknown ";

		std::cout << T << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

#define loop(lp) for(int lp2 = 0; lp2 < lp; lp2 ++)
#define ascent(i, a, b) for(int i = a; i < b; i ++)

#define pb push_back

using namespace std;

int main() {
  int N, M;
  map<int, string> sysID;

  cin >> N;
  ascent(i, 0, N) {
    string tmp;
    cin >> tmp;
    sysID.insert(make_pair(i, tmp));
  }

  cin >> M;
  bool door = false; //if the door opened, then "true"
  ascent(i, 0, M) {
    string card;
    cin >> card;
    //   cout << "  " << card << endl;

    ascent(j, 0, N) {
      //cout << "   " << sysID[j] << endl;
      if(sysID[j] == card) {
	if(door) {
	  cout << "Closed by " << card << endl;
	}
	else {
	  cout << "Opened by " << card << endl;
	}

	door = !door;
	break;
      }

      if(j == N-1) {
	cout << "Unknown " << card << endl;
      }
    }
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n,m,f=-1;
	cin>>n;
	set<string> str;
	string u,t;
	rep(i,0,n){
		cin>>u;
		str.insert(u);
	}
	cin>>m;
	rep(i,0,m){
		cin>>t;
		if(str.count(t)){
			cout<<(f==-1?"Opened by ":"Closed by ");
			cout<<t<<endl;
			f*=-1;
		}else{
			cout<<"Unknown "<<t<<endl;
		}
	}
}
/*
int main(){
	int n,m,f=-1;
	cin>>n;
	vector<string> u(n);
	string t;
	rep(i,0,n) cin>>u[i];
	cin>>m;
	sort(all(u));
	rep(i,0,m){
		cin>>t;
		if(binary_search(all(u),t)){
			cout<<(f==-1?"Opened by ":"Closed by ");
			cout<<t<<endl;
			f*=-1;
		}else{
			cout<<"Unknown "<<t<<endl;
		}
	}
}*/

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

C++: #if 1
#include <bits/stdc++.h>
#else
#include "../../bits/stdc++.h"
#endif

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

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N, M;
char U[258][12], T[258][12];

void input(){
  cin>>N;
  REP(i, N)cin>>U[i];
  cin>>M;
    REP(i, M)cin>>T[i];
}

void solve(){
  bool d=true;
  REP(i, M) {
    bool c = false;
    REP(j, N) {
      c = [](int x, int y) {
        int k;
        if(U[x][0]!=T[y][0])return false;
        for(k=1;U[x][k-1]!='\0';k++) {
          if(U[x][k]!=T[y][k])return false;
        }
        return true;
      }(j, i);
      if(c) {
        if(d)cout<<"Opened by "<<T[i];
        else cout<<"Closed by "<<T[i];
        d = !d;
        break;
      }
    }
    if(!c)cout<<"Unknown "<<T[i];
    cout<<endl;
  }
}

int main(){
  cin.tie(0);

  input();
  solve();

  return 0;
}

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

using namespace std;

int main() {
  int n, m;
  bool is_opened = false;
  string u, t;
  set<string> ids;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> u;
    ids.insert(u);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> t;
    if (ids.count(t) > 0) {
      if (is_opened) {
        cout << "Closed by " << t << endl;
      } else {
        cout << "Opened by " << t << endl;
      }
      is_opened = not is_opened;
    } else {
      cout << "Unknown " << t << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
	int n,m;
	int i1,i2;
	string s;
	int open; // 0 close 1 open

	open = 0;
	cin >> n;
	vector<string> u(n);
	for(i1=0;i1<n;i1++){
		cin >> u[i1];
	}

	cin >> m;
	for(i1=0;i1<m;i1++){
		cin >> s;

		if (find(u.begin(),u.end(),s)==u.end()) {
			cout << "Unknown " << s << endl;
		}
		else{
			if (open==0){
				open = 1;
				cout << "Opened by " << s << endl;
			}
			else{
				open = 0;
				cout << "Closed by " << s << endl;
			}
		}
	}

	return 0;
}