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 <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;




int main(){
    map<string,int> data;
    data.clear();
    
    int n,m;
    cin>>n;
    rep(i,n){
        string a;
        cin>>a;
        data[a]=1;
    }
    
    cin>>m;
    bool now=true;

    rep(i,m){
        string a;
        cin>>a;
        if(data[a]==1){
            if(now){
                cout<<"Opened by ";
            }
            else{
                cout<<"Closed by ";
            }
            now=!now;
            cout<<a<<endl;
            
        }
        else{
            cout<<"Unknown "<<a<<endl;
        }
    }
    
    
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<map>
using namespace std;
int main() {
	map<string, int> word;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string u;
		cin >> u;
		word[u] = 0;
	}
	int m;
	cin >> m;
	bool opened = false;
	for(int i = 0; i < m; i++) {
		string t;
		cin >> t;
		if(word.find(t) != word.end()) {
			if(!opened) {
				cout << "Opened by " << t << endl;
				opened = true;
			}
			else {
				cout << "Closed by " << t << endl;
				opened = false;
			}
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  map<string, bool> m;

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

  cin >> M;
  int state = 0;
  for(int i=0; i<M; i++) {
    string T;
    cin >> T;
    if( m[T] && state == 0 ) cout << "Opened by " << T << endl, state = 1;
    else if( m[T] && state == 1 ) cout << "Closed by " << T << endl, state = 0;
    else cout << "Unknown " << T << endl;
  }
  
}

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

int main(){
    int n;
    cin >> n;
    set<string> user;
    for(int i=0;i<n;++i){
        string u;
        cin >> u;
        user.insert(u);
    }
    int m;
    cin >> m;
    bool door = false;
    for(int i=0;i<m;++i){
        string t;
        cin >> t;
        if(user.count(t)){
            cout << (door ? "Closed by " : "Opened by ") << t << endl;
            door = !door;
        }else{
            cout << "Unknown " << t << endl;
        }
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

vector<string> U(260); 
vector<string> T(260); 
int n,m;
int key=0;

int main(){
  cin>>n;
  for(int i=0;i<n;i++) { cin>>U[i];}
 
  cin>>m;
  for(int i=0;i<m;i++) {
    cin>>T[i];
  }
  
  sort(U.begin(),U.end());

  for(int i=0;i<n;i++){
    
    if(*lower_bound(U.begin(),U.end(),T[i])==T[i]){
      if(key==0){ key=1; printf("Opened by %s\n",&T[i]);}
      else {key=0; printf("Closed by %s\n" ,&T[i]);}
    }
    
    else {printf("Unkown %s\n" ,&T[i]);}
  }

  return 0;}

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

int main(){
    int n,m;
    bool f = false;
    set<string> s;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        s.insert(str);
    }
    cin >> m;
    for(int i=0;i<m;i++){
        string str;
        cin >> str;
        if(s.find(str) == s.end()) cout << "Unknown " << str << endl;
        else if(!f){
            cout << "Opened by " << str << endl;
            f = true;
        } else {
            cout << "Closed by " << str << endl;
            f = false;
        }
    }
}

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<vector>
#include<string>
using namespace std;

int main(){
    while(1){
        int N;
        cin>> N;
        vector<string>U(N);
        for(auto &a : U){
            cin >>a;
        }
        int M;
        cin >>M;
        int flag=0,auth;
        for(int i=0;i<M;i++){
            string s;
            cin >>s;
            auth=0;
            for(int j=0;j<N;j++){
                if(U[j]==s){
                    if(flag==0){
                        cout<<"Opened by "<<s<<endl;
                        flag=1;
                    }
                    else{
                        cout<<"Closed by "<<s<<endl;
                        flag=0;
                    }
                    auth=1;
                    break;
                }
                if(auth)break;
            }
            if(auth==0)cout<<"Unknown "<<s<<endl;
        }
    }
    return 0;
}

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

int main(void){
	int n, m;
	set<string> st;
	cin >> n;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		st.insert(s);
	}
	cin >> m;
	bool open = false;
	for(int i = 0; i < m; ++i){
		cin >> s;
		if(st.find(s) == st.end()){
			cout << "Unknown ";
		}else{
			if(open){
				cout << "Closed by ";
			}else{
				cout << "Opened by ";
			}
			open = !open;
		}
		cout << s << endl;
	}
	return 0;
}

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

vector<string> usr_name;

int main(){
  vector<string>::iterator it;
  int n,m,i = 0,j = 0;
  bool k = 0;
  string tmp;
  cin >>n;
  cin.ignore();
  for(i = 0;i < n;i++){
    cin >>tmp;
    usr_name.push_back(tmp);
    cin.ignore();
  }
  cin >> m;
  cin.ignore();
  for(i = 0; i<m;i++){
    j = 0;
    cin >> tmp;
    it = usr_name.begin();
    while(it != usr_name.end()){
      it++;
      if(tmp == usr_name[j]){
	if(k == 0){
	  cout << "Open by "<<tmp<<endl;
	  k = !k;
	}else{
	  cout << "Close by "<<tmp<<endl;
	  k = !k;
	}
	j = -1;
	break;
      }
      j++;
    }
    if(j != -1)
      cout <<"Unknown "<<tmp<<endl;
  }
    return 0;
  }

C++: #include <cstdio>
#include <string>
#include <algorithm>
 
using namespace std;
 
int N, M;
string U[257];
 
int main() {
  char s[11];
  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->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}