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

import copy, math

n = int(input())
a = input().split()

result = []

num_dict = {}

for x in set(a):
    num_dict[x] = a.count(x)

def calc(x):
    if x >= 2:
        return math.factorial(x) / (math.factorial(x - 2) * 2)
    else:
        return 0

result_dict = {}
result_minus1_dict = {}

for x in set(a):
    result_dict[x] = calc(num_dict[x])
    result_minus1_dict[x] = calc(num_dict[x] - 1)

for i in range(len(a)):
    result = 0

    for key, value in result_dict.items():
        if key == a[i]:
            result += result_minus1_dict[a[i]]
        else:
            result += value

    print(int(result))


### FIXED CODE ###

#%%
import copy, math, collections

n = int(input())
a = input().split()

result = []

num_dict = dict(collections.Counter(a))

def calc(x):
    if x >= 2:
        return math.factorial(x) / (math.factorial(x - 2) * 2)
    else:
        return 0

result_dict = {}
result_minus1_dict = {}

for key, value in num_dict.items():
    result_dict[key] = calc(num_dict[key])
    result_minus1_dict[key] = calc(num_dict[key] - 1)

result_all = sum(result_dict.values())

for i in range(len(a)):
    print(int(result_all - result_dict[a[i]] + result_minus1_dict[a[i]]))

# %%
### BUGGY CODE ###

n = int(input())

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

for i in range(1, n+1):
    print(a.count(i))

### FIXED CODE ###

n = int(input())

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

men = {}

for i in range(1, n+1):
    men[i] = 0

for i in a:
    men[i] += 1

for i in range(1, n+1):
    print(men[i])
### BUGGY CODE ###

def mod_power(a, f_power):
    """
    a の p 乗を求めるアルゴリズム
    計算量はO(log(f_power))
    """
    if f_power == 0:
        return 1
    if f_power % 2 == 0:
        half = mod_power(a, f_power / 2)
        # half : a ** (power /2) の 2乗で a ** power を求める
        return half * half % MOD
    else:
        return a * mod_power(a, f_power - 1) % MOD


def comb(a, b):
    if b > a - b:
        return comb(a, a - b)
    # res = 1
    mul = 1
    div = 1
    for i in range(b):
        # res *= (a - i)
        # res /= (i + 1)
        mul *= (a - i)
        mul %= MOD

        div *= (i + 1)
        div %= MOD
    res = mul * mod_power(div, MOD - 2) % MOD
    return res


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

MOD = 10 ** 9 + 7

ans = 1
i = 2
left = m + 0
while True:
    if (i * i > m) and (left == 1):
        break
    power = 0
    while left % i == 0:
        left /= i
        power += 1
    if power > 0:
        ans *= comb(n - 1 + power, power)
    i += 1

ans %= MOD

print(ans)

### FIXED CODE ###

MOD = 10 ** 9 + 7


def prime_factorization(n):
    i = 2
    res = []
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            n /= i
            cnt += 1
        if cnt > 0:
            res.append(cnt)
        i += 1
    if n > 1:
        res.append(1)
    return res


def comb(a, b):
    b = min(b, a - b)
    if b < 0:
        return 0
    elif b == 0:
        return 1
    elif b == 1:
        return a
    else:
        return (a % MOD) * pow(b, MOD - 2, MOD) % MOD * comb(a - 1, b - 1) % MOD


N, M = map(int, input().split())

ans = 1
for power in prime_factorization(M):
    ans *= comb(N - 1 + power, power)
    ans %= MOD

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

def solve(n, m, a, c, b):
    list1 = a
    for i in range(m):
        list1 += [c[i] for _ in range(b[i])]
    list1.sort(reverse=True)
    return sum(list1[:n])

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
c = []
for _ in range(m):
    d = list(map(int, input().split()))
    b += [d[0]]
    c += [d[1]]
print(solve(n, m, a, c, b))

### FIXED CODE ###

def solve(n, m, a, d):
    a.sort(reverse=True)
    d.sort(key = lambda x:(x[1]), reverse=True)
    list1 = []
    index = 0
    for i in range(m):
        list1 += [d[i][1] for _ in range(min(d[i][0], n-index))]
        index += d[i][0]
        if index >= n:
            break
    if len(list1) < n:
        list1 += [0 for _ in range(n-index)]
    for i in range(n):
        if a[i] > list1[n-1-i]:
            list1[n-1-i] = a[i]
        else:
            break
    return sum(list1)

n, m = map(int, input().split())
a = list(map(int, input().split()))
d = []
for _ in range(m):
    d += [list(map(int, input().split()))]
print(solve(n, m, a, d))
### BUGGY CODE ###

def rev(s):
    new_s = list(reversed(s))
    return new_s

S = list(input())
N = int(input())
for _ in range(N):
    Q = input()
    if Q.isdigit():
        #反転
        S = rev(S)
    else:
        q = Q.split()
        if q[1]=="1":
            S.insert(0,q[2])
        else:
            S.append(q[2])


print(''.join(S))


### FIXED CODE ###

from collections import deque

def rev(s):
    new_s = list(reversed(s))
    return new_s

S = deque(input())
N = int(input())
r_flag=False
for _ in range(N):
    Q = input()
    if Q.isdigit():
        r_flag=not r_flag
    else:
        q = Q.split()
        if r_flag:
            if q[1]=="1":
                S.append(q[2])
            else:
                S.appendleft(q[2])
        else:
            if q[1]=="1":
                S.appendleft(q[2])
            else:
                S.append(q[2])
if r_flag:
    print(''.join(reversed(S)))
else:print(''.join(S))
### BUGGY CODE ###

n,x,y = map(int,input().split())
cnt_l = [0 for i in range(0,n)]
from collections import deque
def bfs(start):
    queue = deque()
    queue.append([start,0])
    isNotSearched = [False]*(n+1)
    
    while(len(queue)>0):
        i,cnt = queue.popleft()
        
        if(isNotSearched[i]):
            continue
        
        isNotSearched[i]=True
        cnt_l[cnt]+=1
        pre = (i-1)
        nex = (i+1)
        if(i==x):
            queue.append([y,cnt+1])
        if(i==y):
            queue.append([x,cnt+1])
        if(pre>=1):
            queue.append([pre,cnt+1])
        if(nex<=n):
            queue.append([nex,cnt+1])
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)

### FIXED CODE ###

n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque
def bfs(start):
    queue = deque()
    queue.append(start)
    isSearched = [-1]*(n+1)
    isSearched[start] = 0
    while(len(queue)>0):
        i = queue.popleft()
        cnt = isSearched[i]
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            if(j < 1 or n < j):
                continue
            if(isSearched[j]!=-1):
                continue
            queue.append(j)
            isSearched[j] = cnt
            cnt_l[cnt] += 1
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))

minA = 10**9

for b in range(min(A)-10,max(A)+N):
    submin = [abs(A[i]-b-i-1) for i in range(N)]
    # print(submin)
    minA = min(sum(submin),minA)

print(minA)

### FIXED CODE ###

from statistics import median

N = int(input())
A = list(map(int,input().split()))
Asort = sorted([A[i]-i-1 for i in range(N)])
# print(Asort)

b_tmp = int(median(Asort))

submin = [abs(A[i]-b_tmp-i-1) for i in range(N)]
# print(submin)
minA = sum(submin)

print(minA)
### BUGGY CODE ###

def seek_dup(s):
    t_list = [t for (t, d) in s]
    #d_list = [d for (t, d) in s]
 
    for t, d in reversed(s):
        if t_list.count(t) > 1:
            return (t, d)
        else:
            continue
        
    return None
 
N, K = map(int, input().split())
menu_ = []
 
for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))
 
menu = sorted(menu_, key = lambda x:x[1], reverse=True)
p = sum([d for (t, d) in menu[:K]]) + len(set([t for (t, d) in menu[:K]]))**2
 
selected_menu = menu[:K]
t_list = [t for (t, d) in selected_menu]
d_list = [d for (t, d) in selected_menu]
ans = p
for m in menu[K:]:
    
    if m[0] not in t_list:
        d = seek_dup(selected_menu)
        if d == None:
            continue
        
        selected_menu.remove(d)
        selected_menu.append(m)
        t_list = [t for (t, d) in selected_menu]
        d_list = [d for (t, d) in selected_menu]        
        
    
        p += (m[1] - d[1]) + 2 * len(set(t_list)) - 1 
        #print(ans, p)
        ans = max(ans, p)
 
print(ans) 

### FIXED CODE ###

N, K = map(int, input().split())
menu_ = []

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

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

import math
N = input()
nums = [int(i) for i in input().split(' ')]

sum = 0

for i in range(len(nums)-1):
    for ii in range(len(nums)-i-1):
        sum += nums[i]*nums[i+ii+1]

sum = sum%(math.pow(10,9)+7)
print(int(sum))


### FIXED CODE ###

N = input()
a_list = [int(i) for i in input().split(' ')]
mod = 1000000007

sum_list = []
sum = 0
for i in a_list:
  sum += i
  sum_list.append(sum)

sum = 0
for idx, i in enumerate(a_list[:-1]):
  sum += i*(sum_list[-1]-sum_list[idx])
  
print(sum%mod)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# abc127/abc127_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    R, L = i2nn()
    ss = set(range(R, L + 1))
    for i in range(1, M):
        R, L = i2nn()
        ss = ss & set(range(R, L + 1))
    print(len(ss))
    return

main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# abc127/abc127_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    L, R = (0, N)
    for i in range(M):
        Li, Ri = i2nn()
        if L < Li:
            L = Li
        if Ri < R:
            R = Ri
    if L > R:
        print(0)
    else:
        print(R - L + 1)
    return

main()
### BUGGY CODE ###

import numpy as np
N = int(input())
A = np.array(list((map(int,input().split()))))

basic=np.arange(1,N+1)
ans=0
for i in range(N):
    # print(A[i:])
    # print(basic[:N-i]-A[i]-1)
    ans+=(A[i:]==(basic[:N-i]-A[i]-1)).sum()
print(ans)

### FIXED CODE ###

import collections
N = int(input())
A = list((map(int,input().split())))

index = list(range(1,N+1))

R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]

R_dict = collections.Counter(R)
L_dict = collections.Counter(L)

ans=0
for i in R_dict.keys()&L_dict.keys():
    ans+=R_dict[i]*L_dict[i]

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

from collections import deque
import sys
H,W=map(int,input().split())
A=[]
for i in range(H):
    a=list(input())
    A.append(a)
#多点スタートな最短路問題
q=deque()
dist=[[-1 for _ in range(W)]for i in range(H)]

for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            dist[i][j]=0
            q.append([i,j])

dx=[1,0,-1,0]
dy=[0,1,0,-1]
while(len(q)):
    h,w=q.popleft()
    #print(h,w)
    #print(q)
    for i in range(4):
        y=h+dy[i]
        x=w+dx[i]
        if (y<0)or(y>=H)or(x<0)or(x>=W):
            continue
        if dist[y][x]==-1:
            dist[y][x]=dist[h][w]+1
            q.append([y,x])
ans=0
#print(dist)
for i in range(len(dist)):
    ans=max(ans,max(dist[i]))
print(ans)

### FIXED CODE ###

from collections import deque
import sys
H,W=map(int,input().split())
A=[]
for i in range(H):
    a=list(input())
    A.append(a)
#多点スタートな最短路問題
q=deque()
dist=[[-1 for _ in range(W)]for i in range(H)]

for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            dist[i][j]=0
            q.append([i,j])

dx=[1,0,-1,0]
dy=[0,1,0,-1]
while(len(q)):
    h,w=q.popleft()
    #print(h,w)
    #print(q)
    for i in range(4):
        y=h+dy[i]
        x=w+dx[i]
        if (y<0)or(y>=H)or(x<0)or(x>=W):
            continue
        if dist[y][x]==-1:
            dist[y][x]=dist[h][w]+1
            q.append([y,x])
ans=0
#print(dist)
for i in range(len(dist)):
    ans=max(ans,max(dist[i]))
print(ans)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
for a in A:
  ans*=a
if ans>10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N=int(input())
A=sorted(list(map(int,input().split())))
if A[0]==0:
  print(0)
  exit(0)
ans=1
for a in A[::-1]:
  ans*=a
  if ans>10**18:
    print(-1)
    exit(0)
print(ans)
### BUGGY CODE ###

#For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)

x,y=map(int,input().split())
r=x%y


while r!=0:
    if x>=y:
        x=y
        y=r
        r=x%y
print(y)



### FIXED CODE ###

x,y=map(int,input().split())
r=x%y

while r!=0:
        x=y
        y=r
        r=x%y
print(y)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ans=[i for i in range(n)]
for i in range(n):
    ans[i]=a.index(i+1)+1
print(*ans)

### FIXED CODE ###

n=int(input())
num=[i+1 for i in range(n)]
L=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for j in range(n):
    ans[L[j]-1]=num[j]
print(*ans)
### BUGGY CODE ###

N, X, M = map(int, input().split())
A = [X]
a = X
s = X
r = 0
r0 = 0
l = 0
amari = 0

for i in range(M+1):
  a = a ** 2 % M
  if a in A:
    r0 = A.index(a)
    l = len(A[r0:])
    r = (N - i - 1) // l
    amari = (N - i - 1) % l
    s = s + sum(A[r0:])*r + sum(A[r0:r0+amari])
    break
  A.append(a)
  s += A[-1]

print(s)

### FIXED CODE ###

N, X, M = map(int, input().split())
A = [X]
A_dict = {X}
a = X
s = X
r = 0
r0 = 0
l = 0
amari = 0

for i in range(M+1):
  a = a ** 2 % M
  if a in A_dict:
    r0 = A.index(a)
    l = len(A[r0:])
    r = (N - i - 1) // l
    amari = (N - i - 1) % l
    s = s + sum(A[r0:])*r + sum(A[r0:r0+amari])
    break
  A.append(a)
  A_dict.add(a)
  s += A[-1]

print(s)
### BUGGY CODE ###

AB = list(map(int,input().strip().split()))
A = AB[0]
B = AB[1]

tmp = A
for i in range(1,B - A + 1):
    tmp ^= (A + i)
print(tmp)


### FIXED CODE ###

import math

AB = list(map(int,input().strip().split()))
A = AB[0]
B = AB[1]


def solve_odd(a):
    return math.floor((a + 1) / 2) % 2


def solve(a):
    if a % 2 == 1:
        return solve_odd(a)
    else:
        return solve_odd(a + 1) ^ (a + 1)


print(solve(B) ^ solve(A - 1))
### BUGGY CODE ###

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

a.sort()

for i in range(m):
  a[-1] = int(a[-1] / 2)
  
  if not(a[0:n-1] == []):
    if a[-1] < max(a[0:n-1]):
      a[-1], a[a.index(max(a[0:n-1]))] = a[a.index(max(a[0:n-1]))], a[-1]
    
print(sum(a))

### FIXED CODE ###

import heapq

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

def minus_int(x):
  return -1 * int(x)

a = list(map(minus_int, input().split()))
heapq.heapify(a)

for i in range(m):
  maxp = heapq.heappop(a)
  maxp = -int(-maxp // 2)
  heapq.heappush(a, maxp)
  
print(-sum(a))
### BUGGY CODE ###

import heapq
N, M = list(map(int, input().split()))
tasks = []
for i in range(N):
    tasks.append(list(map(int, input().split())))

reward = []
heapq.heapify(reward)

total = 0
for i in range(M)[::-1]:
    for j in range(len(reward), N):
        if tasks[j][0] == M - i:
            heapq.heappush(reward, -1 * tasks[j][1])

    if len(reward) > 0:
        total += heapq.heappop(reward) * (-1)

print(total)

### FIXED CODE ###

import heapq
N, M = list(map(int, input().split()))
days = [[] for _ in range(M + 1)]
for i in range(N):
    a, b = list(map(int, input().split()))
    if a > M: continue
    days[a].append(b)

reward = []
heapq.heapify(reward)

total = 0
for i in range(M)[::-1]:
    tasks = days[M - i]
    for task in tasks:
        heapq.heappush(reward, -1 * task)

    if len(reward) > 0:
        total += heapq.heappop(reward) * (-1)

print(total)
### BUGGY CODE ###

N = int(input())
A = input().split()

L = []

for i in range(N):
  if A[i] not in L:
    L.append(A[i])
    if i == N-1:
      print('YES')
  else:
    print('NO')
    break
    

### FIXED CODE ###

N = int(input())
seq = input().split()
 
if len(seq) != len(set(seq)):
  print('NO')
else:
  print('YES')
### BUGGY CODE ###

import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))

### FIXED CODE ###

import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = As.copy()
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)
### BUGGY CODE ###

K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(x,K+1):
        if x+y > S:
            break
        for z in range(y,K+1):
            if x+y+z == S:
#                print(x,y,z)
                if len({x,y,z}) == 1:
                    count += 1
                elif len({x,y,z}) == 2:
                    count += 3
                elif len({x,y,z}) == 3:
                    count += 6
            elif x+y+z > S:
                break
print(count)
        

### FIXED CODE ###

K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
#            print(x,y,z)
            count += 1
print(count)
### BUGGY CODE ###

def main():
    r,g,b,n = map(int, input().split())
    res = 0
    for i in range(n//r + 1):
        for j in range(n//g + 1):
            if r*i + g*j <= n:
                if (n-(r*i + g*j)) % b==0:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = sorted(tmp, reverse=True)
    res = 0
    for i in range(n//r + 1):
        if i*r > n:
            break
        for j in range(n//g + 1):
            if r*i + g*j > n:
                break
            if (n-(r*i + g*j)) % b==0:
                res += 1           
    print(res)

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

d , g = map(int, input().split())
pc = [list(map(int, input().split()))for i in range(d)]
x=[]
y=[0]*d
ac=[0]*d
for i in range(d):
    ac[i]=pc[i][0]*(i+1)*100+pc[i][1]

def dfs(n,m,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(m):
        y[now]=i
        dfs(n,m,y,now+1)
dfs(d,3,y,0)

mi = 1000
for i in x:
    sum = 0
    cost = 0
    stock = []
    sum2 = 0
    for j in range(d):
        if i[j]==1:
            sum+=ac[j]
            cost+=pc[j][0]
            sum2+=ac[j]
        if i[j]==2:
            stock+=[(j+1)*100]*pc[j][0]
            sum2+=ac[j]
    if sum2<g:
        continue
    stock.sort()
    while sum<g and stock:
        sum+=stock.pop()
        cost+=1
    if sum>=g:
        mi=min(mi,cost)

print(mi)


### FIXED CODE ###

d , g = map(int, input().split())
pc = [list(map(int, input().split()))for i in range(d)]
x=[]
y=[0]*d
ac=[0]*d
for i in range(d):
    ac[i]=pc[i][0]*(i+1)*100+pc[i][1]

def dfs(n,m,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(m):
        y[now]=i
        dfs(n,m,y,now+1)
dfs(d,3,y,0)
mi = 1000
for i in x:
    sum = 0
    cost = 0
    stock = []
    sum2 = 0
    cost2 = 0
    for j in range(d):
        if i[j]==1:
            sum+=ac[j]
            cost+=pc[j][0]
            sum2+=ac[j]
            cost2+=pc[j][0]
        if i[j]==2:
            stock+=[(j+1)*100]*pc[j][0]
            sum2+=pc[j][0]*(j+1)*100
            cost2+=pc[j][0]
    if sum2<g:
        continue
    stock.sort()
    if abs(sum2-g)>abs(sum-g):
        while sum<g and stock:
            sum+=stock.pop()
            cost+=1
        if sum>=g:
            mi=min(mi,cost)
    else:
        while sum2>g and stock:
            sum2-=stock.pop()
            cost2-=1
        cost+=1
        mi=min(mi,cost2)

print(mi)
### BUGGY CODE ###

N = int(input())
p_list = map(int, input().split())

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat *= sum + 1
    if r_pos >= 2 * sum + 1: sum += 1
print(pat % 1000000007)

### FIXED CODE ###

N = int(input())
p_list = map(int, input().split())

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat = (pat * (sum + 1)) % 1000000007
    if r_pos >= 2 * sum + 1: sum += 1
print(pat)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    if i%2 == n%2 :
        b.append(a[i])
    else:
        b.insert(0, a[i])
for i in range(n):
    print(b[i], end=" ")


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = a[::2]
c = a[1::2]
if n %2 == 0:
    c.reverse()
    ans =c + b
else:
    b.reverse()
    ans = b + c
for i in range(n):
    print(ans[i], end =' ')
### BUGGY CODE ###

A, B, C, D = map(int, input().split())
MOD = 998244353
dp = [[0]*(D+1) for i in range(C+1)]
for i in range(A, C+1):
    for j in range(B, D+1):
        if (i, j) == (A, B):
            dp[i][j] = 1
        else:
            dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % MOD

print(dp[-1][-1])

### FIXED CODE ###

A, B, C, D = map(int, input().split())
MOD = 998244353
dp = [[0]*(D+1) for i in range(C+1)]
for i in range(A, C+1):
    for j in range(B, D+1):
        if (i, j) == (A, B):
            dp[i][j] = 1
        else:
            dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % MOD

print(dp[-1][-1])
### BUGGY CODE ###

H,W,K=map(int,raw_input().split())

fibo=[1,1,2]
for i in range(W):
    fibo.append(fibo[-1]+fibo[-2])

mod=1000000007
    
def f(H,K):
    if H==0:
        if K==1:
            return 1
        else:
            return 0
    else:
        if K==0 or K==W+1:
            return 0
        else:
            return (f(H-1,K)*fibo[K-1]*fibo[W-K]\
                    +f(H-1,K-1)*fibo[K-2]*fibo[W-K]\
                    +f(H-1,K+1)*fibo[K-1]*fibo[W-K-1])%mod
            
print f(H,K)

### FIXED CODE ###

H,W,K=map(int,raw_input().split())

fibo=[1,1,2]
for i in range(W):
    fibo.append(fibo[-1]+fibo[-2])

mod=1000000007
    
f=[[1 if i==1 else 0 for i in range(W+2)]]
for i in range(H):
    for j in range(W):
        f.append([(f[-1][j]*fibo[j-1]*fibo[W-j]+f[-1][j-1]*fibo[j-2]*fibo[W-j]\
                  +f[-1][j+1]*fibo[j-1]*fibo[W-j-1])% mod\
                     if (j>=1 and j<=W) else 0 for j in range(W+2)])     

print f[H][K]