/*
Author: vpetrigo
Task:
    , 
        . 
        .

   ,   0. 
       .

  
   , 
  0 (  0    , 
     ).

  
   .
Sample Input:
1
2
1
2
1
0
Sample Output:
2

*/

#include <iostream>

using namespace std;

int main() {
    int prev = -1;
    int cur = -1;

    bool prev_gr = false;
    int cnt = 0;

    // Option 1
    while (cin >> cur && cur != 0) {
        if (prev != -1) {
            if (prev < cur && !prev_gr) {
                prev_gr = true;
            }
            else if (prev_gr) {
                if (cur < prev) {
                    ++cnt;
                    prev_gr = false;
                }
                else if (cur == prev) {
                    prev_gr = false;
                }
            }
            else {
                prev_gr = false;
            }
        }

        prev = cur;
    }

    // Option 2

    int next;

    if (cin >> prev && prev != 0) {
        if (cin >> cur && cur != 0) {
            if (cin >> next) {
                while (next != 0) {
                    if (prev < cur && cur > next) {
                        ++cnt;
                    }
                    prev = cur;
                    cur = next;
                    cin >> next;
                }
            }
        }
    }

    cout << cnt;

    return 0;
}
/*
Author: vpetrigo
Task:
    , 
        . 
        .

   ,   0. 
       .

  
   , 
  0 (  0    , 
     ).

  
   .
Sample Input:
1
2
1
2
1
0
Sample Output:
2

*/

#include <iostream>

using namespace std;

int main() {
    int prev = -1;
    int cur = -1;

    bool prev_gr = false;
    int cnt = 0;

    while (cin >> cur && cur != 0) {
        if (prev != -1) {
            if (prev < cur && !prev_gr) {
                prev_gr = true;
            }
            else if (prev_gr) {
                if (cur < prev) {
                    ++cnt;
                    prev_gr = false;
                }
                else if (cur == prev) {
                    prev_gr = false;
                }
            }
            else {
                prev_gr = false;
            }
        }

        prev = cur;
    }

    cout << cnt;

    return 0;
}
--- 
+++ 
@@ -38,6 +38,7 @@
     bool prev_gr = false;
     int cnt = 0;
 
+    // Option 1
     while (cin >> cur && cur != 0) {
         if (prev != -1) {
             if (prev < cur && !prev_gr) {
@@ -60,6 +61,25 @@
         prev = cur;
     }
 
+    // Option 2
+
+    int next;
+
+    if (cin >> prev && prev != 0) {
+        if (cin >> cur && cur != 0) {
+            if (cin >> next) {
+                while (next != 0) {
+                    if (prev < cur && cur > next) {
+                        ++cnt;
+                    }
+                    prev = cur;
+                    cur = next;
+                    cin >> next;
+                }
+            }
+        }
+    }
+
     cout << cnt;
 
     return 0;
Add another solution for week 3, task 13
