#include <iostream>
#include <iomanip>

using namespace std;

int digs(const char * x)
{
    int cnt = 0;
    for(;*x;++x)
        if (isdigit(*x)) ++cnt;
    return cnt;
}

#define  check(x)  cout << left << setw(40) << #x \
           << " = " << ( x ) << "   // " << right \
           << setw(2) << digs(#x) << " digits\n";

int main()
{
    check( (1<<11)+~(11<<1)+~1                     );
    check( (1<<11)-((11+1)<<1)-1                   );
    check( (2<<(2<<2)<<2)+~22-2                    );
    check( (22^(((2<<((2<<2)+2+2))-2)>>2))-2       );
    check( ((33&~3)<<(3+3))+~(3<<3)                );
    check( ((33^((33+3)<<3))<<3)-33                );
    check( ((((4+4)<<4)-4)<<4)+~4+44               );
    check( (444>>4)^((((4+4)<<4)<<4)-4)            );
    check( -~5-~(((5-~5)|55)<<5)                   );
    check( ((55+5+5)<<5)-((55+5)^(5))              );
    check( (((66|6)+~6)<<(~6+6+6))-~6              );
    check( (((((6<<6)-6)|(6<<6))<<6)-6)>>(6&(6+6)) );
    check( ((77-7-7)<<(77&7))+7                    );
    check( ~8+~8-8-~(8<<8)                         );
    check( ((((8<<8)<<8)-8)>>8)-8-8-8              );
    check( (9<<9)^((9<<9)+999)                     );

    cout << endl;

    check( ~1-23+((4-~5+6)<<7)               );
    check( (123<<4)+(56+7)&~8                );
    check( (1-234)^((~5-((6|7)<<8))+~9)      );
    check( (~1-23)^(~4|5)^(((6+7+~8)<<9)+~0) );

    cout << endl;

    check( (9+~(8<<7))^(~(65<<4))            );
    check( 987+(65<<4)+~3                    );
    check( 987-~(65<<4)-3-2                  );
    check( ~(9<<8)+7+6+~5+4321               );
    check( ~9+~8+((765|432)<<1)              );
    check( ~9^(~876&(((54<<3<<2)^~1)+~0))    );

}
