func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   vector<string> vec;   long long int sd(long long int n) {     long long int sum = 0;     while (n != 0) {       sum += n % 10;       n = n / 10;     }     return sum;   }   long long int nd(long long int n) {     long long int ans = 0;     while (n > 0) {       n = n / 10;       ans++;     }     return ans;   }   long long int power(long long int a, long long int b) {     long long int ans = 1ll;     while (b) {       if (b & 1) ans = (ans * a) % 1000000007;       a = (a * a) % 1000000007;       b = b / 2;     }     return ans;   }   int main() {     long long int n, a, b, r, c, d, i, k, j, temp, sum, ct = 0, flag = -1e13,                                                         start = 0, next = 1;     string st, ans;     long long int ar[1005] = {0};     vector<long long int> v;     vector<pair<long long int, long long int> > v2;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> temp;       v.push_back(temp);     }     if (k > n) {       sort(v.begin(), v.end(), greater<long long int>());       cout << v[0];       return 0;     }     for (i = 0; i < n; i++) {       start = (i + 1) % n;       ct = 0;       if (i != 0)         if (v[start] > v[i - 1]) {           ct += 1;         }       while (ct < k) {         if (v[start] > v[i]) break;         ct++;         start++;         if (start == n) start = 0;       }       if (ct == k) {         cout << v[i];         return 0;       }     }     return 0;   }   