Go: package main

import "fmt"

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	ans := 10000
	ans = min(ans, abs((a+b)-(c+d)))
	ans = min(ans, abs((a+c)-(b+d)))
	ans = min(ans, abs((a+d)-(b+c)))
	fmt.Println(ans)
}

Python: a, b, c, d = map(int,input().split())
print(min(abs((a+b)-(c+d)),abs((a+c)-(b+d)),abs((a+d)-(c+b))))

Python: num_list = sorted(list(map(int,input().split()))) #標準入力をして小さい順にしリストに入れる
num1 = num_list[0] + num_list[3] #リストの１番大きい数と１番小さい数を足す
num2 = num_list[1] + num_list[2] #リストの2番目と三番目を足す
print(max(num1,num2) - min(num1,num2)) #2つの数の大きい方から小さい方を引く

Python: l = sorted(list(map(int, input().split())))

print(abs((l[0] + l[3]) - (l[1] + l[2])))

Python: import itertools
a = list(map(int, input().split()))
b = sum(a)
comb = itertools.combinations(a, 2)
sa = []
for i in comb:
    sa.append(abs(b - 2 *sum(i)))
print(min(sa))

Python: a = list(map(int,input().split()))
print(min(abs(sum(a)-(a[0]+a[i])*2) for i in range(1,4)))

Python: A = list(map(int,input().split(" ")))
A = sorted(A)
print(abs(A[3]+A[0]-A[1]-A[2]))

Python: a, b, c, d = map(int, input().split())
x = [a+b-c-d, a+c-b-d, a+d-b-c, b+c-a-d, b+d-a-c, c+d-a-b]
print(min(map(abs, x)))

Python: def main():
    A= list(map( int, input().split()))
    ans = abs(A[0]+A[1]-A[2]-A[3])
    for i in range(4):
        for j in range(4):
            if i == j:
                continue
            now = 0
            for t in range(4):
                if t == i or t == j:
                    now += A[t]
                else:
                    now -= A[t]
            if abs( now) < ans:
                ans = abs(now)
    print(ans)
    
if __name__ == '__main__':
    main()

Python: import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math


def main():
    a,b,c,d = getList()
    ans = min([abs(a+b-c-d), abs(a+c-b-d), abs(a+d-b-c)]
    )
    print(ans)
if __name__ == "__main__":
    main()

Python: a,b,c,d=map(int,input().split())
ans=1e100
for x in (b,c,d):
    ans=min(ans,abs(a+x*2-(b+c+d)))
print(ans)

Python: a = list(map(int,input().split()))
a.sort()
print(abs(a[0]+a[3]-a[2]-a[1]))

Python: a,b,c,d = map(int,input().split())

def f(x,y):
    return abs(x-y)
ans = min(f(a+b,c+d), f(a+c,b+d), f(a+d,b+c))
print(ans)

Python: a,b,c,d = map(int, input().split())

ans = 1<<30

def go(x, y):
    global ans
    ans = min(ans, abs(x-y))

go(a+b,c+d)
go(a+c,b+d)
go(a+d,b+c)

print(ans)

Python: A = sorted(list(map(int, input().split())))
print(abs(A[0]+A[3]-A[1]-A[2]))

Python: A=list(map(int,input().split()))

x=min(A)+max(A)
y=sum(A)-x

print(abs(x-y))

Python: import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = LIST()
A.sort()
a = A[0] + A[3]
b = A[2] + A[1]
# print(A)
print(abs(a - b))

Python: A = sorted(list(map(int, input().split())))
print(abs(A[3]+A[0]-A[1]-A[2]))

Python: #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = list(map(int, input().split()))
    T = sum(s)
    ans = 100000
    for i in range(4):
        for j in range(i+1,4):
            ans = min(abs(2*(s[i]+s[j])-T), ans)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Python: import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
A = list(map(int,read().split()))
S = sum(A)
answer = 10 ** 10
for a,b in itertools.combinations(A,2):
    S1 = a + b
    S2 = S - S1
    x = abs(S1 - S2)
    if answer > x:
        answer = x
print(answer)

Python: #!/usr/bin/env python3
import sys
input = sys.stdin.readline

power = [int(item) for item in input().split()]
power.sort()
print(abs(power[0] + power[3] - power[1] - power[2]))

Python: from heapq import *
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    aa=LI()
    aa.sort()
    print(abs(aa[0]+aa[3]-aa[2]-aa[1]))

main()

Python: a,b,c,d = map(int,input().split())
tuyoi = max(a,b,c,d) + min(a,c,b,d)
print(abs(a+b+c+d-2*tuyoi))

Python: li = list(map(int, input().split()))

ans = 10 ** 9
for bit_state in range(1 << 4):
    if bin(bit_state).count("1") == 2:
        tmp1 = 0
        tmp2 = 0
        for i in range(4):
            if bit_state & (1 << i):
                tmp1 += li[i]
            else:
                tmp2 += li[i]
        ans = min(ans, abs(tmp1 - tmp2))
print(ans)

Python: nums = list(int(x) for x in input().split())
nums.sort()
team_a = 0
team_b = 0
team_a += nums[0]
team_a += nums[3]
team_b += nums[1]
team_b += nums[2]
print(abs(team_a -team_b ))

Python: l = list(map(int, input().split()))
ans = tot = sum(l)
for i in range(3):
    for j in range(i+1,4):
        cur = l[i] + l[j]
        c = abs(tot - cur * 2)
        if ans > c:
            ans = c
print(ans)

C++: #include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Fri Mar 20 13:05:31 JST 2020
 **/

template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}

signed main() {
    vector<Int> a(4);
    REP(i, 4) cin >> a[i];
    vector<Int> perm(4);
    perm[2] = perm[3] = 1;
    Int ans = 1e9;
    do {
        Int x = 0, y = 0;
        REP(i, 4) {
            (perm[i] ? x : y) += a[i];
        }
        chmin(ans, abs(x - y));
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}