malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>       #define PI 3.141592653589793238462643383279   #define EXP 2.71828182846       #define ll long long      using namespace std;      double log2(double n)   {    return log(n)/log(2);   }      double ln(double n)   {    return log(n)/log(EXP);   }       void Heap(signed long long int A[],signed long long int n,signed long long int l,signed long long int r)   {    signed long long int x,i,j;    x=A[l];    i=l;    while(1)    {     j=2*i;     if(j>r)break;     if(j<r&&A[j+1]>=A[j])     j++;     if(x>=A[j]) break;     A[i]=A[j];     i=j;    }    A[i]=x;   }       void HeapSort(signed long long int A[],signed long long int n)   {    signed long long int l,r,temp;    l=n/2;    while(l>=0)    {     Heap(A,n,l,n-1);     l--;    }    r=n-1;    while(r>=1)    {     temp=A[0];     A[0]=A[r];     A[r]=temp;     r--;     Heap(A,n,0,r);    }   }        bool issimple(unsigned long long n){     for(unsigned long long i=2;i<=sqrt(n);i++)     if(n%i==0)      return false;    return true;   }       long long nod(long long a,long long b)   {       long long temp;       while(b)       {           a%=b;           temp=a;           a=b;           b=temp;       }       return a;   }       long long nok(long long a,long long b,long long nod)   {       return a/nod*b;   }       unsigned long long fac(unsigned long long n)   {    unsigned long long f=1;    if(n==0||n==1) return f;    for(int i=2;i<=n;i++)    {     f*=i;    }    return f;   }       int bSearch(int A[],int n,int x)   {    int l=0,r=n-1,m,found=0,c=0;    while(l<=r)     {     m=(l+r)/2;     c++;     if(A[m]==x)      {      found=1;      break;     }     //c++;     if(A[m]<x) l=m+1;     else r=m-1;    }    if(found)     return c;    return 0;   }      map<long long int,long long int> factorize(long long x) {       map<long long int,long long int> factors;           for (int i = 2; i <= sqrt(x); i++) {           while (x % i == 0) {            if(factors.find(i)==factors.end())                factors.insert({i,1});               else                factors[i]++;               x /= i;           }       }           if (x != 1) {           if(factors.find(x)==factors.end())                factors.insert({x,1});               else                factors[x]++;       }           return factors;   }      void answer(bool yes)   {    yes? cout<< YES n :cout<< NO n ;   }      long long ab(long long val)   {    if(val<0) return -val;    return val;   }      bool even(long long number)   {    if (number & 1)        return 0; //íå÷åòíîå    else         return 1; //÷åòíîå   }      int main()   {       long long n,k,i,count,j,t;       bool yes,flag;    cin>>t;    while(t--)    {     cin>>n;     count=0;          count=0;          for(i=1+n;!count;i++)     {      if(issimple(i))      {       for(j=i+n;;j++)       {        if(issimple(j))        {         count=(i)*(j);         break;        }       }             }     }          cout<<count<<endl;     //answer(yes);    }              return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long int ncr(unsigned long long int a, unsigned long long int b) {     unsigned long long int ans = 1;     for (unsigned long long int i = 1; i <= b; i++) {       ans *= (a - i + 1);     }     for (unsigned long long int i = 1; i <= b; i++) {       ans /= i;     }     return ans;   }   unsigned long long int power(unsigned long long int a,                                unsigned long long int b) {     unsigned long long int ans = 1;     for (int i = 1; i <= b; i++) {       ans *= a;     }     return ans;   }   unsigned long long int solvelessthansingle(int numofdigit) {     unsigned long long int ans = ncr(numofdigit - 1, 1);     ans *= 9;     return ans;   }   unsigned long long int solvelessthandouble(int numofdigit) {     unsigned long long int ans = ncr(numofdigit - 1, 2);     ans *= 81;     return ans;   }   unsigned long long int solvelessthantriple(unsigned long long int numofdigit) {     unsigned long long int ans = ncr(numofdigit - 1, 3);     ans *= 729;     return ans;   }   unsigned long long int solvelessthannone(unsigned long long int numofdigit) {     return 1;   }   unsigned long long int solve(unsigned long long int n,                                unsigned long long int rem) {     if (rem == 0) {       return 0;     }     if (n < 10) {       return n;     }     int numofdigit = 0;     unsigned long long int n2 = n;     while (n2) {       numofdigit++;       n2 /= 10;     }     unsigned long long int ans = 0;     if (rem >= 1) ans += solvelessthansingle(numofdigit);     if (rem >= 2) ans += solvelessthandouble(numofdigit);     if (rem >= 3) ans += solvelessthantriple(numofdigit);     int lastdigit;     unsigned long long int n1 = n;     while (n1) {       int temp = n1 % 10;       lastdigit = temp;       n1 /= 10;     }     if (rem >= 1) ans += (lastdigit)*solvelessthannone(numofdigit);     if (rem >= 2) ans += (lastdigit - 1) * solvelessthansingle(numofdigit);     if (rem >= 3) ans += (lastdigit - 1) * solvelessthandouble(numofdigit);     unsigned long long int mul =         power((unsigned long long int)10, (unsigned long long int)numofdigit - 1);     mul *= lastdigit;     n -= mul;     ans += solve(n, rem - 1);     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       unsigned long long int n, m;       cin >> n >> m;       unsigned long long int ans = solve(m, 3) - solve(n - 1, 3);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t = 1;     ios_base::sync_with_stdio(false);     cin.tie(NULL);     while (t--) {       long long int i, j, k, m, n, ans = 0;       cin >> n >> k;       if (n >= k) n = k - 1;       if (k - n >= n) {         cout << 0;         return 0;       }       long long int hi = n, lo = k - n;       cout << (hi - lo + 1) / 2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long sum(long long n) { return (n * (n - 1)) / 2; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     int arr[n + 1];     for (int i = 0; i < n; i++) cin >> arr[i];     pair<int, int> b[n + 1];     for (int i = 0; i < n; i++) {       cin >> b[i].first;       b[i].second = i;     }     sort(b, b + n);     sort(arr, arr + n, greater<int>());     long long a[n + 1];     for (int i = 0; i < n; i++) {       a[b[i].second] = arr[i];     }     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool uin(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   bool uax(T &a, T b) {     return a < b ? (a = b, true) : false;   }   struct TPoint {     long long x, y;     TPoint(long long x, long long y) : x(x), y(y) {}     TPoint operator+(const TPoint &p) const { return TPoint(x + p.x, y + p.y); }     TPoint operator-(const TPoint &p) const { return TPoint(x - p.x, y - p.y); }     long long operator%(const TPoint &p) const { return x * p.y - y * p.x; }     long long operator*(const TPoint &p) const { return x * p.x + y * p.y; }     long long operator~() const { return *this * *this; }     bool operator<(const TPoint &p) const {       return make_pair(x, y) < make_pair(p.x, p.y);     }   };   bool cmp(const TPoint &a, const TPoint &b) {     if (a % b) return a % b > 0;     return ~a < ~b;   }   const int maxn = 210000;   int miny[maxn], maxy[maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.precision(10);     cout << fixed;     int n, m;     while (1) {       cin >> n >> m;       if (!n) break;       for (int i = 0; i < (int)(n + 10); ++i) miny[i] = 1e9, maxy[i] = -1e9;       for (int i = 0; i < (int)(m); ++i) {         int x, y;         cin >> x >> y;         uin(miny[x], y);         uax(maxy[x], y);       }       vector<TPoint> p;       for (int i = 0; i < (int)(n + 2); ++i) {         if (i && miny[i] < miny[i - 1]) p.push_back(TPoint(i, miny[i]));         if (miny[i] < miny[i + 1]) p.push_back(TPoint(i - 1, miny[i]));         if (i && maxy[i] > maxy[i - 1]) p.push_back(TPoint(i, maxy[i] - 1));         if (maxy[i] > maxy[i + 1]) p.push_back(TPoint(i - 1, maxy[i] - 1));       }       TPoint O = *min_element((p).begin(), (p).end());       for (auto &w : p) w = w - O;       sort((p).begin(), (p).end(), cmp);       vector<TPoint> st;       for (auto w : p) {         while (st.size() > 1) {           TPoint prv = st.back(), pprv = st[st.size() - 2];           if ((w - pprv) % (prv - pprv) >= 0)             st.pop_back();           else             break;         }         st.push_back(w);       }       reverse((st).begin(), (st).end());       for (int i = 0; i < (int)(st.size()); ++i) {         st[i] = st[i] + O;       }       int j = min_element((st).begin(), (st).end()) - st.begin();       cout << st.size() <<   n ;       for (int i = 0; i < (int)(st.size()); ++i) {         TPoint w = st[(i + j) % st.size()];         cout << w.x <<     << w.y <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000, M = 2000;   int head[N + 10], ver[M + 10], nxt[M + 10], tot = 0;   void add(int x, int y) {     ver[++tot] = y;     nxt[tot] = head[x];     head[x] = tot;   }   int col[N + 10], cnt = 0;   void dfs(int x) {     col[x] = cnt;     for (int i = head[x]; i; i = nxt[i]) {       int y = ver[i];       if (col[y]) continue;       dfs(y);     }   }   vector<int> seq[N + 10];   pair<int, int> que[N + 10];   int h = 1, t = 0, fa[N + 10];   bool vis[N + 10];   pair<int, int> bfs(int x, bool f) {     memset(vis, 0, sizeof(vis));     if (f) memset(fa, -1, sizeof(fa));     h = 1;     t = 0;     pair<int, int> ans = make_pair(0, 0);     que[++t] = make_pair(0, x);     vis[x] = 1;     while (h <= t) {       pair<int, int> H = que[h++];       ans = max(ans, H);       for (int i = head[H.second]; i; i = nxt[i]) {         int y = ver[i];         if (vis[y]) continue;         vis[y] = 1;         if (f) fa[y] = H.second;         que[++t] = make_pair(H.first + 1, y);       }     }     return ans;   }   int dis[N + 10], v[N + 10];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d %d , &x, &y);       add(x, y);       add(y, x);     }     int maxx = 0, f = 0;     for (int i = 1; i <= n; i++) {       if (!col[i]) {         cnt++;         dfs(i);         pair<int, int> tmp = bfs(bfs(i, false).second, true);         int y = tmp.second;         if (tmp.first >= maxx) {           maxx = tmp.first;           f = cnt;         }         while (~y) {           seq[cnt].push_back(y);           y = fa[y];         }         v[cnt] = seq[cnt][seq[cnt].size() / 2];       }     }     for (int i = 1; i <= cnt; i++) {       if (i == f) continue;       add(v[i], v[f]);       add(v[f], v[i]);     }     printf( %d n , bfs(bfs(1, false).second, false).first);     for (int i = 1; i <= cnt; i++) {       if (i == f) continue;       printf( %d %d n , v[i], v[f]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int n, a, b, t;   pair<int, int> m[MAXN];   bool ans[MAXN];   int main() {     cin >> n >> a >> b;     for (int i = 0; i < n; i++) {       scanf( %d , &m[i].first);       m[i].second = i;       if (a < b) m[i].second *= -1;     }     if (a != b) sort(m, m + n);     for (int i = 0; i < (a < b ? b : a); i++)       if (a < b)         ans[a < b ? -m[i].second : m[i].second] = true;       else         ans[a < b ? -m[i].second : m[i].second] = true;     for (int i = 0; i < n; i++)       printf( %d  , ((a >= b) ? (ans[i] ? 1 : 2) : (ans[i] ? 2 : 1)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   struct matrix {     vector<vector<long long> > a;     int m, n;     matrix(int _m, int _n) {       m = _m;       n = _n;       a.resize(m + 1);       for (int i = (1); i <= (m); ++i) a[i].resize(n + 1);     }     void read() {       for (int i = (1); i <= (m); ++i) {         for (int j = (1); j <= (n); ++j) scanf( %lld , &a[i][j]);       }     }     bool inline operator==(const matrix &o) const {       if (m != o.m || n != o.n) return false;       for (int i = (1); i <= (m); ++i) {         for (int j = (1); j <= (n); ++j) {           if (a[i][j] != o.a[i][j]) return false;         }       }       return true;     }     void inline operator=(const matrix &o) {       m = o.m;       n = o.n;       for (int i = (1); i <= (m); ++i) {         for (int j = (1); j <= (n); ++j) a[i][j] = o.a[i][j];       }     }     matrix inline operator*(const matrix &o) const {       matrix c(m, o.n);       for (int i = (1); i <= (m); ++i) {         for (int j = (1); j <= (o.n); ++j) {           c.a[i][j] = 0;           for (int k = (1); k <= (n); ++k)             c.a[i][j] = (c.a[i][j] + a[i][k] * o.a[k][j]) % 1000003;         }       }       return c;     }     void print() {       for (int i = (1); i <= (m); ++i) {         for (int j = (1); j <= (n); ++j) printf( %lld  , a[i][j]);         puts(  );       }       puts(  );     }   };   matrix matPow(matrix A, int n) {     if (n == 1) return A;     if (n % 2 == 1) return A * matPow(A, n - 1);     matrix B = matPow(A, n / 2);     return B * B;   }   int n, H, W;   int main() {     scanf( %d%d%d , &n, &W, &H);     n += 1;     matrix A(W + 1, W + 1);     for (int i = (1); i <= (W); ++i) A.a[i][i + 1] = 1;     A.a[W + 1][W + 1] = 1;     for (int j = (W); j >= (1); --j)       A.a[W + 1][j] = (A.a[W + 1][j + 1] * H) % 1000003;     matrix F(W + 1, 1);     F.a[1][1] = 1;     for (int i = (2); i <= (W + 1); ++i) {       int p = 1;       for (int j = (i - 1); j >= (1); --j) {         F.a[i][1] = (F.a[i][1] + F.a[j][1] * p) % 1000003;         p = (p * H) % 1000003;       }     }     if (n <= W)       cout << F.a[n + 1][1];     else       cout << (matPow(A, n - W) * F).a[W + 1][1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int to, u, w;   } edge[200000];   struct data {     int x, y, w, d;   } v[200010];   int k = 1, f[200000], low[200010], dfu[200010], n, m, ans[200010], head[200010],       cnt, l;   bool vis[200010];   void add(int x, int y, int z) {     edge[k].u = y;     edge[k].to = head[x];     edge[k].w = z;     head[x] = k++;   }   int getfather(int x) {     if (f[x] == x) return x;     f[x] = getfather(f[x]);     return f[x];   }   void dfs(int now, int from) {     low[now] = dfu[now] = cnt++;     vis[now] = 1;     for (int i = head[now]; i != -1; i = edge[i].to) {       int u = edge[i].u;       if (vis[u] == 1 && edge[i].w != from)         low[now] = min(low[now], dfu[u]);       else if (vis[u] != 1) {         dfs(u, edge[i].w);         low[now] = min(low[now], low[u]);         if (dfu[now] < low[u]) ans[edge[i].w] = 2;       }     }   }   void add(int x, int y) {     int xx = getfather(x);     int yy = getfather(y);     if (xx != yy) {       dfu[x] = dfu[y] = dfu[xx] = dfu[yy] = 0;       low[x] = low[y] = low[xx] = low[yy] = 0;       vis[x] = vis[y] = vis[xx] = vis[yy] = 0;       head[x] = head[y] = head[xx] = head[yy] = -1;       f[xx] = yy;     }   }   bool comp(data x, data y) { return x.w < y.w; }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &v[i].x, &v[i].y, &v[i].w);       v[i].d = i;     }     sort(v + 1, v + m + 1, comp);     memset(head, -1, sizeof(head));     for (int i = 1; i <= n; i++) f[i] = i;     l = 1;     for (int i = 1; i <= m; i++)       if (v[i].w != v[i + 1].w) {         for (int j = l; j <= i; j++) {           int xx = getfather(v[j].x);           int yy = getfather(v[j].y);           if (xx == yy) {             ans[v[j].d] = 1;           } else {             add(xx, yy, v[j].d);             add(yy, xx, v[j].d);           }         }         for (int j = l; j <= i; j++) {           int xx = getfather(v[j].x);           int yy = getfather(v[j].y);           if (xx != yy && vis[xx] == 0) dfs(xx, -1);           if (xx != yy && vis[yy] == 0) dfs(yy, -1);         }         for (int j = l; j <= i; j++) {           add(v[j].x, v[j].y);         }         l = i + 1;       }     for (int i = 1; i <= m; i++)       if (ans[i] == 1)         printf( %s n ,  none );       else if (ans[i] == 0)         printf( %s n ,  at least one );       else         printf( %s n ,  any );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, t = 0, a[30005];     cin >> n >> k;     for (int i = 1; i < n; i++) cin >> a[i];     for (t = 1; t < k; t += a[t])       ;     cout << (t == k ?  YES  :  NO );   }
#include <bits/stdc++.h>   using namespace std;   void Speed() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   struct xi {     long long a, b;   };   const int XS = 1e3 + 12;   const int second = 1e4 + 12;   const int M = 1e5 + 12;   const int L = 1e6 + 12;   const int XL = 1e7 + 12;   const long long INF1 = 1e9 + 7;   const long long INF2 = 1e12 + 7;   long long T, n;   void Tramp() {     cin >> n;     long long a[n + 12], b[n + 12];     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= n; ++i) {       if (i & 1) {         b[i] = a[i + 1] * (-1);         b[i + 1] = a[i];       }     }     for (int i = 1; i <= n; ++i) cout << b[i] <<    ;     cout <<   n ;   }   int main() {     Speed();     cin >> T;     while (T--) Tramp();   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000003ll;   long long npow[64];   long long fast_pow(long long n, long long e) {     if (e == 0) return 1ll;     long long tmp = fast_pow(n, e / 2ll);     tmp = (tmp * tmp) % MOD;     if (e & 1ll) return (tmp * n) % MOD;     return tmp;   }   int main() {     ios::sync_with_stdio(0);     npow[0] = 1ll;     for (int i = 1; i < 63; i++) npow[i] = (npow[i - 1] * 2ll);     long long n, k;     cin >> n >> k;     if (n < 63 && k > npow[n]) {       cout <<  1 1 n ;       return 0;     }     long long tgt = k - 1ll;     long long pcount = 0;     long long val = 2ll;     while (true) {       long long adder = tgt / val;       if (!adder) break;       val *= 2ll;       pcount += adder;     }     long long kmult = n - (pcount / (k - 1));     long long den = fast_pow(2, k - 1ll);     den = fast_pow(den, kmult - 1ll);     den = den * fast_pow(2ll, k - 1 - (pcount % (k - 1)));     den %= MOD;     long long num = 0;     if (k - 1ll < MOD) {       long long prod = fast_pow(2ll, pcount);       long long rem = fast_pow(2ll, n);       num = fast_pow(prod, MOD - 2ll);       for (int i = 1; i <= k - 1ll; i++) {         long long mult = rem - i;         while (mult < 0) mult += MOD;         num = (num * mult) % MOD;       }     }     num = (den - num);     while (num < 0) num += MOD;     cout << num <<     << den <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long su = 0, f = 1;     char c = getchar();     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) su = su * 10 + c -  0 ;     return su * f;   }   inline void wr(long long x) {     if (x < 0)       putchar( - ), wr(-x);     else {       if (x >= 10) wr(x / 10);       putchar(x % 10 +  0 );     }   }   inline void wri(long long x) {     wr(x);     putchar(   );   }   inline void wrn(long long x) {     wr(x);     putchar(  n );   }   inline void wrn(long long x, long long y) {     wri(x);     wrn(y);   }   inline void wrn(long long x, long long y, long long z) {     wri(x);     wrn(y, z);   }   int n, m, ans[600055], k, a[600055], x, y, ss[600055];   vector<pair<long long, long long> > q[600055];   pair<long long, long long> z[600055];   char str[600055];   int Next[600055 * 2], head[600055], to[600055 * 2], nedge, g[600055][4];   void add(int a, int b) {     Next[++nedge] = head[a];     head[a] = nedge;     to[nedge] = b;   }   void add_ne(int a, int b) {     add(a, b);     add(b, a);   }   void ad(int x, int k) {     for (; x <= n; x += x & -x) ss[x] += k;   }   int que(int x) {     int su = 0;     for (; x; x -= x & -x) su += ss[x];     return su;   }   signed main() {     n = read();     for (int i = 1; i <= n; i++)       a[i] = read(), z[i].first = a[i], z[i].second = n - i + 1;     sort(z + 1, z + n + 1);     for (int i = 1; i <= n; i++) z[i].second = n - z[i].second + 1;     m = read();     for (int i = 1; i <= m; i++) {       x = read();       y = read();       q[x].push_back(make_pair(y, i));     }     for (int i = 1; i <= n; i++) {       ad(z[n - i + 1].second, 1);       for (int j = 0; j < int(q[i].size()); j++) {         int l = 1, r = n, t = q[i][j].first;         while (l < r) {           int mid = (l + r) >> 1;           if (que(mid) < t)             l = mid + 1;           else             r = mid;         }         ans[q[i][j].second] = l;       }     }     for (int i = 1; i <= m; i++) wrn(a[ans[i]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;      int main() {        int t , x , k;        cin >> t;        while(t--)    {        cin >> x;                k = (int)(sqrt(8 * x + 1)) / 2;                          if((k * (k + 1) - 2 * x)!=2 && (k * (k + 1) - 2 * x) >= 0)          cout << k <<   n ;                  else          cout << k + 1 <<   n ;                     }             return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[1007];   struct Node {     int pos;     int val;   };   Node res[1007];   int gcd(int a, int b) {     int m = std::max(a, b);     int n = std::min(a, b);     if (m % n == 0)       return n;     else       return gcd(n, m % n);   }   bool is_co_prim(int a, int b) { return gcd(a, b) == 1; }   int get(int a, int b) {     int m = std::min(a, b);     int n = std::max(a, b);     for (int i = m + 1;; i++) {       if (i != n && gcd(a, i) == 1 && gcd(b, i) == 1) {         return i;       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int cnt = 0;     for (int i = 0; i < n - 1; i++) {       if (is_co_prim(a[i], a[i + 1])) {         ;       } else {         res[cnt].pos = i + 1;         res[cnt].val = 1;         cnt++;       }     }     cout << cnt << endl;     int now = 0;     for (int i = 0; i < cnt; i++) {       while (now != res[i].pos) {         cout << a[now] <<    ;         now++;       }       cout << res[i].val <<    ;       now = res[i].pos;     }     while (now < n) {       cout << a[now] <<    ;       now++;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, t;   bool ans = 0;   vector<int> port;   vector<bool> f;   void dfs(int i) {     if (i == t - 1) {       ans = 1;       return;     }     f[i] = 1;     if (i != n - 1 && !f[i + port[i]]) dfs(i + port[i]);   }   int main() {     cin >> n >> t;     port.resize(n - 1);     f.resize(n);     for (int i = 0; i < n - 1; ++i) {       cin >> port[i];     }     dfs(0);     cout << (ans ?  YES  :  NO );     return 0;   }