Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################


R, G, B, N = input_ints()

cnt = 0
for r in range(N // R + 1):
    for g in range(N // G + 1):
        rest = N - r * R - g * G
        if rest >= 0 and rest % B == 0:
            cnt += 1

print(cnt)


### FIXED CODE ###

#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################


R, G, B, N = input_ints()

cnt = 0
for r in range(N // R + 1):
    for g in range(N // G + 1):
        rest = N - r * R - g * G
        if rest < 0:
            break
        if rest % B == 0:
            cnt += 1

print(cnt)
### BUGGY CODE ###

from sys import stderr
from functools import reduce
from operator import add
def f(): [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()',")+'\n')

n = int(input())
s = list(input())

longest = {"E":(0,1),"W":(0,1)}
# index,num of people who is E

i = 0
state = ""
po = 0
while i < n:
    debug(i)
    if po == 0:
        debug("po==0")
        po += 1
        state = s[i]
        i += 1
    else:
        if s[i] == state:
            debug(state,"po increased")
            po += 1
            i += 1
        else:
            debug("po changed")
            if longest[state][1] <= po:
                if state == "E":
                    longest[state] = (i-1, po)
                else:
                    longest[state] = (i-po-1,po)
            po = 0
            i += 1

debug(longest)
if longest["E"][1] < longest["W"][1]:
    leader = longest["W"][0]
else:
    leader = longest["E"][0]

ans = 0
debug(leader,s)
for i in range(leader):
    if s[i] == "W":
        debug(i)
        ans += 1
for i in range(leader+1,n):
    if s[i] == "E":
        debug(i)
        ans += 1

print(ans)

### FIXED CODE ###

from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

n = int(input())
s = list(input())

must = [0 for i in range(n)]
# 一番左の人の値を決める
for i in range(1,n):
    if s[i] == "E":
        must[0] += 1
# 2番目以降の人
for j in range(1,n):
    must[j] = must[j-1]
    if s[j-1] == "W":
        must[j] += 1
    if s[j] == "E":
        must[j] -= 1
print(min(must))
### BUGGY CODE ###

def we_love_abc(S: str)->int:
    ABC = 'ABC'

    dp = [0, 0, 0, 0]
    dp[3] = 1

    for c in reversed(S):
        if c == '?':
            m, m1 = 3, 3
        else:
            m, m1 = 1, 1

        for j in range(3):
            # m1 = 3 if c == '?' else 1
            m2 = 1 if c == '?' or c == ABC[j] else 0
            dp[j] = m1 * dp[j] + m2 * dp[j+1]
        # dp[3] = (3 if c == '?' else 1) * dp[3]
        dp[3] = m * dp[3]

    return dp[0] % 1000000007


if __name__ == "__main__":
    S = input()
    ans = we_love_abc(S)
    print(ans)


### FIXED CODE ###

def we_love_abc(S: str)->int:
    ABC = 'ABC'
    MOD = 1000000007

    dp = [0, 0, 0, 0]
    dp[3] = 1

    for c in reversed(S):
        for j in range(3):
            m1 = 3 if c == '?' else 1
            m2 = 1 if c == '?' or c == ABC[j] else 0
            dp[j] = (m1 * dp[j] + m2 * dp[j+1]) % MOD
        dp[3] = (3 if c == '?' else 1) * dp[3]
        dp[3] %= MOD

    return dp[0] % MOD


if __name__ == "__main__":
    S = input()
    ans = we_love_abc(S)
    print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
num=m//n

ma=[]
for i in range(1,num+1):
    if m%i==0:
        ma.append(i)
ma=sorted(ma,reverse=True)
print(ma[0])

### FIXED CODE ###

n,m=map(int,input().split())
num=m//n

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors
make=make_divisors(m)
make.sort()
import bisect
ans=bisect.bisect_right(make,num)
print(make[ans-1])
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline
  
  N = int(input())
  E = [[] for _ in range(N)]
  for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    E[a].append((b,i))
    E[b].append((a,i))
  
  EG = []
  def dfs(u,v,p):
    if u == v:
      return True
    for t,i in E[u]:
      if t == p:
        continue
      if dfs(t,v,u):
        EG.append(i)
        return True
    return False
  
  M = int(input())
  EM = []
  for i in range(M):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    EM.append((u,v))
  
  ans = 0
  for i in range(1<<M):
    EG2 = []
    bc = 0
    for j in range(M):
      if (i>>j)&1 == 1:
        bc += 1
        u,v = EM[j]
        EG = []
        dfs(u,v,-1)
        EG2 += EG
    p = len(set(EG2))
    if bc%2 == 0:
      ans += 2**(N-1-p)
    else:
      ans -= 2**(N-1-p)
  print(ans)

if __name__ == '__main__':
  main()


### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  
  N = int(input())
  E = [[] for _ in range(N)]
  for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    E[a].append((b,i))
    E[b].append((a,i))
  
  EG = []
  def dfs(u,v,p):
    if u == v:
      return True
    for t,i in E[u]:
      if t == p:
        continue
      if dfs(t,v,u):
        EG.append(i)
        return True
    return False
  
  M = int(input())
  EM = []
  for i in range(M):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    EM.append((u,v))
  
  ES = []
  for i in range(M):
    u,v = EM[i]
    EG = []
    dfs(u,v,-1)
    ES.append((u,v,EG))
  
  ans = 0
  for i in range(1<<M):
    EG2 = []
    bc = 0
    for j in range(M):
      if (i>>j)&1 == 1:
        bc += 1
        EG2 += ES[j][2]
    p = len(set(EG2))
    if bc%2 == 0:
      ans += 2**(N-1-p)
    else:
      ans -= 2**(N-1-p)
  print(ans)

if __name__ == '__main__':
  main()
### BUGGY CODE ###

n = int(input())
a_list = list(map(int,input().split(" ")))
mul = 1
for i in range(n):
    mul *= a_list[i]
if mul > 10**18:
    print(-1)
else:
    print(mul)

### FIXED CODE ###

n = int(input())
a_list = list(map(int,input().split(" ")))
mul = 1
if 0 in a_list:
    print(0)
else:
    for i in range(n):
        if mul > 10**18:
            break
        else:
            mul *= a_list[i]
    if mul <= 10**18:
        print(mul)
    else:
        print(-1)
### BUGGY CODE ###

alphabet = ["aa","bb","cc","dd","ee","ff","gg","hh","ii","jj","kk","ll","mm","nn","oo","pp","qq","rr","ss","tt","uu","vv","ww","xx","yy","zz"]
alphabet2 = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
N = int(input())
S = input()
import math
for k in range(math.ceil(N/2)):
  for i in alphabet:
    if i in S:
      x = alphabet.index(i)
      S = S.replace(i, alphabet2[x])
print(len(S))

### FIXED CODE ###

N = int(input())
S = list(input())
A = [0] * N
same = False
import math
for i in range(1, N):
  if S[i] == S[i-1]:
    same = True
  elif same and S[i] != S[i-1]:
    A[i] = 1
    same = False
  else:
    same = False
    A[i] = 1
    
print(sum(A)+1)
### BUGGY CODE ###

N, Q = map(int,input().split())
S = input()
L = []

for i in range(Q):

    L = (list(map(int,input().split())))
    M = S[L[0]-1:L[1]]
    print(M.count('AC'))

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N,Q = map(int,input().split())
S = input()
A = []
L = []

for i  in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        A.append(i)
        
for i in range(Q):
    L=list(map(int,input().split()))
    minA=bisect_left(A,L[0]-1)
    maxA=bisect_left(A,L[1]-1)
    print(maxA-minA)
### BUGGY CODE ###

N, M = map(int, input().split(" "))
stores = []
can_buy = False
for i in range(N):
    Ai, Bi = map(int, input().split(" "))
    if can_buy and Ai >= stores[-1][0]:
        continue
    stock = 0
    last_idx = -1
    tg_idx = -1
    for idx, s in enumerate(stores):
        if s[0] > Ai and tg_idx == -1:
            stock += Bi
            tg_idx = idx
        if stock < M:
            stock += s[1]
        else:
            last_idx = idx
            can_buy = True
            break
    if tg_idx != -1:
        stores.insert(tg_idx, (Ai, Bi))
    else:
        stores.append((Ai, Bi))
    if last_idx != -1:
        stores = stores[:last_idx+1]

price = 0
for store in stores:
    if M <= store[1]:
        price += store[0] * M
        break
    else:
        price += store[0] * store[1]
        M -= store[1]
print(price)


### FIXED CODE ###

N, M = map(int, input().split(" "))
stores = []

for i in range(N):
    Ai, Bi = map(int, input().split(" "))
    stores.append((Ai, Bi))    

price = 0
for a, b in sorted(stores, key=lambda x: x[0]):
    if M <= b:
        price += a * M
        break
    else:
        price += a * b
        M -= b
print(price)
### BUGGY CODE ###

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N = int(input())

A = []
for i in range(N):
	A.append(int(input()))

B = [0]*N
num = 0
color = 0
while True:
	value = -1
	for i in range(N):
		if B[i] == 0 and value < A[i]:
			value = A[i]
			B[i] = 1
			num += 1

	color += 1
	if num == N:
		break
print(color)

### FIXED CODE ###


import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N = int(input())
A = []
for i in range(N):
	A.append(int(input()))

B = []
min = -10000000000
for i in range(N):
	loc = bisect.bisect_right(B, -A[i])
	if loc == len(B):
		B.append(-A[i])
	else:
		B[loc] = -A[i]

print(len(B))
### BUGGY CODE ###

def acinput():
    return list(map(int, input().split(" ")))


import numpy as np

N,K=acinput()
p=np.array(acinput())


res=0

for i in range(N-K+1):
    tmp = (p[i:(i+K)]+1)/2
    res = max(res, np.sum(tmp))


print(res)


### FIXED CODE ###

def acinput():
    return list(map(int, input().split(" ")))


import numpy as np

N,K=acinput()
p=np.array(acinput())

pp=(p+1)/2

pp=np.insert(pp,0,0)
p_cs=np.cumsum(pp)

res=0

for i in range(K,N+1):
    res=max(res,(p_cs[i]-p_cs[i-K]))
    #tmp = (p[i:(i+K)]+1)/2
    #res = max(res, np.sum(tmp))


print(res)
### BUGGY CODE ###

from functools import lru_cache

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7

# ans = power(2, n, MOD) - 1 - (power(2, a, MOD) - power(2, a - 1, MOD)) - (power(2, b, MOD) - power(2, b - 1, MOD))
ans = power(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)
# - comb(2, a, MOD) - comb(2, b, MOD)

print(ans % MOD)

### FIXED CODE ###

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n,k,mod):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%mod
    for i in range(2,k+1):
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        ans=ans*(n-k+i)*inv[i]%mod
    return ans

n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7

ans = power(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)

print(ans % MOD)
### BUGGY CODE ###

X,Y,Z,K=[int(s) for s in input().split()]
xls=[int(s) for s in input().split()]
yls=[int(s) for s in input().split()]
zls=[int(s) for s in input().split()]
xyls=[]
for x in xls:
  for y in yls:
    xyls.append(x+y)
xyls=sorted(xyls,reverse=True)
M=max([X*Y,K])
cake=[]
for xy in xyls[:M]:
  for z in zls:
    cake.append(xy+z)
cake=sorted(cake,reverse=True)
for i in range(K):
  print(cake[i])

### FIXED CODE ###

X,Y,Z,K=[int(s) for s in input().split()]
xls=sorted([int(s) for s in input().split()],reverse=True)
yls=sorted([int(s) for s in input().split()],reverse=True)
zls=sorted([int(s) for s in input().split()],reverse=True)
xyls=[]
for x in xls[:K]:
  for y in yls[:K]:
    xyls.append(x+y)
xyls=sorted(xyls,reverse=True)
cake=[]
for xy in xyls[:K]:
  for z in zls[:K]:
    cake.append(xy+z)
cake=sorted(cake,reverse=True)
for i in range(K):
  print(cake[i])
### BUGGY CODE ###

N, Q = [ int(x) for x in input().split() ]
S = input()
lr = []
for i in range(Q):
    lr.append([ int(x) for x in input().split() ])

aclist = []
target = 'AC'
index = -1
while True:
    index = S.find(target, index + 1)
    if index == -1:
        break
    aclist.append(index+1)

for i in range(Q):
    matched = [ x for x in aclist if x >= lr[i][0] and x+1 <= lr[i][1] ]
    print(len(matched))


### FIXED CODE ###

import bisect

N, Q = [int(x) for x in input().split()]
S = input()
lr = []
for i in range(Q):
    lr.append([int(x)-1 for x in input().split()])

aclist = []
target = "AC"
index = -1
while True:
    index = S.find(target, index + 1)
    if index == -1:
        break
    aclist.append(index)

for [l, r] in lr:
    min_ac = bisect.bisect_left(aclist, l)
    max_ac = bisect.bisect_right(aclist, r-1)
    print(max_ac - min_ac)
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N, M, K, A, B):
    na = 0
    A = [0] + A
    for i in range(1, len(A)):
        A[i] += A[i - 1]
        if A[i] > K:
            break
        na += 1
    nb = 0
    B = [0] + B
    for i in range(1, len(B)):
        B[i] += B[i - 1]
        if B[i] > K:
            break
        nb += 1
    i = 0
    while True:
        for j in range(max(na - i, 0), na + 1):
            if na + nb - i - j >= 0 and na + nb - i - j <= nb and A[j] + B[na + nb - i - j] <= K:
                return na + nb - i
        i += 1


(N, M, K) = tuple([int(s) for s in input().split()])
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
print(calc(N,M,K,A,B))

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N, M, K, A, B):
    na = 0
    A = [0] + A
    for i in range(1, len(A)):
        A[i] += A[i - 1]
        if A[i] > K:
            break
        na += 1
    nb = 0
    B = [0] + B
    for i in range(1, len(B)):
        B[i] += B[i - 1]
        if B[i] > K:
            break
        nb += 1
    ans = nb
    t = nb
    for i in range(1, na + 1):
        for j in range(t, -1, -1):
            if A[i] + B[j] <= K:
                ans = max(ans, i + j)
                t = j
                break
    return ans


(N, M, K) = tuple([int(s) for s in input().split()])
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
print(calc(N,M,K,A,B))
### BUGGY CODE ###

def main():
  from sys import setrecursionlimit
  setrecursionlimit(100000)

  N = int(input())
  ab = [list(map(int, input().split())) for _ in range(N - 1)]

  nodes = [[] for _ in range(N)]
  for a, b in ab:
    nodes[a-1].append(b-1)
    nodes[b-1].append(a-1)

  used = [set() for _ in range(N)]
  K = max(len(nodes[i]) for i in range(N))
  print(K)

  colors = [[-1] * N for _ in range(N)]

  def f(node, out, p, nodes, colors):
    cn = 1
    for n in nodes[node]:
      if n == p:
        continue
      if cn == out:
        cn += 1
      colors[node][n] = cn
      colors[n][node] = cn
      f(n, cn, node, nodes, colors)
      cn += 1

  f(0, -1, -1, nodes, colors)

  for a, b in ab:
    print(colors[a-1][b-1])
main()


### FIXED CODE ###

from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])
### BUGGY CODE ###

N = int(input())
S = input().strip()
cnt = 0
for k in range(N//2,0,-1):
    A = []
    for i in range(N-k+1):
        A.append((S[i:i+k],i))
    A = sorted(A,key=lambda x:x[0])
    cur = 0
    for i in range(1,N-k+1):
        if A[i][0]!=A[i-1][0]:
            cur = i
        else:
            if A[i][1]-A[cur][1]>=k:
                cnt = k
                break
            else:
                continue
    if A[N-k][1]-A[cur][1]>=k:
        cnt = k
    if cnt>0:break
print(cnt)

### FIXED CODE ###

N = int(input())
S = input().strip()
cmax = 0
for k in range(1,N):
    X = S[:N-k]
    Y = S[k:]
    cur = 0
    cnt = 0
    for i in range(N-k):
        if X[i]!=Y[i]:
            cmax = max(cmax,min(cnt,k))
            cur = i
            cnt = 0
        else:
            cnt += 1
    cmax = max(cmax,min(cnt,k))
print(cmax)
### BUGGY CODE ###

from collections import deque
"""
01-BFS
"""

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1; cw-=1; dh-=1; dw-=1
area = [list(input()) for _ in range(h)]
inf = 10**100
dist = [[inf]*w for i in range(h)]
dwalk = [(0, 1), (0, -1), (1, 0), (-1, 0)]

q = deque([(ch, cw)])
dist[ch][cw] = 0
while q:
    y, x = q.popleft()
    for dy, dx in dwalk:
        py = y+dy; px = x+dx
        if not 0<=py<h: continue
        if not 0<=px<w: continue
        if area[py][px]=='#': continue
        if dist[py][px]>dist[y][x]:
            dist[py][px] = dist[y][x]
            q.appendleft((py, px))
    for dy in range(-2, 3):
        for dx in range(-2, 3):
            py = y+dy; px = x+dx
            if not 0<=py<h: continue
            if not 0<=px<w: continue
            if area[py][px]=='#': continue
            if dist[py][px]>dist[y][x]+1:
                dist[py][px] = dist[y][x]+1
                q.append((py, px))

if dist[dh][dw] == inf:
    print(-1)
else:
    print(dist[dh][dw])

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1; cw-=1; dh-=1; dw-=1
area = [list(input()) for _ in range(h)]
inf = 10**100
dist = [[inf]*w for i in range(h)]

dwalk = [(0, 1), (0, -1), (1, 0), (-1, 0)]

def Dijkstra(ch, cw):
    import heapq
    edgelist = [(0, ch, cw)]
    heapq.heapify(edgelist)
    dist[ch][cw] = 0
    while len(edgelist):
        cost, y, x = heapq.heappop(edgelist)
        if y==dh and x==dw:
            return dist
        if dist[y][x] < cost: continue
        for next_y, next_x in dwalk:
            if 0<=y+next_y<h and 0<=x+next_x<w:
                if area[y+next_y][x+next_x]=='#': continue
                if dist[y+next_y][x+next_x]>cost:
                    dist[y+next_y][x+next_x] = cost
                    heapq.heappush(edgelist, (cost, y+next_y, x+next_x))
        for next_y in range(-2, 3):
            for next_x in range(-2, 3):
                    if 0<=y+next_y<h and 0<=x+next_x<w:
                        if area[y+next_y][x+next_x]=='#': continue
                        if dist[y+next_y][x+next_x]>cost+1:
                            dist[y+next_y][x+next_x] = cost+1
                            heapq.heappush(edgelist, (cost+1, y+next_y, x+next_x))
    return dist

dist = Dijkstra(ch, cw)
if dist[dh][dw] == inf:
    print(-1)
else:
    print(dist[dh][dw])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))

ans = []

for i,x in enumerate(a):
    if i%2 == (n-1)%2:
        ans.insert(0,x)
    else:
        ans.append(x)

print(*ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

farm=[]
latt=[]

for i,x in enumerate(a):
    if i%2 == (n-1)%2:
        farm.append(x)
    else:
        latt.append(x)
farm.reverse()
ans = farm + latt

print(*ans)
### BUGGY CODE ###

n = int(input())
item = []
for x in range(n):
    item.append(input())
    x = set(item)
    y = list(x)
print(len(y))    


### FIXED CODE ###

N = int(input())
ls = []
for x in range(N):
    ls.append(input())
print(len(set(ls)))
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()

def counter(L, R):
    c = 0
    for i in range(L, R):
        if s[i:i + 2] == "AC":
            c += 1
    return c

for i in range(q):
    l, r = map(int, input().split())
    print(counter(l - 1, r - 1))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
t = [0] * n
for i in range(1, n):
    t[i] = t[i - 1] + (1 if s[i - 1:i + 1] == "AC" else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
### BUGGY CODE ###

N, M, Q = map(int, input().split())
train = [[0 for _ in range(N + 1)]for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    train[L][R] += 1
# print(train)

cumsum = [[0 for _ in range(N + 1)]for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, N + 1):
        cumsum[i][j] = cumsum[i][j - 1] + train[i][j]
# print(cumsum)

for _ in range(Q):
    p, q = map(int, input().split())
    tmp = 0
    for i in range(p, q + 1):
        tmp += cumsum[i][q] - cumsum[i][p - 1]
    print(tmp)


### FIXED CODE ###

N, M, Q = map(int, input().split())
train = [[0 for _ in range(N + 1)]for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    train[L][R] += 1
# print(train)

cumsum = [[0 for _ in range(N + 1)]for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, N + 1):
        cumsum[i][j] = cumsum[i][j - 1] + train[i][j]
# print(cumsum)

for _ in range(Q):
    p, q = map(int, input().split())
    tmp = 0
    for i in range(p, q + 1):
        tmp += cumsum[i][q] - cumsum[i][p - 1]
    print(tmp)