#include #include #include using namespace std; long int masks[15] = {9090400, 8499400, 5926800, 8547000, 4958200, 4422600, 5751200, 4175600, 6309600, 5865200, 6604400, 4635000, 10663400, 8087200, 4554000}; long ans = 1000000000; void dfs(int n, long h1, long h2) { if (n == 15) { ans = min(ans, abs(h1 - h2)); return; } dfs(n + 1, h1 + masks[n], h2); dfs(n + 1, h1, h2 + masks[n]); } int main() { dfs(0, 0, 0); cout << ans; }