Harryxun/stf_run huggingface dataset:
n=input()
ps=input()

n=int(n[0])
ps=ps.split()
ps=[int(ps) for ps in ps]

output=0
for i in range(n-2):
    if ps[i]<ps[i+1] and ps[i+1]<ps[i+2]:
        output=output+1
    elif ps[i+2]<ps[i+1] and ps[i+1]<ps[i]:
        output=output+1
    else:output=output+0
    
print(output)

### FIXED CODE ###

input_data=input()
 
a=input_data[0]
b=input_data[1]
c=input_data[2]
d=input_data[3]
 
if a==b :
    if c==d and a!=c :
            output="Yes"
    else :
        output="No"
    
else :
        if a==c and b==d :
            output="Yes"
    
        elif a==d and b==c :
            output="Yes"
        
        else :
            output="No"
           
print(output)
import bisect
import math
import sys
imput = sys.stdin

N, M = [int(item) for item in input().rstrip().split()]
As = sorted([int(item) for item in input().rstrip().split()])
cnt = 0
_t = As.pop()
while(cnt < M):
    if _t <= As[-1]:
        bisect.insort_right(As, _t)
        _t = As.pop()
    _t = _t / 2
    cnt += 1
bisect.insort_right(As, _t)
    
_sum = sum([math.floor(item) for item in As])
print(_sum)


### FIXED CODE ###

import heapq
 
N, M = [int(item) for item in input().rstrip().split()]
hp = [-1 * int(item) for item in input().rstrip().split()]
heapq.heapify(hp)

for i in range(M):
    _t = heapq.heappop(hp)
    heapq.heappush(hp, -1 * (-1 * _t // 2))
    
_sum = sum([-1 * int(item) for item in hp])
print(_sum)
N = int(input())

if N == 1:
  print('Hello World')
else:
  A,B = map(int,input().split(' '))
  print(A + B)

### FIXED CODE ###

N = int(input())
 
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)
n = int(input())
    tasks = []
    for i in range(n):
        a,b = map(int, input().split())
        tasks.append((a,b))

    tasks.sort(key=lambda x:x[1])
    #print(tasks)

    cur = 0
    c = True
    for i in range(n):
        cur += tasks[i][0]
        if cur > tasks[i][1]:
            c = False

    print("Yes" if c else "No")

### FIXED CODE ###

n = int(input())
tasks = []
for i in range(n):
    a,b = map(int, input().split())
    tasks.append((a,b))

tasks.sort(key=lambda x:x[1])
#print(tasks)

cur = 0
c = True
for i in range(n):
    cur += tasks[i][0]
    if cur > tasks[i][1]:
        c = False

print("Yes" if c else "No")
from math import floor,ceil
X = int(input())
cash = 100
count = 0
while cash < X:
    cash=floor(p*1.01)
    count += 1
print(count)

### FIXED CODE ###

from math import floor,ceil
X = int(input())
 
p = 100
c = 0
while p < X:
    p=floor(p*1.01)
    c += 1
print(c)
# https://atcoder.jp/contests/dp/tasks/dp_l

'''
dp[i,j] ... dequeに[i,j]が残っているときに行動するプレイヤーのスコアの最大
dp[i,j] = max(a[i-1]-dp[i-1,j], a[j+1]-dp[i,j+1]) #これじゃgreedyと同じじゃん

dp[i,j] ... dequeに[i,j)が残っているときにその状態からスタートするプレイヤーが達成できるスコアの最大 (区間を伸ばしていく感じ)

初期値 dp[i,i]==0

dp[i,j]=max(a[i]-dp[i+1,j], a[j-1]-dp[i,j-1])
'''
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

N = a_int()
A = ints()


from numba import njit


@njit('(i8,i8[:])', cache=True)
def solve(N, A, dp):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    for i in range(N - 1, -1, -1):
        for j in range(i + 1, N + 1):
            dp[i, j] = max(A[i] - dp[i + 1, j], A[j - 1] - dp[i, j - 1])
    print(dp[0, N])
    # print(*dp, sep='\n')


solve(N, A)


### FIXED CODE ###

# https://atcoder.jp/contests/dp/tasks/dp_l

'''
dp[i,j] ... dequeに[i,j]が残っているときに行動するプレイヤーのスコアの最大
dp[i,j] = max(a[i-1]-dp[i-1,j], a[j+1]-dp[i,j+1]) #これじゃgreedyと同じじゃん

dp[i,j] ... dequeに[i,j)が残っているときにその状態からスタートするプレイヤーが達成できるスコアの最大 (区間を伸ばしていく感じ)

初期値 dp[i,i]==0

dp[i,j]=max(a[i]-dp[i+1,j], a[j-1]-dp[i,j-1])
'''
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

N = a_int()
A = ints()

dp = full((N + 1, N + 1), -10**11)
dp[np.arange(N + 1), np.arange(N + 1)] = 0

from numba import njit


@njit('(i8,i8[:],i8[:,:])', cache=True)
def solve(N, A, dp):
    for i in range(N - 1, -1, -1):
        for j in range(i + 1, N + 1):
            dp[i, j] = max(A[i] - dp[i + 1, j], A[j - 1] - dp[i, j - 1])
    print(dp[0, N])
    # print(*dp, sep='\n')


solve(N, A, dp)
from scipy.misc import comb
#from scipy.special import comb
import itertools

N, X, Y = map(int, input().split())

combi = list(itertools.combinations(range(1,N+1), 2))
#print(combi)
dist = {}
for i in range(1, N):
    dist[i] = 0

for kyori in combi:
    a = kyori[1] - kyori[0]
    b = int(abs((kyori[1] - Y))) + 1 + int(abs((X - kyori[0])))
    c = min([a, b])
    dist[c] += 1
    #print(c, kyori)
dist2 = sorted(dist.items())
#print(dist, dist2)
for i in range(0, N-1):
    print(dist2[i][1])


### FIXED CODE ###

import itertools

N, X, Y = map(int, input().split())

combi = list(itertools.combinations(range(1,N+1), 2))
dist = [[i+1, 0] for i in range(0, N-1)]

c = [min([kyori[1] - kyori[0], int(abs((kyori[1] - Y))) + 1 + int(abs((X - kyori[0])))]) for kyori in combi]

for i in range(len(c)):
    dist[c[i]-1][1] += 1
for i in range(0, N-1):
    print(dist[i][1])
s=input()
a="AKIHABARA"
j=0
for i in s:
    if j>8:
        print("NO")
        exit()
    if i==a[j]:
        j+=1
    elif i==a[j+1] and a[j]=="A":
        j+=2
    else:
        print("NO")
        exit()
print("YES")  

### FIXED CODE ###

a=["KIH","B","R",""]
ans=[]
aaa=[]
for i in range(16):
    b=""
    for j,k in enumerate(a):
        if ((i >> j) & 1):
            b+="A"
        b+=k
    ans.append(b)
print("YES" if input() in ans else "NO")
S = input()
f = int(S[0]+S[1])
b = int(S[2]+S[3])

def judge(int):
    if 1 <= int <= 12
        return 0
    else:
        return 1
ref = [judge(f), judge(b)]

if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS")


### FIXED CODE ###

S = input()
f = int(S[0]+S[1])
b = int(S[2]+S[3])

def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1
ref = [judge(f), judge(b)]

if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS")
S,W =map(int,input().split())
if W >=S:
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###

N = int(input())
if N >=30:
    print('Yes')
else :
    print('No')
x,y=input().split()
z=input()
print(z,x,y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(str(z)+" "+str(x)+" "+str(y))
a,b,c=map(int,intpu().split())
print(max(0,c-(a-b)))

### FIXED CODE ###

a,b,c=map(int,input().split())
print(max(0,c-(a-b)))
s = input()
k = 0
while True:
  if "10" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  elif "01" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  else:
    print(k)
    break

### FIXED CODE ###

s = input()
print(min(s.count("0"), s.count("1"))*2)
s = input()
count = 0
while '10' in s:
    s = s.replace('10', '', 1)
    count += 1
    print(s)

while '01' in s:
    s = s.replace('01', '', 1)
    count += 1
print(count * 2)

### FIXED CODE ###

s = input()
print(min(s.count('0'), s.count('1')) * 2)
import sys
from collections import defaultdict
sys.setrecursionlimit(100000)
N, Q = map(int, input().split())

child = defaultdict(list)
counter = [0] * N
pcounter = [0] * N

for i in range(N-1):
    a, b = map(int, input().split())
    child[a-1].append(b-1)
for i in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

def propagate(node, acc):
    counter[node] += acc
    acc = counter[node]
    for c in child[node]:
        propagate(c, acc)

propagate(0, 0)
print(*counter, sep=' ')


### FIXED CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(100000)
N, Q = map(int, input().split())

neighbor = defaultdict(list)
counter = [0] * N
pcounter = [None] * N
depth = {0: 0}

for i in range(N-1):
    a, b = map(int, input().split())
    a_deper, b_deeper = False, False
    if a in depth and b not in depth:
        depth[b] = depth[a] + 1
    if b in depth and a not in depth:
        depth[a] = depth[b] + 1
    if a in depth and b in depth:
        if depth[a] < depth[b]:
            neighbor[a-1].append(b-1)
        else:
            neighbor[b-1].append(a-1)
    else:
            neighbor[a-1].append(b-1)
            neighbor[b-1].append(a-1)

for i in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

def solve():
    stack = [(0, None)]
    while stack:
        (node, parent) = stack.pop()
        pcounter[node] = counter[node]
        if parent is not None:
            pcounter[node] += pcounter[parent]
        for c in neighbor[node]:
            if pcounter[c] is None:
                stack.append((c, node))

solve()
print(*pcounter, sep=' ')
A,B = map(int,input().split())
K =nA + B

if K % 2 == 0:
    print(K)
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

A,B = map(int,input().split())

if (A+B)%2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
n = int(input())
if n < 10:
	print(n)
elif n < 100:
	print(9)
elif n < 1000:
	print(9 + n - 99)
elif n == 1000:
	print(909)
elif n < 10_000:
	print(909)
elif n == 10_000:
	print(910)
elif n < 100_000:
	print(909 + n-9999)
elif n == 100_000:
	print(90909)

### FIXED CODE ###

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

if x > 0:
	print(x)
else:
	print(0)
h, w = [int(i) for i in input().split()]
k = []
wl = []
  
for i in range(0, 10):
  k.append([int(i) for i in input().split()])
for i in range(0, h):
  wl.append([int(i) for i in input().split()])


n = {1:0}

while len(n) < 10:
  c = 1000
  mn = 10
  for a in n.keys():
    a2 = int(a)
    for b in range(0, 10):
      if not b in n:
        if k[b][a2] + n[a] < c:
          c = k[b][a2] + n[a]
          mn = b
  n[mn] = c

ans = 0
for a in range(0, h):
  for b in range(0, w):
    if wl[a][b] != -1:
      ans += n[wl[a][b]]

print(ans)
      

### FIXED CODE ###

s = input()
if s[1] == s[2] and s[2] == s[3]:
  print("Yes")
else:
  if s[0] == s[1] and s[1] == s[2]:
    print("Yes")
  else:
    print("No")
def gen_factorization(N):
    tables=[-1]*(N+1)
    for i in range(2,N+1):
        if tables[i]!=-1:continue
        tmp=i
        while tmp<=N:
            tables[tmp]=i
            tmp+=i
    def fuctorization(n):
        if n==1:return 1
        elif n<0:n=abs(n)
        elif n>N:return -1
        ans={}
        while n!=1:
            tmp=tables[n]
            #debug print
            #print(tmp,n)
            ans.setdefault(tmp,0)
            ans[tmp]+=1
            n//=tmp
        return ans
    return fuctorization

N=int(input())
f=gen_factorization(10**6)
A=list(map(int,input().split()))
primes={}
for i in A:
  if i==1:continue
  d=f(i)
  for j in d:
    primes.setdefault(j,0)
    primes[j]+=1

ansMax=max(primes.values())
ansMin=min(primes.values())

if ansMax==1:
  print('pairwise coprime')
elif ansMax==N:
  print('not coprime')
else:
  print('setwise coprime')

### FIXED CODE ###


def gen_factorization(N):
    tables=[-1]*(N+1)
    for i in range(2,N+1):
        if tables[i]!=-1:continue
        tmp=i
        while tmp<=N:
            tables[tmp]=i
            tmp+=i
    def fuctorization(n):
        if n==1:return {1:1}
        elif n<0:n=abs(n)
        if n>N:return "error"
        ans={}
        while n!=1:
            tmp=tables[n]
            #debug print
            #print(tmp,n)
            ans.setdefault(tmp,0)
            ans[tmp]+=1
            n//=tmp
        return ans
    return fuctorization

N=int(input())
f=gen_factorization(10**6+10)
A=list(map(int,input().split()))
primes={}
for i in A:
  d=f(i)
  for j in d:
    primes.setdefault(j,0)
    primes[j]+=1
primes[1]=1
ansMax=max(primes.values())

if ansMax==1:
  print('pairwise coprime')
elif ansMax==N:
  print('not coprime')
else:
  print('setwise coprime')
s=input()
print("Yes" if s[3]==s[4] and s[5]==s[6] else "No")

### FIXED CODE ###

s=input()
print("Yes" if s[2]==s[3] and s[4]==s[5] else "No")
X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],100):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], 0, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    print(ans[ans2.index(min(ans2))])

### FIXED CODE ###

X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
elif X not in  p:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],102):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], -100, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    print(ans[ans2.index(min(ans2))])
import sys

length = int(sys.stdin.readline())
value =[ int(num) for num in sys.stdin.readlines() ]
minv = value[0]
maxv = value[1] - value[0]

for i in range(1,length):
    maxv = max(maxv,value[i] - minv)
    minv = min(minv,value[i])

print(maxv)

return 0


### FIXED CODE ###

import sys

count=int(input())
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
maxv=-1000000000
minv=input_list[first]

for i in input_list[second:]:
    if i-minv > maxv:
        maxv=i-minv
    if i < minv:
        minv=i

print(maxv)
t,x=map(float, input().split())
print({0:.4f}.format(t/x))

### FIXED CODE ###

t,x=map(float, input().split())
print("{:.4f}".format(t/x))
N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    # s = ''.join(s)
    S.append(s)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(10):
            a = S[i]
            b = S[j]
            if a[k] != b[k]:
                break
        else:
            ans += 1
print(ans)


### FIXED CODE ###

from itertools import combinations
import sys

N = int(input())
A = [[] for _ in range(N + 1)]
B = [[] for _ in range(N + 1)]
C = [[] for _ in range(N + 1)]
num_hint = []
# hint_dict = {}
for i in range(1, N + 1):
    num_i = int(input())
    num_hint.append(num_i)
    for j in range(num_i):
        x, y = map(int, input().split())
        A[i].append((x, y))
        if y == 1:
            B[i].append(x)
        if y == 0:
            C[i].append(x)
        # if hint_dict.get(x) is None:
        #     hint_dict[x] = {0: [], 1: []}
        #     hint_dict[x][y].append(i)
        # else:
        #     hint_dict[x][y].append(i)

for i in range(N + 1, 0, -1):
    for combi in combinations(range(1, N + 1), i):
        remain = set(range(1, N + 1)) - set(combi)
        s = set()
        t = set()
        hint_dict = {}
        for j in combi:
            s |= set(B[j])
            t |= set(C[j])
            for x, y in A[j]:
                if hint_dict.get(x) is None:
                    hint_dict[x] = {0: [], 1: []}
                    hint_dict[x][y].append(i)
                else:
                    hint_dict[x][y].append(i)
        good1 = True
        for value in hint_dict.values():
            if len(value[0]) != 0 and len(value[1]) != 0:
                good1 = False
                break
        good2 = True
        if len(s & remain) != 0:
            good2 = False
        good3 = True
        if len(t & set(combi)) != 0:
            good3 = False
        if good1 and good2 and good3:
            print(i)
            sys.exit()
print(0)
A,B=map(int, input().split())
if A<5:
    print(0)
elif A<12:
    print(B/2)
else:
    print(B







### FIXED CODE ###

# coding: utf-8
# Your code here!
A, B = map(int, input().split())

if A>=13:
    print(B)
elif A<=5:
    print(0)
else:
    print(B//2)
word=inpput()
# word="WBWBWBWBWB"
ans=0
for i in range(len(word)-1):
    if word[i]!=word[i+1]:
        ans+=1
        
print(ans)

### FIXED CODE ###

word=input()
# word="WBWBWBWBWB"
ans=0
for i in range(len(word)-1):
    if word[i]!=word[i+1]:
        ans+=1
        
print(ans)
N = int(input())
A = [int(c) for c in input().split()]

A_plus, A_minus = [], []
for a in A:
    if a>0: A_plus.append(a)
    else: A_minus.append(a)

if len(A_minus)%2==0:
    print(sum(A_plus) - sum(A_minus))
else:
    if min(A_plus) > -max(A_minus):
        print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)
    else:
        print(sum(A_plus) - sum(A_minus) - min(A_plus)*2)
        


### FIXED CODE ###

N = int(input())
A = [int(c) for c in input().split()]

A_plus, A_minus = [], []
for a in A:
    if a>0: A_plus.append(a)
    else: A_minus.append(a)

if len(A_minus)%2==0:
    print(sum(A_plus) - sum(A_minus))
elif len(A_plus)==0:
    print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)    
else:
    if min(A_plus) > -max(A_minus):
        print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)
    else:
        print(sum(A_plus) - sum(A_minus) - min(A_plus)*2)
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a*c<b){
            System.out.println(c);
        }else{
            System.out.println(b/a);
        }
    }   
}

### FIXED CODE ###

a,b,c = map(int,input().split())
if a*c<b:
    print(c)
else:
    print(b//a)
S = input()
K = int(input())
a = []
ans = 0
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] :
        count += 1
    else:
        if count!=0:
            ans += (count+1)//2
            a.append(count)
            count = 0
if count !=0:
    ans += (count+1)//2 
ans = ans*K
if (count+a[0])%2 == 0 and count!=0 and len(a)!=0 and S[0]==S[1] :
    ans+=K-1

print(ans)

### FIXED CODE ###

S = input()
K = int(input())
a = []
ans = 0
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] :
        count += 1
    else:
        if count!=0:
            ans += (count+1)//2
            a.append(count+1)
            count = 0
if count !=0:
    ans += (count+1)//2 
ans = ans*K
a.append(0)
if len(S) == 1:
    ans = K//2
else:    
    
    if (count+1)%2==1 and a[0]%2 == 1 and S[0]== S[1] and S[0] == S[len(S)-1]:
    
        ans+=K-1
    if S[0]!= S[1] and (count+1)%2 ==1 and  S[0] == S[len(S)-1]:
        ans+=K-1
    if count+1 == len(S):
        if len(S)%2==1:
            ans = (len(S)*K)//2
 
print(ans)
a,b,c,k =map(int,input().split())

if k==0:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(a-b)
elif k==1:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(b-a)
elif abs(a-b)==0:
    print("Unfair")
else:
    if k>=100:
        print("Unfair")
    else:    
        m = int(2(2**(k-1)-(-1)**(k-1))/3)
        n = int((2**k-(-1)**k)/3)
        ans = (a-b)*(m-n)
        if abs(ans)>=10**18:
            print("Unfair")
        else:
            print(ans)        


### FIXED CODE ###


if __name__ == "__main__":
    a,b,c,k = map(int,input().split())
    if k%2 == 0:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(a-b)
    else:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(b-a)
n = input()
sort_list = list()

for i in range(0,n):
    sort_list.append(int(input(),10))

for i in range(1,n):
    
    for j in range(0,n):
        print(sort_list[j])
        if j is not n - 1:
            print(" ")
        else:
            print("\n")
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[i] > v:
        sort_list[j+1] = sort_list[j]
        j = j - 1
    sort_list[j+1] = v




### FIXED CODE ###

import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(0,n):
    
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[j] > tmp:
        sort_list[j+1] = sort_list[j]
        j = j - 1

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        elif i is not n - 1:
            sys.stdout.write("\n")
            
print("")
s1=input()
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))
  

### FIXED CODE ###

s1=list(input())
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))
from collections import deque

s = deque(list(input()))
q = int(input())

rev = True

for i in range(q):
    q = list(input().split())
    if(int(q[0]) == 1):
        rev = rev ^ True
    else:
        n = int(q[1])
        if((n == 1 and rev) or (n == 2 and not rev)):
            s.appendleft(q[2])
        else:
            s.append(q[2])

if not rev:
    s = s[::-1]

print(''.join(s))


### FIXED CODE ###

from collections import deque

s = deque(list(input()))
q = int(input())

rev = True

for i in range(q):
    q = list(input().split())
    if(int(q[0]) == 1):
        rev = rev ^ True
    else:
        n = int(q[1])
        if((n == 1 and rev) or (n == 2 and not rev)):
            s.appendleft(q[2])
        else:
            s.append(q[2])


txt = ''
if rev:
    txt = ''.join(s)
else:
    while not(not s):
        txt += s.pop()

print(txt)
def main():
    n, K = map(int, input().split())
    a = list(map(int, input().split()))
    cnt = a.count(n)
    for k in range(min(k, 100)):
        an = [0] * n
        for i in range(n):
            if an[i] < n:
                an[i] += 1
            for j in range(1, a[i]+1):
                if i - j >= 0 and an[i-j] < n:
                    an[i-j] += 1
                    if an[i-j] == n:
                        cnt += 1
                if i + j < n and an[i+j] < n:
                    an[i+j] += 1
                    if an[i+j] == n:
                        cnt += 1
        else:
            a = an
            if cnt == n:
                break
    print(*a)
main()

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(k):
        imos = [0] * (n + 1)
        for i in range(n):
            imos[max(0, i - a[i])] += 1
            imos[min(n, i + a[i] + 1)] -= 1
        for i in range(1, n):
            imos[i] += imos[i-1]
        imos.pop()
        a = imos
        if min(a) == n:
            break 
    print(*a)
main()
if S[0] == S[1] and S[2] == S[3] and S[0] == S[2]:
    print("No")
elif S[0] == S[1] and S[2] == S[3]:
  print("Yes")
elif S[0] == S[2] and S[1] == S[3]:
  print("Yes")
elif S[0] == S[3] and S[2] == S[1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] == S[2]:
    print("No")
elif S[0] == S[1] and S[2] == S[3]:
    print("Yes")
elif S[0] == S[2] and S[1] == S[3]:
    print("Yes")
elif S[0] == S[3] and S[2] == S[1]:
    print("Yes")
else:
    print("No")