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 <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 close = 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 ( close ) {
				printf( "Opened by " );
			}
			else {
				printf( "Closed by " );
			}
			close = !close;
		}
		else {
			printf( "Unknown " );
		}
		cout << a << "\n";
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    cin >> n;
    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    int m;
    cin >> m;
    bool locked = true;
    rep(i, m) {
        string s;
        cin >> s;
        if (st.count(s)) {
            cout << (locked ? "Opened by " : "Closed by ") << s << endl;
            locked ^= 1;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<cstdio>
using namespace std;

int main(){
	int n, m;
	bool door = false;
	string id[256];
	string id2;

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> id[i];
	}

	cin >> m;

	for (int i = 0; i < m; i++){
		cin >> id2;
		for (int j = 0; j < n; j++){
			if (id2 == id[j]){
				door = !door;
				if (door){
					cout << "Opened by " << id2 << endl;
				}
				else cout << "Closed by " << id2 << endl;
				break;
			}
			else {
				if (j == n - 1)
					cout << "Unknown " << id2 << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(void){

  int n;
  string u;
  cin >> n;
  set<string>U;
  for(int i=0;i<n;i++){
    cin >> u;
    U.insert(u);
  }

  int m;
  string t;
  cin >> m;
  bool fg = false;
  while(m--){
    cin >> t;
    if(!fg && U.find(t) != U.end())cout << "Opened by " << t << endl, fg^=true;
    else if(fg && U.find(t) != U.end())cout << "Closed by " << t << endl, fg^=true;    
    else cout << "Unknown " << t << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        map<string,int> MA;
        
        for(int i=0;i<N;i++){
            string S;cin>>S;
            MA[S]++;
        }
        
        int M;cin>>M;
        int cnt=1;
        
        for(int i=0;i<M;i++){
            string S;cin>>S;
            if(MA[S]==0){
                cout<<"Unknown "<<S<<endl;
            }else if(cnt%2==0){
                cout<<"Closed by "<<S<<endl;
                cnt++;
            }else{
                cout<<"Opened by "<<S<<endl;
                cnt++;
            }
        }
        
        break;
    }
}

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

using namespace std;
int main() {
	vector<string>VS{ "Opened by ","Closed by ","Unknown " };
	set<string>SS;
	int N;
	cin >> N;
	for( size_t i = 0; i < N; i++ ) {
		string S;
		cin >> S;
		SS.insert( S );
	}
	cin >> N;
	bool x = 0;
	for( size_t i = 0; i < N; i++ ) {
		string S;
		cin >> S;
		if( SS.end() == find( SS.begin(), SS.end(), S ) ) {
			cout << VS[2] << S << endl;
		} else {
			cout << VS[x] << S << endl;
			x = 1 - x;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	int n, m, i, j, count;
	char u[256][11], t[11], c;
	scanf("%d%*c",&n);
	for(i = 0;i < n;i++){
		j = 0;
		while((c = getchar()) != '\n')
			u[i][j++] = c;
		u[i][j] = '\0';
	}

	scanf("%d%*c",&m);
	count = 0;
	for(i = 0;i < m;i++){
		j = 0;
		while((c = getchar()) != '\n')
			t[j++] = c;
		t[j] = '\0';
		for(j = 0;j < n;j++)
			if(!strcmp(t,u[j])) break;
		if(j != n){
			if(count % 2 == 1)
				printf("Closed by ");
			else
				printf("Opened by ");
			count++;
		}
		else
			printf("Unknown ");
		puts(t);
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  string u[257];
  for(int i=0;i<n;i++)cin >> u[i];

  int m;
  cin >> m;
  
  string t;
  int sta = 1;
  for(int i=0;i<m;i++){
    cin >> t;
    
    int flg = 0;
    for(int i=0;i<n;i++){
      if(t == u[i]) {
	flg = 1;
	sta++;
	break;
      }
    }

    if(flg == 1){
      if(sta%2 == 1) cout << "Closed by ";
      else cout << "Opened by ";
      cout << t << endl;
    }
    else cout << "Unknown "<<t<<endl;
    
  }
  return 0;
}