I would suppose you could do a longer stop in both cities within the rule, and since you have to clear immigration/customs and enter Canada officially in YVR anyways (unless you were on a sterile same-plane flight YVR-YYZ), then pre-clear U.S. immigration/customs again at YYZ to get into the U.S., you'd need a valid passport and entry visa for Canada as well as the U.S. to this trip this way.l