Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func parseToArray2d(lines []string) [][]int64 {
	var result [][]int64
	for _, line := range lines {
		var parsedLine []int64
		for _, element := range strings.Split(line, " ") {
			n, err := strconv.ParseInt(element, 10, 64)
			if err != nil {
				fmt.Printf("Error: element = %v\n", element)
			}
			parsedLine = append(parsedLine, n)
		}
		result = append(result, parsedLine)
	}
	return result
}

func pop(stack []int64) ([]int64, int64) {
	lenStack := len(stack)
	return stack[0:(lenStack - 1)], stack[lenStack-1]
}

func contains(s []int64, e int64) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	content := []string{}
	for scanner.Scan() {
		line := scanner.Text()
		content = append(content, line)
	}
	arr := parseToArray2d(content)
	input := arr[1]

	stack := []int64{}
	result := -1

	for i, x := range input {
		if x > 0 {
			if contains(stack, x) {
				result = i + 1
				break
			} else {
				stack = append(stack, x)
			}
		} else {
			var top int64
			if len(stack) == 0 {
				result = i + 1
				break
			}
			stack, top = pop(stack)
			if top != -x {
				result = i + 1
			}
		}
	}

	if result < 0 {
		fmt.Println("OK")
	} else {
		fmt.Println(result)
	}
}

Python: L = int(input())

cs = list(map(int, input().split()))

cave = []

cats = [0] * 110

for i, c in enumerate(cs):
    if c > 0 and cats[c] == 0:
        cave.append(c)
        cats[c] = 1
    elif c < 0 and cats[-c] == 1 and cave[-1] == -c:
        cave.pop()
        cats[-c] = 0
    else:
        print(i+1)
        exit()
    # print(cave)
    # print(cats[:10])

print("OK")

Python: L = int(input())
c = [int(x) for x in input().split()]
cat, row, flag = [0]*101, [], 1
for i,j in enumerate(c):
    if j > 0 and cat[j] == 0:
        row.append(j)
        cat[j] = 1
    elif j < 0 and cat[-j] == 1 and row[-1] == -j:
        row.pop()
        cat[-j] = 0
    else:
        flag = 0
        break
if flag: print('OK')
else: print(i+1)

Python: L = int(input())
C = list(map(int, input().split()))
A = []
for i in range(len(C)):
	if C[i]>0:
		if A.count(C[i]):
			print(i+1)
			exit(0)
		else:
			A.append(C[i])
	else:

		if len(A)==0 or A[len(A)-1]!=abs(C[i]):
			print(i+1)
			exit(0)
		else:
			del(A[len(A)-1])
print('OK')

Python: input()
n = [int(i) for i in input().split()]
l = []
ret = 0
for index, i in enumerate(n):
    if i > 0:
        if i in l:
            ret = index + 1
            break
        l.append(i)
    else:
        try:
            if l.pop(-1) != abs(i):
                ret = index + 1
                break
        except:
            ret = index + 1
            break
if ret == 0:
    print('OK')
else:
    print(ret)

Python: N = int(input())
a = list(int(x) for x in input().split())
plus = []
minus = []
plus = plus[::-1]
answer ="OK"
for i in range(N):
  if a[0] < 0:
    answer = i +1
    break
    
  if a[i] > 0 and not(a[i] in plus):
    plus.append(a[i])
  elif a[i] < 0 and not(a[i] in minus):
    if (-(a[i]) in plus):
      minus.append(a[i])
      if (len(plus)-1) -plus.index(-(a[i])) == minus.index(a[i]):
        del minus[minus.index(a[i])]
        del plus[plus.index(-(a[i]))]
      else:
        answer = i+1
        break
    else:
      answer = i+1
      break
  else:
    answer = i+1
    break
print(answer)

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  int n=1e5;
  int m;
  cin>>m;
  vector<int> cs(m);
  for(int i=0;i<m;i++) cin>>cs[i];
  vector<int> used(n+1,0);
  stack<int> stk;
  for(int i=0;i<m;i++){
    if(cs[i]>0){
      if(used[+cs[i]]) drop(i+1);
      stk.emplace(+cs[i]);
      used[+cs[i]]=1;
    }else{
      if(!used[-cs[i]]) drop(i+1);
      if(stk.empty()) drop(i+1);
      if(stk.top()!=-cs[i]) drop(i+1);
      stk.pop();
      used[-cs[i]]=0;
    }
  }
  drop("OK");
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int L;
    cin >> L;
    int c[L];
    for (int i = 0; i < L; i++) {
        cin >> c[i];
    }
    if (c[0] < 0) {
        cout << "1\n";
        return 0;
    }
    deque<int> q;
    q.push_back(c[0]);
    int s[101]{};
    s[c[0]]++;
    for (int i = 1; i < L; i++) {
        if (c[i] < 0) {
            if (q.back() != -c[i]) {
                cout << i + 1 << "\n";
                return 0;
            } else {
                s[q.back()]--;
                q.pop_back();
            }
        } else {
            if (s[c[i]] == 0) {
                s[c[i]] = 1;
                q.push_back(c[i]);
            } else {
                cout << i + 1 << "\n";
                return 0;
            }
        }
    }
    cout << "OK\n";
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int l;
  cin>>l;
  stack<int> st;
  vector<bool> fg(1000,false);
  for(int i=0;i<l;i++){
    int c;
    cin>>c;
    if(c>0){
      if(fg[c]){
        cout<<i+1<<'\n';
        return(0);
      }
      fg[c]=true;
      st.push(c);
    }
    else{
      if(!st.empty()){
        if(st.top()!=-c){
          cout<<i+1<<'\n';
          return(0);
        }
        st.pop();
        fg[-c]=false;
      }
      else{
        cout<<i+1<<'\n';
        return(0);
      }
    }
  }
  cout<<"OK"<<'\n';
  return(0);
}

C++: #include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main(){
    int l;
    cin >> l;
    stack<int> st;
    vector<bool> used(101,false);
    for(int i=0;i<l;i++){
        int c;
        cin >> c;
        if(c > 0){
            if(used[c] == true){
                cout << i+1 << endl;
                return 0;
            }
            used[c] = true;
            st.push(c);
        }
        else{
            if(st.empty() || st.top() != abs(c)){
                cout << i+1 << endl;
                return 0;
            }
            st.pop();
            used[abs(c)] = false;
        }
    }
    cout << "OK" << endl;
    return 0;
}

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



int main(){
  int l;
  bool ana[201];
  
  cin>>l;
  for(int i=1;i<=201;i++){
    ana[i]=false;
  }
  stack<int> neko;
  for(int i=1;i<=l;i++){
    int c;
    cin>>c;
    if(c>0){
      if(ana[c]){
        cout<<i<<endl;
        return 0;
      }
      neko.push(c);
      ana[c]=true;
      continue;
    }
    if(!neko.empty()){
      if(neko.top()==c*-1){
        neko.pop();
        ana[c*-1]=false;
        continue;
      }
    }
    cout<<i<<endl;
    return 0;
    
    
    
  }
  cout<<"OK"<<endl;
  
  
  
  
  
  
}

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

int main() {
  int L;
  cin >> L;
  vector<int> c(L);
  for (int i = 0; i < L; ++i)
    cin >> c[i];

  int ans = 0, c2[101] = {};
  stack<int> c3;
  for (int i = 0; i < L; ++i) {
    if (c[i] > 0)
      c3.push(c[i]), ++c2[c[i]];
    else if (c3.empty())
      ans = i + 1;
    else if (-c[i] == c3.top())
      c3.pop(), --c2[-c[i]];
    else
      ans = i + 1;
    if (c2[abs(c[i])] != 0 && c2[abs(c[i])] != 1)
      ans = i + 1;
    if (ans)
      break;
  }

  if (ans)
    cout << ans << endl;
  else
    cout << "OK" << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool a[1000];
signed main(){
  stack <int> st;
  int l;
  cin>>l;
  for(int i=1;i<=l;i++){
    int n;
    cin>>n;
    if(n>0){
      if(a[n]==0){
	st.push(n);
	a[n]++;
      }else{
	cout<<i<<"\n";
	return(0);
      }
    }else{
      if(st.empty()){
	cout<<i<<"\n";
	return(0);
      }else{
	if(st.top()==-n){
	  st.pop();
	  a[-n]=false;
	}else{
	  cout<<i<<"\n";
	  return(0);
	}
      }
    }
  }
  cout<<"OK\n";
}