akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
mod=10**9+7
n=int(input())
A=[tuple(map(int,input().split())) for _ in range(n)]
DP=[-1]*(1<<n)
DP[(1<<n)-1]=1

def dfs(s,m):
    if DP[s]!=-1:
        return DP[s]
    tmp=0
    for i in range(n):
        if (s>>i)&1==0 and A[m][i]==1:
            tmp+=dfs(s+(1<<i),m+1)
    DP[s]=tmp%mod
    return DP[s]

print(dfs(0,0))

Measured memory_bytes: 63836
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,vector<int>> u;
int vis[200005];
int dp[200005];
int dfs(int src){
    
    vis[src]=1;
    
    for(auto node:u[src]){
        if(vis[node]!=1){
            dp[src]=max(dp[src],1+dfs(node));
        }
        else{
            dp[src]=max(dp[src],1+dp[node]);
        }
    }
  //  cout<<src<<" "<<dp[src]<<endl;
 // if(dp[src]==0)
   //dp[src]=1;
    return dp[src];
}

int main(){
    int n,m;cin>>n>>m;
    
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        u[x].push_back(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(vis[i]!=1)
        ans=max(ans,dfs(i));
      //  cout<<ans<<endl;
    }
    int a=0;
    for(int i=1;i<=n;i++){
        a=max(a,dp[i]);
    }

  //  cout<<dp[4];
    cout<<ans;
    
}

Measured memory_bytes: 11940
#include<stdio.h>

int main(){
    long int N,i,odd=0,even=0,four=0;
    long long int a;

    scanf("%ld",&N);

    for(i=0;i<N;i++){
        scanf("%lld",&a);
        if(a%4==0){
            four++;
        }else if(a%2==0){
            even++;
        }else{
            odd++;
        }
    }
    if(even!=0){
        if(odd>four){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }else{
        if(odd>four+1){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;

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

	int N;
	cin >> N;

	long long int whole = 0; //バームクーヘンの大きさ
	int* A = new int[N];
	for (int i = 0; i < N; i++){
		cin >> A[i];
		whole += (long long int)A[i];
	}

	long long int one_third = whole / 3;

	int i = 0;
	long long int piece1 = 0;
	while (piece1 + (long long int)A[i] <= one_third){
		piece1 += (long long int)A[i];
		i++;
		if (i == N) i -= N; //周期的境界条件
	}
	
	int piece2_i = i;
	long long int piece2 = 0;
	while (1){
		piece2 += (long long int)A[i];
		i++;
		if (i == N) i -= N; //周期的境界条件
		if (piece2 >= piece1) break;
	}
	
	int piece3_i = i;
	long long int piece3 = whole - piece1 - piece2;
	long long int ans = min(piece1, piece3);

	for (int i = 1; i < N; i++){
		if (piece1 == 0){
			piece2 -= (long long int)A[piece2_i];
			piece2_i++;
		}
		else piece1 -= (long long int)A[i-1];

		while (piece1 + (long long int)A[piece2_i] <= one_third){
			piece1 += (long long int)A[piece2_i];
			piece2 -= (long long int)A[piece2_i];
			piece2_i++;
			if (piece2_i == N) piece2_i -= N; //周期的境界条件
		}

		while (piece2 < piece1){
			piece2 += (long long int)A[piece3_i];
			piece3_i++;
			if (piece3_i == N) piece3_i -= N; //周期的境界条件
		}

		piece3 = whole - piece1 - piece2;
		ans = max(ans, min(piece1, piece3));
	}

	cout << ans << endl;

	delete[] A;
	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll dp[200010][3][2];

ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=a*a%mod;
    return k%2 ? a*n%mod : a;
}
int main(){
    ll N,K; cin>>N>>K;
    vec d(K+1,0);
    ll ans=0;
    for(ll i=K; i>0; i--){
        ll a=K/i;
        d[i]=ruijou(a,N);
        if(a>1) REP(j,2,a+1) ADD(d[i],mod-d[i*j]);
        ADD(ans,d[i]*i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
struct Node{
	int x,id;
}node[maxn];
bool cmp(Node i,Node j)
{
	return i.x<j.x;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		node[i].x=x;node[i].id=i;
	}
	sort(node+1,node+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		cout<<node[i].id<<" ";
	}
 } 

Measured memory_bytes: 1536
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] == S[2]:
    print("No")
elif S[0] == S[1] and S[2] == S[3]:
    print("Yes")
elif S[0] == S[2] and S[1] == S[3]:
    print("Yes")
elif S[0] == S[3] and S[2] == S[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <double, double> P;

const ll MOD=1000000007;
const int MAX_N=4e4; //変える
int N;
struct BIT{
    //1-indexed
    int bit[MAX_N+1];
    
    void init(){
        memset(bit, 0, sizeof(bit));
    }
    
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    
    void add(int i, int x){
        while(i<=N){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};
ll calc(vector<double> x){
    vector<P> y;
    rep(i,0,sz(x)){
        y.pb(P(x[i],i));
    }
    sor(y);
    rep(i,0,sz(x)){
        x[y[i].sc]=i+1;
    }
    BIT b;
    b.init();
    ll ans=0;
    rep(i,0,N){
        ans+=i-b.sum(x[i]);
        b.add(x[i],1);
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    double A[N], B[N], C[N];
    rep(i,0,N){
        cin>>A[i]>>B[i]>>C[i];
    }
    vector<P> v;
    rep(i,0,N){
        v.pb(P((C[i]+B[i]*(3e8))/A[i],i));
    }
    sor(v);
    double ylb=-2e8-1, yub=2e8+1;
    rep(Z,0,60){
        double mid=(ylb+yub)/2;
        vector<double> q;
        rep(i,0,N){
            ll j=v[i].sc;
            q.pb((C[j]-B[j]*mid)/A[j]);
        }
        if(calc(q)>=(N*(N-1)/2+1)/2) yub=mid;
        else ylb=mid;
    }
    v.clear();
    rep(i,0,N){
        v.pb(P((C[i]+A[i]*(3e8))/B[i],i));
    }
    sor(v);
    double xlb=-2e8-1, xub=2e8+1;
    rep(Z,0,60){
        double mid=(xlb+xub)/2;
        vector<double> q;
        rep(i,0,N){
            ll j=v[i].sc;
            q.pb((C[j]-A[j]*mid)/B[j]);
        }
        if(calc(q)>=(N*(N-1)/2+1)/2) xub=mid;
        else xlb=mid;
    }
    cout << setprecision(15)<<xlb<<" "<<yub<<"\n";
}

Measured memory_bytes: 4448
#define _CRT_SECURE_NO_WARNINGS
#define NOMINMAX
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INF = (int) 1e9;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.00001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(full(a));
	int lst = INT_INF;
	for (int i = 0; i + k - 1 < n; i++) {
		lst = min(lst, a[i + k - 1] - a[i]);
	}
	cout << lst << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
long long n, s;
long long p[156] = { 1,2,4,6,12,24,36,48,60,120,180,240,360,720,840,1260,1680,2520,5040,10080,15120,25200,27720,55440,110880,166320,277200,332640,554400,665280,720720,1441440,2162160,3603600,4324320,7207200,8648640,10810800,21621600,36756720,61261200,73513440,122522400,147026880,183783600,367567200,698377680,735134400,1102701600,1163962800,1396755360,2327925600,2793510720,3491888400,6983776800,13967553600,20951330400,27935107200,41902660800,48886437600,80313433200,160626866400,321253732800,481880599200,642507465600,963761198400,1124388064800,1927522396800,2248776129600,3373164194400,4497552259200,4658179125600,6746328388800,9316358251200,13974537376800,18632716502400,27949074753600,32607253879200,55898149507200,65214507758400,97821761637600,130429015516800,144403552893600,195643523275200,288807105787200,433210658680800,577614211574400,866421317361600,1010824870255200,1732842634723200,2021649740510400,3032474610765600,4043299481020800,6064949221531200,10685862914126400,12129898443062400,21371725828252800,24259796886124800,30324746107656000,32057588742379200,37400520199442400,64115177484758400,74801040398884800,112201560598327200,149602080797769600,224403121196654400,448806242393308800,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600,897612484786617600 };
long long q[156];
std::map<unsigned long long, unsigned> prime_factorize(unsigned long long x) {
	std::map<unsigned long long, unsigned> ret;
	for (unsigned i = 2; 1ULL * i * i <= x; i++) {
		while (x % i == 0) x /= i, ret[i]++;
	}
	if (x != 1) ret[x]++;
	return ret;
}
unsigned long long divisor_function(unsigned long long x, int r) {
	std::map<unsigned long long, unsigned> res = prime_factorize(x);
	unsigned long long ret = 1;
	for (std::pair<unsigned long long, unsigned> w : res) {
		unsigned long long mulexp = 1, mul = 1, sum = 1;
		for (int i = 0; i < r; i++) mulexp *= w.first;
		for (int i = 0; i < w.second; i++) mul *= mulexp, sum += mul;
		ret *= sum;
	}
	return ret;
}
int main() {
	for (int i = 0; i < 109; i++)q[i] = divisor_function(p[i], 1);
	while (true) {
		cin >> n; if (n == 0)break;
		for (int i = 1; i < 109; i++) {
			if (p[i] > n) { printf("%.11Lf\n", 1.0l*q[i - 1] / p[i - 1]); break; }
		}
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    if (i%3 == 0) {
      ans = ans;
    }
    else if (i%5 == 0) {
      ans = ans;
    }
    else {
      ans += i;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n/2), b(n/2);
    map<int, int> a1, b1;
    rep(i, n/2){
        cin >> a[i] >> b[i];
        a1[a[i]]++;
        b1[b[i]]++;
    }
    priority_queue<P> a2, b2;
    for(auto i: a1){
        a2.push(P(i.second, i.first));
    }
    for(auto i: b1){
        b2.push(P(i.second, i.first));
    }
    a2.push(P(0, 0)); b2.push(P(0,0));
    ll ans = 0;
    if(a2.top().second != b2.top().second){
        ans = n - a2.top().first - b2.top().first;
    }else{
        ll memo, memo1;
        memo = a2.top().first; a2.pop();
        memo1 = b2.top().first; b2.pop();
        ans = max(memo + b2.top().first, memo1 + a2.top().first);
        ans = n - ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7668
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s, t; cin >> s >> t;
	sort(ALL(s));
	sort(ALL(t)); reverse(ALL(t));
	cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
mod=10**9+7
x,y=map(int,input().split())
if y>=x:
  x,y=y,x
mods=[1]
rmods=[1]
for i in range(1,x+1):
  tmp=i*mods[-1]
  tmp%=mod
  mods.append(tmp)
for i in range(1,x+1):
  tmp=pow(i,mod-2,mod)*rmods[-1]
  tmp%=mod
  rmods.append(tmp)
ans=0
for i in range(x+1):
  n=i
  if (x-i)%2==1:
    continue
  m=(x-i)//2
  if 2*n+m!=y:
    continue
  else:
    tmp=mods[n+m]*rmods[n]*rmods[m]
    tmp%=mod
    ans+=tmp
    ans%=mod
print(ans)

Measured memory_bytes: 99336
S = gets.chomp
T = gets.chomp

mapping_s = Hash.new { |h, k| h[k] = [] }
mapping_t = Hash.new { |h, k| h[k] = [] }

S.chars.zip(T.chars).each do |s, t|
  mapping_s[s] << t
  mapping_t[t] << s
end

f1 = mapping_s.values.all? { |l| l.uniq.size <= 1 }
f2 = mapping_t.values.all? { |l| l.uniq.size <= 1 }

if f1 && f2
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 36936
#include <iostream>
#include <vector>

int main() {
    int N, D;
    std::cin >> N >> D;

    std::vector<std::vector<int>> X(N, std::vector<int>(D));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < D; j++)
            std::cin >> X[i][j];

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i; j < N; j++) {
            int res = 0;
            for (int k = 0; k < D; k++)
                res += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            for (int p = 1; p * p <= res; p++)
                if (p * p == res)
                    ans++;
        }
    }
    std::cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   int a,b;
   cin>>a>>b;
   vector<int> vec(a);
   rep(i,a){
       cin>>vec.at(i);
   }
   sort(vec.begin(),vec.end());
   vector<int> check(200000,0);
   rep(i,a){
       check.at(vec.at(i))++;
   }
   int cou=0;
   sort(check.begin(),check.end());
   rep(i,200000){
       if(check.at(i)>0){
           cou++;
       }
   }
   int how=cou-b;
   int ans=0;
   if(cou<=b){
       cout<<ans<<endl;
   }
   else{
       rep(i,200000){
           if(check.at(i)!=0){
               ans+=check.at(i);
                how--;
           }
           if(how==0){
               break;
           }

       }
       cout<<ans<<endl;
   }
   
}



Measured memory_bytes: 1792
N = gets.to_i
@a = N.times.map{gets.split.map(&:to_i)}

INFTY = 1<<21
WHITE = 0
GRAY  = 1
BLACK = 2

@adj = Array.new(N){[]}
@pq = []
@h = 0

def max_heapify(i)
  l = 2 * i
  r = 2 * i + 1

  if l <= @h && (@pq[l] <=> @pq[i]) == 1
    largest = l
  else
    largest = i
  end

  if r <= @h && (@pq[r] <=> @pq[largest]) == 1
    largest = r
  end

  if largest != i
    @pq[i], @pq[largest] = @pq[largest], @pq[i]
    max_heapify(largest)
  end
end

def extract
  return -INFTY if @h < 1
  maxv = @pq[1]

  @pq[1] = @pq[@h]
  @h -= 1

  max_heapify(1)
  maxv
end

def increase_key(i, key)
  return if (key <=> @pq[i]) == -1

  @pq[i] = key
  while i > 1 && (@pq[i / 2] <=> @pq[i]) == -1
    @pq[i], @pq[i / 2] = @pq[i / 2], @pq[i]
    i = i / 2
  end
end

def insert(key)
  @h += 1
  @pq[@h] = -INFTY
  increase_key(@h, key)
end

def dijkstra
  insert([0, 0])

  d = Array.new(N){INFTY}
  d[0] = 0
  color = Array.new(N){WHITE}
  color[0] = GRAY

  loop do
    f = extract
    break if f == -INFTY

    u = f[1]
    color[u] = BLACK
    next if d[u] < f[0] * -1

    (0...@adj[u].size).each do |j|
      v = @adj[u][j][0]
      next if color[v] == BLACK

      if d[v] > d[u] + @adj[u][j][1]
        d[v] = d[u] + @adj[u][j][1]
        insert([d[v] * -1, v])

        color[v] = GRAY
      end
    end
  end

  (0...N).each do |i|
    puts "#{i} #{d[i] == INFTY ? -1 : d[i]}"
  end
end

(0...N).each do |i|
  u = @a[i][0]
  k = @a[i][1]

  (2...(k * 2 + 2)).each do |j|
    next if j.odd?
    v = @a[i][j]
    c = @a[i][j + 1]
    @adj[u] = [] if @adj[u].nil?
    @adj[u].push([v, c])
  end
end
dijkstra


Measured memory_bytes: 41352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ?????°?????????
		int cnt1 = 0;
		int cnt2 = 0;

		while(true) {

			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H == 0 && W == 0) {

				
				break;

			} else {

				for(cnt1 = 0; cnt1 < H; cnt1++ ) {

					for(cnt2 = 0; cnt2 < W ; cnt2++ ) {
						System.out.print("#");
					}
				System.out.println("");

				}
			}
			
			System.out.println("");

		}

		sc.close();

	}

}

Measured memory_bytes: 35068
#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
int A[int(1e5+5)];
vector <int> cnt;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);

  int now = 1;
  for (int i = 0; i < N; i++){
    if (A[i] == A[i + 1]) now++;
    else{
      cnt.push_back(now);
      now = 1;
    }
  }

  sort(cnt.begin(), cnt.end(), greater<int>());
  int ans = N;


  for (int i = 0; i < cnt.size(); i++){
    while (cnt[i] > 1){
      ans -= 2;
      if (cnt[i] == 2) cnt[i]--, cnt[i+1]--;
      else cnt[i] -= 2;
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl

long long  n, a[200010], sum;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= (i + 1);
        sum += a[i];
    }

    sort(a, a + n);
    
    long long sol = 1e18, s = 0;
    for (int i = 0; i < n; i++) {
        long long tmp = i * a[i] - s + sum - s - (n - i) * a[i];
        sol = min(sol, tmp);
        s += a[i];
    }

    cout << sol;

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<vector<long long> > g(n, vector<long long>(n));
    for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) cin >> g[i][j];
    vector<vector<bool> > used(n, vector<bool>(n, false));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            for(int x = 0; x < n; ++x){
                if(x == i || x == j || i == j) continue;
                if(g[i][j] > g[i][x] + g[x][j]){
                    cout << -1;
                    return 0;
                }
                if(g[i][j] == g[i][x] + g[x][j]){
                    used[i][j] = used[j][i] = true;
                }
            }
    long long ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            if(i == j) continue;
            if(!used[i][j]) ans += g[i][j];
        }
    cout << ans / 2;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(void){
    string S;
    string O;
    cin>>S>>O;
    int i = 0;
    while(i<S.size()){
        cout<<S[i];
        if(i<O.size()){
        cout<<O[i];
        
        }
        i++;
        
    }
    return 0;
}
    

Measured memory_bytes: 384
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N;
    sll(N);
    cout << N / 2 + N%2<<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3220
#pragma GCC optimize "O3"
#pragma GCC target "avx"
#include <cstdio>
#include <vector>
#include <algorithm>
#include <bitset>
#include <chrono>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr int k_max = 5000;
constexpr long long tle = 2000;
int main() {
    chrono::high_resolution_clock::time_point clock_begin = chrono::high_resolution_clock::now();
    int n, k; scanf("%d%d", &n, &k);
    vector<int> a(n);
    repeat (i,n) {
        scanf("%d", &a[i]);
        setmin(a[i], k);
    }
    whole(sort, a);
    whole(reverse, a);
    int unnecessary = 0;
    auto mask_base = ~ (((~ bitset<k_max>()) >> k) << k);
    repeat (i,n) {
        if (a[i] == k) continue;
        auto mask = ((mask_base >> (k - a[i])) << (k - a[i]));
        bitset<k_max> dp = {};
        dp[0] = true;
        repeat (j,n) if (j != i and a[j] != k) {
            dp |= dp << a[j];
            if (j % 128 == 0 and (dp & mask).any()) break;
        }
        if ((dp & mask).none()) {
            unnecessary = n-i;
            break;
        }
        chrono::high_resolution_clock::time_point clock_end = chrono::high_resolution_clock::now();
        if (chrono::duration_cast<chrono::milliseconds>(clock_end - clock_begin).count() >= tle * 0.95) break;
    }
    printf("%d\n", unnecessary);
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
 
#include <bits/stdc++.h>
using namespace std;
 
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
 
int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No";
            break;
        }
    }
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    static <T extends Comparable<? super T>> boolean nextPermutation(T[] sequence) {
        int first = getFirst(sequence);
        if (first == -1) return false;
        int toSwap = sequence.length - 1;
        while (sequence[first].compareTo(sequence[toSwap]) >= 0) --toSwap;
        swap(sequence, first++, toSwap);
        toSwap = sequence.length - 1;
        while (first < toSwap) swap(sequence, first++, toSwap--);
        return true;
    }

    static <T extends Comparable<? super T>> int getFirst(T[] sequence) {
        for (int i = sequence.length - 2; i >= 0; --i)
            if (sequence[i].compareTo(sequence[i + 1]) < 0) return i;
        return -1;
    }

    static <T extends Comparable<? super T>> void swap(T[] sequence, int i, int j) {
        T tmp = sequence[i];
        sequence[i] = sequence[j];
        sequence[j] = tmp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] matrix = new int[n][n];
        for (int i = 0; i < n; ++i) Arrays.fill(matrix[i], 0);
        for (int i = 0; i < m; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            matrix[a][b] = 1;
            matrix[b][a] = 1;
        }

        Integer[] path = new Integer[n];
        for (int i = 0; i < n; ++i) path[i] = i;
        int res = 0;
        do {
            if (path[0] != 0) continue;

            boolean flag = true;
            for (int i = 0; i < n - 1; ++i) {
                if (matrix[path[i]][path[i+1]] != 1) {
                    flag = false; break;
                }
            }
            if (flag) ++res;

        } while(nextPermutation(path));

        System.out.println(res);
    }
}

Measured memory_bytes: 22960
#include <stdio.h>

int abs(int n) {
  return n >= 0 ? n : -n;
}

int dist[1010];
int main(void) {
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);

  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int hoge = abs(j - y) + abs(i - x) + 1;
      int poyo = j - i > hoge ? hoge : j - i;
      dist[poyo]++;
    }
  }

  for (int i = 1; i < n; i++) {
    printf("%d\n", dist[i]);
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<std::pair<int64_t, int64_t>> rl(N);
	for (auto& e: rl)
	{
		int64_t X, L;
		scanf("%lld%lld", &X, &L);
		e = {X + L, X - L};
	}
	std::sort(rl.begin(), rl.end());
	int64_t prev{-(1ll << 50)};
	int count{};
	for (auto& e: rl)
	{
		if (e.second < prev) continue;
		prev = e.first;
		count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1792
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=r[1].split(""),o=0,u=0;u<t;u++){"."==n[u]&&(o+=1)}for(var i=o,f=0,l=9999999,c=0;c<t;c++){var a=n[c];"."==a&&(i-=1);var p=f+i;p<l&&(l=p),"#"==a&&(f+=1)}console.log(l)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 9548
//RITIK RAI:
//#pragma GCC optimize("O3")
//#define ritik ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//vector<vector<ll>> 2Darray(rows,vector<ll>(col,val));
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ull unsigned long long int
#define ld long double
 #define pb push_back

#define mp make_pair
#define fir first
#define sec second
 
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search

#define intg INT_MAX
#define ints INT_MIN
#define endl '\n'
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>b;i--)
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define print1(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl
#define print(arr,a,b)  for(ll i=a;i<b;i++) cout<<arr[i]<<endl
#define print2d(dp,r,c) for(ll i=0;i<r;i++){for(ll j=0;j<c;j++) cout<<dp[i][j]<<" "; cout<<endl;}

/*--------------------------------------------FUNCIONS--------------------------------------------------------------*/
 
ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

/*-----------------------------------------------write your code here-----------------------------------------------------------*/

ll mod=1000000007;

int main()
{
    ll h,w; cin>>h>>w;
    vector<vector<char>> graph(h+3,vector<char>(w+3,'*'));
    vector<vector<ll>> dp(h+3,vector<ll>(w+3,0ll));
    f(i,1,h+1) f(j,1,w+1) 
        cin>>graph[i][j];
    dp[h][w]=1ll;
    rf(i,h,0) rf(j,w,0)
        if(i*j!=h*w) dp[i][j]=( (graph[i][j]=='.') ? (dp[i][j+1]+dp[i+1][j])%mod : 0ll );
    cout<<dp[1][1]%mod<<endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vll vector<ll>
#define vvll vector<vll>
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

int inf = 2e9+15;
ll INF = 2e18L+15;
const int mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	int a[n];
	vector <pii> test[n];
	int x, y;
	rep(i,n){
		cin >> a[i];
		rep(j,a[i]){
			cin >> x >> y;
			test[i].push_back({x-1,y});
		}
	}
	/*cout <<">\n";
	rep(i,n){
		cout << i<<endl;
		rep(j,a[i]){
			cout << test[i][j].first << " ";
			cout << test[i][j].second<<endl;
		}
	}*/
	int ans = 0;
	for(int i = 0; i <= (1<<n)-1; ++i){
		int mask = i;
		int ok = 1;
		int num = 0;
		vi hon(n,0);
		vi dis(n,0);
		for(int j=0;j<n;++j){
			if(mask & (1<<(n-1-j))){
				num++;
				for(int k=0;k<a[j];++k){
					x = test[j][k].first;
					y = test[j][k].second;
					if(y){
						hon[x]++;
					}else{
						dis[x]++;
					}
				}
			}
		}
		/*if(mask==6){
			rep(a,n){
				cout <<"i\thon\tdis\n";
				cout <<a<<"\t"<<hon[a]<<"\t"<<dis[a]<<endl;
			}
		}*/
		rep(j,n){
			if(mask&(1<<(n-1-j))){
				if(dis[j])
					ok = 0;
			}else{
				if(hon[j])
					ok = 0;
			}
		}
		if(ok){
			amax(ans, num);
			//cout << "Mask : "<<mask<< " Ans : "<<ans<<endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()
edges = defaultdict(dict)
pairs = []
for i in range(M):
    a, b = nl()
    pairs.append([a-1, b-1])
    edges[a-1][b-1] = True
    edges[b-1][a-1] = True

done = [False] * N

def check(v):
    done[v] = True
    for dst, on in edges[v].items():
        if not on or done[dst]:
            continue
        check(dst)

bridges = 0
for pair in pairs:
    edges[pair[0]][pair[1]] = False
    edges[pair[1]][pair[0]] = False

    done = [False] * N
    check(0)
    if not all(done):
        bridges += 1

    edges[pair[0]][pair[1]] = True
    edges[pair[1]][pair[0]] = True

print(bridges)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in2(a, b);
  if(a > b)
    a--;
  out(a);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (c <= (a+b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int n,m,ans;
  vector<int> v;
  
  cin >> n >> m;
  for (int i=0; i<m; i++){
    int a,b; cin >> a >> b;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  ans=0;
  for (int i=1; i<m; i++){
    if (v[i]<n) ans += n-v[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3160
#include <bits//stdc++.h>
using namespace std;
typedef long double ld;
#define c(n) cout << fixed <<setprecision(10) << n << endl
#define pi acos(-1)
int main() {
	int a, b, x; cin >> a >> b >> x;ld d;
	if (2 * x > a * a * b)d = 2.0 *(b * a * a - x) / pow(a,3);
	else d = 1.0 * b * b * a / (2 * x);
	c((atan(d)) / pi * 180);
}

Measured memory_bytes: 4144
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	for(;n=in();){
		n/=4;
		int i,sum=0;
		for(i=0;i<n;i++){
			sum+=in();
		}
		cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
[N,Q] = list(map(int,input().split()))
locate= [-1]*N

str=input()
s = list(str)

num_a=[0]*N
tmp=0

for i in range(1,N):
    if s[i-1]=='A' and s[i]=='C':
        tmp+=1
    num_a[i]=tmp
        

for i in range(Q):
    a = list(map(int, input().split()))
    L=a[0]-1
    R=a[1]-1
    print(num_a[R]-num_a[L])
 

Measured memory_bytes: 7748
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

int main(int,char**){
	int deb(100000);
	int n;
	int tmp;
	std::cin >> n;
	while(n--){
		deb*=1.05;
		if(deb%1000) {
			deb/=1000;
			++deb;
			deb*=1000;
		}
	}
	std::cout << deb <<std::endl;
	return 0;
}

Measured memory_bytes: 0
/*
ID: jerrywcy
TASK: AtCoder ABC 101 Problem C
LINK: https://abc102.contest.atcoder.jp/tasks/abc102_c
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int n,k;

int main(){
	cin>>n>>k;
	cout<<(n-k+(k-2))/(k-1)+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;


int main() {

	int n,m;
	cin >> n >> m;
	vi a(n);
	rep(i, n)cin >> a[i];

	int sum=0;
	rep(i, n)sum += a[i];

	sort(all(a));
	reverse(all(a));
	if (a[m - 1] *4*m< sum) cout << "No" << endl;
	else 	cout <<"Yes" << endl;
}

Measured memory_bytes: 256
// ababa
//  baba
// a  ba

//   aba
//  b ba
//   aba
// a  ba

//      

#include <iostream>
#include <set>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
ll ha[1'000'001];
const ll hash_c1 = 1007;
const ll hash_c2 = 11;
int main() {
  int n;
  cin>>n;
  unordered_map<ll, int> n_intact;
  vector<string> input;
  ll ans = 0;
  for(int i = 0; i < n; ++i) {
    string s;
    cin>>s;
    input.push_back(s);
    ll h = 0;
    //ha[j] == s[j...]
    ha[s.size()] = 0;
    //cout<<s<<": ";
    for(int j = (int)s.size()-1; j >= 0; --j) {
      ha[j] = ha[j+1]*hash_c1 + s[j];
      //cout<<ha[j]<<' ';
    }
    ans += n_intact[ha[0]];
    ++n_intact[ha[0]];
  }

  for(int i = 0; i < n; ++i) {
    string s = input[i];
    ll h = 0;
    //ha[j] == s[j...]
    ha[s.size()] = 0;
    //cout<<s<<": ";
    for(int j = (int)s.size()-1; j >= 0; --j) {
      ha[j] = ha[j+1]*hash_c1 + s[j];
      //cout<<ha[j]<<' ';
    }
    //cout<<'\n';
    set<char> c;
    for(int j = 0; j < s.size(); ++j) {
      c.insert(s[j]);
      if(j == 0) continue;
      for(auto x: c) {
        ll comb_hash = ha[j+1]*hash_c1 + x;
        ans += n_intact.count(comb_hash);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 18188
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var a = new int[N];
		for (var i = 0; i < N; i++) {
			a[i] = NextInt();
		}
		var j = 1;
		for (var i = 1; i <= N; i++) {
			j = a[j - 1];
			if (j == 2) {
				WriteLine(i);
				return;
			}
		}
		WriteLine(-1);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 17504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 100000;
    for (int i = 0; i < s.length() - t.length() + 1; i++)
    {
        int cnt = 0;
        for (int j = 0; j < t.length(); j++)
        {

            if (s[i + j] != t[j])
            {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cerr << #x << " = " << x << '\n';
#define PR(A, n) cerr << #A << " = "; for (int i=1; i<=n; ++i) cerr << A[i] << ' '; cerr << '\n';
#define PR0(A, n) cerr << #A << " = "; for (int i=0; i<n; ++i) cerr << A[i] << ' '; cerr << '\n';

int n, A[10002], B[10002];

int main() {
	//freopen("B.inp", "r", stdin);
	//freopen("B.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i=1; i<=n; ++i)
		cin >> A[i];
	for (int i=1; i<=n; ++i) 
		cin >> B[i];
	int64_t s = 0;
	for (int i=1; i<=n; ++i)
		s += B[i]-A[i];
	for (int i=1; i<=n; ++i) {
		s -= max(0, (B[i]-A[i])/2 + (B[i]-A[i])%2);
	}
	if (s<0)
		cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <cstdlib>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back

using namespace std;

const int N = 200010;
const int Mod = 1e9 + 7;

typedef long long LL;

LL Pow(LL x, LL e){
	LL ret = 1;
	while(e){
		if(e & 1) ret = ret * x % Mod;
		x = x * x % Mod;
		e >>= 1;
	}
	return ret;
}

LL fac[N], inv[N];

void init(int n){
	fac[0] = 1;
	For(i, 1, n) fac[i] = fac[i - 1] * i % Mod;
	inv[n] = Pow(fac[n], Mod - 2);
	Forr(i, n - 1, 0) inv[i] = inv[i + 1] * (i + 1) % Mod;
}

inline LL C(int n, int m){
	return fac[n] * inv[m] % Mod * inv[n - m] % Mod;
}

vector<int> G[N];

bool vis[N];
int stk[N], cir[N], ver[N], c, m, sume, sumv;
bool flag;

void DFS(int o, int f){
	stk[++c] = o;
	ver[++sumv] = o;
	vis[o] = true;
	for(int v : G[o]){
		++sume;
		if(v == f) continue;
		if(!vis[v]) DFS(v, o);
		else if(!flag){
			flag = true;
			int x = c;
			while(stk[c] != v) cir[++m] = stk[c--];
			cir[++m] = stk[c--];
			c = x;
		}
	}
	--c;
}

bool oncir[N];
int match[N];

void DFS_init(int o, int f = 0){
	if(f) match[o] = f;
	for(int v : G[o]){
		if(oncir[v] || v == f) continue;
		DFS_init(v, o);
	}
}

vector<int> S[N];
bool calced[N];
int sz[N], f[N];

void DFS_calc(int o){
	sz[o] = 0;
	calced[o] = true;
	f[o] = 1;
	for(int v : S[o]){
		DFS_calc(v);
		f[o] = 1LL * C(sz[o] + sz[v], sz[v]) * f[o] % Mod * f[v] % Mod;
		sz[o] += sz[v];
	}
	++sz[o];
}

int ind[N];

int work(){
	S[0].clear();
	For(i, 1, sumv) ind[ver[i]] = 0;
	For(i, 1, sumv){
		int o = ver[i];
		S[o].clear(), calced[o] = false;
		for(int j = 0; G[o][j] != match[o]; ++j) S[o].pb(G[o][j]), ind[G[o][j]]++;
	}
	For(i, 1, sumv) if(!ind[ver[i]]) S[0].pb(ver[i]);
	DFS_calc(0);
	return f[0];
}

int main(){
	int n;
	scanf("%d", &n);
	init(2 * n);
	For(i, 1, 2 * n){
		int x, y;
		scanf("%d%d", &x, &y);
		G[x].pb(y + n), G[y + n].pb(x);
	}
	n *= 2;
	For(i, 1, n) sort(G[i].begin(), G[i].end());
	int ans = 1;
	int pre = 0;
	For(i, 1, n){
		if(vis[i]) continue;
		c = m = sume = sumv = 0, flag = false;
		DFS(i, 0);
		if(sume != sumv * 2){
			ans = 0;
			break;
		}

		//For(j, 1, sumv) printf("%d%c", ver[j], j == sumv ? '\n' : ' ');
		For(j, 1, m) oncir[cir[j]] = true;//, printf("%d%c", cir[j], j == m ? '\n' : ' ');
		For(j, 1, m) DFS_init(cir[j]);

		For(j, 1, m - 1) match[cir[j]] = cir[j + 1];
		match[cir[m]] = cir[1];
		int ret = work();

		For(j, 2, m) match[cir[j]] = cir[j - 1];
		match[cir[1]] = cir[m];
		ret += work();

		ans = 1LL * ans * ret % Mod * C(sumv + pre, sumv) % Mod;
		pre += sumv;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 30844
#include <stdio.h>

int main(void) {
 int a, b, c, d;
 double e;
 
 scanf("%d %d", &a, &b);
 
 c=a/b;
 d=a%b;
 e=(double)a/b;
 
 printf("%d %d %f\n", c, d, e);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;

int main(){

    int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> num(200001,0);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
        num.at(a.at(i))++;
    }

    long long int count=0;
    for(int i=1; i<200001; i++){
        count+=num.at(i)*(num.at(i)-1)/2;
    }
    
    long long int ans;
    for(int i=0; i<n; i++){
        ans=count-num.at(a.at(i))+1;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6364
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  ll x,y,z;in(x,y,z);
  out(z,x,y);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256