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<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;

class UnionFind {
private:
	std::vector<int> parent;
	std::vector<int> height;
	std::vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 1);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};


int main() {

	int n, m; cin >> n;

	string user[256];

	for (int i = 0; i < n; i++) {
		cin >> user[i];
	}

	cin >> m;

	string t[256];

	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}

	bool swich = true;//true:施錠 false:開錠  状態

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

C++: // Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N, M;
  cin >> N;
  vector<string> U(N);
  for (int i = 0; i < N; i++) {
    cin >> U[i];
  }

  cin >> M;
  int state = 0; // 0:locked, 1:unlocked
  for (int i = 0; i < M; i++) {
    string s; cin >> s;
    int unknown = 1;
    for (int j = 0; j < N; j++) {
      if (s == U[j]) {
        if (state == 0) {
          state = 1;
          cout << "Opened by ";
        } else {
          state = 0;
          cout << "Closed by ";
        }
        cout << s << endl;
        unknown = 0;
        break;
      }
    }
    if (unknown) {
      cout << "Unknown " << s << endl;
    }
  }
}

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

using namespace std;

int main(){
	int n,m,sum;
	sum=0;
	string S[1000],T;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>S[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>T;
		for(int j=0;j<n;j++){
			if(S[j]==T){
				sum++;
				if(sum%2==0){
					cout<<"Closed by "<<T<<endl;
				}
				else{
					cout<<"Opened by "<<T<<endl;
				}
				goto Exit;
			}
		}
		cout<<"Unknown "<<T<<endl;
Exit:;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<string> users(n);

    for( auto &x : users )
        cin >> x;

    int m;
    cin >> m;

    int state = 0;

    for(int i = 0; i < m; i++){

        string t;
        cin >> t;

        if( find(users.begin(), users.end(), t) != users.end() ){

            state ^= 1;

            if(state)
                cout << "Opened by ";
            else
                cout << "Closed by ";

            cout << t << endl;

        } else {
            cout << "Unknown " << t << endl;
        }

    }

    return 0;

}

C++: #include<iostream>
#include<vector>
#include<queue>

using namespace std;

bool find(string str, vector<string> v){
	for (int i = 0; i < v.size(); i++){
		if (v[i] == str) return true;
	}
	return false;
}

int main(){
	int n; cin >> n;
	vector<string> regist(n);
	for (int i = 0 ; i < n; i++){
		cin >> regist[i];
	}
	bool lock = false;

	int m; cin >> m;
	for (int i = 0; i < m; i++){
		string id; cin >> id;
		if (find(id,regist) and !lock){
			cout << "Opened by " << id << endl;
			lock = true;
		}else if (find(id,regist) and lock){
			cout << "Closed by " << id << endl;
			lock = false;
		}else if (!find(id,regist)){
			cout << "Unknown " << id << endl;
		}
	}

return 0;
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPEQ(i, n) FOREQ(i, 0, n)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline int size(const T& x) { return x.size(); }
template <typename T1, typename T2> inline void
updateMax(T1& x, const T2& y) { if (y < x) { x = y; } }
template <typename T1, typename T2> inline void
updateMin(T1& x, const T2& y) { if (x < y) { x = y; } }
template <typename T1, typename T2, typename K1, typename K2> inline void
updateMax(T1& x, K1& i, const T2& y, const K2& j) { if (y < x) { x = y; i = j; } }
template <typename T1, typename T2, typename K1, typename K2> inline void
updateMin(T1& x, K1& i, const T2& y, const K2& j) { if (x < y) { x = y; i = j; } }

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

  int N;
  while (cin >> N) {
    vector<string> ids(N);
    REP(i, N) cin >> ids[i];
    sort(ALL(ids));

    int M; cin >> M;
    bool open = false;
    REP(i, M) {
      string id; cin >> id;
      auto p = equal_range(ALL(ids), id);
      if (p.first != p.second) {
        open = !open;
        if (open) cout << "Opened by " << id << endl;
        else cout << "Closed by " << id << endl;
      } else {
        cout << "Unknown " << id << endl;
      }
    }
  }
}

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

int main(){
  int n,m;
  string t;
  string u;
  int cnt = 0;
  cin>>n;
 for(int i=0;i<n;i++){
 cin>>u;
 }
 cin>>m;
 for(int j=0;j<m;j++){
 cin>>t;
 }
 for(int i=0;i<n;i++){
 for(int j=0;j<m;j++){
 if(u == t) cnt++;
 }
 if(cnt == 1) cout<<"Opened by"<<" "<<u<<endl;
 else cout<<"Closed by"<<" "<<u<<endl;
 }

   return 0;
}

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

int main(){
　int N,M;
  int cnt1 = 0;
  int cnt2 = 0;
  string U[256];
  string T[256];
  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++){
  for(int i=0;i<N;i++){
 if(T[j] == U[i]) cnt1++;
 else cnt2++;
 }
if(cnt1 % 2 == 1 && cnt2 != N) cout<<"Opened by"<<" "<<T[j]<<endl;
if(cnt1 % 2 == 0 && cnt2 != N) cout<<"Closed by"<<" "<<T[j]<<endl;
if(cnt2 == N) cout<<"Unknown"<<" "<<T[j]<<endl;
cnt2 = 0;
}
 return 0;
}