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;
while(1){
    int main(){
        int N;
        cin>> N;
        vector<string>U(N);
        for(auto &a : U){
            cin >>a;
        }
        int M;
        cin >>M;
        int flag=0,auth;
        for(int i=0;i<M;i++){
            string s;
            cin >>s;
            auth=0;
            for(int j=0;j<N;j++){
                if(U[j]==s){
                    if(flag==0){
                        cout<<"Opened by "<<s<<endl;
                        flag=1;
                    }
                    else{
                        cout<<"Closed by "<<s<<endl;
                        flag=0;
                    }
                    auth=1;
                    break;
                }
                if(auth)break;
            }
            if(auth==0)cout<<"Unknown "<<s<<endl;
        }
        return 0;
    }
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        set<string> okid;
        for(int i = 0; i < N; ++i){
            string tmp;
            cin >> tmp;
            okid.insert(tmp);
        }
        int M;
        cin >> M;
        bool close = true;
        for(int i = 0; i < M; ++i){
            string tmp;
            cin >> tmp;
            if(okid.count(tmp)){
                if(close){
                    cout << "Opened by " << tmp;
                }else{
                    cout << "Closed by " << tmp;
                }
                close = !close;
            }else{
                cout << "Unknown " << tmp;
            }
            cout << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}

C++: #include<iostream>

using namespace std;

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

int main() {
  int n, m;
  cin >> n;
  string a[300], b;
  rep (i, n) cin >> a[i];
  bool open = false;
  cin >> m;
  rep (i, m) {
    cin >> b;
    rep (j, n) if (a[j]  == b) {
      open = !open;
      if (open) cout << "Opened by ";
      else cout << "Closed by ";
      goto ok;
    }
    cout << "Unknown ";
  ok:;
    cout << b << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n, m;
  set<string> admin;
  cin >> n;
  for( int i = 0; i < n; i++ ) {
    string tmp;
    cin >> tmp;
    admin.insert( tmp );
  }
  cin >> m;
  bool door = false; // closed
  for( int i = 0; i < m; i++ ) {
    string tmp;
    cin >> tmp;
    if( admin.find( tmp ) == admin.end() ) {
      cout << "Unknown ";
    }else if( !door ){
      cout << "Opened by ";
      door = !door;
    }else{
      cout << "Closed by ";
      door = !door;
    }
    cout << tmp << endl;
  }

  return EXIT_SUCCESS;
}

C++: #include<iostream>
#include<set>
#include<map>
using namespace std;
int main(){
	int n,m,flag=0;
	string str;
	set<string>	st;
	map<string,int>	mp;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> str;
		mp[str]++;
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> str;
		if(mp[str]!=0){
			if(flag){
				cout << "Closed by " << str << endl;
				flag=0;
			}
			else{
				cout << "Opened by " << str << endl;
				flag=1;
			}
		}
		else	cout << "Unknown " << str << endl;
	}
}

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

int main(){
  int n,m;
  cin >> n;
  map<string,int> flg;
  for(int i=0;i<n;i++){
    string str;
    cin >> str;
    flg[str] = 1;
  }
  cin >> m;
  int now = 1;
  for(int i=0;i<m;i++){
    string str;
    cin >> str;
    if(flg[str] == 1){
      if(now) cout << "Opened by " << str << endl;
      else cout << "Closed by " << str << endl;
    }
    else {
      cout << "Unknown " << str << endl;
    }
  }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string>ch(n);
  for(int i=0;i<n;i++)
    cin>>ch[i];
  bool flag=false;
  int m;cin>>m;
  for(int i=0;i<m;i++){
    string str;cin>>str;
    int j;
    for(j=0;j<n;j++){
      if(ch[j]==str){
	if(flag){
	  cout<<"Closed by"<<" "<<str<<endl;
	  flag=false;
	  break;
	}else{
	  cout<<"Opened by"<<" "<<str<<endl;
	  flag=true;
	  break;
	}
      }
    }
    if(j==m)
      cout<<"Unknown"<<" "<<str<<endl;
  }
  return 0;
}