#include #include #include #include #include using namespace std; using ll = long long; bool check(ll a1, ll b1, ll a2, ll b2, ll a3, ll b3) { ll c = 1e9; ll a21 = a2 - a1; ll a32 = a3 - a2; ll b21 = b2 - b1; ll b32 = b3 - b2; ll le9 = b32 / c * a21 + b32 % c * a21 / c; ll re9 = b21 / c * a32 + b21 % c * a32 / c; if (le9 < re9) return true; if (le9 > re9) return false; return b32 % c * a21 % c < b21% c* a32% c; return (a2 - a1) * (b3 - b2) < (b2 - b1) * (a3 - a2); } int main() { ll a, q; cin >> a >> q; set> ch; for (ll qs = 0; qs < q; qs++) { ll qq; cin >> qq; if (qq == 1) { ll s, t; cin >> s >> t; pair add = make_pair(s + t, - s * t); //pair add = make_pair(s, t); auto it = ch.lower_bound(add); if (it != ch.begin() && it != ch.end()) { auto ita = it; ita--; if (!check(ita->first, ita->second, add.first, add.second, it->first, it->second)) { continue; } } it = ch.insert(add).first; while (1) { auto it2 = it; auto it3 = it; it2++; it3++; if (it2 == ch.end()) break; it3++; if (it3 == ch.end()) break; if (check(it->first, it->second, it2->first, it2->second, it3->first, it3->second)) break; ch.erase(it2); } while (1) { auto it2 = it; auto it3 = it; if (it == ch.begin()) break; it2--; it3--; if (it2 == ch.begin()) break; it3--; if (check(it3->first, it3->second, it2->first, it2->second, it->first, it->second)) break; ch.erase(it2); } } else { ll t; cin >> t; while (!ch.empty()) { auto it = ch.begin(); auto it2 = it; it2++; if (it2 == ch.end()) break; if (t * it->first + it->second <= t * it2->first + it2->second) ch.erase(it); else break; } if (ch.empty()) { cout << "0\n"; } else { auto it = ch.begin(); ll ans = a * (-t * t + it->first * t + it->second); cout << max(ans, 0LL) << "\n"; } } } return 0; }