#include <iostream>
#include <vector>
using namespace std;
int main (void)
{
vector <int> a = {1, 2, 3, 4, 5, 6};
vector <int> b = {1, 2, 3, 5, 5, 6};
int X = 6;
int i = 0;
int j = b.size () - 1;
while (i < (int) a.size())
{
while (a[i] + b[j] > X && j > 0)
j--;
if (a[i] + b[j] == X)
cout << i << " " << j << endl;
i++;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluICh2b2lkKQp7Cgl2ZWN0b3IgPGludD4gYSA9IHsxLCAyLCAzLCA0LCA1LCA2fTsKCXZlY3RvciA8aW50PiBiID0gezEsIDIsIDMsIDUsIDUsIDZ9OwoJaW50IFggPSA2OwoKCWludCBpID0gMDsKCWludCBqID0gYi5zaXplICgpIC0gMTsKCgl3aGlsZSAoaSA8IChpbnQpIGEuc2l6ZSgpKQoJewoJCXdoaWxlIChhW2ldICsgYltqXSA+IFggJiYgaiA+IDApCgkJCWotLTsKCQlpZiAoYVtpXSArIGJbal0gPT0gWCkKCQkJY291dCA8PCBpIDw8ICIgIiA8PCBqIDw8IGVuZGw7CgkJaSsrOwoJfQoKCXJldHVybiAwOwp9Cg==