akhauriyash/Code-Regression huggingface dataset:
#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>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); 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 S, class T>bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>bool chmin(S &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 << ld((n+1)/2)/n << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
char in[110];
int main(){
	int a;scanf("%d",&a);
	double b=0;
	for(int i=0;i<a;i++){
		int c;scanf("%d",&c);
		b+=1.0/c;
	}
	printf("%.12f\n",1.0/b);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll a,b,n;
  cin>>a>>b>>n;
  ll i=b-1,x=b-1;
  ll ans=(a*n)/b-a*(n/b);
  if(x<n)
  {
  	deb(max(ans,(a*x)/b-a*(x/b)));
  }
  else
  {
  	deb(ans);
  }
}

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

struct Point { double x, y; };

void koch_curve(int n, Point p1, Point p2)
{
    if (n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 /180.0;//度からラジアンへの変換

    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch_curve(n-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch_curve(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch_curve(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch_curve(n-1, t, p2);
}

int main()
{
    Point p1, p2;
    int n;
    cin >> n;

    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;

    printf("%.8f %.8f\n", p1.x, p1.y);
    koch_curve(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);

    return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vector<ll> one(61,0);
    rep(i,N){
        rep(j,61){
            if((A[i]&pw2[j])==pw2[j]) one[j]++;
        }
    }
    
    ll ans=0;
    rep(i,61){
        ans+=(((one[i]*(N-one[i]))%MOD)*mod_pow(2,i,MOD))%MOD;
        ans%=MOD;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 5632
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for _ in range(101)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).find('AGC') != -1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))



Measured memory_bytes: 48476
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
#include <thread>
using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	unordered_map<char, vector<string>> um1, um2;
	um1['a'].push_back("a");
	for (int i = 1; i < n; i++) {
		um2.clear();
		for (char c = 'a'; c <= 'z'; c++) {
			for (auto s : um1[c]) {
				if (s.size() != i) continue;
				// cout << s << endl;
				for (char cc = 'a'; cc <= 'z' && cc <= c + 1; cc++) {
					string ss = s;
					ss.push_back(cc);
					um2[max(cc, c)].push_back(ss);
					// um2[max(cc, c)].back().push_back(cc);
				}
			}	
		}
		um1 = um2;
	}
	vector<string> res;
	for (char c = 'a'; c <= 'z'; c++) {
		for (auto s : um1[c]) {
			res.push_back(s);
		}
	}
	sort(res.begin(), res.end());
	for (auto s : res) {
		cout << s << endl;
	}
}









Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
int main(){
    long long n,m,c,ans=0,sum,a;
    cin>>n>>m>>c;
    long long b[m];
    f(i,0,m){
        cin>>b[i];
    }
    f(i,0,n){
        sum=c;
        f(j,0,m){
            cin>>a;
            sum+=a*b[j];
        }
        if(sum>0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>

using namespace std;
int main(void){
    // Your code here!
    int N, M;
    cin >> N >> M;
    vector<int> vec(40);
    for(int i = 0; i < 39; i++) vec.at(i) = 0;
    
    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        for(int j = 0; j < K; j++){
            int A;
            cin >> A;
            vec.at(A)++;
        }
    }
    
    int count = 0;
    for(int i = 0; i < 39; i++){
        if(vec.at(i) == N){
            count++;
        }
    }
    cout << count << endl;



}


Measured memory_bytes: 384
N = gets.to_i
ds = gets.split.map(&:to_i)

if ds[0] != 0
  puts 0
  exit 0
end

sorted = ds.sort.uniq
n = 0
sorted.each do |d|
  unless d == n
    puts 0
    exit 0
  end
  n += 1
end

table = ds.reduce({}) do |acc, d|
  acc[d] ||= 0
  acc[d] += 1
  acc
end

if table[0] >= 2
  puts 0
  exit 0
end

MOD = 998244353
ans = 1
(1..(table.size - 1)).each do |d|
  pd = table[d - 1]
  ans = ans * (pd ** table[d]) % MOD
end
puts ans


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

int main() { //this code may be TLE...
    int N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> score(N);
    score.at(0) = 0;
    int k = 0;

    for (int i = 1; i < N; i++) {
        if (S.at(i) == 'C' && S.at(i-1) == 'A') {
            k++;
        }

        score.at(i) = k;
    }

    vector<int> ans(Q);

    for (int i = 0; i < Q; i++) {
        int l,r;
        cin >> l >> r;
        ans.at(i) = score.at(r-1) - score.at(l-1);
    }

    for (int i = 0; i < Q; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 1792
def koch_divide(p,q):
    v = [q[0]-p[0], q[1]-p[1]]
    s = [p[0]+v[0]/3, p[1]+v[1]/3]
    t = [q[0]-v[0]/3, q[1]-v[1]/3]
    u = [p[0]+v[0]*0.5-v[1]*0.288675, p[1]+v[0]*0.288675+v[1]*0.5]
    return [s,u,t,q]

def koch_curve(previous):
    vertices = [previous[0]]
    for p,q in zip(previous[:-1], previous[1:]):
        vertices.extend(koch_divide(p,q))
    return vertices

if __name__=='__main__':
    p_q = [[0.0, 0.0], [100.0, 0.0]]
    n = int(input())
    for _ in range(n):
        p_q = koch_curve(p_q)
    for vertex in p_q:
        print(" ".join(['{:.8f}'.format(x) for x in vertex]))

Measured memory_bytes: 8428
#include<stdio.h>
int main(void)
{
	int a,b,x,y,z,ans;
	scanf("%d %d",&a,&b);
	ans=0;
	x=a+b;
	z=x%2;
	y=x/2;
	if(z==1){
		ans=y+1;
	}
	else if(z==0){
		ans=y;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ.Volume0
{
    class Program0011
    {
        static void Main(string[] args)
        {
            int vert = int.Parse(Console.ReadLine());
            int hol = int.Parse(Console.ReadLine());

            int[] result = new int[vert];
            Queue<int[]> swapList = new Queue<int[]>();

            for (int i = 0; i < hol; i++)
            {
                string line = Console.ReadLine();
                swapList.Enqueue(line.Split(',').Select(int.Parse).ToArray());
            }

            //あみだくじ初期化
            for (int i = 0; i < vert; i++)
            {
                result[i] = i + 1;
            }

            foreach (var swapPair in swapList)
            {
                int temp = result[swapPair[0] - 1];
                result[swapPair[0] - 1] = result[swapPair[1] - 1];
                result[swapPair[1] - 1] = temp;
            }

            foreach (var item in result)
            {
                Console.WriteLine(item);
            }
        }
    }
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)

template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
//******************************************************************************

void print_vec(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}

signed main()
{
	//IOS();
	int M,K;
	cin>>M>>K;
	if((K&&M<2)||(K&&(1ll<<M)-1<K)){
		cout<<-1<<endl;
		return 0;
	}
	if(K==0){
		vint ans;
		rep(i,0,1ll<<M){
			ans.push_back(i);
			ans.push_back(i);
		}
		print_vec(ans);
		return 0;
	}
	vector<int>ans;
	ans.push_back(K);
	rep(i,0,1ll<<M){
		if(i!=K){
			ans.push_back(i);
		}
	}
	ans.push_back(K);
	rrep(i,0,1ll<<M){
		if(i!=K){
			ans.push_back(i);
		}
	}
	print_vec(ans);
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p==2){
    	ll ans=0;
    	for(int i=s.length()-1;i>=0;i--){
    		if((s[i]-'0')%2==0)ans+=i+1;
    	}
    	cout << ans << endl;
    	return 0;
    }
    if(p==5){
    	ll ans=0;
    	for(int i=s.length()-1;i>=0;i--){
    		if((s[i]-'0')%5==0)ans+=i+1;
    	}
    	cout << ans << endl;
    	return 0;
    }
    ll a[n],b=(s[n-1]-'0')%p,c=10;a[n-1]=b;
    for(int i=s.length()-2;i>=0;i--){
        (b+=c*(s[i]-'0'))%=p;
        a[i]=b;
        (c*=10)%=p;
    }
    ll num[p];
    for(int i=0;i<p;i++)num[i]=0;
    num[a[0]]=1;
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=num[a[i]];
        num[a[i]]+=1;
    }
    ans+=num[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2196
#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 ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    int T=1;
    //cin >> T;
    while(T--){
        ll n;
        cin>>n;
        ll d[n];
        ll sum=0;
        rep(i,n){
            cin>>d[i];
            sum+=d[i];
        }
        ll ans=0;
        rep(i,n){
            ans+=d[i]*(sum-d[i]);
        }
        cout<<ans/2<<el;
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    string n;
    cin>>n;
    string ans="No";
    if(n[0]==n[1]&&n[1]==n[2])ans="Yes";
    if(n[1]==n[2]&&n[2]==n[3])ans="Yes";
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=("; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	vec X(N);

	REP(i, N) {
		cin >> X[i];
	}

	ll ans = 0;
	REP(i, N - 1) {
		ans += min(B, A * (X[i + 1] - X[i]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long LL;

const int maxN = 1e6+3;
LL prime[maxN];
int pi;
bool vis[maxN];

int main()
{
	LL x;
	std::cin >> x;
	pi = 0;
	for (LL i=2; i<=1e6; ++i)
	{
		if (!vis[i]) prime[pi++] = i;
		for (int k=0; k<pi; ++k)
		{
			LL j = i*prime[k];
			if (j >= 1e6) break;
			vis[j] = true;
			if (i % prime[k] == 0) break;
		}
	}
	// std::cerr << pi << "\n";
	int ans = 0;
	for (int i=0; i<pi; ++i)
	{
		LL p = prime[i];
		while (x % p == 0)
		{
			++ans;
			x /= p;
			p *= prime[i];
		}
		while (x % prime[i] == 0) x /= prime[i];
		// std::cerr << x << "\n";
	}
	if (x != 1) ++ans;
	std::cout << ans;
}

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

main() {
  while(1) {
    int n, k;
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    int data[n+1];
    fill_n(data, n+1, 0);
    for(int i = 0; i < k; i++) {
      int a;
      cin >> a;
      data[a] = 1;
    }

    int dp[2][n+1];
    fill_n(dp[0], 2*(n+1), 0);
    if(data[0]) dp[1][0] = 1;
    int maxL = -1;
    for(int i = 1; i <= n; i++) {
      if(data[i]) {
	dp[0][i] = dp[0][i-1]+1;
	dp[1][i] = dp[1][i-1]+1;
      } else {
	dp[0][i] = 0;
	dp[1][i] = dp[0][i-1]+1;
      }
      if(maxL == -1 || dp[data[0]][i] > maxL) maxL = dp[data[0]][i];
    }
    cout << maxL << endl;
  }
}

Measured memory_bytes: 1256
str = input()
num = int(input())
for i in range(num):
    command = input().split()
    c1, c2, c3 = command[0], int(command[1]), int(command[2])
    if c1 == 'print':
        print(str[c2:c3 + 1])
    elif c1 == 'reverse':
        str = str[:c2] + str[c2:c3 + 1][::-1] + str[c3 + 1:]
    elif c1 == 'replace':
        str = str[:c2] + command[3] + str[c3 + 1:]

Measured memory_bytes: 7684
#include <unordered_set>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>


void run() {
	int n;
	int d[100];
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		std::cin >> d[i];
	}
	std::sort(d, d + n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		while (i + 1 < n&&d[i] == d[i + 1])
			++i;
		++ans;
	}
	std::cout << ans << std::endl;
}
int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, ans = 0; cin >> n;
	for(ll i = 1; i <= n; i++) ans += (i * (n/i) * (1 + n/i))/2;
	cout << ans;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  ll comb[21][21];
  REP(i,21)REP(j,21)comb[i][j]=0;
  comb[0][0] = 1;
  REPR(i,21)REP(j,21){
    comb[i][j] += comb[i-1][j];
    if(j!=0)comb[i][j] += comb[i-1][j-1];
  }
  string s;
  cin >> s;
  ll n = s.size();
  bool odd = n%2==1;
  int cnt[26] = {};
  REP(i,n){
    cnt[s[i]-'a']++;
  }
  if(odd){
    int center = -1;
    REP(i,26){
      if(cnt[i]%2==1){
        if(center == -1){
          center = i;
          cnt[i]--;
        }else{
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  ll result = 1;
  ll t = n/2;
  REP(i,26){
    ll s = cnt[i]/2;
    if(s*2 != cnt[i]){
      cout << 0 << endl;
      return 0;
    }
    if(s==0)continue;
    result *= comb[t][s];
    t -= s;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1184
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elif else if
#define unint unsigned int
#define sint short int
#define lint long long int
#define Size 200000

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,a[Size];
    cin>>x;
    for(int i = 0; i < Size; i++)
    {
        a[i] = 0;
    }
    for(int i = 0; i<x-1; i++)
    {
        int tmp;
        cin>>tmp;
        a[tmp-1] += 1;
    }
    for(int i = 0; i < x; i++)
    {
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4436
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n=ip()
v=linp()
c=linp()
ans=0
for i in range(n):
    if v[i]>c[i]:ans+=v[i]-c[i]
print(ans)

Measured memory_bytes: 3064
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    static String P = "";
    static String Q = "";
    static int countP = 0;
    static int countQ = 0;
    static boolean isP = false;
    static boolean isQ = false;
    public static void main(String[] args) {
        int a = nextInt();
        int b = nextInt();

        if(a < b){
            for(int i=0; i<b; i++)
            {
                print(a);
            }
        }else{
            for(int i=0; i<a; i++)
            {
                print(b);
            }
        }
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21716
from collections import deque


def solve(string):
    n, *ab = map(int, string.split())
    e = [[] for _ in range(n + 1)]
    q = deque([1])
    c = [0] * (n + 1)
    for a, b in zip(*[iter(ab)] * 2):
        e[a].append(b)
    while q:
        s = q.popleft()
        d = 0
        for t in e[s]:
            d += 1 + (d + 1 == c[s])
            c[t] = d
            q.append(t)
    return str("{}\n{}".format(max(c), "\n".join(str(c[b]) for _, b in zip(*[iter(ab)] * 2))))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 29220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 998244353;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int h, w;
    cin >> h >> w;
    vector<vector<char>> a = inp(h, w);

    queue<pair<int, int>> que1, que2;
    int b = 0;
    rep(i, h) rep(j, w) if (a[i][j] == '#') ++b, que2.emplace(i, j);

    int ans = 0;
    while (!que2.empty() && b != h * w) {

        ++ans;

        que1.swap(que2);

        while (!que1.empty()) {
            auto p = que1.front();
            que1.pop();
            int y = p.first;
            int x = p.second;
            rep(i, 4) {
                int ty = y + dy[i];
                int tx = x + dx[i];
                if (ty < 0 || ty >= h) continue;
                if (tx < 0 || tx >= w) continue;
                if (a[ty][tx] == '#') continue;

                ++b;
                a[ty][tx] = '#';
                que2.emplace(ty, tx);
            }
        }
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 9488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
int a[N];
ll pre[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1) cin>>a[i];
  vi v;
  rep(i,1,n+1) v.pb(a[i]-i);
  sort(all(v));
  pre[0]=v[0];
  rep(i,1,sz(v)) pre[i]=pre[i-1]+v[i];
  ll ans=LLONG_MAX;
  rep(i,0,sz(v))
    ans=min(ans,(ll)(i+1)*v[i]-pre[i]+pre[n-1]-pre[i]-(ll)(n-1-i)*v[i]);
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 3572
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int h = scan.nextInt();
			int w = scan.nextInt();
			if(h == 0 && w == 0){
				break;
			}
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(i == 0 || j == 0 || i == h - 1 || j == w - 1){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}System.out.println();
			}System.out.println();
		}
	}
}

Measured memory_bytes: 24624
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int h,w;
VS s;

int f(int startx, int starty){
    VVI dist(h);
    REP(i,h){
        dist[i].resize(w,-1);
    }
    queue<PII> q;
    q.push(MP(startx,starty));
    dist[startx][starty] = 0;

    VI dx = {1,-1,0,0};
    VI dy = {0,0,1,-1};

    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        /*
        if(dist[x][y] != -1){
            continue;
        }
        dist[x][y] = 
        */
        
        REP(i,4){
            int nx = x+dx[i];
            int ny = y+dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w){
                continue;
            }
            if(s[nx][ny] == '#'){
                continue;
            }
            if(dist[nx][ny] != -1){
                continue;
            }
            dist[nx][ny] = dist[x][y]+1;
            q.push(MP(nx,ny));
        }
    }

    int result = 0;
    REP(i,h){
        REP(j,w){
            result = max(result,dist[i][j]);
        }
    }

    return result;
}

void Main()
{
    cin>>h>>w;
    s.resize(h);
    REP(i,h){
        cin>>s[i];
    }

    int result = 0;

    REP(i,h){
        REP(j,w){
            if(s[i][j] == '#'){
                continue;
            }
            int dist = f(i,j);
            result = max(result,dist);
        }
    }

    cout<<result<<endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

struct state{
  int x,y,t;
};

int T,N;
int F[311][311];
int H[311][311];

int dx[]={0,1,1,0,-1,-1};
int dy[]={1,1,0,-1,-1,0};

int main(){
  while( cin >> T >> N && (T||N) ){
    for(int i=0;i<N;i++){
      int x,y;
      cin >> x >> y;
      x+=150; y+=150;
      F[x][y] = 1;
    }
    int x,y;
    cin >> x >> y;
    x+=150; y+=150;
    queue<state> q;
    q.push(  (state){x,y,0} );
    H[x][y] = 1;
    while( !q.empty() ){
      state p = q.front(); q.pop();
      if( p.t == T ) continue;
      for(int i=0;i<6;i++){
	int nx = p.x + dx[i], ny = p.y + dy[i];
	if( F[nx][ny] ) continue;
	if( !H[nx][ny] ) {
	  H[nx][ny] = 1;
	  q.push( (state){nx,ny,p.t+1} );
	}
      }
    }
    int cnt = 0;
    for(int i=0;i<=300;i++){
      for(int j=0;j<=300;j++){
	if( H[j][i] ) cnt++;
      }
    }
    cout << cnt << endl;
    memset(H,0,sizeof(H));
    memset(F,0,sizeof(F));
  }
}

Measured memory_bytes: 1980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] XYZ = Console.ReadLine().Split(' ');

            Console.WriteLine(XYZ[2] + " " + XYZ[0] + " " + XYZ[1]);
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    int b = sc.nextInt();
    
    int ans = 0;
    
    if (b > 1 && b <= a){
      ans = 1;
    } else if (b > a){
      ans = (b - a)/(a-1) + 1;
      if ((b-a)%(a-1) != 0){
        ans++;
      }
    }
    
    System.out.print(ans);
    
  }
}

Measured memory_bytes: 23380
#include <iostream>
#include <string>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long x, ans = 0;
	cin >> x;
	ans += x / 11 * 2;
	x %= 11;
	if(x == 0) ;
	else if(x <= 6) ans += 1;
	else ans += 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, k = [int(elem) for elem in input().split()]
a_lst = [int(elem) for elem in input().split()]
minimum = min(a_lst)
num = n - Counter(a_lst)[minimum]

if num % (k-1) == 0: 
  print(num // (k-1))
else:
  print((num // (k-1)) + 1)

Measured memory_bytes: 19936
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = double.Parse(Console.ReadLine());

            var count = 0;
            for(int i = 1; i<Math.Ceiling(N/2); i++)
            {
                int a = (int)N - i;
                if(a != i)
                {
                    count++;

                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()
flag = True
num = 0
for i in range(m):
    while d[num] != t[i]:
        if d[num] > t[i]:
            flag = False
            break
        else:
            num += 1
    else:
        num += 1
    if flag == False:
        break
if flag == True:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 39560
#include <iostream>
using namespace std;
int main(){
int N;
cin>>N;
int odd=0;
for(int i=0;i<N;i++){
long k;
cin>>k;
if(k%2==1)odd++;
}
if(odd%2==1)cout<<"NO"<<endl;
else cout<<"YES"<<endl;


return 0;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> x(h,vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin>>x[i][j];
    }
  }
  //白だけの行Hと列Wをカウント
  vector<int> couh,couw;
  for(int i=0; i<h; i++){
    int a=0;
    for(int j=0; j<w; j++){
      if(x[i][j]=='.'){
        a++;
      }
    }
    if(a==w){
      couh.push_back(i);
    }
  }

  for(int i=0; i<w; i++){
    int a=0;
    for(int j=0; j<h; j++){
      if(x[j][i]=='.'){
        a++;
      }
    }
    if(a==h){
      couw.push_back(i);
    }
  }
    //cout<<couw[0]<<endl<<endl;
    //出力
  bool okh=true,okw=true;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      okh=true;okw=true;
      for(int k=0; k<couh.size(); k++){
        if(couh[k]==i){
            okh=false;
        }
      }
      for(int k=0; k<couw.size(); k++){
        if(couw[k]==j){
            okw=false;
        }
      }
      if(okh&&okw){
          cout<<x[i][j];
      }
    }
    if(okh){
      cout<<endl;
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0;i < N;i++) {
    string s;
    cin >> s;
    
    if(s == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N - 1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
/* - - - - - - - - - - - - - - -
    	User : 		VanishD
    	problem :
    	Points : 	
    - - - - - - - - - - - - - - - */
    # include <bits/stdc++.h>
    # define 	ll 		long long
    using namespace std;
    const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
    const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
    int read(){
    	int tmp = 0, fh = 1; char ch = getchar();
    	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
    	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
    	return tmp * fh;
    }
    const int P = 1e9 + 7, N = 210;
    int n, h[N];
    ll f[N][2][2][2], g0[2][2][2], g1[2][2][2], use[N];
    ll power(ll x, int y){
    	ll i = x; x = 1;
    	while (y > 0){
    		if (y % 2 == 1) x = x * i % P;
    		i = i * i % P;
    		y /= 2;
    	}
    	return x;
    }
    int main(){
    //	freopen(".in", "r", stdin);
    //	freopen(".out", "w", stdout);
    	n = read();
    	for (int i = 1; i <= n; i++) h[i] = read(); 
    	h[++n] = 1;
    	int las = inf, lim, tmp, cnt = 0;
    	while (cnt < n){
    		lim = -1;
    		for (int j = 1; j <= n; j++)
    			if (use[j] == 0) 
    				lim = max(h[j], lim);
    		tmp = las - lim;
    		for (int j = 1; j <= n; j++){
    			if (use[j] == 2) continue;
    			if (use[j] == 0){
    				if (h[j] < lim) continue;
    				use[j] = 1;
    				f[j][0][0][0] = f[j][0][1][1] = 1;
    				cnt++;
    			}
    			else if (use[j] == 1){
    				f[j][0][0][0] = f[j][0][1][1] = (f[j][0][1][1] + f[j][0][0][0]) * power(2, tmp - 1) % P;
    				f[j][0][0][1] = f[j][0][1][0] = (f[j][0][0][1] + f[j][0][1][0]) * power(2, tmp - 1) % P;
    				if (tmp % 2 == 1){
    					swap(f[j][1][0][0], f[j][1][1][1]);
    					swap(f[j][1][0][1], f[j][1][1][0]);
    				}
    			}
    			if (j != 1 && use[j - 1] != 0){
    				use[j] = 2;
    				int k = j - 1;
    				while (use[k] == 2) k--;
    				for (int t0 = 0; t0 <= 1; t0++)
    					for (int t1 = 0; t1 <= 1; t1++)
    						for (int t2 = 0; t2 <= 1; t2++)
    							g0[t0][t1][t2] = f[k][t0][t1][t2], g1[t0][t1][t2] = f[j][t0][t1][t2];
    				for (int t0 = 0; t0 <= 1; t0++)
    					for (int t1 = 0; t1 <= 1; t1++){
    						f[k][0][t0][t1] = (g0[0][t0][1] * g1[0][0][t1] + g0[0][t0][0] * g1[0][1][t1]) % P;
    						f[k][1][t0][t1] = ((g0[1][t0][1] + g0[1][t0][0]) * (g1[1][0][t1] + g1[1][1][t1] + g1[0][0][t1] + g1[0][1][t1])) % P;
    						f[k][1][t0][t1] = (f[k][1][t0][t1] + (g0[0][t0][1] + g0[0][t0][0]) * (g1[1][0][t1] + g1[1][1][t1])) % P;
    						f[k][1][t0][t1] = (f[k][1][t0][t1] + g0[0][t0][1] * g1[0][1][t1] + g0[0][t0][0] * g1[0][0][t1]) % P;
    					}
    			}
    		}
    		las = lim; 
    	}
    	ll ans = 0;
    	for (int t0 = 0; t0 <= 1; t0++)
    		for (int t1 = 0; t1 <= 1; t1++)
    			ans = (ans + f[1][0][t0][t1] + f[1][1][t0][t1]) % P;
    	printf("%lld\n", 1ll * ans * power(2, P - 2) % P);
    	return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

int check(llong P)
{
	int i=0;
	for(int j=0;j<k;j++)
	{
		llong s=0;
		while(s + T[i] <= P)
		{
			s += T[i];
			i++;
			if(i==n)
			{
				return n;
			}
		}
	}
	return i;
}

int solve()
{
	llong left=0;
	llong right=100000*10000;
	llong mid;
	while(right-left>1)
	{
		mid=(left + right)/2;
		int v=check(mid);
		if(v>=n)
		{
			right=mid;
		}
		else
		{
			left = mid;
		}
	}
	return right;
}

int main(void)
{
	scanf("%d",&n);
	scanf("%d",&k);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&T[i]);
	}
	llong ans=solve();
	printf("%d\n",ans);
}




Measured memory_bytes: 2564
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ***********************************/
/******* Main ****************************************/
void Main() {
  int n, x, ans = 0;
  while (cin >> n >> x) {
    if (n == 0 && x == 0) return;
    ans=0;
    rep(i, 1, n + 1) {
      rep(j, i + 1, n + 1) {
        rep(k, j + 1, n + 1) {
          if (i + j + k == x) ans++;
        }
      }
    }
    con(ans);
  }
}

/*********************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

************************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3108
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, cnt int
	fmt.Scan(&n)

	s := make([]string, n)
	for i := range s {
		var w string
		fmt.Scan(&w)
		s[i] = sortString(w)
	}
	sm := make(map[string]int)

	for i := 0; i < len(s); i++ {
		str := s[i]
		n := sm[str]
		if n != 0 {
			cnt += n
		}
		sm[str]++
	}

	fmt.Println(cnt)
}

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}


Measured memory_bytes: 13440
#include <stdio.h>

int main(int argc, char **argv) {
    int k, a, b ;
    scanf("%d %d %d", &k, &a, &b) ;

    int tmp = k ;
    while(k<a) k += tmp ;
    if(k<=b) printf("OK\n") ;
    else printf("NG\n") ;
    
    return 0 ;
}


Measured memory_bytes: 1600
#include<stdio.h>
int main(void)
{
 int a,b,d,r;
 double f;
 scanf("%d %d",&a,&b);
 d=a/b;
 r=a%b;
 f=1.00000*a/b;
 printf("%d %d %f\n",d,r,f);
 return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n;
  for(int i=n;;)
  {
      m=i/2;
      int flag=0;
      if(i==2)
      {
          cout<<i<<endl;
          break;
      }
      else
      {
          for(int j=2;j<=m;j++)
          {
              if(i%j==0)
              {
                  flag=1;
                  break;
              }

          }
          if(flag==0)
          {
              cout<<i<<endl;
              break;
          }
          else
          {
              i++;
          }
      }


  }
  return 0;




}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)x.size())
typedef pair<int,int> PII;
const int N=200010;
int n,m,a[N];
int getres(int x,int y){
	if(x>y)return 0;
	int mid=(x+y)>>1,res=0;
	ref(i,x,mid)res=max(res,(a[i]+a[x+y-i])%m);
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	ref(i,1,n*2)scanf("%d",&a[i]);
	sort(a+1,a+n*2+1);
	int L=0,R=n*2;
	while(L+2<R){
		int mid=(L+R)>>1;if(mid&1)mid++;
		bool fg=1,FG=1;
		if(1<=mid)ref(i,1,(mid+1)/2)if(a[i]+a[mid+1-i]>m)fg=0;
		if(mid<n*2)ref(i,mid+1,(mid+1+n*2)/2)if(a[i]+a[mid+1+n*2-i]<=m)FG=0;
		if(!fg)R=mid;else
		if(!FG)L=mid;else
		R=mid;
	}
	int ans=1e9;
	while(L<=R){
		ans=min(ans,max(getres(1,L),getres(L+1,n*2)));
		L+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1152