#include <iostream>
#include <iterator>
template<class B,class E> struct range_iter{
B b; E e;
range_iter(B b_,E e_):b(b_),e(e_){}
B& begin(){return b;} E& end(){return e;}
range_iter<B,E>& operator++(){++b; return *this;}
typename std::iterator_traits<B>::reference operator*(){return *b;}
bool has_next(){return b!=e;}
};
template<class B,class E> range_iter<B,E> to_ri(B b, E e){return range_iter<B,E>(b,e);}
int main(){
int a[] = {0,10,20,30,40};
for(auto it=to_ri(a+1, a+3); it.has_next(); ++it){std::cout<<*it<<std::endl;}
//for(auto e : to_ri(a+1, a+3)){...}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+Cgp0ZW1wbGF0ZTxjbGFzcyBCLGNsYXNzIEU+IHN0cnVjdCByYW5nZV9pdGVyewogIEIgYjsgRSBlOwogIHJhbmdlX2l0ZXIoQiBiXyxFIGVfKTpiKGJfKSxlKGVfKXt9CiAgQiYgYmVnaW4oKXtyZXR1cm4gYjt9IEUmIGVuZCgpe3JldHVybiBlO30KICByYW5nZV9pdGVyPEIsRT4mIG9wZXJhdG9yKysoKXsrK2I7IHJldHVybiAqdGhpczt9CiAgdHlwZW5hbWUgc3RkOjppdGVyYXRvcl90cmFpdHM8Qj46OnJlZmVyZW5jZSBvcGVyYXRvciooKXtyZXR1cm4gKmI7fQogIGJvb2wgaGFzX25leHQoKXtyZXR1cm4gYiE9ZTt9Cn07CnRlbXBsYXRlPGNsYXNzIEIsY2xhc3MgRT4gcmFuZ2VfaXRlcjxCLEU+IHRvX3JpKEIgYiwgRSBlKXtyZXR1cm4gcmFuZ2VfaXRlcjxCLEU+KGIsZSk7fQoKaW50IG1haW4oKXsKICBpbnQgYVtdID0gezAsMTAsMjAsMzAsNDB9OwogIGZvcihhdXRvIGl0PXRvX3JpKGErMSwgYSszKTsgaXQuaGFzX25leHQoKTsgKytpdCl7c3RkOjpjb3V0PDwqaXQ8PHN0ZDo6ZW5kbDt9Ci8vZm9yKGF1dG8gZSA6IHRvX3JpKGErMSwgYSszKSl7Li4ufQogIHJldHVybiAwOwp9