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

def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]

    b_list = list()
    for i, a in enumerate(a_list):
        c = i+1
        if (c%2 == 0 and n%2 == 0) or (c%2 == 1 and n%2 == 1): b_list.insert(0, a)
        else: b_list.insert(len(b_list), a)

    print(' '.join([str(i) for i in b_list]))


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]

    b_list = [-1 for i in range(512345)]
    left = 212345
    right = left+1
    for i in range(n):
        if (i+1)%2 == n%2:
            b_list[left] = a_list[i]
            left -= 1
        else:
            b_list[right] = a_list[i]
            right += 1

    print(' '.join([str(i) for i in b_list[left+1:right]]))

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

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

x = input()

for i in range(0, pow(10, 10000)):
    if "ST" in x:
        x = x.replace("ST", "")
    else:
        break

print(len(x))


### FIXED CODE ###

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

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)
### BUGGY CODE ###

def f(n, k, a_s):
    md = 10 ** 9 + 7
    dp = [[0] * (k + 1) for _ in range(n)]
    dp[0][0] = 1
    dpi = dp[0]
    for i, a in enumerate(a_s[:-1]):
        dpi1 = dp[i + 1]
        dpi1[0] = dp[i][0] % md
        for j in range(1, a + 1):
            dpi1[j] = (dpi1[j - 1] + dpi[j]) % md
        for j in range(a + 1, k + 1):
            dpi1[j] = (dpi1[j - 1] + dpi[j] - dpi[j - a - 1]) % md
        dpi = dpi1
    return sum(dp[-1][k - a_s[-1]:]) % md


n, k = map(int, input().split())
a_s = list(map(int, input().split()))
print(f(n, k, a_s))


### FIXED CODE ###

def f(n, k, a_s):
    md = 10 ** 9 + 7
    dp = [0] * (k + 1)
    dp[0] = 1
    for a in a_s[:-1]:
        ndp = [0] * (k + 1)
        ndp[0] = s = dp[0] % md
        for j in range(1, a + 1):
            ndp[j] = s = (s + dp[j]) % md
        for j in range(a + 1, k + 1):
            ndp[j] = s = (s + dp[j] - dp[j - a - 1]) % md
        dp = ndp
    return sum(dp[k - a_s[-1]:]) % md


n, k = map(int, input().split())
a_s = list(map(int, input().split()))
print(f(n, k, a_s))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
import collections

def main():
    N = int(input())
    Q = []
    for _ in range(N):
        a = list(map(int, input().split()))
        q = collections.deque()
        for i in a:
            q.append(i)
        Q.append(q)
        
    days = 0
    while True:
        gamed = [0 for _ in range(N)]
        b = False
        for i in range(len(Q)):
            if len(Q[i]) == 0 or gamed[i] != 0:
                continue
            for j in range(i+1, len(Q)):
                if len(Q[j]) == 0 or gamed[j] != 0:
                    continue
                if Q[i][0] == j+1 and Q[j][0] == i+1:
                    Q[i].popleft()
                    Q[j].popleft()
#                    print("game:", j+1, i+1, days)
                    b = True
                    gamed[i] = 1
                    gamed[j] = 1
                    break
        days += 1
        if not b:
            print(-1)
            return
        if all(len(q) == 0 for q in Q):
            break

    print(days)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input=sys.stdin.readline
from collections import deque

def main():
    N = int(input())
    Q = [deque(map(int, input().split())) for _ in range(N)]
    games = N*(N-1)//2

    days = 0
    nxt = [i for i in range(N)] # 翌日に対戦相手を更新する選手のリスト
    opp = [0]*N # 選手毎の、次の対戦相手のリスト
    while 1:
        days += 1
        for i in nxt:
            opp[i] = Q[i].popleft() - 1 if Q[i] else -1

        tmp = set() # 次の日の更新のため、試合をした選手をメモ
        for i in nxt:
            if i not in tmp and i == opp[opp[i]]:
#                print("game:", i+1, opp[i]+1, days)
                tmp.add(i)
                tmp.add(opp[i])
                games -= 1
        if games == 0:
            break
        elif not tmp:
            print(-1)
            return
        nxt = tmp
    print(days)

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

from functools import lru_cache
import sys
sys.setrecursionlimit(500000)
def input() -> str:
    return sys.stdin.readline().rstrip()
mod = 10**9 + 7
@lru_cache(maxsize=None)
def dp(i):
    if i == n - 1:
        return 1
    if i == n - 2:
        return 2 - int(n - 1 in a)
    return (dp(i + 1) * int(i + 1 not in a) % mod + dp(i + 2) * int(i + 2 not in a) % mod) % mod
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
print(dp(0))

### FIXED CODE ###

import sys
def input():
  return sys.stdin.readline().rstrip()
mod = 10**9 + 7
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
notin = [1] * n
for i in a:
  notin[i] = 0
dp = [0] * n
dp[n - 1] = 1
if n > 1:
	dp[n - 2] = 1 + notin[n - 1]
for i in range(n - 3, -1, -1):
  dp[i] += dp[i + 1] * notin[i + 1] % mod
  dp[i] += dp[i + 2] * notin[i + 2] % mod
  dp[i] %= mod
print(dp[0])
### BUGGY CODE ###

S = input()
N = len(S)
dp = [[0]*(13) for _ in range(N+1)]
dp[0][0] = 1
mod = 10**9+7
for n in range(N):
    s = S[n]
    if s!='?':
        s = int(s)*pow(10, (N-n-1), 13)%13
        for i in range(13):
            idx = (s+i)%13
            dp[n+1][idx] = dp[n][i]%mod
    else:
        for i in range(10):
            s = i*pow(10, (N-n-1), 13)%13
            for j in range(13):
                idx = (s+j)%13
                dp[n+1][idx] += dp[n][j]%mod

print(dp[-1][5]%mod)

### FIXED CODE ###

S = input()
N = len(S)
dp = [[0]*(13) for _ in range(N+1)]
dp[0][0] = 1
mod = 10**9+7
for n in range(N):
    s = S[n]
    if s!='?':
        s = int(s)*pow(10, (N-n-1), 13)%13
        for i in range(13):
            idx = (s+i)%13
            dp[n+1][idx] = dp[n][i]%mod
    else:
        for i in range(10):
            s = i*pow(10, (N-n-1), 13)%13
            for j in range(13):
                idx = (s+j)%13
                dp[n+1][idx] += dp[n][j]%mod

print(dp[-1][5]%mod)
### BUGGY CODE ###

N = int(input())
sum=0
while N!=0:
    sum=(sum+N%10)%9
    N//=10
if sum%9==0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N=list(str(input()))
sum=0
for i in range(len(N)):
    sum=(sum+int(N[i]))%9
if sum%9==0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

import math

n = int(input())
y = 0

for i in range(n):
  for j in range(n):
    for k in range(n):
      i_ = i + 1
      j_ = j + 1
      k_ = k + 1
      y_ = math.gcd(math.gcd(i_, j_), k_)
      y += y_
 
print(y)

### FIXED CODE ###

import math
import numpy as np
import numba
import math

n = int(input())

@numba.jit
def main(n):
  lis = np.zeros((n, n, n))
  for i in range(n):
    for j in range(n):
      for k in range(n):
        lis[i][j][k] = math.gcd(math.gcd(i+1, j+1), k+1)
  return int(np.sum(lis))

print(main(n))
### BUGGY CODE ###

class Dice:
    def __init__(self,ls):
        self.a = ls[1-1] # top
        self.b = ls[2-1] # front
        self.c = ls[3-1] # right
        self.d = ls[4-1] # left
        self.e = ls[5-1] # back
        self.f = ls[6-1] # bottom
    
    def E(self):
        self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
    def W(self):
        self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
    def S(self):
        self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
    def N(self):
        self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a

import random
ls = map(int,raw_input().split())
q = int(raw_input())
for i in range(q):
    dice = Dice(ls)
    a,b = map(int,raw_input().split())
    while dice.a != a or dice.b != b:
        random.choice([dice.E(), dice.W(), dice.S(), dice.N()])

    print dice.c

### FIXED CODE ###

class Dice:
    
    def __init__(self,ls):
        self.a = ls[1-1] # top
        self.b = ls[2-1] # front
        self.c = ls[3-1] # right
        self.d = ls[4-1] # left
        self.e = ls[5-1] # back
        self.f = ls[6-1] # bottom
    
    def E(self):
        self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
    def W(self):
        self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
    def S(self):
        self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
    def N(self):
        self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a   
                        
import random
ls = map(int,raw_input().split())
q = int(raw_input())
for i in range(q):
    dice = Dice(ls)
    a,b = map(int,raw_input().split())
    while dice.a != a or dice.b != b:
        i = random.choice([1,2,3,4])
        if i == 1: dice.E()
        elif i == 2: dice.W()
        elif i == 3 : dice.S()
        elif i == 4 : dice.N()
    print dice.c
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
nums = list(set(a_list))
nums.sort()
if len(nums) > 2:
	nums.pop(0)
	nums.pop(-1)
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
import copy
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
 
N, *D = mi()
S = [sys.stdin.readline()[:2] for _ in range(N)]
ans = [0]*N
 
def cv(m):
    if m == 'A':
        return 0
    if m == 'B':
        return 1
    if m == 'C':
        return 2
 
def dfs(i, D, ans):
    if D[0]<0 or D[1]<0 or D[2]<0:
        return
    if i == N:
        print('Yes')
        for m in ans:
            print(m)
        exit()
    s, t = cv(S[i][0]), cv(S[i][1])
    D_ = copy.deepcopy(D)
    ans_ = copy.deepcopy(ans)
    D[s] += 1
    D[t] -= 1
    ans[i] = S[i][0]
    dfs(i+1, D, ans)
    D_[s] -= 1
    D_[t] += 1
    ans_[i] = S[i][1]
    dfs(i+1, D_, ans_)
 
dfs(0, D, ans)
print('No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, *D = mi()
S = [sys.stdin.readline()[:2] for _ in range(N)]
ans = [0]*N

def cv(m):
    if m == 'A':
        return 0
    if m == 'B':
        return 1
    if m == 'C':
        return 2

def dfs(i, A, B, C, ans):
    if A<0 or B<0 or C<0:
        return
    if i == N:
        print('Yes')
        for m in ans:
            print(m)
        exit()
    #s, t = cv(S[i][0]), cv(S[i][1])
    '''
    D[s] += 1
    D[t] -= 1
    ans[i] = S[i][0]
    dfs(i+1, D, ans)
    D_[s] -= 1
    D_[t] += 1
    ans_[i] = S[i][1]
    dfs(i+1, D_, ans_)
    '''
    if S[i] == 'AB':
        ans[i] = 'A'
        dfs(i+1, A+1, B-1, C, ans)
        ans[i] = 'B'
        dfs(i+1, A-1, B+1, C, ans)
    if S[i] == 'BC':
        ans[i] = 'B'
        dfs(i+1, A, B+1, C-1, ans)
        ans[i] = 'C'
        dfs(i+1, A, B-1, C+1, ans)
    if S[i] == 'AC':
        ans[i] = 'A'
        dfs(i+1, A+1, B, C-1, ans)
        ans[i] = 'C'
        dfs(i+1, A-1, B, C+1, ans)

dfs(0, D[0], D[1], D[2], ans)
print('No')
### BUGGY CODE ###


import itertools

K,S = map(int, input().split())
X = list(range(K+1))
count=0

for x,y,z in list(itertools.product(X, X, X)):
    if x+y+z == S:
        count+=1

print(count)

### FIXED CODE ###

k,s = map(int, input().split())
cnt = 0

for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-(x+y) <= k:
            cnt += 1




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

#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
for i in range(N):
    B=A[::]
    del B[i]
    kari=gcdlist(B)
    MAX=max(MAX,kari)
if N == 2:
    MA=max(A)
    g=gcd(A[0],A[1])
    MAX=max(MA,g)
print(MAX)
    


### FIXED CODE ###

#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
gcdf=[]
for i in range(N):
    if i == 0:
        gcdf.append(A[i])
    else:
        gcdf.append(gcd(A[i],gcdf[-1]))
gcdb=[]
for i in range(N):
    if i == 0:
        gcdb.append(A[-1])
    else:
        gcdb.append(gcd(A[-1-i],gcdb[-1]))
MAX=0
gcdb=gcdb[::-1]
for i in range(N):
    if i == 0:
        kari=gcdb[1]
    elif i == N-1:
        kari=gcdf[-2]
    else:
        f=gcdf[i-1]
        b=gcdb[i+1]
        kari=gcd(f,b)
    MAX=max(kari,MAX)
print(MAX)
### BUGGY CODE ###

def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

N, K = MI()
A = LI()
score = 1

for i in range(K):
    score *= A[i]

idx = 0
for i in range(K, N):
    tmp = score
    score = score * A[i] // A[idx]
    print("Yes" if score > tmp else "No")
    idx += 1

### FIXED CODE ###

def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

N, K = MI()
A = LI()

idx = 0
for i in range(K, N):
    print("Yes" if A[i] > A[idx] else "No")
    idx += 1
### BUGGY CODE ###

import sys
import pdb
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,Q = map(int, input().split())
    S = input().rstrip()
    ans = [0]*Q
    for q in range(Q):
        l,r = map(int, input().split())
        l -= 1
        r -= 1
        qua = (r+l)//4
        mid1 = qua+1
        mid2 = qua*2+1
        mid3 = qua*3+1
        cnt = 0
        for i in range(l,mid1):
            if S[i:i+2] == 'AC': cnt += 1
        for i in range(mid1,mid2):
            if S[i:i+2] == 'AC': cnt += 1
        for i in range(mid2,mid3):
            if S[i:i+2] == 'AC': cnt += 1
        for i in range(mid3,r):
            if S[i:i+2] == 'AC': cnt += 1
        print(cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import pdb
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,Q = map(int, input().split())
    S = input().rstrip()
    dp = [0]*(N+1)
    for i in range(1,N):
        if S[i-1:i+1] == 'AC':
            dp[i+1] = dp[i]+1
        else:
            dp[i+1] = dp[i]
    for _ in range(Q):
        l,r = map(int, input().split())
        print(dp[r]-dp[l])

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

# encoding: "utf-8"

class Unreachable(Exception):
    pass

def main():
    n, q = [int(x) for x in input().split()]
    setlist = list()
    for i in range(n):
        setlist.append({i})

    for _ in range(q):
        run(setlist)


def run(setlist):
    com, x, y = [int(x) for x in input().split()]
    if com == 0:
        # unite
        new_set = setlist[x] | setlist[y]
        for i in new_set:
            setlist[i] = new_set

    elif com == 1:
        # same
        if y in setlist[x]:
            print(1)
        else:
            print(0)
    else:
        raise Unreachable

if __name__ == "__main__":
    main()

### FIXED CODE ###

# encoding: "utf-8"

from enum import Enum

class Unreachable(Exception):
    pass


class Type(Enum):
    VAL = 0
    PTR = 1


class Elem:
    def __init__(self, i, value, _type):
        self.idx = i
        self.value = value
        self.type = _type

    def set(self, value, _type):
        self.value = value
        self.type = _type
        

class SetManager:
    def __init__(self, n):
        self.data = list()
        for i in range(n):
            self.data.append(Elem(i, {i}, Type.VAL))

    def get(self, i):
        return self.data[i]

    def set(self, i, value):
        if isinstance(value, set):
            t = Type.VAL
        elif isinstance(value, int):
            t = Type.PTR
        self.data[i].set(value, t)

    def find_root(self, i):
        elem = self.get(i)
        if elem.type == Type.VAL:
            return (i, elem)
        elif elem.type == Type.PTR:
            j, root_elem = self.find_root(elem.value)
            self.set(i, j)
            return (j, root_elem)
        else:
            raise Unreachable

    def run(self, command):
        com, x, y = command
        if com == 0:
            self.unite(x, y)

        elif com == 1:
            if self.same(x, y):
                print(1)
            else:
                print(0)

        else:
            raise Unreachable

    def unite(self, x, y):
        i, elem_x = self.find_root(x)
        j, elem_y = self.find_root(y)
        if i != j:
            new_set = elem_x.value | elem_y.value
            self.set(i, new_set)
            self.set(j, i)

    def same(self, x, y):
        return y in self.find_root(x)[1].value


class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, n, converter):
        assert(n == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def main():
    n, q = Stdin.read_line(int)
    manager = SetManager(n)
    commands = Stdin.read_lines(q, int)
    
    for command in commands:
        manager.run(command)


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

S = list(map(int,list(input())))

MOD = 2019
S.reverse()
cnt = 0
temp = 0
ans = [0]*2019
for i in S:
    temp += i*10**cnt % MOD
    temp %= MOD
    ans[temp] += 1
    cnt += 1

ans[0] += 1

ans2 = 0
for i in ans:
    ans2 += i*(i-1)//2
print(ans2)

### FIXED CODE ###

S = list(input())

MOD = 2019
S.reverse()
cnt = 1
temp = 0
ans = [0]*2019
for i in S:
    temp += int(i)*cnt % MOD
    temp %= MOD
    ans[temp] += 1
    cnt *= 10
    cnt %= MOD

ans[0] += 1

ans2 = 0
for i in ans:
    ans2 += i*(i-1)//2
print(ans2)
### BUGGY CODE ###

import sys
n,m=map(int,input().split())
s=input()
t=input()

def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

def lcm(a, b):

	return a * b // gcd (a, b)


l=(lcm(n,m))

a=["A" for i in range(l)]

for i in range(n):
    a[int(l/n)*i]=s[i]

for i in range(m):
    if a[int(l/m)*i]!="A" and a[int(l/m)*i]!=t[i]:
        print(-1)
        sys.exit()
    
print(l)


### FIXED CODE ###

n,m=map(int,input().split())
s=input()
t=input()

#最大公約数
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

#最小公倍数
def lcm(x,y):
    return x*y//gcd(x,y)

l=lcm(n,m)

a=l//n
b=l//m
ln=[]
lm=[]
i=0
while i<n:
    ln.append(i)
    i+=b
i=0
while i<m:
    lm.append(i)
    i+=a

p=0
for i in range(len(ln)):
    if s[ln[i]]!=t[lm[i]]:
        p=1
if p==0:
    print(l)
else:
    print(-1)
### BUGGY CODE ###

# coding: utf-8
from sys import stdin


def main():
    # コンソール入力を受け取る
    N = int(stdin.readline().rstrip())
    P = stdin.readline().rstrip().split()
    P = [int(i) for i in P]

    ans = 0
    for i in range(N):
        for j in range(i+1):
            if P[i] > P[j]:
                break
            if i == j:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding: utf-8
from sys import stdin


def main():
    # コンソール入力を受け取る
    N = int(stdin.readline().rstrip())
    P = stdin.readline().rstrip().split()
    P = [int(i) for i in P]

    ans = 1
    min = P[0]
    for i in range(N-1):
        if P[i+1] < min:
            ans += 1
            min = P[i+1]
    print(ans)


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

from collections import Counter

n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
    b, c = input().split()
    B.append(int(b))
    C.append(int(c))


my_dict = Counter(A)

def cals_sum(my_dict):
    values = [ my_dict[key]*key for key in my_dict.keys() if my_dict[key] != 0]
    #for key in my_dict.keys():
    #    value = my_dict[key]
    #    sum += int(key) * int(value)
    return sum(values)

for i in range(len(B)):
    b = B[i]
    c = C[i]
    tmpb = my_dict[b] 
    my_dict[b] = 0
    tmpc = my_dict[c]
    my_dict[c] = tmpb + tmpc

    print(cals_sum(my_dict))




### FIXED CODE ###

from collections import Counter

n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
    b, c = input().split()
    B.append(int(b))
    C.append(int(c))


my_dict = Counter(A)

def cals_sum(my_dict):
    values = [ my_dict[key]*key for key in my_dict.keys() if my_dict[key] != 0]
    #for key in my_dict.keys():
    #    value = my_dict[key]
    #    sum += int(key) * int(value)
    return sum(values)
  
my_sum = cals_sum(my_dict)

for i in range(len(B)):
    b = B[i]
    c = C[i]
    tmpb = my_dict[b] 
    my_dict[b] = 0
    tmpc = my_dict[c]
    my_dict[c] = tmpb + tmpc
    
    my_sum += ((tmpb)*c - tmpb*b)

    print(my_sum)
### BUGGY CODE ###

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

a, b, c, d = map(int, input().split())

g = 0

while 0 == d:
    d = d - a * d
    if a - d >= 0:
        g += d
        d = 0

b > 0

for i in range(d):
    if a > 0:
        g += 1
        a -= 1
        continue
    if b > 0:
        b -= 1
        continue
    if c > 0:
        g -= 1
        c -= 1
        continue

print(str(g))


### FIXED CODE ###

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

import sys

a, b, c, d = map(int, input().split())

g = 0
gc = d

if d - a > 0 and a > 0:
    g += a
    d -= a
elif a > 0:
    g += d
    print(str(g))
    sys.exit()

if d - b > 0 and b > 0:
    d -= b
elif b > 0:
    print(str(g))
    sys.exit()

if d == c and c > 0:
    g -= d
elif c > 0:
    g -= d

print(str(g))