#include <iostream>
class Robot {
private:
    int sc;
    int save;
public:
    Robot() { sc = 0;save = 0;}
    void P() {sc++;}
    void D() {sc--;}
    
    void M() {sc = std::max(sc, save);}
    void S() {save = std::max(sc, save);}
    int G() { return sc; }
    
};

int main() {
    Robot h;
    h.P();
    h.P();
    h.S();
    h.D();
    h.M();
    h.P();
    h.P();
    std::cout << h.G() << std::endl;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: