akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int rad[414514] = {};
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string a, s;
	cin >> a;
	int cnt[26] = {};
	ll count = 0;
	REP(i, a.size()){
		count += cnt[a[i]-'a'];
		cnt[a[i]-'a']++;
	}
	int mx = 0;
	int j = 0;
	/*
	for(int i=0;i < s.size();){
		while(0 <= i-j && i+j < s.size() && s[i-j]==s[i+j]) j++;
		rad[i] = j;
		mx = max(mx, j);
		int k;
		for( k = 1;0 <= i-k && i+k < s.size() && rad[i-k] < rad[i]-k;k++){
			rad[i+k] = rad[i-k];
		}
		i+=k;
		j = max(j-k, 0);
	}
	ll res = 0;	
	REP(i, s.size()){
		if(i%2 == 0)
			res += max((rad[i]-1)/2, 0);
		else
			res += max((rad[i])/2, 0);
	}
	*/
	cout << (a.size())*(a.size()-1)/2-count+1 << endl;

}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9



vector<vector<int> >v;
vector<int>col,ans;
vector<int>d;
int n;

void dfs(int u,int p)
{
    int ind=lower_bound(d.begin(),d.end(),col[u])-d.begin();
    int prev=d[ind];
    if(d[ind-1]<col[u] and col[u]<d[ind])
        d[ind]=col[u];
    int ind1=lower_bound(d.begin(),d.end(),INF)-d.begin();
    ans[u]=ind1-1;
    for(int i=0;i<v[u].size();i++)
    {
        if(v[u][i]!=p)
            dfs(v[u][i],u);
    }
    d[ind]=prev;
}

int main()
{
    fastio;
    cin >> n;
    v.resize(n);
    col.resize(n);
    ans.resize(n);
    d.resize(n+1,INF);
    d[0]=-INF;
    for(int i=0;i<n;i++)
        cin >> col[i];
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        x-=1;y-=1;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(0,-1);
    for(int i=0;i<n;i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 30840
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {


	int N;
	scanf("%d", &N);

	printf("%f", 1.0-(double)(N / 2) / (double)N);



}






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

signed main(){
	int n,a;
	cin>>n;
	map<int,int> mp;
	for(int i=0;i<n;i++){
	    cin>>a;
	    mp[a]++;
	}
	for(auto i=mp.begin();i!=mp.end();i++){
	    int x=i->first,y=i->second;
	    if(x<=y){
	        ans+=y-x;
	    }
	    else{
	        ans+=y;
	    }
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define pf push_front
#define ll long long
using namespace std;
void TxtRead(){
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
}
void TheTime(){
    ios_base::sync_with_stdio(false);
	cin.tie();
}
const int N = 3e3+5;
const ll INF = 1e9+5;
const ll MOD = 1e9+7;
const double PI = 3.141592653589793116;

string s1, s2;
int dp[N][N];

int main()
{
    //TxtRead();
    TheTime();
	
	cin>>s1>>s2;
	s1='#'+s1;
	s2='$'+s2;
	int m=s1.size()-1;
	int n=s2.size()-1;
	
  	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++){
			if(s1[i]==s2[j])
				dp[i][j]=max(dp[i][j], dp[i-1][j-1]+1);
			else 
				dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
		}
	}
	
	int a=1, b=1, mx=0;
	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++){
			if(dp[i][j]>mx) a=i, b=j;
		}
	}
  
	string ans="";
	while(true){
		if(a==0 || b==0) break;
		if(dp[a][b]==dp[a-1][b]) a--;
		else if(dp[a][b]==dp[a][b-1]) b--;
		else{
			ans+=s1[a];
			a--, b--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<'\n';
}


Measured memory_bytes: 35456
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define mod          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)
#define sim 		 template<class T

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

sim > void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
sim > void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}

///.............................input.................................///
sim > void readvec( std::vector<T>& v, const int n) {
    rep(i,0,n) {
        T p;
        std::cin>>p;
        v.pb(p);
    }
}
///...........................input end...............................///


using namespace std;
using namespace __gnu_pbds;

const int maxn=800005;


void solve()
{
	int c;
	cin>>c;
	int ans=c^1;
	
	cout<<ans<<endl;
	
	
}


int main()
{
	
    fast_cin;


   // case
    {
      //  cout<<"Case "<<cas++<<": ";
        solve();
    }

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 int fun (int i, int j, vector<vector<int>>&a , vector<vector<int>> &dp)
{
    if(dp[i][j]!=-1)
        return dp[i][j];
    else
    {
        int m=0;
        if(j==0)
        {
            int x,y,z;
            x=max(fun(i-1,2,a,dp)+a[i][1],fun(i-1,3,a,dp)+a[i][1]);
             y=max(fun(i-1,1,a,dp)+a[i][2],fun(i-1,3,a,dp)+a[i][2]);
              z=max(fun(i-1,2,a,dp)+a[i][3],fun(i-1,1,a,dp)+a[i][3]);
              m=max(x,max(y,z));

        }
        else if(j==1)
        {
            m=max(fun(i-1,2,a,dp)+a[i][1],fun(i-1,3,a,dp)+a[i][1]);
        }
        else if(j==2)
        {
            m=max(fun(i-1,1,a,dp)+a[i][2],fun(i-1,3,a,dp)+a[i][2]);
        }
        else
        {
            m=max(fun(i-1,2,a,dp)+a[i][3],fun(i-1,1,a,dp)+a[i][3]);
        }
         return dp[i][j]=m;
         
    }

}

int main()
{
    #ifndef ONLINE_JUDGE 
    freopen ("input1.txt", "r", stdin); 
   freopen ("output1.txt", "w", stdout); 
    #endif
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

     int n;
     cin>>n;
     vector<vector<int>>a(n+1,vector<int>(4)),dp(n+1,vector<int>(4,-1));
     for(int i=1;i<=n;i++)
     {
        for(int j=1;j<=3;j++)
            cin>>a[i][j];
     }
     for(int i=1;i<4;i++)
        dp[n][i]=a[n][i];
    for(int i=0;i<4;i++)
        dp[0][i]=0;
     int ans=fun(n,0,a,dp);
     
     cout<<ans<<"\n";
    return 0; 

} 

  
        
    

    

    

        

    

  
        
    

    

    

        

    

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        int n; cin >> n;
        map<int, int> freq;
        while (n--) {
                int x; cin >> x;
                freq[x]++;
        }

        int ans = 0;
        for (auto it: freq) {
                if (it.second < it.first) ans += it.second;
                else ans += it.second - it.first;
        }

        cout << ans;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 8108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int N){
        par.assign(N,0);
        rank.assign(N,0);
        REP(i,N) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) swap(x,y);

        //x becomes root
        par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    VI a(N);
    REP(i,N) cin >> a[i];

    if(N == M+1){
        cout << 0 << endl;
        return 0;
    }

    VI x(M),y(M);
    REP(i,M) {
        cin >> x[i] >> y[i];
        uf.unite(x[i],y[i]);
    }

    if(N < 2*(N-M-1)){
        cout << "Impossible" << endl;
        return 0;
    }

    vector<PII> nec(N,PII(INF,INF));
    REP(i,N){
        if(nec[uf.find(i)].first > a[i]){
            nec[uf.find(i)] = PII(a[i],i);
        }
    }
    int used[112345] = {};
    LL ans = 0;
    REP(i,N){
        if(nec[i].first != INF){
            used[nec[i].second] = 1;
            ans += nec[i].first;
        }
    }
    priority_queue<int,vector<int>,greater<int>> q;
    REP(i,N){
        if(!used[i]){
            q.push(a[i]);
        }
    }
    REP(i,2*(N-M-1)-(N-M)){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 4092
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	int n;
	re(n);
	pair <int,int> p[n];
	ld sum = 0.0;
	for(int i= 0 ; i <n; i++)
	{
		re(p[i].fst,p[i].snd);
		//sum += sqrtl(p[i].fst*p[i].fst + p[i].snd*p[i].snd);
	}
	ll k = 1;
	for(int i = 1; i <=n; i++)
		k = k * i;
	ll k1 = k;
	k = k*2;
	k = k/n;
	for(int i =0 ; i +1 <n; i++)
	{
		for(int j = i+1; j < n; j++)
		{
			sum += sqrtl((p[i].fst - p[j].fst)*(p[i].fst - p[j].fst) + (p[i].snd - p[j].snd)*(p[i].snd - p[j].snd));
		}
	}
	sum = sum*k;
	sum = sum / k1;
	cout<<setprecision(10)<<sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;


int main(){
    int a,b,c;
    cin >> a >> b >> c;

    cout << min({a+b,b+c,a+c}) << endl;





    return 0;
}





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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            var ans = Solve();

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int Solve()
        {
            var N = GetInt();
            var A = GetIntArray();
            var ans = 0;
            while (true)
            {
                for(int i = 0; i < N; i++)
                {
                    if (A[i] % 2 != 0)
                    {
                        return ans;
                    }
                    else
                    {
                        A[i] /= 2;
                    }
                }
                ans++;
            }
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const double EPS = 1e-12;
const ll INF = numeric_limits<ll>::max() / 2;
const ll MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<ll> c(n);
    for(int i=0;i<n;i++) cin>>c[i];
    int q;cin>>q;
    vector<ll> num(n,0);
    for(int i=0;i<q;i++){
        int t,x,d;cin>>t>>x>>d;
        x--;
        if(t==1){
            if(num[x]+d>c[x]){
                cout<<x+1<<endl;
                return 0;
            }
            else{
                num[x]+=d;
            }
        }
        else{
            if(num[x]-d<0){
                cout<<x+1<<endl;
                return 0;
            }
            else{
                num[x]-=d;
            }
        }
    }
    cout<<0<<endl;
}



Measured memory_bytes: 3240
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
  if A[i] == B[i] == C[i]:
    continue
  elif A[i] != B[i] and A[i] != C[i] and B[i] != C[i]:
    ans += 2
  else:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using i_i = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const ll mod = 1000000007LL;

bool search(vector<int>& a, int length, int k) {
	int count = 0;
	for(int cur : a) {
		if (cur > length) {
			count += (cur - 1) / length;
			if (count > k) return false;
		}
	}
	return  true;
}

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> a(n);

	rep(i, n) {
		cin >> a[i];
	}
	int ok = 1000000001;
	int ng = 0;

	while(abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (search(a, mid, k)) {
			ok = mid;
		} else {
			ng = mid;
		}
		//cout << "ok:" << ok << " ng:" << ng << endl;
	}
	cout << ok << endl;


	return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int num[5000];

int main() {
	double v;
	while(scanf("%lf", &v) != EOF) {
		rep(i, 1000) {
			double y = 5 * i - 5;
			double t = sqrt(y / 4.9);
			double a = 9.8 * t;
			if(a > v) {
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3208
//start 11:37
//written 11:46
//test pass 12:01
#include <stdio.h>
//#define DEBUG

#define N_MAX 10
int list[N_MAX];
int n_list=0;

void init(void)
{
    n_list=0;
}
void push(int n)
{
    list[n_list++]=n;
}
void swap(int  *a,int *b)
{
    int tmp=*b; *b=*a; *a=tmp;
}
void sort(void)
{
    int i,j;
    for(i=0;i<n_list;i++){
        for(j=i+1;j<n_list;j++){
            if(list[i]>list[j]){
                swap(list+i,list+j);
            }
        }
    }
}

int main(void)
{
    FILE *fp;
#ifdef DEBUG
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif
    while(feof(fp)==0){
        int n;
        fscanf(fp,"%d\n",&n);
        int i;
        init();
        for(i=512;n>0;i/=2){
            if(n>=i){
                push(i);
                n-=i;
            }
        }
        sort();
        for(i=0;i<n_list;i++){
            printf("%d",list[i]);
            printf("%s",(i==n_list-1)?"\n":" ");
        }
    }
    return 0;
}

Measured memory_bytes: 0
import math
while 1: 
    n=int(input())
    if n==0:
        break
    else:
        l=list(map(int,input().split()))
        ave=sum(l)/n
        bunsi=0
        for j in l:
            bunsi+=(j-ave)**2
        ans=math.sqrt(bunsi/n)
        print(ans)


Measured memory_bytes: 5696
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e5+8;
int val[inf][2];
int n, w;
int dp[110][inf];

int f(int index, int left){
     if(left==0) return 0;
     if(left<0) return -1e16;
     if(index==n) return 0;

     int&ans=dp[index][left];
     if(ans!=-1) return ans;

     ans=0;
     ans=max(ans, val[index][1]+f(index+1, left-val[index][0]));
     ans=max(ans, f(index+1, left));
     return ans;
}

int32_t main(){
     memset(dp, -1, sizeof(dp));
     cin>>n>>w;
     for(int i=0;i<n;i++){
          cin>>val[i][0]>>val[i][1];
     }
     cout<<f(0, w);
}



Measured memory_bytes: 86272
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int k, t; cin >> k >> t;
    vector<pii> cake; 
    rep(i, t){
        int a; cin >> a;
        cake.emplace_back(a, i); //i番目のケーキがa個ある
    }

    int res = 0;
    vector<int> eat(k, -1);//食べたケーキ
    rep(i, k){
        sort(all(cake), greater<pii>());
        if(i>0 && eat[i-1] == cake[0].second){//同じケーキを食べそうになった場合
            if(cake.size() > 1 && cake[1].first > 0){//他に食べられそうなケーキがあれば        
                eat[i] = cake[1].second;
                cake[1].first--;
            }else{
                eat[i] = cake[0].second;
                cake[0].first--;
            }
        }else{
            eat[i] = cake[0].second;
            cake[0].first--;
        }
        if(i>0 && eat[i] == eat[i-1]) res++;
    }
    cout << res << ln;
}

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

int main(){
  int n;
  cin >> n;
  vector<tuple<string, int, int>> a;//string:市,int:点数,int:番号となっている
  for (int i=1;i<=n;++i){
    string s;
    int p;
    cin >> s >> p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  
  sort(a.begin(),a.end());
  for (int i=0;i<n;++i){
    cout << get<2>(a[i]) << endl;
  }
}
//可読性考えたら、構造体にして自分で比較関数作るのがベター


Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int n = scan.nextInt();
        int k = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        
        int cnt = 0;
        
        if( n <= k )cnt = n * x;
        
        else{
         cnt = (x * k) + (n - k) * y; 
        }
         
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    sort(ALL(vec));
    UNIQUE(vec);
    cout << vec.size() << endl;
    
    return 0;
}


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

#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ll long long
#define sc second
#define fr first
const int nax = 1e6+5;
const int mod = 1e4+7;
using namespace std;
typedef pair<double,double> pi;
typedef tuple<int,int,int> tu;


signed main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
    #endif
	int n,d;
	cin >> n >> d;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin >> x >> y;
		double ans = (double)sqrt(x*x+y*y);
		if(ans <= (double)d)
			cnt++;
	}
	cout << cnt << "\n";
}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  reverse(s.begin(), s.end());
  vector<string> vs;
  vs.push_back("dream");
  vs.push_back("dreamer");
  vs.push_back("erase");
  vs.push_back("eraser");
  for(int i = 0; i < vs.size(); ++i) reverse(vs[i].begin(), vs[i].end());
  int n = s.length();
  bool flag = true;
  for(int i = 0; i < n;){
    char c = s[i];
    if(c == 'm' && s.substr(i, 5) == vs[0]) i += 5;
    else if(c == 'e' && s.substr(i, 5) == vs[2]) i += 5;
    else if(c == 'r'){
      if(s.substr(i, 7) == vs[1]) i += 7;
      else if(s.substr(i, 6) == vs[3]) i += 6;
      else{
        flag = false;
        break;
      }
    }
    else {
      flag = false;
      break;
    }
  }
  cout << (flag ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3760
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		String S = fs.next();
		String T = fs.next();
		if(T.substring(0, T.length() - 1).equals(S)) System.out.println("Yes");
		else System.out.println("No");
		
	}

}


Measured memory_bytes: 25352
package main
import "fmt"
func main() {
  var s string
  var n,m int
  fmt.Scan(&s)
  n = len(s)
  m = 0
  for i:=0;i<n;i++ {
    if s[i:i+1] == "1" { m++ }
  }
  if m > n-m { m = n-m }
  fmt.Println(2*m)
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll A,B,N;
	cin>>A>>B>>N;
	ll X=min(N,B-1);
	DBG("","","","");
	cout<<(A*X/B-A*(X/B))<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
     
    using namespace std;
typedef long long ll;
ll N, K;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
 
  ll d = N % K;
  ll d_abs = d - K < 0 ? K - d : d - K;
  ll ans = min(d, d_abs);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
/*
void solve(){
  ll n; cin >> n;
  vector<ll> prime;
  FOR(i,2,(1000006)){
    bool flg = true;
    
    if(flg) prime.push_back(i);
  }
}
*/
/*
void solve(){
  int n; cin >> n; int ans =0;
  if(n<10) {cout << n; return;}
  priority_queue<
      int,                // 要素の型はint
      std::vector<int>,   // 内部コンテナはstd::vector (デフォルトのまま)
      std::greater<int>   // 昇順 (デフォルトはstd::less<T>)
    > qb, qa;
  FOR(i,1,10000000){
    string s = std::to_string(i);
    bool flg=true;
    FOR(j,0,s.size()-1){
      if(abs(s[j]-s[j+1])>1) {flg=false; break;}
    }
    if(flg) ans++;
    if(ans==n) {cout << i; return;}
  }
  cout << ans << endl;
}*/
/*
void solve(){
  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
}*/
template <class T> std::vector<T> divisors(const T &n) {
  std::vector<T> ret;
  T i = static_cast<T>(1);
  while (i * i < n) {
    if (n % i == static_cast<T>(0)) {
      ret.push_back(i);
      ret.push_back(n / i);
    }
    ++i;
  }
  if (i * i == n) {
    ret.push_back(i);
  }
  std::sort(ret.begin(), ret.end());
  ret.shrink_to_fit();
  return std::move(ret);
}


template<class T> struct prime{
  T N;
  vector<T> v;
  void init(const T &n){
    N = n;
    T i = static_cast<T>(2);
    while(true);
  }
};


void solve(){
  ll n; cin >> n;
  size_t ans = 0;
  for (const ll k : divisors(n)) {
    if (k == 1)
      continue;
    ll m = n;
    while (m % k == 0) {
      m /= k;
    }
    if (m % k == 1) {
      ans += 1;
    }
  }
  ans += divisors(n - 1).size();
  std::cout << ans - 1 << std::endl;
}

void solve2(){
  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
  vector<int> L(k+5), R(k+5);
  int cnt = 0, bf=-987654321;
  FOR(i,0,n){
    if(s[i]=='o' && (i-bf)>c) {bf = i; L[cnt] = i; cnt++;}
    if(cnt==k) break;
  }
  bf = 987654321; cnt = k-1;
  IFOR(i,0,n){
    if(s[i]=='o' && (bf-i)>c) {bf = i; R[cnt] = i; cnt--;}
    if(cnt==-1) break;
  }
  FOR(i,0,k){
    if(L[i]==R[i]) cout << (L[i]+1) << endl;
  }
}

int main(){
  solve();
  //solve2();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n,k,sum=0;
    cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin>>a[i];
    sort(a,a+n);
    for (int i = 0; i < k ; i++) {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,p;cin >> n >> p;
    vi a(n);
    rep(i,n)cin >> a[i];
    vector<vl> dp(n+10,vl(2,0));
    dp[0][0] = 1;
    dp[0][1] = 0;
    rep(i,n){
        if(a[i]&1){
            dp[i+1][0] = dp[i][0] + dp[i][1];
            dp[i+1][1] = dp[i][0] + dp[i][1];
        }else{
            dp[i+1][0] = 2*dp[i][0];
            dp[i+1][1] = 2*dp[i][1];
        }
    }
    cout << dp[n][p] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	}
}


Measured memory_bytes: 82492
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 3e5 + 5;
struct info{
	int val, pos;
}a[N], b[N];
inline bool comp(info x, info y) {
	return x.val > y.val;
}
int x[N], y[N];
bool va[N], vb[N];
vector <int> ta[N], tb[N];
int main() {
	int h, w, m;
	readin(h); readin(w);
	readin(m);
	for (int i = 1; i <= m; i ++) {
		readin(x[i]); readin(y[i]);
		a[x[i]].val ++;
		b[y[i]].val ++;
	}
	for (int i = 1; i <= h; i ++) a[i].pos = i;
	for (int i = 1; i <= w; i ++) b[i].pos = i;
	sort(a + 1, a + h + 1, comp);
	sort(b + 1, b + w + 1, comp);
	int p1, p2;
	for (int i = 1; i <= h; i ++) {
		va[a[i].pos] = true;
		if (a[i].val > a[i + 1].val) {
			p1 = i;
			break;
		}
	}
	for (int i = 1; i <= w; i ++) {
		vb[b[i].pos] = true;
		if (b[i].val > b[i + 1].val) {
			p2 = i;
			break;
		}
	}
	long long cnt = 0;
	long long sum = 1ll * p1 * p2;
	for (int i = 1; i <= m; i ++) {
		if (va[x[i]] && vb[y[i]]) cnt ++;
	}
	if (cnt == sum) writeln(a[1].val + b[1].val - 1, '\n');
	else writeln(a[1].val + b[1].val, '\n');
	return 0;
}




Measured memory_bytes: 25284
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

#define INFTY (1<<30);

long int A[2000000+1];
int H;

int parent(int i){ return i/2; }
int left(int i){ return i*2; }
int right(int i){ return i*2+1; }

void heapIncreasekey(int i, int key){
    if(key < A[i]) return;
    A[i] = key;
    while(i>1 && A[i/2]<A[i]){  //正しい位置まで繰り返す
        swap(A[i/2], A[i]);
        i = i/2;
    }
}

void insert(int x){
    H++;
    A[H] = -INFTY;  //新しい節を作る
    heapIncreasekey(H, x);    //A[H]にkeyを設定する
}

void maxHeap(int i){
    int l = left(i);
    int r = right(i);
    int largest;
    if((l<=H)&&(A[l]>A[i])){
        largest = l;
    }else{
        largest = i;
    }
    if((r<=H)&&(A[r]>A[largest])){
        largest = r;
    }

    if(largest!=i){
        swap(A[largest], A[i]);
        maxHeap(largest);   //再帰処理
    }
}

int heapExtract(){
    if(H<1) return -1;
    int max = A[1];
    A[1] = A[H];
    H--;
    maxHeap(1);

    return max;
}

int main(){

    while(1){
        string str;
        cin >> str;
        if(str == "insert"){
            int x;
            scanf("%d", &x);
            insert(x);
        }else if(str == "extract"){
            int x = heapExtract();
            if(x!=-1) printf("%d\n", x);
        }else if(str == "end"){
            break;
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for(int i=0; i<N; i++)
    cin >> mochi.at(i);
  sort(mochi.begin(), mochi.end());
  int count=1;
  for(int j=0; j<N-1; j++){
    if(mochi.at(j) < mochi.at(j+1)){
      count++;
      continue;
    }
    else
      continue;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n , m = map(int, input().split())
h = list(map(int, input().split()))
d = dict()
for i in range(m):
    a,b = list(map(int, input().split()))
    if a not in d:
        d[a] = set()
    if b not in d:
        d[b] = set()
    d[a].add(b)
    d[b].add(a)
ans = 0
for val in d:
    ans += 1
    r = d[val]
    for j in r:
        if h[val-1] <= h[j-1]:
            ans -= 1
            break

vals = len(list(d.values()))
l = n - vals
print(ans + l)


Measured memory_bytes: 113868
#include <bits/stdc++.h>
using namespace std;
int main() {
  char C;
  cin >> C;
  string s = "abcdefghijklmnopqrstuvwxyz";
  // 26 letters at total
  for (int i = 0; i < 25; i++){
    if (C == s.at(i)){
      cout << s.at(i+1) << endl;
      break;
    }
    
  }
  
}
  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;
using ll = long long;

// int main(){
//     int L;
//     cin >> L;
//     double l = L/3.l;
//     printf("%.12f\n.",pow(l,3));
//     return 0;
// }

int main() {
    int L;
    cin >> L;
 
    double d = L / 3.f;
    double ans = d * d * d;
 
    printf("%.10f", ans);
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    while(1){
        int i, j, h, w;
        scanf(" %d %d", &h, &w);
        if(h==0 && w==0) break;
         
        for(i=0; i<h; ++i){
            for(j=0; j<w; ++j){
                if( (i+j)%2==0 ) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
 
    }
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    rep(i,50000){
        if(i*1.08>=n and i*1.08<n+1){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = sorted([list(sorted(input())) for _ in range(N)]) + [" "]
ans = 0
cnt = 1
for i in range(N):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1

print(ans)

Measured memory_bytes: 25448
var main=function(){
	var INF=1<<30;
	var arg;
	for(;(arg=readline().split(' ').map(Number))[0];){
		var n=arg[0],m=arg[1];
		var c=[];
		for(var i=0;i<m;i++)c[i]=Number(readline());
		var prev=[];
		for(var i=0;i<256;i++)prev[i]=INF;
		prev[128]=0;
		var cur=[];
		for(var i=0;i<n;i++){
			var x=Number(readline());
			for(var j=0;j<256;j++)cur[j]=INF;
			for(var j=0;j<256;j++)if(prev[j]<INF){
				for(var k=0;k<m;k++){
					var t=Math.min(255,Math.max(0,j+c[k]));
					var y=prev[j]+(x-t)*(x-t);
					cur[t]=Math.min(cur[t],y);
				}
			}
			var t=prev;prev=cur;cur=t;
		}
		print(Math.min.apply(null,prev));
	}
};

/// IO ///
if(typeof process!=='undefined'){
	//node.js
	var print=function(x){
		console.log(x);
	}
	var readline=(function(){
		var T=[],cnt=0;
		var stdin = process.openStdin();
		stdin.setEncoding('utf8');

		var input_fragment="";
		stdin.on('data', function(input) {
			var ref=(input_fragment+input).split("\n");
			input_fragment=ref.pop();
			for(var i=0;i<ref.length;i++){
				if(ref[i]=='')continue;
				T.push(ref[i]);
			}
		});
		stdin.on('end', function(z) {
			if(input_fragment){
				var ref=(input_fragment+"\n").split("\n");
				input_fragment=ref.pop();
				for(var i=0;i<ref.length;i++){
					if(ref[i]=='')continue;
					T.push(ref[i]);
				}
			}
			main();
		});

		return function(){
			if(T.length<=cnt)return null;
			return T[cnt++];
		};
	})();
}else{
	//v8
	main();
}

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

int main()
{
	string s;
	vector<int> cnt(26);
	while (cin >> s) {
		for (char c : s) {
			if (c >= 'a' && c <= 'z') {
				cnt[c - 'a']++;
			}
			else if (c >= 'A' && c <= 'Z') {
				cnt[c - 'A']++;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << cnt[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 100100

string A[MAXN];
int mem[MAXN][26][26];
int offset[MAXN];

struct trie{
	trie* V[30];
	int n,num,v;

	trie(int i){
		n=i;
		for (int j=0;j<26;++j)V[j] = nullptr;
		num=0;v=0;
	}

	void insert(int ind){
		num += 1;
		if (SZ(A[ind]) == n){++v;return;}
		int t = A[ind][n] - 'a';
		if (V[t] == nullptr)V[t] = new trie(n+1);
		V[t]->insert(ind);
	}

	void compute(int ind){
		if (SZ(A[ind]) == n)return;
		offset[ind] += v;
		int t = A[ind][n] - 'a';
		for (int i=0;i<26;++i)if(i!=t){
			if (V[i] == nullptr)continue;
			mem[ind][t][i] += V[i]->num;
			// for (int k=0;k<V[i]->num;++k)cout<<(char)('a' + t)<<' '<<(char)('a' + i)<<'\n';
		}
		V[t]->compute(ind);
	}
}*root;

int N,Q,a;
string S;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N;
	for (int i=1;i<=N;++i)cin>>A[i];
	root = new trie(0);
	for (int i=1;i<=N;++i)root->insert(i);
	for (int i=1;i<=N;++i)root->compute(i);
	// root->compute(3);
	// for (int i=1;i<=N;++i)cout<<offset[i]<<' ';cout<<'\n';
	cin>>Q;
	while (Q--){
		cin>>a>>S;
		// for (int i=0;i<26;++i){
		// 	for (int j=0;j<26;++j)cout<<mem[a][i][j]<<' ';cout<<'\n';
		// }
		int ans =0 ;
		for (int i=0;i<26;++i){
			for (int j=i+1;j<26;++j){
				// You lose out mem[a][S[i]][S[j]] if i > j
				ans += mem[a][S[j] - 'a'][S[i] - 'a'];
			}
		}
		cout<<ans+offset[a]+1<<'\n';
		// return 0;
	}
}

Measured memory_bytes: 302208
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K;cin>>N>>K;
  double ans=0;
  for(int i=1;i<=N;i++){
    double a = 1.0/N;
    int j=i;
    while(j<K){
      j<<=1;
      a *= 1.0/2;
    }
    ans += a;
  }
  printf("%.10lf\n",ans);
  return 0;
}


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

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

    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (auto& a : A) std::cin >> a;

    std::vector<int> G;
    for (int i = 1; i <= N; i = 3 * i + 1) G.push_back(i);
    std::cout << G.size() << "\n";

    int cnt = 0;
    while (!G.empty()) {
        int g = G.back();
        G.pop_back();
        std::cout << g << " \n"[G.empty()];

        for (int i = g; i < N; ++i) {
            int v = A[i];
            int j = i - g;
            while (j >= 0 && A[j] > v) {
                // 大きい要素を後ろへずらす
                A[j + g] = A[j];
                j -= g;
                ++cnt;
            }
            A[j + g] = v;
        }
    }

    std::cout << cnt << "\n";
    for (auto a : A) {
        std::cout << a << "\n";
    }
    return 0;
}



Measured memory_bytes: 6636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<int> V(3);
    rep(i,3) cin >> V[i];
    sort(V.begin(),V.end());
    
    int ans = 0;
    
    while(V[1]!=V[2]){
        ans++;
        V[0]++;
        V[1]++;
    }
    while(V[0]<V[2]){
        ans++;
        V[0] += 2;
    }
    if(V[0]==V[2]) cout << ans << endl;
    else cout << ans + 1 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int b=1,c=0;
    string a;
    cin>>a;
    for(int i=0;i<4;i++){
        if(i){
            if(a[i]==a[i-1]) b++;
            if(b>=3) c++;
            if(a[i]!=a[i-1]) b=1;
        }
    }
    if(c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256