akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll x, ll y) {
    if(x%y == 0) {
        return y;
    } else {
        return gcd(y,x%y);
    }
}

vector<pair<ll,ll>> prime_factorization(ll N) {
    vector<pair<ll,ll>> res;
    for(ll i = 2; i * i <= N; i++) {
        if(N % i == 0) {
            ll ex = 0;
            while(N % i == 0) {
                ex++;
                N /= i;
            }
            res.push_back(make_pair(i,ex));
        }
    }
    if(N != 1) res.push_back(make_pair(N,1));
    return res;
}

int main() {
    ll A,B; cin >> A >> B;
    vector<pair<ll,ll>> res = prime_factorization(gcd(A,B));
    cout << res.size()+1 << endl;
}

Measured memory_bytes: 256
import math

N = int(input())
S = []

for _ in range(N):
    S.append(input())

def create_hash(_str):
    hash = ""
    for i, a in enumerate(["a", "b", "c", "d", "e",
     "f", "g", "h", "i", "j",
     "k", "l", "m", "n", "o",
     "p", "q", "r", "s", "t",
     "u", "v", "w", "x", "y", "z"]):
        count = 0
        for s in _str:
            if s == a:
                count += 1
        hash += str(count)
    return hash

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

hist = {}
for s in S:
    hash = create_hash(s)
    hist[hash] = hist.get(hash, 0) + 1

pairs = 0
for k, v in hist.items():
    if v > 1:
        pairs += combinations(v, 2)
print(pairs)


Measured memory_bytes: 84312
#include <stdio.h>

int main(void)
{
	int i=0,j=0,k=0,H=0,W=0;
	for (i = 0; i < 300; ++i)
	{
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)
		{
			break;
		}
		else
		{
			for (i = 0; i < H; ++i)
			{
				if(i==0)
				{
					for ( j = 0; j < W ; ++j)
					{
						printf("#");
					}
					printf("\n");
				}
				if (i>0&&i<H-1)
				{
					for ( j = 0; j < W; ++j)
					{
						if(j==0)
						{
							printf("#");
						}  
						if(j>0&&j<W-1)
						{
							printf(".");
						}
						if (j==W-1)
						{
							printf("#\n");
						}
					} 
			        
			    }
			    if(i==H-1)
			    {
			    	for ( j = 0; j < W ; ++j)
					{
						printf("#");
					}
					printf("\n");
			    }
			

			}
			printf("\n");
		}
	}
	

	return 0;
}					

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a<b)rep(i,0,b)cout << a;
    else rep(i,0,a) cout << b;
    cout << endl;
    
}

Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    vector<double> v(n);
    for(ll i=0; i<n; i++){
        cin>>v[i];
    }
    vector<vector<double> > dp(n+1, vector<double>(n+1));
    for(ll i=0; i<=n; i++){
        dp[i][0] = 1;
    }
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=n; j++){
            dp[i][j] = dp[i-1][j-1]*(v[i-1])+dp[i-1][j]*(1-v[i-1]);
        }
    }
    cout<<ps(dp[n][(n+1)/2],9)<<endl;
    return 0;
}






Measured memory_bytes: 73796
#include<stdio.h>
int main(void){
  int a,b,c,d,e,f;
  scanf("%d %d %d",&a,&b,&c);
  if( a <= b && b <= c )
  d=a,e=b,f=c;
  else if (a <= c && c <= b )
  d=a,e=c,f=b;
  else if (b <= a && a <= c )
  d=b,e=a,f=c;
  else if (b <= c && c <= a )
  d=b,e=c,f=a;
  else if (c <= a && a <= b )
  d=c,e=a,f=b;
  else if (c <= b && b <= a )
  d=c,e=b,f=a;


  printf("%d %d %d\n",d,e,f);

return 0;


}



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

/**
 * @title Fenwick tree (Add)
 * @docs fenwick_tree_add.md
 */
template <typename T>
class FenwickTreeAdd {
  using value_type = T;

  int size;
  std::vector<value_type> data;

public:
  FenwickTreeAdd(){}
  FenwickTreeAdd(int size): size(size), data(size + 1, 0){}

  void update(int i, value_type val){
    i += 1; // 1-index

    while(i <= size){
      data[i] = data[i] + val;
      i += i & (-i);
    }
  }

  value_type get(int i) const { // [0, i)
    value_type ret = 0;
    i += 1; // 1-index

    while(i > 0){
      ret = ret + data[i];
      i -= i & (-i);
    }

    return ret;
  }

  value_type get(int l, int r) const { // [l, r)
    return get(r - 1) - get(l - 1);
  }
};


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

  int N, Q; std::cin >> N >> Q;

  FenwickTreeAdd<int64_t> s(N);

  std::vector<int64_t> a(N);
  for(int i = 0; i < N; ++i){
    std::cin >> a[i];
    s.update(i, a[i]);
  }

  for(int i = 0; i < Q; ++i){
    int type; std::cin >> type;
    if(type == 0){
      int p, x; std::cin >> p >> x;
      s.update(p, x);
    }else{
      int l, r; std::cin >> l >> r;
      std::cout << s.get(l, r) << "\n";
    }
  }



  return 0;
}


Measured memory_bytes: 12176
#include<cstdio>

int main(void){
char s[202];
char p[101];
int i,j,n,m;

scanf("%s",s);
scanf("%s",p);
n=0;
while(s[n]!='\0'){n++;};
//n???s???????????°

for(i=0;i<n;i++){
	s[i+n]=s[i];
};

m=0;
while(p[m]!='\0'){m++;};

bool b=false;
for(i=0;i<n;i++){
	for(j=0;j<m;j++){
		if(s[i+j]!=p[j]) break;
	};
	
	if (j==m) {
		b=true;
	};
};
if(b){
	printf("Yes\n");
} else {
	printf("No\n");
};
return 0;

}

Measured memory_bytes: 2680
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;



int main() {
	int n,k;
	scanf("%d %d", &n, &k);
	if (n % 2) {
		int centc = ((n + 1) / 2) % 3;
		if (!centc)centc = 3;
		centc += 3;
		REP(i, k) {
			int a, b;
			scanf("%d %d", &a, &b);
			a -= (n + 1) / 2;
			b -= (n + 1) / 2;
			int kyo = max(abs(max(a, b)), abs(min(a, b)));
			printf("%d\n", !(centc - (kyo % 3)) ? 3 : (centc - (kyo % 3)));
		}
	}
	else {
		int centc = (n / 2) % 3;
		if (!centc)centc = 3;
		centc += 3;
		REP(i, k) {
			int a, b;
			scanf("%d %d", &a, &b);
			a -= n / 2 + (bool)(a > (n / 2));
			b -= n / 2 + (bool) (b > (n / 2));
			int kyo = max(abs(max(a, b)), abs(min(a, b)));
			printf("%d\n", !((centc - (kyo % 3))%3) ? 3 : ((centc - (kyo % 3)) % 3));
		}
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    unsigned long O{0};
    for(unsigned long i{0}, A; i < M; ++i){
        cin >> A;
        O += A;
    }
    if(O > N)puts("-1");
    else cout << N - O << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
    long long x,y,n,d;
    int cnt=0;
    scanf("%lld %lld",&n,&d);
    for(int i=0;i<n;i++)
    {
        scanf("%lld %lld",&x,&y);
        if(d*d>=(x*x)+(y*y)) cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 1736
n, k = gets.split.map(&:to_i)
z = Array.new(k + 1, 0)
1.upto(n) do |i|
  z[i % k] += 1
end
ans = 0
k.times do |a|
  b = (k - a) % k
  c = (k - a) % k
  ans += z[a] * z[b] * z[c] if (b + c) % k == 0
end
puts ans

Measured memory_bytes: 3324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace puro
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = x.Max() - x.Min();
            int c = Math.Abs(b);
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値

// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
int main(){
ll n,k,r,s,p;
string t;
cin>>n>>k>>r>>s>>p>>t;
ll dp[n][3]={{}};
ll counter=0;
ll ca=0;
for(ll i=0; i<k; i++){
if(t.at(i)=='r'){
dp[i][0]=p;}
else if(t.at(i)=='s'){
dp[i][1]=r;}
else{
dp[i][2]=s;}}
for(ll i=0; i<k; i++){
for(ll m=k; i+m<n; m=m+k){
if(t.at(i+m)=='r'){
dp[i+m][0]=max(dp[i+m-k][1]+p,dp[i+m-k][2]+p);
dp[i+m][1]=max(dp[i+m-k][0],dp[i+m-k][2]);
dp[i+m][2]=max(dp[i+m-k][0],dp[i+m-k][1]);}
else if(t.at(i+m)=='s'){
dp[i+m][1]=max(dp[i+m-k][0]+r,dp[i+m-k][2]+r);
dp[i+m][0]=max(dp[i+m-k][1],dp[i+m-k][2]);
dp[i+m][2]=max(dp[i+m-k][0],dp[i+m-k][1]);}
else{
dp[i+m][0]=max(dp[i+m-k][1],dp[i+m-k][0]);
dp[i+m][1]=max(dp[i+m-k][0],dp[i+m-k][2]);
dp[i+m][2]=max(dp[i+m-k][0]+s,dp[i+m-k][1]+s);}
}}
for(ll i=n-1; i>n-k-1;i--){
ca=max(dp[i][0],dp[i][1]);
ca=max(dp[i][2],ca);
counter+=ca;
ca=0;}
cout<<counter<<endl;}

Measured memory_bytes: 6044
from collections import deque

n = int(input())
C = [[] for _ in range(n+1)]
for _ in range(n):
    stdin = list(map(int,input().split()))
    for j in range(stdin[1]):
        C[stdin[0]].append(stdin[2+j])

q = deque()
q.append(1)
d = [-1]*(n+1)
visited = [False]*(n+1)
d[1] = 0
visited[1] = True

while q:
    node = q.popleft()
    for adj in C[node]:
        if visited[adj] == False:
            q.append(adj)
            d[adj] = d[node]+1
            visited[adj] = True

for i in range(1,n+1):
    print("{} {}".format(i,d[i]))












Measured memory_bytes: 6008
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    ll res = 0, sm = 0;
    vl a(2*n),b(2*n);
    multiset<int> x,y;
    rep(i,2*n){
        cin >> a[i];
        res += a[i];
    }
    rep(i,2*n){
        cin >> b[i];
        b[i] -= a[i];
        if(i > 0 && i < 2*n-1){
            if(b[i] > 0){
                x.insert(b[i]);
                sm += b[i];
            }else{
                y.insert(-b[i]);
            }
        }
    }
    rep(i,q){
        int p,q,r;
        cin >> p >> q >> r;
        --p;
        res -= a[p];
        if(p > 0 && p < 2*n-1){
            if(b[p] > 0){
                x.erase(x.find(b[p]));
                sm -= b[p];
            }else{
                y.erase(y.find(-b[p]));
            }
        }
        a[p] = q;
        res += q;
        b[p] = r - q;
        if(p > 0 && p < 2*n-1){
            if(b[p] > 0){
                x.insert(b[p]);
                sm += b[p];
            }else{
                y.insert(-b[p]);
            }
        }
        ll ans = 0;
        if(len(x)%2){
            ans = res + max(sm-*x.begin(), sm-*y.begin());
        }else{
            ans = res+sm;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  ll S;
  cin >> S;
  ll x = ll(1e9 - S % ((ll)1e9)) % (ll)1e9;
  ll y = (S + x) / 1e9;
  cout << fixed << "0 0 " << (ll)1e9 << " 1 " << x << " " << y << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int num[n+1] = {0};
    for(int i = 0; i < n; i++){
        num[a[i]]++;
    }

    sort(num, num+n+1, greater<int>());

    // for(int i = 0; i < n+1; i++){
    //     cout << num[i] << endl;
    // }

    int ans = 0;
    for(int i = k; i < n+1; i++){
        ans += num[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    for(int H, W; scanf("%d %d", &H, &W), H!=0 && W!=0; printf("\n"))
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            printf("#");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2108
#include<stdio.h>
int main()
{
	const int cost[7][7] = {
		{0   ,300, 500 ,600,700,1350,1650,},
		{300 ,0  , 350 ,450,600,1150,1500,},
		{500 ,350, 0   ,250,400,1000,1350,},
		{600 ,450, 250 ,0  ,250,850 ,1300,},
		{700 ,600, 400 ,250,0  ,600 ,1150,},
		{1350,1150,1000,850,600,0   ,500},
		{1650,1500,1350,1300,1150,500,0},
	},distance[7][7] = {
		{ 0, 6,13,18,23,43,58,},
		{ 6, 0, 7,12,17,37,52,},
		{13, 7, 0, 5,10,30,45,},
		{18,12, 5, 0, 5,25,40,},
		{23,17,10, 5, 0,20,35,},
		{43,37,30,25,20, 0,15,},
		{58,52,45,40,35,15, 0,},
	};
	int toIndex,fromIndex,fromH,fromM,toH,toM,c,d;
	while(scanf("%d",&fromIndex),fromIndex)
	{
		scanf("%d%d%d%d%d",&fromH, &fromM, &toIndex, &toH, &toM);
		c=cost[fromIndex-1][toIndex-1];
		d=distance[fromIndex-1][toIndex-1];
		if( (
				(fromH==18 || (fromH==17&&fromM>=30) || (fromH==19&&fromM<=30)) ||
				(toH==18 || (toH==17&&toM>=30) || (toH==19&&toM<=30))
				) && d<=40)
			printf("%d\n", c%100 + c/100*50 );
		else printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    cout << powint(n, 3) << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 2000000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}

int E[2*maxn] ;

int main()
{
    preprocess() ;

    int n , a , b , c ;

    scanf("%d %d %d %d",&n,&a,&b,&c) ;

    numberTheory nt ;

    for(int i=1 ; i<=2*n ; i++)
    {
        E[i] = (1LL*E[i-1]*(a+b) + 100LL)%mod ;

        E[i] = (1LL*E[i]*nt.modularInverse(100-c,mod))%mod ;

    //    printf("%d\n",E[i]) ;
    }

    int ans = 0 ;

    for(int x=n ; x<2*n ; x++)
    {
        int ret = (1LL*nt.bigMod(a,n,mod)*nt.bigMod(b,x-n,mod) + 1LL*nt.bigMod(b,n,mod)*nt.bigMod(a,x-n,mod))%mod ;
        ret = (1LL*ret*E[x])%mod ;
        ret = (1LL*ret*nt.modularInverse( nt.bigMod(a+b,x,mod) ,mod) )%mod ;
        ret = (1LL*ret*C(x-1,n-1))%mod ;
        ans = (ans+ret)%mod ;
    //    printf("%d\n",ans) ;
    }

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

    return 0 ;
}


Measured memory_bytes: 32256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll N;
  cin >> N;
  ll B = N;
  for (ll A = 2; A * A <= N; A++) {
    if (N % A == 0) {
      B = N / A;
    }
  }
  cout << to_string(B).size() << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  for(int i=1;;i++){
   int x = sc.nextInt();
   if(x == 0){
     break;
    }
    System.out.printf("Case %d: %d\n" ,i,x);
  }
 }
}

Measured memory_bytes: 67704
unittest
{
	assert( [ "abaccaba" ].parse.expand.solve == "Yes" );
	assert( [ "hthth" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto w = input.front.to!( dchar[] );
	return tuple( w );
}

auto solve( dchar[] w )
{
	foreach( c; w.sort().group )
	{
		if( c[ 1 ] % 2 == 1 ) return "No";
	}
	return "Yes";
}


Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
    
def main():
    X = int(input())
    
    flag = True
    while flag:
        if is_prime(X):
            flag = False
        else:
            X += 1
    print(X)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            char sC = (char)(((int)sS[0]) + 1);

            // 出力
            System.Console.WriteLine("{0}", sC.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

d = 0
while black_cells:
    # キューとして使うのでpop()ではなくpopleft()
    h, w = black_cells.popleft()  # 黒いセルの座標
    d = dist[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_h = h + dy
        new_w = w + dx
        if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
            continue
        if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
            dist[new_h][new_w] = d+1
            black_cells.append((new_h, new_w))

print(d)

Measured memory_bytes: 87900
//
//*****************
//Created by corol
//*****************
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define wv(a, n) for (int i=0;i<(n);i++) {cin >> (a)[i];}
#define w(t) while (t--)
#define vi vector <int>
#define vs vector <string>
#define vll vector <long long>
#define vii vector <pair <int,int>>
#define MM <<
#define all(x) sort((x).begin(), (x).end());
#define rall(x) sort((x).rbegin(), (x).rend());
#define it int64_t
int dp[1000][1000];

template<class A>
void read(vector<A> &v);

template<class A, size_t S>
void read(array<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class T>
void print(T &x) {
    cout << x;
}

struct graph {
    int first, second;
};

bool cmputd(pair<int, int> a, pair<int, int> b) {
    return a.first > b.first;
}

bool cmpdtu(pair<int, int> a, pair<int, int> b) {
    return a.first < b.first;
}

bool cmpdtu_struct(graph a, graph b) {
    return a.first < b.first;
}

void test_cases();

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

    test_cases();
    //cout << "Time elapsed: " << 1.000 * clock() / CLOCKS_PER_SEC << " ms. \n";
    return 0;
}

int d_min(vector<int> &a, int p) {
    int l = -1;
    int r = (int) a.size();
    while (r > l + 1) {
        int m = (l + r) / 2;
        if (a[m] <= p) l = m;
        else r = m;
    }
    return l;
}

int d_max(vector<int> &a, int p) {
    int l = -1;
    int r = (int) a.size();
    while (r > l + 1) {
        int m = (l + r) / 2;
        if (a[m] < p) l = m;
        else r = m;
    }
    return r;
}

void test_cases()
{
    it a,b,c,d;
    cin >> a >>b >> c >> d;
    cout << max({a*d,a*c,b*c,b*d});
}

Measured memory_bytes: 3632
N = int(input())
r = 1
l = 10 ** 18
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
    print("0")
    exit()
for a in A:
    r = r * a
    if r > l:
        print("-1")
        exit()
print(r)

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

ll c[105][105];

void init_c()
{
    c[0][0] = 1LL;
    rep(i, 55)
    rep(j, i + 1)
    {
        c[i + 1][j] += c[i][j];
        c[i + 1][j + 1] += c[i][j];
    }
}

ll comb(int n, int m)
{
    return c[n][m];
}

int main()
{
    init_c();

    //  get input
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> values(n);
    rep(i, n) cin >> values[i];
    
    sort(values.begin(), values.end());
    reverse(values.begin(), values.end());

    double value = 0;
    rep(i, a)
        value += values[i];
    value /= (double)a;

    int cnt_v = 0;
    int cnt_need = 0;
    rep(i, n)
    {
        if (values[i] == values[a - 1])
        {
            cnt_v++;
            if (i < a)
                cnt_need++;
        }
    }

    ll ans_cnt = 0;
    if (values[0] == values[a - 1])
    {
        for (int cap = a; cap <= b and cap <= cnt_v; cap++)
            ans_cnt += comb(cnt_v, cap);
    }
    else
        ans_cnt += comb(cnt_v, cnt_need);

    cout.precision(20);
    cout << value << endl;
    cout << ans_cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
static int hat[100][100];
static int w,h;

void dfs(int x, int y,int k);

int main(void){
  int i,j,ans,i1,j2;

  //?????????1??????2?????????3??¢?´¢??????0
  while(1){
  ans=0;
  scanf("%d%d",&h,&w);
  if(h==0&&w==0) break;
  char hatt[h][w];
  for(i=0;i<h;i++){
    scanf("%s",hatt[i]);
    for(j=0;j<w;j++){
      if('@'==hatt[i][j]){hat[i][j]=1;
      }else if('#'==hatt[i][j]){hat[i][j]=2;
      }else if('*'==hatt[i][j]){hat[i][j]=3;
    }
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(hat[i][j]!=0){
	ans++;
	dfs(j,i,hat[i][j]);
      }
    }
  }
  printf("%d\n", ans);
  }
return 0;
}

void dfs(int x,int y,int k){
  hat[y][x]=0;
  //???
  if(y!=h-1&&hat[y+1][x]==k) dfs(x,y+1,k);
    //???
  if(x!=w-1&&hat[y][x+1]==k) dfs(x+1,y,k);
    //???
  if(y!=0&&hat[y-1][x]==k) dfs(x,y-1,k);
    //???   
  if(x!=0&&hat[y][x-1]==k) dfs(x-1,y,k);
}

Measured memory_bytes: 2008
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
	int n, d;
	cin>>n>>d;
	int cnt=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(sqrt(pow(a,2)+pow(b,2))<=d){
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3676
def main():
    N = int(input())
    song_time = [None] * N
    song_name = [None] * N
    for i in range(N):
        tmp = input().split()
        song_name[i] = tmp[0]
        song_time[i] = int(tmp[1])
    X = input()

    ind = song_name.index(X)

    ret = 0
    for i in range(ind+1, N):
        ret += song_time[i]

    print(ret)


if __name__ == '__main__':
    main()


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

int main()
{
    ll n, ans;
    cin >> n;
    ll d[n];
    rep(i, n) cin >> d[i];
    sort(d, d + n);
    if (n % 2 == 0)
        ans = d[n / 2] - d[n / 2-1];
    else
        ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble();
		double m = sc.nextDouble();
		double d = sc.nextDouble();
		double ans = (m - 1) * ((n - d) / n / n);
		if(d == 0) {
			System.out.printf("%.10f", ans);
		} else {
			System.out.printf("%.10f", ans * 2);
		}
	}
}



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

using namespace std;

int main()
{
    char a[60][60]={0},b[60][60]={0};
    int n,m,i,j,k,l,flag;
    cin >> n >> m;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin >> a[i][j];
        }
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<m;j++)
        {
            cin >> b[i][j];
        }
    }
    for(i=0;i<n-m+1;i++)
    {
        for(j=0;j<n-m+1;j++)
        {
            flag=0;
            for(k=i;k<i+m;k++)
            {
                for(l=j;l<j+m;l++)
                {
                    if(a[k][l]!=b[k-i][l-j])
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag==1) break;
            }
            if(flag==0) break;
        }
        if(flag==0) break;
    }
    if(flag==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
        int s,h,m,t;
        scanf("%d",&t);
        h =t/3600;
        m =(t-3600*h)/60;
        s =t-(h*3600+m*60);
        printf("%d:",h);
        printf("%d:",m);
        printf("%d\n",s);
        return 0;
}

Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define Inf 123372036854775806ll
using namespace std;


int main() {
    ll N,M;
    cin>>N>>M;
    
    
    // N+2*x, 2*(M-2*x)
    

    if (2*N >= M) {
        cout << M/2 << endl;
    } else {
        // find the largest x such that
        // 2*(N+x) <= (M-2*x)
        // 2*N+2*x <= M-2*x
        // 4*x <= M-2*N
        
        ll x = (M-2*N)/4;

        
        cout << N+x << endl;
        // N+2*x and 2*(M-2*x)
        
        
        
        
    }
    
    
    
    
    
}

Measured memory_bytes: 256
#include<stdio.h>
int  main(void)
{
	int temp,goukei[100] = { 0 },mondai, time[100], drink, siyou[100], siyoutime[100], i, n, t;
	scanf("%d", &mondai);
	for (i = 0; i < mondai; i++)
	{
		scanf("%d", &time[i]);
	}
	scanf("%d", &drink);
	for (i = 0; i < drink; i++)
	{
		scanf("%d%d", &siyou[i], &siyoutime[i]);
		siyou[i]--;
	}
	for (i = 0; i < drink; i++)
	{
		temp = time[siyou[i]];
		time[siyou[i]] = siyoutime[i];
		for (n = 0; n < mondai; n++)
		{
			goukei[i] += time[n];
		}
		time[siyou[i]] = temp;
	}
	for (i = 0; i < drink; i++)
		printf("%d\n",goukei[i] );
	return 0;
}

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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define f(n) for (int i=0;i<n;++i)
#define init(arr,m,n,value) std::fill(*arr,*arr+m*n,value)
#define low(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define up(s) transform(s.begin(),s.end(),s.begin(),::toupper)
//debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);

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

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//clock_t z = clock();
	string s;
	cin>>s;
	int n = s.size();
	if (s[n-1]=='s')cout<<s+"es";
	else cout<<s+'s';

}


Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				String str = reader.readLine();
				String[] arr = str.split(" ");
				String op = arr[1];
				if ("?".equals(arr[1])) {
					break;
				}
				int a = Integer.parseInt(arr[0]);
				int b = Integer.parseInt(arr[2]);
				int sum = 0;
				switch (op) {
				case "+":
					sum = a + b;
					break;
				case "-":
					sum = a - b;
					break;
				case "*":
					sum = a * b;
					break;
				case "/":
					sum = a / b;
					break;
				default:
					break;
				}
				System.out.println(sum);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 24220
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

#define int long long int
using namespace std;

int gcd(int a, int b) {
  if (a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }

  while (b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

void solve() {
  int A, B;
  cin >> A >> B;
  int z = gcd(A, B);

  int ans = 1;
  int lim = sqrt(z) + 1;
  for (int i = 2; i <= lim; i++) {
    if (z % i == 0) {
      ans++;
    }
    while (z % i == 0) {
      z /= i;
    }
  }
  if (z != 1) {
    ans++;
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int d[100010];
int main(){
  cin>>N;
  rep(i,N) cin>>d[i];
  sort(d,d+N);
  prin(d[N/2]-d[(N-1)/2]);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;

string s;
signed main()
{
    cin >> s;

    int sum = 0;
    REP(i, s.size()) sum += s[i] - '0';

    int N = stoi(s);
    if (N % sum == 0)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll X, N; cin >> X >> N;
	vector<ll> p(N);rep(i,N)cin >> p[i];
	map<ll,ll> q;
	rep(i,N) q[p[i]] = 1;

	ll min = 1e10;
	ll ans;
	for(int n = -100; n <= 200; n++){
		if(q[n] != 1 && abs(X-n) < min){
			ans = n;
			min = abs(X-n);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int n;
vector<int> bmb;
int a, b, c;
int ans;
void dfs(vector<int> &A){
    if(A.size() == n){
        // 得られている数列は、全探索したいものの1つを表している
        int len_a = 0, len_b = 0, len_c = 0;
        int cnt = 0;
        for(int i = 0; i < n; i++){
            if(A[i] == 0){
                len_a += bmb[i];
                cnt++;
            }
            else if(A[i] == 1){
                len_b += bmb[i];
                cnt++;
            }
            else if(A[i] == 2){
                len_c += bmb[i];
                cnt++;
            }
        }

        int tmp_ans = 0;
        if(len_a > 0 && len_b > 0 && len_c > 0){
            tmp_ans += 10 * (cnt - 3);
            tmp_ans += abs(a - len_a) + abs(b - len_b) + abs(c - len_c);
            ans = min(tmp_ans, ans);
        }
        return;
    }

    for(int v = 0; v < 4; v++){
        A.push_back(v);
        dfs(A);
        A.pop_back();
    }
}



int main(void){
    cin >> n;
    cin >> a >> b >> c;
    bmb.resize(n);
    for(int i = 0; i < n; i++){
        cin >> bmb[i];
    }

    vector<int> A;
    ans = 900000000;
    dfs(A);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cassert>
#include<stdint.h>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define all(n) (n).begin(),(n).end()
#define inf (1<<29)
using namespace std;

const uint64_t INF = 100000000000010;

struct List
{
  int identifier;
  uint64_t range[2];// [range[0],range[1]]
  bool hasNext,hasPrev;
  List *prev;
  List *next;
  List(int identifier=inf,uint64_t r1=INF,uint64_t r2=INF):identifier(identifier)
  {
    range[0] = r1, range[1] = r2;
    hasNext = hasPrev = false;
  }
};

int N,I,S,P;
char c;
List list;

void list_walk(List *l)
{
  cout << '[' << l->range[0] << "," << l->range[1] << " : " << l->identifier << "]";
  if(l->hasNext)list_walk(l->next);
}

void ddfs(List *l)
{
  if(l->hasNext)ddfs(l->next);
  if(l->hasPrev)delete l;
    
}

void init()
{
  if(list.hasNext)ddfs(&list);
  list.hasNext = true;
  list.hasPrev = false;
  list.range[0] = list.range[1] = -1;
  list.identifier = -1;
  list.next = new List;
  list.next->hasNext = false;
  list.next->hasPrev = true;
  list.next->range[0] = list.next->range[1] = INF;
  list.next->identifier = inf;
  list.next->prev = &list;
}

void dfsW(List *l)
{
  uint64_t v1 = l->range[1];
  uint64_t v2 = l->next->range[0];
  uint64_t diff = v2-v1-1;
  if(diff)
    {
      List *node = new List;
      node->identifier = I;
      node->hasNext = node->hasPrev = true;
      node->next = l->next;
      node->prev = l;
      l->next->prev = node;
      l->next = node;

      node->range[0] = v1+1;
      if(S <= diff)
	{
	  node->range[1] = node->range[0] + S - 1;
	  S = 0;
	}
      else if(S > diff)
	{
	  node->range[1] = node->range[0] + diff - 1;
	  S -= diff;
	}    
    }  
  if(S > 0)dfsW(l->next);
}

void compute_W()
{
  dfsW(&list);
}

void dfsD(List *l)
{
  if(l->identifier == I)
    {
      l->next->prev = l->prev;
      l->prev->next = l->next;
      delete l;
    }
  if(l->hasNext)dfsD(l->next);
}

void compute_D()
{
  dfsD(&list);
}

void dfsR(List *l)
{
  if(l->range[0] <= P && P <= l->range[1])
    {
      cout << l->identifier << endl;
    }
  else
    {
      if(l->hasNext)dfsR(l->next);
      else cout << -1 << endl;
    }
}

void compute_R()
{
  dfsR(&list);
}


int main()
{
  while(cin >> N,N)
    {

      init();
      rep(_,N)
	{
	  cin >> c;
	  if(c == 'W')cin >> I >> S,compute_W();
	  if(c == 'D')cin >> I,compute_D();
	  if(c == 'R')cin >> P,compute_R();
	}
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1448
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    int p[n+1];
    rep(i, 1, n+1){
        scanf("%d", &p[i]);
    }
    int a=0, b=0;
    rep(i, 1, n+1){
        if(p[i] == i){
            a++;
        }
    }
    rep(i, 1, n){
        if(p[i]==i && p[i+1]==i+1){
            b++;
            i++;
        }
    }
    printf("%d", a-b);

    return 0;
}

Measured memory_bytes: 512
import java.io.FileInputStream
import java.util.*


var sc: Scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
    if (args.size > 0) {
        System.setIn(FileInputStream(args[0]))
    }
    sc = Scanner(System.`in`)

    problem()

}

fun problem() {

    val N = sc.nextInt()
    sc.nextLine()
    val brueCards = mutableMapOf<String, Int>()
    for (a in 1..N) {
        val key = sc.nextLine()
        if (brueCards[key] == null) {
            brueCards[key] = 1
        }
        else {
            brueCards[key] = brueCards[key]!! + 1
        }
    }

    val M = sc.nextInt()
    sc.nextLine()
    for (a in 1..M) {
        val key = sc.nextLine()
        if (brueCards[key] == null) {
            brueCards[key] = -1
        }
        else {
            brueCards[key] = brueCards[key]!! - 1
        }
    }

    var maxk: String? = null
    var maxv = -200
    for ((key, value) in brueCards) {
        if (value == null) {
            return
        }
        if (value > maxv) {
            maxv = value
            maxk = key
        }
    }
    if (maxv >= 0) {
        println(maxv)
    }
    else {
        println(0)
    }

    //println(redCards)


    //var ans = sortedList.joinToString("")
    //println(Q)
}


Measured memory_bytes: 31264
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int A, B, H, M;
  cin >> A >> B >> H >> M;

  int m = H * 60 + M;
  long double r1 = M_PI * 2 * m / (12 * 60);
  long double r2 = M_PI * 2 * M / 60;
  long double a = sin(r1)*B, b = cos(r1) * B, c = sin(r2)*A, d = cos(r2) * A;

  cout << std::fixed << std::setprecision(15);
  long double x = c - a, y = d - b;
  long double r = sqrt(x * x + y * y);
  cout << r;
}
#endif


Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
int n;
int A[200005];
vector<int> M[200005];
ll dp[200005];

int main() {
  INCANT;
  cin >> n;
  rep(i, n) {
    cin >> A[i];
    A[i]--;
  }
  vector<int> P(n, -1);
  rep(i, n) {
    int sz = M[A[i]].size();
    if (sz) P[i] = M[A[i]][sz-1];
    M[A[i]].push_back(i);
  }

  fill(dp, dp+n, -1);
  dp[0] = 1ll;
  for (int i=1; i<n; i++) {
    dp[i] = dp[i-1];
    if (A[i]!=A[i-1] && P[i]>=0) {
      dp[i] += dp[P[i]];
      dp[i]%=MOD;
    } 
  }

  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <cstring>
using namespace std;
int main() {
	string S;
	bool g=0;
	cin>>S;
	for(int i=0;i<S.length();i++) {
		if(S[i]=='C')g=1;
		if(S[i]=='F' && g==1) {
			cout<<"Yes";
			return 0;
		}
	} 
	cout<<"No";
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
S = input()
w_num = S.count('W')
e_num = S.count('E')
a = 0
b = e_num
amin = n+1
if(len(set(S)) == 1):
    print(0)
else:
    for i in S:
        if(i == 'E'):
            b -= 1
        else:
            a+=1
        if(a+b < amin):
            amin = a+b
    print(min(amin, w_num, e_num))



Measured memory_bytes: 3672