fork download
  1. /*
  2. ==> Don't stop when you're tired, stop when you're done.
  3. ==> Don't forget from the river to the sea palestine will be free
  4. --> @author: MIDORIYA_
  5. */
  6. //*==============================================================
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. typedef long long ll;
  10. typedef double db;
  11. typedef long double ld;
  12. typedef pair<int, int> pii;
  13. typedef pair<ll, ll> pll;
  14. typedef vector<int> vi;
  15. typedef vector<ll> vll;
  16. typedef vector<db> vd;
  17. typedef vector<ld> vld;
  18. typedef vector<bool> vb;
  19. typedef vector<vector<ll>> vvl;
  20. typedef vector<vector<int>> vvi;
  21. typedef vector<pii> vii;
  22. typedef set<int> si;
  23. typedef set<ll> sl;
  24. #define pb push_back
  25. #define all(x) x.begin(), x.end()
  26. #define rall(x) x.rbegin(), x.rend()
  27. #define endl "\n"
  28. const ll MOD = 998244353, mod = 1e9 + 7, maxA = 1e5 + 5;
  29. #define time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << endl;
  30. //*===================>>>Fast-IO-Functions<<<=================
  31. void fastIO()
  32. {
  33. ios_base::sync_with_stdio(false);
  34. cin.tie(nullptr);
  35. cout.tie(nullptr);
  36. }
  37. //*===================>>>File-IO-Functions<<<=================
  38. void fileIO()
  39. {
  40. #ifndef ONLINE_JUDGE
  41. freopen("in.txt", "r", stdin);
  42. freopen("out.txt", "w", stdout);
  43. #endif
  44. }
  45. //*===================>>>ONE-FOR-ALL-Function<<<==============
  46. void OneForAll()
  47. {
  48. ll M, N, P, Q;
  49. cin >> M >> N >> P >> Q;
  50.  
  51. bool flag = false;
  52. ll given = 2LL * M * N, target = 1LL * P * Q;
  53. if (given < target)
  54. {
  55. flag = false;
  56. }
  57.  
  58. if ((P <= 2 * M and Q <= N) || (P <= M and Q <= 2 * N))
  59. {
  60. flag = true;
  61. }
  62.  
  63. if ((Q <= 2 * M and P <= N) || (Q <= M and P <= 2 * N))
  64. {
  65. flag = true;
  66. }
  67.  
  68. cout << (flag ? to_string(given - target) : "IMPOSSIBLE") << endl;
  69. }
  70.  
  71. int main()
  72. {
  73. fastIO();
  74. fileIO();
  75.  
  76. ll tc = 1;
  77. // cin >> tc;
  78. // factorial(mod);
  79. while(tc--)
  80. {
  81. // cout << "Case " << i << ": ";
  82. OneForAll();
  83. }
  84. time;
  85. return 0;
  86. }
Success #stdin #stdout #stderr 0s 5320KB
stdin
Standard input is empty
stdout
2238367670759587840
stderr
Time Taken: 0.004358 Secs