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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/challenges/sources/JAG/Summer/2440>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
void solve(){
    int N; cin >> N;
    map<string,int> mp;
    set<string> s;
    for(int i = 0; i < N;i++) { string U; cin >> U; mp[U] = 0; s.insert(U);}
    int M; cin >> M;
    bool state = false;
    for(int i = 0; i < M;i++){
        string T; cin >> T;
        if(s.find(T) == s.end()){
            cout << "Unknown " << T << endl;
        }else{
            if(state == 0){
                state = 1;
                cout << "Opened by " << T << endl;
            }else{
                state = 0;
                cout << "Closed by " << T << endl;
            }
        }
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e18
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> P;
const int mod = 1000000007;


signed main(){

    int n, m;
    cin >> n;
    vector<string> u(n);
    rep(i, n)cin >> u[i];
    bool now = false; // true -> open, false -> close
    cin >> m;
    rep(i, m){
        string s;
        cin >> s;
        bool f = true;
        rep(j, n)if(u[j] == s)f = false;
        if(f){
            cout << "Unknown " << s << endl;
            continue;
        }
        if(now){
            cout << "Closed by " << s << endl;
            now = false;
        }
        else{
            cout << "Opened by " << s << endl;
            now = true;
        }
    }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



map<string,int> ma;
int N, M;

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> N) {
        if (N == 0) break;
        ma.clear();
        for (int i = 0; i < N; ++i) {
            string str;
            cin >> str;
            ma[str]++;
        }
        int mode = 0;
        cin >> M;
        for (int i = 0; i < M; ++i) {
            string str;
            cin >> str;
            if (ma[str] > 0) {
                if (mode == 0) cout << "Opened by " << str << endl;
                else cout << "Closed by " << str << endl;
                mode = 1-mode;
            }
            else cout << "Unknown " << str << endl;
        }
    }       
    
    return 0;
}

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

int main(){

  int n,m;
  cin>>n;
  string u[n];

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

  cin>>m;
  string t[m];
  
  for(int i=0;i<m;i++){
    cin>>t[i];
  }

  int b=0;

  for(int i=0;i<m;i++){
    int a=0;
    for(int j=0;j<n;j++){
      if(t[i]==u[j]){
	a=1;
      }
    }

    if(a==1){
      if(b==0){
	cout<<"Opened by "<<t[i]<<endl;
	b=1;
      }else{
	cout<<"Closed by "<<t[i]<<endl;
	b=0;
      }
    }else{
      cout<<"Unknown "<<t[i]<<endl;
    }

  } 


  return 0;

}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
		int n;
		cin >> n;
		vector<string> u(n);
		for(int i=0;i<n;i++)
			cin >> u[i];
		int m;
		cin >> m;
		bool open=false;
		for(int i=0;i<m;i++)
		{
			string t;
			cin >> t;
			bool flag=false;
			for(int j=0;j<u.size();j++)
			{
				if(t==u[j])
					flag=true;
			}
			if(flag)
			{
				if(open)
					cout << "Closed by " << t << endl;
				else
					cout << "Opened by " << t << endl;
				open=(!open);
			}
			else
			{
				cout << "Unknown " << t << endl;
			}

		}





}

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

int main() {
  vector<string> V;
  bool locked = true;
  int N,M;
  string S;
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    cin >> S;
    V.push_back(S);
  }
  scanf("%d", &M);
  for (int i=0; i<M; i++) {
    cin >> S;
    if (find(V.begin(), V.end(), S) != V.end()) { // 登録されている
      if (locked) {
	cout << "Opened by " << S << endl;
      } else {
	cout << "Closed by " << S << endl;
      }
      locked = !locked;
    } else {
      cout << "Unknown " << S << endl;
    }
  }  
}

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

vector<string> id;
map<bool, string> st;
bool isOpen = false;

void solve(string t) {
  if(find(id.begin(), id.end(), t) != id.end()) {
    isOpen = !isOpen;
    cout << st[isOpen] << t << endl;
  }
  else {
    cout << "Unknown " << t << endl;
  }
}

int main() {
  int n, m;
  string buf;
  st.insert(make_pair(true, "Opened by "));
  st.insert(make_pair(false, "Closed by "));
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> buf;
    id.push_back(buf);
  }
  cin >> m;
  for(int i = 0; i < m; ++i) {
    cin >> buf;
    solve(buf);
  }
  return 0;
}