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 <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int n; cin>>n;
    set<string> key;
    REP(i,n){
        string t; cin>>t;
        key.insert(t);
    }
    
    cin>>n;
    bool state = false;
    REP(i,n){
        string t; cin>>t;
        if(key.find(t)==key.end()){
            cout<<"Unknown "<<t<<endl;
        }else{
            if(state){
                cout<<"Closed by "<<t<<endl;
            }else{
                cout<<"Opened by "<<t<<endl;
            }
            state=!state;
        }
    }
    
    return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int main(){
    int n;
    vector<string> ok;
    scanf("%d",&n);
    rep(i,n){
        string str;
        cin >> str;
        ok.push_back(str);
    }
    int m;
    bool f = false;
    scanf("%d",&m);
    rep(i,m){
        bool c = false;
        string str;
        cin >> str;
        rep(j,n){
            if(ok[j] == str){
                (f) ? f = false : f = true;
                c = true;
                (f) ? printf("Opened by ") : printf("Closed by ");
                cout << str << endl;
            }
        }
        if(!c)printf("Unknown ");
        cout << str << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
const int OPEN = 1, CLOSE = 0;
 
typedef pair<string, int> pp;
 
int main()
{
    int n, m;
    string s;
    map<string, int> l;
    cin >> n;
    REP(n){ cin >> s ; l.insert(pp(s, 1));}
    cin >> m;
    int f = CLOSE;
    REP(m)
    {
        cin >> s;
        if(l.find(s) == l.end())
            cout << "Unknown " << s << endl;
        else
        {
            if(f == CLOSE){ cout <<"Opened by " << s << endl;  f = OPEN;}
            else { cout << "Closed by " << s << endl; f = CLOSE;}
        }
    }
 
    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  map<string, bool> t;
  rep(i, n) {
    string s;
    cin >> s;
    t[s] = true;
  }
  int m;
  cin >> m;
  bool d = false;
  rep(i, m) {
    string s;
    cin >> s;
    if (t.count(s)) {
      d ^= 1;
      cout << (d ? "Opened" : "Closed") << " by " << s << endl;
    } else {
      cout << "Unknown " << s << endl;
    }
  }
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include <algorithm>

using namespace std;

int main()
{
	int N,M,flag=0,CP=0;
	char U[100][1000],T[1000];
	
	cin >> N;
	for(int i=0;i<N;i++)cin>>U[i];
	
	cin >> M;
	for(int i=0;i<M;i++)
	{
		cin>>T;
		
		for(int j=0;j<N;j++)
		{
			int count=0;
			
			for(int k=0;k<strlen(T);k++)if(U[j][k]==T[k])count++;

			
			if(count==strlen(T))
			{
				flag=1;
				CP++;
				break;
			}
			else flag=0;
		}
		
		if(flag==1)
		{
			if(CP%2==1)cout << "Opened by " << T <<endl;
			else cout << "Closed by " << T <<endl;
		}
		else cout << "Unknown " << T <<endl;
	}
	
	return 0;
}

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

int main() {
	int N, M;
	string S;
	bool open = false;
	cin >> N;
	map<string, bool> mp;
	for (int i = 0; i < N; i++) {
		cin >> S;
		mp[S] = true;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> S;
		if (!mp[S]) {
			cout << "Unknown " << S << endl;
		}
		else {
			if (open) cout << "Closed by " << S << endl;
			else cout << "Opened by " << S << endl;
			open = !open;
		}
	}
}

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

int n, m;
set<string> st;
int t;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		st.insert(s);
	}
	cin >> m;
	for(int j=0; j<m; ++j){
		string s;
		cin >> s;
		auto ite = st.find(s);
		if(ite == st.end()) cout << "Unknown " << s << "\n";
		else{
			if(t == 0) cout << "Opened by " << s << "\n";
			else cout << "Closed by " << s << "\n";
			t = 1 - t;
		}
	}
}

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

using namespace std;

int main() {
  int n;
  set<string> set1;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    set1.insert(s);
  }
  
  bool isOpen = 0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(set1.count(s)) {
      cout << (isOpen ? "Closed" : "Opened") << " by " << s << endl;
      isOpen = !isOpen;
    }
    else {
      cout << "Unknown " << s << endl;
    }
  }
  
  return 0;
}