F. ⅓ оf а Рrоblеm
Source: codeforces
Tags: *special, math

-----Examples-----
Input:
0 1
Output:
0

C++ solution:
#include <iostream>
#include <cstdlib> // for abs function

using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;
    
    // Calculate each term carefully to prevent overflow
    long long term1 = 12LL * a;
    long long term2 = 15LL * a * b;
    long long term3 = 3LL * b * b;
    long long term4 = abs(a - b);
    long long term5 = 2LL;
    
    // Calculate in an order that minimizes overflow risk
    long long result = term2 - term3;  // Largest terms first
    result += term1;
    result += term4;
    result += term5;
    
    cout << result << endl;
    return 0;
}

Go solution:
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var a, b int64
	fmt.Scan(&a, &b)

	// Convert to big.Int to handle arbitrarily large numbers
	bigA := big.NewInt(a)
	bigB := big.NewInt(b)

	// Calculate each term precisely
	twelveA := new(big.Int).Mul(big.NewInt(12), bigA)
	fifteenAB := new(big.Int).Mul(big.NewInt(15), new(big.Int).Mul(bigA, bigB))
	threeBSquared := new(big.Int).Mul(big.NewInt(3), new(big.Int).Mul(bigB, bigB))
	absDiff := new(big.Int).Abs(new(big.Int).Sub(bigA, bigB))
	two := big.NewInt(2)

	// Combine all terms without overflow
	result := new(big.Int).Add(twelveA, fifteenAB)
	result.Sub(result, threeBSquared)
	result.Add(result, absDiff)
	result.Add(result, two)

	fmt.Println(result)
}

Java solution:
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // Read input as BigInteger to handle any size numbers
        BigInteger a = new BigInteger(scanner.next());
        BigInteger b = new BigInteger(scanner.next());
        
        // Calculate each term separately
        BigInteger term1 = BigInteger.valueOf(12).multiply(a);
        BigInteger term2 = BigInteger.valueOf(15).multiply(a).multiply(b);
        BigInteger term3 = BigInteger.valueOf(3).multiply(b).multiply(b).negate();
        BigInteger term4 = a.subtract(b).abs();
        BigInteger term5 = BigInteger.valueOf(2);
        
        // Combine all terms
        BigInteger result = term1.add(term2)
                                .add(term3)
                                .add(term4)
                                .add(term5);
        
        System.out.println(result);
    }
}

JavaScript solution:
const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line) => {
    const [aStr, bStr] = line.trim().split(' ');
    const a = parseInt(aStr, 10);
    const b = parseInt(bStr, 10);
    
    // Break down the calculation to prevent overflow
    const term1 = 12 * a;
    const term2 = 15 * a * b;
    const term3 = -3 * Math.pow(b, 2);
    const term4 = Math.abs(a - b);
    const term5 = 2;
    
    // Calculate using proper order of operations
    const result = (term1 + term2) + (term3 + term4) + term5;
    
    console.log(result.toString());
    rl.close();
});

Python solution:
a, b = map(int,input().split())
print(12*a+15*a*b-3*b*b+abs(a-b)+2)

Ruby solution:
a, b = gets.split.map(&:to_i)
result = 12 * a + 14 * a * b + (a - b).abs + (a - 3 * b) * b + 2
puts result