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 n;
int m;
char buf[100000];
set<string> ids;

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf(" %s", buf);
    ids.insert(buf);
  }

  scanf("%d", &m);

  bool opened = false;
  for (int i=0; i<m; i++) {
    scanf(" %s", buf);
    if (ids.count(buf)) {
      opened ^= 1;
      if (opened) printf("Opened by %s\n", buf);
      else printf("Closed by %s\n", buf);
    } else printf("Unknown %s\n", buf);
  }
}

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

int main() {
	int n;
	cin >> n;
	string str;
	vector<string> IDlist;
	for (int i = 0; i < n; ++i) {
		cin >> str;
		IDlist.emplace_back(str);
	}
	cin >> n;
	bool key = false;
	for (int i = 0; i < n; ++i) {
		cin >> str;
		for (int j = 0; j < IDlist.size(); ++j) {
			if (IDlist[j] == str) {
				if (key == false) {
					cout << "Opened by " << str << endl;
					key = true;
				}
				else {
					cout << "Closed by " << str << endl;
					key = false;
				}
				break;
			}
			if (j == IDlist.size() - 1) {
				cout << "Unknown " << str << endl;
			}
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

string nextString(){string s;cin >> s;return s;}

int main(){
  int n,m;
  vector<string> regid;
  string id;
  int isopen=0;
  cin >> n;
  REP(i,n)regid.push_back(nextString());
  cin >> m;
  REP(i,m){
    cin >> id;
    REP(j,regid.size()){
      if(id == regid[j]){
	if(isopen){
	  isopen--;
	  cout << "Closed by " << id << endl;
	}else{
	  isopen++;
	  cout << "Opened by " << id << endl;
	}
	break;
      }
      if(j == regid.size()-1)
	cout << "Unknown " << id << endl;
    }
  }
      
  return 0;
}

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

int main(void){
  int n, m, i;
  bool lock;
  string u, t, mess;
  map<string, bool> mp;

  cin >> n;
  for(i=0;i<n;i++){
    cin >> u;
    mp[u] = true;
  }
  
  lock = true;
  cin >> m;
  for(i=0;i<m;i++){
    cin >> t;
    if(mp.find(t) == mp.end()){
      cout << "Unknown " << t << endl;
    }else{
      mess = lock ? "Opened by ":"Closed by ";
      lock = not lock;
      cout << mess << t << endl;
    }
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main() {
	int N, M;
	cin >> N;

	set<string> name;
	string tmp;
	REP(i, N) {
		cin >> tmp;
		name.insert(tmp);
	}

	int status = 0;
	cin >> M;
	REP(i, M) {
		cin >> tmp;
		if(EXIST(name, tmp)) {
			if(!(status%2)) {
				cout << "Opened by " << tmp << endl;
			} else {
				cout << "Closed by " << tmp << endl;
			}
			status++;
		} else {
			cout << "Unknown " << tmp << endl;
		}
	}
	
	return 0;
}

C++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

  cin >> m;
  vector<string> t(m);
  rep (i, m) cin >> t[i];

  vector<bool> ut(m);
  bool opened = false;

  rep (i, m) {
    bool solved = false;

    rep (j, n) {
      if (t[i] == u[j]) {
        if (opened) {
          cout << "Closed by " << t[i] << endl;
          opened = false;
          solved = true;
        }
        else {
          cout << "Opened by " << t[i] << endl;
          opened = true;
          solved = true;
        }
        break;
      }
    }

    if (!solved) cout << "Unknown " << t[i] << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
int n,m;
string tmp;
bool opened=false;
vector<string>pass;
cin>>n;
for(int i=0;i<n;i++){
	cin>>tmp;
	pass.push_back(tmp);
}
cin>>m;
for(int i=0;i<m;i++){
	bool matched=false;
	cin>>tmp;
	for(int j=0;j<n;j++){
		if(pass[j]==tmp){
			if(opened)cout<<"Closed by "<<tmp<<endl;
			else cout<<"Opened by "<<tmp<<endl;
			opened=!opened;
			matched=true;
			break;
		}
	}
	if(!matched)cout<<"Unknown "<<tmp<<endl;
}
return 0;
}

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

int main()
{
	int N,M;
	char U[256][10];
	char T[10];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> U[i];
	}
	cin >> M;
	int cnt = 0;
	for (int i = 0; i < M; i++)
	{
		bool find = false;
		cin >> T;

		for (int j = 0; j < N; j++)
		{
			int c = strcmp(U[j], T);
			if (c == 0)
			{
				find = true;
				cnt++;
				break;
			}
		}

		if (find)
		{
			if (cnt % 2== 1)
			{
				cout << "Opened by "<< T << endl;
			}
			else
			{
				cout << "Closed by " << T << endl;
			}
		}
		else
		{
			cout << "Unknown " << T << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    bool isLocked = true;
    vector<string> map;
    int N, M;
    cin >> N;
    
    map.clear();
    map.resize(N);
    for (int i = 0; i < N; ++i) {
        string id;
        cin >> id;
        map[i] = id;
    }
    
    cin >> M;
    for (int i = 0; i < M; ++i) {
        string id;
        cin >> id;
        auto itr = find(map.begin(), map.end(), id);
        if (itr != map.end()) {
            if (isLocked) {
                cout << "Opened by " << id << "\n";
            } else {
                cout << "Closed by " << id << "\n";
            }
            isLocked = !isLocked;
        } else {
            cout << "Unknown " << id << "\n";
        }
    }
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  vector<string> U;
  string s;
  bool open, f;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    U.push_back(s);
  }
  cin >> M;
  open = false;
  for (int i = 0; i < M; ++i) {
    cin >> s;
    f = true;
    for (int j = 0; j < N; ++j) {
      if (U[j] == s) {
	f = false;
	if (open) {
	  cout << "Closed by " << s << endl;
	  open = false;
	} else {
 	  cout << "Opened by " << s << endl;
	  open = true;
	}
      }
    }
    if (f) cout << "Unknown " << s << endl;
  }
}