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

int main(){
    int N,M,openflag=0,flag = 0;
    string baf_U,baf_T;
    string U[256];
    string T[256];
    cin >> N;
    for(int i= 0;i<N;i++){
        cin >> baf_U;
        U[i] = baf_U;
    }
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> baf_T;
        T[i] = baf_T;
    }
    for(int i=0;i<M;i++){
        for(int k = 0;k<N;k++){
            if(U[k]==T[i]){
                flag = 1;
            }
        }
        if(flag ==1){
            if(openflag==0){
                cout <<"Opened by "<<T[i]<<endl;
                openflag = 1;
            }else{
                cout <<"Closed by "<<T[i]<<endl;
                openflag = 0;
            }
        }else{
            cout <<"Unknown "<<T[i]<<endl;
        }
        flag = 0;
    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string *registeredID = new string[n];
	for(int i=0;i<n;i++){
		cin >> registeredID[i];
	}
	sort(registeredID, registeredID+n);
	int m;
	cin >> m;
	string *cardID = new string[m];
	for(int i=0;i<m;i++){
		cin >> cardID[i];
	}
	bool isOpen = false;
	for(int i=0;i<m;i++){
		bool contains = binary_search(registeredID,registeredID+n, cardID[i]);
		if(contains==true){
			if(isOpen == true){
				cout << "Closed by " << cardID[i];
			}else{
				cout << "Opened by " << cardID[i];
			}
		}else{
			cout << "Unknown " << cardID[i];
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <set>

using namespace std;



int N, M;
string open="Opened by ", close="Closed by ", unk = "Unknown ";

int main() {
	cin >> N;
	
	set<string> users;
	for (int i=0; i<N; i++) {
		string user; cin >> user;
		users.insert(user);
	}
	
	cin >> M;
	bool opened = false;
	for (int i=0; i<M; i++) {
		string comes; cin >> comes;
		if (users.find(comes) != users.end()) {
			if (!opened) cout << open << comes << endl;
			else cout << close << comes << endl;
			opened = !opened;
		} else {
			cout << unk << comes << endl;
		}
	}
	
	return 0;
}

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

using namespace std;

int N, M;
string U[256];

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;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


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

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

int main(){

  int door[257];
  string id[257];
  string name;
  int n, m;
  int flag = 1; // flag == 1 locked

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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    set<string> se;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        se.insert(S);
    }
    int M;
    cin >> M;
    bool lock = true;
    for(int i=0; i<M; i++){
        string S;
        cin >> S;
        if(se.count(S)){
            if(lock){
                cout << "Opened by " << S << "\n";
                lock = false;
            }else{
                cout << "Closed by " << S << "\n";
                lock = true;
            }
        }else{
            cout << "Unknown " << S << "\n";
        }
    }
    return 0;
}

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

int main(){
   int N, M;
   string U[300], T[300];
   cin>>N;
   for(int i=0;i<N;i++) cin>>U[i];
   cin>>M;
   for(int j=0;j<M;j++) cin>>T[j];
   
   int key=0,mes[300]; //key=0 before close
   for(int i=0;i<M;i++){
       for(int j=0;j<N;j++){
           if(U[j] == T[i] && key == 0){
                     mes[i]+=1;
           }
           else if(U[j] == T[i] && key == 1){
                     mes[i]+=300;
           
           }
           else mes[i]+=0;
        }
        if(mes[i]>299) key=0;
        else if(mes[i]>0) key=1;
        else key=key;
     }

    for(int i=0;i<M;i++){
          if(mes[i]>300) cout<<"Closed by "<<T[i]<<endl;
          else if(mes[i]>0) cout<<"Opened by "<<T[i]<<endl;
          else cout<<"Unknown "<<T[i]<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
    int n, m;
    string u, t;
    bool is_opened = false;
    set<string> ids;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> u;
        ids.insert(u);
    }
    cin >> m;
    for (int i=0; i<m; i++) {
        cin >> t;
        if (ids.find(t) == ids.end()) {
            cout << "Unknown " << t << endl;
        }
        else {
            is_opened = !is_opened;
            if (is_opened) {
                cout << "Opened by " << t << endl;
            }
            else {
            cout << "Closed by " << t << endl;
            }
        }
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;cin>>n;
    vector<string>vs(n);
    for(int i=0;i<n;++i){
        cin>>vs[i];
    }
    sort(vs.begin(),vs.end());
    int m;cin>>m;
    bool lock=0;
    for(int i=0;i<m;++i){
        string s;cin>>s;
        auto it1=lower_bound(vs.begin(),vs.end(),s);
        auto it2=upper_bound(vs.begin(),vs.end(),s);
        if(it1==it2){
            cout<<"Unknown "<<s<<endl;
            continue;
        }
        else{
            if(lock)lock=false;
            else lock=true;
            if(lock)cout<<"Opened by "<<s<<endl;
            else cout<<"Closed by "<<s<<endl;
        }
    }
    return 0;
}