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 <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, m;
  string tmp;
  vector<string> user;
  bool open = false;
  cin >> n;
  while (n--) {
    cin >> tmp;
    user.push_back(tmp);
  }
  cin >> m;
  while (m--) {
    cin >> tmp;
    if (find(user.begin(), user.end(), tmp) == user.end()) {
      cout << "Unknown " << tmp << el;
    }
    else {
      if (open) {
        open = false;
        cout << "Closeed by " << tmp << el;
      } else {
        open = true;
        cout << "Opened by " << tmp << el;
      }
    }
  }
}

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

using namespace std;

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

C++: #include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int solve(int n, int a, int b, int c, int x) {
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    int ret = -1;
    for (int i = 0, j = 0; i < n && j < 10001; j++) {
        if (x == y[i]) i++;
        x = (a*x+b)%c;
        if (i == n) ret = j; 
    }
    return ret;
}

int main(){
    int N; cin >> N;
    set<string> U;
    for (int i = 0; i < N; i++) {
        string u; cin >> u;
        U.insert(u);
    }
    int M; cin >> M;
    vector<string> T(M);
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }
    bool closed = true;
    for (int i = 0; i < M; i++) {
        if (U.count(T[i])) {
            if (closed) {
                closed = false;
                cout << "Opened by " << T[i] << endl;
            } else {
                closed = true;
                cout << "Closed by " << T[i] << endl;
            }
        } else {
            cout << "Unknown " << T[i] << endl; 
        }
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int n;
	cin >> n;

	set<string> ids;
	REP( i, 0, n )
	{
		string tmp;
		cin >> tmp;
		ids.insert( tmp );
	}

	int m;
	cin >> m;
	bool opend = false;
	REP( i, 0, m )
	{
		string user;
		cin >> user;

		if ( EXIST( ids, user ) )
		{
			cout << ( opend ? "Closed" : "Opend" ) << " by ";
			opend = !opend;
		}
		else
		{
			cout << "Unknown ";
		}
		cout << user << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> U(N);
  for (int i = 0; i < N; i++){
    cin >> U[i];
  }
  bool lock = true;
  int M;
  cin >> M;
  for (int i = 0; i < M; i++){
    string T;
    cin >> T;
    bool ok = false;
    for (int j = 0; j < N; j++){
      if (T == U[j]){
        ok = true;
      }
    }
    if (ok){
      if (lock){
        cout << "Opened by " << T << endl;
        lock = false;
      } else {
        cout << "Closed by " << T << endl;
        lock = true;
      }
    } else {
      cout << "Unknown " << T << endl;
    }
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int now=0; // 0-close 1-open
  string user[257];
  string visit[257];
  cin>>n;
  for(int i=0;i<n;i++)cin>>user[i];
  cin>>m;
  for(int i=0;i<m;i++)cin>>visit[i];
 
  for(int i=0;i<m;i++){
    int flag=0;
    for(int j=0;j<n;j++){
      if(user[j]==visit[i]){
	if(now==0){
	  cout<<"Opened by "<<visit[i]<<endl;
	  now=1;
	}else{
	  cout<<"Closed by "<<visit[i]<<endl;
	  now=0;
	}
	flag=1;
      }
    }
    if(!flag){
      cout<<"Unknown "<<visit[i]<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

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

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/


int main()
{
	int N, M;
	string U, T;
	vector<string> ids;
	bool key = false;
	
	cin >> N;
	REP(N)
	{
		cin >> U;
		ids.push_back(U);
	}
	cin >> M;
	REP(M)
	{
		cin >> T;
		if (find(ids.begin(), ids.end(), T) != ids.end())
		{
			//見つかった場合
			if (key)
			{
				cout << "Closed by " << T << endl;
				key = !key;
			} else {
				cout << "Opened by " << T << endl;
				key = !key;
			}
		} else {
			cout << "Unknown " << T << endl;
		}
	}
	
	return 0;
}