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<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back


int main(void){
  int n,m;
  vector<string> u;
  string t;
  cin >> n;
  rep(i,n){cin >> t;u.eb(t);}
  cin >> m;
  bool s = true;
  rep(i,m){
    bool f=false;
    cin >> t;
    rep(i,n){
      if(t==u[i]){
        f=true;
      }
    }
    if(f){
      if(s) cout << "Opened by " << t << endl;
      else  cout << "Closed by " << t << endl;
      s ^= true;
    }else{
      cout << "Unknown " << t << endl;
    }
  }



  return 0;
}

C++: #ifdef LOCAL
    #define _GLIBCXX_DEBUG
    #define __clock__
#else
    #pragma GCC optimize("Ofast")
#endif
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

ll SUM(VI& V){
  return accumulate(ALL(V), 0LL);
}

void print_vector(VI& V){
  ll n = V.size();
  rep(i, n){
    if(i) cout << ' ';
    cout << V[i];
  }
  cout << endl;
}

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N;cin>>N;
    map<string, ll> mp;
    rep(i,N){
      string s;cin>>s;
      mp[s] = 0;
    }
    ll M;cin>>M;
    ll open=0;
    rep(i,M){
      string s;cin>>s;
      if(mp.count(s)==0){
        p2("Unknown", s);
      }else{
        open = 1-open;
        if(open==1){
          p2("Opened by", s);
        }else{
          p2("Closed by", s);
        }
      }
    }

    
    return 0;
}

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

int main(void){
  int n, m, i;
  bool lock;
  string u, t, mess;
  map<string, bool> mp;

  cin >> n;
  for(i=0;i<n;i++){
    cin >> u;
    mp[u] = true;
  }
  
  lock = true;
  cin >> m;
  for(i=0;i<m;i++){
    cin >> t;
    if(mp.find(t) == mp.end()){
      cout << "Unknown " << t << endl;
    }else{
      mess = lock ? "Opened by ":"Colsed by ";
      lock = not lock;
      cout << mess << t << endl;
    }
  }
  return 0;
}

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

int main() {
    int n;
    while (cin >> n) {
        set<string> ss;
        for (int i = 0; i < n; i++) {
            string id;
            cin >> id;
            ss.insert(id);
        }
        int m;
        cin >> m;
        bool isOpen = false;
        for (int i = 0; i < m; i++) {
            string id;
            cin >> id;
            if (ss.find(id) == ss.end()) {
                cout << "Unknown " << id << endl;
            } else {
                if (isOpen) {
                    cout << "Closed by " << id << endl;
                } else {
                    cout << "Opened by " << id << endl;
                }
                isOpen = !isOpen;
            }
        }
    }
}

C++: #include<iostream>
#include<vector>
#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; cout<<"Opened by "<<T[i]<<endl;}
      else {key=0; cout<<"Closed by "<<T[i]<<endl;}
    }
    
    else{cout<<"Unknown "<<T[i]<<endl;}
  }

  return 0;}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  int m;
  cin >> m;
  string t;
  bool closed = true;
  bool flag;
  for(int i=0;i<m;i++){
    cin >> t;
    flag=false;
    for(int j=0;j<n;j++){
      if(t==s[j]){
        closed=(!closed);
        cout << (closed?"Closed by ":"Opened by ") <<
            t << endl;
        flag=true;
      }
    }
    if(!flag){
      cout << "Unknown " << t << endl;
    }
  }
  return 0;
}