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<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int main(){
	int n, m;
	set<string> u;
	string s;
	bool o = 0;
	
	cin >> n;
	while(n--){
		cin >> s;
		u.insert(s);
	}
	cin >> m;
	while(m--){
		cin >> s;
		if(!u.count(s)) cout << "Unknown " << s << endl;
		else{
			o ^= 1;
			cout << (o ? "Opened" : "Closed") << " by " << s << endl;
		}
	}
	return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, M;
    bool open = false;

    cin >> N;
    set<string> u;
    REP( i, N ){
        string s; cin >> s;
        u.insert( s );
    }

    cin >> M;
    REP( i, M ){
        string t; cin >> t;
        if( u.find( t ) != u.end() ){
            open ^= 1;
            cout << ( open ? "Opened by " : "Closed by " ) << t << endl;
        }else{
            cout << "Unknown " << t << endl;
        }
    }
}

C++: #include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N, M;
    cin >> N;
    set<string> s;
    REP(i, N){
        string str;
        cin >> str;
        s.insert(str);
    }
    bool opend = false;
    cin >> M;
    REP(i, M){
        string str;
        cin >> str;
        if(s.count(str)>0){
            cout << (opend?"Closed by ":"Opened by ") << str << endl;
            opend=!opend;
        }else{
            cout << "Unknown " << str << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <set>
#include <string>
using namespace std;

int main(){
    int n, m;
    string username;
    set<string> user;
    int door=1;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> username;
        user.insert(username);
    }
    cin >> m;
    for(int i=0;i<m;++i){
        cin >> username;
        if(user.find(username)==user.end()) cout << "Unknown ";
        else{
            if(door) cout << "Opened by ";
            else cout << "Closed by ";
            door = 1 - door;
        }
        cout << username << endl;
    }
}

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

int main()
{
 map<string,int> d;
 int n,m;
 cin>>n;
 for(int i=0;i<n;i++)
   {
     string s;
     cin>>s;
     d[s]=1;
   }
 cin>>m;
 bool door =false;
 for(int i=0;i<m;i++)
   {
     string s;
     cin>>s;
     if(d.count(s))
       {
	 if(door)
	     cout<<"Closed by ";
	 else
	     cout<<"Opened by ";
	 door=!door;
       }
     else
       cout<<"Unknown ";
     cout<<s<<endl;
   }
}

C++: #include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int N, M;
string U[256];

int main() {
  char s[11];
  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%s", s);
    U[i] = s;
  }
  scanf("%d", &M);
  bool opened = false;
  for (int i=0;i<M;i++) {
    scanf("%s", s);
    const string* p = find(U, U+N, (string)s);
    if (!p->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}

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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;

int main() {
  int n, m;
  bool key = 1;
  cin >> n;
  string A[n];
  rep(i, n) cin >> A[i];
  cin >> m;
  rep(i, m) {
    string S;
    cin >> S;
    rep(i, n) if (A[i] == S) {
      cout << (key ? "Opened" : "Closed") << " by " << S << endl;
      if (key)
        key = 0;
      else
        key = 1;
      goto end;
    }
    cout << "Unknown " << S << endl;
  end:;
  }
  return 0;
}