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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001


int main(){
  int n,m;
  string u,t;
  set<string> dic;

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    cin >> u;
    dic.insert(u);
  }

  scanf("%d",&m);


  bool f = false;
  for(int i=0;i<m;i++){
    cin >> t;

    if(dic.find(t)==dic.end()){
      cout << "Unknown " << t << endl;
    }else{
      if(f==false){
	cout << "Opened by " << t << endl;
      }else{
	cout << "Closed by " << t << endl;
      }

      f = !f;
    }
  }    

  return 0;
}

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

int main()
{
	bool IsOpen = false;
	int n, m;
	map<string, int> u;

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

	cin >> m;
	for (int i = 0; i < m; i++)
	{
		string s;
		cin >> s;
		if (u.count(s))
		{
			if (!IsOpen)
			{
				cout << "Opened by " + s << endl;
				IsOpen = true;
			}
			else
			{
				cout << "Closed by " + s << endl;
				IsOpen = false;
			}
		}
		else
		{
			cout << "Unknown " + s << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m;
    cin >> n;
    map<string, int> mp;
    while (n--){
        string u;
        cin >> u;
        mp[u] = 1;
    }
    cin >> m;
    int f = 1;
    while (m--){
        string t;
        cin >> t;
        if (mp[t]){
            if (f) cout << "Opened by " << t << endl;
            else cout << "Closed by " << t << endl;
            f ^= 1;
        }else{
            cout << "Unknown " << t << endl;
        }
    }
    return 0;
}

C++: #include <stdio.h>

#define MYSCAN scanf

char u[300][20];
int n;

int match(char t[20]);

int main(void){
	int i;
	int m;
	int mat;
	char t[20];
	int door = -1;

	MYSCAN("%d", &n);
	MYSCAN("\n");
	// テァツ卍サテゥツ個イIDテ」ツ?ョテ・ツ?・テ・ツ環?
	for (i = 0; i < n; i++){
		gets_s(u[i]);
	}

	MYSCAN("%d", &m);
	MYSCAN("\n");
	for (i = 0; i < m; i++){
		// テ」ツつォテ」ツδシテ」ツδ嘉」ツつ津」ツ?凝」ツ?姪」ツ??
		gets_s(t);
		mat = match(t);
		// テァツ卍サテゥツ個イテ」ツ?陛」ツつ古」ツ?ヲテ」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌」ツつ?
		if (mat == -1){
			printf("Unknown %s\n", t);
		}
		else{
			// テ」ツδ嘉」ツつ「テ」ツ?古ゥツ鳴嘉」ツ?セテ」ツ?」テ」ツ?ヲテ」ツ?淌」ツつ嘉」ツ?づ」ツ?妥」ツつ?
			if (door == -1){
				printf("Opened by %s\n", t);
			}
			// テゥツ鳴凝」ツ??」ツ?ヲテ」ツ?淌」ツつ嘉ゥツ鳴嘉」ツつ?」ツつ?
			else{
				printf("Closed by %s\n", t);
			}
			door *= -1;
		}
	}


	return 0;
}


// テヲツ鳴?・ツュツ療・ツ按療」ツ?古」ツ?づ」ツ?」テ」ツ?ヲテ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツつ津・ツ按、テ・ツョツ堙」ツ?凖」ツつ凝ゥツ鳴「テヲツ閉ー
// テ・ツ青暗ィツ?エテ」ツ?凖」ツつ凝ヲツ鳴?・ツュツ療・ツ按療」ツ?古」ツ?ェテ」ツ?妥」ツつ古」ツ?ー-1テ」ツつ津ィツソツ氾」ツ??
int match(char t[20]){
	int i, j;

	for (i = 0; i < n; i++){
		for (j = 0; t[j] != '\0' && u[i][j] != '\0'; j++){
			if (t[j] != u[i][j]){ break; }
		}
		if (t[j] == '\0' && u[i][j] == '\0'){
			return i;
		}
	}
	return -1;
}

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

bool search(string* array, int length,  string target)
{
  string array_last = array[length - 1];
  array[length - 1] = target;
  
  int i;
  for (i = 0; array[i] != target; i++)
  {
  }
  array[length - 1] = array_last;
  if (i < length-1)
  {
    return true;
  }
  else if (array_last == target)
  {
    return true;
  }
  else
  {
    return false;
  }
}

int main(void)
{
  bool open = false;
  int n;
  cin >> n;
  string* u = new string[n];
  for (int i = 0; i < n; i++)
  {
    //getline(cin, u[i]);
    cin >> u[i];
  cerr << i << endl;
  }
  cerr << "---" << endl;

  int m;
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    string t;
    //getline(cin, t);
    cin >> t;
    if (search(u, n, t) )
    {
      if (open)
      {
        cout << "Closed by ";
      }
      else
      {
        cout << "Opened by ";
      }
      open = !open;
    }
    else
    {
      cout << "Unknown ";
    }
    cout << t << endl;
  }

  delete[] u;
  return 0;
}

C++: #include <stdio.h>
#include <math.h>

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2204 : Kagisys **/
int main()
{
	set<string> s;
	int N, M; bool open=false;
	cin>>N;
	rep(i, N) {
		string st;
		cin>>st;
		s.insert(st);
	}
	cin>>M;
	rep(i, M) {
		string st;
		cin>>st;
		if (s.count(st)) {
			if (!open)
				cout << "Opened by " << st << endl;
			else
				cout << "Closed by " << st << endl;
			open = !open;
		} else {
			cout << "Unknown " << st << endl;
		}
	}
}

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

map<string,int> sys;

int N, M;
string s;
bool locked = true;

int main() {
    cin >> N;
    for (int i=0; i<N; ++i) {
        cin >> s;
        sys[s] = 1;
    }
    cin >> M;
    for (int i=0; i<M; ++i) {
        cin >> s;
        if (sys[s]) {
            if (locked) {
                locked = false;
                cout << "Opened by " << s << endl;
            } else {
                locked = true;
                cout << "Closed by " << s << endl;
            }
        } else {
            cout << "Unknown " << s << endl;
        }
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<cstdio>
using namespace std;

int main(){
	int n, m;
	bool door = false;
	string id[256];
	string id2;

	cin >> n;

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

	cin >> m;

	for (int i = 0; i < m; i++){
		cin >> id2;
		for (int j = 0; j < n; j++){
			if (id2 == id[j]){
				door = !door;
				if (door){
					cout << "Opend by " << id2 << endl;
				}
				else cout << "Closed by " << id2 << endl;
				break;
			}
			else {
				if (j == n - 1)
					cout << "Unknown " << id2 << endl;
			}
		}
	}
	return 0;
}