Codeforces #559 (Div. 1) A. The Party and Sweets

https://codeforces.com/contest/1158/problem/A

I didn't know the iterator has operator[] *1. I found this when I read his solution.

#include <vector>
#include <cassert>
using namespace std;
int main() {
  vector<int> a{1,2,3,4,5};
  assert(a.begin()[0] == 1);
  assert(a.begin()[1] == 2);
  assert(a.end()[-1] == 5);
  assert(a.end()[-2] == 4);
  assert(a.rbegin()[0] == 5);
  assert(a.rbegin()[1] == 4);
}

*1:According to http://www.cplusplus.com/reference/iterator/, only random access iterators have this operator. For example, if we need to find the second minimum of a set S, we cannot write S.begin()[1].