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 <string>
#include <set>
#include <iostream>
using namespace std;

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

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

int main(){
  int n,m;
  vector<string> u;
  string t;

  cin >> n;

  for(int i=0;i<n;i++){
    string var;
    cin >> var;
    u.push_back(var);
  }

  cin >> m;
  int state=0; // close

  for(int i=0;i<m;i++){
    cin >> t;
    for(int j=0;j<n;j++){
      if(t==u[j]){
        if(state==0){
          cout << "Opened by " << t << endl;
          state=1;
        }else{
          cout << "Closed by " << t << endl;
          state=0;
        }
        break;
      }else if(t!=u[j]&&j==n-1){
        cout << "Unknown " << t << endl;
        break;
      }
    }
  }
  return 0;
}

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

int main(){
    int N,M,openflag=0,flag = 0;
    string baf_U,baf_T;
    string U[256];
    string T[256];
    cin >> N;
    for(int i= 0;i<N;i++){
        cin >> baf_U;
        U[i] = baf_U;
    }
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> baf_T;
        T[i] = baf_T;
    }
    for(int i=0;i<M;i++){
        for(int k = 0;k<N;k++){
            if(U[k]==T[i]){
                flag = 1;
            }
        }
        if(flag ==1){
            if(openflag==0){
                cout <<"Opened by "<<T[i]<<endl;
                openflag = 1;
            }else{
                cout <<"Closed by "<<T[i]<<endl;
                openflag = 0;
            }
        }else{
            cout <<"Unknown "<<T[i]<<endl;
        }
        flag = 0;
    }
    exit(0);
}

C++: #include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;


int main(){
  int n,m;
  cin>>n;
  vector<string> user(n);
  rep(i,n)cin>>user[i];
  cin>>m;
  vector<string> t(m);
  rep(i,m)cin>>t[i];
  int key=1;
  if(n<=m)
  rep(i,m){
    rep(j,n){
      if(t[i]==user[j]){
	cout<<(key>0?"Opened by":"Closed by")<<t[i]<<endl;
	key*=-1;
	break;
      }else if(j==n-1){
	cout<<"Unknown"<<t[i]<<endl;
      }
    }
  }
  return 0;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	string s[256];
	rep(i,n) cin>>s[i];

	int q; cin>>q;
	bool b=true;
	while(q--){
		string t; cin>>t;
		if(count(s,s+n,t)==0) cout<<"Unknown "<<t<<endl;
		else{
			cout<<(b?"Opened by ":"Closed by ")<<t<<endl;
			b^=true;
		}
	}

	return 0;
}

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

using namespace std;

string message[] = {"Opened by ","Closed by "};
int cnt;
int main() {
    int n,m;
    set<string> data;
    cin>>n;
    for(int i=0;i<n;i++) {
        string ss; cin>>ss;
        data.insert(ss);
    }

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

    return 0;
}