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;
  string scan;
  vector<string> ID;
  bool door=false;
  bool flag=false;

  cin >> N;

  for(int i=0; i<N; ++i){
    cin >> scan;
    ID.emplace_back(scan);
  }

  cin >> M;

  for(int i=0; i<M; ++i){
    cin >> scan;

    for(int k=0; k<ID.size(); ++k){
      if(ID[k]==scan){
	flag=true;
      }
    }

    if(flag){
      if(door){
	door=false;
	cout << "Closed by " << scan << endl;
      }else{
	door=true;
	cout << "Opened by " << scan << endl;
      }
    }else{
      cout << "Unknown " << scan << endl;
    }

    flag=false;
  }

  
  return 0;
}

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

int main(){
    int n,m;
    cin >> n;
    unordered_set<string> u(n);
    string tmp;
    for(int i=0; i<n; i++){
        cin >> tmp;
        u.insert(tmp);
    }
    cin >> m;

    bool locked=true;
    for(int i=0; i<m; i++){
        cin >> tmp;
        auto itr = find(u.begin(), u.end(), tmp);
        if(itr!=u.end()){
            if(locked){
                cout << "Opened by " << tmp << endl;
                locked = false;
            }else{
                cout << "Closed by " << tmp << endl;
                locked = true;
            }
        }else{
            cout << "Unknown " << tmp << endl;
        }
    }

    return 0;
}

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

int main() {
    int n;
    while (cin >> n and n) {
        vector<string> v(n);
        rep(i, n) cin >> v[i];
        int m; cin >> m;
        bool s=false;
        rep(i, m) {
            string t;
            cin >> t;

            bool f=false;
            rep(j, n) {
                if (v[j] == t) {
                    f=true;
                    break;
                }
            }

            if (f) {
                if (s) {
                    cout << "Closed by " << t << endl;
                    s = !s;
                }
                else {
                    cout << "Opened by " << t << endl;
                    s = !s;
                }
            }
            else {
                cout << "Unknown " << t << endl;
            }

        }
    }
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int n; cin>>n;
    set<string> st;
    REP(i,n){
        string s; cin>>s;
        st.insert(s);
    }
    
    int m; cin>>m;
    bool locked=true;
    REP(i,m){
        string s; cin>>s;
        if(st.count(s)){
            locked=!locked;
            cout<<(locked?"Closed by ":"Opened by ");
        } else{
            cout<<"Unknown ";
        }
        cout<<s<<endl;
    }
        
}

C++: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	string s[1000] = {};
	for (int i = 0; i < N; i++)cin >> s[i];
	cin >> M;
	string t;
	bool door = true;
	for (int i = 0; i < M; i++) {
		cin >> t;
		bool f = false;
		for (int j = 0; j < N; j++) {
			if (t == s[j])f = true;
		}
		if (f) {
			if (door) {
				cout << "Opened by " << t << endl;
			}
			else {
				cout << "Closed by " << t << endl;
			}
			door ^= true;
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    set<string> U;
    while(N--){
        string id;
        cin >> id;
        U.insert(id);
    }
    bool cl = true;
    int M;
    cin >> M;
    while(M--){
        string T;
        cin >> T;
        if(!U.count(T))T = "Unknown " + T;
        else{
            T = (cl? "Opened by ": "Closed by ") + T;
            cl = !cl;
        }
        cout << T << '\n';
    }
    return 0;
}

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

int main() {
  int N, M, key = 0, kk = 0;
  string U[256], T;
  cin >> N;
  rep(i, N) cin >> U[i];
  cin >> M;
  rep(i, M) {
    cin >> T;
    rep(i, N) {
      if (U[i] == T && key == 0) {
        cout << "Opened by " << T << endl;
        key = 1;
        kk = 1;
        break;
      } else if (U[i] == T && key == 1) {
        cout << "Closed by " << T << endl;
        key = 0;
        kk = 1;
        break;
      }
    }
    if (kk == 0) {
      cout << "Unknown " << T << endl;
    }
    kk = 0;
  }
  return 0;
}

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

int main(){
  int n, m;
  std::cin >> n;
  set<string> u;
  for (int i = 0; i < n; i++) {
    string s;
    std::cin >> s;
    u.insert(s);
  }
  std::cin >> m;
  string t;
  bool lock = 1;
  for (int i = 0; i < m; i++) {
    std::cin >> t;
    if(u.find(t) != u.end()){
      if(lock == 1){
        std::cout << "Opened by " << t << std::endl;
      }else{
        std::cout << "Closed by " << t << std::endl;
      }
      lock = 1 - lock;
    }else{
      std::cout << "Unknown " << t << std::endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
using namespace std;
map<string,int> tbl;
string input(){ string s;cin>>s;return s;}
int main(){
  int n,m;
  bool open = false;
  cin>>n;
  while(n--){
    tbl[input()]=1;
  }
  cin>>m;
  while(m--){
    string s = input();
    if(!tbl[s]) cout << "Unknown " << s << endl;
    else if(open){
      cout << "Closed by " << s << endl;
      open = false;
    }
    else{
      cout << "Opened by " << s << endl;
      open = true;
    }
  }
  return 0;
}

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

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

int main() {
	int n, m;
	cin >> n;
	vector<string> sn(n);
	rep(i, n) {
		cin >> sn[i];
	}
	cin >> m;
	bool open = true;
	rep(i, m) {
		string in;
		cin >> in;
		bool match = false;
		rep(j, n) {
			if( sn[j] == in ) {
				match = true;
				break;
			}
		}
		if(match) {
			cout << (open ? "Opened by " : "Closed by ");
			open = !open;
		} else {
			cout << "Unknown ";
		}
		cout << in << endl;
	}
	return 0;
}