Harryxun/stf_run huggingface dataset:
def solve(string):
    ins = string.split("\n")
    h, w = map(int, ins[0].split(" "))
    a = [list(map(lambda x: int(x) % 2 == 1, _i.split(" "))) for _i in ins[1:]]
    move = []
    v_flag = False
    h_flag = False
    """
    for i, _a in enumerate(a):
        for j, __a in enumerate(_a):
            curr = __a
            if h_flag:
                curr = not curr
                h_flag = False
            if j == w - 1 and v_flag:
                curr = not curr
                v_flag = False
            if not curr:
                continue
            if j < w - 1:
                h_flag = True
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
            elif i < h - 1:
                v_flag = True
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1))
    """
    for i in range(h):
        for j in range(w):
            if not a[i][j]:
                continue
            if j < w - 1:
                a[i][j + 1] = not a[i][j + 1]
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
            elif i < h - 1:
                a[i + 1][j] = not a[i + 1][j]
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1))
    move.insert(0, str(len(move)))
    return "\n".join(move)


if __name__ == '__main__':
    line = input()
    tmp = [line]
    for _ in range(int(line[0])):
        tmp.append(input())
    print(solve('\n'.join(tmp)))


### FIXED CODE ###

h,w = map(int,input().split())
a = []
for i in range(h):
    tmp = list(map(lambda x:int(x)%2,input().split()))
    a.append(tmp)
result = []
 
for i in range(h):
    for j in range(w-1):
        if a[i][j] == 1:
            #a[i][j] == 0
            a[i][j+1] = 1 ^ a[i][j+1]
            result.append((i+1,j+1,i+1,j+2)) 
for i in range(h-1):
    if a[i][w-1] == 1:
        a[i+1][w-1] = 1 ^ a[i+1][w-1]
        result.append((i+1,w,i+2,w))
print(len(result))
for row in result:
    print("{} {} {} {}".format(row[0],row[1],row[2],row[3]))
import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N)
for n in range(N):
    i = bisect.bisect(lis, A[n])    
    lis[i] = A[n]
    #print (lis)
print (bisect.bisect_left(lis, INF)) a

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N+1)
lis[0] = -1
for n in range(N):
    i = bisect.bisect(lis, A[n])    
    lis[i] = A[n]
print (bisect.bisect_left(lis, INF) - 1)
import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd

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

left_gcds = [gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(gcd(left_gcds[i-1], As[i]))

right_gcds = [gcd(As[-1], As[-1])]
for i in reversed(range(len(As)-1)):
    right_gcds.append(gcd(right_gcds[i-1], As[i]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))

### FIXED CODE ###

import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd



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

left_gcds = [gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(gcd(left_gcds[i-1], As[i]))

right_gcds = [gcd(As[-1], As[-1])]
for i in range(1, len(As)):
    right_gcds.append(gcd(right_gcds[i-1], As[-(i+1)]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))
while 1:
  x, y = map(int,raw_input().split)
  if x == 0 and y == 0:
    break
  min = min(x,y)
  max = max(x,y)
  print "%d %d", (min,max)

### FIXED CODE ###

while 1:
  x, y = map(int, raw_input().split())
  if x == 0 and y == 0:
    break
  elif x > y:
    print "%d %d" % (y,x)
  else:
    print "%d %d" % (x,y)
for i in range(1, 10):
  for j in range(1, 10):
    print str(i) + '×' + str(j) + '=' + str(i*j)

### FIXED CODE ###

for i in range(1, 10):
  for j in range(1, 10):
    print str(i) + 'x' + str(j) + '=' + str(i*j)
n,k=(map(int,input().split())
a=n%k
print(min(a,abs(a-k)))

### FIXED CODE ###

n,k=map(int,input().split())
print(min(n%k,abs(n%k-k)))
# ABC174 E

n, k = map(int, input().split())
a_l = [int(x) for x in input().split()]

left = 0
right = max(a_l)


def cut(len):
    ret = 0
    for i in range(n):
        if a_l[i] % len == 0:
            ret += a_l[i] // len - 1
        else:
            ret += a_l[i] // len
    return ret


while (right - left) > 1:
    _q = max((left + right) // 2, 1)
    _ret = cut(_q)
    if k >= _ret:
        right = _q
    else:
        left = _q

_l = cut(left)
_r = cut(right)

if _l <= k:
    print(left)
else:
    print(right)


### FIXED CODE ###

# ABC174 E

n, k = map(int, input().split())
a_l = [int(x) for x in input().split()]

left = 0
right = max(a_l)


def cut(len):
    ret = 0
    for i in range(n):
        if a_l[i] % len == 0:
            ret += a_l[i] // len - 1
        else:
            ret += a_l[i] // len
    return ret


while (right - left) > 1:
    _q = (left + right) // 2
    _ret = cut(_q)
    if k >= _ret:
        right = _q
    else:
        left = _q

print(right)
def main():
  n,a,b = (int(x) for x in input().split())

  num_a = int(n / (a + b))
  num_b = int(n % (a + b))
  
  if(num_b >= a):
    nun_x = a
  else:
    num_x = num_b

  print(num_a * a + num_x)
  
if __name__ == '__main__':
  main()  


### FIXED CODE ###

import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))

  print(int(num_a * a + min(a, num_b)))
  
if __name__ == '__main__':
  main()
import collections
cc = collections.Counter()
count = 0
n = raw_input()
for i,e in enumerate(map(int, raw_input().split())):
	count += cc[e - i]
    cc[e-  i] +=1
    
print count

### FIXED CODE ###

import collections
n = int(raw_input())
hs = map(int, raw_input().split(' '))
def f(nums):
	cc,count = collections.Counter(), 0

	#j - i = aj + ai  =>  ai + i = j - aj
	for i in range(len(nums)-1, -1, -1):
		count += cc[nums[i] + i]
		cc[i - nums[i]]+=1
	return count
		


print f(hs)
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict,deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[(1,1),(-1,1),(1,-1),(-1,-1),(2,0),(-2,0),(0,2),(0,-2),(1,2),(-1,2),(1,-2),(-1,-2),(2,1),(-2,1),(2,-1),(-2,-1),(2,2),(-2,2),(2,-2),(-2,-2)]

visit=defaultdict(lambda: 0) #未訪問:0 訪問済み:1

q=deque()
q.append((0,CH,CW))
visit[(CH,CW)]=1

while q:
    kyori, fro_h, fro_w=q.popleft()
    visit[(fro_h, fro_w)]=1
    if fro_h==DH and fro_w==DW:
        print kyori
        quit()
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W:
            if S[to_h][to_w]==".":
                if visit[(to_h, to_w)]==0:
                    q.appendleft((kyori,to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W:
            if S[to_h][to_w]==".":
                if visit[(to_h, to_w)]==0:
                    q.append((kyori+1, to_h, to_w))

print -1


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
a,b,c = (int(i) for i in input().split())
if (a-c)(b-c)<0: print("Yes")
else: print("No")

### FIXED CODE ###

a,b,c = (int(i) for i in input().split())
if (a-c)*(b-c)<0: print("Yes")
else: print("No")
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
s=[sc[i][0] for i in range(M)]
c=[sc[i][1] for i in range(M)]
sc.sort()
sets=list(set(s))
setc=list(set(c))
if len(sets)!=len(setc):
    ans=-1
if len(setc)==1 and setc[0]==0:
    ans=0
elif sc[0][0]==1 and sc[0][1]==0:
    ans=-1
else:
    if len(sets)==3:
        ans=sc[0][1]*100+sc[1][1]*10+sc[2][1]
    elif len(sets)==2:
        if len(sc)==3:
            sc=[sc[0],sc[2]]
        if sc[0][0]==1:
            if sc[1][0]==2:
                if N==2:
                    ans=sc[0][1]*10+sc[1][1]
                if N==3:
                    ans=sc[0][1]*100+sc[1][1]*10
            if sc[1][0]==3:
                ans=sc[0][1]*100+sc[1][1]
        if sc[0][0]==2:
            ans=100+sc[0][0]*10+sc[0][1]
    elif len(sets)==1:
        if sc[0][0]==1:
            if N==1:
                ans=sc[0][1]
            if N==2:
                ans=sc[0][1]*10
            if N==3:
                ans=sc[0][1]*100
        if sc[0][0]==2:
            if N==1:
                ans=-1
            if N==2:
                ans=sc[0][1]*10
            if N==3:
                ans=100+sc[0][1]*10
        if sc[0][0]==3:
            if N==1:
                ans=-1
            if N==2:
                ans=-1
            if N==3:
                ans=sc[0][1]*100
if len(str(ans))==N:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
s=[sc[i][0] for i in range(M)]
c=[sc[i][1] for i in range(M)]

for i in range(1000):
    if len(str(i)) == N:
        for j in range(M):
            if str(i)[s[j]-1] != str(c[j]):
                break
        else:
            print(i)
            break
else:
    print(-1)
import sys
input = sys.stdin.readline

mod = 10**9 + 7


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

C1 = [1]
for i in range(n - k):
    C1.append((k + i) / (i + 1))
C2 = [1]
for i in range(n - k):
    C2.append(int(C2[i] * C1[i + 1]))

A.sort()
A_max = A[k - 1:]
sum_max = 0
for i in range(n - k + 1):
    sum_max += A_max[i] * C2[i]

A.sort(reverse = True)
A_min = A[k - 1:]
sum_min = 0
for i in range(n - k + 1):
    sum_min += A_min[i] * C2[i]

print((sum_max - sum_min) % mod)


### FIXED CODE ###

import sys
input = sys.stdin.readline

mod = 10**9 + 7


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

FACTORIAL = [1] * (n + 1)
for i in range(1, n + 1):
    FACTORIAL[i] = FACTORIAL[i - 1] * i % mod
INVERSE = [1] * (n + 1)
INVERSE[n] = pow(FACTORIAL[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    INVERSE[i] = INVERSE[i + 1] * (i + 1) % mod

def combination(n, r):
    return FACTORIAL[n] * INVERSE[n - r] % mod * INVERSE[r] % mod

A.sort()
sum_max = 0
for i in range(k - 1, n):
    sum_max = (sum_max + A[i] * combination(i, k - 1)) % mod

A.sort(reverse = True)
sum_min = 0
for i in range(k - 1, n):
    sum_min = (sum_min + A[i] * combination(i, k - 1)) % mod

print((sum_max - sum_min) % mod)
import numpy as np
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    M = len(numbers)
    if M <= K:
        return 0
    dp = np.full((M+1, M+1), N, dtype=int)
    dp[0,:] = 0
    for i, n in enumerate(numbers.values()):
        for j in range(M+1):
            if j > 0:
                dp[i+1,j] = min(dp[i+1,j], dp[i,j-1], dp[i,j] + n)
            else:
                dp[i+1,j] = min(dp[i+1,j], dp[i,j] + n)
    return min(dp[M,:K+1])

N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print solve(N, K, A)

### FIXED CODE ###

print len(filter(lambda c: c=="1", raw_input()))
A,B = map(int, input().split())
cnt = 1
ans = 0
while cnt < B:
    cnt += A-1
    ans += 1
print(ans)

### FIXED CODE ###

S=list(map(str,input()))
T=list(map(str,input()))
cnt=0
for i in range(len(S)):
    if S[i]==T[i]:
        cnt +=1
print(cnt)
from collections import Counter



def main():
    N = int(input())
    a = list(map(int, input().split()))
    a_dict = Counter(a)
    max_count = 0
    for key in a_dict.keys():
        tmp_count = 0
        for i in a_dict.key():
            if abs(key - i) <= 1:
                tmp_count += a_dict[i]
        if tmp_count > max_count:
            max_count = tmp_count
    print(max_count)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def main()->None:
    N = int(sys.stdin.readline())
    a = list(map(int, sys.stdin.readline().split()))
    max_a = max(a)
    # print(max_a)
    l = [0 for _ in range(max_a+2)] # 配列の初期化、固定長、位置が配列の数字で要素がカウント
    for i in a:
        l[i] += 1
    res = 0
    for i in range(0, max_a+1):
        tmp = l[i-1]+l[i]+l[i+1]
        res = max(res, tmp)
    print(res)


if __name__ == "__main__":
    main()
#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
for i in range(N):
    B=A[::]
    del B[i]
    kari=gcdlist(B)
    MAX=max(MAX,kari)
if N == 2:
    MA=max(A)
    g=gcd(A[0],A[1])
    MAX=max(MA,g)
print(MAX)
    

### FIXED CODE ###

#A問題
A,B,T=map(int,input().split())
print(B*int(T/A))
N = int(input())
K = int(input())

now = 1
for i in range(N):
	if(now>=K):
		now*=2
    else:
		now+=K
print(now)

### FIXED CODE ###

N = int(input())
K = int(input())

now = 1
for i in range(N):
    if now <= K:
        now *= 2
    else:
        now+=K
print(now)
a,b,c=map(int,input().split())
 if a+c==2*b:
  print(Yes)
  else:
  print(No)


### FIXED CODE ###

a,b,c=map(int,input().split())
if a+c==2*b:
  print("YES")
else:
  print("NO")
import math
a, b, c = map(int, input().split())

if 4 * math.sqrt(a * b) < c - a - b:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])
inp = input()
print('Yes' if inp[3] == inp[4] and inp[5] == inp[6] else 'No')

### FIXED CODE ###

inp = input()
print('Yes' if inp[2] == inp[3] and inp[4] == inp[5] else 'No')
import numpy as np
n,k,q = map(int, input().split())
a = [input() for _ in range(q)]
point_list  = np.array([k] * n)

for i in a:
    print(point_list)
    point_list -= 1
    point_list[i-1] += 1

for i in point_list:
    if i >0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]
point_list  = [k-q] * n 
for i in a:
    point_list[i-1] += 1
for i in point_list:
    if i >0:
        print('Yes')
    else:
        print('No')
n=int(input())
if '7' in n:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n=input()
if '7' in n:
    print('Yes')
else:
    print('No')
L=int(input())-1
M=0
threelist=[]
j=1
i=1
while i<=10**6:
    i=3**j-1
    threelist.append(i)
    j+=1


threelist=threelist[::-1]

j=0
while True:
    if L>=threelist[j]:
       break
    else:
        j+=1

node=len(threelist)-j

PATH=[]
for i in range(2,2+node):
    PATH.append((i,i+1,0))

    PATH.append((i,i+1,3**(node+2-i-1)))
    PATH.append((i,i+1,2*3**(node+2-i-1)))
    M+=3

while L>0:
    j=0
    while True:
        if L>=threelist[j]:
            break
        else:
            j+=1

    k=len(threelist)-j
    rest=L-(3**k-1)

    PATH.append((1,node+2-k,rest))
    M+=1

    L=rest-1

    if L==0:
        PATH.append((1,node+2,0))
        M+=1
        break
    if L==1:
        PATH.append((1,node+2,0))
        PATH.append((1,node+2,1))
        M+=2
        break

print(node+2,M)
for pa in PATH:
    print(pa[0],pa[1],pa[2])

### FIXED CODE ###

import sys


L=int(input())-1
if L==1:
    print(2,2)
    print(1,2,0)
    print(1,2,1)
    sys.exit()

M=0
threelist=[]
j=1
i=1
while i<=10**6:
    i=3**j-1
    threelist.append(i)
    j+=1


threelist=threelist[::-1]

j=0
while True:
    if L>=threelist[j]:
       break
    else:
        j+=1

node=len(threelist)-j

PATH=[]
for i in range(2,2+node):
    PATH.append((i,i+1,0))

    PATH.append((i,i+1,3**(node+2-i-1)))
    PATH.append((i,i+1,2*3**(node+2-i-1)))
    M+=3

while L>0:
    j=0
    while True:
        if L>=threelist[j]:
            break
        else:
            j+=1

    k=len(threelist)-j
    rest=L-(3**k-1)

    PATH.append((1,node+2-k,rest))
    M+=1

    L=rest-1

    if L==0:
        PATH.append((1,node+2,0))
        M+=1
        break
    if L==1:
        PATH.append((1,node+2,0))
        PATH.append((1,node+2,1))
        M+=2
        break

print(node+2,M)
for pa in PATH:
    print(pa[0],pa[1],pa[2])
# -*- coding:utf-8 -*-
def euc(a,b):
    if b == 0:
        return a
    else:
        return euc(b, a%b)

N = int(input())
T = [ int(input()) for tmp in range(N) ]
if len(T) > 1:
    a = T.pop()
    b = T.pop()
    lcm = a*b/euc(a,b)
    for tmp in T:
        lcm = tmp*lcm/euc(tmp,lcm)
    print(int(lcm))
else:
    print(T.pop())

### FIXED CODE ###

# -*- coding:utf-8 -*-
def euc(a,b):
    if b == 0:
        return a
    else:
        return euc(b, a%b)

N = int(input())
T = [ int(input()) for tmp in range(N) ]
if len(T) > 1:
    a = T.pop()
    b = T.pop()
    lcm = a*b//euc(a,b)
    for tmp in T:
        lcm = tmp*lcm//euc(tmp,lcm)
    print(lcm)
else:
    print(T.pop())
n,k = map(int,input().split())
h = list(int,input().split())
ans = 0
for i in range(n):
  if h[i]>=k:
    ans += 1
    
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
for i in range(n):
  if h[i]>=k:
    ans += 1
    
print(ans)
41 7 46
26 89 2
78 92 8
5
6
45
16
57
17


### FIXED CODE ###

bingo = []
for i in range(3):
    bingo.append(list(map(int, input().split())))

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                bingo[i][j] = "o"

for i in range(3):
    flag = 0
    for j in range(3):
        if bingo[i][j] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
    flag = 0
    for j in range(3):
        if bingo[j][i] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
# 斜め
if (
    bingo[0][0] == bingo[1][1] == bingo[2][2] == "o"
    or bingo[0][2] == bingo[1][1] == bingo[2][0] == "o"
):
    print("Yes")
    exit()
print("No")
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

for i in range(N):
	x[i] -= X
if N == 1:
	print(abs(x[0]))
else:
	a = x[0]
	for i in range(N - 1):
		b = x[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a

print(abs(a))

### FIXED CODE ###

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

for i in range(N):
	x[i] -= X
if N == 1:
	print(abs(x[0]))
else:
	a = x[0]
	for i in range(N - 1):
		b = x[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	print(abs(a))
h,w,m=list(map(int,input().split()))

bom=[[0 for i in range(w+1)] for i in range(h+1)]

for i in range(m):
  h,w=list(map(int,input().split()))
  bom[h][w]=1


from itertools import accumulate
for i in range(h+2):
  bom[i]=list(accumulate(bom[i]))


for i in range(1,h+2):
  for j in range(w+1):
    bom[i][j]=bom[i][j]+bom[i-1][j]

ans=0  
for i in range(1,h+2):
  for j in range(1,w+1):
    ans=max(ans,bom[h][w]-(bom[i-1][j-1]+bom[i-1][w]-bom[i-1][j]+bom[h][j-1]-bom[i][j-1]+bom[h][w]-bom[i][w]-bom[h][j]+bom[i][j]))
print(ans)


  

### FIXED CODE ###

h,w,m=list(map(int,input().split()))
s=[]
t=[]

for i in range(m):
  H,W=list(map(int,input().split()))
  s.append(H)
  t.append(W)
  
from collections import Counter
u=Counter(s)
v=Counter(t)
max_u=max(u.values())
max_u_set = set([kv[0] for kv in u.items() if kv[1]==max_u])
max_v=max(v.values())
max_v_set = set([kv[0] for kv in v.items() if kv[1]==max_v])
check=len(max_u_set)*len(max_v_set)

ans=0
for i in range(m):
  if u[s[i]]==max_u and v[t[i]]==max_v:
    ans=ans+1

if check-ans==0:
  print(max_u+max_v-1)
else:
  print(max_u+max_v)
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]
    for i in range(n):
        if len(g[i]) > 1:
            cnt = 0
            for j in g[i]:
                if len(g[j]) == 1:
                    cnt += 1
            if cnt > 1:
                print("First")
                return
    print(1/0)


main()

### FIXED CODE ###

def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    g = [set() for _ in [0]*n]
    [g[a-1].add(b-1) for a, b in ab]
    [g[b-1].add(a-1) for a, b in ab]
    only = []
    sign = [False]*n
    for i in range(n):
        if len(g[i]) == 1:
            only.append(i)
    while only:
        i = only.pop()
        if not g[i]:
            print("Second")
            return
        j = g[i].pop()
        g[j].remove(i)
        if sign[i] and not g[j]:
            print("First")
            return
        if not sign[i] and sign[j]:
            print("First")
            return
        if not sign[j] and not sign[i]:
            sign[j] = True
        if len(g[j]) == 1:
            only.append(j)


main()
n = int(input())

otoshidamas = []
kingaku = 0
for i in range(n):
  otoshidamas.append([float(item) for item in input()])
  
for item in otoshidamas:
  if otoshidamas[1] == "JPY":
    kingaku += otoshidamas[0]
  else:
    kingaku += otoshidamas[0] * 380000.0

print(kingaku)

### FIXED CODE ###

n = int(input())
 
otoshidamas = []
kingaku = 0
for i in range(n):
  otoshidamas.append(input().split())
  
for item in otoshidamas:
  if item[1] == "JPY":
    kingaku += float(item[0])
  else:
    kingaku += float(item[0]) * 380000.0
 
print(kingaku)
n = int(input())
l = map(int, input().split())

ans = l[0] + l[-1]
for i in range(n-2):
  ans += min(l[i], l[i+1])
print(ans)

### FIXED CODE ###

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

ans = l[0] + l[-1]
for i in range(n-2):
  ans += min(l[i], l[i+1])
print(ans)
S=int(input())
h=s//3600
m=(s//60)%60
s=S%60
print(h,";",m,":",s,sep="")

### FIXED CODE ###

S = int(input())
h = S // 3600
m = (S // 60) % 60
s = S % 60
print(h,":",m,":",s,sep="")