Language: C++

#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;

long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
long long int dp[10005]={};


string S;
vector<long long int>output;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 1; i <= N; i++){
        cin>>A[i];
    }
    long long int res2=0;
    long long int type=0;
    for(long long int i = 2; i <= N; i++){
        if(A[i]==A[i-1]){
            
        }else if(A[i]<A[i-1]){
            if(type==1){
                res++;
                type=0;
            }else{
                type=2;
            }
        }else{
            if(type==2){
                res++;
                type=0;
            }else{
                type=1;
            }
        }
        
    }
    cout<<res+1<<endl;
}
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;

long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
long long int dp[10005]={};


string S;
vector<long long int>output;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 1; i <= N; i++){
        cin>>A[i];
    }
    long long int res2=0;
    long long int type=0;
    for(long long int i = 2; i <= N; i++){
        if(A[i]==A[i-1]){
            
        }else if(A[i]<A[i-1]){
            if(type==1){
                res++;
                type=0;
            }else{
                type=2;
            }
        }else{
            if(type==2){
                res++;
                type=0;
            }else{
                type=1;
            }
        }
        
    }
    cout<<res+1<<endl;
}


Compiler output:
a.cc:201:21: error: redefinition of 'const long long int mod'
  201 | const long long int mod = 1000000007;
      |                     ^~~
a.cc:81:21: note: 'const long long int mod' previously defined here
   81 | const long long int mod = 1000000007;
      |                     ^~~
a.cc:202:21: error: redefinition of 'const long long int INF'
  202 | const long long int INF = 1e18;
      |                     ^~~
a.cc:82:21: note: 'const long long int INF' previously defined here
   82 | const long long int INF = 1e18;
      |                     ^~~
a.cc:204:15: error: redefinition of 'long long int N'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |               ^
a.cc:84:15: note: 'long long int N' previously declared here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |               ^
a.cc:204:17: error: redefinition of 'long long int M'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                 ^
a.cc:84:17: note: 'long long int M' previously declared here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                 ^
a.cc:204:19: error: redefinition of 'long long int A [300200]'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                   ^
a.cc:84:19: note: 'long long int A [300200]' previously declared here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                   ^
a.cc:204:29: error: redefinition of 'long long int B [201002]'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                             ^
a.cc:84:29: note: 'long long int B [201002]' previously declared here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                             ^
a.cc:204:39: error: redefinition of 'long long int L [200200]'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                       ^
a.cc:84:39: note: 'long long int L [200200]' previously declared here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                       ^
a.cc:204:49: error: redefinition of 'long long int R [202000]'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                                 ^
a.cc:84:49: note: 'long long int R [202000]' previously declared here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                                 ^
a.cc:204:59: error: redefinition of 'long long int sum [200200]'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                                           ^~~
a.cc:84:59: note: 'long long int sum [200200]' previously defined here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                                           ^~~
a.cc:204:74: error: redefinition of 'long long int res'
  204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                                                          ^~~
a.cc:84:74: note: 'long long int res' previously defined here
   84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0;
      |                                                                          ^~~
a.cc:205:15: error: redefinition of 'long long int dp [10005]'
  205 | long long int dp[10005]={};
      |               ^~
a.cc:85:15: note: 'long long int dp [10005]' previously defined here
   85 | long long int dp[10005]={};
      |               ^~
a.cc:208:8: error: redefinition of 'std::string S'
  208 | string S;
      |        ^
a.cc:88:8: note: 'std::string S' previously declared here
   88 | string S;
      |        ^
a.cc:209:22: error: redefinition of 'std::vector<long long int> output'
  209 | vector<long long int>output;
      |                      ^~~~~~
a.cc:89:22: note: 'std::vector<long long int> output' previously declared here
   89 | vector<long long int>output;
      |                      ^~~~~~
a.cc:210:5: error: redefinition of 'int main()'
  210 | int main()
      |     ^~~~
a.cc:90:5: note: 'int main()' previously defined here
   90 | int main()
      |     ^~~~