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])
                }
        }
}

Python: l = []

while(1):
    try:
        n = int(input())
    except:
        break

    if n == 0:
        ans = l.pop(-1)
        print(ans)
    else:
        l.append(n)

Python: l = []
while True:
	try:
		train = raw_input()
		if train == '0':
			print(l.pop())
		else:
			l.append(train)
	except EOFError:
		break

Python: import sys

arr = []
for line in sys.stdin:
    n = int(line)
    if n == 0:
        print(arr.pop())
    else:
        arr.append(n)

Python: import sys
a=[int(i)for i in sys.stdin]

b=[]
for j in a:
	if j == 0:
		print(b.pop())
	else:
		b.append(j)

Python: import sys

def run():
    cars = []
    for _n in sys.stdin:
        n = int(_n)
        if n == 0:
            print(cars.pop())
        else:
            cars.append(n)

if __name__ == '__main__':
    run()

Python: import sys
l=[]
for line in sys.stdin:
    o=int(line)
    if not o:
        print(l.pop())
    else:
        l.append(o)

Python: import sys

lines = sys.stdin.readlines()
queue = []
for line in lines:
    if int(line)>0:
        queue.append(int(line))
    elif int(line)==0:
        print (queue[-1])
        queue.pop(-1)

Python: # coding: utf-8
L=[]
while True:
    try:
        n=int(input())
        if n==0:
            L.pop()
        else:
            L.append(n)
    except EOFError:
        break

Python: # AOJ 0013 Switching Railroad Cars
# Python3 2018.6.9 bal4u

class Stack:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return self.items == []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        return self.items[len(self.items)-1]

    def size(self):
        return len(self.items)

s = Stack()
while True:
    try:
        a = int(input())
        if a > 0:
            s.push(a)
        else:	
            print(s.pop())
    except EOFError:
        break

Python: import sys
x=[]
u=[]
for line in sys.stdin.readlines():
    y=int(line)
    if(y!=0):
        x.append(y)
    else:
         u.append(x.pop(-1))
for i in range(len(u)):
    print(u[i])

Python: import sys
cars = []
for line in sys.stdin:
    car = int(line)
    if car:
        cars.append(num)
    else:
        print(cars.pop())

Python: import sys
data = []
for l in sys.stdin:
    l = int(l)
    if l == 0:
        print(data.pop())
    else:
        data.append(l)

Python: a=[]
while 1:
    try:n=int(input())
    except:break
    if n:a.append(n)
    else:print(a.pop())

Python: from sys import stdin
from collections import deque
box = deque()
for _, train in enumerate(stdin) :
    if train.strip() != '0' : box.append(train.strip())
    else : print(box.pop())

Python: s = []
while 1:
    try:
        n = int(input())
        if n == 0:
            print(s.pop())
        else:
            s.append(n)
    except:
        break

Python: D=[]
while True:
  try:
    n=int(input())
    if n==0:
      print(D.pop(-1))
    else:
      D.append(n)
  except EOFError:
    break

Python: while True:
    try:
        n = int(input())
    except:
        break

    arr = []
    if n == 0:
        print(arr[-1])
        arr = arr[:-1]
    else:
        arr.append(n)

Python: import sys
if __name__ == '__main__':
    a = []
    for tmpLine in sys.stdin:
        x = (int)(tmpLine)
        if x != 0:
            a.append(x)
        else:
            print(a.pop())

Python: try:
    num = []
    while True:
        #標準入力
        i = int(input())
        #0だった場合１番後ろを出力し削除、それ以外はリストに追加
        if i == 0:
            print(num[-1])
            num.pop(-1)
        else:num.append(i)
#EOFErrorをひろい、ループを抜ける
except EOFError:
    pass

Python: from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = []
for line in stdin:
    if not line.strip():
        continue
    n = int(line)
    if not n:
        print(L.pop())
    else:
        L.append(n)

Python: l=[]
l.append(int(input()))
while l:
    o=int(input())
    if not o:
        print(l.pop())
    else:
        l.append(o)

Python: t = []
while 1:
    try:
        a = input()
    except:
        break
    if a == 0:
        print(t[-1])
        t = t[:-1]
    else:
        t.append(a)

Python: cars = []
while True:
    try:
        inVal = int(input())
        if inVal == 0:
            print(cars.pop(-1))
        else:
            cars.append(inVal)
    except EOFError:
        break

Python: list1 = []
for i in range(1, 200):

    try:
        str1 = input()
        if str1 != '0' and str1 != '':
            list1.append(str1)
        elif str1 == '0':
            print(list1.pop())
        else:
            break
    except:
        break

Python: car = []
while True:
   try:
       x =int(input())
       if x == 0:
            print(car.pop())
       else:
           car.append(x)
   except:break

Python: import sys

lst = []
for line in sys.stdin:
#    if line:
    num = line.strip()
    if num == "0":
        print(str(lst.pop()) + "")
    else:
        lst.append(num)
sys.exit(0)

Python: a = [] 
while True: 
  try: 
    i = int(input()) 
  except: 
    break
  if i == 0: 
    c = a.pop() 
    print(c) 
  else: 
    a.append(i)

Python: stack=[]
i=0
x=int(input())
stack.append(x)
while 1:
    try:
        x=int(input())
        if (x==0):
            print(stack[i])
            stack.pop()
            i-=1
        else:
            stack.append(x)
            i+=1
    except EOFError:
        break

Python: import sys

if __name__ == '__main__':
    stack = []
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            print(stack.pop(len(stack) - 1))
        else:
            stack.append(n)

Python: car=[]
while True:
    try:
        n=int(input())
        if n!=0:
            car.append(n)
        else:
            print(car.pop())
    except:break

Python: stack = []
while True:
  try:
    num = int(input())
  except EOFError:
    break
  if num != 0:
    stack.append(num)
  elif num == 0:
    print(stack.pop(-1))

Python: garage = []
while True:
    num = int(input())
    if num == 0:
        print(garage.pop())
    else:
        garage.append(num)
    if not garage:
        break

Python: import sys
a=[int(i)for i in sys.stdin]

b=[]

for j in a:
	if j == 0:
		print(b.pop())
	else:
		b.append(j)

Python: # -*- coding:utf-8 -*-

def main():
    LIST=[]
    while True:
        try:
            IN=int(input())
            if IN==0:
                print(LIST[len(LIST)-1])
                del LIST[len(LIST)-1]
            else:
                LIST.append(IN)

        except:
            break
            
    
if __name__ == '__main__':
    main()

Python: stack = []
while True:
    a = int(input())
    if a == 0:
        print(stack.pop())
    else:
        stack.append(a)
    if len(stack) == 0:
        exit()

Python: import sys
s = []
[print(s.pop()) if int(e) == 0 else s.append(int(e)) for e in sys.stdin]

Python: stack = []
stack.append(int(input()))
while stack:
    inp = int(input())
    if inp == 0:
        a = stack[-1]
        del stack[-1]
        print(a)
    else:
        stack.append(inp)

Python: # Switching Railroad Cars
from collections import deque
num = int(input())
stk = deque()
while 1:
    if num == 0:
        print(stk.pop())
    else:
        stk.append(num)
    try: num = int(input())
    except EOFError: break
while stk: print(stk.pop())