func_code_string: #include <bits/stdc++.h>   using namespace std;   long long sign(long long x) { return x < 0 ? -1 : 1; }   pair<long long, long long> part(long long from, long long to, long long s,                                   long long dir) {     pair<long long, long long> res{dir, abs(to - from)};     if (to != from && sign(to - from) != sign(dir)) {       res.first *= -1;       res.second += 2 * abs(from - (dir == -1 ? 0 : s));     }     return res;   }   long long solve(long long s, long long x1, long long x2, long long t1,                   long long t2, long long p, long long d) {     auto toTram = part(p, x1, s, d);     return min(part(x1, x2, s, sign(x2 - x1)).second * t2,                (toTram.second + part(x1, x2, s, toTram.first).second) * t1);   }   void tests() {     assert(7 == solve(10, 3, 8, 1, 2, 1, 1));     assert(9 == solve(10, 3, 8, 1, 2, 1, -1));     assert(10 == solve(10, 3, 8, 1, 2, 2, -1));     assert(12 == solve(10, 3, 8, 1, 5, 4, -1));     assert(24 == solve(10, 3, 8, 1, 5, 4, 1));     assert(20 == solve(10, 3, 8, 1, 4, 4, 1));     assert(15 == solve(10, 3, 8, 1, 3, 10, -1));     assert(18 == solve(10, 3, 8, 1, 4, 10, -1));     assert(19 == solve(10, 3, 8, 1, 4, 9, 1));     assert(20 == solve(10, 3, 8, 2, 4, 9, 1));     assert(5 == solve(10, 3, 8, 1, 4, 3, 1));     assert(11 == solve(10, 3, 8, 1, 4, 3, -1));     assert(20 == solve(10, 3, 8, 1, 5, 8, 1));     assert(16 == solve(10, 3, 8, 1, 4, 8, -1));     assert(5 + 4 + 5 == solve(10, 8, 3, 1, 4, 3, 1));     assert(6 + 5 + 4 + 5 == solve(10, 8, 3, 1, 5, 3, -1));     assert(4 + 5 == solve(10, 8, 3, 1, 4, 8, 1));     assert(5 == solve(10, 8, 3, 1, 4, 8, -1));     assert(8 == solve(4, 2, 4, 3, 4, 1, 1));     assert(7 == solve(5, 4, 0, 1, 2, 3, 1));   }   int main() {     tests();     long long s, x1, x2, t1, t2, p, d;     while (cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d) {       cout << solve(s, x1, x2, t1, t2, p, d) << endl;     }     return 0;   }   