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>

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int N, M;

int main() {
	cin >> N;
	string U[N];
	rep(i, N) cin >> U[i];
	bool lock = false;
	cin >> M;
	rep(i, M) {
		string T; cin >> T;
		rep(j, N) {
			if (T == U[j]) {
				if (lock) {
					cout << "Closed by " << T << endl;
					lock = false;
					break;
				} else {
					cout << "Opened by " << T << endl;
					lock = true;
					break;
				}
			} else if (j == N - 1) {
				cout << "Unknown " << T << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    set<string> ids;
    bool is_closed = true;

    int n;
    cin >> n;

    for( int i=0; i<n; ++i ) {
        string s;
        cin >> s;

        ids.insert( s );
    }

    int m;
    cin >> m;

    for( int i=0; i<m; ++i ) {
        string s;
        cin >> s;

        if ( ids.find( s ) != ids.end() ) {
            cout << ( is_closed ? "Opened" : "Closed" ) << " by " << s << endl;
            is_closed = !is_closed;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m;
	string u[256];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>u[i];
	bool door=true;
	string a;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>a;
		bool t=false;
		for(int j=0;j<n;j++){
			if(u[j]==a){
				t=true;
				if(door==true){
					cout<<"Opened by "<<a<<endl;
					door=false;
				}
				else{
					cout<<"Closed by "<<a<<endl;
					door=true;
				}
			}
		}
		if(t==false)
			cout<<"Unknown "<<a<<endl;
	}
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
	int n,m;
	cin>>n;
	string s;
	set<string>u;
	for(int i=0;i<n;i++){
		cin>>s;
		u.insert(s);
	}
	cin>>m;
	int parity=0;
	for(int i=0;i<m;i++){
		cin>>s;
		if(u.count(s)==0)cout<<"Unknown"<<" "<<s<<endl;
		else{
			if(parity==0){
				cout<<"Opened by"<<" "<<s<<endl;
				parity=1;
			}
			else{
				cout<<"Closed by"<<" "<<s<<endl;
				parity=0;
			}
		}
	}
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    map<string, int> ma;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        ma[s]++;
    }
    int m;
    cin >> m;
    int cnt = 1;
    for (int i = 0; i < m; ++i) {
        string t;
        cin >> t;
        if(ma.count(t)){
            printf(cnt%2 ? "Opened by " : "Closed by ");
            cnt++;
        }else {
            printf("Unknown ");
        }
        cout << t << "\n";
    }
    return 0;
}

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

int main(){
  int N,M;
  string str[257];
  cin>>N;
  string str2[257];
  int f,k=0;
  for(int i=0;i<N;i++){
    cin>>str[i];
  }
  cin>>M;
  for(int i=0;i<M;i++){
    cin>>str2[i];
  }

  for(int i=0;i<M;i++){
    f=0;
    for(int j=0;j<N;j++){
      if(str2[i]==str[j]){
	if(k==0){
	  f=1;
	  k=1;
	  cout<<"Opened by "<<str2[i]<<endl;
	  break;
	}else{
	  k=0;
	  cout<<"Closed by "<<str2[i]<<endl;
	  break;
	}
      }
      else{
	if(j==N-1 && f==0) cout<<"Unknown "<<str2[i]<<endl;
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<set>
#include<string>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)

int main(){
	int N, M; cin >>N;
	int openFlg = 0;
	set<string> s;
	rep(i, N){
		string tmp; cin >>tmp;
		s.insert(tmp);
	}
	cin >>M;
	rep(i, M){
		string tmp; cin >>tmp;
		if(s.find(tmp) != s.end()){
			openFlg = (openFlg + 1) % 2;
			if(openFlg == 1) cout <<"Opened by ";
			else cout <<"Closed by ";
			cout <<tmp <<endl;
		} else{
			cout <<"Unknown " <<tmp <<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  vector<string>sis(256);
  int n,m;

  cin>>n;
  rep(i,n)cin>>sis[i];

  cin>>m;
  int key=1;
  rep(i,m){
    string in;
    bool known=false;
    cin>>in;
    rep(i,n)if(sis[i]==in)known=true;
    if(known){
      if(key){cout<<"Opened by "<<in<<endl;key=0;}
      else {cout<<"Closed by "<<in<<endl;key++;}
    }else cout<<"Unknown "<<in<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int N,M;
	scanf("%d",&N);
	int flag=0,oc=0,i,j;
	char U[256][11];
	for(i=0;i<N;i++){
		scanf("%s",U[i]);
	}
	scanf("%d",&M);
	char T[11];
	for(i=0;i<M;i++){
		flag=0;
		scanf("%s",T);
		for(j=0;j<N;j++){
			if(strcmp(U[j],T)==0){
				flag=1;
				break;
			}
		}
		if(flag==0){
			cout<<"Unknown "<<T<<endl;
		}else if(oc==0){
			cout<<"Opened by "<<T<<endl;
			oc=1;
		}else{
			cout<<"Closed by "<<T<<endl;
			oc=0;
		}
	}


	return 0;
}

C++: #include <iostream>

using namespace std;

bool flag;

bool check(string t, string u){
 if(s==t){
  if(!flag)cout << "Opened by " << t << endl;
  else cout << "Closed by " << t << endl;
  flag ^= 1;
  return true;
 }
 return false;
}


int main(){
 int n,i,j,m;
 bool ans=false;
 string u[260],t[260];
 cin >> n;
 for(i=0;i<n;i++)cin >> u[i];
 cin >> m;
 for(i=0;i<m;i++)cin >> t[i];
 for(i=0;i<m;i++){
  ans = false;
  for(j=0;j<n;j++)ans|=check(t[i],u[j]);
  if(!ans)cout << "Unknown " << t[i] << endl;
 }
 return 0;
}

C++: #include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

vector<string> U(260); 
vector<string> T(260); 
int n,m;
int key=0;

int main(){
  cin>>n;
  for(int i=0;i<n;i++) { cin>>U[i];}
 
  cin>>m;
  for(int i=0;i<m;i++) {
    cin>>T[i];
  }
  
  sort(U.begin(),U.end());

  for(int i=0;i<n;i++){
    
    if(*lower_bound(U.begin(),U.end(),T[i])==T[i]){
      if(key==0){ key=1; cout<<"Opened by"<<T[i]<<endl;}
      else {key=0; cout<<"Closed by"<<T[i]<<endl;}
    }
    
    else{cout<<"Unknown"<<T[i]<<endl;}
  }

  return 0;}