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

n, k = map(int, input().split())
p = list(map(int, input().split()))
l = 0
r = k - 1
ans_list = []
for i in range(n-k+1):
    ans = 0
    for j in range(l, r+1):
        ans += (p[j]+1) / 2
    ans_list.append(ans)
    l += 1
    r += 1

print(max(ans_list))

### FIXED CODE ###

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

kitaiti = [0 for _ in range(n)]
ruisekiwa = [0 for _ in range(n)]
r = k - 1
max = 0
now = 0
ans_list = []

for i in range(n):
    kitaiti[i] = (p[i]+1) / 2
    if i == 0:
        ruisekiwa[0] = kitaiti[0]
    else:
        ruisekiwa[i] = ruisekiwa[i-1] + kitaiti[i]
    if i == r:
        now = ruisekiwa[i]
    elif i > r:
        now = ruisekiwa[i] - ruisekiwa[i-r-1]
    if now > max:
        max = now
print(max)
### BUGGY CODE ###

n,m=map(int,input().split())
l=sorted([list(map(int,input().split())) for _ in range(m)])
ans=0
a=0
for i in range(m):
    if l[i][0]!=1:
        a=i
        break
for i in range(a):
    for j in range(a,m):
        if set(l[i])^set(l[j])=={1,n}:
            ans=1
            break
print("POSSIBLE" if ans==1 else "IMPOSSIBLE")

### FIXED CODE ###

n,m=map(int,input().split())
sa=set()
sb=set()
for i in range(m):
    a,b=map(int,input().split())
    if a==1:sa.add(b)
    if b==n:sb.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")
### BUGGY CODE ###


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

    for _ in range(K):
        imos_table = np.zeros(N + 1, np.int64)
        for i, a in enumerate(A):
            # 配列の個数を超えないように注意
            imos_table[max(i - a, 0)] += 1
            imos_table[min(i + a + 1, N)] -= 1
        A = np.cumsum(imos_table)

        if np.all(A == N):
            print(*A[:-1])
            return
    else:
        print(*A[:-1])

if __name__ == "__main__":
    resolve()


### FIXED CODE ###


from itertools import accumulate
def resolve():

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

    for _ in range(K):
        imos_table = [0]*(N+1)
        for i, a in enumerate(A):
            # 配列の個数を超えないように注意
            imos_table[max(i - a, 0)] += 1
            imos_table[min(i + a + 1, N)] -= 1
        A = list(accumulate(imos_table))[:-1]
        if all([True if a == N else False for a in A]):
            print(*A)
            return
    else:
        print(*A)

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

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

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
t=[0]*N
for i in range(N-1):
    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 = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: (x[0], x[1]))
A, B = [0], [0]
for i in range(N):
    A.append(X[i][0])
    B.append(X[i][1])

ans = 0
index_upper = 1
for k in range(1, M + 1):
    Ak = [a for a in A if a <= k]
    index_upper = len(Ak)
    res = max(B[:index_upper])
    if res != 0:
        A.remove(A[B.index(res)])
        B.remove(res)
    ans += res
print(ans)


### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):
    while (j < N) and (X[j][0] <= i):
        heapq.heappush(hq, -X[j][1])
        j += 1
    if len(hq):
        ans -= heapq.heappop(hq)

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

N, K = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1)]

from collections import defaultdict

v = defaultdict(set)

for a, b in AB:
    v[a].add(b)
    v[b].add(a)

r = [-1] * (N + 1)
M = 10**9+7

import sys
sys.setrecursionlimit(100001)

def check(n, b, p):
    r[n] = max(K - b - p, 0)
    #print("check:", n, r[n])
    b = 0
    for x in v[n]:
        if r[x] == -1:
            check(x, b, min(p + 1, 2))
            b += 1

check(1, 0, 0)

#print(r)

result = 1
for i in range(N):
    result = result * r[i + 1] % M

print(result)


### FIXED CODE ###

N, K = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1)]

from collections import defaultdict

v = defaultdict(set)

for a, b in AB:
    v[a].add(b)
    v[b].add(a)

M = 10**9+7

import sys
sys.setrecursionlimit(100001)

result = 1

def check(n, b, p):
    global result
    result = result * max(K - b - p, 0) % M
    #print("check:", n, r[n])
    np = min(p + 1, 2)
    for b, x in enumerate(v[n]):
        v[x].remove(n)
        check(x, b, np)

check(1, 0, 0)

print(result)
### BUGGY CODE ###

A, B, N = map(int,input().split())
max = 0
x = 0
n = int(B/A)
if(n < 1):n=1
if(A == 1 or B == 1):
  print(max)
else:
  while(x <= N):
    f = (A*x)//B - A*(x//B)
    #x += n
    x += 1
    #print(f)
    if(max <= f):
      max = f
    if(max != 0 and f == 0):
      break
  print(max)

### FIXED CODE ###

A,B,N = map(int,input().split())
def f(x):
  f = int((A*x)/B)-A*int(x/B)
  return f
if(B-1 < N):
  print(f(B-1))
else:
  print(f(N))
### BUGGY CODE ###

from bisect import insort_left

def main():
  N, M = map(int, input().split())
  A = sorted(list(map(int, input().split())))

  for i in range(M):
    a = A.pop(N-1)  
    insort_left(A, a//2)

  print(sum(A))  	
  
if __name__ == '__main__':
  main()
  

### FIXED CODE ###

from heapq import heappush, heappop, heapify

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

    for i in range(M):
      a = heappop(A)
      heappush(A, -(-a//2))

  print(-sum(A))  
  
if __name__ == '__main__':
  main()
### BUGGY CODE ###


def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(1,n+1):
        temp = int(a*x/b) - a * int(x / b)
        mx = max(mx,temp)
    print(mx)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    x = min(b-1,n)



    print(int(a*x/b) - a * int(x/b))


    #plt.plot(list(range(len(right))),right,label="test")


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

N = input()
a = raw_input().split()

b = []
stead = []

for i in range(N):
    b.append(a[i])
    b.reverse()

b.reverse()

for i in range(N - 1):
    print b.pop(),

print b.pop()


### FIXED CODE ###

N = input()
a = raw_input().split()

even = []
odd = []

for i in range(N):
    if (i + 1) % 2 != 0:
        odd.append(a[i])
    else:
        even.append(a[i])

if N % 2 != 0:
    even.reverse()
else:
    odd.reverse()

ans = []
if N % 2 != 0:
    ans = even + odd
else:
    ans = odd + even

for i in range(N - 1):
    print ans.pop(),

print ans.pop()
### BUGGY CODE ###

from bisect import bisect_left, insort_left
N = int(input())
A = list(map(int, input().split()))


# 各数の出現場所を持ってソート: 1-indexed
A_with_position = sorted([[a, i] for i, a in enumerate(A, start=1)])


# 出現したもののindex
appeared_index = [0, N + 1]

ans = 0
for a, i in A_with_position:
    li = bisect_left(appeared_index, i) - 1
    ri = bisect_left(appeared_index, i)

    lx, rx = appeared_index[li], appeared_index[ri]
    ans += a * (i - lx) * (rx - i)

    insort_left(appeared_index, i)

print(ans)


### FIXED CODE ###

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

d = [0] * (N+1)
for i in range(N):
    d[a[i]] = i

left = list(range(N+1))
right = list(range(N+1))

ans = 0
for i in range(N, 0, -1):
    di = d[i]
    ans += i * (right[di]-di+1) * (di-left[di]+1)
    right[left[di] - 1] = right[di]
    left[right[di] + 1] = left[di]

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

N = int(input())
binary = [0]*60
for i in input().split():
    i = bin(int(i))[2:][::-1]
    for j in range(len(i)):
        binary[j] += int(i[j])
    
ret = 0
pow2 = 1
for elem in binary:
    m = elem # m < 10**9 + 7
    n = (N - elem) # n < 10**9 + 7
    mn = m * n % (10**9 + 7)
    ret += pow2 * mn % (10**9 + 7)
    pow2 = pow2 * 2 % (10**9 + 7)
print(ret % (10**9 + 7))

### FIXED CODE ###

N = int(input())
binary = [0]*60
for inp in input().split():
    inp = bin(int(inp))[2:][::-1]
    for j, _inp in enumerate(inp):
        if _inp == '1':
            binary[j] += 1
    
ret = 0
pow2 = 1
for elem in binary:
    if elem == 0 or elem == N:
        pass
    else: 
        mn = elem * (N - elem) % (10**9 + 7)
        ret += pow2 * mn 
        ret = ret % (10**9 + 7)
    pow2 = pow2 * 2 % (10**9 + 7)
print(ret)
### BUGGY CODE ###

N,K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
counter_list = []
for i in range(1,N+1):
    if a_list.count(i) > 0:
        counter_list.append(a_list.count(i))

counter_list.sort()

count = 0
for i in range(len(counter_list) - K):
    count += counter_list[i]

print(count)


### FIXED CODE ###

N,K = map(int, input().split())
a_list = list(map(int, input().split()))
counter_list = [0]*N
for i in a_list:
    counter_list[i-1] += 1

counter_list.sort(reverse=True)

ans = N - sum(counter_list[:K])    

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

T = list(input())

for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

ans = ''
for i in range(len(T)):
    ans += T[i]

print(ans)


### FIXED CODE ###

T = list(input())

for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

ans = ''
for i in range(len(T)):
    ans += T[i]

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

n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
  res = res * a[i]
if(res > 1000000000000000000):
  res = -1
print(res)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  res = 0
  print(res)
  sys.exit()
  
res = 1
for i in range(n):
  if(res > pow(10,18)):
    break
  else:
    res = res * a[i]
if(res > pow(10,18)):
   res = -1
print(res)
### BUGGY CODE ###

N=int(input())
hako=list(map(int,input().split()))
fin=0
for i in range(N):
  for k in range(N):
    if i!=k:
      fin=fin+hako[i]*hako[k]
fin=fin//2
fin=fin%(10**9+7)
print(fin)

### FIXED CODE ###

N=int(input())
hako=list(map(int,input().split()))
tasu=sum(hako)
tasu=tasu**2
for i in range(N):
  tasu=tasu-(hako[i])**2
tasu=tasu//2
tasu=tasu%(10**9+7)
print(tasu)
### BUGGY CODE ###

n, k = map(int, input().split())
li_p = list(map(int, input().split()))

li_kitai = list()
for l in li_p:
    li_kitai.append(sum(range(1, l + 1)) / l)

answer = 0

for idx, v in enumerate(li_kitai[:len(li_kitai) - k + 1]):
    answer = max(answer, sum(li_kitai[idx:idx + k]))
print(answer)




### FIXED CODE ###

n, k = map(int, input().split())
li_p = list(map(int, input().split()))

li_kitai = list()
d_kitai_memo = dict()
for l in li_p:
    if l not in d_kitai_memo:
        val = sum(range(1, l + 1)) / l
        d_kitai_memo[l] = val
        li_kitai.append(val)
    else:
        li_kitai.append(d_kitai_memo[l])

answer = 0
memo = 0
for idx, v in enumerate(li_kitai[:len(li_kitai) - k + 1]):
    if idx == 0:
        memo = sum(li_kitai[idx:idx + k])
    else:
        memo = memo - li_kitai[idx - 1] + li_kitai[idx + (k - 1)]
    answer = max(answer, memo)

print(answer)
### BUGGY CODE ###

N = int(input())
info = [list(map(int,input().split())) for i in range(N)]
def modify(l1,l2):
    i = 1
    while True:
        if l2[0] * i >= l1[0] and l2[1] * i >= l1[1]:
            l2[0] *= i
            l2[1] *= i
            break
        i += 1
for i in range(N-1):
    modify(info[i],info[i+1])
ans = sum(info[-1])
print(ans)

### FIXED CODE ###

N = int(input())
info = [list(map(int,input().split())) for i in range(N)]
def modify(l1,l2):
    # k >= b / a
    # a * k >= b
    k1 = l1[0]//l2[0]
    k2 = l1[1]//l2[1]
    k = max(k1,k2)
    for i in range(k,k+2):
        if l2[0] * i >= l1[0] and l2[1] * i >= l1[1]:
            l2[0] *= i
            l2[1] *= i
            break
for i in range(N-1):
    modify(info[i],info[i+1])
ans = sum(info[-1])
print(ans)
### BUGGY CODE ###

s = input()
count = 0
while 'ABC' in s:
    s = s.replace('ABC','BCA',1)
    count += 1
print(count)

### FIXED CODE ###

s = input()
count = 0
s = s.replace('BC','X')
s = s.replace('B','Z').replace('C','Z')
s = s.split('Z')
for i in s:
    ac = 0
    for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac
print(count)
### BUGGY CODE ###

def main(n):
    ans = 0
    for k in range(1, n+1):
        for f in range(1,n//k+1):
            ans += k*f
    return ans

n = int(input())
print(main(n))

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
    tmp = n//i
    ans += (tmp*(tmp+1)//2)*i
print(ans)
### BUGGY CODE ###

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
LRC = [lr() for _ in range(M)]
LRC.sort()
INF = 10 ** 15
dp = np.full(N+1, INF) # 1-indexed
dp[1] = 0
for l, r, c in LRC:
    m = dp[l:r+1].min()
    dp[r] = min(dp[r], m + c)

if dp[N] == INF:
    print(-1)
else:
    print(int(dp[N]))
# 17

### FIXED CODE ###

import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def dijkstra(start):
    dist = [INF] * (N+1)
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for cost, next in graph[prev]:
            d1 = d + cost
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

N, M = lr()
INF = 10 ** 15
graph = [[] for _ in range(N+1)] # 1-indexed
for i in range(2, N+1):
    graph[i].append((0, i-1))

for _ in range(M):
    l, r, c = lr()
    graph[l].append((c, r))

dist = dijkstra(1)

if dist[N] == INF:
    print(-1)
else:
    print(dist[N])
# 19
### BUGGY CODE ###

def solution():
	n = int(input())
	l = []
	for i in range(n):
		x = int(input())
		if x in l:
			del l[l.index(x)]
		else:
			l.append(x)

	print(len(l))

solution()

### FIXED CODE ###

def solution():
	n = int(input())
	l = []
	for i in range(n):
		x = int(input())
		l.append(x)

	l.sort()

	i = 0
	ans = 0
	while i<(n-1):
		if l[i]==l[i+1]:
			i+=2
		else:
			i+=1
			ans+=1
	if i==n-1:
		ans+=1
			

	print(ans)

solution()
### BUGGY CODE ###

from math import ceil
def solve():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int,input().split())
        T.append(t)
        A.append(a)
    
    now_t = T[0]
    now_a = A[0]

    for i in range(1,N):
        j = ceil(now_t / T[i])
        mul_t = T[i] * j
        mul_a = A[i] * j
        while now_t > mul_t or now_a > mul_a:
            j += 1
            mul_t = T[i] * j
            mul_a = A[i] * j
        else:
            now_t = mul_t
            now_a = mul_a
    
    print(now_t + now_a)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

from math import ceil
def solve():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int,input().split())
        T.append(t)
        A.append(a)
    
    now_t = T[0]
    now_a = A[0]

    for i in range(1,N):
        mul = f(now_t,now_a,T[i],A[i])
        now_t = T[i] * mul
        now_a = A[i] * mul
    
    print(now_t + now_a)

def f(now_t, now_a, t, a):
    left = 0
    right = 10 ** 18
    while right - left > 1:
        mid = (right + left) // 2
        if now_t > t * mid or now_a > a * mid:
            left = mid
        else:
            right = mid
    
    return right

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

# coding: utf-8
#!/usr/bin/env python3

from queue import Queue
# from collections import deque

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

# direction vector
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]

# 訪れたかどうかの情報を持つ bool 値
is_visited = [ [False] * w for _ in range(h) ]

q = Queue()

for x in range(w):
    for y in range(h):
        if a[y][x] == "#":
            q.put( (x, y, 0) )
            is_visited[y][x] = True

ans = 0

while not q.empty():
    # queue の先頭を取り出す
    x, y, dist = q.get()
    ans = max(ans, dist)
    # 4方向にループ
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]

        if nx < 0 or w <= nx or ny < 0 or h <= ny:
            continue

        if is_visited[ny][nx]:
            continue

        q.put( (nx, ny, dist+1) )
        is_visited[ny][nx] = True

print(ans)



### FIXED CODE ###

# coding: utf-8
#!/usr/bin/env python3

from collections import deque

# input
h, w = map(int, input().split())
a = [ list(input()) for _ in range(h) ]

# direction vector
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]

# 訪れたかどうかの情報を持つ bool 値
is_visited = [ [False for _ in range(w)] for __ in range(h) ]

q = deque()

for x in range(w):
    for y in range(h):
        if a[y][x] == "#":
            q.append( (x, y, 0) )
            is_visited[y][x] = True

while q:
    # queue の先頭を取り出す
    x, y, cnt = q.popleft()
    # 4方向にループ
    for i in range(4):
        nx, ny = x + dx[i], y + dy[i]

        if nx < 0 or w <= nx or ny < 0 or h <= ny or is_visited[ny][nx]:
            continue

        q.append( (nx, ny, cnt+1) )
        is_visited[ny][nx] = True

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

n = int(input())
x = input()
a = x.count('1')
b = int(x,2)
# print (b)

ary = [None for i in range(200010)]
ary[0] = 0

def f(n):
  if ary[n] is not None:
    return ary[n]
  b = bin(n).count('1')
  r = 1 + f(n%b)
  ary[n] = r
  return ary[n]


a1 = a + 1
a0 = a - 1
for i in range(200010):
  f(i)


one = [1] * 200010
zero = [1] * 200010
for i in range(1, 200010):
    if a0 != 0:
        one[i] = one[i-1] * 2 % a0
    zero[i] = zero[i-1] * 2 % a1


ans = [0 for i in range(n)]
for i in range(n-1, -1, -1):
  if x[n-1-i] == '0':
    y = b%a1 + zero[i]
    # y = x %a1
    y %= a1
    print (ary[y]+1)
  else:
    if a0 != 0:
      y = b%a0 - one[i]
      # y = x %a0
      y %= a0
      print (ary[y]+1)
    else:
      print (0)
# ans.reverse()
# for i in ans:
#   print (i)

### FIXED CODE ###

n = int(input())
x = input()
a = x.count('1')
b = int(x,2)
# print (b)

ary = [None for i in range(200010)]
ary[0] = 0

def f(n):
  if ary[n] is not None:
    return ary[n]
  b = bin(n).count('1')
  r = 1 + f(n%b)
  ary[n] = r
  return ary[n]


a1 = a + 1
a0 = a - 1
for i in range(200010):
  f(i)


one = [1] * 200010
zero = [1] * 200010
for i in range(1, 200010):
    if a0 != 0:
        one[i] = one[i-1] * 2 % a0
    zero[i] = zero[i-1] * 2 % a1


ans = [0 for i in range(n)]
c1 = b%a1
if a0 != 0:
  c0 = b%a0
for i in range(n-1, -1, -1):
  if x[n-1-i] == '0':
    y = c1 + zero[i]
    # y = x %a1
    y %= a1
    print (ary[y]+1)
  else:
    if a0 != 0:
      y = c0 - one[i]
      y %= a0
      print (ary[y]+1)
    else:
      print (0)
# ans.reverse()
# for i in ans:
#   print (i)
### BUGGY CODE ###

from collections import Counter

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

ans = 0
c = Counter(a).most_common()
for i in range(min(a), max(a) + 1):
    temp = [value if abs(i - key) <= 1 else 0 for key, value in c]
    ans = max(ans, sum(temp))

print(ans)


### FIXED CODE ###

from collections import Counter

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

x = []
for i in a:
    x.append(i)
    x.append(i + 1)
    x.append(i - 1)

ans = max(Counter(x).values())
print(ans)
### BUGGY CODE ###

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

d = dict()

for a in A:
    d[a] = d.get(a, 0) + 1

ans = []
for _ in range(int(input())):
    b, c = map(int, input().split())
    if d.get(b, 0) != 0:
        temp = d[b]
        d[b] -= temp
        d[c] = d.get(c, 0) + temp

    ans.append(list(d.items()))

for a in ans:
    print(sum(k*v for k, v in a))

### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))

    sum_a = sum(A)

    d = dict()

    for a in A:
        d[a] = d.get(a, 0) + 1

    for _ in range(int(input())):
        b, c = map(int, input().split())
        if d.get(b, 0) != 0:

            temp = d[b]         
            d[b] -= temp
            d[c] = d.get(c, 0) + temp

            sum_a += (c - b) * temp
        print(sum_a)
        
main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[[0 for i in range(12881)] for j in range(w)] for k in range(h)]
for i in range(h):
  for j in range(w):
    for k in range(12801):
      t = grid[i][j]
      if i == j == 0 and t == k:
        dp[i][j][k] = 1
      if j > 0:
        dp[i][j][k] = dp[i][j][k] or dp[i][j-1][abs(k+t)] or dp[i][j-1][abs(k-t)]
      if i > 0:
        dp[i][j][k] = dp[i][j][k] or dp[i-1][j][abs(k+t)] or dp[i-1][j][abs(k-t)]
for i in range(12801):
  if dp[h-1][w-1][i] == 1:
    print(i)
    break


### FIXED CODE ###

h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[0 for j in range(w)] for k in range(h)]
buf = (h+w)*80
for i in range(h):
  for j in range(w):
      t = grid[i][j]
      if i == j == 0:
        dp[i][j] = 1 << buf+t | 1 << buf-t
      if j > 0:
        dp[i][j] = dp[i][j] | dp[i][j-1] << t | dp[i][j-1] >> t
      if i > 0:
        dp[i][j] = dp[i][j] | dp[i-1][j] << t | dp[i-1][j] >> t
for i in range(buf):
  if (dp[h-1][w-1] & 1 << buf+i) or (dp[h-1][w-1] & 1 << buf-i):
    print(i)
    exit()
### BUGGY CODE ###

num=int(raw_input())
tmp=[]
for i in range(num):
    tmp.append(int(raw_input()))

output=0
for i in set(tmp):
    if tmp.count(i)%2 ==1:
        output+=1
print output

### FIXED CODE ###

num=int(raw_input())
tmp={}
for i in range(num):
    a=int(raw_input())
    if a in tmp:
        tmp[a]+=1
    else:
        tmp[a]=1

output=0
for i in tmp:
    if tmp[i]%2 ==1:
        output+=1
print output
### BUGGY CODE ###

from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]

listT = []
for t in l:
  listT = listT + t

s = min(list(set(listT)))
e = max(list(set(listT)))
cnt = 0
for i in range(s, e+1):
  isOk = True
  for start, end in l:
    if i < start or i > end:
      isOk = False
      break
  if isOk == True:
    cnt = cnt + 1

print(cnt)

### FIXED CODE ###

from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]

sMax = 0
eMin = 0
for s, e in l:
  if sMax < s or sMax == 0:
    sMax = s
  if eMin > e or eMin == 0:
    eMin = e

if eMin - sMax >= 0:
  print(eMin - sMax + 1)
else:
  print(0)
### BUGGY CODE ###

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

total_list = []
for i in range(int(10e100)):
    for i in range(A):
        total_list.append("b")
    for i in range(B):
        total_list.append("r")
    if len(total_list) >= N:
        break

count = 0
for i in range(N):
    if total_list[i] == 'b':
        count += 1
print(count)

### FIXED CODE ###

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

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
p = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    tmp = 0
    for j in range(i):
        if p[j] >= p[i]:
            tmp += 1
    if tmp == i:
        ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
p = [int(i) for i in input().split()]

ans = 1
tmp = p[0]
for i in range(1, n):
    if tmp >= p[i]:
        ans += 1
        tmp = p[i]
print(ans)