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 <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){

  int n;
  while(cin >> n){
    string st;
    set<string> s;
    rep(i,n){
      cin >> st; 
      s.insert(st);
    }
    int m,f=0;
    cin >> m;
    rep(i,m){
      cin >> st;
      if(s.count(st) == 0){
	cout << "Unknown " << st << endl;
      }
      else{
	if(f==0){
	  cout << "Opened by " << st << endl;
	  f=1;
	}
	else{
	  cout << "Closed by " << st << endl;
	  f=0;
	}
      }
    }
  }
}

C++: #include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  vector<string>sis(256);
  int n,m;

  cin>>n;
  rep(i,n)cin>>sis[i];

  cin>>m;
  int key=1;
  rep(i,m){
    string in;
    bool known=false;
    cin>>in;
    rep(i,n)if(sis[i]==in)known=true;
    if(known){
      if(key){cout<<"Opened by "<<in<<endl;key=0;}
      else {cout<<"Closed by "<<in<<endl;key++;}
    }else cout<<"Unknown "<<in<<endl;
  }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
const int OPEN = 1, CLOSE = 0;

typedef pair<string, int> pp;

int main()
{
	int n, m;
	string s;
	map<string, int> l;
	cin >> n;
	REP(n){ cin >> s ; l.insert(pp(s, 1));}
	cin >> m;
	int f = CLOSE;
	REP(m)
	{
		cin >> s;
		if(l.find(s) == l.end())
			cout << "Unknown " << s << endl;
		else
		{
			if(f == CLOSE){	cout <<"Opened by " << s << endl;  f = OPEN;}
			else { cout << "Closed by " << s << endl; f = CLOSE;}
		}
	}

	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

int main(){
  int n, m;
  cin >> n;
  string reg[n];
  REP(i, n) cin >> reg[i];
  cin >> m;
  string user;
  bool locked = true;
  REP(i, m) {
    cin >> user;
    bool find = false;
    REP(j, n) if(user == reg[j]) { find = true; locked = !locked; break; }
    if(find)
      cout << (locked ? "Closed" : "Opened") << " by " << user << endl;
    else cout << "Unknown " << user << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, m;
  string tmp;
  vector<string> user;
  bool open = false;
  cin >> n;
  while (n--) {
    cin >> tmp;
    user.push_back(tmp);
  }
  cin >> m;
  while (m--) {
    cin >> tmp;
    if (find(user.begin(), user.end(), tmp) == user.end()) {
      cout << "Unknown " << tmp << el;
    }
    else {
      if (open) {
        open = false;
        cout << "Closeed by " << tmp << el;
      } else {
        open = true;
        cout << "Opened by " << tmp << el;
      }
    }
  }
}

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

using namespace std;
int main() {
        vector<string>VS{ "Opened by ","Closed by ","Unknown " };
        set<string>SS;
        int N;
        cin >> N;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                SS.insert( S );
        }
        cin >> N;
        bool x = 0;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                if( SS.end() == find( SS.begin(), SS.end(), S ) ) {
                        cout << VS[2] << S << endl;
                } else {
                        cout << VS[x] << S << endl;
                        x = 1 - x;
                }
        }
        sleep(1);
        return 0;
}

C++: /*
 * 2440.cc: Kagisys
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef map<string,int> msi;

/* global variables */

msi us;

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;

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

  int m;
  cin >> m;

  bool dr = false;

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

    msi::iterator mit = us.find(ti);
    if (mit == us.end()) cout << "Unknown " << ti << endl;
    else {
      dr = ! dr;
      string stat = dr ? "Opened" : "Closed";
      cout << stat << " by " << ti << endl;
    }
  }
  
  return 0;
}

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

int main(){
	int n,m;
	vector<string> v(256);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	cin >> m;
	bool open = false;
	for(int i=0;i<m;i++){
		string t;
		cin	>> t;
		if(find(v.begin(),v.end(),t) != v.end()){
			if(open){
				cout << "Closed by ";
			} else {
				cout << "Opened by ";
			}
			open=(open+1)%2;
			cout << t << endl;
		} else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

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

int main(){
  int n,m;
  string s;
  set<string> id;

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

  cin >> m;
  bool open = false;
  for(int i=0;i<m;i++){
    cin >> s;
    if(id.find(s) == id.end()){
      cout << "Unknown " << s << endl;
    }else{
      if(open)cout << "Closed by " << s << endl;
      else cout << "Opened by " << s << endl;
      open = !open;
    }
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<string> u(n);
    for(int i=0;i<n;i++)cin>>u[i];
    int m;
    cin>>m;
    int a=0;
    for(int i=0;i<m;i++){
        string t;
        cin>>t;
        for(int j=0;j<n;j++){
            if(t==u[j]){
                if(a==0){
                    cout<<"Opened by "<<t<<endl;
                    a=1;
                }
                else{
                    cout<<"Closed by "<<t<<endl;
                    a=0;
                }
                break;
            }
            if(j==n-1)cout<<"Unknown "<<t<<endl;
        }
    }
    return 0;
}

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

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

int main() {
    map<string, bool> memo;
    int n; cin >> n;
    rep(i,n) {
        string s; cin>>s;
        memo[s] = true;;
    }

    int m; cin >> m;
    int cur = 1;
    rep(i,m) {
        string s; cin>>s;
        if(memo[s] == 0)
            cout << "Unknown " << s << "\n";
        else if(memo[s] == 1 and cur == 1)
            cout << "Opened by " << s << "\n", cur*=-1;
        else
            cout << "Closed by " << s << "\n", cur*=-1;
    }

    return 0;
}