C++ 8ms 99% easy to follow O(1) space
\nclass RLEIterator {\n  int idx_ = 0; \n  int used_ = 0;\n  vector<int>& theA_;\npublic:\n  RLEIterator(vector<int>& A): theA_(A) { }\n\n  int next(int n) {\n 
```\nclass RLEIterator {\n  int idx_ = 0; \n  int used_ = 0;\n  vector<int>& theA_;\npublic:\n  RLEIterator(vector<int>& A): theA_(A) { }\n\n  int next(int n) {\n    for(; idx_<theA_.size(); idx_ += 2) {\n      if(theA_[idx_] - used_ > n) {\n        used_ += n;\n        return theA_[idx_+1];\n      }\n      else if (theA_[idx_] - used_ == n) {\n        used_ = 0;\n        idx_ += 2;\n        return theA_[idx_-1];\n      }\n      else {\n        n -= theA_[idx_] - used_;\n        used_ = 0;\n      }\n    }\n    \n    return -1;\n  }\n};\n```
[]