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 <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 << "Opend by " << s << endl;
	  open = true;
	}
      }
    }
    if (f) cout << "Unknown " << s << endl;
  }
}

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 <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n, m;
    cin >> n;
    string u[n];
    for (int i = 0; i < n; i++) cin >> u[i];
    
    bool key = 0;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string t;
        cin >> t;
        string pf = "Unknown";
        for (int j = 0; j < n; j++) {
            if (t == u[j]) {
                if (key) pf = "Closed by";
                else pf = "Opened by";
                key ^= 1;
                break;
            }
        }
        cout << pf _ t << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,m;
string u[300],t[300];
string s;

int main() {
	cout << fixed << setprecision(18);
	bool open=false;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>t[i];
		for(int j=0;j<n;j++){
			if(t[i]==u[j]&&!open){
				cout<<"Opened by "<<t[i]<<endl;
				open=true;
				break;
			}else if(t[i]==u[j]){
				cout<<"Closed by "<<t[i]<<endl;
				open=false;
				break;
			}
			if(j==n-1){
				cout<<"Unknown "<<t[i]<<endl;
			}
		}
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<string> S;
    for (int i = 0; i < N; i++) {
        string u;
        cin >> u;
        S.insert(u);
    }
    int M;
    cin >> M;
    bool open = false;
    while (M--) {
        string t;
        cin >> t;
        if (S.find(t) != S.end()) {
            if (!open) cout << "Opened by " << t << endl;
            else cout << "Closed by " << t << endl;
            open = !open;
        } else cout << "Unknown " << t << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <unordered_map>

std::unordered_map<std::string, int> m;

int main(){
    int N;
    std::cin >> N;

    for(int i=0;i<N;i++){
        std::string key;
        std::cin >> key;

        ++m[key];
    }

    int M;
    std::cin >> M;

    bool locked = true;
    for(int i=0;i<M;i++){
        std::string id;
        std::cin >> id;

        if(m[id] > 0){
            if(locked){
                std::cout << "Opened by " << id << std::endl;
            }else{
                std::cout << "Closed by " << id << std::endl;
            }
            locked ^= 1;
        }else{
            std::cout << "Unknown " << id << std::endl;
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
void solve(vector<string> ids,vector<string> strs){
    bool s=false,st=false;
    for(string x:strs){
        st=s;
        for(string y:ids){
            if(x==y){
                if(s){
                    s=false;
                    cout<<"Closed by "<<y<<endl;
                }
                else{
                    s=true;
                    cout<<"Opened by "<<y<<endl; 
                }
            }
        }
        if(st==s){
            cout<<"Unknown b"<<x<<endl; 
        }
    }
}



int main(void){
    int a;
    string str;
    vector<string> ids,strs;
    cin>>a;
    for(int i=0;i<a;i++){
        cin >> str;
        ids.push_back(str);
    }
    cin >> a;
    for(int i=0;i<a;i++){
        cin >> str;
        strs.push_back(str);
    }
    solve(ids,strs);
}

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



int main()
{
	int N, M;
	vector<string> U;
	bool flag = true;
	string str;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> str;
		U.push_back(str);
	}

	cin >> M;

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

		bool f = false;

		for (int j = 0; j < N; j++) {
			if (str == U[j]) {
				if (flag == true) {
					cout << "Opened by " << U[j] << endl;
					flag = false;
				}
				else {
					cout << "Closed by " << U[j] << endl;
					flag = true;
				}
				f = true;
				break;
			}
		}

		if (f == false) {
			cout << "Unknown " << str << endl;
		}
	}

	return 0;
}