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>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, m;
  cin >> n;
  set<string> se;
  rep(i, n) { string u; cin >> u; se.insert(u); }
  cin >> m;
  bool opened = false;
  rep(i, m) {
    string s; cin >> s;
    if (se.count(s) > 0) {
      opened = !opened;
      if (opened) {
        cout << "Opened by " << s << '\n';
      } else {
        cout << "Closed by " << s << '\n';
      }
    } else {
      cout << "Unknown " << s << '\n';
    }
  }
}

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" : "Opened" ) << " by ";
			opend = !opend;
		}
		else
		{
			cout << "Unknown ";
		}
		cout << user << endl;
	}

	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;
 
int main(){
    int n, m;
    bool open = false;
    map<string, int> door;
    cin >> n;
    while(n--){
        string input;
        cin >> input;
        door[input] = 1;
    }
    cin >> m;
    while(m--){
        string input;
        cin >> input;
        if(door.find(input) == door.end()){
            cout << "Unknown " << input << endl;
        }else{
            if(door[input] == 1 && open == false){
                cout << "Opened by " << input << endl;
                open = true;
            }else if(door[input] == 1 && open == true){
                cout << "Closed by " << input << endl;
                open = false;
            }
        }
 
    }
}

C++: #include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;


int main(){
  int n,m;
  cin>>n;
  vector<string> user(n);
  rep(i,n)cin>>user[i];
  cin>>m;
  vector<string> t(m);
  rep(i,m)cin>>t[i];
  int key=1;
  if(n<=m)
  rep(i,m){
    rep(j,n){
      if(t[i]==user[j]){
	cout<<(key>0?"Opened by":"Closed by")<<" "<<t[i]<<endl;
	key*=-1;
	break;
      }else if(j==n-1){
	cout<<"Unknown"<<" "<<t[i]<<endl;
      }
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

string user[256];
int n,m;

int check(string in){
	for(int i=0;i<n;i++) if(user[i] == in) return 1;
	return 0;
}
main(){
	string in;
	int i,j;
	int state = 0;
	cin >> n;
	for(i=0;i<n;i++) cin >> user[i];
	cin >> m;
	for(i=0;i<m;i++){
		cin >> in;
		if(check(in)) printf("%s by %s\n", state++%2 ? "Closed":"Opened", in.c_str());
		else printf("Unknown %s\n", in.c_str());
	}
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
	int n, m, count = 0,countt=0;
	vector<string> s;
	vector<string> ss;

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

	cin >> m;
	ss.resize(m);
	for (int i = 0; i < m; i++) {
		cin >> ss[i];
		for (int j = 0; j < n; j++) {
			if (ss[i] == s[j]) {
				countt++;
				count++;
				if (count % 2 == 1) {
					cout << "Opened by " + ss[i] << endl;
				}
				else {
					cout << "Closed by " + ss[i] << endl;
				}
			}
		}
		if (countt == 0) {
			cout << "Unknown " + ss[i] << endl;
		}
		countt = 0;
	}
}