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, m;
  cin >> n;
  vector<string> u(n);
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> u[i];
    mp[u[i]]++;
  }
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }
  bool f = true;
  for (int i = 0; i < m; i++) {
    if (mp[t[i]] == 0) {
      cout << "Unknown " << t[i] << endl;
    } else {
      if (f) {
        f = !f;
        cout << "Opened by " << t[i] << endl;
      } else {
        f = !f;
        cout << "Closed by " << t[i] << endl;
      }
    }
  }

  return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n,m;
	set<string> u;
	string s;

	int k=0; //0:close 1:open

	cin>>n;
	for(int i1=0;i1<n;i1++){
		cin>>s;
		u.insert(s);
	}

	cin>>m;

	for(int i1=0;i1<m;i1++){
		cin>>s;
		if(u.find(s)!=u.end()) {
			if(k==0) {
				cout<<"Opened by "+s<<endl;
				k=1;
			}
			else {
				cout<<"Closed by "+s<<endl;
				k=0;
			}
		}
		else cout<<"Unknown "+s<<endl;

	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, M;
string U[310], T[310];

void _main() {
    cin >> N;
    set<string> st;
    REP (i, N) {
        cin >> U[i];
        st.insert(U[i]);
    }
    cin >> M;
    bool open = false;
    REP (i, M) {
        cin >> T[i];
        if (st.count(T[i]) == 0) {
            cout << "Unknown " << T[i] << endl;
        } else if (open) {
            cout << "Closed by " << T[i] << endl;
            open = false;
        } else {
            cout << "Opened by " << T[i] << endl;
            open = true;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main(){
  int n,m;
  int cnt=0,flg=0;
  string u[260]={},t[260]={};
  
  cin >> n;
  for(int i=0;i < n;i++)
    {
      cin >> u[i];
    }
  
  cin >> m;
  for(int j=0;j < m;j++)
    {
      cin >> t[j];
    }

  for(int j=0;j < m;j++)
    {
      flg=0;
      for(int i=0;i < n;i++)
	{
	  if(t[j]==u[i] && cnt ==0)
	    {
	      cnt++;
	      flg = 1;
	      cout << "Opened by " << t[j] << endl;
	    }
	  else if(t[j]==u[i] && cnt ==1)
	    {
	      cnt--;
	      flg = 1;
	      cout << "Closed by " << t[j] << endl;
	    }
	}
      if(flg==0)
	{
	  cout << "Unknown " << t[j] << endl;
	}
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,m; cin>>n;
	string id[n];
	for(int i = 0; i < n; ++i)
	{
		cin>>id[i];
	}
	cin>>m;
	bool isOpen=false;
	for(int i = 0; i < m; ++i)
	{
		string in; cin>>in;
		bool out=false;
		for(int j = 0; j < n; ++j)
		{
			if(in==id[j])
			{
				if(!isOpen) cout<<"Opened by "<<in<<endl;
				else cout<<"Closed by "<<in<<endl;
				isOpen=!isOpen;
				out=true;
				break;
			}
		}
		if(!out) cout<<"Unknown "<<in<<endl;
	}
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,now=0;
	string ic[256],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=sizeof(string);j>0&&!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++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n,m;
  bool open;

  cin >> n;
  string tou[200];
  REP(i,n){
	cin >> tou[i];
  }
  cin >> m;
  string kita;
  REP(i,m){
	cin >> kita;
	REP(j,n){

	  if(kita == tou[j]){
		if(open){
		  cout<<"Opened by "<<kita<<endl;
		  open = (not open);
		}else{
		  cout<<"Closed by "<<kita<<endl;
		  open = (not open);
		}
	  }else{
		cout<<"Unknown "<<kita<<endl;
	  }
	}
  }
}

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

int main() {
  int N; cin >> N;
  map<string,bool> U;
  for(int i = 0; i < N; ++i) {
    string id; cin >> id;
    U[id];
  }
  int M; cin >> M;
  while(M--) {
    string id; cin >> id;
    if(U.count(id)) {
      if(U[id]) cout << "Closed by " << id << endl;
      else cout << "Opened by " << id << endl;
      U[id] ^= 1;
    } else {
      cout << "Unknown " << id << endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
using namespace std;
using ll = long signed long;

int main() {

    ll n; cin >> n;

    set<string> u;
    REP(i, n) {
        string ui; cin >> ui;
        u.insert(ui);
    }

    ll m; cin >> m;

    bool o = false;
    REP(i, m) {
        string ti; cin >> ti;
        bool found = u.find(ti) != u.end();
        if (found) {
            if (o) {
                cout << "Closed by " + ti << "\n";
            } else {
                cout << "Opened by " + ti << "\n";
            }
            o = !o;
        } else {
            cout << "Unknown " + ti << "\n";
        }
    }

}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int main(){
  int n,m;
  vector<string> v;
  string str;
  int flag1 = 0;
  int flag2;
  cin >> n;
  for(int i = 0; i < n;i++){
    cin >> str;
    v.push_back(str);
  }

  cin >> m;

  for(int i = 0;i < m;i++){
    cin >> str;
    flag2 = 0;
    for(int j = 0; j < v.size();j++){
      if(str == v[j]){
        if(flag1 == 0){
          cout << "Opened by "<<str << endl;
          flag2 = 1;
          flag1 = 1;
        }else if(flag1 == 1){
          cout << "Closed by "<< str << endl;
          flag2 = 1;
          flag1 = 0;
        }
      }
    }
    if(flag2 == 0){
      cout << "Unknown " << str << endl;
    }
  }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string>ch(n);
  for(int i=0;i<n;i++)
    cin>>ch[i];
  bool flag=false;
  int m;cin>>m;
  for(int i=0;i<m;i++){
    string str;cin>>str;
    int j;
    for(j=0;j<m;j++){
      if(ch[j]==str){
	if(flag){
	  cout<<"Closed by "<<str<<endl;
	  flag=false;
	  break;
	}else{
	  cout<<"Opened by "<<str<<endl;
	  flag=true;
	  break;
	}
      }
    }
    if(j==m)
      cout<<"Unknown "<<str<<endl;
  }
  return 0;
}