-## Note:
+One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.
Let\'s think about a scene in real life: there are lots of people waiting in front of the elevator, each person wants to go to a certain floor. We can formalize it in the following way. We have
-th floor. Unfortunately, there is only one elevator and its capacity equal to
people can use it simultaneously). Initially the elevator is located on the first floor. The elevator needs $|a-b|$ seconds to move from the
-th floor (we don\'t count the time the people need to get on and off the elevator).
What is the minimal number of seconds that is needed to transport all the people to the corresponding floors and then return the elevator to the first floor?
$1 \\le n,k \\le 2000$ — the number of people and the maximal capacity of the elevator.
-th person.
+## Output:
+Output a single integer — the minimal time needed to achieve the goal.
Output
8
+## Note:
In first sample, an optimal solution is:
- The elevator takes up person #1 and person #2.
- It goes to the 2nd floor.
- Both people go out of the elevator.
- The elevator goes back to the 1st floor.
- Then the elevator takes up person #3.
- And it goes to the 2nd floor.
- It picks up person #2.
- Then it goes to the 3rd floor.
- Person #2 goes out.
- Then it goes to the 4th floor, where person #3 goes out.
- The elevator goes back to the 1st floor.
\ No newline at end of file
diff --git a/assets/ipl/solutions/18fa/contest11/C-cf746c.txt b/assets/ipl/solutions/18fa/contest11/C-cf746c.txt
index c30e48f..4e76513 100644
--- a/assets/ipl/solutions/18fa/contest11/C-cf746c.txt
+++ b/assets/ipl/solutions/18fa/contest11/C-cf746c.txt
@@ -1,9 +1,9 @@
-The tram in Berland goes along a straight line from the point
0 to the point
s and back, passing
1 meter per
t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points $x = 0$ and $x = s$.
Igor is at the point
x1. He should reach the point
x2. Igor passes
1 meter per
t2 seconds.
Your task is to determine the minimum time Igor needs to get from the point
x1 to the point
x2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point
x1.
Igor can enter the tram unlimited number of times at any moment when his and the tram\'s positions coincide. It is
not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than
1 meter per
t2 seconds). He can also stand at some point for some time.
-## Input:
-The first line contains three integers
s,
x1 and
x2 ($2 \\le s \\le 1000$, $0 \\le x_1, x_2 \\le s$, $x_1 \\ne x_2$) — the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to.
The second line contains two integers
t1 and
t2 ($1 \\le t_1, t_2 \\le 1000$) — the time in seconds in which the tram passes
1 meter and the time in seconds in which Igor passes
1 meter.
The third line contains two integers
p and
d ($1 \\le p \\le s-1$,
d is either $1$ or $-1$) — the position of the tram in the moment Igor came to the point
x1 and the direction of the tram at this moment. If $d = -1$, the tram goes in the direction from the point
s to the point
0. If $d = 1$, the tram goes in the direction from the point
0 to the point
s.
-## Output:
-Print the minimum time in seconds which Igor needs to get from the point
x1 to the point
x2.
-## Sample:
-
Output
7
-## Note:
+The tram in Berland goes along a straight line from the point
0 to the point
s and back, passing
1 meter per
t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points $x = 0$ and $x = s$.
Igor is at the point
x1. He should reach the point
x2. Igor passes
1 meter per
t2 seconds.
Your task is to determine the minimum time Igor needs to get from the point
x1 to the point
x2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point
x1.
Igor can enter the tram unlimited number of times at any moment when his and the tram\'s positions coincide. It is
not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than
1 meter per
t2 seconds). He can also stand at some point for some time.
+## Input:
+The first line contains three integers
s,
x1 and
x2 ($2 \\le s \\le 1000$, $0 \\le x_1, x_2 \\le s$, $x_1 \\ne x_2$) — the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to.
The second line contains two integers
t1 and
t2 ($1 \\le t_1, t_2 \\le 1000$) — the time in seconds in which the tram passes
1 meter and the time in seconds in which Igor passes
1 meter.
The third line contains two integers
p and
d ($1 \\le p \\le s-1$,
d is either $1$ or $-1$) — the position of the tram in the moment Igor came to the point
x1 and the direction of the tram at this moment. If $d = -1$, the tram goes in the direction from the point
s to the point
0. If $d = 1$, the tram goes in the direction from the point
0 to the point
s.
+## Output:
+Print the minimum time in seconds which Igor needs to get from the point
x1 to the point
x2.
+## Sample:
+
Output
7
+## Note:
In the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass
2 meters and it takes
8 seconds in total, because he passes
1 meter per
4 seconds.
In the second example Igor can, for example, go towards the point
x2 and get to the point
1 in
6 seconds (because he has to pass
3 meters, but he passes
1 meters per
2 seconds). At that moment the tram will be at the point
1, so Igor can enter the tram and pass
1 meter in
1 second. Thus, Igor will reach the point
x2 in
7 seconds in total.
\ No newline at end of file
diff --git a/assets/ipl/solutions/18fa/contest11/E-cf627a.cpp b/assets/ipl/solutions/18fa/contest11/E-cf627a.cpp
index 8bfd7a0..a93573d 100644
--- a/assets/ipl/solutions/18fa/contest11/E-cf627a.cpp
+++ b/assets/ipl/solutions/18fa/contest11/E-cf627a.cpp
@@ -1,42 +1,42 @@
-#include
-
-using namespace std;
-
-int ss[50], xx[50];
-
-int main () {
- long long s, x;
- cin >> s >> x;
- long long _s = s, _x = x;
- for (int i = 0; i < 50; i++) {
- ss[i] = s & 1;
- s >>= 1;
- xx[i] = x & 1;
- x >>= 1;
- }
- long long ans = 1;
- int jin = 0;
- for (int i = 0; i < 49; i++) {
- if (ss[i] == 0 && xx[i] == 0) {
- if (jin == 0) { jin = ss[i+1] ^ xx[i+1]; }
- else { cout << 0 << endl; return 0; }
- }
- if (ss[i] == 0 && xx[i] == 1) {
- if (jin == 0) { cout << 0 << endl; return 0; }
- else { ans <<= 1; }
- }
- if (ss[i] == 1 && xx[i] == 0) {
- if (jin == 0) { cout << 0 << endl; return 0; }
- else { jin = ss[i+1] ^ xx[i+1]; }
- }
- if (ss[i] == 1 && xx[i] == 1) {
- if (jin == 0) { ans <<= 1; }
- else { cout << 0 << endl; return 0; }
- }
- }
- if (_s == _x) ans -= 2;
- cout << ans << endl;
-
- return 0;
-}
-
+#include
+
+using namespace std;
+
+int ss[50], xx[50];
+
+int main () {
+ long long s, x;
+ cin >> s >> x;
+ long long _s = s, _x = x;
+ for (int i = 0; i < 50; i++) {
+ ss[i] = s & 1;
+ s >>= 1;
+ xx[i] = x & 1;
+ x >>= 1;
+ }
+ long long ans = 1;
+ int jin = 0;
+ for (int i = 0; i < 49; i++) {
+ if (ss[i] == 0 && xx[i] == 0) {
+ if (jin == 0) { jin = ss[i+1] ^ xx[i+1]; }
+ else { cout << 0 << endl; return 0; }
+ }
+ if (ss[i] == 0 && xx[i] == 1) {
+ if (jin == 0) { cout << 0 << endl; return 0; }
+ else { ans <<= 1; }
+ }
+ if (ss[i] == 1 && xx[i] == 0) {
+ if (jin == 0) { cout << 0 << endl; return 0; }
+ else { jin = ss[i+1] ^ xx[i+1]; }
+ }
+ if (ss[i] == 1 && xx[i] == 1) {
+ if (jin == 0) { ans <<= 1; }
+ else { cout << 0 << endl; return 0; }
+ }
+ }
+ if (_s == _x) ans -= 2;
+ cout << ans << endl;
+
+ return 0;
+}
+
diff --git a/assets/ipl/solutions/18fa/contest11/E-cf627a.txt b/assets/ipl/solutions/18fa/contest11/E-cf627a.txt
index 33cc63b..727b173 100644
--- a/assets/ipl/solutions/18fa/contest11/E-cf627a.txt
+++ b/assets/ipl/solutions/18fa/contest11/E-cf627a.txt
@@ -1,9 +1,9 @@
-Two positive integers $a$ and $b$ have a sum of $s$ and a bitwise XOR of $x$. How many possible values are there for the ordered pair $(a,b)$?
-## Input:
-The first line of the input contains two integers $s$ and $x$ ($2 \\le s \\le 10^{12}$, $0 \\le x \\le 10^{12}$), the sum and bitwise xor of the pair of positive integers, respectively.
-## Output:
-Print a single integer, the number of solutions to the given conditions. If no solutions exist, print 0.
-## Sample:
-Output
0
-## Note:
+Two
positive integers $a$ and $b$ have a sum of $s$ and a bitwise XOR of $x$. How many possible values are there for the ordered pair $(a,b)$?
+## Input:
+The first line of the input contains two integers $s$ and $x$ ($2 \\le s \\le 10^{12}$, $0 \\le x \\le 10^{12}$), the sum and bitwise xor of the pair of positive integers, respectively.
+## Output:
+Print a single integer, the number of solutions to the given conditions. If no solutions exist, print
0.
+## Sample:
+
Output
0
+## Note:
In the first sample, we have the following solutions: $(2,7)$, $(3,6)$, $(6,3)$, $(7,2)$.
In the second sample, the only solutions are $(1,2)$ and $(2,1)$.
\ No newline at end of file
diff --git a/assets/ipl/solutions/18sp/cf/cf116c.cpp b/assets/ipl/solutions/18sp/cf/cf116c.cpp
index f86abf8..f84aaec 100644
--- a/assets/ipl/solutions/18sp/cf/cf116c.cpp
+++ b/assets/ipl/solutions/18sp/cf/cf116c.cpp
@@ -1,26 +1,26 @@
-#include
-
-using namespace std;
-
-int p[2001];
-int dep[2001];
-
-int calc_dep(int i) {
- if (i == -1) return 0;
- if (dep[i]) return dep[i];
- return dep[i] = calc_dep(p[i]) + 1;
-}
-
-int main () {
- int n;
- cin >> n;
- for (int i = 1; i <= n; i ++) cin >> p[i];
- for (int i = 1; i <= n; i ++) {
- calc_dep(i);
- }
- int ans = 0;
- for (int i = 1; i <= n; i ++) ans = max(ans, dep[i]);
- cout << ans << endl;
- return 0;
-}
-
+#include
+
+using namespace std;
+
+int p[2001];
+int dep[2001];
+
+int calc_dep(int i) {
+ if (i == -1) return 0;
+ if (dep[i]) return dep[i];
+ return dep[i] = calc_dep(p[i]) + 1;
+}
+
+int main () {
+ int n;
+ cin >> n;
+ for (int i = 1; i <= n; i ++) cin >> p[i];
+ for (int i = 1; i <= n; i ++) {
+ calc_dep(i);
+ }
+ int ans = 0;
+ for (int i = 1; i <= n; i ++) ans = max(ans, dep[i]);
+ cout << ans << endl;
+ return 0;
+}
+
diff --git a/assets/ipl/solutions/18sp/cf/cf384a.cpp b/assets/ipl/solutions/18sp/cf/cf384a.cpp
index 424435e..9d46114 100644
--- a/assets/ipl/solutions/18sp/cf/cf384a.cpp
+++ b/assets/ipl/solutions/18sp/cf/cf384a.cpp
@@ -1,18 +1,18 @@
-#include
-
-using namespace std;
-
-int main () {
- int n;
- cin >> n;
- cout << (n * n + 1) / 2 << endl;
- for (int i = 0; i < n; i ++) {
- for (int j = 0; j < n; j ++) {
- if ((i & 1) == (j & 1)) cout << 'C';
- else cout << '.';
- }
- cout << endl;
- }
- return 0;
-}
-
+#include
+
+using namespace std;
+
+int main () {
+ int n;
+ cin >> n;
+ cout << (n * n + 1) / 2 << endl;
+ for (int i = 0; i < n; i ++) {
+ for (int j = 0; j < n; j ++) {
+ if ((i & 1) == (j & 1)) cout << 'C';
+ else cout << '.';
+ }
+ cout << endl;
+ }
+ return 0;
+}
+
diff --git a/assets/ipl/solutions/18sp/cf/cf459c.cpp b/assets/ipl/solutions/18sp/cf/cf459c.cpp
index ad30952..71ca1d8 100644
--- a/assets/ipl/solutions/18sp/cf/cf459c.cpp
+++ b/assets/ipl/solutions/18sp/cf/cf459c.cpp
@@ -1,26 +1,26 @@
-#include
-#include