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

def main():
	S=input()                                               # 1行1列
	Q=int(input())                                          # 1行1列
	Q_LIST=[input().split() for i in range(Q)]                # N行C列・・・Cは任意

	dir = 0 # 0が正常

	List = [S]

	for query in Q_LIST:
		if query[0] == '1':
			if dir == 0:
				dir = 1
			else:
				dir = 0

		if dir == 0:
			HEAD = '1'
			BACK = '2'
		else:
			HEAD = '2'
			BACK = '1'

		if query[0] == '2':
			if query[1] == HEAD:
				List.insert(0, query[2])
			if query[1] == BACK:
				List.append(query[2])

	S = ''.join(List)

	if dir == 0:
		print(S)
	else:
		print(S[::-1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
	S=input()                                               # 1行1列
	Q=int(input())                                          # 1行1列
	Q_LIST=[input().split() for i in range(Q)]                # N行C列・・・Cは任意
	 
	dir = 0 # 0が正常

	S_HEAD = ''
	S_BACK = ''

	for query in Q_LIST:
		if query[0] == '1':
			if dir == 0:
				dir = 1
			else:
				dir = 0
	 
		if dir == 0:
			HEAD = '1'
			BACK = '2'
		else:
			HEAD = '2'
			BACK = '1'
	 
		if query[0] == '2':
			if query[1] == HEAD:
				S_HEAD = query[2] + S_HEAD
			if query[1] == BACK:
				S_BACK =  S_BACK + query[2]

	S = S_HEAD + S + S_BACK

	if dir == 0:
		print(S)
	else:
		print(S[::-1])

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

def main():
    n = int(input())
    a = [list(map(int, input().split())) for i in range(n)]

    dist = [[a[i][j] for j in range(n)] for i in range(n)]
    total = sum([sum(a[i]) for i in range(n)])
    for k in range(n):
        for i in range(n):
            if k==i:
                continue
            for j in range(n):
                if i == j or k ==j:
                    continue
                if dist[i][j] > dist[i][k] + dist[k][j]:
                    print(-1)
                    exit()
                if dist[i][j] == dist[i][k] + dist[k][j]:
                    total -= dist[i][j]
    print(total//2)
    

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = [list(map(int, input().split())) for i in range(n)]

    total = sum([sum(a[i]) for i in range(n)])
    for k in range(n):
        for i in range(n):
            if k == i:
                continue
            for j in range(n):
                if i == j or k == j:
                    continue
                if a[i][j] > a[i][k] + a[k][j]:
                    print(-1)
                    exit()
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i == k or j == k:
                    continue
                if a[i][j] == a[i][k] + a[k][j]:
                    total -= a[i][j]
                    break

    print(total//2)


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

N=input()
list=[]
a=[]
b=[]
c=[]
s=[]
t=0
for i in range(int(N)):
    list.append(input())
    for l in range(len(a)):
        if(a[l]==list[i]):
            b[l]+=1
            t=1
            break
    if t==0:
        a.append(list[i])
        b.append(1)
    else:
        t=0

for i in range(len(a)):
    if b[i]==max(b):
        c.append(a[i])
s=sorted(c)
for i in range(len(s)):
    print(s[i])


    



### FIXED CODE ###

import collections
import sys
N=int(input())
S=[input() for i in range(N)]
c = collections.Counter(S).most_common()
c.sort()
c.sort(key=lambda c:c[1],reverse=True)
max_count=c[0][1]
for _ in c:
  if _[1]==max_count:
    print(_[0])
  else:
    sys.exit()
### BUGGY CODE ###

A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if (i <= A + K - 1) or (i >= B - K + 1):
        print(i)
        continue


### FIXED CODE ###

A, B, K = map(int, input().split())
if B - A + 1 <= 2 * K:
    for i in range(A, B + 1):
        print(i)
    exit()
for i in range(A, A + K):
    print(i)
for i in range(B - K + 1, B + 1):
    print(i)
### BUGGY CODE ###

#!/usr/bin/env python3


def solve(H, W, S):
    grid = [[0] * W for _ in range(H)]
    for y in range(H):
        count = 0
        start = 0
        for x in range(W):
            if S[y][x] == '#':
                for i in range(start, x):
                    grid[y][i] = count
                start = x + 1
                count = 0
            else:
                count += 1
        for i in range(start, W):
            grid[y][i] = count

    for x in range(W):
        count = 0
        start = 0
        for y in range(H):
            if S[y][x] == '#':
                for i in range(start, y):
                    grid[i][x] += count
                start = y + 1
                count = 0
            else:
                count += 1
        for i in range(start, H):
            grid[i][x] += count

    ans = 0
    for x in range(W):
        for y in range(H):
            if grid[y][x] > ans:
                ans = grid[y][x]
    return ans - 1


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [input().strip() for _ in range(H)]

    ans = solve(H, W, S)

    print(ans)


### FIXED CODE ###

#!/usr/bin/env python3


def solve(H, W, S):
    grid = [[0] * W for _ in range(H)]
    for y in range(H):
        count = 0
        start = 0
        for x in range(W):
            if S[y][x] == '#':
                for i in range(start, x):
                    grid[y][i] = count
                start = x + 1
                count = 0
            else:
                count += 1
        for i in range(start, W):
            grid[y][i] = count

    for x in range(W):
        count = 0
        start = 0
        for y in range(H):
            if S[y][x] == '#':
                for i in range(start, y):
                    grid[i][x] += count
                start = y + 1
                count = 0
            else:
                count += 1
        for i in range(start, H):
            grid[i][x] += count

    ans = 0
    for x in range(W):
        for y in range(H):
            if grid[y][x] > ans:
                ans = grid[y][x]
    return ans - 1


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [input().strip() for _ in range(H)]

    ans = solve(H, W, S)

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

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
distance=[[99999999 for i in range(n)] for i in range(n)]
for i in range(n):
  distance[i][i]=0
for i in range(m):
  distance[l[i][0]-1][l[i][1]-1]=l[i][2]
  distance[l[i][1]-1][l[i][0]-1]=l[i][2]

for k in range(n):
  for i in range(n):
    for j in range(n):
      distance[i][j]=min(distance[i][k]+distance[k][j],distance[i][j])

ct=m
for k in range(m):
  for i in range(n):
    for j in range(n):
      if i!=j:
        if distance[i][j]==distance[i][l[k][0]-1]+l[k][2]+distance[l[k][1]-1][j]:
          ct-=1
          break
    else:
      continue
    break
print(ct)

### FIXED CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
distance=[[99999999 for i in range(n)] for i in range(n)]
for i in range(n):
  distance[i][i]=0
for i in range(m):
  distance[l[i][0]-1][l[i][1]-1]=l[i][2]
  distance[l[i][1]-1][l[i][0]-1]=l[i][2]

for k in range(n):
  for i in range(n):
    for j in range(n):
      distance[i][j]=min(distance[i][k]+distance[k][j],distance[i][j])

ct=m
for k in range(m):
  for i in range(n):
    for j in range(n):
      if i!=j:
        if distance[i][j]==distance[i][l[k][0]-1]+l[k][2]+distance[l[k][1]-1][j]:
          ct-=1
          break
    else:
      continue
    break
print(ct)
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin



def main():
  ## input
  N,Q = map(int, stdin.readline().rstrip().split())
  STX = [[0,0,0] for _ in range(N)]
  for i in range(N):
    s,t,x = map(int, stdin.readline().rstrip().split())
    STX[i] = [x,s-x,t-x]
  Dn = [int(stdin.readline().rstrip()) for _ in range(Q)] + [10**10]
  ans = {}

  for x,s,t in sorted(STX):
    l = bisect_left(Dn,s)
    while Dn[l] < t:
      ans[Dn[l]] = x
      del Dn[l]

  for d in Dn[:-1]:
    ans[d] = -1

  return ans


if __name__ == "__main__":
  ans = main()
  for d in sorted(list(ans.keys())):
    print(ans[d])
    


### FIXED CODE ###

import sys
from bisect import bisect_left



N,Q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = map(int, line.split())
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

print('\n'.join(map(str, ans)))
### BUGGY CODE ###

k = int(input())
from collections import deque
dic = {1:1}
queue = deque()
queue.appendleft([1,1])
while queue:
    v,cost = queue.popleft()
    v_ = (v+1)%k
    if not v_ in dic or cost+1<dic[v_]:
        dic[v_] = cost+1
        queue.appendleft([v_,cost+1])
    v_ = v*10%k
    if not v_ in dic or cost<dic[v_]:
        dic[v_] = cost
        queue.appendleft([v_,cost])

print(dic[0])


### FIXED CODE ###

k = int(input())
from collections import deque
dic = {1:1}
queue = deque([[1,1]])
while queue:
    v,cost = queue.popleft()
    if not (v+1)%k in dic or cost+1<dic[(v+1)%k]:
        dic[(v+1)%k] = cost+1
        queue.appendleft([(v+1)%k,cost+1])
    if not v*10%k in dic or cost<dic[v*10%k]:
        dic[v*10%k] = cost
        queue.append([v*10%k,cost])

print(dic[0])
### BUGGY CODE ###

n, k = map(int, input().split())
scaffolds = list(map(int, input().split()))
dp = [10 ** 5 * 10 ** 4] * n
dp[0] = 0
for i in range(1, n):
    scaffold = scaffolds[i]
    threshold = max(-1, i - k - 1)
    for j in range(i - 1, threshold, -1):
        dp[i] = min(dp[i], abs(scaffold - scaffolds[j]) + dp[j])
print(dp[-1])

### FIXED CODE ###

n, k = map(int, input().split())
scaffolds = list(map(int, input().split()))
dp = [10 ** 5 * 10 ** 4] * n
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i + j >= n:
            break
        dp[i + j] = min(dp[i + j], abs(scaffolds[i] - scaffolds[i + j]) + dp[i])
print(dp[-1])
### BUGGY CODE ###

from fractions import*
M=10**9+7
_,a=open(0)
*a,=map(int,a.split())
s=1
for t in a:s*=t//gcd(s,t)
c=0
for i in a:
    c+=s//i
    if c>M:c%=M
print(c)

### FIXED CODE ###

from fractions import*
from functools import*
M=10**9+7
_,a=open(0)
*a,=map(int,a.split())
s=reduce(lambda x,y:x//gcd(x,y)*y,a)%M
c=0
for i in a:
    c+=s*pow(i,M-2,M)
    c%=M
print(c)
### BUGGY CODE ###

n, k = map(int, input().split())
a = [int(x)-1 for x in input().split()]

inds = {}
y = [0]*n

for i in range(n):
    if a[i] in inds:
        y[inds[a[i]][-1]] = i+1 - inds[a[i]][-1]
        inds[a[i]].append(i)
    else:
        inds[a[i]] = [i]

for lst in inds.values():
    y[lst[-1]] = n+lst[0]+1 - lst[-1]

length = (n*k).bit_length()

db = [y]
for m in range(length):
    db.append([db[-1][i] + db[-1][(i+db[-1][i]) % n] for i in range(n)])

cur = 0
i = length

while cur < n*k:
    while i > -1 and cur + db[i][cur % n] > n*k:
        i -= 1
    if i == -1:
        break
    cur = cur + db[i][cur % n]

ans = []
while cur < n*k:
    if cur + db[0][cur % n] > n*k:
        ans.append(cur)
        cur += 1
    elif cur + db[0][cur % n] == n*k:
        break
    else:
        cur = cur + db[0][cur % n]

print(*map(lambda x: a[x % n]+1, ans))


### FIXED CODE ###

from bisect import bisect_right
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]].append(i)
    else:
        d[a[i]] = [i]


def simulate(k):
    if k == 0:
        return 0, []
    lap = 1
    res = [0]
    while True:
        s = res.pop()
        nxt = d[a[s]][bisect_right(d[a[s]], s) % len(d[a[s]])] + 1
        if nxt == n:
            if lap == k and s == n-1:
                res.append(s)
            if s == n-1:
                lap += 1
            return lap, res
        elif nxt <= s+1:
            if lap == k:
                res.append(s)
                if s == n-1:
                    return lap, res
                res.append(s+1)
                if s+1 == n-1:
                    return lap, res
            else:
                res.append(nxt)
                lap += 1
        else:  # s+1 < nxt
            s = nxt
            res.append(s)
    return 0


period, ans = simulate(k)

if period != k:
    lap, ans = simulate(k % period)

print(*[a[x] for x in ans])
### BUGGY CODE ###

import numpy as np
if __name__ =="__main__":
    N = input()
    status = np.array([float(N), 0, 0, 0, 0])
    cap = np.zeros(5)
    for x in range(5):
        a = input()
        cap[x]=int(a)
    time=0
    move=np.zeros(5)
    while(True):
        pre_move = 0
        for x in range(4):
            move[x+1] = min(cap[x],status[x])
        status -= cap
        status=np.where(status<0,0,status)
        status+=move
        time+=1
        if sum(status)==0:
            break
    print(time)

### FIXED CODE ###

import math
if __name__ =="__main__":
    N = input()
    N = float(N)
    cap_min=10.0**16
    for x in range(5):
        a = input()
        cap_min = min(float(a),cap_min)
    time = math.ceil(N/cap_min)+4
    print(time)
### BUGGY CODE ###

def main():
    R, C, K = map(int, input().split())
    items = [[0 for _ in range(C)] for _ in range(R)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        items[r - 1][c - 1] = v
    dp = [[[0, 0, 0, 0] for _ in range(C)] for _ in range(R)]
    dp[0][0][1] = items[0][0]
    for r in range(R):
        for c in range(C):
            for i in range(4):
                tmp = dp[r][c][i]
                # right
                if c != C - 1:
                    # unpick
                    dp[r][c + 1][i] = max(dp[r][c + 1][i], tmp)
                    # pick
                    if i < 3:
                        dp[r][c + 1][i +
                                     1] = max(dp[r][c + 1][i + 1], tmp + items[r][c + 1])
                # down
                if r != R - 1:
                    # unpick
                    dp[r + 1][c][i] = max(dp[r + 1][c][i], tmp)
                    # pick
                    dp[r + 1][c][1] = max(dp[r + 1][c][1], tmp + items[r + 1][c])
    ans = 0
    for i in range(4):
        ans = max(ans, dp[-1][-1][i])
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
input = stdin.readline
def main():
    R, C, K = map(int, input().split())
    items = [[0 for _ in range(C)] for _ in range(R)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        items[r - 1][c - 1] = v
    dp = [[[0 for _ in range(C)] for _ in range(R)] for _ in range(4)]
    dp[1][0][0] = items[0][0]
    for r in range(R):
        for c in range(C):
            for i in range(4):
                tmp = dp[i][r][c]
                # right
                if c != C - 1:
                    # unpick
                    dp[i][r][c + 1] = max(dp[i][r][c+1], tmp)
                    # pick
                    if i < 3:
                        dp[i+1][r][c + 1] = max(dp[i+1][r]
                                                [c + 1], tmp + items[r][c + 1])
                # down
                if r != R - 1:
                    # unpick
                    dp[0][r + 1][c] = max(dp[0][r + 1][c], tmp)
                    # pick
                    dp[1][r + 1][c] = max(dp[1][r + 1][c],
                                          tmp + items[r + 1][c])
    ans = 0
    for i in range(4):
        ans = max(ans, dp[i][-1][-1])
    print(ans)


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

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
mod = 10**9 + 7

def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

for key, val in cnt.items():
    if val == 2:
        doubled_num = key
        break

left = None
for i, a in enumerate(A):
    if a == doubled_num:
        if left == None:
            left = i
        else:
            right = i

rest = n - right
left
for i in range(1, n+2):
    print((comb(n+1, i, mod) - comb(left + rest, i-1, mod)) % mod)

### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
mod = 10**9 + 7

def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


for key, val in cnt.items():
    if val == 2:
        doubled_num = key
        break

left = None
for i, a in enumerate(A):
    if a == doubled_num:
        if left == None:
            left = i
        else:
            right = i

rest = n - right
base_numerator = n+1
base_denominator = 1
base = (base_numerator * mod_inv(base_denominator, mod)) % mod
duplicate_numerator = left + rest + 1
duplicate_denominator = 0
duplicate = 1
for i in range(n+1):
    #print("base", base_numerator, base_denominator)
    #print("dup", duplicate_numerator, duplicate_denominator)
    #print(base, duplicate)
    print((base - duplicate) % mod)

    base_numerator -= 1
    base_denominator += 1
    base *= base_numerator * mod_inv(base_denominator, mod)
    base %= mod
    duplicate_numerator -= 1
    duplicate_denominator += 1
    duplicate *= duplicate_numerator * mod_inv(duplicate_denominator, mod)
    duplicate %= mod
### BUGGY CODE ###

n = int(input())
a = input().split()[::-1]
b = []
for i in range(n):
    n = a.pop()
    b.append(n)
    b = b[::-1]

print(*b)

### FIXED CODE ###

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

a_odd = a[0::2]
a_even = a[1::2]

if n % 2 == 1:
    print(" ".join(a_odd[::-1] + a_even))
else:
    print(" ".join(a_even[::-1] + a_odd))
### BUGGY CODE ###

A, B, N = map(int,input().split())
t = 0
for x in range(1, N+1):
  t = max(t, (A * x) // B - A * (x // B))
print(t)

### FIXED CODE ###

A, B, N = map(int,input().split())
x = min(B-1, N)
print((A * x) // B - A * int(x // B))
### BUGGY CODE ###

N, Ma, Mb = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
INF = float("inf")


for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

#dp[i][j][k]...i番目までの品物で, タイプAの物質をjグラム, タイプBの物質をkグラム調達するのに必要な費用の最小値

dp = [[[INF]*400 for _ in range(400)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(1, N+1):
    for j in range(400):
        for k in range(400):
            if j < a[i-1] or k < b[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            else:
                dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1])

ans = INF

for i in range(1, N+1):
    for j in range(1, 400):
        for k in range(1, 400):
            if j*Mb == k*Ma:
                ans = min(ans, dp[i][j][k])
if ans == INF:
    print(-1)
else:
    print(ans)




### FIXED CODE ###

N, Ma, Mb = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
INF = 10000


for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

#dp[i][j][k]...i番目までの品物で, タイプAの物質をjグラム, タイプBの物質をkグラム調達するのに必要な費用の最小値

dp = [[[INF]*400 for _ in range(400)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(1, N+1):
    for j in range(400):
        for k in range(400):
            if j < a[i-1] or k < b[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            else:
                dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1])

ans = INF

for i in range(1, N+1):
    for j in range(1, 400):
        for k in range(1, 400):
            if j*Mb == k*Ma:
                ans = min(ans, dp[i][j][k])
if ans == INF:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

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

anl =[]
print(len([anl for i in range(1,n+1)
 for j in range(i+1,n+1)
 for k in range(j+1,n+1)
 if s[i-1]!=s[k-1]
 if s[j-1]!=s[k-1] 
 if s[i-1]!=s[j-1]
 if i<j and j<k and (j-i) != (k-j)]))

### FIXED CODE ###

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

an = s.count('R') *s.count('G') *s.count('B')

for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j-i
        if (k<n) and (s[i]!=s[j]) and (s[j]!=s[k])and(s[i]!=s[k]):
                an -= 1

print(an)
### BUGGY CODE ###

def pypri(p,y):print(str(p).zfill(6)+str(y).zfill(6))
n,m=map(int,input().split())
a=[[]for _ in range(n)]
b=[]
for i in range(m):
  p,y=map(int,input().split())
  b.append(p-1)
  a[p-1].append([y,len(a[p-1])+1])
for i in range(n):
  a[i].sort()
  for j in range(len(a[i])):
    a[i][j]=[a[i][j][1],j]
    a[i].sort()
for i in b:
  pypri(i+1,a[i][0][1]+1)
  del a[i][0]

### FIXED CODE ###

n,m = map(int,input().split())
py = []
for i in range(m):
    py.append(list(map(int,input().split())))
    py[i].append(i)
py.sort(key=lambda x:x[1])
py.sort(key=lambda x:x[0])
x = py[0][0]
j=0
for i in range(m):
    if x != py[i][0]:
        j = 1
        x = py[i][0]
    else:
        j+=1
    s = str(py[i][0]).zfill(6) + str(j).zfill(6)
    py[i].append(s)
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][3])
### BUGGY CODE ###

s = str(input())
l = [1 if c == "<" else -1 for c in list(s)]

def leftmore(i):
    num = 0
    while True:
        if i == 0:
            break
        elif s[i-1] == "<":
            i -= 1
            num += 1
        else:
            break
    return num

def rightless(i):
    num = 0
    while True:
        if i == len(s):
            break
        elif s[i] == ">":
            i += 1
            num += 1
        else:
            break
    return num

sumlist = [0] * (len(s)+1)
for i in range(len(sumlist)):
    sumlist[i] = max(leftmore(i),rightless(i))


print(sum(sumlist))

### FIXED CODE ###

s = str(input())
#s = "<>>><<><<<<<>>><"
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)
### BUGGY CODE ###

import math

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

x=0
if n<math.sqrt(m):
	for i in range(m//n):
		if m%(i+1)==0 and m//(i+1)>n-1:
			x=max(x,i+1)
	print(x)
else:
	for i in range(math.floor(math.sqrt(m))):
		if m%(i+1)==0 and m//(i+1)>n-1:
			x=max(x,i+1)
	print(x)



### FIXED CODE ###

import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)
		s.append(m//(i+1))




for i in s:
	if m%(i)==0 and m//(i)>n-1:
		x=max(x,i)
print(x)
### BUGGY CODE ###

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

### FIXED CODE ###

from collections import deque
b=deque([])
n=int(input())
a=list(map(str,input().split()))
b.append(a[0])
for i in range(1,n):
  if i%2==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
if n%2==0:
  print(*b)
else:
  print(*reversed(b))