#include using namespace std; using ll = long long; #define TYPE_OF( VAR ) remove_const::type >::type #define CIN( LL , A ) LL A; cin >> A #define ASSERT( A , MIN , MAX ) assert( MIN <= A && A <= MAX ) #define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) #define QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; cin >> VARIABLE_FOR_CHECK_REDUNDANT_INPUT; assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin ); int main() { constexpr const ll bound = 1000000000; CIN_ASSERT( A , 1 , bound ); CHECK_REDUNDANT_INPUT; // B - A < x < A + B // <=> B - A + 1 <= x <= A + B - 1; // ( A + B - 1 ) - ( B - A + 1 ) + 1 = 2A - 1; RETURN( A + A - 1 ); }