Go: package main

import "fmt"

func main() {
	stack := []int{}
	for {
		var a int
		i, _ := fmt.Scan(&a)
		if i == 0 {
			break
		}
		if a == 0 {
			fmt.Println(stack[len(stack)-1])
			stack = stack[:len(stack)-1]
			continue
		}
		stack = append(stack, a)
	}
}

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

using namespace std;

int main(void){
	int tmp;
	stack<int> st;
	vector<int> vehicles;

	while (cin >> tmp){
		if (tmp != 0){
			st.push(tmp);
		}
		else{
			if (st.empty() == false){
				vehicles.push_back(st.top());
				//cout << st.top() << endl;
				st.pop();
			}
		}
	}

	vector<int>::iterator it = vehicles.begin();
	while (it != vehicles.end()){
		cout << *it << endl;
		++it;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    vector<int>a;
	int b;
	while(cin >> b){
		if(b==0){
			printf("%d\n",a[a.size()-1]);
			a.pop_back();
		}
		else{
			a.push_back(b);
		}
	}
    return 0;
}

C++: #include <stdio.h>

#define N 20
int main(void){
    int stk[N], sp=0;
    int n;
   
    while (scanf("%d", &n) != EOF){
        if (n==0 && sp!=0){
            printf("%d\n", stk[--sp]);
        } else {
            stk[sp++] = n;
        }
    }
    return 0;
}

C++: #include<stdio.h>
int main(){
  int n,m,i=0,j=0,h=0;
  int data[20];
  int str[10]={0};
  while(scanf("%d",&n)!=EOF){
    data[i]=n;
    if(n==0){
      j=i;
      while(data[i-1]==0){
	i--;
      }
      str[h]=data[i-1];
      data[i-1]=0;
      i=j;
      j=0;
      h++;
    }
    i++;
  }
  for(i=0;i<h;i++){
    printf("%d\n",str[i]);
  }
  return(0);
}

C++: #include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <stack>
#include <cstring>

using namespace std;

int main(){
	stack<int> garage;
	vector<int> out;
	int enter;
	cin >> enter;
	garage.push(enter);
	while(!garage.empty()){
		cin >> enter;
		if(enter == 0){
			out.push_back(garage.top());
			garage.pop();
		}
		else{
			garage.push(enter);
		}
	}

	for(vector<int>::iterator it = out.begin(); it != out.end(); it++){
		cout << *it << endl; 
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
vector<int> inc,ouc;
int cmd;
while(1){
if(!(inc.size())&&ouc.size())break;
cin >> cmd;
if(!cmd)ouc.push_back(inc[inc.size()-1]),inc.pop_back();
else inc.push_back(cmd);
}
for(int i = 0;i<ouc.size();i++)
cout << ouc[i] << endl;
return 0;
}

C++: #include<stdio.h>
int main(){
  int sp=0,data[9],n,i;
  for(i=0;i<100;i++){
    scanf("%d",&n);
    if(n==0){
      printf("%d\n",data[sp]);
      sp--;
    }else{
      sp++;
      data[sp]=n;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
int main(){
	std::vector<int> car,ans;
	int a;
	while(std::cin>>a){
		if(a!=0)car.push_back(a);
		else {
			std::vector<int>::iterator it=car.end();
			int *n=&*it;
			car.pop_back();
			ans.push_back(*n);
		}
	}
	for(int i=0;i<ans.size();i++){
		std::cout<<ans[i]<<std::endl;
	}
	return 0;
}

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

int main() {
  int n;
  stack<int> stk;
  while (cin >> n) {
    if (n) {
      stk.push(n);
    } else {
      cout << stk.top() << "\n";
      stk.pop();
    }
  }
  return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	stack<int> T;
	int q;
	while(cin>>q){
		if(q){
			T.push(q);
		}
		else{
			out(T.top());
			T.pop();
		}
	}

	return 0;
}

C++: #include <stdio.h>
#include <math.h>

using namespace std;

class STACK{
public:
	STACK(){
		index = 0;
	}

	void push(int data){
		array[index] = data;
		index++;
	}
	int pop(){
		index--;
		return array[index];
	}
	bool isEmpty(){
		return index == 0;
	}

private:
	int array[100];
	int index;
};

int main(){

	STACK stack;
	int tmp;
	while(scanf("%d",&tmp) != EOF){
		if(tmp == 0){
			printf("%d\n",stack.pop());
		}else{
			stack.push(tmp);
		}
	}
    return 0;
}

C++: //#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>
//#include <time.h>

using namespace std;


int main(){

	int a;
	vector <int> s;

	while (cin >> a){
		if (a == 0){
			cout << s.back() << endl;
			s.pop_back();
		}
		else{
			s.push_back(a);
		}
	}


	return 0;
}

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

int main() {
  stack<int> s;
  int l;
  while(cin>>l){
    if(l==0){
      cout<<s.top()<<endl;
      s.pop();
    }else{
      s.push(l);
    }
  }
  return 0;
}

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

int main() {
  int id;
  stack<int> cars;
  while(cin >> id) {
    if(id == 0) {
      cout << cars.top() << endl;
      cars.pop();
    }
    else
      cars.push(id);
  }
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main(){
    stack<int>st;
    int n;
    cin>>n;
    st.push(n);
    while(cin>>n){
    	if(n==0){
    		cout<<st.top()<<endl;
    		st.pop();
    	}
    	else
    		st.push(n);
    }
    return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main(void){
  stack<int> s;
  int n;
  while(cin>>n){
    if(n)
      s.push(n);
    else{
      cout<<s.top()<<endl;
      s.pop();
    }
  }
  return 0;
}

C++: #include<cstdio>
int main()
{
    int train[10]={0},n,count=0,outTrain[10],trainCount=0;
    while(scanf("%d",&n)!=EOF){
        if(n){
            for(int i=count ; i!=0 ; i--){
                train[i]=train[i-1];
            }
            train[0]=n;
            count++;
        }
        else{
            outTrain[trainCount]=train[0];
            for(int i=0 ; i<count ; i++){
                train[i]=train[i+1];
            }
            train[count]=0;
            count--;
            trainCount++;
        }
    }
    for(int i=0 ; i<trainCount ; i++){
        printf("%d\n",outTrain[i]);
    }
    return 0;
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main(){
  stack<int> b;
  int n;
  while(cin>>n){
    if(n==0){
      cout<<b.top()<<endl;
      b.pop();
    }
    else b.push(n);
  }
  return 0; 
}

C++: #include <stdio.h>

#define N 20
int main(void){
    int stk[N], sp=0;
    int n;
   
    while (scanf("%d", &n) != EOF){
        if (n==0 && sp!=0){
            printf("%d\n", stk[--sp]);
        } else {
            stk[sp++] = n;
        }
    }
    return 0;
}

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

int main(){
	int in, out;
	stack<int> stk;
	while( cin >> in ){
		
		if(in != 0){
			stk.push(in);
		}else{
			out = stk.top();
			cout << out << endl;
			stk.pop();
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  stack<int> a;
  int box;
  while(1){
    cin >> box;
    if(box){
      a.push(box);
    }else{
      cout << a.top() << endl;
      a.pop();
    }
    if(a.empty())break;
  }
}

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

int main(){
	int tmp;
	stack<int>st;
	while(cin>>tmp){
		if(tmp>0){
			st.push(tmp);
		}
		else if(tmp==0){
		cout<<st.top()<<endl;
		st.pop();
		}
	}
}