Problem:
B: 周期数列 - Periodic Sequence -
問題
H大学の教授を務めているPeriod博士は、万物に潜むとされる周期と呼ばれる性質を研究している。一般的に知られている基本的な周期としては、数列に潜む周期が考えられるだろう。すなわち、長さ
N
の数列
S = S_1, S_2,
...
, S_N
が以下の性質を満たすならば、周期
t
(
t \≤ N
) を持つという事実である。
1 \≤ i \≤ N − t
について、
S_i=S_{i+t}
である。
今、Period博士が着目しているのは、周期を用いてより簡易な記述ができる数列である。例えば、長さ
N
の数列が周期
t
(
\≤ N
) を持つとき、ある整数
k
を用いて
N=kt
と書けるならば、その数列は長さ
t
の数列
S_1,
...
, S_t
が
k
個連続したものである、と記述できる。Period博士は数列を例のように記述できたとき、その数列は
k
-partであると言うことにした。
Period博士は、
k
が最も大きい
k
-partに興味を示している。そこで助手であるあなたは、入力として数列を受け取り、それが
k
-partであるとき最も大きい
k
を出力するプログラムの作成を任されることとなった。Period博士の要求に正確に応えるプログラムを作成しよう。
入力形式
N
S_1
...
S_N
1行目には、数列の長さを表す整数
N
が与えられる。2行目には、長さ
N
の数列の各要素を表す整数
S_i
(
1 \≤ i \≤ N
) が空白区切りで与えられる。また、入力は
1 \≤ N \≤ 200,000
と
1 \≤ S_i \≤ 100,000
(
1 \≤ i \≤ N
) を満たす。
出力形式
与えられた数列に対して、
k
-partであるときの
k
の最大値を1行に出力せよ。
入力例1
6
1 2 3 1 2 3
出力例1
2
入力例2
12
1 2 1 2 1 2 1 2 1 2 1 2
出力例2
6
入力例3
6
1 2 3 4 5 6
出力例3
1

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;

using LL = long long; using ll = LL;
using PII = pair<int, int>; using pii = PII;
using PLL = pair<LL, LL>; using pll = PLL;
using VI = vector<int>; using VL = vector<LL>;
const ll LINF = 1e18;
const int INF = 1e9;
#define FOR(i,s,t) for(int i =s; i < t;i++)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()

void solve() {
	ll N; cin >> N;
	vector<ll> S(N);
	for (auto& in : S) cin >> in;

	ll res = 1;
	for (ll t = 1; t <= N; t++) {
		if (N%t != 0) continue;
		bool f = false;
		for (ll i = 0; i < N - t; i++) {
			if (S[i] == S[i + t]) continue;
			f = true;
			break;
		}
		if (f) continue;
		res = N / t;
		break;
	}
	cout << res << endl;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	solve();

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4648
final_rank: 7

code_snippet: #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define rep(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define drep(i, m, n) for (ll i = m - 1; i >= n; i--)
#define Endl endl
#define all(a) a.begin(), a.end()
#define pr(i, j) make_pair(i, j)
#define isin(x, l, r) (l <= x && x < r)
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define srt(ar) sort(ar.begin(), ar.end())
#define rev(ar) reverse(ar.begin(), ar.end())
#define jge(f, s, t) cout << (f ? s : t) << endl
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define printar(ar)             \
    do                          \
    {                           \
        for (auto dbg : ar)     \
        {                       \
            cout << dbg << " "; \
        }                       \
        cout << endl;           \
    } while (0)
const ll inf = 1e18;
const ld pi = 3.14159265358979;
const ld eps = 1e-9;
template <class T, ll n, ll idx = 0>
auto make_vec(const ll (&d)[n], const T &init) noexcept
{
    if constexpr (idx < n)
        return std::vector(d[idx], make_vec<T, n, idx + 1>(d, init));
    else
        return init;
}

template <class T, ll n>
auto make_vec(const ll (&d)[n]) noexcept
{
    return make_vec(d, T{});
}
//////////////// 以下を貼る ////////////////
template <class T>
size_t HashCombine(const size_t seed, const T &v)
{
    return seed ^ (std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
}
/* pair用 */
template <class T, class S>
struct std::hash<std::pair<T, S>>
{
    size_t operator()(const std::pair<T, S> &keyval) const noexcept
    {
        return HashCombine(std::hash<T>()(keyval.first), keyval.second);
    }
};
////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> s(n);
    rep(i, 0, n)
    {
        cin >> s[i];
    }
    vector<bool> f(n + 1, true);
    rep(i, 2, n + 1)
    {
        if (!f[i])
        {
            continue;
        }
        if (n % i != 0)
        {
            for (ll j = i; j <= n; j += i)
            {
                f[j] = false;
            }
        }
        else
        {
            ll t = n / i;
            bool g = true;
            rep(j, 0, n - t)
            {
                if (s[j] != s[j + t])
                {
                    g = false;
                }
            }
            if (!g)
            {
                for (ll j = i; j <= n; j += i)
                {
                    f[j] = false;
                }
            }
        }
    }
    ll ans = 1;
    rep(i, 1, n + 1)
    {
        if (f[i])
        {
            ans = i;
        }
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 4992
final_rank: 10

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=2167167167167167167;
const int INF=2100000000;
const ll mod=1e9+7;
#define rep(i,a) for (int i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}
template<class T> T min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}


namespace po167{
//LCP vec[0,n) and vec[i,n)
//for all i 
//O(vec.size())
template<class T>
std::vector<int> Z_algo(std::vector<T> &vec){
	int n=vec.size();
	int ind=1,j=0,k;
	std::vector<int> ans(n,0);
	ans[0]=n;
	while(ind<n){
		while(ind+j<n&&vec[j]==vec[ind+j]) j++;
		ans[ind]=j;
		if(j==0){
			ind++;
			continue;
		}
		k=1;
		while(k+ind<n&&ans[k]+k<j){
			ans[k+ind]=ans[k];
			k++;
		}
		j-=k;
		ind+=k;
	}
	return ans;
}
std::vector<int> Z_algo(std::string &vec){
	int n=vec.size();
	int ind=1,j=0,k;
	std::vector<int> ans(n,0);
	ans[0]=n;
	while(ind<n){
		while(ind+j<n&&vec[j]==vec[ind+j]) j++;
		ans[ind]=j;
		if(j==0){
			ind++;
			continue;
		}
		k=1;
		while(k+ind<n&&ans[k]+k<j){
			ans[k+ind]=ans[k];
			k++;
		}
		j-=k;
		ind+=k;
	}
	return ans;
}
}
using po167::Z_algo;

void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	int N;
	cin>>N;
	vector<int> S(N);
	rep(i,N) cin>>S[i];
	auto Z=Z_algo(S);
	rep(i,N){
		if(i==0) continue;
		if(__gcd(i,N)!=i) continue;
		if(Z[i]==N-i){
			cout<<N/i<<"\n";
			return;
		}
	}
	cout<<"1\n";
}
accuracy: 1
time_ms: 20
memory_kb: 4644
final_rank: 9

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
 
#define MOD 1000000007
 
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
const double EPS = 1e-8, PI = acos(-1);
const double pi = 3.141592653589793238462643383279;
//ここから編集    
typedef string::const_iterator State;
ll GCD(ll a, ll b){
  return (b==0)?a:GCD(b, a%b);
}
ll LCM(ll a, ll b){
  return a/GCD(a, b) * b;
}
template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< 998244353 >;
template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;
 
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
 
  inline T fact(int k) const { return _fact[k]; }
 
  inline T rfact(int k) const { return _rfact[k]; }
 
  inline T inv(int k) const { return _inv[k]; }
 
  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }
 
  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
 
  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};
 
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  while(n) {
    if(n&1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}
template<typename T> 
struct BIT{
  int N;
  std::vector<T> node;

  BIT(int n){
    N = n;
    node.resize(N+10);
  }

  /* a: 1-indexed */
  void add(int a, T x){
    for(int i=a; i<(int)node.size(); i += i & -i) node[i] += x;
  }

  /* [1, a] */
  T sum(int a){
    T res = 0;
    for(int x=a; x>0; x -= x & -x) res += node[x];
    return res;
  }

  /* [l, r] */
  T rangesum(int l, int r){
    return sum(r) - sum(l-1);
  }

  /* 
    a1+a2+...+aw >= valとなるような最小のwを返す
    @verify https://codeforces.com/contest/992/problem/E
  */
  int lower_bound(T val) {
    if(val < 0) return 0;

    int res = 0;
    int n = 1; 
    while (n < N) n *= 2;

    T tv=0;
    for (int k = n; k > 0; k /= 2) {
      if(res + k < N && node[res + k] < val){
        val -= node[res+k];
        res += k;
      }
    }
    return res+1; 
  }
};
struct UnionFind{
  std::vector<int> par;
  std::vector<int> siz;

  UnionFind(int sz_): par(sz_), siz(sz_) {
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  void init(int sz_){
    par.resize(sz_);
    siz.resize(sz_);
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  int root(int x){
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }

  bool merge(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) std::swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return siz[root(x)];
  }
};
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;
    int n;
    // construct
    RollingHash(const string &S) {
        n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
 
    inline pair<long long, long long> c_shift(int l) {
      auto h1 = get(0, l);
      auto h2 = get(l, n);
      return {(h1.first + h2.first * power1[l]) % mod1, (h1.second + h2.second * power2[l]) % mod2};
    }
 
    // get lcp of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

int main() {  
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int n; cin >> n;
  vector<int> s(n);
  REP(i,n) cin >> s[i];

  int ans = 1;
  for(int i=1; i*i<=n; i++) {
    if(n%i == 0) {
      int a = i, b = n/i;
      bool f = true;
      for(int j=a; j<n; j++) {
        if(s[j] != s[j-a]) f = false;
      }
      if(f) ans = max(ans, b);
      f = true;
      for(int j=b; j<n; j++) {
        if(s[j] != s[j-b]) f = false;
        
      }
      if(f) ans = max(ans, a);
    }
  }
  cout << ans << endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3876
final_rank: 4

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
 
#define MOD 1000000007
 
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
const double EPS = 1e-8, PI = acos(-1);
const double pi = 3.141592653589793238462643383279;
//ここから編集    
typedef string::const_iterator State;
ll GCD(ll a, ll b){
  return (b==0)?a:GCD(b, a%b);
}
ll LCM(ll a, ll b){
  return a/GCD(a, b) * b;
}
template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< 998244353 >;
template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;
 
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
 
  inline T fact(int k) const { return _fact[k]; }
 
  inline T rfact(int k) const { return _rfact[k]; }
 
  inline T inv(int k) const { return _inv[k]; }
 
  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }
 
  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
 
  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};
 
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  while(n) {
    if(n&1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}
template<typename T> 
struct BIT{
  int N;
  std::vector<T> node;

  BIT(int n){
    N = n;
    node.resize(N+10);
  }

  /* a: 1-indexed */
  void add(int a, T x){
    for(int i=a; i<(int)node.size(); i += i & -i) node[i] += x;
  }

  /* [1, a] */
  T sum(int a){
    T res = 0;
    for(int x=a; x>0; x -= x & -x) res += node[x];
    return res;
  }

  /* [l, r] */
  T rangesum(int l, int r){
    return sum(r) - sum(l-1);
  }

  /* 
    a1+a2+...+aw >= valとなるような最小のwを返す
    @verify https://codeforces.com/contest/992/problem/E
  */
  int lower_bound(T val) {
    if(val < 0) return 0;

    int res = 0;
    int n = 1; 
    while (n < N) n *= 2;

    T tv=0;
    for (int k = n; k > 0; k /= 2) {
      if(res + k < N && node[res + k] < val){
        val -= node[res+k];
        res += k;
      }
    }
    return res+1; 
  }
};
struct UnionFind{
  std::vector<int> par;
  std::vector<int> siz;

  UnionFind(int sz_): par(sz_), siz(sz_) {
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  void init(int sz_){
    par.resize(sz_);
    siz.resize(sz_);
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  int root(int x){
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }

  bool merge(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) std::swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return siz[root(x)];
  }
};
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;
    int n;
    // construct
    RollingHash(const string &S) {
        n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
 
    inline pair<long long, long long> c_shift(int l) {
      auto h1 = get(0, l);
      auto h2 = get(l, n);
      return {(h1.first + h2.first * power1[l]) % mod1, (h1.second + h2.second * power2[l]) % mod2};
    }
 
    // get lcp of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

int main() {  
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int n; cin >> n;
  vector<int> s(n);
  REP(i,n) cin >> s[i];

  int ans = 1;
  for(int i=2; i*i<=n; i++) {
    if(n%i == 0) {
      int a = i, b = n/i;
      bool f = true;
      for(int j=a; j<n; j++) {
        if(s[j] != s[j-a]) f = false;
      }
      if(f) ans = max(ans, b);
      f = true;
      for(int j=b; j<n; j++) {
        if(s[j] != s[j-b]) f = false;
        
      }
      if(f) ans = max(ans, a);
    }
  }
  cout << ans << endl;
  return 0;
}
accuracy: 0.5
time_ms: 10
memory_kb: 3880
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;

//イテレーション
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// x:コンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647           // 2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807  // 9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007             //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x)                                                   \
    for (auto i = x.begin(); i != --x.end(); i++) cout << *i << " "; \
    cout << *--x.end() << endl;

// aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a, ll b) { return (a + (b - 1)) / b; }
ll myfloor(ll a, ll b) { return a / b; }

int main() {
    //小数の桁数の出力指定
    // cout<<fixed<<setprecision(10);
    //入力の高速化用のコード
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    ll N;
    cin >> N;
    vector<ll> ss;
    REP(i, N) {
        ll t;
        cin >> t;
        ss.push_back(t);
    }

    ll bk = 1;
    FOR(i, 1, N-1) {
        if(N % i != 0) continue;
        ll k = N / i;

        bool f = true;
        FOR(j, 0, i - 1) {
            for(ll n = 1; n < k; n++) {
                //cout << k << " " << i << " " << j << " " << n << " " << ss[j] << " " << ss[n*i+j] << endl;
                if(ss[j] != ss[n*i+j]) {
                    f = false;
                    break;
                }
            }
            if(!f) break;
        }
        if(f) {
            bk = k;
            break;
        }
    }
    cout << bk << endl;
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 5180
final_rank: 13

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    int res=1;
    for(int i=1;i<=n;i++){
        if(n%i==0){
            bool ok=true;
            for(int j=i;j<n;j++){
                if(s[j]!=s[j%i]){
                    ok=false; break;
                }
            }
            if(ok){
                res=max(res,n/i);
            }
        }
    }
    cout << res << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3900
final_rank: 5

code_snippet: #line 2 "cpplib/util/template.hpp"
/**
 * These codes are licensed under CC0.
 * http://creativecommons.org/publicdomain/zero/1.0/deed.ja
 */
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
struct __INIT__{__INIT__(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}__INIT__;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>using V=vector<T>;
template<typename T>using VV=V<V<T>>;
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void debug(T t){bool f=0;for(auto i:t){cerr<<(f?" ":"")<<i;f=1;}cerr<<endl;}
template<typename T>inline void debug2(T t){for(auto i:t)debug(i);}
#define loop(n) for(long long _=0;_<(long long)(n);++_)
#define _overload4(_1,_2,_3,_4,name,...) name
#define __rep(i,a) repi(i,0,a,1)
#define _rep(i,a,b) repi(i,a,b,1)
#define repi(i,a,b,c) for(long long i=(long long)(a);i<(long long)(b);i+=c)
#define rep(...) _overload4(__VA_ARGS__,repi,_rep,__rep)(__VA_ARGS__)
#define _overload3_rev(_1,_2,_3,name,...) name
#define _rep_rev(i,a) repi_rev(i,0,a)
#define repi_rev(i,a,b) for(long long i=(long long)(b)-1;i>=(long long)(a);--i)
#define rrep(...) _overload3_rev(__VA_ARGS__,repi_rev,_rep_rev)(__VA_ARGS__)

// #define rep(i,...) for(auto i:range(__VA_ARGS__)) 
// #define rrep(i,...) for(auto i:reversed(range(__VA_ARGS__)))
// #define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
// #define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
// #define irep(i) for(lint i=0;;++i)
// inline vector<long long> range(long long n){if(n<=0)return vector<long long>();vector<long long>v(n);iota(v.begin(),v.end(),0LL);return v;}
// inline vector<long long> range(long long a,long long b){if(b<=a)return vector<long long>();vector<long long>v(b-a);iota(v.begin(),v.end(),a);return v;}
// inline vector<long long> range(long long a,long long b,long long c){if((b-a+c-1)/c<=0)return vector<long long>();vector<long long>v((b-a+c-1)/c);for(int i=0;i<(int)v.size();++i)v[i]=i?v[i-1]+c:a;return v;}
// template<typename T>inline T reversed(T v){reverse(v.begin(),v.end());return v;}
#define all(n) begin(n),end(n)
template<typename T,typename E>bool chmin(T& s,const E& t){bool res=s>t;s=min<T>(s,t);return res;}
template<typename T,typename E>bool chmax(T& s,const E& t){bool res=s<t;s=max<T>(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
#if __cplusplus>=201703L
    template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}
#endif
#define extrep(v,...) for(auto v:__MAKE_MAT__({__VA_ARGS__}))
#define bit(n,a) ((n>>a)&1)
vector<vector<long long>> __MAKE_MAT__(vector<long long> v){if(v.empty())return vector<vector<long long>>(1,vector<long long>());long long n=v.back();v.pop_back();vector<vector<long long>> ret;vector<vector<long long>> tmp=__MAKE_MAT__(v);for(auto e:tmp)for(long long i=0;i<n;++i){ret.push_back(e);ret.back().push_back(i);}return ret;}
using graph=vector<vector<int>>;
template<typename T>using graph_w=vector<vector<pair<int,T>>>;
template<typename T,typename E>ostream& operator<<(ostream& out,pair<T,E>v){out<<"("<<v.first<<","<<v.second<<")";return out;}
#if __cplusplus>=201703L
    constexpr inline long long powll(long long a,long long b){long long res=1;while(b--)res*=a;return res;}
#endif

template<typename T,typename E>pair<T,E>& operator+=(pair<T,E>&s,const pair<T,E>&t){s.first+=t.first;s.second+=t.second;return s;}
template<typename T,typename E>pair<T,E>& operator-=(pair<T,E>&s,const pair<T,E>&t){s.first-=t.first;s.second-=t.second;return s;}
template<typename T,typename E>pair<T,E> operator+(const pair<T,E>&s,const pair<T,E>&t){auto res=s;return res+=t;}
template<typename T,typename E>pair<T,E> operator-(const pair<T,E>&s,const pair<T,E>&t){auto res=s;return res-=t;}
#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);
#line 2 "code.cpp"

std::vector<int> z_algorithm(const vec& s){
    std::vector<int>res(s.size());
    res[0]=s.size();
    int i=1,j=0;
    while(i<(int)s.size()){
        while(i+j<(int)s.size()&&s[j]==s[i+j])++j;
        res[i]=j;
        if(j==0){++i;continue;}
        int k=1;
        while(i+k<(int)s.size()&&k+res[k]<j)res[i+k]=res[k],++k;
        i+=k;j-=k;
    }
    return res;
}

int main(){
    lint n;
    cin>>n;
    vec a(n);
    rep(i,n)cin>>a[i];
    auto d=z_algorithm(a);
    rep(i,1,n){
        if(n%i==0&&d[i]==n-i){
            cout<<n/i<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 5428
final_rank: 12

code_snippet: #line 1 "b.cpp"
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void Case(int i) { cout << "Case #" << i << ": "; }
#pragma endregion Macros

#line 1 "/home/siro53/kyo-pro/compro_library/math/divisor.hpp"
template<class T>
vector<T> divisor(T n) {
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}
#line 70 "b.cpp"

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    auto v = divisor(N);
    int ans = -INF;

    for(int len : v) {
        vector<vector<int>> v(N/len);
        for(int i = 0; i < N; i += len) {
            REP(j, len) v[i/len].push_back(a[i + j]);
        }
        debug(len, v);
        bool ok = true;
        FOR(i, 1, N/len) if(v[i-1] != v[i]) ok = false;
        if(ok) chmax(ans, N/len);
    }

    cout << ans << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 14888
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)

vector<long long> divisor(long long n){
    vector<long long> r;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            r.emplace_back(i);
            if(i*i!=n)r.emplace_back(n/i);
        }
    }
    sort(r.begin(),r.end());
    return r;
}

signed main(){
    ll n;
    cin>>n;
    vector<ll> S(n);
    rep(i,n)cin>>S[i];
    auto v=divisor(n);
    for(auto a:v){
        if(a>n-1)break;
        rep(i,n-a){
            if(S[i]!=S[i+a]){
                break;
            }
            if(i==n-a-1){
                cout<<n/a<<endl;
                return 0;
            }
        }
    }
    cout<<1<<endl;
}
accuracy: 1
time_ms: 30
memory_kb: 4692
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)

vector<long long> divisor(long long n){
    vector<long long> r;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            r.emplace_back(i);
            if(i*i!=n)r.emplace_back(n/i);
        }
    }
    sort(r.begin(),r.end());
    return r;
}

signed main(){
    ll n;
    cin>>n;
    vector<ll> S(n);
    rep(i,n)cin>>S[i];
    auto v=divisor(n);
    ll t=n;
    for(auto a:v){
        if(a>n-1)break;
        if(S[0]==S[a]){
            t=a;
            break;
        }
    }
    cout<<n/t<<endl;
}
accuracy: 0.72
time_ms: 30
memory_kb: 4700
final_rank: 17

code_snippet: #include <bits/stdc++.h>
typedef long long int lli;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define out(s) cout << s << endl;
using namespace std;
int main()
{
    string s = "";
    lli n;
    cin >> n;
    vector<lli> yaku;
    lli p = 2;
    while(p<=n/2){
        if(n%p==0){
            yaku.push_back(p);
        }
        p++;
    }
    rep(i, n)
    {
        string a;
        cin >> a;
        s = s + a;
    }
    lli k = 1;
    lli div = 0;
    while (true)
    {

        if (s.size() % yaku[div] == 0)
        {
            string sub = s.substr(0, s.size() / yaku[div]);
            bool check = true;
            rep(j, s.size() /sub.size() - 1)
            {
                if (sub != s.substr((sub.size()) * (j + 1), s.size()/yaku[div]))
                {
                    check = false;
                    break;
                }
            }

            if (check)
            {
                k = k * yaku[div];
                div = 0;
                s = sub;
                continue;
            }
        }
        div++;
        if (div >=yaku.size())
        {
            break;
        }
    }
    cout << k << endl;
}
accuracy: 0.04
time_ms: 670
memory_kb: 4020
final_rank: 19

code_snippet: #include <bits/stdc++.h>
typedef long long int lli;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define out(s) cout << s << endl;
using namespace std;
int main()
{
    string s = "";
    lli n;
    cin >> n;
    vector<lli> yaku;
    lli p = 2;
    while(p*p<=n){
        if(n%p==0){
            yaku.push_back(p);
        }
        p++;
    }
    rep(i, n)
    {
        string a;
        cin >> a;
        s = s + a;
    }
    lli k = 1;
    lli div = 0;
    while (true)
    {
        if (s.size() % yaku[div] == 0)
        {
            string sub = s.substr(0, s.size() / yaku[div]);
            bool check = true;
            rep(j, s.size() /sub.size() - 1)
            {
                if (sub != s.substr((sub.size()) * (j + 1), s.size()/yaku[div]))
                {
                    check = false;
                    break;
                }
            }

            if (check)
            {
                k = k * yaku[div];
                div = 0;
                s = sub;
                continue;
            }
        }
        div++;
        if (div >=yaku.size())
        {
            break;
        }
    }
    cout << k << endl;
}
accuracy: 0.04
time_ms: 700
memory_kb: 3984
final_rank: 20

code_snippet: #include <bits/stdc++.h>

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;

#define rep(i,a,b) for(i64 i=(a);(i) < (b);(i)++)
#define all(i) i.begin(),i.end()

int main(){
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  i64 n;
  std::cin>>n;

  std::vector<i64> s(n);
  for(auto&& e:s)std::cin>>e;

  std::vector<i64> yaku;

  for(i64 i=1;i*i<=n;i++){
    if(n%i==0){
      yaku.emplace_back(i);
      if(i*i!=n)yaku.emplace_back(n/i);
    }
  }

  std::sort(all(yaku),std::greater<i64>());

  for(const auto& e:yaku){
    i64 len = n/e;
    bool isok=true;
    rep(i,0,len){
      rep(j,0,e)isok&=(s[i] == s[i+len*j]);
    }
    if(isok){
      std::cout<<e<<"\n";
      return 0;
    }
  }

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4672
final_rank: 8

code_snippet: #include <algorithm>
#include <cstdio>

using namespace std;

#define SIZE 200000

int main() {
  int N, S[SIZE];

  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    scanf("%d", S + i);
  }

  int ans = 1;

  for (int i = 1; i <= N; i++) {
    if (N % i != 0) continue;

    bool ok = true;

    for (int j = 0; j + i < N; j++) {
      ok &= S[j] == S[i + j];
    }

    if (ok) {
      ans = max(ans, N / i);
    }
  }

  printf("%d\n", ans);

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3788
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=1; i<=N; i++){
        if(N%i == 0){
            bool can = true;
            for(int j=0; i+j<N; j++){
                if(A[j] != A[i+j]){
                    can = false;
                    break;
                }
            }
            if(can){
                cout << N/i << enld;
                return 0;
            }
        }
    }
    
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3632
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    int ans = inf;
    for(int i=1; i<=N; i++){
        if(N%i == 0){
            bool can = true;
            for(int j=1; j<=i; j++){
                int now = A[j];
                for(int k=j; k<=N; k+=i){
                    if(now != A[k]){
                        can = false;
                        break;
                    }
                }
                if(!can) break;
            }
            if(can){
                chmin(ans,i);
            }
        }
    }
    cout << N/ans << enld;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3636
final_rank: 3

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans;
    for(int k=n; k>=1; k--){
        if(n%k != 0) continue;
        int t = n/k;
        bool ok = true;
        for(int i=0; i<n; i++){
            if(a[i] != a[i%t]){
                ok = false;
                break;
            }
        }
        if(ok){
            ans = k;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3636
final_rank: 6

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

vector<int> KMP(vector<int> S){
    int l = S.size();
    vector<int> A(l+1);
    A[0] = -1;
    int j = -1;
    for(int i=0; i<l; i++){
        while(j >= 0 and S[i] != S[j]) j = A[j];
        j++;
        if(i<l and S[i+1] == S[j]) A[i+1] = A[j];
        else A[i+1] = j;
    }
    return A;
}

int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> S(N);
    for(int i=0; i<N; i++) cin >> S[i];
    vector<int> A = KMP(S);
    int temp = N/(N-A[N]);
    cout << gcd(N,temp) << enld;  
    return 0;
}
accuracy: 0.88
time_ms: 10
memory_kb: 5272
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

vector<int> KMP(vector<int> S){
    int l = S.size();
    vector<int> A(l+1);
    A[0] = -1;
    int j = -1;
    for(int i=0; i<l; i++){
        while(j >= 0 and S[i] != S[j]) j = A[j];
        j++;
        if(i<l and S[i+1] == S[j]) A[i+1] = A[j];
        else A[i+1] = j;
    }
    return A;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> S(N);
    for(int i=0; i<N; i++) cin >> S[i];
    vector<int> A = KMP(S);
    cout << N/(N-A[N]) << enld;  
    return 0;
}
accuracy: 0.8
time_ms: 10
memory_kb: 5252
final_rank: 16