Problem:

Vector

 

  For a dynamic array $A = \{a_0, a_1, ...\}$ of integers, perform a sequence of the following operations:

  
pushBack($x$): add element $x$ at the end of $A$

  
randomAccess($p$):print element $a_p$

  
popBack(): delete the last element of $A$

  
$A$ is a 0-origin array and it is empty in the initial state.

Input

  The input is given in the following format.

$q$
$query_1$
$query_2$
:
$query_q$

  Each query $query_i$ is given by

0 $x$

or

1 $p$

or

2

  where the first digits 0, 1 and 2 represent pushBack, randomAccess and popBack operations respectively.

  randomAccess and popBack operations will not be given for an empty array.

Output

  For each randomAccess, print $a_p$ in a line.

Constraints

  
$1 \leq q \leq 200,000$

  
$0 \leq p < $ the size of $A$

  
$-1,000,000,000 \leq x \leq 1,000,000,000$

Sample Input 1

8
0 1
0 2
0 3
2
0 4
1 0
1 1
1 2

Sample Output 1

1
2
4



Sample input:
8
0 1
0 2
0 3
2
0 4
1 0
1 1
1 2


Sample output:
1
2
4

Submission status: Accepted

Solution code:
class Vector():
    def __init__(self):
        self.vector = []

    def pushBack(self, x):
        self.vector.append(x)

    def randomAccess(self, p):
        return self.vector[p]

    def popBack(self):
        self.vector.pop()


num_queue = int(input())
vector = Vector()

for i in range(0, num_queue):
    queue = tuple(map(int, input().split(' ')))
    if queue[0] == 0:
        vector.pushBack(queue[1])
    elif queue[0] == 1:
        print(f'{vector.randomAccess(queue[1])}')
    elif queue[0] == 2:
        vector.popBack()

Submission status: Accepted

Solution code:

q=int(input())
S=list()

for i in range(q):
    query = input().split()
    #print(query)
    if query[0] == '0':      #pushBack(x)
        S.append(query[1])
    
    elif query[0] == '1':    #randomeAccess(p)
        print("{}".format(S[int(query[1])]))
    
    elif query[0] == '2':    #popBack()
        S.pop()

Submission status: Accepted

Solution code:
query_n = int(input())

lst = []

for _ in range(query_n):
    query = input().split()
    
    if query[0] == "0":
        lst.append(query[1])
    elif query[0] == "1":
        print(lst[int(query[1])])
    elif query[0] == "2":
        del lst[-1]

Submission status: Accepted

Solution code:
q = int(input())

l = []
for _ in range(q):
    a = input().split()
    if a[0] == "2":
        l.pop()
    else:
        m,q = map(int, a)
        if m == 0:
            l.append(q)
        else:
            print(l[q])

Submission status: Accepted

Solution code:
n = int(input())
dic = []
for i in range(n):
    a = list(map(int,input().split()))
    if len(a) == 1:
        del dic[-1]
    elif a[0] == 0:
        dic.append(a[1])
    else:
        print(dic[a[1]])

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans
    
    ### intチェック
    def is_integer(self, n):
        try:
            float(n)
        except ValueError:
            return False
        else:
            return float(n).is_integer()

    ### 幾何学問題用
    def dist(self, A, B):
        d = 0
        for i in range(len(A)):
            d += (A[i]-B[i])**2            
        d = d**(1/2)
        return d

    ### 絶対値
    def abs(self, n):
        if n >= 0:
            return n
        else:
            return -n

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート（代入する必要なし）
# N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
            #N.append([int(x) for x in input().split()])
        except EOFError:
            break
    return N

q = int(input())
A = []

for i in range(q):
    que = [int(x) for x in input().split()]
    if que[0] == 0:
        A.append(que[1])
    elif que[0] == 1:
        print(A[que[1]])
    elif que[0] == 2:
        A.pop()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    aa=[]
    for _ in range(n):
        qq=list(map(int, input().split()))
        if qq[0]==0:aa.append(qq[1])
        elif qq[0]==1:print(aa[qq[1]])
        else:aa.pop()

main()

Submission status: Accepted

Solution code:
class Vector:


    def __init__(self):
        self.a = []

    def pushBack(self, x):
        self.a.append(x)

    def randomAccess(self, p):
        print(self.a[p])

    def popBack(self):
        self.a = self.a[:-1]


v = Vector()

n = int(input())
for i in range(n):
    q_str =  input().split()
    q = int(q_str[0])
    if q == 0:
        v.pushBack(int(q_str[1]))
    elif q  == 1:
        v.randomAccess(int(q_str[1]))
    else:
        v.popBack()

Submission status: Accepted

Solution code:
def main():
    A=[]
    box=[]
    q=int(input())
    for i in range(q):
        query=input()
        if query.isdigit():
            A.pop(-1)
        else:
            que,num=map(int,query.split())
            if que==0:
                A.append(num)
            elif que==1:
                box.append(A[num])

    for a in box:
        print(a)

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    cmd = list(map(int, input().split()))
    if cmd[0] == 0:
        a.append(cmd[1])
    elif cmd[0] == 1:
        print(a[cmd[1]])
    elif cmd[0] == 2:
        a.pop(-1)

Submission status: Accepted

Solution code:
q = int(input())
a = []

for i in range(q):
    p = input().split()
    if p[0] == '0':
        a.append(p[1])
    elif p[0] == '1':
        print(a[int(p[1])])
    else:
        a.pop(-1)

Submission status: Accepted

Solution code:
q = int(input())
A = []
for _ in range(q):
    n, *x = map(int, input().split())
    if n == 0:
        A.append(x)
    elif n == 1:
        print(A[x[0]][0])
    else:
        A.pop(-1)

Submission status: Accepted

Solution code:
n=int(input())
que=[]

for i in range(n):
    command=list(map(str,input().split()))
    if command[0]=="0":
        que.append(int(command[1]))
    elif command[0]=="1":
        print(que[int(command[1])])
    elif command[0]=="2":
        que.pop()

Submission status: Accepted

Solution code:
import sys
q = int(input())

ans = []
d = []
for i in range(q):
    # a = list(map(int, input().split()))
    a = sys.stdin.readline()
    
    if a[0] == '0':
        d.append(a[2:])
    elif a[0] == '1':
        ans.append(d[int(a[2:])])
    else:
        d.pop(-1)
for i in ans:
    print(i.strip())

Submission status: Accepted

Solution code:
#import sys
#from sys import stdin
#input = stdin.readline

A = []
n = int(input())

for _ in range(n):
    command = input()
    if command == "2":
        A.pop()
    else:
        command, value = command.split()
        if command == "0":
            A.append(int(value))
        else:
            print(A[int(value)])

Submission status: Accepted

Solution code:
q = int(input())
A = []
for i in range(q):
    com = list(map(int, input().split()))
    if com[0] == 0:
        A.append(com[1])
    elif com[0] == 1:
        print(A[com[1]])
    else:
        A.pop()

Submission status: Accepted

Solution code:
class Vector:
    def __init__(self):
        self._container = []
    
    def pushback(self, x):
        self._container.append(x)
    
    def randomAccess(self, index):
        return self._container[index]
    
    def popback(self):
        return self._container.pop()
        
num_operations = int(input())
vector = Vector()

for _ in range(num_operations):
    line = input()
    if line[0] in ('0', '1'):
        operation, target = line.split()
        target = int(target)
    else:
        operation = line[0]
        
    if operation == '0':
        vector.pushback(target)
    elif operation == '1':
        print(vector.randomAccess(target))
    elif operation == '2':
        vector.popback()

Submission status: Accepted

Solution code:
from collections import deque
q=deque([])
_,*l=open(0)
for x in l:
    if x[0]=="2":q.pop()
    else:
        a,b=map(int,x.split())
        if a==0:q.append(b)
        else:print(q[b])

Submission status: Accepted

Solution code:
n=int(input())
S = [list(map(int, input().split())) for i in range(n)]
A=[]
for i in range(n):
  if S[i][0]==0:
    A.append(S[i][1])
  elif S[i][0]==1:
    try:
      print(A[S[i][1]])
    except AttributeError:
      pass
  elif S[i][0]==2:
    try:
      A.pop()
    except AttributeError:
      pass

Submission status: Accepted

Solution code:
queue = []

for i in range(int(input())):
    query = list(map(int, input().split()))
    
    if query[0] == 0:
        queue.append(query[1])
    elif query[0] == 1:
        print(queue[query[1]])
    else:
        queue.pop()

Submission status: Accepted

Solution code:
lists = []
n = int(input())
 
for i in range(n):
    query = list(map(int, input().split()))
    if(query[0] == 0):
        lists.append(query[1])
    elif(query[0] == 1):
        print(lists[query[1]])
    elif(query[0] == 2):
        lists.pop()

Submission status: Accepted

Solution code:

num = int(input())

l = []

for i in range(num):
    c = [int(x) for x in input().split()]
    if c[0]== 0:
        l.append(c[1])
    elif c[0] ==1:
        print(l[c[1]])
    elif c[0] ==2:
        del(l[-1:])

Submission status: Accepted

Solution code:
from typing import List


if __name__ == "__main__":
    num_query = int(input())
    vector: List[int] = []
    for _ in range(num_query):
        op, *value = map(lambda x: int(x), input().split())
        if (0 == op):
            vector.append(value[0])
        elif (1 == op):
            print(f"{vector[value[0]]}")
        elif (2 == op):
            vector.pop()
        else:
            pass

Submission status: Accepted

Solution code:
q = int(input())

ans = []

for _ in range(q):
    x = input().split()

    if x[0] == "0":
        ans.append(x[1])
    elif x[0] == "1":
        print(ans[int(x[1])])
    else:
        ans.pop()

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
Deq=deque()
for i in range(n):
    command=input().split( )
    com=int(command[0])
    if len(command)>1:
        com1=int(command[1])
    if com==0:
        Deq.append(com1)
    elif com==1:
        q=Deq[com1]
        print(q)
    elif com==2:
        del Deq[-1]

Submission status: Accepted

Solution code:
from collections import deque

q = int(input())
a = deque()
for _ in range(q):
    op = list(map(int, input().split()))
    if op[0] == 0:
        a.append(op[1])
    elif op[0] == 1:
        print(a[op[1]])
    elif op[0] == 2:
        a.pop()

Submission status: Accepted

Solution code:
N = int(input())

A = []

for _ in range(N):
    x = list(map(int, input().split()))
    if x[0] == 0:
        A.append(x[1])
    if x[0] == 1:
        print(A[x[1]])
    if x[0] == 2:
        A.pop()

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    x = input()
    if x[0] == "0":
        a, b = map(int, x.split())
        l.append(b)
    elif x[0] == "1":
        a, b = map(int, x.split())
        print(l[b])
    elif x[0] == "2":
        del l[-1]

Submission status: Accepted

Solution code:
A = []
ans = []
for i in range(int(input())):
    query = list(map(int, input().split()))
    if(query[0] == 0):
        A.append(query[1])
    elif(query[0] == 1):
        ans.append(A[query[1]])
    else:
        A.pop()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
a = int(input())

res = []
for i in range(a):
    temp = list(map(int, input().split()))
    if temp[0] == 0:
        res.append(temp[1])
    elif temp[0] == 1:
        print(res[temp[1]])
    else:
        res.pop()

Submission status: Accepted

Solution code:
n = int(input())
lst = []
for i in range(n):
    lst1 = list(map(int,input().split()))
    lst.append(lst1)
vec = []
for i in range(n):
    if lst[i][0]==0:
        vec.append(lst[i][1])
    elif lst[i][0]==2:
        vec.pop()
    else:
        print(vec[lst[i][1]])

Submission status: Accepted

Solution code:
from collections import deque
q=int(input())
a=deque([])
for i in range(q):
    query=input()
    if query=="2":
        a.pop()
        continue
    que,x=query.split()
    if que=="1":
        print(a[int(x)])
    else:
        a.append(x)

Submission status: Accepted

Solution code:
q = int(input())
A = []
 
for i in range(q):
    Q, *x = (int(x) for x in input().split())
    x = x[0] if x else None
    if Q == 0:
        A.append(x)
    elif Q == 1:
        print(A[x])
    else:
        del A[-1]

Submission status: Accepted

Solution code:
q = int(input())
ans = []
for i in range(q):
    a = list(map(int, input().split()))
    if a[0] == 0: ans.append(a[1])
    elif a[0]==1: print(ans[a[1]])
    else: ans.pop()

Submission status: Accepted

Solution code:
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
    a = input()
    if   a[0] == '0': Q.append(a[2:])      # pushBack
    elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
    else:             Q.pop()              # popBack

Submission status: Accepted

Solution code:
def solve():
    A = []

    import sys
    f_i = sys.stdin
    q = f_i.readline()
    
    ans = []
    for q in f_i:
        if q[0] == '0':
            A.append(q[2:])
        elif q[0] == '1':
            ans.append(A[int(q[2:])])
        else:
            A.pop()
    print(''.join(ans), end='')

solve()

Submission status: Accepted

Solution code:
Q = int(input())
querys = [[int(x) for x in input().split()] for _ in range(Q)]
def execute_query(lst,op):
    if len(op)==2 and op[0]==0:
        lst.append(op[1])
        return lst
    if len(op)==2 and op[0]==1:
        print(lst[op[1]])
        return lst
    else:
        return lst[:-1]
       
lst=[] 
for q in querys:
    lst=execute_query(lst,q)

Submission status: Accepted

Solution code:
q = int(input())
vec = []
for i in range(q):
    a = list(map(int, input().split()))
    k = a[0]
    if k == 0:
        vec.append(a[1]) 
    if k == 1:
        print(vec[a[1]])
    if k == 2:
        vec.pop(-1)

Submission status: Accepted

Solution code:
A=[]
q=int(input())
for i in range(1,q+1):
    query=list(map(int,input().split()))
    if query[0]==0:
        A.append(query[1])
    elif query[0]==1:
        print(A[query[1]])
    elif query[0]==2:
        A.pop()

Submission status: Accepted

Solution code:
q=int(input())
query=[]
A=[]
for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        A.append(query[1])
    elif query[0]==1:
        print(A[query[1]])
    else:
        A.pop(-1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Dynamic Arrays and List - Vector
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_1_A&lang=jp

"""
import sys


class Vector:
    def __init__(self):
        self.n = 0
        self.d = dict()

    def push(self, x):
        self.d[self.n] = x
        self.n += 1

    def access(self, p):
        return self.d[p]

    def pop(self):
        self.n -= 1


def main(args):
    v = Vector()
    q = int(input())
    for _ in range(q):
        op, x = (input() + ' 1').split()[:2]
        if op == '0':
            v.push(int(x))
        elif op == '1':
            print(v.access(int(x)))
        else:
            v.pop()


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
q = int(input())
a_list = [0]*q
pos = 0
for _ in range(q):
    com, *x = map(int, input().split())
    if com == 0:
        a_list[pos] = x[0]
        pos += 1
    elif com == 1:
        print(a_list[x[0]])
    else:
        pos -= 1

Submission status: Accepted

Solution code:
import sys
q = int(input())
v = []
for _ in range(q):
    s = sys.stdin.readline()
    if s[0] == '2':
        v.pop()
    else:
        c, x = map(int, s.split())
        if c == 0:
            v.append(x)
        else:
            sys.stdout.write("{}\n".format(v[x]))

Submission status: Accepted

Solution code:
class Operation():
    def __init__(self, num_list):
        self.num_list = num_list
        
    def ope(self, queries):
        q = queries[0]
        # print(queries, self.num_list)
        if q == 0:
            self.pushBack(queries[1])
        elif q == 1:
            self.randomAccess(queries[1])
        elif q == 2:
            self.popBack()
    
    def pushBack(self, x):
        # print("pushBack")
        self.num_list.append(x)
    def randomAccess(self, p):
        # print(len(self.num_list), p + 1)
        if len(self.num_list) >= p + 1:
            print(self.num_list[p])
    def popBack(self):
        if len(self.num_list) > 0:
            self.num_list.pop(-1)
    

x = int(input())
op = Operation(list())
for i in range(x):
    op.ope(list(map(int,input().split())))

Submission status: Accepted

Solution code:
# Vector 2018/06/02
# job hunting (*_*)

class Vector(object):
    def __init__(self):
        self.A = list()

    def pushBack(self, x):
        self.A.append(x)

    def randomAccess(self, p):
        print self.A[p]

    def popBack(self):
        del self.A[-1]

A = Vector()
q = int(raw_input())
for i in range(q):
    line = [int(i) for i in raw_input().split()]
    if line[0] == 0:
        A.pushBack(line[1])
    elif line[0] == 1:
        A.randomAccess(line[1])
    else:
        A.popBack()

Submission status: Accepted

Solution code:
n = int(input())
A = []
for i in range(n):
    x = list(map(int, input().split()))
    
    if x[0] == 0:
        A.append(x[1])
    elif x[0] == 1:
        print(A[x[1]])
    elif x[0] == 2:
        del A[-1]

Submission status: Accepted

Solution code:
end = 0
ans = [0]
def pushBack(x):
    global end, ans
    ans[end] = x
    end += 1
    if end >= len(ans):
        ans.append(0)

def randomAccess(p):
    global ans
    print(ans[int(p)])

def popBack():
    global end
    end -= 1

q = int(input())
for i in range(q):
    query = list(input().split())
    if query[0] == "0":
        pushBack(query[1])
    elif query[0] == "1":
        randomAccess(query[1])
    else:
        popBack()

Submission status: Accepted

Solution code:
num = int(input())
A = []
for i in range(num):
    order = list(map(int, input().split()))
    if order[0] == 0:
        A.append(order[1])
    if order[0] == 1:
        print(A[order[1]])
    if order[0] == 2:
        del A[-1:]

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline())

que = list()

for i in range(n):
    query = sys.stdin.readline().split()
    if query[0] == '0': # push
        que.append(query[1])
    elif query[0] == '1':
        print(que[int(query[1])])
    elif query[0] == '2':
        que.pop()

Submission status: Accepted

Solution code:
q = int(input())

A = []

for _ in range(q):
    
    command, *list_num = input().split()

    if   command == "0":
        A.append(int(list_num[0]))
    elif command == "1":
        print(A[int(list_num[0])])
    elif command == "2":
        A.pop()
    else:
        raise

Submission status: Accepted

Solution code:
lst = []
for _ in range(int(input())):
    moji = input().split()
    method = moji[0]
    if len(moji) == 2:
        x = moji[1]
    if method == "0":
        lst.append(x)
    elif method == "1":
        print(lst[int(x)])
    elif method == "2":
        del lst[-1]

Submission status: Accepted

Solution code:
def vec(ap):
    input_line = input()
    x = input_line.split()
    query = [int(s) for s in x]
    if query[0] == 0:
        ap.append(query[1])
    elif query[0] == 1:
        ap_out = ap[query[1]]
        print(ap_out)
    elif query[0] == 2:
        del ap[-1]
    x = []
    s = []
    input_line = 0
    return ap

x = []
ap = []
input_num = int(input())
for a in range(input_num):
    vec(ap)

Submission status: Accepted

Solution code:
from collections import deque
box = deque()
n = int(input())
for _ in range(n):
    a, *b = map(int, input().split())
    if a == 0:
        box.append(b[0])
    elif a == 1:
        print(box[b[0]])
    else:
        box.pop()

Submission status: Accepted

Solution code:
a = []
q = int(input())
for i in range(q):
  order = list(input().split())
  if int(order[0]) == 0:
    x = int(order[1])
    a.append(x)
  if int(order[0]) == 1:
    p = int(order[1])
    print(a[p])
  if int(order[0]) == 2:
    del a[len(a)-1]

Submission status: Accepted

Solution code:
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
    a = input()
    if   a[0] == '0': Q.append(a[2:])
    elif a[0] == '1': print(Q[int(a[2:])])
    else:             Q.pop()

Submission status: Accepted

Solution code:
a=[]
q=int(input())

def pushback(a,x):
    a.append(x)
    return a

def randomaccess(a,p):
    print(a[p])

def popback(a):
    a.pop(len(a)-1)
    return a

for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        a=pushback(a,query[1])
    elif query[0]==1:
        randomaccess(a,query[1])
    else:
        a=popback(a)

Submission status: Accepted

Solution code:
A=[]
def pushBack(x):
    A.append(x)
def randomAccess(x):
    if len(A)==0:
        return
    print(A[x])
def popBack():
    if len(A)==0:
        return
    A.pop()
q=int(input())
for i in range(q):
	a=list(map(int,input().split()))
	if a[0]==0:
		pushBack(a[1])
	elif a[0]==1:
		randomAccess(a[1])
	elif a[0]==2:
		popBack()

Submission status: Accepted

Solution code:
q = int(input())
list_A = []
for q in range(q):
    query = list(input().split())
    if int(query[0]) == 0:
        list_A.append(query[1])
    elif int(query[0]) == 1:
        print(list_A[int(query[1])])
    else:
        list_A.pop(len(list_A)-1)

Submission status: Accepted

Solution code:
N= int(input())
P = []
for i in range(N):
    a, *b = (int(b) for b in input().split())
    b= b[0] if b else None
    if a == 0:
        P.append(b)
    elif a == 1:
        print(P[b])
    else:
        del P[-1]

Submission status: Accepted

Solution code:
A = [int(input())]
def pushBack(x):
	A.append(x)
def randomAccess(p):
	print(A[p+1])
def popBack():
	del A[-1]
while(1):
	try:
		a = input()
		if " " in a:
			b,c = [int(i) for i in a.split()]
			if b == 0:
				pushBack(c)
			else:
				randomAccess(c)
		else:
			popBack()
	except EOFError:
		break

Submission status: Accepted

Solution code:
#入力の取得
n = int(input())

values = []

for i in range(n):
    query = list(map(int, input().split()))
    operation = query[0]
    if operation == 0: #後ろに足す
        value = query[1]
        values.append(value)
    elif operation == 1: #表示
        position = query[1]
        print(values[position])
    else:
        values.pop(-1) #末尾を消す

Submission status: Accepted

Solution code:
q = int(input())
A = []

for i in range(q):
    Q, *x = (int(x) for x in input().split())
    x = x[0] if x else None
    if Q == 0:
        A.append(x)
    elif Q == 1:
        print(A[x])
    else:
        del A[-1]

Submission status: Accepted

Solution code:
n = int(input())

values = []
for i in range(n):
    query = list(map(int, input().split()))
    operation = query[0]
    if operation == 0:
        values.append(query[1])
    elif operation == 1:
        print(values[query[1]])
    else:
        values.pop(-1)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
    x=list(map(int, input().split()))
    if x[0]==0:a.append(x[1])
    if x[0]==1:print(a[x[1]])
    if x[0]==2:a.pop()

Submission status: Accepted

Solution code:
n = int(input())
ans = []

for i in range(n):
	lst = list(map(int,input().split()))
	if lst[0] == 0:
		ans.append(lst[1])
	elif lst[0] == 1:
		print(ans[lst[1]])
	else:
		del ans[-1]

Submission status: Accepted

Solution code:
#ITP2_1_A Vector

lists = []
n = int(input())

for i in range(n):
    query = list(map(int, input().split()))
    if(query[0] == 0):
        lists.append(query[1])
    elif(query[0] == 1):
        print(lists[query[1]])
    elif(query[0] == 2):
        lists.pop()

Submission status: Accepted

Solution code:
li=[]
for i in range(int(input())):
	req=list(map(int,input().split()))
	if req[0]==0:
		li.append(req[1])
	elif req[0]==1:
		print(li[req[1]],end='\n')
	else:
		del li[len(li)-1]

Submission status: Accepted

Solution code:
A = []

for i in range(int(input())):
    a = [int(j) for j in input().split()]
    if a[0] == 0:
        x = a[1]
        A.append(x)
    elif a[0] == 1:
        p = a[1]
        print(A[p])
    else:
        A.pop()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a = []
    anslst = []
    n = int(input())
    for i in range(n):
        l = list(map(int, input().split()))
        if l[0] == 0:
            a.append(l[1])
        elif l[0] == 1:
            anslst.append(a[l[1]])
        else:
            a.pop()
    for n in anslst:
        print(n)

Submission status: Accepted

Solution code:
import sys
nq = int(input())
lines = sys.stdin.readlines()
vector = []
for i in range(nq):
    query, *arg = lines[i].split()
    if query == '0':    # pushback
        vector.append(arg[0])
    elif query == '1':  # randaccess
        print(vector[int(arg[0])])
    elif query == '2':    # pop
        vector.pop()
    else:
        raise AssertionError

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    q=list(map(int,input().split()))
    if q[0]==0:
        l.append(q[1])
    elif q[0]==1:
        print(l[q[1]])
    else:
        del l[-1]

Submission status: Accepted

Solution code:
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_1_A&lang=jp
#  Vector

wl = []
for i in range(0,int(input())):
    l = list(map(str,input().split()))
    c = int(l[0])

    if ( c == 0 ):
        d = int(l[1])
        wl.append(d)
    elif(c == 1):
        d = int(l[1])
        print (wl[d])
    elif(c == 2):
        wl.pop()

Submission status: Accepted

Solution code:
import sys
sys.stdin.readline()
A = []
ans = []
operations = {'0': A.append, '1': lambda x: ans.append(A[int(x)]), '2': A.pop}
for query in sys.stdin:
    operations[query[0]](query[2:] if query[2:] else -1)
sys.stdout.writelines(ans)

Submission status: Accepted

Solution code:
readline = open(0).readline
writelines = open(1, 'w').writelines
Q = int(readline())
ans = []
A = []
def access(p):
    ans.append("%d\n" % A[p])


C = [A.append, access, A.pop].__getitem__
for i in range(Q):
    t, *a=map(int, readline().split())
    C(t)(*a)
writelines(ans)

Submission status: Accepted

Solution code:

def pushBack(ary, elem):
    ary.append(elem)


def randomAccess(ary, idx):
    print(ary[idx])


def popBack(ary):
    ary.pop()


def main():
    n = int(input())
    ary = []
    for i in range(n):
        query = input()
        if (query[0] == '0'):
            elem = int(query[2:])
            pushBack(ary, elem)
        elif (query[0] == '1'):
            idx = int(query[2:])
            randomAccess(ary, idx)
        elif (query[0] == '2'):
            popBack(ary)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

anslist = []
printlist = []

for i in range(n):
    query = list(map(int, input().split()))
    if query[0] == 0:
        anslist.append(query[1])
    elif query[0] == 1:
        printlist.append(anslist[query[1]])
    elif query[0] == 2:
        anslist.pop(-1)

for p in printlist:
    print(p)

Submission status: Accepted

Solution code:
n = int(input())
A = []
for i in range(n):
    query = list(map(int, input().split()))
    if query[0] == 0:
        A.append(query[1])
    elif query[0] == 1:
        print(A[query[1]])
    else:
        A.pop()

Submission status: Accepted

Solution code:
n = int(input())
A = []

for i in range(n):
    li = [int(j) for j in input().split()]
    if li[0] == 0:
        A.append(li[1])
    elif li[0] == 2:
        A.pop()
    else:
        print(A[li[1]])

Submission status: Accepted

Solution code:
n = int(input())
a = []

for i in range(n):
    d = list(map(int, input().split()))
    if d[0] == 0:
        a.append(d[1])
    elif d[0] == 1:
        print(a[d[1]])
    elif d[0] == 2:
        a.pop()

Submission status: Accepted

Solution code:
def pushBack(x):
    A.append(x)
def randomAccess(p):
    print(A[p])
def popBack():
    A.pop()
A = []
N = int(input())
for i in range(N):
    S = list(map(int,input().split(" ")))
    if S[0] == 0:
        pushBack(S[1])
    elif S[0] == 2:
        popBack()
    else:
        randomAccess(S[1])

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

stack = list()
num_tc = int(sys.stdin.readline())

for i in range(num_tc):
    query = list(map(int, sys.stdin.readline().split()))
    if query[0] == 0:   # push data
        stack.append(query[1])
    elif query[0] == 1:
        print(stack[query[1]])   # random access
    elif query[0] == 2:
        stack.pop()     # pop last element
    else:
        raise ValueError

Submission status: Accepted

Solution code:
A = []
queries = [input().split() for _ in range(int(input()))]
for query in queries:
    if query[0] == "0":
        A.append(int(query[1]))
    elif query[0] == "1":
        print(A[int(query[1])])
    elif query[0] == "2":
        A.pop()

Submission status: Accepted

Solution code:
n = int(input())
xlist = []
for i in range(n):
    order = list(map(int, input().split()))
    o = order[0] 
    if (o == 0):
        xlist.append(order[1])
    elif (o == 1):
        print(xlist[order[1]])
    elif (o == 2):
        del xlist[-1]