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

from operator import itemgetter

H, W, M = map(int, input().split())
h_count = [[i, 0] for i in range(H)]
w_count = [[i, 0] for i in range(W)]
exist = dict()
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    h_count[h][1] += 1
    w_count[w][1] += 1
    exist[(h, w)] = 1

h_count.sort(key=itemgetter(1), reverse=True)
w_count.sort(key=itemgetter(1), reverse=True)
h_max = h_count[0][1]
w_max = w_count[0][1]
res = 0
for h in h_count:
    if h[1] != h_max:
        break
    for w in w_count:
        if w[1] != w_max:
            break
        val = h[1] + w[1]
        if exist.get((h[0], w[0]), 0):
            val -= 1
        res = max(res, val)
print(res)


### FIXED CODE ###

from operator import itemgetter

H, W, M = map(int, input().split())
h_count = [[i, 0] for i in range(H)]
w_count = [[i, 0] for i in range(W)]
exist = dict()
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    h_count[h][1] += 1
    w_count[w][1] += 1
    exist[(h, w)] = True

h_count.sort(key=itemgetter(1), reverse=True)
w_count.sort(key=itemgetter(1), reverse=True)
h_max = h_count[0][1]
w_max = w_count[0][1]
res = 0
is_dup = True
for h in h_count:
    if h[1] != h_max or not is_dup:
        break
    for w in w_count:
        if w[1] != w_max or not is_dup:
            break
        val = h[1] + w[1]
        if exist.get((h[0], w[0]), False):
            val -= 1
        else:
            is_dup = False
        res = max(res, val)
print(res)
### BUGGY CODE ###

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

### FIXED CODE ###

n,k = list(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 ###

import numpy as np
import copy

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

"""
def median_cal(data):
    num = len(data)
    # データを昇順ソート
    data.sort()
    # データ数が偶数の場合
    median = int((num + 1) / 2 - 1)
    median = data[median]
    return median"""
  
for i in range(n):
  list1 = copy.copy(x)
  list1.pop(i)
  list1 = np.array(list1)
  median = np.median(list1)
  print(int(median))

### FIXED CODE ###

import copy

n = int(input())
x = list(map(int, input().split()))
num = 0

y = copy.copy(x)
x.sort()
num1 = x[n//2-1]
num2 = x[n//2]

for i in y:
  if i <= num1:
    print(num2)
  else:
    print(num1)
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from functools import reduce
import itertools

def gcd(a,b):
  while b:a,b=b,a%b
  return a

def gcd_list(l):
    return reduce(gcd, l)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

K = i_i()

h = {}
ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            tmp = "".join([str(y) for y in sorted([a,b,c])])
            if h.get(tmp):
                ans += h[tmp]
            else:
                h[tmp] = gcd_list([a,b,c])
                ans += h[tmp]

print(ans)


### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
import math

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

K = i_i()

res = sum([math.gcd(math.gcd(a, b), c) for a in range(1,K+1) for b in range(1,K+1) for c in range(1,K+1)])
print(res)
### BUGGY CODE ###

from collections import defaultdict
def gcd(m,n):
    if n==0:
        return m
    return gcd(n,m%n)
##print(gcd(5,3))
##print(gcd(2,4))
k=int(input())
d=defaultdict(int)
t=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            if list((i,j,k)) in [list(x) for x in d.keys()]:
                t+=d[(i,j,k)]
            else:
                d[tuple(sorted((i,j,k)))]=gcd(i,gcd(j,k))
                t+=d[tuple(sorted((i,j,k)))]
print(t)
                
                
            
    


### FIXED CODE ###

from collections import defaultdict
def gcd(m,n):
    if n==0:
        return m
    return gcd(n,m%n)

k=int(input())
t=0
for i in range(1,k+1):
    for j in range(1,k+1):
        g=gcd(i,j)
        for k in range(1,k+1):
            if k%g==0:
                t+=g
            elif g%k==0:
                t+=k
            else:
                t+=gcd(g,k)
print(t)
### BUGGY CODE ###

N = int(input())
L = input().split()
L = [int(L[i]) for i in range(len(L))]
L.sort(reverse=True)
tri = 0
for i in range(N):
  for j in range(i+1,N):
    tri += len([k for k in range(j+1,N) if L[i]-L[j] < L[k] < L[j]])
    
print(tri)

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
N=int(input())
S=list(map(int,input().split()))

ans=10**10

ave=0
for i in range(N):
    ave+=S[i]
ave=ave//N

for i in range(ave-N//2-100,ave-N//2+100):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei
        
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import statistics

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

S1=[]
for i in range(N):
    S1.append(S[i]-i)
S1.sort()
chuouchi=statistics.median_high(S1)
chuouchi2=statistics.median_low(S1)
chuouchi3=statistics.median(S1)
ans=10**20
ansj=0
A=chuouchi-4
B=chuouchi+4
C=chuouchi2-4
D=chuouchi2+4
E=int(chuouchi3)-4
F=int(chuouchi3)+4
for i in range(A,B):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei
        
for i in range(C,D):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei

for i in range(E,F):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei        
        
print(ans)
### BUGGY CODE ###

import math

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


### FIXED CODE ###

import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))
### BUGGY CODE ###

n, p = map(int, input().split())
out=1
for i in range(2,p+1):
    if i==2:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i

    elif i%2!=0:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
            
        if p < i**n:
            break
print(out)

### FIXED CODE ###

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

if n==1:
    print(p)
else:
    out=1
    tm = int(pow(p, 1/n))
    for i in range(2,tm+1):
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
        if p < i**n:
            break
    print(out)
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
 
m, m_index = 0, 0
for i in range(N-K+1):
    total =sum(P[i:i+K])
    if total > m:
        m = total
        m_index = i
 
print(sum(map(lambda x: sum(list(range(1, x+1)))/x, P[m_index : m_index+K])))

### FIXED CODE ###

from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

ans = 0
for i in range(K, N+1):
    ans = max(ans, accum_expected[i]-accum_expected[i-K])
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
tmp,count,l0=A[0],1,[]
for i in range(1,N):
  if tmp==A[i]:
    count+=1
  else:
    l0.append([tmp,count])
    tmp=A[i]
    count=1
l0.append([tmp,count])
BC=[]
for i in range(M):
  BC.append(list(map(int,input().split())))
BC.sort(key=lambda x:x[1],reverse=True)
cnt=0
l1=[]
for b,c in BC:
  if cnt>N:
    break
  else:
    l1.append([c,b])
    cnt+=b
l=l0+l1
l.sort(key=lambda x:x[0],reverse=True)
d=0
ans=0
while d<N:
  if l[0][1]==0:
    l.remove(l[0])
  ans+=l[0][0]
  d+=1
  l[0][1]-=1
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[]
for i in range(M):
  BC.append(list(map(int,input().split())))
A.sort(reverse=True)
BC.sort(key=lambda x:x[1],reverse=True)
ans=sum(A)
for i in range(M):
  for _ in range(BC[i][0]):
    if A==[]:
      print(ans)
      exit()
    if A[-1]>BC[i][1]:
      print(ans)
      exit()
    else:
      p=A.pop()
      ans-=p
      ans+=BC[i][1]
      
print(ans)
### BUGGY CODE ###

N, *A = map(int, open(0).read().split())
MOD = 1_000_000_007
ans = 0
for i in range(64):
    p, q, = 0, 0
    for a in A:
        if a >> i & 1:
            p += 1
        else:
            q += 1
    ans += pow(2, i, MOD) * p * q
    ans %= MOD
print(ans)

### FIXED CODE ###

import numpy as np


def solve():
    ans = 0
    mask = 1
    for i in range(60):
        one_cnt = np.sum(A >> i & 1)
        tmp = one_cnt * (N - one_cnt)
        tmp %= MOD
        ans += tmp * mask
        ans %= MOD
        mask <<= 1
        mask %= MOD
    return ans


N, *A = map(int, open(0).read().split())
A = np.array(A, dtype=np.int64)
MOD = 1_000_000_007
print(solve())
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)


class Segtree():
    INT_MIN=-10**9

    def __init__(self,size):
        self.size=1
        while self.size<size:
            self.size=self.size*2
        self.node=[self.INT_MIN]*(2*self.size-1)


    def update(self,k,a):
        k+=self.size-1
        self.node[k]=a
        while k>0:
            k=(k-1)/2
            self.node[k]=max(self.node[k*2+1],self.node[k*2+2])

    def get_max(self,queryL,queryR,k=0,nodeL=0,nodeR=-1):
        if nodeR==-1:nodeR=self.size
        if (nodeR<=queryL or queryR<=nodeL):return self.INT_MIN
        if (queryL<=nodeL and nodeR<=queryR):return self.node[k]
        else:
            nodeM=(nodeL+nodeR)/2
            vl=self.get_max(queryL,queryR,k*2+1,nodeL,nodeM)
            vr=self.get_max(queryL,queryR,k*2+2,nodeM,nodeR)
            return max(vl,vr)
            
n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
seg=Segtree(n)
for i in xrange(n):
    seg.update(i,a[i])
ans=0
mx=0
for i in xrange(n):
    tmp=seg.get_max(i,n)-a[i]
    if mx<tmp:
        ans=1
        mx=tmp
    elif mx==tmp:
        ans+=1
print ans


### FIXED CODE ###

n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
now=a[0]
cnt=[]
for i in xrange(1,n):
    if now<a[i]:
        cnt.append(a[i]-now)
    else:
        now=a[i]
print(cnt.count(max(cnt)))
### BUGGY CODE ###

import heapq
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
    x1,y1,z1,a1=[int(i) for i in input().split()]
    en.append([x1-1,y1-1,z1])
    en.append([y1-1,x1-1,z1])
    su.append([x1-1,y1-1,a1])
    su.append([y1-1,x1-1,a1])
def shortest_path(edge,num_v,start):
    inf = float("inf")
    cost = [[inf for i in range(num_v)] for j in range(num_v)]
    for e in edge: cost[e[0]][e[1]] = e[2]
    d = [inf for j in range(num_v)]
    q = []
    heapq.heappush(q, (0, start))
    d[start] = 0
    syou = inf
    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if prov_cost > syou:
        break
      if d[src] < prov_cost:
                continue
      for dest in range(num_v):
        you = cost[src][dest]
        if you != float('inf') and d[dest] > d[src] + you:
          d[dest] = d[src] + you
          heapq.heappush(q, (d[dest], dest))
          syou = max(d[dest],syou)
    return d


from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
sai = float("inf")
for i in range(n-1,-1,-1):
  kon = kae[i]+tori[i]
  if sai > kon:
     ans.appendleft(kon)
     sai = kon
  else:
    ans.appendleft(sai)
    
moti = 10**15
for i in range(n):
  print(moti-ans[i])

### FIXED CODE ###

import heapq
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
    x1,y1,z1,a1=[int(i) for i in input().split()]
    en.append([x1-1,y1-1,z1])
    su.append([x1-1,y1-1,a1])
def shortest_path(edge,num_v,start):
    inf = float("inf")
    cost = [[] for i in range(n+1)]
    for path in edge:
      cost[path[0]].append((path[1],path[2]))
      cost[path[1]].append((path[0],path[2]))
    d = [inf for j in range(num_v)]
    q = []
    heapq.heappush(q, (0, start))
    d[start] = 0
    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if d[src] < prov_cost:
                continue
      for dest,weight in cost[src]:
        if weight != float('inf') and d[dest] > d[src] + weight:
          d[dest] = d[src] + weight
          heapq.heappush(q, (d[dest], dest))
    return d
 
 
from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
sai = float("inf")
for i in range(n-1,-1,-1):
  kon = kae[i]+tori[i]
  if sai > kon:
     ans.appendleft(kon)
     sai = kon
  else:
    ans.appendleft(sai)
    
moti = 10**15
for i in range(n):
  print(moti-ans[i])
### BUGGY CODE ###

n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
import collections

P=collections.defaultdict(int)
PI=[collections.defaultdict(int) for _ in range(n)]
for i in range(n):
  a=A[i]
  for j in range(2,int(a**0.5)+1):
    while a%j==0:
      PI[i][j]+=1
      a//=j
  if a>1:
    PI[i][a]=1
  for p in PI[i].keys():
    P[p]=max(P[p],PI[i][p])
ans=0
for i in range(n):
  mul=1
  for p in P.keys():
    mul=(mul*pow(p,(P[p]-PI[i][p])))%mod


  ans=(ans+mul)%mod
print(ans)

### FIXED CODE ###

n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)
### BUGGY CODE ###

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

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
 
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
 
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
### BUGGY CODE ###

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

ans_max = M//N
ans = 0

for i in range(ans_max):
    if M % (ans_max-i) == 0:
        ans = ans_max-i
        break

print(ans)

### FIXED CODE ###

N,M = list(map(int, input().split()))
divi = []

for i in range(1,int(M**0.5)+1):
    if M % i == 0:
        if i >= N:
            divi.append(i)
        if i != M//i:
            if M//i >= N:
                divi.append(M//i)

print(M//min(divi))
### BUGGY CODE ###

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

sumA = [0]

for i in range(N):
    if i == 0:
        sumA.append(A[i] % K)
    else:
        sumA.append((sumA[-1] + A[i]) % K)
ans = 0

for i in range(N):
    for j in range(i+1, N+1):
        if (sumA[j] - sumA[i]) % K == j - i:
            ans += 1
#            print(sumA[j],sumA[i])

print(ans)

### FIXED CODE ###

import sys
from itertools import accumulate
from collections import defaultdict
input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [i-1 for i in a]
suma = [0]+list(accumulate(a))
suma = [i%k for i in suma]
rem = defaultdict(int)
ans = 0
if k > n:
    for i in range(n+1):
        x = suma[i]
        rem[x] += 1
    for s in rem.values():
        ans += s*(s-1)//2
    print(ans)
    exit()
for i in range(k):
    x = suma[i]
    rem[x] += 1
for s in rem.values():
    ans += s*(s-1)//2
for i in range(n-k+1):
    rem[suma[i]%k] -= 1
    rem[suma[i+k]%k] += 1
    ans += rem[suma[i+k]] -1
print(ans)
### BUGGY CODE ###

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

p = list(map(lambda x: (x + 1) / 2, P))

p, sp = [], []
for i in range(N):
    p.append((P[i] + 1) / 2)

for i in range(N - K + 1):
    sp.append(sum(p[:i + K]) - sum(p[:i]))

print('{:.10f}'.format(max(sp)))


### FIXED CODE ###

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

p = [0]
for i in range(N):
    p.append(p[-1] + (P[i] + 1) / 2)

print(max(p[i+K] - p[i] for i in range(N-K+1)))
### BUGGY CODE ###

n = int(input())
list = []
ans = 0
for i in range(n):
  list.append(input())
  list[i] = ''.join(sorted(list[i]))
for i in range(n):
  ans += list.count(list[i]) -1
print(int(ans/2))

### FIXED CODE ###

n = int(input())
dict= {}
ans = 0
for i in range(n):
  temp = ''.join(sorted(input()))
  if temp in dict:
    dict[temp] += 1
    ans += dict[temp]
  else:
    dict.update([(temp, 0)])
print(ans)
### BUGGY CODE ###

import math

n = int(input())
x = list(map(int, input().split()))
ans = 0
pattern = math.factorial(n-1)
p=1
k=pattern
while p < n:
  ans += k * (x[p]-x[p-1])
  ans %= 1000000007
  p += 1
  k += pattern//(p)
print(ans)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
ans = 0
mod = 1000000007
p = 1
for i in range(1, n):
  p *= i
  p %= mod
for i in range(n-1):
  ans += (x[n-1]-x[i])*pow(i+1, mod-2, mod)
ans *= p
ans %= 1000000007
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[j] = cur[j] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)


### FIXED CODE ###


P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[j] = cur[j] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for upper_bit_bound in range(41,-2,-1):
    if (upper_bit_bound != -1 and not (K & 1 << upper_bit_bound)):
        continue
    fx = 0
    for bit_index in range(41,-1,-1):
        mask = 1 << bit_index
        hit_num = 0
        for a in A:
            if(a & mask):
                hit_num += 1
        nohit_num = N - hit_num
        if (bit_index > upper_bit_bound):
            if(K & mask):
                fx += mask * nohit_num
            else:
                fx += mask * hit_num
        elif(bit_index == upper_bit_bound):
            fx += mask * hit_num
        else:
            fx += mask * max(hit_num, nohit_num)
    ans = max(ans, fx)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
"""
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
max_A = max(A)
bit = bin(K)
if max_A > K:
    bit = bin(max_A)"""
max_f = 0
#for d in range(1,len(bit))[::-1]:
for d in range(41,-2,-1):
    #d=d-2
    if (d != -1 and not (K & 1 << d)):
        continue
    f=0
    #for e in range(2,len(bit))[::-1]:
    for e in range(41,-1,-1):
        #e=e-2
        mask = 1<<e
        num=0
        for a in A:
            if a&mask:
                num+=1
        n_num = N - num
        if e>d:
            if K&mask:
                f += mask*n_num
            else:
                f += mask*num
        elif e==d:
            f += mask*num
        else:
            f += mask*max(n_num,num)
    max_f = max(f,max_f)
print(max_f)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

H,W,K=map(int,input().split())
sy,sx,gy,gx=map(int,input().split())
c=['@'*(W+2) for _ in range(H+2)]
for column in range(1,H+1):
    c[column]='@'+input()+'@'
que=deque()
d=[[INF]*(W+2) for _ in range(H+2)]
v=[[[0]*4 for _ in range(W+2)] for _ in range(H+2)]
que.append((sy,sx))
d[sy][sx]=0
dy,dx=(1,0,-1,0),(0,1,0,-1)
while que:
    y,x=que.popleft()
    for k in range(4):
        ny,nx=y+dy[k],x+dx[k]
        if c[ny][nx]=='.':
            if v[y][x][k]>0:
                if d[ny][nx]>d[y][x]:
                    v[ny][nx]=[0]*4
                    v[ny][nx][k]=v[y][x][k]-1
                    d[ny][nx]=d[y][x]
                    que.append((ny,nx))
                elif d[ny][nx]==d[y][x]:
                    v[ny][nx][k]=v[y][x][k]-1
            else:
                if d[ny][nx]>d[y][x]+1:
                    v[ny][nx]=[0]*4
                    v[ny][nx][k]=K-1
                    d[ny][nx]=d[y][x]+1
                    que.append((ny,nx))
                elif d[ny][nx]==d[y][x]+1:
                    v[ny][nx][k]=K-1
print(d[gy][gx] if d[gy][gx]!=INF else -1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

H,W,K=map(int,input().split())
sy,sx,gy,gx=map(int,input().split())
st=sx+sy*(W+2)
gl=gx+gy*(W+2)
c=['@']*(W+2)
for i in range(H):
    c.extend(['@']+list(input())+['@'])
c.extend(['@']*(W+2))
que=deque()
dist=[INF]*(W+2)*(H+2)
que.append(st)
dist[st]=0
d=(-1,1,W+2,-(W+2))
while que:
    v=que.popleft()
    for k in range(4):
        nv=v
        for _ in range(K):
            nv+=+d[k]
            if c[nv]=='.' and dist[nv]>dist[v]:
                if dist[nv]==INF:
                    dist[nv]=dist[v]+1
                    que.append(nv)
            else:
                break
print(dist[gl] if dist[gl]!=INF else -1)
### BUGGY CODE ###

N = int(input())

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

V = [0 for i in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            V[j] += A[i]
        elif i > j and (i + j) % 2 == 0:
            V[j] += A[i]
        elif i < j and (i + j) % 2 == 1:
            V[j] += A[i]
        else:
            V[j] -= A[i]

for volume in V:
    print(volume, end=' ')
print()

### FIXED CODE ###

N = int(input())

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


volume = 0
for j in range(N):
    if j % 2 == 0:
        volume += A[j]
    else:
        volume -= A[j]
print(volume ,end=' ')

for i in range(1, N):
    volume = 2 * A[i - 1] - volume
    print(volume ,end=' ')

print()