Harryxun/stf_run huggingface dataset:
n, m, k = map(int, input().split())

friend = [[] for _ in range(n)]
block = [[] for _ in range(n)]

for _ in range(m):
  a, b = map(int, input().split())
  friend[a-1].append(b-1)
  friend[b-1].append(a-1)
  
for _ in range(k):
  c, d = map(int, input().split())
  block[c-1].append(d-1)
  block[d-1].append(c-1)
  
groups = []
active = [True] * n
belong = [0] * n
g_index = 0
while any(active):
  idx = active.index(True)
  g = [idx]
  active[idx] = False
  belong[idx] = g_index
  stack = [idx]
  while stack:
    v = stack.pop()
    for i in friend[v]:
      if active[i]:
        stack.append(i)
        active[i] = False
        belong[i] = g_index
        g.append(i)
  groups.append(g)
  g_index += 1
  
for i in range(n):
  size = len(groups[belong[i]]) - 1
  for j in groups[belong[i]]:
    if j in friend[i] or j in block[i]:
      size -= 1
  print(size, end=' ')

### FIXED CODE ###

n = int(input())
print((n+1) // 2)
a,b=map(int,input(),split())
x=(a+b)/2
if (a+b)%2==0:
  print(x)
else:
  print(x+1)


### FIXED CODE ###

a,b=map(int,input().split())
x=(a+b)/2
if (a+b)%2==0:
  print(int(x))
else:
  print(int(x)+1)
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)]
    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]-1] = c[i][1]

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

if __name__ == "__main__":
    main()

### 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()
K = int(input())
A,B = map(int,input().split())

for i in range(A,B+1):
    if i%K=0:
        return print("OK")
return print("NG")


### FIXED CODE ###

K = int(input())
A,B = map(int,input().split())
flag=0
for i in range(A,B+1):
    if i%K==0:
        flag=1

if flag==1:
    print("OK")
else:
    print("NG")
N = int(input())
  
for h in range(1, 3501):
  if 1 / h < 4 / N:
    for n in range(1, h):
      w = 1 / (4 / N - 1 / h - 1 / n)
      if w > 3500:
        break
      if w.is_integer():
        print(h, n, int(w))
        exit()

### FIXED CODE ###

N = int(input())

for h in range(1, 3501):
  for n in range(h, 3501):
    if (4 * h * n - N * n - h * N) == 0:
      continue
    w = (N * h * n) / (4 * h * n - N * n - h * N)
    if w.is_integer() and 1 <= w < 3501:
      print(h, n, int(w))
      exit()
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n=II()
	A=LI()

	A=np.array(A)

	B=np.cumsum(A)
	C=np.cumsum(A[::-1])

	#print(B,C)

	D=abs(B[:-1]-C[:-1][::-1])
	#print(D)

	print(np.min(D))









if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

	ans=10**18
	cnt=0

	Asum=sum(A)
	for i in range(n):
		cnt+=A[i]
		ans=min(ans,abs(Asum-2*cnt))
	print(ans)









if __name__ == "__main__":
	main()
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

dp_b = [0] * n
j = 0
for i in range(n):
  while j < n:
    if B[i] >= C[j]:
      dp_b[i] = j
      break
    j += 1
  if j == n:
    dp_b[i] = n

for i in range(1, n):
  dp_b[i] = dp_b[i] + dp_b[i-1]

ans = 0
j = 0
for i in range
  while j < n:
    if A[i] >= B[j]:
      if j == 0:
        break
      else:
        ans += B[j-1]
        break
    j += 1
    if j == n:
      ans += B[n-1]
  
print(ans)

### FIXED CODE ###

n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

dp_b = [0] * n
j = 0
for i in range(n):
    while j < n:
        if B[i] >= C[j]:
            dp_b[i] = j
            break
        j += 1
    if j == n:
        dp_b[i] = n

for i in range(1, n):
    dp_b[i] = dp_b[i] + dp_b[i - 1]

ans = 0
j = 0
for i in range(n):
    while j < n:
        if A[i] >= B[j]:
            if j == 0:
                break
            else:
                ans += dp_b[j - 1]
                break
        j += 1
    if j == n:
        ans += dp_b[n - 1]

print(ans)
import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

def on(x,n,nn,k):
	global a
	for i in range(len(x[n])):
		if not x[n][i][0] == nn:
			if (k + x[n][i][1]) % 2 == 0:
				a[x[n][i][0]] = 0
				on(x,x[n][i][0],n,(k + x[n][i][1]) % 2)
			else:
				on(x,x[n][i][0],n,(k + x[n][i][1]) % 2)


n = int(input())

a = [1 for i in range(n)]
a[0] = 0
b = [[] for i in range(n)]

for i in range(n-1):
	z,x,c = m();
	b[z-1].append([x-1,c])
	b[x-1].append([z-1,c])

on(b,0,0,0)

for i in range(n):
	print(a[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
nnn = int(input())

a = [-2 for i in range(nnn)]
a[0] = 0

def m():
	return map(int,input().split())


def oon(x,n,nn,k):
	global a
	for i in range(len(x[n])):
		if x[n][i][0] != nn and a[nn] != -2:
			p = (k + x[n][i][1]) % 2
			if p == 0:
				a[x[n][i][0]] = 0
			else:
				a[x[n][i][0]] = 1
			oon(x,x[n][i][0],n,p)



b = [[] for i in range(nnn)]

for i in range(nnn-1):
	z,x,c = m();
	b[z-1].append([x-1,c])
	b[x-1].append([z-1,c])

oon(b,0,0,0)

for i in range(nnn):
	print(a[i])
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10**7
print(ball.count('b',0,N))


### FIXED CODE ###

N,A,B=map(int,input().split())
if N == (N//(A+B))*(A+B):
    print(N-(N//(A+B))*(B))
elif (N//(A+B))*(A+B)<N <= (N//(A+B))*(A+B)+A:
    print(N-(N//(A+B))*(B))
else:
    print((N//(A+B)+1)*(A))
import collections as cl
N = int(input())
A = list(map(int,inpput().split()))
cn = cl.Counter(A)
sumC = sum([n*(n-1)//2 for n in cl.values()])
for k in range(N):
  print(sumC - cn[A[k]] +1)

### FIXED CODE ###

import collections
N = int(input())
li = list(map(int, input().split()))
cn = collections.Counter(li)
sumC = sum([n*(n-1)//2 for n in cn.values()])
for k in range(N):
    print(sumC-cn[li[k]] + 1)
A,B= map(int, input().split())
if A<=8 and B<=8;
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

A,B= map(int, input().split())
if A<=8 and B<=8:
    print('Yay!')
else:
    print(':(')
n,m = map(int, input().split())

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if n == 1 and m == 1:
    print(0)
elif n == 1 and m != 1:
    print(comb(m,2))
elif n != 1 and m == 1:
    print(comb(n,2))
else:
    print(comb(n,2) + comb(m,2))

### FIXED CODE ###

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

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if n == 0:
    base1 = 0
elif n == 1:
    base1 = 0
else:
    base1 = comb(n,2)

if m == 0:
    base2 = 0
elif m == 1:
    base2 = 0
else:
    base2 = comb(m,2)

print(base1 + base2)
a,b = map(int, input().split())
diff = b - a
def tower(n):
    if n < 1:
        return 0
    return n + tower(n - 1)
print(int(tower(diff) - b))

### FIXED CODE ###

a,b = map(int, input().split())
print(int(((b-a)*(b-a+1))/2) - b)
import sys
input = sys.stdin.readline

X, Y, A, B, C = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)

pq = p[:X] + q[:Y]
if len(pq) < X + Y:
    pq += [0] * (X + Y - len(pq))
pq.sort()
for i in range(min(C, A + B)):
    if pq[i] < r[i]:
        pq[i] = r[i]
print(sum(pq))

### FIXED CODE ###

import sys
input = sys.stdin.readline

X, Y, A, B, C = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)

pq = p[:X] + q[:Y]
if len(pq) < X + Y:
    pq += [0] * (X + Y - len(pq))
pq.sort()
for i in range(min(C, len(pq))):
    if pq[i] < r[i]:
        pq[i] = r[i]
print(sum(pq))
n, a, b = map(int, input().split())
x="b"*a+"r"*b
x= x*(10**100)
strx = x[0:n]
def split(w):
    return [all for all in w]
def countX(lst, x): 
    return lst.count(x) 
listx = split(strx)
print(countX(listx))

### FIXED CODE ###

n,a,b = map(int,input().split())
x = n//(a+b)
if n - x*(a+b) > a:
    Y =a
else:
    Y=n - x*(a+b)
print(a*x+Y)
n,k = map(int,input().split())
ls = list(map(int,input().split()))
di = [1]
fi = [-1]*(n+1)
a = 0
for i in range(k):
    if fi[ls[a]] == -1:
        fi[ls[a]] = i
        a = ls[a] - 1
    else:
        ind = fi[ls[a]]
        t = (k - ind) % (max(fi) - ind)
        t += ind
        print(fi.index(t))
        break
else:
    print(a)

### FIXED CODE ###

n,k = map(int,input().split())
ls = list(map(int,input().split()))
fi = [-1]*(n+1)
fi[1] = 0
a = 0
aa = 0
for i in range(k):
    if fi[ls[a]] == -1:
        fi[ls[a]] = i + 1
        aa = a
        a = ls[a] - 1
    else:
        ind = fi[ls[a]]
        t = (k - ind) % (max(fi) + 1 - ind)
        t += ind
        print(fi.index(t))
        break
else:
    print(ls[aa])
import numpy as np
import fractions
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in range(0,n):
  lcm = lcm * a[i] // fractions.gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
b = np.zeros(n)


for i in range(0,n):
  while a[i] % 2 == 0:
    b[i] += 1
    a[i] = a[i] // 2



for i in range(1,n):
  for j in range(0,i):
    if b[i] != b[j]:
      ans = 0
      break

print(ans)

### FIXED CODE ###

from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
b = []
lcm = 1
for i in a:
    b.append(i//2)
for i in b:
  lcm = lcm // gcd(lcm,i) * i
ans = m // lcm
sum = 0
for i in b:
  if (lcm // i) % 2 == 1:
    sum += 1
if sum != len(a):
  print(0)
elif ans%2 ==1:
    print((ans+1)//2)
else:
    print(ans//2)
from math import gcd
from functools import reduce

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)

### FIXED CODE ###

from fractions import gcd
from functools import reduce
n,x = map(int,input().split())
 
l=list(map(int,input().split()))
l=list(map(lambda i: abs(i-x),l))
 
x = reduce(gcd,l)
print(x)
inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(1, int(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)
    

### FIXED CODE ###

def f():
  n, m = map(int, input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())
#include <bits/stdc++.h>

using namespace std;

int main() {
	int A, B; cin >> A >> B;
	int ans = 0;
	int outlet = 1;
	while (outlet < B) {
		--outlet;
		outlet += A;
		++ans;
	}
	cout << ans << endl;
}

### FIXED CODE ###

import math
a,b = map(int, input().split())

print(math.ceil((b-1)/(a-1)))
import math
import fractions
def isprime(number):
    for i in range(2, round(math.sqrt(number)) + 1):
        if number % i == 0:
            return False
    return True

A, B = map(int, input().split())
count = 1
N = fractions.gcd(A, B)

for i in range(2, N + 1):
  	if i != 2 and i % 2 == 0:
    	continue
    if N % i == 0:
        if isprime(i):
            count += 1

print(str(count))


### FIXED CODE ###

from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 1:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)
import sys
import math
from collections import Counter
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B=MI()

print(lcm(A,B))

### FIXED CODE ###

import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
A,B=MI()
 
print(lcm(A,B))
n = input()
N = int(n)

m = N % 10

if (m == 3):
    print(bon)
elif (m == 0 or m == 1 or m == 6 or m == 8):
    print(pon)
else:
    print(hon)

### FIXED CODE ###

n = input()
N = int(n)

m = N % 10

if (m == 3):
    print("bon")
elif (m == 0 or m == 1 or m == 6 or m == 8):
    print("pon")
else:
    print("hon")
n, m = map(int, input().split())
a = [0 for _ in range(n+1)]
for i in range(m):
    a[int(input())] = 1

dp = [-1 for _ in range(n+1)]
dp[-1], dp[-2], dp[-3] = 0, 1, 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]
print(dp[0]%1000000007)

### FIXED CODE ###

n, m = map(int, input().split())
IN = [int(input()) for _ in range(m)]

# i段目が壊れているならa[i] = 1,そうでないならa[i] = 0
a = [0 for _ in range(n+1)]
for i in IN:
    a[i] = 1

# dp[i] := i段目から最上段にたどり着くまでの移動方法の数
# dp[i] = 0 (a[i] が 1)
# dp[i] = dp[i+1] + dp[i+2] (それ以外)
dp = [-1 for _ in range(n+1)]

dp[n] = 0
if a[n-1] == 1:
    dp[n-1] = 0
else:
    dp[n-1] = 1
if a[n-2] == 1:
    dp[n-2] = 0
elif dp[n-1] == 0:
    dp[n-2] = 1
else:
    dp[n-2] = 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]

print(dp[0]%(10 ** 9 + 7))
a = int(input())
if a == 1:
    print("Hello World")
else:
    b, c = map(int, input().split())
    print('{}'.format(b+c))

### FIXED CODE ###

a = int(input())
if a == 1:
    print("Hello World")
else:
    b = int(input())
    c = int(input())
    print('{}'.format(b+c))
H, W, M = map(int, input().split())

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_idx + minus)

### FIXED CODE ###

H, W, M = map(int, input().split())

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)
a=int(input())
b,c=[int(x) for x in input().split()]
s=input()
print(a+b+c, s)



### FIXED CODE ###

b,c=[int(x) for x in input().split()]
if c>=b:
    print("unsafe")
else:
    print("safe")
#!/usr/bin/env python3
import sys


def solve_(S: str, K: int):
    mn = 'z'
    tmp = set()
    for i, c in enumerate(S):
        if c < mn:
            tmp = set()
            for j in range(5):
                tmp.add(S[i:i + j + 1])
            mn = c
        elif c == mn:
            for j in range(5):
                tmp.add(S[i:i + j + 1])
    #print(tmp)
    if len(tmp) < K:
        s = ''
        for c in S:
            if c != mn:
                s += c
        return solve_(s, K - len(tmp))
    else:
        tmp = list(tmp)
        tmp.sort()
        return tmp[K - 1]

def solve(S, K):
    ret = solve_(S, K)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve_(S: str, K: int, used):
    #print(S, K, used)
    mn = 'z'
    tmp = set()
    for i, c in enumerate(S):
        if c < mn and not c in used:
            tmp = set()
            for j in range(5):
                tmp.add(S[i:i + j + 1])
            mn = c
        elif c == mn:
            for j in range(5):
                tmp.add(S[i:i + j + 1])
    if len(tmp) < K:
        used.append(mn)
        return solve_(S, K - len(tmp), used)
    else:
        tmp = list(tmp)
        tmp.sort()
        return tmp[K - 1]

def solve(S, K):
    ret = solve_(S, K, [])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()
x = int(input())
print(x * x * x *)

### FIXED CODE ###

x = int(input())
print(x * x * x)
n, l = map(int, input().split())
str_list = [input() for i in range(3)]

str_list.sort()

print("".join(str_list))



### FIXED CODE ###

n, l = map(int, input().split())
str_list = [input() for i in range(n)]

str_list.sort()

print("".join(str_list))
d, s, t = [int(i) for i in input().split()]
if s * t >= d:
  	print("Yes")
else
	print("No")

### FIXED CODE ###

d, s, t = [int(i) for i in input().split()]
if s * t >= d:
  	print("Yes")
else:
	print("No")
List = list(map(int, input().split()))
List.sort()
res = List[2]-List[1]
Litt[1] = List[2]
List[0] += res
mid = List[2] - List[0]
if mid % 2 == 1:
  res += mid //2 +1
else:
  res += mid //2
print(res)

### FIXED CODE ###

List = list(map(int, input().split()))
List.sort()
res = List[2]-List[1]
List[1] = List[2]
List[0] += res
mid = List[2] - List[0]
if mid % 2 == 1:
  res += mid // 2 +2
else:
  res += mid //2
print(res)
r,c,k = map(int,input().split())
t = [[0 for i in range(c)] for i in range(r)]
for i in range(k):
    a,b,z = map(int,input().split())
    t[a-1][b-1] = z
dp = [[[0 for i in range(c)]for i in range(r)]for i in range(4)]
dp[0][0][0] = 0
dp[1][0][0] = t[0][0]
dp[2][0][0] = t[0][0]
dp[3][0][0] = t[0][0]
for i in range(r-1):
    dp[0][i+1][0] = dp[1][i][0]
    for j in range(1,4):
        dp[j][i+1][0] = dp[1][i][0]+t[i+1][0]
for i in range(c-1):
    dp[0][0][i+1] = 0
    for j in range(1,4):
        dp[j][0][i+1] = max(dp[1][0][i],t[0][i+1])
    for j in range(2,4):
        dp[j][0][i+1] = max(dp[2][0][i],dp[1][0][i]+t[0][i+1])
    dp[3][0][i+1] = max(dp[3][0][i],dp[2][0][i]+t[0][i+1])
for i in range(r-1):
    for j in range(c-1):
        for s in range(0,4):
            dp[s][i+1][j+1] =  max(dp[0][i+1][j],dp[3][i][j+1])
        for s in range(1,4):
            dp[s][i+1][j+1] = max(dp[0][i+1][j]+t[i+1][j+1],dp[1][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
        for s in range(2,4):
            dp[s][i+1][j+1] = max(dp[1][i+1][j]+t[i+1][j+1],dp[2][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
        dp[3][i+1][j+1] = max(dp[2][i+1][j]+t[i+1][j+1],dp[3][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
print(dp[3][r-1][c-1])

if __name__=='__main__':
    main()

### FIXED CODE ###

def run():
    # sys.stdin.readline()
    import sys
    input = sys.stdin.readline
    r,c,k = map(int,input().split())
    t = [[0 for i in range(c)] for i in range(r)]
    for i in range(k):
        a,b,z = map(int,input().split())
        t[a-1][b-1] = z
    t = tuple(t)
    dp = [[[0 for i in range(c)]for i in range(r)]for i in range(4)]
    dp[0][0][0] = 0
    dp[1][0][0] = t[0][0]
    dp[2][0][0] = t[0][0]
    dp[3][0][0] = t[0][0]
    for i in range(r-1):
        dp[0][i+1][0] = dp[1][i][0]
        for j in range(1,4):
            dp[j][i+1][0] = dp[1][i][0]+t[i+1][0]
    for i in range(c-1):
        dp[0][0][i+1] = 0
        for j in range(1,4):
            dp[j][0][i+1] = max(dp[1][0][i],t[0][i+1])
        for j in range(2,4):
            dp[j][0][i+1] = max(dp[2][0][i],dp[1][0][i]+t[0][i+1])
        dp[3][0][i+1] = max(dp[3][0][i],dp[2][0][i]+t[0][i+1])
    for i in range(r-1):
        for j in range(c-1):
            u = max(dp[0][i+1][j],dp[3][i][j+1])
            for s in range(0,4):
                dp[s][i+1][j+1] =  u
            u = max(dp[0][i+1][j]+t[i+1][j+1],dp[1][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
            for s in range(1,4):
                dp[s][i+1][j+1] = u
            u = max(dp[1][i+1][j]+t[i+1][j+1],dp[2][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
            for s in range(2,4):
                dp[s][i+1][j+1] = u
            dp[3][i+1][j+1] = max(dp[2][i+1][j]+t[i+1][j+1],dp[3][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
    print(dp[3][r-1][c-1])

if __name__ == "__main__":
    run()