Go: package main

import (
        "fmt"
)

func main() {
        var stk [101]int
        var c int
        pvt := 0
        for {
                _, err := fmt.Scanf("%d", &c)
                if err != nil {
                        break
                }
                if c > 0 {
                        stk[pvt] = c
                        pvt++
                } else {
                        pvt--
                        fmt.Printf("%d\n", stk[pvt])
                }
        }
}

C++: #include<iostream>
#include<malloc.h>
using namespace std;

struct stack{
	int element;
	struct stack *next;
};
int top(struct stack *s){
	return s->element;
}
struct stack* pop(struct stack *s){
	struct stack *p, *q;
	q = s;
	p = s->next;
	free(q);
	s = p;
	return s;
}
struct stack* push(struct stack *s, int x){
	struct stack *p, *q;
	q = s;
	p = (struct stack*)malloc(sizeof(struct stack));
	p->element = x;
	p->next = q;
	s = p;
	return s;
}

int main(){
	struct stack *S=NULL;
	int num;
	while (cin>>num){	
		if (num==0){
			cout<<top(S)<<endl;
			S = pop(S);
		} else{
			S=push(S, num);
		}
	}
	return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int i = 0; i < 600 / n; i++) {
			ans += 600/n*i;
		}
		ans *= 600 / n;
		cout << ans << endl;
	}
}

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

int main() {
	std::list<int> cars;
	int n;
	while (std::cin >> n) {
		if (n != 0) {
			cars.push_back(n);
		}
		else {
			std::cout << cars.back() << std::endl;
			cars.pop_back();
		}
	}
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int x;
  stack<int> s;
  queue<int> q;
  while (cin >> x) {
    if (x == 0) {
      q.push(s.top());
      s.pop();
    } else {
      s.push(x);
    }
  }
  for (; q.size(); q.pop()) cout << q.front() << endl;
}

C++:     #include <iostream>
    using namespace std;
     
    int a[11], b[11], c, t;
     
    int main() {
      cin>>a[0];
      t=1;
      c=0;
     
      while(t>1) {
        cin>>a[t];
        if(a[t]>0) {
          t++;
        }else {
          b[c]=a[t-1];
          c++;
          t--;
        }
      }
     
      for(int i=0;i<c;i++) {
      	cout<<b[i]<<endl;
      }
     
      return 0;
    }

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

int main(void){
    int n;
    stack<int> s;
    while(scanf("%d",&n)!=EOF){
        if(n!=0) s.push(n);
        else{
            cout << s.top() << "\n";
            s.pop();
        }
    }
}

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

int main()
{
	std::stack<int> s;
	int x;
	while( std::cin >> x ){
	 	if( x ) s.push( x );
		else{
		 	std::cout << s.top() << std::endl;
			s.pop();
		}
	}

 	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  
  int a[10],c=0,num;

  while( scanf("%d",&num) != EOF ){

    if( num != 0 ){
      a[c]=num;
      c++;
    }else{
      cout <<a[c-1]<<endl;
      c--;
    }   

  }
  return 0;

}

C++: #include <stdio.h>

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

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

int main(void) {
    u_int in;
    std::stack<u_int> st;

    while (std::cin >> in) {
        if (in > 0) {
            st.push(in);
        } else {
            std::cout << st.top() << std::endl;
            st.pop();
        }
    }

    return 0;
}

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

int main(int argc,char* argv[]){
  std::vector<int> vec(1000);
  
  while(!std::cin.eof()){
    int temp;
    std::cin >> temp;
    if(temp == 0){
      std::cout << vec.back() << std::endl;
      vec.pop_back();
      continue;
    }else{
      vec.push_back(temp);
      continue;
    }
  }

  return 0;

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


using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
  int number,count1,count2,enter[11],leave[11],sum;
  sum=0;
  count1=0;
  count2=0;
  while(1){
    
    if( cin >> number && number>=0 && number<=10){
    
    if(number!=0){
      sum++;
      enter[count1]=number;
      count1++;}
    else if(number==0){
      count1--;
      leave[count2]=enter[count1];
      count2++;}
    if(sum-1<count2)break;
    }}
  for(int i=0;i<count2;i++){
    cout << leave[i]<< endl;
  }
 
  return 0;
}

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

int main() {
  int i;
  int cnt = 0;
  std::vector<int> vec;
  while(cnt < 50) {
    scanf("%d", &i);
    if(i == 0){
      printf("%d\n", vec.back());
      vec.pop_back();
    }else{
      vec.push_back(i);
    }
    cnt++;
  }
  return 0;
}

C++: #include <stdio.h>
#include <vector>
using namespace std;

int main() {
    vector<int> v;
    int a;
    while (scanf("%d", &a) != EOF) {
        if (a != 0) v.push_back(a);
        else {
            printf("%d\n", v.back());
            v.pop_back();
        }
    }
    return 0;
}

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

using namespace std;

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

C++: #include <stdio.h>

int main(void) {

  int car;
  int cars[10];

  int top=0;

  while(scanf("%d",&car)!=EOF) {

    if(car==0) {
      
      top--;
      printf("%d\n",cars[top]);

    }
      
    else {
      
      cars[top]=car;
      top++;

    }

  }

  return 0;

}

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


int main(){
    int num;
    stack<int> Train;
    while(cin >> num){
        if(num){
            Train.push(num);
        }else{
            cout << Train.top() << endl;
            Train.pop();
        }
    }

    return 0;
}