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 <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

#define REP(i, n) for (int (i)=0; (i)<(n); (i)++)
#define SET(n, v) \
    do { \
        (v).resize(n); \
        REP(i, (n)) cin >> (v)[i]; \
    } while (false)

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main() {
    string oc[2] = {"Opened by ", "Closed by "};
    int N, M;
    hset<string> uid;

    string s;
    cin >> N;
    REP(i, N) {
        cin >> s;
        uid.insert(s);
    }

    int k=0;
    cin >> M;
    REP(i, M) {
        cin >> s;
        if (uid.find(s) == uid.end()) {
            cout << "Unknown " << s << endl;
        } else {
            cout << oc[k] << s << endl;
            k = (k+1) % 2;
        }
    }

    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    int n,m;
    cin >> n;
    map<string, int> u;
    rep(i, n){
        string a;
        cin >> a;
        u[a]=1;
    }
    cin >> m;
    bool open=false;
    rep(i, m){
        string a;
        cin >> a;
        if (u[a]==1) {
            if (open) {
                open = false;
                cout << "Closed by "<<a<<endl;
            }else{
                open = true;
                cout << "Opened by "<<a<<endl;
            }
            continue;
        }else{
            cout << "Unknown "<<a<<endl;
        }
    }
}

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

vector<string> U(260); 
vector<string> T(260); 
int n,m;
int key=0;

int main(){
  cin>>n;
  for(int i=0;i<n;i++) { cin>>U[i];}
 
  cin>>m;
  for(int i=0;i<m;i++) {
    cin>>T[i];
  }
  
  sort(U.begin(),U.end());

  for(int i=0;i<n;i++){
    
    if(*lower_bound(U.begin(),U.end(),T[i])==T[i]){
      if(key==0){ key=1; cout<<"Opened by "<<T[i]<<endl;}
      else {key=0; cout<<"Closed by "<<T[i]<<endl;}
    }
    
    else{cout<<"Unknown "<<T[i]<<endl;}
  }

  return 0;}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    int n; cin >> n;
    set<string> val;

    rep(i, 0, n) {
        string s; cin >> s;
        val.insert(s);
    }

    int m; cin >> m;

    bool isopen = false;
    
    rep(i, 0, m) {
        string s; cin >> s;
        if (val.find(s) != val.end()) {
            if (isopen) cout << "Closed by ";
            else cout << "Opened by ";

            isopen ^= 1;
            cout << s << endl;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
    string reg[300],num;
    int FLG=0,L,LL;
    cin>>L;
    for(int i=0;i<L;i++){
        cin>>reg[i];
    }
    cin>>LL;
    while(LL--){
        int uno=0;
        cin>>num;
        for(int i=0;i<L;i++){
            if(num==reg[i]){
                if(FLG==0){cout<<"Opened by "<<num<<endl;FLG=1;uno=1;break;}
                if(FLG==1){cout<<"Closed by "<<num<<endl;FLG=0;uno=1;break;}
            }
        }
    if(uno==0)cout<<"Unknown "<<num<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
        int N;
        cin >> N;
        string key[N];
        for(int i=0;i<N;i++) cin >> key[i];
        string ID;
        int M;
        cin >> M;

        bool lock = true, find = false;
        for(int i=0;i<M;i++){
            cin >> ID;
            for(int j=0;j<N;j++){
                if(ID == key[j]){
                    if(lock){
                        cout << "Opened by " << key[j] << endl;
                        lock = false;
                        find = true;
                        break;
                    }else{
                        cout << "Closed by " << key[j] << endl;
                        lock = true; 
                        find = true;
                        break;
                    }
                }
            }
            if(!find) cout << "Unknown " << ID << endl;
            find = false;
        }
}

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


int main(){
  vector<string> mem;
  string s;
  int n;
  bool flag=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    mem.push_back(s);
  }
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<mem.size();j++){
      if(mem[j]==s){
	if(flag==0){
	  cout<<"Opened by "<<s<<endl;
	  flag=1;
	}else{
	  cout<<"Closed by "<<s<<endl;
	  flag=0;
	}
	//cout<<"flag is "<<flag<<endl;
	break;
      }
      if(j==mem.size()-1)cout<<"Unknown "<<s<<endl;
    }
  }
  return 0;
}

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

int main(){
map<string,int> hito;
int n,m;
string s;
cin>>n;
for(int q=0;q<n;q++){
cin>>s;
hito[s]=1;
}
cin>>m;
int j=0;
for(int q=0;q<m;q++){
cin>>s;
if(hito.find(s)==hito.end()) cout<<"Unknown "<<s<<endl;
else{
if(j%2==1)cout<<"Closed by "<<s<<endl;
else cout<<"Opened by " <<s<<endl;
j++;
}
}


return 0;
}