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

import array

def expect_value(number):
  expect = 0
  for i in range(1, number+1):
    expect = expect + i / number
  return expect
  
N, K = map(int, input().split())
num = list(map(int, input().split()))

# 各サイコロの期待値を出す
expect = array.array('f')
for i in range(N):
  expect.append(expect_value(num[i]))

# 隣接するN個の期待値を出す
max = 0
for i in range(N):
  if i > N - K:
    break
  temp = 0
  for j in range(K):
	  temp = temp + expect[i + j]
  if max < temp:
    max = temp
print(max)


### FIXED CODE ###

N, K = map(int, input().split())
num = list(map(int, input().split()))

# 各サイコロの期待値を出す
expect = []
for i in range(N):
  expect.append((1 + num[i]) / 2)

# 累積和を作る
cs = [0]
for (i, number) in enumerate(expect):
  cs.append(cs[i] + expect[i])

max = 0
for i in range(K, N+1): # 配列0番目に初期値0が増えてるので1足す
  if max < cs[i] - cs[i-K]:
    max = cs[i] - cs[i - K]
print(max)
### BUGGY CODE ###

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

for i in range(N):
    temp = A.pop(i)
    print(max(A))
    A.insert(i, temp)


### FIXED CODE ###

import copy

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

chinpo = max(A)
B = copy.copy(A)
B.remove(max(A))
chinchin = max(B)

for i in range(A.index(max(A))):
    print(chinpo)
print(chinchin)
for i in range(A.index(max(A))+1,N):
    print(chinpo)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import bisect

n,d,a= map(int, input().split())
x= [list(map(int, input().split())) for i in range(n)]

x.sort()
y=[]
for i in range(n):
    y.append(x[i][0])
    x[i][1]=-(-x[i][1]//a)

# どのモンスターまで倒したか管理しながら進める。
ans=0
i=0
k=0
while i<=n-1:
    if x[i][1]>=1:
        w=x[i][1]
        ans+=w
        q=bisect.bisect_right(y,x[i][0]+2*d,i,n)
        flag=True
        for j in range(q-i):
            if x[i+j][1]<=0:
                if flag:
                    k+=1
            else:
                x[i+j][1]-=w
                flag=False
    i=i+k
    k=0
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
import collections
from collections import deque
n,d,a= map(int, input().split())
x= [list(map(int, input().split())) for i in range(n)]

x.sort()
y=[]
for i in range(n):
    y.append(x[i][0])
    x[i][1]=-(-x[i][1]//a)

# どのモンスターまで倒したか管理しながら進める。
# 累積ダメージを管理
qq=deque([])
ans=0
atk=0
for i in range(n):
    w=x[i][1]
    # iがダメージの有効期限を超過している場合
    while len(qq)>0 and i > qq[0][0]:
        atk-=qq[0][1]
        qq.popleft()

    if w-atk>0:
        ans+=w-atk
        q=bisect.bisect_right(y,x[i][0]+2*d)-1
        # 有効期限　ダメージ
        qq.append([q,w-atk])
        atk += w - atk
print(ans)
### BUGGY CODE ###

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

A.insert(0,0)
A.append(0)
_A = []
for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
allS = sum(_A)


for i in range(0,N):
  allS = sum(_A)
  allS -= (_A[i]+_A[i+1])
  allS += abs(A[i+2]-A[i])
  print(allS)

### FIXED CODE ###

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

A.insert(0,0)
A.append(0)
_A = []

for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
S = sum(_A)


for i in range(0,N):
  allS = S
  allS -= (_A[i]+_A[i+1]-abs(A[i+2]-A[i]))
  print(allS)
### BUGGY CODE ###

a=int(input())
l=[a]
b=True
i=1
while b==True:
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a in l:
    b==False
    print(i+1)
    exit
  else:
    l.append(a)
    i+=1
   
  
    

### FIXED CODE ###

a=int(input())
l=[a]
b=True
i=1
while b==True:
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a in l:
    b=False
    print(i+1)
    exit
  else:
    l.append(a)
    i+=1
### BUGGY CODE ###

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

def main():
    h, w = map(int, input().split())

    a = [input()[:-1] for i in range(h)]

    already = [[False]*w for i in range(h)]
    key = deque([])
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                if not key:
                    judge = (i, j)
                key.append((i, j))
                already[i][j] = True
    
    ans = -1
    way = [(-1, 0), (1, 0), (0, 1), (0, -1)]
    change = False
    while key:
        value = key.popleft()
        if value == judge:
            ans += 1
            judge = value
            change = True
        i, j = value
        for x, y in way:
            p, q = i+x, j+y
            if 0 <= p < h and 0 <= q < w  and not already[p][q]:
                already[p][q] = True
                key.append((p, q))
                if change:
                    judge = (p, q)
                    change = False

    print(ans)







    
if __name__ == "__main__":
    main()



### FIXED CODE ###

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

def main():
    h, w = map(int, input().split())

    a = [input()[:-1] for i in range(h)]

    already = [[False]*w for i in range(h)]
    key = deque([])
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                if not key:
                    judge = (i, j)
                key.append((i, j))
                already[i][j] = True
    
    ans = -1
    way = [(-1, 0), (1, 0), (0, 1), (0, -1)]
    change = False
    while key:
        value = key.popleft()
        if value == judge:
            ans += 1
            judge = value
            change = True
        i, j = value
        for x, y in way:
            p, q = i+x, j+y
            if 0 <= p < h and 0 <= q < w  and not already[p][q]:
                already[p][q] = True
                key.append((p, q))
                if change:
                    judge = (p, q)
                    change = False

    print(ans)







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

from collections import deque

N,M,K=map(int,input().split())
A={i:set() for i in range(1,N+1)}
for _ in range(M):
    a,b=map(int,input().split())
    A[a].add(b)
    A[b].add(a)

C={i:set() for i in range(1,N+1)}
for _ in range(K):
    c,d=map(int,input().split())
    C[c].add(d)
    C[d].add(c)

T={i:False for i in range(1,N+1)}
def Connected_Component(v):
    S=deque([v])
    T[v]=True
    q=1
    D=[]
    while S:
        w=S.pop()
        D.append(w)
        for u in [u for u in A[w] if not T[u]]:
            q+=1
            T[u]=True
            S.append(u)

    return D

s=0
F=[0]*(N+1)
E=[]
for v in range(1,N+1):
    if not T[v]:
        B=Connected_Component(v)
        E.append(set(B))
        for x in B:
            F[x]=s
        s+=1

P=[]
for i in range(1,N+1):
    c=F[i]
    P.append(str(len(E[c]-(A[i]|C[i]|{i}))))
print(" ".join(P))


### FIXED CODE ###

class Union_Find():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

A=[set() for _ in range(N+1)]
U=Union_Find(N+1)
for _ in range(M):
    a,b=map(int,input().split())
    A[a].add(b)
    A[b].add(a)
    U.union(a,b)

C=[set() for _ in range(N+1)]
for _ in range(K):
    c,d=map(int,input().split())
    C[c].add(d)
    C[d].add(c)

S=[]
for k in range(1,N+1):
    t=U.size(k)
    for a in C[k]:
        if U.find(a)==U.find(k):
            t-=1

    t-=len(A[k])
    S.append(t-1)

print(" ".join(map(str,S)))
### BUGGY CODE ###

def main():
    s = input()
    t = input()

    if not set(t) <= set(s):
        print(-1)
        return

    s_indexes = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
    for i, s_c in enumerate(s):
        s_indexes[s_c].append(i)
    s_pointer = {c: 0 for c in "abcdefghijklmnopqrstuvwxyz"}
    s_length = {c: len(s_indexes[c]) for c in "abcdefghijklmnopqrstuvwxyz"}

    power = 0
    last_index = -1
    for i, t_c in enumerate(t):
        if s_length[t_c] <= s_pointer[t_c]:
            # reset
            s_pointer = {c: 0 for c in "abcdefghijklmnopqrstuvwxyz"}
            power += 1
        elif s_indexes[t_c][s_pointer[t_c]] <= last_index:
            for i, index in enumerate(s_indexes[t_c]):
                if last_index < index:
                    s_pointer[t_c] = i
                    break
            else:
                # reset
                s_pointer = {c: 0 for c in "abcdefghijklmnopqrstuvwxyz"}
                power += 1

        last_index = s_indexes[t_c][s_pointer[t_c]]
        s_pointer[t_c] += 1

    print(len(s) * power + last_index + 1)


main()


### FIXED CODE ###

def main():
    s = input()
    t = input()

    if not set(t) <= set(s):
        print(-1)
        return

    s_indexes = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
    for i, s_c in enumerate(s):
        s_indexes[s_c].append(i)
    s_pointer = {c: 0 for c in "abcdefghijklmnopqrstuvwxyz"}
    s_length = {c: len(s_indexes[c]) for c in "abcdefghijklmnopqrstuvwxyz"}

    power = 0
    last_index = -1
    for i, t_c in enumerate(t):
        if s_length[t_c] <= s_pointer[t_c]:
            # reset
            s_pointer = {c: 0 for c in "abcdefghijklmnopqrstuvwxyz"}
            power += 1
        elif s_indexes[t_c][s_pointer[t_c]] <= last_index:
            for j in range(s_pointer[t_c], s_length[t_c]):
                if last_index < s_indexes[t_c][j]:
                    s_pointer[t_c] = j
                    break
            else:
                # reset
                s_pointer = {c: 0 for c in "abcdefghijklmnopqrstuvwxyz"}
                power += 1

        last_index = s_indexes[t_c][s_pointer[t_c]]
        s_pointer[t_c] += 1

    print(len(s) * power + last_index + 1)


main()
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, [input() for _ in range(m)]))

dp = [0] * (n+1)
# 0段目と1段目は1通り（但し、１段目が壊れていない場合）（0 段目は「なにもしない」という から1 通り）
dp[:2] = 1, 1 if 1 not in a else 0 

for i in range(2, n+1):
    if i in a:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2])

print(dp[-1] % (10**9+7))

### FIXED CODE ###

n, m = map(int, input().split())
a = set(map(int, [input() for _ in range(m)]))

dp = [0] * (n+1)
# 0段目と1段目は1通り（但し、１段目が壊れていない場合）（0 段目は「なにもしない」という から1 通り）
dp[:2] = 1, 1 if 1 not in a else 0 

for i in range(2, n+1):
    if i in a:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2])

print(dp[-1] % (10**9+7))
### BUGGY CODE ###

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

for a in A:
    ans = ans*a

if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

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

if min(A)==0:
    print(0)
else:
    ans = 1
    for a in A:
        if ans * a > 10**18:
            ans=-1
            break
        else:
            ans = ans*a
    print(ans)
### BUGGY CODE ###

import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

K = ri()
S = rs()

class CombMod:
    def __init__(self, N):
        self.fact = [1]
        self.rfact = [1]
        for i in range(1, N+1):
            self.fact.append(self.fact[i-1]*i % mod)
            self.rfact.append(pow(self.fact[i], mod-2, mod))

    def comb(self, n, k):
        return self.fact[n]*self.rfact[k]*self.rfact[n-k] % mod

N = len(S)
cm = CombMod(K+N)

ans = 0
for i in range(K+1):
	ans += cm.comb(K+N-i-1, N-1) * pow(26, i, mod) * pow(25, K-i, mod)
	ans = ans % mod
print(ans)


### FIXED CODE ###

import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

K = ri()
S = rs()

class CombMod:
    def __init__(self, N):
        self.fact = [1]
        self.rfact = [1]
        for i in range(1, N+1):
            self.fact.append(self.fact[i-1]*i % mod)
            self.rfact.append(pow(self.fact[i], mod-2, mod))

    def comb(self, n, k):
        return self.fact[n]*self.rfact[k]*self.rfact[n-k] % mod

N = len(S)
cm = CombMod(K+N)

pows = [1]
pows2 = [1]
p = 1
p2 = 1
for i in range(K+1):
	p = (p * 25) % mod
	p2 = (p2 * 26) % mod
	pows.append(p)
	pows2.append(p2)
#print(pows)
ans = 0
for i in range(K+1):
	#ans += cm.comb(K+N-i-1, N-1) * pow(26, i, mod) * pow(25, K-i, mod)
	ans += cm.comb(K+N-i-1, N-1) * pows2[i] * pows[K-i]
	ans = ans % mod
print(ans)
### BUGGY CODE ###

import math

n = int(input())
li = [int(x) for x in input().split()]
ans = 0
isAvailable = False
for a in li:
    if a % 2 == 0:
        isAvailable = True
        for _ in range(a):
            if a % 2 == 0:
                a /= 2
                ans += 1
if isAvailable:
    print(ans)
else:
    print(0)


### FIXED CODE ###

import math

n = int(input())
li = [int(x) for x in input().split()]
ans = 0
isAvailable = False
for a in li:
    if a % 2 == 0:
        isAvailable = True
        while(a % 2 == 0):
            a /= 2
            ans += 1
if isAvailable:
    print(ans)
else:
    print(0)
### BUGGY CODE ###

H = int(input())

cnt = 0

ans = 1
while True:
    H = int(H / 2)
    cnt += 1
    ans *= 2
    if H ==1:
        break
cnt += 1
ans *= 2

print(ans-1)



### FIXED CODE ###


H = int(input())


def iterated_power(z: int, n: int, mod=None) -> int:
    """ 繰り返し二乗法でn**kを求める（再帰処理は使わない）
    >>> p = Prime()
    >>> p.iterated_power(3, 10)
    59049
    >>> p.iterated_power(3, 10, 10)
    9
    """
    beta = bin(n)[2:]

    Z, q, t = z, 0, len(beta)
    while beta[t - q - 1] == '0':
        Z = Z * Z
        if mod is not None:
            Z = Z % mod
        q += 1
    result = Z

    for k in range(q + 1, t):
        Z = Z * Z
        if mod is not None:
            Z = Z % mod
        if beta[t - k - 1] == '1':
            result = result * Z
            if mod is not None:
                result = result % mod

    if mod is not None:
        result = result % mod

    return result


ans = iterated_power(2, H.bit_length()) - 1
print(ans)
### BUGGY CODE ###

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

s = sum(a)

ans = float('inf')
for i in range(n-1):
    x = sum(a[:i+1])
    ans = min(ans, abs(s-2*x))

print(ans)


### FIXED CODE ###

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

s = sum(a)

ans = float('inf')
x = 0
for i in range(n-1):
    x += a[i]
    ans = min(ans, abs(s-2*x))

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

N = int(input())
*A, = map(int, input().split())
X = [0]*N
X_total = sum(A)
for i in range(N):
    X[i] = X_total - 2*sum([A[j % N] for j in range(i+1, N+i, 2)])
print(*X)

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
X = [0]*N
X_total = sum(A)
A_odd = sum([A[i % N] for i in range(1, N, 2)])
A_even = sum([A[i % N] for i in range(2, N+1, 2)])
for i in range(N):
    X[i] = X_total - 2*(A_odd if i % 2 == 0 else A_even)
    if i % 2 == 0: A_odd += A[i] - A[(i+1) % N]
    else: A_even += A[i] - A[(i+1) % N]
print(*X)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
c = sorted(a,reverse=True)
if a.count(max(a))>1:
    for i in range(n):
        print(max(a))
else:
    for i in range(n):
        if i==a.index(max(a)):
            print(c[1])
        else:
            print(max(a))
    

    

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
c = sorted(a,reverse=True)
b = max(a)
if a.count(b)>1:
    for i in range(n):
        print(b)
    exit()
for i in a:
    if i==b:
        print(c[1])
    else:
        print(b)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())

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

cnt = 0
for i in range(N):
  if min(a_list[:i+1]) >= a_list[i]:
    cnt += 1
    
print(cnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

cnt = 0
min_a  = 10 ** 9
for i in range(N):
  min_a  =  min(min_a,a_list[i])
  if min_a >= a_list[i]:
    cnt += 1
    
print(cnt)
### BUGGY CODE ###

a,b,n = map(int, input().split())
ans = 0

yuka = lambda a,b: (a-(a%b))//b

for x in range(b):
  if x>n:
    break
  score = yuka(a*(x%b),b)
  ans = max(ans,score)

print(ans)

### FIXED CODE ###

a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

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

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

ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        ans += A[i] * A[j]

print(ans % 1000000007)

### FIXED CODE ###

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

S = sum(A)
S_2 = sum(map(lambda x: x*x, A))

ans = (S*S - S_2)//2 #切り捨て除算にしないと結果をfloatで返してきやがるので

print(ans%(10**9 + 7))
### BUGGY CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7
def cmb(n,k,p):
    x,y = 1,1
    for i in range(k):
        x=x*(n-i)%p
        y=y*(i+1)%p
    return x*pow(y,p-2,p)%p

N,K = I()
A = l()
A.sort()
ans = 0
for i in range(N-K+1):
    ans -= A[i]*cmb(N-i-1,K-1,mod)
    ans %= mod
A = A[::-1]
for i in range(N-K+1):
    ans += A[i]*cmb(N-i-1,K-1,mod)
    ans %= mod
print(ans%mod)


### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod=10**9+7
MAX=10**5+100
g1=[1,1]
g2=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(pow(num_1,mod-2,mod))
def cmb(n,r):
    return g1[n]*g2[r]*g2[n-r]%mod

N,K = I()
A = l()
A.sort()
ans = 0
for i in range(N-K+1):
    ans -= A[i]*cmb(N-i-1,K-1)
    ans %= mod
A = A[::-1]
for i in range(N-K+1):
    ans += A[i]*cmb(N-i-1,K-1)
    ans %= mod
print(ans%mod)
### BUGGY CODE ###

k=int(input())

s=7

cnt=1
m=0
while(1):
  t=s%k
  if t==0:
    print(cnt)
    break
  else:
    s=t*10 + 7

  if cnt==1:
    m=t

  elif m==t:
    print("-1")
    break
  cnt+=1


### FIXED CODE ###

k=int(input())

s=7
cnt=1
m=0

while(1):

  t=s%k
  if m==0 and t!=s:
    m=t
  elif m==t:
    print("-1")
    break

  if t==0:
    print(cnt)
    break
  else:
    s=t*10 + 7

  cnt+=1
### BUGGY CODE ###

import math

def cal(N):
    num=math.ceil(N**0.5)
    num=int(num)
    for i in range(num,N+1):
       if N%i==0:
           x=len(str(i))
           break
    return x

print(cal(int(input())))

### FIXED CODE ###

def cal(N):
    num=(N**0.5)//1
    num=int(num)
    for i in range(num,0,-1):
       if N%i==0:
           k=int(N/i)
           x=len(str(k))
           break
    return x

print(cal(int(input())))
### BUGGY CODE ###

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

for i in range(K):
    cum_sum = np.array([0]*N)
    for j in range(N):
        left = max(0, j - A[j])
        right = min(N-1, j+A[j])
        cum_sum[left] += 1
        if right + 1 < N:
            cum_sum[right+1] -= 1
    A[0] = cum_sum[0]
    for j in range(N-1):
        cum_sum[j+1] += cum_sum[j]
        A[j+1] = cum_sum[j+1]

    if A[0] == N and A[N-1] == N:
        break
    
        
for i in range(N):
    print(A[i], " ", end = "")
print()


### FIXED CODE ###

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


for i in range(min(K, 42)):
    cum_sum = [0]*N
    for j in range(N):
        left = max(0, j - A[j])
        right = min(N-1, j+A[j])
        cum_sum[left] += 1
        if right + 1 < N:
            cum_sum[right+1] -= 1
    A[0] = cum_sum[0]
    for j in range(N-1):
        cum_sum[j+1] += cum_sum[j]
        A[j+1] = cum_sum[j+1]
    
        
for i in range(N):
    print(A[i], " ", end = "")
print()
### BUGGY CODE ###

n, k = map(int, input().split())
memo = [1 for i in range(n)]
a = list(map(int, input().split()))
for i in range(k, n+1, 1):
    for j in range(i-k, i, 1):
        memo[i-1] *= a[j]
for i in range(k, n, 1):
    if memo[i-1] < memo[i]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i-k] < a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
finish = [False] * N
As, Bs = [], []
for i in range(N):
    a,b = map(int, input().split())
    As.append((a,b,i))
    Bs.append((b,a,i))
from operator import itemgetter
cnt = 0
As = sorted(As, key=itemgetter(0,1),reverse=True)
Bs = sorted(Bs, key=itemgetter(0,1),reverse=True)

p_a = 0
p_b = 0
while sum(finish)<N:
    # 高橋くんのターン
    while True:
        a,_,i = As.pop()
        if not finish[i]:
            p_a += a
            finish[i] = True
            cnt += 1
            break
    # 青木
    while True and cnt < N:
        b,_,i = Bs.pop()
        if not finish[i]:
            p_b += b
            finish[i] = True
            cnt += 1
            break
    # print(cnt,p_a,p_b)

print(p_a-p_b)


### FIXED CODE ###

N = int(input())
ABs = []
sum_B = 0
for i in range(N):
    a,b = map(int, input().split())
    ABs.append(a+b)
    sum_B += b 
ABs.sort(reverse=True)
ans = sum(ABs[::2])-sum_B
print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
f = 0
for i in range(Q):
  Query = input().split()
  if Query[0] == '1':
    f = 1 - f
  else:
    if int(Query[1]) - f == 1:
      S = Query[2] + S
    else:
      S = S + Query[2]
if f == 0:
  print(S)
else:
  print(S[::-1])

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
d = 0 # d=0:right, d=1:left
for i in range(Q):
  I = list(input().split())
  if I[0] == "1":
    d ^= 1
  else:
    if d + int(I[1]) == 2:
      S.append(I[2])
    else:
      S.appendleft(I[2])
if d == 1:
  S.reverse()
for s in S:
  print(s, end="")
print()