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<string>
using namespace std;

int main(){
  int i,j,n,m;
  string id[300],id_2;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> id[i];
  }

  cin >> m;
    int count=0;
    int k=1;
  while(m>0){
    m--;
    cin >> id_2;
    for(i = 0; i < n; i++){
      if(id_2==id[i]){
	count+=k;
	k++;
      }
    }
    
    if(count==0){
      cout << "Unknown" << " " << id_2 << endl;
    }
    else if(count%2==0){
      cout << "Closed by" << " " << id_2 << endl;
      count=0;
    }else if(count%2!=0){
      cout << "Opened by" << " " << id_2 << endl;
      count=0;
    }
  }
  return 0;
}

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

using namespace std;

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

int main(){
    set<string> ids;
    int n; cin>>n;
    rep(i,n){
        string id; cin >> id;
        ids.insert(id);
    }
    int m; cin >> m;
    bool open = true;
    string s[2]={"Opened by ","Closed by "};

    rep(i,m){
        string id; cin >> id;
        auto it=ids.find(id);
        if(it!=ids.end()){
            cout << s[open=1-open] << *it << endl;
        } else {
            cout << "Unknown " << id << endl;
        }
    }
}

C++: #include<iostream>
#include<set>
#include<map>
using namespace std;
int main(){
	int n,m;
	string str;
	set<string>	st;
	map<string,int>	mp;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> str;
		mp[str]++;
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> str;
		if(mp[str]!=0){
			if(mp[str]>0){
				cout << "Closed by " << str << endl;
				mp[str]=mp[str]*(-1);
			}
			else{
				cout << "Opened by " << str << endl;
				mp[str]=mp[str]*(-1);
			}
		}
		else	cout << "Unknown " << str << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	map<string,int>ma;
	rep(i,n){
		string s;
		cin>>s;
		ma[s]=1;
	}
	cin>>n;
	bool h=false;
	rep(i,n){
		string s;
		cin>>s;
		if(ma[s]==0)cout<<"Unknown "<<s<<endl;
		else{
			if(h)cout<<"Closed by "<<s<<endl;
			else cout<<"Opened by "<<s<<endl;
			h^=1;
		}
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <string.h>
using namespace std;
using ll = long long;

#define right true
#define left false

int main()
{
  int n;
  cin >> n;
  vector<string> u(n);
  for (auto &e : u)
    cin >> e;
  int m;
  cin >> m;
  vector<string> t(m);
  for (auto &e : t)
    cin >> e;

  bool state = 0;
  for (int i = 0; i < m; ++i)
  {
    bool exist = false;
    for (int j = 0; j < n; ++j)
    {
      if (t[i] == u[j])
        exist = true;
    }
    if (exist)
    {
      if (state)
      {
        cout << "Closed by " << t[i] << endl;
        state = false;
      }
      else
      {
        cout << "Opened by " << t[i] << endl;
        state = true;
      }
    }
    else
    {
      cout << "Unknown " << t[i] << endl;
    }
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    vector<string> u(n);
    rep(i, n) cin >> u[i];

    int status = 0;
    int m; cin >> m;
    rep(i, m) {
        string s; cin >> s;
        if (count(all(u), s)) {
            if (status) cout << "Closed by "+s << endl;
            else cout << "Opened by "+s << endl;
            status ^= 1;
        } else {
            cout << "Unknown " + s << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        int n;
        scanf("%d", &n);
        set<string> S;
        rep(i, n){
                string s;
                cin>>s;
                S.insert(s);
        }
        int m;
        scanf("%d", &m);
        int state=0;
        while(m--){
                string s;
                cin>>s;
                if(S.find(s)!=S.end()){
                        state^=1;
                        cout << (state ? "Opened " : "Closed ");
                        cout << "by " << s << "\n";
                }
                else{
                        cout << "Unknown " << s << "\n";
                }
        }
}

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

using namespace std;

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

int main(){
    set<string> ids;
    int n; cin>>n;
    rep(i,n){
        string id; cin >> id;
        ids.insert(id);
    }
    int m; cin >> m;
    bool open = true;
    string s[2]={"Opened by ","Closed by "};

    rep(i,m){
        string id; cin >> id;
        auto it=ids.find(id);
        if(it!=ids.end()){
            cout << s[open=1-open] << *it << endl;
        } else {
            cout << "Unknown " << id << 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=255;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;
	}
}