Problem:
Score : 300 points

Problem Statement

You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:

Choose two among A, B and C, then increase both by 1.

Choose one among A, B and C, then increase it by 2.

It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Constraints

0 \leq A,B,C \leq 50

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the minimum number of operations required to make A, B and C all equal.

Sample Input 1

2 5 4

Sample Output 1

2

We can make A, B and C all equal by the following operations:

Increase A and C by 1. Now, A, B, C are 3, 5, 5, respectively.

Increase A by 2. Now, A, B, C are 5, 5, 5, respectively.

Sample Input 2

2 6 3

Sample Output 2

5

Sample Input 3

31 41 5

Sample Output 3

23

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    ll a,b,c;
    cin>>a>>b>>c;
    vl ngo = {a,b,c};
    sort(all(ngo));
    if(ngo[2]%2 == 0 && ngo[1]%2 == 0 && ngo[0]%2 == 0){
        cout<<((ngo[2]-ngo[0])/2+(ngo[2]-ngo[1])/2)<<endl;
    }
    else if(ngo[2]%2 == 1 && ngo[1]%2 == 0 && ngo[0]%2 == 0){
        cout<<((ngo[1]-ngo[0])/2+ngo[2]-ngo[1])<<endl;
    }
    else if(ngo[2]%2 == 0 && ngo[1]%2 == 1 && ngo[0]%2 == 0){
        cout<<(1+(ngo[2]+1-ngo[1])/2+(ngo[2]+1-ngo[0])/2)<<endl;
    }
    else if(ngo[2]%2 == 0 && ngo[1]%2 == 0 && ngo[0]%2 == 1){
        cout<<(1+(ngo[2]+1-ngo[1])/2+(ngo[2]+1-ngo[0])/2)<<endl;
    }
    else if(ngo[2]%2 == 1 && ngo[1]%2 == 1 && ngo[0]%2 == 0){
        cout<<(1+(ngo[2]+1-ngo[1])/2+(ngo[2]+1-ngo[0])/2)<<endl;
    }
    else if(ngo[2]%2 == 1 && ngo[1]%2 == 0 && ngo[0]%2 == 1){
        cout<<(1+(ngo[2]+1-ngo[1])/2+(ngo[2]+1-ngo[0])/2)<<endl;
    }
    else if(ngo[2]%2 == 0 && ngo[1]%2 == 1 && ngo[0]%2 == 1){
        cout<<((ngo[1]-ngo[0])/2+ngo[2]-ngo[1])<<endl;
    }
    else if(ngo[2]%2 == 1 && ngo[1]%2 == 1 && ngo[0]%2 == 1){
        cout<<((ngo[2]-ngo[1])/2+(ngo[2]-ngo[0])/2)<<endl;
    }
	return 0;
}