using namespace std;

#define MNL 1000

class Rope {
public:
    Rope(string &str);
    void Insert(string, uint64_t);
    void Delete(uint64_t, uint64_t);
    string Split(uint64_t, uint64_t);
    void Concat(Rope);	
    string Stringify();
    char Index(uint64_t);
    void Adjust(string &str);
    void Rebuild();
    void Balance();
private:
    shared_ptr<Rope> Left;
    shared_ptr<Rope> Right;
    string Value;
    uint64_t Weight;
};
