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++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2440

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int output(int isLock, string id, vector<string> id_list)
{
	bool flag=false;

	rep(i,id_list.size()){
		if(id_list[i] == id){flag=true;}
	}

	if(flag){
		if(isLock < 0){
			cout << "Opened by " << id << endl;
			return isLock*-1;
		}else{
			cout << "Closed by " << id << endl;
			return isLock*-1;
		}
	}else{
		cout << "Unknown " << id << endl;
		return isLock;
	}

}

int main() {
	
	int N,M;
	int isLock=-1;
	vector<string> id_list;

	cin >> N;
	string id;
	rep(i,N){
		cin >> id;
		id_list.push_back(id);
	}

	cin >> M;
	rep(i,M){
		cin >> id;
		isLock = output(isLock, id, id_list);
	}
	return 0;
}

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

int main()
{
    int N, M;
    bool lock = true;
    map<string, int> list;
    cin>>N;
    while(N-- > 0) {
        string U;
        cin>>U;
        list.insert(make_pair(U, 1));
    }
    cin>>M;
    while(M-- > 0) {
        string T;
        cin>>T;
        if(list.count(T)) {
            if(lock) cout<<"Opened by "<<T<<endl;
            else cout<<"Closed by "<<T<<endl;
            lock = !lock;
        } else {
            cout<<"Unknown "<<T<<endl;
        }
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
	int n; cin >> n;
    set<string> st;
    rep(i,n){
        string s; cin >> s;
        st.insert(s);
    }

    int m; cin >> m;

    bool jud = true;
    rep(i,m){
        string t; cin >> t;
        if(st.count(t)){
            if(jud){
                cout << "Opened by " << t << endl;
                jud = false;
            }
            else{
                cout << "Closed by " << t << endl;
                jud = true;
            }
        }

        else{
            cout << "Unknown " << t << endl;
        }
    }
}

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

void doAction(int n, string id[], string str){
	static int status = 0,i;
	for(i=0;i<n;i++){
		if(!id[i].compare(str)){
			status = !status;
			if(status) cout<<"Opened by " << str << endl;
			else cout << "Closed by " << str << endl;
			break;
		}
	}
	if(i==n) cout<< "Unknown " << str <<endl;
}

int main(){
	int n,m;
	string id[256],str;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> id[i];
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> str;
		doAction(n,id,str);
	}
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int n, m;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> n;
	map<string, bool> ids;
	rep (i, n) {
		string u;
		cin >> u;
		ids[u] = true;
	}
	cin >> m;
	VS ans;
	VS ts;
	bool flag = false;
	rep (i, m) {
		string s;
		string t;
		cin >> t;
		if (!ids.count(t)) {
			s = "Unknown " + t;
		} else if (flag) {
			s = "Closed by " + t;
			flag = false;
		} else {
			s = "Opened by " + t;
			flag = true;
		}
		ans.pb(s);
	}
	for (string a : ans) {
		cout << a << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int main(){
    unordered_set<string>a;
    int b;
    cin>>b;
    for(int c=0;c<b;c++){
	string d;
	cin>>d;
	a.insert(d);
	}
    bool e=false;
    int f;
    cin>>f;
    for(int g=0;g<f;g++){
	string h;
	cin>>h;
	if(a.find(h)!=a.end()){
	    if(e){e=false;cout<<"Closed by "<<h<<endl;}
	    else {e=true;cout<<"Opened by "<<h<<endl;}
	    }
	   else cout<<"Unknown "<<h<<endl;
	}
    }

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

int main() {
  int n, m;

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

  cin >> m;
  int cnt = 0;
  for(int i = 0; i < m; i++) {
    string t;
    cin >> t;
    bool b = true;
    for(int j = 0; j < n; j++) {
      if(u[j] == t) {
	if(cnt % 2 == 0) {
	  cout << "Opened by " << t << endl;
	  cnt++;
	  b = false;
	} else {
	  cout << "Closed by " << t << endl;
	  cnt++;
	  b = false;
	}
	if(!b) break;
      }
    }
    if(b) cout << "Unknown " << t << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int main(int argc, char *argv[])
{
  map<string,int> key;
  int n;
  cin >> n;
  string in;
  int op=0;
  rep(i,n){
    cin >> in;
    key[in]=0;
  }

  cin >> n;
  rep(i,n){
    cin >> in;
    if(key.count(in)){
      cout << (!op?"Opened":"Closed") << " by " << in << endl;
      op^=1;
    }else cout << "Unknown " << in << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <ios>
#include <set>
using namespace std;
int main(void) {
    ios::sync_with_stdio(false);

    set<string> registered;
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        string ID;
        cin >> ID;
        registered.insert(ID);
    }
    cin >> n;
    bool isLocked = true;
    for(int i = 0; i < n; ++i) {
        string ID;
        cin >> ID;
        if(registered.find(ID) != registered.end()) {
            if(isLocked) {
                cout << "Opened by " << ID << endl;
                isLocked = false;
            } else {
                cout << "Closed by " << ID << endl;
                isLocked = true;
            }
        } else {
            cout << "Unknown " << ID << endl;
        }
    }
    return 0;
}