alexjercan/bugnet huggingface dataset:
Problem p00500 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int N, i, k, cnt = 0, m, a, data[201][3] = {0}, point[201] = {0};
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    for (k = 1; k <= 3; k++) {
      scanf("%d", &data[i][k]);
    }
  }
  for (i = 1; i <= N; i++) {
    for (k = 1; k <= 3; k++) {
      a = data[i][k];
      for (m = 1; m <= N; m++) {
        if (i == m)
          continue;
        if (a == data[m][k])
          a = 0;
      }
      point[i] += a;
    }
  }

  for (i = 1; i <= N; i++) {
    printf("%d\\n", point[i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int N, i, k, j, l, a;
  scanf("%d", &N);
  int data[N][3];
  for (i = 1; i <= N; i++) {
    for (k = 1; k <= 3; k++) {
      scanf("%d", &data[i][k]);
    }
  }
  for (i = 1; i <= N; i++) {
    for (k = 1; k <= 3; k++) {
      a = data[i][k];
      for (j = 1; j <= N; j++) {
        for (l = 1; l <= 3; k++) {
          if (i == j && l == l)
            continue;
          if (a != data[j][l])
            data[j][0] += data[j][l];
        }
      }
    }
  }
  for (i = 1; i <= N; i++) {
    printf("%d\\n", data[i][0]);
  }
  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {

  int n;
  string mise, str;

  cin >> n;
  cin >> mise;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> str;

    // for(int i=0;i<str.size();i++)cout<< i<<str[i]<<"|";
    // cout << endl;

    int c = 0;
    int site[101] = {0};
    for (int j = 0; j < str.size(); j++) {
      if (mise[c] == str[j]) {
        // cout << mise[c] <<" = "<< str[j] << endl;
        site[c] = j;
        // cout << "site" << site[c] << endl;
        c++;
      }

      if (c >= 3 && site[c - 2] - site[c - 3] != site[c - 1] - site[c - 2]) {
        //	cout << site[c-2] - site[c-3] << " != "<<site[c-1] - site[c-2]<<
        //endl;
        c--;
        j = site[c];
        site[c] = 0;
      }
      if (c >= 2 && site[c - 1] - site[c - 2] < j - site[c - 1]) {
        // cout <<"koeta"<<endl;
        c--;
        j = site[c];
        site[c] = 0;
      }

      if (c == mise.size()) {
        ans++;
        break;
      }

      if (c != 0 && j == str.size() - 1) {
        // cout << "j= size" <<endl;
        c--;
        j = site[c];
        site[c] = 0;
        // cout << "j = " <<j<<endl;
        // cout << c<<endl;
        if (c != 0 && j == str.size() - 1) {
          c--;
          j = site[c];
          site[c] = 0;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {

  int n;
  string mise, str;

  cin >> n;
  cin >> mise;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> str;

    // for(int i=0;i<str.size();i++)cout<< i<<str[i]<<"|";
    // cout << endl;

    int c = 0;
    int site[101] = {0};
    for (int j = 0; j < str.size(); j++) {
      if (mise[c] == str[j]) {
        // cout << mise[c] <<" = "<< str[j] << endl;
        site[c] = j;
        // cout << "site" << site[c] << endl;
        c++;
      }

      if (c >= 3 && site[c - 2] - site[c - 3] != site[c - 1] - site[c - 2]) {
        //	cout << site[c-2] - site[c-3] << " != "<<site[c-1] - site[c-2]<<
        //endl;
        c--;
        j = site[c];
        site[c] = 0;
      }
      if (c >= 2 && site[c - 1] - site[c - 2] < j - site[c - 1]) {
        // cout <<"koeta"<<endl;
        c--;
        j = site[c];
        site[c] = 0;
      }

      if (c == mise.size()) {
        ans++;
        break;
      }

      if (j == str.size() - 1) {
        // cout << "j= size" <<endl;
        c--;
        j = site[c];
        site[c] = 0;
        //	cout << "j = " <<j<<endl;
        // cout << c<<endl;
      }
      if (j == str.size() - 1) {
        // cout << "j= size" <<endl;
        c--;
        j = site[c];
        site[c] = 0;
        // cout << "j = " <<j<<endl;
        // cout << c<<endl;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstring>
int main() {
  int N, SL, TL;
  char S[26], T[101];
  scanf("%d", &N);
  scanf("%s", S);
  SL = strlen(S);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    scanf("%s", T);
    TL = strlen(T);
    for (int j = 0; j < TL; j++) {
      if (S[0] != T[j])
        continue;
      bool _OK = false;
      for (int k = j + 1; k < TL; k++) {
        if (S[1] != T[k])
          continue;
        int span = k - j;
        bool OK = true;
        for (int l = 2; l < SL; l++) {
          if ((k + span * (l - 1)) >= TL) {
            OK = false;
            break;
          }
          if (S[l] != T[k + span * (l - 1)]) {
            OK = false;
            break;
          }
        }
        if (OK) {
          _OK = true;
          break;
        }
      }
      if (_OK) {
        ans++;
        break;
      }
    }
  }
  printf("%d\\n", ans);
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int N, L, ans = 0;
  string S, S1, S2;
  cin >> N >> S;
  for (int i = 0; i < N; i++) {
    cin >> S1;
    L = S1.size();
    for (int j = 0; j < (1 << L); j++) {
      int pos = -1, span = -1;
      S2 = "";
      bool OK = true;
      for (int k = 0; k < L; k++) {
        if (j & (1 << k)) {
          if (pos != -1) {
            if (span == -1) {
              span = (k - pos);
            } else {
              if (span != (k - pos)) {
                OK = false;
                break;
              }
            }
          }
          pos = k;
          S2 += S1[k];
        }
      }
      if (OK && S == S2) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, len, len2, sum = 0;
  char str[201], str2[201];
  // memset(str,NULL,sizeof(str));
  memset(str2, NULL, sizeof(str2));
  cin >> n;
  cin >> str;
  len = strlen(str);
  for (int i = 0; i < n; i++) { //??????????????\\???
    cin >> str2;
    len2 = strlen(str2);
    for (int j = 0; j < len2;
         j++) { //???????????????????????????????????????????´¢
      if (str2[j] == str[0]) {
        for (int y = 1; y < len2; y++) {
          for (int x = 1; x < len; x++) {
            if (str2[j + y * x] != str[x] || j + y * x > len2) {
              goto ruio;
            }
            if (x == len - 1) {
              // cout<<str2<<endl;
              sum++;
              goto sugii;
            }
          }
        ruio:;
        }
      }
    }
  sugii:;
  }
  cout << sum << endl;
}

Error: 0

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, sum = 0;
  char str[26], str2[26];
  cin >> n;
  cin >> str;
  int len = strlen(str);
  for (int i = 0; i < n; i++) { //??\\???
    cin >> str2;
    int len2 = strlen(str2);
    for (int j = 0; j < len2 - len; j++) { //??????????????????????´¢
      if (str[0] == str2[j]) {
        for (int z = 1;; z++) { //
          for (int x = 1; x < len - 1; x++) {
            // cout<<"sugii";
            if (j + (z * x) >= len2)
              goto sugii;
            if (str2[j + (z * x)] != str[x])
              break;
            if (x == len - 2) {
              sum++; /*cout<<str2<<endl*/
              ;
              goto ruio;
            }
          }
        }
      }
    sugii:;
    }
  ruio:;
  }
  cout << sum << endl;
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define str to_string
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_N 101
int N;
char name[30]; // .{3,25}
int len_name;

// buf??§`name`????????????????????????
bool solve(char *buf) {
  int len_buf = strlen(buf);
  if (len_buf < len_name)
    return false;

  int t = len_buf;
  for (int offset = 0; offset < len_buf; offset++) {
    if (buf[offset] != name[0])
      continue;

    for (int size = 1; size < t; size++) {

      rep(i, len_name) {
        // if ((offset + i*size) < len_buf) goto PASS;
        if (buf[offset + i * size] != name[i])
          goto PASS;
      }
      return true;
    PASS:;
    }
  }

  return false;
}

int main() {
  cin >> N;
  cin >> name;
  len_name = strlen(name);

  char buf[110];

  int answer = 0;
  rep(i, N) {
    memset(buf, 0, 110);
    cin >> buf;
    if (solve(buf))
      answer++;
  }

  cout << answer << '\\n';
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define str to_string
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_N 101
int N;
char name[30]; // .{3,25}
int len_name;

// buf??§`name`????????????????????????
bool solve(char *buf) {
  int len_buf = strlen(buf);
  if (len_buf < len_name)
    return false;

  int t = len_buf;
  for (int offset = 0; offset < len_buf; offset++) {
    if (buf[offset] != name[0])
      continue;

    for (int size = 1; size < t; size++) {

      rep(i, len_name) {
        // if ((offset + i*size) < len_buf) goto PASS;
        if (buf[offset + i * size] != name[i])
          goto PASS;
      }
      return true;
    PASS:;
    }
  }

  return false;
}

int main() {
  cin >> N;
  cin >> name;
  len_name = strlen(name);

  char buf[30];

  int answer = 0;
  rep(i, N) {
    memset(buf, 0, 30);
    cin >> buf;
    if (solve(buf))
      answer++;
  }

  cout << answer << '\\n';
  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, ans = 0;
  bool f;
  string s, gs;
  cin >> n >> s;
  int len = (signed)s.length(), glen;
  for (int i = 0; i < n; ++i) {
    cin >> gs;
    f = false;
    glen = (signed)gs.length();
    for (int j = 0; j <= glen - len && !f; ++j) {
      for (int k = 1; k <= (glen - j - 1) / (len - 1) && !f; ++k) {
        for (int l = 0; l < len; ++l) {
          if (s[l] != gs[j + l * k])
            break;
          if (l == len - 1) {
            ans++;
            f = true;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, ans = 0;
  bool f;
  string s, gs;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    unsigned int idx1, idx2;
    int len = (signed)s.length(), glen;
    cin >> gs;
    glen = (signed)gs.length();
    if (len == 1) {
      if (gs.find(s[0], 0) != string::npos)
        ans++;
    } else {
      idx1 = -1;
      f = false;
      while ((idx1 = gs.find(s[0], idx1 + 1)) != string::npos) {
        idx2 = idx1;
        while ((idx2 = gs.find(s[1], idx2 + 1)) != string::npos) {
          int l = (signed)(idx2 - idx1);
          if ((signed)idx1 + (len - 1) * l > glen - 1)
            break;
          if (len == 2) {
            ans++;
            f = true;
          } else
            for (int j = 2; j < len; ++j) {
              if (s[j] != gs[(signed)idx1 + l * j])
                break;
              if (j == len - 1) {
                ans++;
                f = true;
              }
            }
          if (f)
            break;
        }
        if (f)
          break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
#include <string>
using namespace std;

int main() {
  int n, ans = 0, len, glen;
  bool f;
  string s, gs;
  set<int> fidx, sidx;
  cin >> n >> s;
  len = (signed)s.length();
  for (int i = 0; i < n; ++i) {
    cin >> gs;
    glen = (signed)gs.length();
    if (glen == 1) {
      if (gs.find(s[0], 0) != string::npos)
        ans++;
    } else {
      f = false;
      fidx.clear();
      sidx.clear();

      // find first character or second character of s in gs
      for (int j = 0; j < glen; ++j) {
        if (gs[j] == s[0])
          fidx.insert(j);
        else if (gs[j] == s[1])
          sidx.insert(j);
      }

      for (set<int>::iterator f_it = fidx.begin(); f_it != fidx.end() && !f;
           ++f_it) {
        for (set<int>::iterator s_it = sidx.lower_bound(*f_it);
             s_it != sidx.end() && !f; ++s_it) {
          int k = (*s_it) - (*f_it);
          if ((*f_it) + k * (len - 1) + 1 > glen)
            break;
          for (int l = 2; l < len; ++l) {
            if (s[l] != gs[(*f_it) + k * l])
              break;
            if (l == len - 1) {
              ans++;
              f = true;
              break;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <string>
using namespace std;

int main() {
  int n, ans = 0, len, glen;
  bool f;
  string s, gs;
  set<int> fidx, sidx;
  unsigned int idx;
  cin >> n >> s;
  len = (signed)s.length();
  for (int i = 0; i < n; ++i) {
    cin >> gs;
    glen = (signed)gs.length();
    if (glen == 1) {
      if (gs.find(s[0], 0) != string::npos)
        ans++;
    } else {
      f = false;
      fidx.clear();
      sidx.clear();
      idx = -1;
      // find first character of s in gs
      while ((idx = gs.find(s[0], idx + 1)) != string::npos)
        fidx.insert((signed)idx);
      idx = -1;
      // find second character of s in gs
      while ((idx = gs.find(s[1], idx + 1)) != string::npos)
        sidx.insert((signed)idx);

      for (set<int>::iterator f_it = fidx.begin(); f_it != fidx.end() && !f;
           ++f_it) {
        for (set<int>::iterator s_it = sidx.lower_bound(*f_it);
             s_it != sidx.end() && !f; ++s_it) {
          int k = (*s_it) - (*f_it);
          if ((*f_it) + k * (len - 1) + 1 > glen)
            break;
          for (int l = 2; l < len; ++l) {
            if (s[l] != gs[(*f_it) + k * l])
              break;
            if (l == len - 1) {
              ans++;
              f = true;
              break;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  int counter = 0;
  for (int i = 0; i < n; i++) {
    string b;
    cin >> b;
    bool hantei = false;
    while (b.find(a[0]) != string::npos) {
      int p = b.find(a[0]);
      for (int j = 1;; j++) {
        if (p + (a.size() - 1) * j > b.size() - 1) {
          break;
        }
        string c = "";
        c += b[p];
        for (int k = 1; k < a.size(); k++) {
          c += b[p + j * k];
        }
        if (a == c) {
          hantei = true;
          counter++;
          break;
        }
      }
      if (hantei) {
        break;
      }
      b = b.substr(p + 1);
    }
  }
  cout << counter << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string b;
  cin >> b;
  int counter = 0;
  string a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    int counter2 = 0;
    while (counter2 < a.size()) {
      bool hantei = false;
      int counter3 = counter2;
      if ((a.substr(counter2)).find(b[0]) != string::npos) {
        counter2 += (a.substr(counter2)).find(b[0]) + 1;
        string c = a.substr(counter2);
        if (c.find(b[1]) != string::npos) {
          counter3 = c.find(b[1]);
          do {
            string d = c.substr(counter3 + 1);
            for (int j = 2; j < b.size(); j++) {
              if (d[counter3] == b[j]) {
                if (j == b.size() - 1) {
                  counter++;
                  hantei = true;
                  break;
                }
                c = c.substr(counter3 + 1);
              } else {
                break;
              }
            }
            if ((c.substr(counter3 + 1)).find(b[1]) != string::npos) {
              counter3 += ((c.substr(counter3 + 1)).find(b[1]) + 1);
            } else {
              break;
            }
          } while (counter3 <= c.size() || hantei);
        } else {
          break;
        }
      } else {
        break;
      }
      if (hantei) {
        break;
      }
    }
  }
  cout << counter << endl;
  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, len, len2, sum = 0;
  char str[201], str2[201];
  memset(str2, NULL, sizeof(str2));
  cin >> n;
  cin >> str;
  len = strlen(str);
  for (int i = 0; i < n; i++) { //??????????????\\???
    cin >> str2;
    len2 = strlen(str2);
    for (int j = 0; j < len2;
         j++) { //???????????????????????????????????????????´¢
      if (str2[j] == str[0]) {
        for (int y = 1; y < len2; y++) {
          for (int x = 1; x < len; x++) {
            if (str2[j + y * x] != str[x] || j + y * x > len2) {
              goto ruio;
            }
            if (x == len - 1) {
              sum++;
              goto sugii;
            }
          }
        ruio:;
        }
      }
    }
  sugii:;
  }
  cout << sum << endl;
}

Error: -11

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  int N, ans = 0, in, i, sp, kan, st, tf;
  char com[100], tem[100];
  cin >> N;
  cin >> tem;
  for (in = 0; in < N; in++) {
    cin >> com;
    for (kan = 0; kan < (strlen(com) / 2); kan++) {
      for (sp = 0; sp <= kan; sp++) {
        for (st = sp; st < N - ((kan + 1) * (strlen(tem) - 1)); st += kan + 1) {
          tf = 1;
          for (i = 0; i < strlen(tem); i++) {
            if (com[st] != tem[i]) {
              tf = 0;
              break;
            }
          }
          if (tf == 1) {
            ans++;
            break;
          }
        }
        if (tf == 1)
          break;
      }
      if (tf == 1)
        break;
    }
  }
  cout << ans << endl;
}
Problem p00501 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {

  int a, b = 0, c = 0, d = 0, e = 1, j;
  string mo;
  cin >> a >> mo;
  string ka[a];
  for (int k = 0; k < a; k++) {
    cin >> ka[k];
  }
  //
  for (int i = 0; i < a; i++) {
    for (int e = 1; e < ka[i].size() / mo.size() + 5 && c == 0; e++) {
      for (int j = 0; j < ka[i].size() - mo.size() + 2 && c == 0; j++) {
        for (int y = 0; y < mo.size() && c == 0; y++) {
          if (mo[y] == ka[i][j + y * e]) {
            b = b + 1;
            // cout << e;
          } else {
            b = 0;
            break;
          }
          if (b == mo.size()) {
            c = 1;
            break;
          }
        }
        b = 0;
      }
    }
    if (c == 1)
      d = d + 1;
    c = 0;
  }
  cout << d << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, ans = 0, coun, k = 0, r, anser = 0;
  string word;

  cin >> n >> word;

  string bard[100];
  for (int r = 0; r < n; r++) {
    cin >> bard[r];
  }
  for (int i = 0; i < n; i++) {
    coun = bard[i].size() - word.size();
    int u = bard[i].size() / word.size() + 1;
    for (int y = 0; y < u; y++) {
      for (int h = 0; h < coun; h++) {
        for (int f = 0; f < word.size(); f = f + y)
          if (word[k] == bard[i][f + h])
            ans = 1;
        k += 1;
      }
      k = 0;
    }
    if (ans == 1)
      anser += 1;
    ans = 0;
  }
  cout << anser << endl;

  return 0;
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {

  int n, len = 0, ans = 0;
  string c, str;
  queue<int> que;
  cin >> n >> c;

  for (int i = 0; i < n; i++) {
    cin >> str;

    for (int j = 0; j < str.size(); j++) {

      if (c[0] == str[j]) {
        for (int k = j + 1; k < str.size(); k++) {
          if (c[1] == str[k])
            que.push(k);
        }

        while (!que.empty()) {
          int sa = que.front() - j;
          for (int k = j; len < c.size() && k < str.size(); k += sa) {
            if (c[len] != str[k])
              break;
            len++;
          }
          if (len == c.size()) {
            ans++;
            break;
          }
          len = 0;
          que.pop();
        }
      }
      while (!que.empty())
        que.pop();
      if (len != 0) {
        len = 0;
        break;
      }
    }
  }

  cout << ans << endl;
  return (0);
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

  int n, len, ans = 0;
  string c, str;
  cin >> n >> c;

  for (int i = 0; i < n; i++) {
    cin >> str;

    for (int j = 0; j < str.size(); j++) {

      if (c[0] == str[j]) {
        for (int k = j + 1; k < str.size(); k++) {

          if (c[1] == str[k]) {
            len = 0;
            for (int l = j; len < c.size(); l += (k - j)) {
              if (c[len] == str[l])
                len++;
            }

            if (len == c.size()) {
              ans++;
              break;
            }
          }
        }
      }
    }
  }

  cout << ans << endl;
  return (0);
}
Problem p00501 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string.h>
using namespace std;
int main(void) {
  int n, tstr, bstr, ans = 0, cnt, tf;
  char t[100];
  char b[100];
  cin >> n;
  cin >> t;
  tstr = strlen(t);
  for (int I = 0; I < n; I++) {
    cin >> b;
    bstr = strlen(b);
    for (int kan = 1; kan <= (bstr - (tstr - 1)); kan++) {
      for (int start = 0; start < bstr - kan * (tstr - 1); start++) {
        tf = 1;
        cnt = 0;
        for (int i = start; i < bstr && cnt < tstr; i += kan) {
          // cout<<"??£???="<<I+1<<" start="<<start<<" kan="<<kan<<"
          // t["<<cnt<<"]="<<t[cnt]<<" b["<<i<<"]="<<b[i]<<endl;
          if (t[cnt] != b[i]) {
            tf = 0;
            // cout<<"----------"<<endl;
            break;
          }
          cnt++;
        }
        if (tf == 1) {
          // cout<<"----------"<<endl;
          ans++;
          break;
        }
      }
      if (tf == 1)
        break;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main(void) {
  int n, tstr, bstr, ans = 0, cnt, tf;
  char t[100], b[100];
  cin >> n;
  tstr = strlen(t);
  for (int I = 0; I < n; I++) {
    cin >> b;
    bstr = strlen(b);
    for (int kan = 0; kan < bstr / tstr; kan++) {
      for (int start = 0; start <= bstr - (kan * (tstr - 1) + tstr); start++) {
        tf = 1;
        cnt = 0;
        for (int i = start; i < bstr && cnt < tstr; i += kan) {
          // cout<<"cnt="<<cnt<<" i="<<i<<" "<<t[cnt]<<' '<<b[i]<<endl;
          if (t[cnt] != b[i]) {
            tf = 0;
            break;
          }
          cnt++;
        }
        if (tf == 1) {
          ans++;
          break;
        }
      }
      if (tf == 1)
        break;
    }
  }
  cout << ans << endl;
  return 0;
}