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;

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;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, m;

  cin >> n;
  vector<string> u(n);
  REP(i, n) cin >> u[i];

  cin >> m;
  bool state = true;
  REP(i, m) {
    bool b = true;
    string t;
    cin >> t;
    REP(j, n) {
      if(u[j] == t) {
	if(state) cout << "Opened by " << t << endl;
	else cout<< "Closed by " << t << endl;
	b = false;
	state ^= 1;	
	break;
      }
    }
    if(b) cout << "Unknown " << t << endl;
  }
}

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

using namespace std;

int N, M;
string U[257];

int main() {
  char s[14];
  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%s", s);
    U[i] = s;
  }
  scanf("%d", &M);
  bool opened = false;
  for (int i=0;i<M;i++) {
    scanf("%s", s);
    const string* p = find(U, U+N, (string)s);
    if (p && !p->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
    bool isLocked = true;
    vector<int> map;
    int N, M;
    cin >> N;
    
    map.clear();
    map.resize(N);
    for (int i = 0; i < N; ++i) {
        int id;
        cin >> id;
        map[i] = id;
    }
    
    cin >> M;
    for (int i = 0; i < M; ++i) {
        int id;
        cin >> id;
        auto itr = find(map.begin(), map.end(), id);
        if (itr != map.end()) {
            if (isLocked) {
                cout << "Opened by " << id << "\n";
            } else {
                cout << "Closed by " << id << "\n";
            }
            isLocked = ~isLocked;
        } else {
            cout << "Unknown " << id << "\n";
        }
    }
    
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	string str;
	vector<string> IDlist;
	for (int i = 0; i < n; ++i) {
		cin >> str;
		IDlist.emplace_back(str);
	}
	cin >> n;
	bool key = false;
	for (int i = 0; i < n; ++i) {
		cin >> str;
		for (int j = 0; j < IDlist.size(); ++j) {
			if (IDlist[j] == str) {
				if (key == false) {
					cout << "Opened by " << str;
					key = true;
				}
				else {
					cout << "Closed by " << str;
					key = false;
				}
				break;
			}
			if (j == IDlist.size() - 1) {
				cout << "Unknown " << str;
			}
		}
	}
	return 0;
}

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

set<string> reg;

int main(){
  int n;

  while(cin >> n){
    reg.clear();

    for(int i = 0; i < n; i++){
      string s;
      cin >> s;
      reg.insert(s);
    }

    bool open = false;
    int m;
    cin >> m;

    while(m--){
      string s;
      cin >> s;

      if(reg.find(s) == reg.end()){
        cout << "Unknown " << s << endl;
      }
      else if(open){
        open = !open;
        cout << "Closed by " << s << endl;
      }
      else{
        open = !open;
        cout << "Opened by " << s << endl;
      }
    }
  }
}

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

int main(){
	int n, m;
	string u[100010];
	string input;

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

		bool isExist = false;
		bool isOpen = false;
		for(int j=0; j < n; j++){
			if(u[j] == input){
				isExist = true;
				if(isOpen) isOpen = false;
				else isOpen = true;
			}
		}
		if(isExist){
			if(isOpen){
				cout << "Closed by " << input << endl;
				isOpen = false;
			}
			else {
				cout << "Opened by " << input << endl;
				isOpen = true;
			}
		}
		else {
			cout << "Unknown " << input << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;


int main(){
  int n;
  cin>>n;
  string u;
  map<string,int> a;
  for(int i=0;i<n;i++){
    cin>>u;
    a[u]=1;
  }
  int m,count=0;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>u;
    if(a[u]==1){
      count++;
      if(count%2==1){
	cout<<"Opened by ";
      }else{
	cout<<"Closed by ";
      }
      cout<<u<<endl;
    }else{
      cout<<"Unknown "<<u<<endl;
    }
  }
  return 0;
}

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

int main(int argc, char *argv[])
{
    int n, m;
    bool open = false;
    cin >> n;
    string line;
    vector<string> ids;
    for (int i = 0; i < n; ++i) {
        cin >> line;
        ids.push_back(line);
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> line;
        vector<string>::iterator itr = find(ids.begin(), ids.end(), line);
        if (itr == ids.end()) {
            cout << "Unknown " << line << endl;
        } else if (open) {
            cout << "Closed by " << line << endl;
            open = false;
        } else {
            cout << "Opened by " << line << endl;
            open = true;
        }
    }
    return 0;
}

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

int main(){
  int n;
  string s[300];
  while(cin>>n&&n){
    for(int i=0;i<n;i++) cin>>s[i];
    int m;
    cin>>m;
    bool p=0,np=0;
    while(m--){
      string str;
      cin>>str;
      for(int i=0;i<n;i++)
	if(str==s[i]){
	  np=!np;
	  break;
	}
      if(p==np) cout<<"Unknown "<<str<<endl;
      else if(np) {cout<<"Opened by "<<str<<endl;p=np;}
      else {cout<<"Closed by"<<str<<endl;p=np;}
    }
  }
  return 0;
}

C++: #include <iostream>
#include <map>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N, M;
string S;
map<string, bool> p;
bool s;

int main(void) {
  cin >> N;
  REP(i, 0, N) {
    cin >> S;
    p[S] = false;
  }
  cin >> M;
  s = false;
  REP(i, 0, M) {
    cin >> S;
    if(p.count(S)) {
      if(s == false) {
        cout << "Opened by " << S << endl;
        s = true;
      } else {
        cout << "Closed by " << S << endl;
        s = false;
      }
    } else {
      cout << "Unknown " << S << endl;
    }
  }
}