Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
char c[200][10]= {"2019",
                   "4038",
                   "6057",
                   "8076",
                   "10095",
                   "12114",
                   "14133",
                   "16152",
                   "18171",
                   "20190",
                   "22209",
                   "24228",
                   "26247",
                   "28266",
                   "30285",
                   "32304",
                   "34323",
                   "36342",
                   "38361",
                   "40380",
                   "42399",
                   "44418",
                   "46437",
                   "48456",
                   "50475",
                   "52494",
                   "54513",
                   "56532",
                   "58551",
                   "60570",
                   "62589",
                   "64608",
                   "66627",
                   "68646",
                   "70665",
                   "72684",
                   "74703",
                   "76722",
                   "78741",
                   "80760",
                   "82779",
                   "84798",
                   "86817",
                   "88836",
                   "90855",
                   "92874",
                   "94893",
                   "96912",
                   "98931",
                   "100950",
                   "102969",
                   "104988",
                   "109026",
                   "111045",
                   "113064",
                   "115083",
                   "117102",
                   "119121",
                   "121140",
                   "123159",
                   "125178",
                   "127197",
                   "129216",
                   "131235",
                   "133254",
                   "135273",
                   "137292",
                   "139311",
                   "141330",
                   "143349",
                   "145368",
                   "147387",
                   "149406",
                   "151425",
                   "153444",
                   "155463",
                   "157482",
                   "159501",
                   "161520",
                   "163539",
                   "165558",
                   "167577",
                   "169596",
                   "171615",
                   "173634",
                   "175653",
                   "177672",
                   "179691",
                   "181710",
                   "183729",
                   "185748",
                   "187767",
                   "189786",
                   "191805",
                   "193824",
                   "195843",
                   "197862",
                   "199881",
                  };
char s[200010];
int lenW,lenT;
int next[1010];
void getnext(int lenW,int k)
{
    int i=0,j=-1;
    next[i]=-1;
    while(i<lenW)
    {
        if(j==-1||c[k][i]==c[k][j])
        {
            next[++i]=++j;
        }
        else
            j=next[j];
    }
}

int kmp(int pos,int lenW,int lenT,int k)
{
    int i=pos,j=0,ans=0;
    while(i<lenT)
    {
        if(s[i]==c[k][j]||j==-1)
            ++i,++j;
        else
            j=next[j];
        if(j==lenW)
        {
            ans++;
            j=next[j-1];
            i--;
        }
    }
    return ans;
}

int main()
{
    int ans=0;
    scanf("%s",s);
    lenT=strlen(s);
    for(int i=0; i<98; i++)
    {
        int lenW=strlen(c[i]);
       // cout<<lenW;
        getnext(lenW,i);
        ans+=kmp(0,lenW,lenT,i);
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'void getnext(int, int)':
a.cc:118:5: error: reference to 'next' is ambiguous
  118 |     next[i]=-1;
      |     ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:114:5: note:                 'int next [1010]'
  114 | int next[1010];
      |     ^~~~
a.cc:123:13: error: reference to 'next' is ambiguous
  123 |             next[++i]=++j;
      |             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:114:5: note:                 'int next [1010]'
  114 | int next[1010];
      |     ^~~~
a.cc:126:15: error: reference to 'next' is ambiguous
  126 |             j=next[j];
      |               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:114:5: note:                 'int next [1010]'
  114 | int next[1010];
      |     ^~~~
a.cc: In function 'int kmp(int, int, int, int)':
a.cc:138:15: error: reference to 'next' is ambiguous
  138 |             j=next[j];
      |               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:114:5: note:                 'int next [1010]'
  114 | int next[1010];
      |     ^~~~
a.cc:142:15: error: reference to 'next' is ambiguous
  142 |             j=next[j-1];
      |               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:114:5: note:                 'int next [1010]'
  114 | int next[1010];
      |     ^~~~