>>777
const int allday = 24 * 60;

void spend(int &x, int &y, int dy){
  int m = (x * 60 + y + dy) % allday;
  x = m / 60;
  y = m % 60;
}