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

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

def solve(S, query):
    for q in query:
        command = q.split()
        T = int(command[0])
        if T == 1:
            S = S[::-1]
        elif T == 2:
            F = int(command[1])
            C = command[2]
            if F == 1:
                S = C + S
            elif F == 2:
                S += C
    return S


def main():
    S = input()
    Q = int(input())
    query = [input() for n in range(Q)]
    print(solve(S, query))


if __name__ == '__main__':
    main()


### FIXED CODE ###

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

def main():
    S = input()
    Q = int(input())
    flag = False
    head = []
    tail = []
    for n in range(Q):
        query = input()
        if query[0] == '1':
            flag = not flag
        elif query[0] == '2':
            command = query.split()
            F = int(command[1])
            C = command[2]
            if (not flag and F == 1) or (flag and F == 2):
                head.append(C)
            else:
                tail.append(C)
    result = ''.join(reversed(head)) + S + ''.join(tail)
    if flag:
        result = result[::-1]
    print(result)


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

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

BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
    
cards = A[:]
cards  =sorted(cards)

opes = BC[:]
opes = sorted(opes, reverse=True, key=lambda x: x[1])

#print(cards)
#print(opes)

top_list = []
for b, c in opes:
    top_list += [c] * b
    
#print(top_list)

for i, x in enumerate(top_list):
    if cards[i] < x:
        cards[i] =  x
    else:
        break
ans = sum(cards)
print(ans)

            


### FIXED CODE ###

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

BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
    
cards = A[:]
opes = BC[:]

cards_dict = {}

for c in cards:
    if c in cards_dict:
        cards_dict[c] += 1
    else:
        cards_dict[c] = 1

for b, c in opes:
    if c in cards_dict:
        cards_dict[c] += b
    else:
        cards_dict[c] = b
        
cards_dict = sorted(cards_dict.items(), reverse=True)
#print(cards_dict)

num = 0
ans = 0
for k, v in cards_dict:
    if num + v > N:
        ans += k * (N-num)
        num = N
    else:
        ans +=  k * v
        num += v
    if num == N:
        break
        
print(ans)
### BUGGY CODE ###

import sys
n,a,b=map(int,input().split())
count=0
if a==0:
  print('0')
  sys.exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    elif n<b:
      n=0
ball=a*count+n
print(ball)

### FIXED CODE ###

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

kosuu=n//(a+b)
amari=n%(a+b)

if a>amari:
  print(a*kosuu+amari)
else:
  print(a*kosuu+a)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l,r = map(int, input().split())
    print(S[l-1:r].count('AC'))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])
### BUGGY CODE ###

import sys
import bisect
input=sys.stdin.readline

def ci(c):
  return "abcdefghijklmnopqrstuvwxyz".find(c)

N=int(input())
S=[ci(c) for c in str(input())]+[0]
Q=int(input())

C=[[0]*26 for _ in range(N+1)]
for i in range(N):
  for j in range(26):
    C[i][j]=C[i-1][j]
  C[i][S[i]]+=1

L=list()

for i in range(Q):
  t,x,y=input().split()
  if t=='1':
    L.append([int(x)-1,ci(y)])
  else:
    t,l,r=0,int(x)-1,int(y)-1
    c=[0]*26
    for x,j in L:
      if l<=x and x<=r:
        c[j]+=1
        c[S[x]]-=1
    for j in range(26):
      if C[r][j]-C[l-1][j]+c[j]>0:
        t+=1
    print(t)


### FIXED CODE ###

import bisect

N=int(input())
S=list(str(input()))

def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x)

d=[[] for _ in range(26)]
for i,s in enumerate(S):
  d[ci(s)].append(i)

for i in range(int(input())):
  t,x,y=input().split()
  if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c)
### BUGGY CODE ###

h,w = map(int,input().split())
S = [(input()+'#') for i in range(h)]+['#'*(w+1)]
Rows = []
Columns = []
for i in range(h):
    Row = []
    row = 0
    for j in range(w+1):
        if S[i][j] == '.':
            row += 1
        else:
            if row > 0:
                Row += [row]
            row = 0
            Row += [row]
    Rows += [Row]
for j in range(w):
    Column = []
    column = 0
    for i in range(h+1):
        if S[i][j] == '.':
            column += 1
        else:
            if column > 0:
                Column += [column]
            column = 0
            Column += [column]
    Columns += [Column]
mRows = []
mColumns = []
for i in range(h):
  mRow= []
  for j in range(len(Rows[i])):
    mRow += [Rows[i][j]]*max(1,Rows[i][j])
  mRows += [mRow]
for i in range(w):
  mColumn= []
  for j in range(len(Columns[i])):
    mColumn += [Columns[i][j]]*max(1,Columns[i][j])
  mColumns += [mColumn]
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans,mRows[i][j]+mColumns[j][i]-1)
print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
S = [(input()+'#') for i in range(h)]+['#'*(w+1)]
Rows = []
Columns = []
for i in range(h):
    Row = []
    row = 0
    for j in range(w+1):
        if S[i][j] == '.':
            row += 1
        else:
            if row > 0:
                Row += [row]
            row = 0
            Row += [row]
    Rows += [Row]
for j in range(w):
    Column = []
    column = 0
    for i in range(h+1):
        if S[i][j] == '.':
            column += 1
        else:
            if column > 0:
                Column += [column]
            column = 0
            Column += [column]
    Columns += [Column]
mRows = []
mColumns = []
for i in range(h):
  mRow= []
  for j in range(len(Rows[i])):
    mRow += [Rows[i][j]]*max(1,Rows[i][j])
  mRows += [mRow]
for i in range(w):
  mColumn= []
  for j in range(len(Columns[i])):
    mColumn += [Columns[i][j]]*max(1,Columns[i][j])
  mColumns += [mColumn]
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans,mRows[i][j]+mColumns[j][i]-1)
print(ans)
### BUGGY CODE ###

K, S = map(int, input().split())
cnt = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if X + Y > S:
            break
        elif Z > K:
            continue
        else:
            if X + Y + Z == S:
                cnt +=1
print(cnt)

### FIXED CODE ###

K, S = map(int, input().split())
cnt = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if 0<=Z and Z<=K:
            cnt +=1

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

from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
count = 0
for i in range(n):
    if q[0] < p[i]:
        q.popleft()
        q.append(p[i])
        count = max(count, sum(q))
    else:
        q.popleft()
        q.append(p[i])
if count % 2 == 0:
    print(ex_even(count) + 0.5*(k-1))
else:
    print(ex_odd(count) + 0.5*(k-1))

### FIXED CODE ###

n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
s = sum(p[0:k])
s_max = sum(p[0:k])
for i in range(n-k):
    s = s-p[i] + p[i+k]
    s_max = max(s_max,s)
if s_max % 2 == 0:
    print(ex_even(s_max) + 0.5*(k-1))
else:
    print(ex_odd(s_max) + 0.5*(k-1))
### BUGGY CODE ###

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


### FIXED CODE ###

input()
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    quit()
else:
    prod = 1
    for a in A:
        prod*=a
        if prod > 10**18:
            print(-1)
            quit()
    print(prod)
### BUGGY CODE ###

import numpy as np

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

A.append(K + A[0])

diff = np.diff(A).tolist()

min_ = sum(diff)
for i in range(len(diff)):
  diff_ = diff[:]
  diff_.remove(diff[i])
  if min_ > sum(diff_):
    min_ = sum(diff_)

print(min_)  

### FIXED CODE ###

import numpy as np

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

A.append(K + A[0])

diff = np.diff(A).tolist()
diff = sorted(diff)

print(sum(diff[:-1]))
### BUGGY CODE ###

n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)
x_sub = []

if n >= m:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1) ]
    
    for i in range(n-1):
        x_sub.remove(max(x_sub))
    
    print(sum(x_sub))

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))
### BUGGY CODE ###

from collections import deque

def argmax_poss(a):
    if len(a) == 0:
        return []
    all_ = [0]
    max_ = a[0]
    for i in range(1, len(a)):
        if a[i] > max_:
            all_ = [i]
            max_ = a[i]
        elif a[i] == max_:
            all_.append(i)
    return all_

h,w,m = map(int,input().split())
Ms = []

h_scores = [0 for i in range(h)]
w_scores = [0 for i in range(w)]

record = set()

for i in range(m):
  h,w = map(int,input().split())
  record.add((h-1,w-1))
  h_scores[h-1] += 1
  w_scores[w-1] += 1

max_h_poss = argmax_poss(h_scores)
max_w_poss = argmax_poss(w_scores)

out_pos_count = 0 

c = False

for i in max_h_poss:
    for j in max_w_poss:
        if (i,j) not in record:
            c = True        

if c:
    print(max(h_scores) + max(w_scores))
else:
    print(max(h_scores) + max(w_scores)-1)



### FIXED CODE ###

from collections import deque

h,w,m = map(int,input().split())
Ms = []

h_scores = [0 for i in range(h)]
w_scores = [0 for i in range(w)]

record = set()

for i in range(m):
  h,w = map(int,input().split())
  record.add((h-1,w-1))
  h_scores[h-1] += 1
  w_scores[w-1] += 1

max_h = max(h_scores)
max_w = max(w_scores)
max_h_poss = [i for i,v in enumerate(h_scores) if v == max_h]
max_w_poss = [i for i,v in enumerate(w_scores) if v == max_w]

out_pos_count = 0 

c = False

for i in max_h_poss:
    for j in max_w_poss:
        if (i,j) not in record:
            c = True
            break        

if c:
    print(max(h_scores) + max(w_scores))
else:
    print(max(h_scores) + max(w_scores)-1)
### BUGGY CODE ###

def main():
    l = set([str(i*2019) for i in range(1, 101)])
    S = input()
    ans = 0
    for i in range(len(S)):
        for j in range(i+1, len(S)):
            if S[i:j+1] in l:
                ans += 1
    print(ans)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import defaultdict

def main():
    S = input()
    d = defaultdict(int)
    d[0] = 1

    num = 0
    for digit, c in enumerate(S[::-1]):
        num += int(c) * pow(10, digit, 2019)
        num %= 2019
        d[num] += 1
    ans = sum([d[i]*(d[i]-1)//2 for i in range(2019)])
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N=int(input())
S=[input() for i in range(N)]

count=0
s=[]
for i in range(N):
  if(S[i] not in s):
    count+=1
    s.append(S[i])
print(count)

### FIXED CODE ###

N=int(input())
S=[input() for i in range(N)]
S.sort()
count=1
s=[]
for i in range(N-1):
  if(S[i]!=S[i+1]):
    count+=1
print(count)
### BUGGY CODE ###

#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = 0
for i in range(M-N):
  sum_ += min(koma)
  koma.remove(min(koma))
print(sum_)



### FIXED CODE ###

#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))
### BUGGY CODE ###

def ma():
    return map(int,input().split())
y="Yes"
t="No"
n,k=ma()
A=list(ma())
ans=[]
now=1
while True:
    ans.append(now)
    now=A[now-1]
    if now in ans:
        use=ans.index(now)
        tool=len(ans)-use
        break 

if use>=k:
    print(ans[k])
    exit()
else:
    p=(k-use)%tool
    print(ans[use+p])

### FIXED CODE ###

def ma():
    return map(int,input().split())
def main():
    n,k=ma()
    A=list(ma())
    ans=[]
    exp=[0]*(n+1)
    now=1
    
    while True:
        ans.append(now)
        exp[now]=1
        now=A[now-1]
        if exp[now]==1:
            use=ans.index(now)
            tool=len(ans)-use
            break 

    if use>=k:
        print(ans[k])
        exit()
    else:
        p=(k-use)%tool
        print(ans[use+p])

main()
### BUGGY CODE ###

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

ans=1

for i in range(N):
    ans=ans*A[i]
    
if ans>10**18:
    ans=-1
print(ans)

### FIXED CODE ###


import sys

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

A.sort()
A.reverse()

if A[N-1]==0:
    print(0)
    sys.exit()
ans=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)
### BUGGY CODE ###

n = int(input())
c = [list(map(int, input().split())) for _ in range(n-1)]

def tr(s,n):
    time = c[s-1][1] + c[s-1][0]
    for j in range(s,n-1):
        for i in range (0,100000):
            if (time <= c[j][1]+c[j][2]*i):
                time = c[j][1]+c[j][2]*i+c[j][0]
                break
    return time

ans = []
for k in range(1,n):
    ans.append(tr(k,n))
ans.append(0)
print(*ans, sep='\n')

### FIXED CODE ###

n = int(input())
c = [list(map(int, input().split())) for _ in range(n-1)]

def tr(s,n):
    time = c[s-1][1] + c[s-1][0]
    for j in range(s,n-1):
        if (time <= c[j][1]):
            time = c[j][1]+c[j][0]
        else:        
            a = (time - c[j][1]) // c[j][2]
            if ((time - c[j][1])%c[j][2] != 0):
                a = a+1
            time = c[j][1]+c[j][2]*(a)+c[j][0]
    return time

ans = []
for k in range(1,n):
    ans.append(tr(k,n))
ans.append(0)
print(*ans, sep='\n')
### BUGGY CODE ###

def abc177_c_1():
    n = int(input())
    a = list(map(int, input().split(' ')))

    mod = 10 ** 9 + 7
    ans = 0

    for i in range(n - 1):
        ans += (a[i] * sum(a[i + 1:])) % mod

    ans = ans % mod
    print(ans)

if __name__ == '__main__':
    abc177_c_1()

### FIXED CODE ###

def abc177_c_2():
    n = int(input())
    a = list(map(int, input().split(' ')))

    mod = 10 ** 9 + 7
    ans = 0
    x = 0

    for i in range(n):
        ans = (ans + a[i] * x) % mod
        x = (x + a[i]) % mod

    print(ans)

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

k = int(input())

l = int(0)
if k % 7 == 0:
    l = 9 * k // 7
else:
    l = 9 * k

for i in range(1, l + 1):
    m = pow(10, i, l)
    if m == 1:
        print(i)
        break
else:
    print(-1)


### FIXED CODE ###

from numba import njit
k = int(input())

l = 0
if k % 7 == 0:
    l = 9 * k // 7
else:
    l = 9 * k

@njit
def fun():
    m = 1
    for i in range(1, l + 1):
        m = m * 10 % l
        if m == 1:
            print(i)
            break
    else:
        print(-1)

fun()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

h, w, d = map(int, input().split())
n = h*w
a = [0]*n
for i in range(h):
    t = list(map(int, input().split()))
    for j in range(w):
        a[w*i+j] = t[j]-1

def dist(i, j):
    dh = abs(i//w - j//w)
    dw = abs(i%w - j%w)
    return dh + dw

idx_list = [a.index(i) for i in range(n)]
dist_list = [0]*n
for i in range(n):
    if i < d:
        dist_list[i] = 0
    else:
        dist_list[i] = dist_list[i-d] + dist(idx_list[i-d], idx_list[i])

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    l-=1; r-=1
    print(dist_list[r] - dist_list[l])



### FIXED CODE ###

import sys
input = sys.stdin.readline

h, w, d = map(int, input().split())
n = h*w
a = [0]*n
for i in range(h):
    t = list(map(int, input().split()))
    for j in range(w):
        a[w*i+j] = t[j]-1

def dist(i, j):
    dh = abs(i//w - j//w)
    dw = abs(i%w - j%w)
    return dh + dw

idx_list = [0] * n
for i in range(n):
    idx_list[a[i]] = i

dist_list = [0]*n
for i in range(n):
    if i < d:
        dist_list[i] = 0
    else:
        dist_list[i] = dist_list[i-d] + dist(idx_list[i-d], idx_list[i])

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    l-=1; r-=1
    print(dist_list[r] - dist_list[l])
### BUGGY CODE ###

import collections, itertools

h, w, m = map(int,input().split())

h_list = list()
w_list = list()

targets = list()

for _ in range(m):
    temp_h, temp_w, = map(int,input().split())

    h_list.append(temp_h)
    w_list.append(temp_w)

    targets.append((temp_h, temp_w))

num_dict_h = dict(collections.Counter(h_list))
num_dict_w = dict(collections.Counter(w_list))

h_candidates = [k for k, v in num_dict_h.items() if v == max(num_dict_h.values())]
w_candidates = [k for k, v in num_dict_w.items() if v == max(num_dict_w.values())]

for temp_h, temp_w in itertools.product(h_candidates, w_candidates):
    if not ((temp_h, temp_w) in targets):
        print(num_dict_h[temp_h] + num_dict_w[temp_w])
        break
else:
    print(num_dict_h[temp_h] + num_dict_w[temp_w] - 1)

### FIXED CODE ###

h, w, m = map(int,input().split())

h_dict = dict()
w_dict = dict()

targets = list()

for i in range(m):
    temp_h, temp_w, = map(int,input().split())

    h_dict[temp_h] = h_dict.get(temp_h, default=0) + 1
    w_dict[temp_w] = w_dict.get(temp_w, default=0) + 1

    targets.append((temp_h, temp_w))

h_dict_values = list(h_dict.values())
w_dict_values = list(w_dict.values())

max_h = max(h_dict_values)
max_w = max(w_dict_values)

nh = h_dict_values.count(max_h)
nw = w_dict_values.count(max_w)

x = 0

for i in range(m):
    temp_h, temp_w = targets[i]
    if h_dict[temp_h]==max_h and w_dict[temp_w]==max_w:
        x += 1

ans = max_h + max_w

if x == nh * nw:
    ans -= 1

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

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

import itertools

def mostProperComb(childs, x):
    if sum([c[1] for c in childs]) > x:
        print("IMPOSSIBLE")
        exit()

    max_a, min_b = 0, 0
    for code in itertools.product([True, False], repeat=len(childs)):
        a, b = 0, 0
        for j, bool in enumerate(code):
            if bool:
                a += childs[j][1]
                b += childs[j][0]
            else:
                a += childs[j][0]
                b += childs[j][1]
        if a >= max_a and x >= a:
            max_a, min_b = a, b
            if max_a == x:
                break

    return (max([x, min_b]), min([x, min_b]))


n = int(input())

p_list = [0] + list(map(int, input().split()))
x_list = list(map(int, input().split()))
c_list = [[] for i in range(n)]

if n == 1:
  print("POSSIBLE")
  exit()

for i in range(n):
    index = n-1-i

    if len(c_list[index]) == 0:
        c_list[index] = (x_list[index], 0)
        c_list[p_list[index]-1].append(index)
    else:
        childs = [c_list[child_index] for child_index in c_list[index]]
        c_list[index] = mostProperComb(childs, x_list[index])
        if not p_list[index] == 0:
            c_list[p_list[index]-1].append(index)

print("POSSIBLE")


### FIXED CODE ###

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

import itertools


def mostProperComb(childs, x):
    tmp_sum = sum([c[1] for c in childs])
    if tmp_sum > x:
        print("IMPOSSIBLE")
        exit()

    total = tmp_sum + sum([c[0] for c in childs])

    sset = set([tmp_sum])
    for child in childs:
        rest = child[0] - child[1]
        tmp_set = set(sset)
        for s in sset:
            if s + rest <= x:
                tmp_set.add(s+rest)
        sset = tmp_set

    return (tuple(sorted([x, total-max(sset)], reverse=True)))


n = int(input())

p_list = [0] + list(map(int, input().split()))
x_list = list(map(int, input().split()))
c_list = [[] for i in range(n)]

if n == 1:
    print("POSSIBLE")
    exit()

for i in range(n):
    index = n-1-i

    if len(c_list[index]) == 0:
        c_list[index] = (x_list[index], 0)
        c_list[p_list[index]-1].append(index)
    else:
        childs = [c_list[child_index] for child_index in c_list[index]]
        c_list[index] = mostProperComb(childs, x_list[index])
        if not p_list[index] == 0:
            c_list[p_list[index]-1].append(index)

print("POSSIBLE")
### BUGGY CODE ###

N = int(input())
A = []#生徒たちが出席した順番
students = []#生徒たちの番号
rank_sort = []#出席した順の生徒たちの番号

i = 0
for x in input().split():
    i += 1
    A.append(int(x))
    students.append(int(i))

rank = 1
n = N
for i in range(N):
    for j in range(n):
        if A[j] == rank:
            rank_sort.append(students[j])
            del A[j]
            del students[j]
            break
    rank += 1
    n -= 1
print(' '.join(map(str,rank_sort)))

### FIXED CODE ###

N = int(input())
A = []#生徒たちが出席した順番
rev = [0]*N #早く来た順の生徒の番号

for x in input().split():
    A.append(int(x))

for i in range(N):
    rev[A[i]-1] = i+1

print(' '.join(map(str,rev)))
### BUGGY CODE ###

n = []
for z in range(1, 100, 1):
    for y in range(1, 100, 1):
        for x in range(1, 100, 1):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if x ** 2 + y ** 2 + z ** 2 > 10 ** 4:
                break
            else:
                n.append(tmp)
N = int(input())
for i in range(1, N+1, 1):
    print(n.count(i))

### FIXED CODE ###

n = [0 for i in range(10001)]
for z in range(1, 100, 1):
    for y in range(1, 100, 1):
        for x in range(1, 100, 1):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if tmp > 10 ** 4:
                break
            else:
                n[tmp] += 1
N = int(input())
for i in range(1, N+1, 1):
    print(n[i])
### BUGGY CODE ###

N, K = [int(n) for n in input().split()]
q =[]
ans = 0

for p in [int(n) for n in input().split()]:
    if len(q) < K:
        q.append((p-1)/2+1)
    else:
        m = sum(q)
        if m > ans:
            ans = m
        q.append((p-1)/2+1)
        q.pop(0)
print(ans if ans>sum(q) else sum(q))


### FIXED CODE ###

N, K = [int(n) for n in input().split()]
P = [(int(n)+1)/2 for n in input().split()]
ans = sum(P[:K])
e = ans
for p,x in zip(P, P[K:]):
    e = e-p+x
    if ans < e:
        ans = e
print(ans)