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++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;

// s.....0=�{�� 1=����
int n, m, s = 0, c = 0;
char u[256][11] = {}, t[256][11] = {};

int check(int a, int b);

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &u[i]);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%s", &t[i]);
	}

	for (int i = 0; i < m; i++) {
		c = 0;

		for (int j = 0; j < n; j++) {
			if (check(j, i)) {
				c = 1;
				if (s == 0) {
					printf("Opened by %s\n", t[i]);
					s = 1;
					break;
				}
				if (s == 1) {
					printf("Closed by %s\n", t[i]);
					s = 0;
					break;
				}
			}
		}

		if (c == 0) {
			printf("Unknown %s\n", t[i]);
		}
	}
	return 0;
}

int check(int a, int b) {
	for (int i = 0; i < 10; i++) {
		if (u[a][i] != t[b][i])
			return 0;
		if (u[a][i] == t[b][i] && u[a][i] == 0)
			return 1;

	}
	printf("fadsfasf");
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main(){
	int N, M;
	vector<string> regi;
	cin >> N;
	for( int i = 0; i < N; i++ ){
		string ID;
		cin >> ID;
		regi.push_back(ID);
	}
	cin >> M;
	int rock = 0;
	for( int i = 0; i < M; i++ ){
		string ID;
		cin >> ID;
		size_t j = 0;
		for( ; j < regi.size(); j++ ){
			if( ID == regi[j] ){
				if( rock == 0 ){
					cout << "Opened by " << regi[j] << endl;
					rock = 1;
				}else{
					cout << "Closed by " << regi[j] << endl;
					rock = 0;
				}
				break;
			}
		}
		if( j == regi.size() ) cout << "Unknown " << ID << endl;
	}
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

/// template end ///



void solve()
{
	READ(int, N);
	auto IDs = read<string>(N);

	bool locked = true;
	READ(int, M);
	REP(i, M)
	{
		READ(string, id);
		if (count(ALLOF(IDs), id))
		{
			locked = !locked;
			write( string(locked ? "Closed" : "Opened") + string(" by ") + id);
		}
		else
		{
			write("Unknown " + id);
		}
	}
}

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

int main()
{
  int N;
  cin >> N;
  string ID[N];
  REP(i, N)
    cin >> ID[i];
  int M, state;
  string T;
  state = 1;
  cin >> M;
  REP(i, M){
    cin >> T;
    if(find(ID, ID + N, T) != ID + N){
      if(state){
        cout << "Opened by " << T << endl;
        state = 0;
      }else{
        cout << "Closed by " << T << endl;
        state = 1;
      }
    }else{
      cout << "Unknown " << T << endl;
    }
  }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string>ch(n);
  for(int i=0;i<n;i++)
    cin>>ch[i];
  bool flag=false;
  int m;cin>>m;
  for(int i=0;i<m;i++){
    string str;cin>>str;
    int j;
    for(j=0;j<n;j++){
      if(ch[j]==str){
	if(flag){
	  cout<<"Closed by"<<" "<<str<<endl;
	  flag=false;
	  break;
	}else{
	  cout<<"Opened by"<<" "<<str<<endl;
	  flag=true;
	  break;
	}
      }
    }
    if(j==n)
      cout<<"Unknown"<<" "<<str<<endl;
  }
  return 0;
}

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

int main(){
    int n;
    string str;
    vector<string> v;
    
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> str;
        v.push_back(str);
    }
    cin >> n;
    int st = 0; //0 Closed , 1 Opened
    for(int i = 0 ; i < n ; i++){
        int flg = 0;
        cin >> str;
        for(int j = 0 ; j < v.size() ; j++){
            if(str == v[j]){
                if(!st){
                    cout << "Opened by " << str << endl;
                    st = 1;
                }
                else{
                    cout << "Closed by " << str << endl;
                    st = 0;
                }
                flg = 1;
                break;
            }
        }
        if(!flg) cout << "Unknown " << str << endl;
    }
    
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	set<string> s;
	while (N--) {
		string U; cin >> U;
		s.insert(U);
	}
	int M; cin >> M;
	bool locked = true;
	while (M--) {
		string T; cin >> T;
		if (s.count(T)) {
			locked = !locked;
			cout << (locked ? "Closed by " : "Opened by ");
		}
		else cout << "Unknown ";
		cout << T << endl;
	}
}

C++: #include<cstdio>
#include<string>
#include<list>
#include<iostream>
#include<map>
#include<set>

using namespace std;

int n,m;
set<string> str;
int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		str.insert(s);
	}
	scanf("%d",&m);
	int flag=1;
	for(int i=0;i<m;i++){
		string s;
		cin >> s;
		if(str.find(s)!=str.end()){
			printf("%s by ",flag?"Opened":"Closed");
			cout << s << endl;
			flag=1-flag;
		}else{
			cout << "Unknown " << s << endl;
		}
	}
	return 0;
}