#include <iostream>
#include <stdexcept>
int addition();
int main()
{
try //we can deal with exceptions that are thrown here
{
while(true)
{
std::cout << addition() << std::endl;
}
}
catch(std::exception &e)
{
std::cerr << "Exception caught in main: " << e.what() << std::endl;
}
}
int addition()
{
int x, y;
if(!(std::cin >> x >> y)) //check if the input operation succeeds
{
//throw an exception if it failed, since we can't do anything here
throw std::runtime_error{"unable to read two integers"};
}
//otherwise, return normally
return x + y;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkZXhjZXB0PgoKaW50IGFkZGl0aW9uKCk7CgppbnQgbWFpbigpCnsKCXRyeSAvL3dlIGNhbiBkZWFsIHdpdGggZXhjZXB0aW9ucyB0aGF0IGFyZSB0aHJvd24gaGVyZQoJewoJCXdoaWxlKHRydWUpCgkJewoJCQlzdGQ6OmNvdXQgPDwgYWRkaXRpb24oKSA8PCBzdGQ6OmVuZGw7CgkJfQoJfQoJY2F0Y2goc3RkOjpleGNlcHRpb24gJmUpIAoJewoJCXN0ZDo6Y2VyciA8PCAiRXhjZXB0aW9uIGNhdWdodCBpbiBtYWluOiAiIDw8IGUud2hhdCgpIDw8IHN0ZDo6ZW5kbDsKCX0KfQoKaW50IGFkZGl0aW9uKCkKewogICAgaW50IHgsIHk7CiAgICBpZighKHN0ZDo6Y2luID4+IHggPj4geSkpIC8vY2hlY2sgaWYgdGhlIGlucHV0IG9wZXJhdGlvbiBzdWNjZWVkcwogICAgewogICAgCS8vdGhyb3cgYW4gZXhjZXB0aW9uIGlmIGl0IGZhaWxlZCwgc2luY2Ugd2UgY2FuJ3QgZG8gYW55dGhpbmcgaGVyZQogICAgCXRocm93IHN0ZDo6cnVudGltZV9lcnJvcnsidW5hYmxlIHRvIHJlYWQgdHdvIGludGVnZXJzIn07CiAgICB9CiAgICAvL290aGVyd2lzZSwgcmV0dXJuIG5vcm1hbGx5CiAgICByZXR1cm4geCArIHk7Cn0=