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 _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    map<string, bool> key;
    int n;
    cin >> n;
    rep(i, n)
    {
        string s;
        cin >> s;
        key[s] = true;
    }
    int m;
    cin >> m;
    bool isopen = false;
    rep(i, m)
    {
        string s;
        cin >> s;
        if (key[s])
        {
            if (isopen)
            {
                cout << "Closed by " << s << endl;
            }
            else
            {
                cout << "Opened by " << s << endl;
            }
            isopen ^= true;
        }
        else
        {
            cout << "Unknown " << s << endl;
        }
    }
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    unordered_map<string,bool> user;
    string str;
    REP(i,n){
        cin >> str;
        user[str]=false;
    }
    int m;
    bool flg=false;
    cin >> m;
    REP(i,m){
        cin >> str;
        if(user.find(str)!=user.end()){
            flg=!flg;
            if(flg)cout << "Opened by "<<str << endl;
            else cout << "Closed by "<<str << endl;
        }else{
            cout << "Unknown "<<str<<endl;
        }
    }
}

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

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

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<string> ids(n);
  REP(i,n)cin>>ids[i];
  bool opened = false;
  int m;
  cin>>m;
  REP(i,m){
    string s;
    cin>>s;
    auto itr = find(begin(ids),end(ids),s);
    if (itr == end(ids)) {
      cout << "Unknown " << s << endl;
    } else {
      if (opened) {
        cout << "Closed by " << s << endl;
      } else {
        cout << "Opened by " << s << endl;
      }
      opened = !opened;
    }
  }
  return 0;
}

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

int main(){

	int N;
	int state = 1; //??????
	cin >> N;
	char ID[N][10];
	for (int i = 0; i <= N-1; i++){
		cin >> ID[i];
	}

	int M;
	cin >> M;
	char IC[M][10];

	for (int i = 0; i <= M-1; i++){
		cin >> IC[i];
		int check = 0;
		for (int j = 0; j<= N-1; j++){
			if(strcmp(IC[i],ID[j]) == 0){
				if (state == 1){
					state = 0;
					check = 1;
					cout << "Opened by" << " " << ID[j] << endl;
				}
				else if (state == 0){
					state = 1;
					cout << "Closed by" << " " << ID[j] << endl;
					check = 1;
				}
			}
		}
		if (check == 0){
				cout << "Unknown" << " " << IC[i] << endl;
			}
	}
}

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

int main(){
  int i,j,n,m;
  string id[300],id_2;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> id[i];
  }

  cin >> m;

  while(m>0){
    int count=0;
    m--;
    cin >> id_2;
    for(i = 0; i < n; i++){
      if(id_2==id[i])count++;
    }
    if(count==1){
      cout << "Opened by" << " " << id_2 << endl;
    }else if(count==0){
      cout << "Unknown" << " " << id_2 << endl;
    }
  }
  
  return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

set<string> s;

int main(void){
	int n,m;
	cin >> n;
	rep(i,n){
		string in;
		cin >> in;
		s.insert(in);
	}
	bool locked=true;
	cin >> m;
	rep(i,m){
		string in;
		cin >> in;
		if(exist(s,in)){
			if(locked)
				cout << "Opened by " << in << endl;
			else
				cout << "Closed by " << in << endl;
			locked^=true;
		}else{
			cout << "Unknown " << in << endl;
		}
	}
	return 0;
}

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

using namespace std;

set<string> data;
int n, m;

main(){
  cin >> n;
  for(int i=0;i<n;i++){
    string in;
    cin >> in;
    data.insert(in);
  }
  cin >> m;
  int open = 0;
  for(int i=0;i<m;i++){
    string in;
    cin >> in;
    if(data.find(in) != data.end()){
      cout << (open ? "Closed by" : "Opened by") << ' ' << in << endl;
      open = 1 - open;
    }else cout << "Unknown" << ' ' << in << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  string s[257], k[257];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k[i];
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>s[i];
  }
  int count=0, c[300]={};
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(s[i] == k[j]){
	count++;
	c[i]++;
	break;
      }
    }
    if(c[i] == 0) cout<<"Unknown"<<" "<<s[i]<<endl;
    else if(c[i] != 0 && count % 2 != 0) cout<<"Opened by"<<" "<<s[i]<<endl;
    else cout<<"Closed by"<<" "<<s[i]<<endl;
  }
  return 0;
}

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

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);

  std::set<std::string> U;
  for (size_t i = 0; i < n; ++i) {
    char buf[16];
    scanf("%s", buf);
    U.insert(buf);
  }

  size_t m;
  scanf("%zu", &m);
  bool opens = false;
  for (size_t i = 0; i < m; ++i) {
    char buf[16];
    scanf("%s", buf);
    if (U.count(buf)) {
      printf("%s by %s\n", (opens? "Closed": "Opened"), buf);
      opens = !opens;
    } else {
      printf("Unknown %s\n", buf);
    }
  }
  return 1;
}

int main() {
  while (!testcase_ends()) {}
}