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

N = int(input())
A = [int(input()) for _ in range(N)]

MAX_1 = max(A)
MAX_2 = sorted(A)[-2]

for i in range(N):
    if i == A.index(MAX_1):
        print(MAX_2)
    else:
        print(MAX_1)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

MAX_1 = max(A)
MAX_2 = sorted(A)[-2]

for i in range(N):
    if A[i] == MAX_1:
        print(MAX_2)
    else:
        print(MAX_1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

# K+1 - x でうつす -> i と 2K+2-i は同じ

MOD = 998244353
U = 10000
fact = [1] * (U+1)
fact_inv = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1] * n % MOD
fact_inv[n] = pow(fact[n], MOD-2, MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

def comb(n,k):
    if not (0 <= k <= n):
        return 0
    return fact[n] * fact_inv[k] * fact_inv[n-k] % MOD

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

def F(x,y,N):
    n = min(x, N)
    return sum(comb(x,i) * pow(2,i,MOD) * comb(N+y-1,i+y-1) for i in range(n+1)) % MOD

answer = []
for S in range(2,K+2):
    if S & 1:
        x = F((S-1)//2, K - S + 1, N)
    else:
        x = F((S-1)//2, K - S + 1, N) + F((S-1)//2, K - S + 1, N - 1)
    answer.append(x % MOD)

answer += answer[:-1][::-1]

print('\n'.join(map(str,answer)))



### FIXED CODE ###

import sys
input = sys.stdin.readline

# K+1 - x でうつす -> i と 2K+2-i は同じ

MOD = 998244353
U = 10000
fact = [1] * (U+1)
fact_inv = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1] * n % MOD
fact_inv[n] = pow(fact[n], MOD-2, MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

def comb(n,k):
    if not (0 <= k <= n):
        return 0
    return fact[n] * fact_inv[k] * fact_inv[n-k] % MOD

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

def F(x,y,N):
    n = min(x, N)
    return sum(comb(x,i) * pow(2,i,MOD) * comb(N+y-1,i+y-1) for i in range(n+1)) % MOD

answer = []
for S in range(2,K+2):
    if S & 1:
        x = F((S-1)//2, K - S + 1, N)
    else:
        x = F((S-1)//2, K - S + 1, N) + F((S-1)//2, K - S + 1, N - 1)
    answer.append(x % MOD)

answer += answer[:-1][::-1]

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

import sys
INF=100000000
def frog(i,K,h,dp):
    global INF
    if dp[i]!=INF:
        return dp[i]
    else:
        cost=INF*100
        for k in range(1,K+1):
            if i-k-1>=0:
                x=frog(i-k,K,h,dp)+abs(h[i-1]-h[i-k-1])
                if cost>x:
                    cost=x
                continue
            break
        dp[i]=cost
        return dp[i]
sys.setrecursionlimit(INF)
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[INF for i in range(N+1)]
dp[1]=0
dp[2]=abs(h[1]-h[0])
print(frog(N,K,h,dp))


### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
h=list(map(int,input().split()))
h=np.array(h)
cost=np.zeros(N+1)
cost[1]=0
cost[2]=abs(h[1]-h[0])
for i in range(3,N+1):
    x=1 if i-K<=1 else i-K
    cost[i]=(cost[x:i]+abs(h[i-1]-h[x-1:i-1])).min()
print(int(cost[N]))
### BUGGY CODE ###

S = input()
Q = int(input())
flag = 1

for i in range(Q):
    q = list(map(str, input().split()))
    if q==["1"]:
        flag *= -1
    else:
        if flag==1 and q[1]=="1":
            S = q[2]+S
        elif flag==1 and q[1]=="2":
            S += q[2]
        elif flag==-1 and q[1]=="1":
            S += q[2]
        else:
            S = q[2]+S

if flag==1:
    print(S)
else:
    ans = ""
    for i in reversed(S):
        ans += i
    print(ans)
    # print("".join(list(reversed(S))))


### FIXED CODE ###

S = input()
Q = int(input())
flag = 1
left = ""
right = ""

for i in range(Q):
    q = input().split()
    if q==["1"]:
        flag *= -1
    else:
        if flag==1 and q[1]=="1":
            left = q[2]+left
        elif flag==1 and q[1]=="2":
            right += q[2]
        elif flag==-1 and q[1]=="1":
            right += q[2]
        else:
            left = q[2]+left
# print(S)

if flag==1:
    print(left+S+right)
else:
    print(right[::-1]+S[::-1]+left[::-1])
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path
N, X, Y = map(int, input().split())

G = np.full((N, N), np.inf, dtype=float)
for i in range(N - 1):
    G[i][i + 1] = 1
    G[i + 1][i] = 1
G[X - 1][Y - 1] = 1
G[Y - 1][X - 1] = 1

G = shortest_path(G, method='D')
for cnt in range(1, N):
    print(np.sum(G == cnt) // 2)


### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] * N
for i in range(N):
    for j in range(i+1, N):
        ans[ min(j - i, abs(X - i) + 1 + abs(Y - j))] += 1
for i in range(1, N):
    print(ans[i])
### BUGGY CODE ###

import numpy as np
N, Q = map(int, input().split())
# print(N, Q)
S = input()
AC_array = np.array([
    1 if (S[i] == "A" and S[i + 1] == "C") else 0 for i in range(N - 1)
])
lr_array = [list(map(int, input().split())) for i in range(Q)]
# print(lr_array)
# print(AC_array)
ans = ""
for lr in lr_array:
    ans += str(np.sum(AC_array[lr[0]-1:lr[1]-1])) + "\n"
print(ans[:-1])

### FIXED CODE ###

N, Q = map(int, input().split())
# print(N, Q)
S = input()
lr_array = [list(map(int, input().split())) for i in range(Q)]
AC_array = []
AC_count = 0

# print(S)
for i, s in enumerate(S):
    if i == 0:
        s_old = s
        continue
    if s_old == "A" and s == "C":
        AC_count += 1
    AC_array.append(AC_count)
    s_old = s

# print(lr_array)
# print(AC_array)
ans = ""
for lr in lr_array:
    ans += str(AC_array[lr[1] - 2] -
               (AC_array[lr[0] - 2] if lr[0] > 1 else 0)) + "\n"
print(ans[:-1])
### BUGGY CODE ###

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

B = 0
for i in range(N-K+1):
    s = 1
    for j in range(K):
        s *= A[i+j]
    if B != 0 and B < s:
        print('Yes')
    elif B != 0 and B >= s:
        print('No')
    B = s




### FIXED CODE ###

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

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
### BUGGY CODE ###

n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
ans = 0
while k:
    if k & 1:
        ans = a[ans]
    a = [a[a[i]] for i in range(n)]
    k >>= 1
print(ans + 1)

### FIXED CODE ###

from copy import copy
n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
ans = 0
while k:
    if k & 1:
        ans = a[ans]
    c = [a[a[i]] for i in range(n)]
    a = copy(c)
    k >>= 1
print(ans + 1)
### BUGGY CODE ###

M=10**9+7
n,*a=map(int,open(0).read().split())
c=0
for i in range(61):
  i=2**i
  t=sum(i&b>0for b in a)
  c=(c+t*(n-t)*i)%(10**9+7)
print(c)

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
b=[0]*61
for c in a:
  for i in range(61):b[i]+=2**i&c>0
print(sum(2**i*c*(n-c)for i,c in enumerate(b))%(10**9+7))
### BUGGY CODE ###

def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    S = sum(A)

    for _ in range(q):
        b, c = map(int, input().split())
        k = A.count(b)
        A = [c if a == b else a for a in A]
        S += k * (c - b)
        print(S)

resolve()

### FIXED CODE ###

def resolve():
    from collections import defaultdict
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    S = sum(A)
    d = defaultdict(int)
    for a in A:
        d[a] += 1

    for _ in range(q):
        b, c = map(int, input().split())
        k = d[b]
        d[b] -= k
        d[c] += k
        S += k * (c - b)
        print(S)

resolve()
### BUGGY CODE ###

a,b = map(int,input().split())
c = 0
for i in range(a,b+1):
    d = bin(c ^ i)
    c = int(d,2)   
print(c)

### FIXED CODE ###

a,b = map(int,input().split())
if a % 4 == 0 and b % 4 == 0:
    print(b)
    exit()

c = []
if a % 4 != 0:
    c += list(range(a,a+(4-(a%4))))
c += list(range(b-(b%4),b+1))

e = 0
for i in c:
    d = bin(e ^ i)
    e = int(d,2)
print(e)
### BUGGY CODE ###


n = int(input())
arr = list(map(int,input().split()))
arr.sort()

cnt = {}
kouho = []
erat = set([i for i in range(n)])

for i in range(n):
    if arr[i] not in cnt:
        cnt[arr[i]] = 1
    else:
        cnt[arr[i]] += 1

    if i in erat:
        kouho.append(arr[i])

        dis = []
        for val in erat:
            if arr[val]%arr[i] == 0:
                dis.append(val)
        for d in dis:
            if len(erat) > 0:
                erat.discard(d)

    # print(erat)

# print(kouho)
ans = 0
for k in kouho:
    if cnt[k] == 1:
        ans += 1


print(ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
arr.sort()

cnt = {}
kouho = []
erat = [True for i in range(10**6+1)]

for i in range(n):
    if arr[i] not in cnt:
        cnt[arr[i]] = 1
    else:
        cnt[arr[i]] += 1
    if erat[arr[i]]:
        kouho.append(arr[i])
        tp = arr[i]
        while True:
            erat[tp] = False
            tp += arr[i]
            if tp > 10**6:
                break
# print(kouho)
ans = 0
for k in kouho:
    if cnt[k] == 1:
        ans += 1


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

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

count = 0

x = 0
y = 0
z = 0

for targetX in range(ks[1]+1):
    
    for targetY in range(ks[1]+1):
    
        for targetZ in range(ks[1]+1):
        
            if targetX <= ks[0] and targetY <= ks[0] and targetZ <= ks[0] and 0 <= targetX:
                if targetX + targetY + targetZ == ks[1]:
                
                    count +=1
            
            targetZ +=1
    
        targetY +=1
        
    targetX +=1
        

#print(ks)
print(count)


### FIXED CODE ###

ks= list(map(int, input().split())) 
 
count = 0
 
x = 0
y = 0
z = 0
 
for targetX in range(ks[0]+1):
    
    
    if targetX <= ks[0] and ks[1]-(targetX+ks[0]+ks[0]) <= 0:
    
        for targetY in range(ks[0]+1):
            
            z = ks[1] - (targetX + targetY)
            
            if 0 <= z and z <= ks[0]:
                count += 1
                
        
        
        
 
print(count)
### BUGGY CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
sec = []
cur = 1
while cur not in sec:
    sec.append(cur)
    if cur == 2:
        break
    cur = A[cur - 1]
print(len(sec) - 1 if 2 in sec else -1)

### FIXED CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
count, current = 0, 1
while current != 2:
    current = A[current - 1]
    count += 1
    if count > n:
        count = -1
        break
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math
import sys


MOD = 10 ** 9 + 7

def main():
    input = sys.stdin.readline
    N = int(input())
    S = input()
    if S[0] == 'W' or S[-1] == 'W':
        print(0)
        return

    Dc = 1
    LRsub = 1
    Pattern = 1
    for i in range(1,2*N):
        Dc = Dc if S[i] != S[i-1] else -Dc
        if Dc < 0:
           Pattern *= LRsub
        LRsub += Dc

    if LRsub == 0:
        Pattern *= math.factorial(N)
        Pattern = Pattern % MOD
        print(Pattern)
    else:
        print(0)

if __name__ == "__main__":
    main()


### FIXED CODE ###

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

MOD = 10 ** 9 + 7

N = int(input())
S = list(map(lambda x: int(x == "W"),input()))
if S[0] or S[-1]:
    print(0)
    exit(0)

Dc = 1
LRsub = 1
Pattern = 1
Sp = S[0]

for i in range(1,N*2):
    Sc = S[i]
    Dc = Dc if Sc != Sp else -Dc
    Sp = Sc
    if Dc < 0:
        Pattern = (Pattern * LRsub) % MOD
    LRsub += Dc

if LRsub == 0:
    for i in range(2,N+1):
        Pattern = (Pattern * i) % MOD
    print(Pattern)
else:
    print(0)
### BUGGY CODE ###

Max, Sum = map(int, input().split())

counter = 0
for i in range(Max+1):
  for j in range(Max+1):
    for k in range(Max+1):
      if i + j + k == Sum:
        counter += 1
 
print(counter)

### FIXED CODE ###

Max, Sum = map(int, input().split())

counter = 0
for i in range(Max+1):
  for j in range(Max+1):
    k = Sum - i -j
    if k >= 0 and k <= Max:
      counter += 1
 
print(counter)
### BUGGY CODE ###

import collections
N = int(input())
A = list(map(int,input().split()))
count_dict = collections.Counter(A)
d = []
for k,v in count_dict.items():
	d.append(k)
	d.append(k-1)
	d.append(k+1)

d = list(set(d))
ans = 0
for i in d:
	count = 0
	for j in range(N):
		if A[j] == i or A[j]+1 == i or A[j]-1 == i:
			count += 1
		ans = max(ans,count)
print(ans)

### FIXED CODE ###

import collections
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    max_a = max(a)
    count = [0 for _ in range(max_a+1)]
    c = collections.Counter(a)
    c = list(c.items())

    if len(c) == 1:
        print(c[0][1])

    elif len(c) == 2:
        if abs(c[0][0]-c[1][0]) <= 2:
            print(c[0][1]+c[1][1])
        else:
            print(max(c[0][1],c[1][1]))

    else:
        for i in range(len(c)):
            count[c[i][0]] = c[i][1]

        sum_list = [0 for _ in range(len(count)-2)]
        for i in range(len(count)-2):
            sum_list[i] = count[i]+count[i+1]+count[i+2]
        print(max(sum_list))

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

import sys
N,K=map(int,input().split())
A=sorted([int(i) for i in input().split()])
def f(x):
    y=A[x]
    if y>=K:
        return True
    L=set()
    L.add(0)
    for i in range(N):
        if i==x:
            continue
        T=set()
        s=A[i]
        for k in L:
            T.add(k)
            if k+s>=K:
                continue
            if k+s+y>=K:
                return True
            T.add(k+s)
        L=T
    return False
ma=N-1
mi=0
if not f(N-1):
    print(N)
    sys.exit()
if f(0):
    print(0)
    sys.exit()
while ma-mi>1:
    #print(ma,mi)
    a=(ma+mi)//2
    if f(a):
        ma=a
    else:
        mi=a
print(ma)



### FIXED CODE ###

import sys
N,K=map(int,input().split())
A=sorted([int(i) for i in input().split()])
sa=sum(A)
def f(x):
    y=A[x]
    if y>=K:
        return True
    L=set()
    L.add(0)
    dp=[False]*(K-y)
    dp[0]=True
    t=0
    for i in range(N):
        if i==x:
            continue
        s=A[i]
        for k in range(t,-1,-1):
            if not dp[k]:
                continue
            if k+s>=K:
                continue
            if k+s+y>=K:
                return True
            dp[k+s]=True
        t=min(t+s,K-y-1)
    return False
ma=N-1
mi=0
if not f(N-1):
    print(N)
    sys.exit()
if f(0):
    print(0)
    sys.exit()
while ma-mi>1:
    #print(ma,mi)
    a=(ma+mi)//2
    if f(a):
        ma=a
    else:
        mi=a
print(ma)
### BUGGY CODE ###

import bisect
n,m=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
a.sort()

while(m):
  m-=1
  now=a.pop()
  a.append(now//2)
  a.sort()

print(sum(a))

### FIXED CODE ###

import heapq as hp
n,m=[int(x) for x in input().rstrip().split()]
a=[-int(x) for x in input().rstrip().split()]

hp.heapify(a)
a.sort()

while(m):
  
  m-=1
  now=hp.heappop(a)
  now=-((-now)//2)
  hp.heappush(a,now)
  
print(-sum(a))
### BUGGY CODE ###

n,m = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
add = []
for _ in range(m):
    b,c = map(int,input().split())
    add += [c]*b
add.sort(reverse=True)
fin = []
#print(len(li),len(add))
if len(li)>len(add):
    fin = li[len(add):]
#print(fin)
for l,a in zip(li,add):
    #print(l,a)
    if a>l:
        fin.append(a)
    else:
        fin.append(l)
print(sum(fin))

### FIXED CODE ###

n,m = map(int,input().split())
li = list(map(int,input().split()))
tmp_li = []
for _ in range(m):
    b,c = map(int,input().split())
    tmp_li.append((c,b))
tmp_li.sort(reverse=True)
#print(tmp_li)
for c,b in tmp_li:
    li.extend([c]*b)
    if len(li)>= 2*n:
        break
li.sort(reverse=True)
print(sum(li[:n]))
### BUGGY CODE ###

import sys
# input = sys.stdin.readline
S = list(input())
p = 10 ** 9 + 7
# p = 10 ** 18

A = AB = ABC = 0
Q = 0
for i, Si in enumerate(S):
    # print("#", A, AB, ABC)
    if Si == 'A':
        A = (A + 1 * (3 ** Q)) % p
    elif Si == 'B':
        AB = (AB + A) % p
    elif Si == 'C':
        ABC = (ABC + AB) % p
    else:
        ABC = (3 * ABC + AB) % p
        AB = (3 * AB + A) % p
        #A = (3 * A + 1 * (3 ** Q)) % p
        A = (3 * A + 1 * (pow(3,Q))) % p
        Q += 1

print(ABC)


### FIXED CODE ###

S=input()
N=len(S)
mod=pow(10,9)+7
dpa=[0]*N
dpl=[0]*N
dpc=[0]*N
dpr=[0]*N
for i in range(1,N):
    if S[i-1]=='A':
        dpa[i]=dpa[i-1]+1
        dpl[i]=dpl[i-1]
    elif S[i-1]=='?':
        dpa[i]=dpa[i-1]
        dpl[i]=dpl[i-1]+1
    else:
        dpa[i]=dpa[i-1]
        dpl[i]=dpl[i-1]
for i in range(N-2,-1,-1):
    if S[i+1]=='C': 
        dpc[i]=dpc[i+1]+1
        dpr[i]=dpr[i+1]
    elif S[i+1]=='?': 
        dpc[i]=dpc[i+1]
        dpr[i]=dpr[i+1]+1
    else: 
        dpc[i]=dpc[i+1]
        dpr[i]=dpr[i+1]
ans=0 
for i in range(1,N-1):
    if S[i]=='?' or S[i]=='B':
        x=pow(3,dpl[i],mod)
        y=pow(3,max(dpl[i]-1,0),mod)
        z=pow(3,dpr[i],mod)
        w=pow(3,max(dpr[i]-1,0),mod)
        x=(x*dpa[i])%mod
        y=(y*dpl[i])%mod
        z=(z*dpc[i])%mod
        w=(w*dpr[i])%mod
        s=(x+y)%mod
        u=(z+w)%mod
        t=(s*u)%mod
        ans = (ans+t)%mod
print(ans)
### BUGGY CODE ###

from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)
ans = 1
n = 2
while g > 1:
  if g % n == 0:
    ans += 1
  while g % n == 0:
    g //= n
  n += 1
print(ans)

### FIXED CODE ###

from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)
ans = 1
n = 2
while g > 1:
  if n * n > g:
    ans += 1
    break
  if g % n == 0:
    ans += 1
  while g % n == 0:
    g //= n
  n += 1
print(ans)
### BUGGY CODE ###

n = int(input())
S = [None]*n
ans = 0

for i in range(n):
    s = input()
    s_s = ''.join(sorted(s))
    S[i] = s_s
S.sort()
for i in range(n-1):
    f = True
    F = True
    t = 1
    while F:
        for j in range(10):
            if S[i][j] != S[i+t][j]:
                f = False
                F = False
                break
        if f:
            ans += 1
            t += 1
            if t+i >= n:
                break
print(ans)

### FIXED CODE ###

n = int(input())
S = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s_s = ''.join(s)
    if s_s in S:
        ans += S[s_s]
        S[s_s] += 1
    else:
        S[s_s] = 1

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

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        for j, k in enumerate(SI()):
            if k == '#':
                S[i, j] = 1
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        l = 0
        r = 0
        for j in range(W):
            if S[i, j] == 1:
                l = 0
            else:
                l += 1
            L[i, j] = l
            if S[i, -1 - j] == 1:
                r = 0
            else:
                r += 1
            R[i, -1 - j] = r
    for j in range(W):
        t = 0
        b = 0
        for i in range(H):
            if S[i, j] == 1:
                t = 0
            else:
                t += 1
            T[i, j] = t
            if S[-1 - i, j] == 1:
                b = 0
            else:
                b += 1
            B[-1 - i, j] = b
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = []
    for i in range(H):
        S.append(list(SI()))
    S = (numpy.array(S) == '.')
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        L[i] = (L[i - 1] + 1) * S[i]
        R[-1 - i] = (R[-i] + 1) * S[-1 - i]
    for i in range(W):
        T[:, i] = (T[:, i - 1] + 1) * S[:, i]
        B[:, -1 - i] = (B[:, -i] + 1) * S[:, -1 - i]
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())
### BUGGY CODE ###

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)
for i in range(m):
    a[i], b[i]=map(int, input().split())
    g[a[i]].append(b[i])
    g[b[i]].append(a[i])
    #print(g)

def Count_n_d(neighbor, start, search):
    visited = []
    stack = []
    stack.append(start)
    result = []
    while len(stack) > 0:
        next_city = stack.pop()
        if next_city in visited:
            continue
        result.append(next_city)
        visited.append(next_city)
        for nei in neighbor[next_city]:
            if nei==search:
                return [[]]                
            stack.append(nei)
    if search in result:
        return [[]]
    else:
        return [result]

def Count_n(neighbor, start, search):
    visited = []
    queue = []
    queue.append(start)
    result = []
    while len(queue) > 0:
        next_city = queue.pop(0)
        if next_city in visited:
            continue
        result.append (next_city)
        visited.append(next_city)
        for nei in neighbor[next_city]:
            queue.append(nei)
    if search in result:
        return [[]]
    else:
        return [result]
'''
print(g)
#print(Count(1,4,0))
for l in range(1,n+1):
    print('l,Count_n(g,l,0),len(Count_n(g,l,0))',l,Count_n(g,l,0),len(Count_n(g,l,0)[0]))
'''

ans=0
for i in range(m):
    g[a[i]].remove(b[i])
    g[b[i]].remove(a[i])
    cnt_a=len(Count_n(g,a[i],b[i])[0])
    if cnt_a==0:
        0
    else:
        ans+=cnt_a*len(Count_n_d(g,b[i],0)[0])
    print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

par=[i for i in range(n)]
cnt_con=[1 for i in range(n)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1


tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
#ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

    
for i in range(m):
    print(ans[i])
### BUGGY CODE ###

n,k = map(int,input().split())
list = input().split()
expectation = []
for i in range(len(list)):
  expectation.append((1+int(list[i]))/2)
max = 0
for i in range(n-k+1):
  tmp = sum(expectation[i:i+k])
  if tmp > max:
    max = tmp
print(max)


### FIXED CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
ave=[0]*(N-K+1)
tmp=0
for i in range(K):
    tmp+=(p[i]+1)/2
ave[0]=tmp
for i in range(1,N-K+1):
    ave[i]=ave[i-1]-(p[i-1]+1)/2 + (p[i+K-1]+1)/2
print(max(ave))