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<set>

using namespace std;

int main(){

    
        int N;
        cin>> N;
        string U[N];
        for(int i=0; i<N; i++) cin>> U[i];
        int M;
        cin>> M;
        string T[M];
        for(int i=0; i<M; i++) cin>> T[i];

        set<string> user;
        for(int i=0; i<N; i++) user.insert(U[i]);
        int open=0;
        for(int i=0; i<M; i++){
            if(user.count(T[i])){
                if(open){
                    cout<< "Closed by "<< T[i]<< endl;
                    open=0;
                }else{
                    cout<< "Opened by "<< T[i]<< endl;
                    open=1;
                }
            }else{
                cout<< "Unknown "<< T[i]<< endl;
            }
        }

    

    return 0;
}

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

using namespace std;
vector<string> ans;

int main(){
	int n;
	cin >> n;
	string mem[256];
	for(int i = 0;i < n;i++){
		cin >> mem[i];
	}
	int m;
	cin >> m;
	bool door = false;
	for(int i = 0;i < m;i++){
		string id;
		cin >> id;
		bool tid = false;
		string mes;
		for(int j = 0;j < n;j++){
			if(id == mem[j]){
				tid = true;
				if(door){
					mes = "Closed by ";
					mes += id;
					door = false;
				}else{
					mes = "Opened by ";
					mes += id;
					door = true;
				}
				break;
			}
		}
		if(!tid){
			mes = "Unknown ";
			mes += id;
		}
		ans.push_back(mes);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

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

using namespace std;

int main()
{
  int N, M;
  set<string> system;
  bool open = false;
  cin >> N;
  for(int i = 0; i < N; i++){
    string id;
    cin >> id;
    system.insert(id);
  }
  cin >> M;
  for(int i = 0; i < M; i++){
    string id;
    cin >> id;
    if(system.count(id)){
      if(open) cout << "Closed by " << id << endl;
      else cout << "Opened by " << id << endl;
      open = !open;
    } else {
      cout << "Unknown " << id << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;int main(){string u[256],t;int n,m,i,j,f=0,k;cin>>n;for(i=0;i<n;i++)cin>>u[i];cin>>m;for(i=0;i<m;i++){cin>>t;k=f;for(j=0;j<n;j++)if(t==u[j]){if(f==0)f=1,cout<<"Opened by "<<t<<endl;else f=0,cout<<"Closed by "<<t<<endl;}if(k==f)cout<<"Unknown "<<t<<endl;}return 0;}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0 };
static const int dy[] = { 0, 0, 1, -1 };

static int n, m;
VS ar;
string a;
bool closed = true;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}


int main() {
	scanf( "%d", &n );
	ar.resize( n );
	ar.reserve( n );
	for ( int i = 0; i < n; i++ ) {
		cin >> ar[ i ];
	}
	sort( ar.begin(), ar.end() );
	scanf( "%d", &m );
	for ( int i = 0; i < m; i++ ) {
		cin >> a;
		if ( binary_search( ar.begin(), ar.end(), a ) ) {
			if ( closed ) {
				printf( "Opened by " );
			}
			else {
				printf( "Closed by " );
			}
			closed = !closed;
		}
		else {
			printf( "Unknown " );
		}
		cout << a << "\n";
	}
	return 0;
}

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

using namespace std;

int main() {
	map<string, int> reg;
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		string str; cin >> str;
		reg[str] = 0;
	}
	int M; cin >> M;
	for (int i = 0; i < M; ++i) {
		string str; cin >> str;
		if (reg.find(str) != reg.end()) {
			if (reg[str] == 0) {
				printf("Opened by %s\n", str.c_str());
				reg[str] = 1;
			}
			else {
				printf("Closed by %s\n", str.c_str());
				reg[str] = 0;
			}
		}
		else printf("Unknown %s\n", str.c_str());
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m; cin>>n;
  string u[n];
  for(int i=0;i<n;++i) cin>>u[i];
  cin>>m;
  bool o=false;
  for(int i=0;i<m;++i){
    string t; cin>>t;
    bool flag=false;
    for(int j=0;j<n;++j)
      if(t==u[j]){
        flag=true;
        if(o) o=false;
        else o=true;
      }
    if(flag)
      if(o) cout<<"Opened by "<<t<<endl;
      else cout<<"Closed by "<<t<<endl;
    else cout<<"Unknown "<<t<<endl;
  }
  return 0;
}

C++: //O(mn)の全探索解法
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	string *registeredID = new string[n];//登録されているID
	for(int i=0;i<n;i++){
		cin >> registeredID[i];
	}
	int m;
	cin >> m;
	string *cardID = new string[m];//扉にかざすID
	for(int i=0;i<m;i++){
		cin >> cardID[i];
	}
	//入力終わり
	bool isOpen = false;
	for(int i=0;i<m;i++){
		bool contains = false;//登録されているかどうか
		for(int j=0;j<n;j++){
			if(cardID[i] == registeredID[j]){
				contains = true;
				break;
			}
		}
		if(contains==true){
			if(isOpen == true){
				cout << "Closed by " << cardID[i] << endl;
			}else{
				cout << "Opened by " << cardID[i] << endl;
			}
			isOpen = !isOpen;//trueとfalseを入れ替える
		}else{
			cout << "Unknown " << cardID[i] << endl;
		}
	}
	delete []cardID;
	delete []registeredID;
	return 0;
}