#include <iostream>
using namespace std;
auto func(int angle){
angle %= 360;
if(angle > 180){
angle -=360;
}else if(angle < -180){
angle += 360;
}
return angle;
}
int main() {
// -45 45 45 -45
cout << func(315) << endl << func(-315) << endl << func(765) << endl << func(-765) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYXV0byBmdW5jKGludCBhbmdsZSl7CglhbmdsZSAlPSAzNjA7CgkKCWlmKGFuZ2xlID4gMTgwKXsKCQlhbmdsZSAtPTM2MDsKCX1lbHNlIGlmKGFuZ2xlIDwgLTE4MCl7CgkJYW5nbGUgKz0gMzYwOwoJfQoJCglyZXR1cm4gYW5nbGU7Cn0KCmludCBtYWluKCkgewoJLy8gLTQ1IDQ1IDQ1IC00NQoJY291dCA8PCBmdW5jKDMxNSkgPDwgZW5kbCA8PCBmdW5jKC0zMTUpIDw8IGVuZGwgPDwgZnVuYyg3NjUpIDw8IGVuZGwgPDwgZnVuYygtNzY1KSA8PCBlbmRsOwoJCglyZXR1cm4gMDsKfQ==