-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Profitable_Interest_Rate.cpp
More file actions
144 lines (137 loc) · 3.84 KB
/
A_Profitable_Interest_Rate.cpp
File metadata and controls
144 lines (137 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// gl hf
// Arkantos_on_vacation
// Created on: 20-10-2024 Sunday 15:07:21 UTC:+06:00
// CODE ID 0d171a6b-f608-4742-8189-c08730d24106_40787d
// Problem - A Profitable Interest Rate
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define ld long double
#define bl bool
#define vct vector
#define ull unsigned long long
#define vi vector<ll>
#define vl vector<ll>
#define vb vector<bl>
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define vpvp vector<pair<ll, pair<ll, ll>>>
#define Map map<ll, ll>
#define Set set<ll>
#define PQ priority_queue<ll>
#define MinPQ priority_queue<ll, vector<ll>, greater<ll>>
#define UM unordered_map<ll, ll>
#define US unordered_set<ll>
#define Stk stack<ll>
#define Que queue<ll>
#define Deque deque<ll>
#define OS ordered_set<ll>
#define Rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define For(i, n) for (ll i = 0; i < (n); ++i)
#define Rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define ForV(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define trav(i, a) for (auto &i : a)
#define sumV(v, i, j) accumulate(v.begin() + i, v.begin() + j + 1)
#define cinAll(v) \
for (auto &x : v) \
cin >> x;
#define coutAll(v) \
for (const auto &x : v) \
cout << x << " ";
#define sumAll(v) accumulate(v.begin(), v.end(), 0LL)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define sortAll(v) sort(v.begin(), v.end())
#define sortMax64(v) sort(v.begin(), v.end(), std::greater<ll>())
#define sortMax32(v) sort(v.begin(), v.end(), std::greater<int>())
#define py cout << "YES" << endl;
#define pn cout << "NO" << endl;
#define ps cout << " " << endl;
#define nocap true
#define cap false
#define print(x) cout << x << endl;
#define ret return;
#define minAll(v) *min_element(v.begin(), v.end())
#define maxAll(v) *max_element(v.begin(), v.end())
#define minV *min_element
#define maxV *max_element
#define minVi *min_element(v.begin(), v.begin() + i)
#define maxVi *max_element(v.begin(), v.begin() + i)
#define firstSet(x) __builtin_ffs(x) - 1
#define countSet(x) __builtin_popcountll(x)
#define leadingZeros(x) __builtin_clz(x)
#define trailingZeros(x) __builtin_ctz(x)
#define parityBit(x) __builtin_parity(x)
#define leadingSignBits(x) __builtin_clrsb(x)
#define byteSwap32(x) __builtin_bswap32(x)
#define byteSwap64(x) __builtin_bswap64(x)
#define addOverflow(a, b, res) __builtin_add_overflow(a, b, res)
#define subOverflow(a, b, res) __builtin_sub_overflow(a, b, res)
#define mulOverflow(a, b, res) __builtin_mul_overflow(a, b, res)
#define inmap(um, x) um.find(x) == um.end()
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = LONG_LONG_MAX;
const ll NEG = -1e9;
ll myceil(ll a, ll b)
{
return (ll)ceil(1.0 * a / b);
}
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
os << "{ ";
for (const T &x : v)
os << x << " ";
os << "}";
return os;
}
void solve()
{
ll a, b;
cin >> a >> b;
if (a >= b)
{
print(a)
}
else
{
print(((2 * a - b) > 0 ? 2 * a - b : 0))
}
}
// gg wp
int main()
{
const static auto fast = []()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
ll t;
if (t != 1)
cin >> t;
while (t--)
{
solve();
}
return 0;
}