akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> dp(100010);
    dp[0] = 0;
    for (int i = 1; i <= 100000; i++)
    {
        dp[i] = 100000;
        int p6 = 1;
        while (p6 <= i)
        {
            dp[i] = min(dp[i], dp[i-p6] + 1);
            p6 *= 6;
        }
        int p9 = 1;
        while (p9 <= i)
        {
            dp[i] = min(dp[i], dp[i-p9] + 1);
            p9 *= 9;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/
 
const int maxn = 500010;
 
char s[maxn];
 
int p[maxn][26], n, w[maxn], q[maxn][20];
 
bool res[100010];
int main() {
  memset(p, -1, sizeof p);
  memset(q, -1, sizeof q);
  scanf("%s", s);
  n = strlen(s);
  for (int i = n - 1; i >= 0; i --) {
    int k = s[i] - 'a';
    int nxt = p[i][k] = i + 1;
    for (int j = k; j < 25; j ++) {
      if (p[nxt][j] >= 0) {
        p[i][j + 1] = nxt = p[nxt][j];
      } else break;
    }
    if (p[i][25] >= 0 && 
        p[p[i][25]][25] >= 0) {
      w[i] = p[p[i][25]][25];
      rep(j, k)
        p[i][j] = p[w[i]][j];
    } else w[i] = i;
  }
 
  w[n] = n;
  rep(i, n + 1) {
    q[i][0] = w[i];
  }
 
  drep(i, n + 1) {
    rep(j, 1, 20) {
      q[i][j] = q[q[i][j - 1]][j - 1];
    }
  }
 
  int Q; scanf("%d", &Q);
  rep(i, Q) {
    int l, r;
    scanf("%d %d", &l, &r);
    l --;
    //cout << l <<  ' ' << r << ' ' << q[l][0] << endl;
    drep(j, 20) {
      //assert(l >= 0);
      if (q[l][j] <= r) 
        l = q[l][j];
      //cout << l << ' ';
    }
    //cout << endl;
    if (l == r) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
 
  return 0;
}


Measured memory_bytes: 92928
#include<iostream>
#include<vector>
using namespace std;
vector<int>a[26];
int n,m;
string s[500];
vector<pair<int,int> >g[26];
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<s[i].size();j++)
		{
			if(s[i][j]>64)g[s[i][j]-65].push_back(make_pair(i,j));
		}
	}
	for(int i=0;i<26;i++)
	{
		if(g[i].size()==0)continue;
		int x1,x2,y1,y2;
		x1=g[i][0].first,y1=g[i][0].second,x2=g[i][1].first,y2=g[i][1].second;
		if(x1==x2)
		{
			if(y2-y1>1)
			{
				int x=0;
				for(int j=y1+1;j<y2;j++)if(s[x1][j]>64)x|=1<<s[x1][j]-65;
				a[i].push_back(x);
			}
		}
		else if(y1==y2)
		{
			if(x2-x1>1)
			{
				int x=0;
				for(int j=x1+1;j<x2;j++)if(s[j][y1]>64)x|=1<<s[j][y1]-65;
				a[i].push_back(x);
			}
		}
		else
		{
			int x=0,y=0;
			if(y1<y2)
			{
				for(int j=y1+1;j<=y2;j++)
				{
					if(s[x1][j]>64)x|=1<<s[x1][j]-65;
					if(s[x2][j-1]>64)y|=1<<s[x2][j-1]-65;
				}
			}
			else
			{
				for(int j=y2;j<y1;j++)
				{
					if(s[x1][j]>64)x|=1<<s[x1][j]-65;
					if(s[x2][j+1]>64)y|=1<<s[x2][j+1]-65;
				}
			}
			for(int j=x1+1;j<x2;j++)
			{
				if(s[j][y2]>64)x|=1<<s[j][y2]-65;
				if(s[j][y1]>64)y|=1<<s[j][y1]-65;
			}
			a[i].push_back(x);
			a[i].push_back(y);
		}
	}
	int cnt=0;
	for(int count=26;count--;)
	{
		for(int i=0;i<26;i++)
		{
			bool flag=0;
			for(int j=0;j<a[i].size();j++)flag|=!a[i][j];
			if(flag)
			{
				a[i].clear();
				cnt+=2;
				int x=~(1<<i);
				for(int j=0;j<26;j++)
				{
					for(int&e:a[j])e&=x;
				}
			}
		}
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"

signed main()
{
	int n,w;
	cin>>n>>w;
	pair <int,int> a[n+1];
	rep(i,n)
	{
		cin>>a[i+1].S>>a[i+1].F;
	}
	sort(a,a+n+1);
	int dp[n+1][(int)1e5+1];
	fill(dp[0],dp[0]+(int)1e5+1,1e9+5);
	rep(i,n+1) dp[i][0]=0;
	REP(i,1,n)
	{
		REP(j,1,(int)1e5)
		{
			if (j<a[i].F)
			dp[i][j]=dp[i-1][j];
			else
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-a[i].F]+a[i].S);
		}
	}
	// rep(i,n+1)
	// {
	// 	rep(j,20) cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }
	int ans=0;
	REPR(i,(int)1e5,0)
	{
		if (dp[n][i]<=w)
		{
			ans=i;
			break;
		}
	}
	cout<<ans;
   return 0;
}


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

int main() {
  ll n,k,nd,na;
  ll d[100],A[100],sum=0;
  cin>>n>>k;
  rep(i,n){
    A[i]=1;
  }
  rep(i,k){
    cin>>nd;
    rep(j,nd){
      cin>>na;
      if(A[na-1]==1) A[na-1]=0;
    }
  }
  rep(i,n){
    sum+=A[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include <iostream>

int main() {
    int a=0;
    while(true){
        int b=0;
        int c=0;
        std::cin>>a;
        if(a==0)
            break;
        for(int i=0;i<a;i++){
            int x,y;
            std::cin>>x>>y;
            if(x>y){
                b+=x+y;
            }else if(x<y){
                c+=x+y;
            }else if(x==y){
                b+=x;
                c+=y;
            }
        }
        std::cout<<b<<" "<<c<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

typedef long double lld;

using namespace std;

lld _abs(lld x) {
    if (x < 0) return -x;
	return x;
}

lld sqr(lld x) {
   return x * x;
}

lld det(const vector<vector<lld>> a) {
	
	return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
	       a[1][0] * (a[0][1] * a[2][2] - a[2][1] * a[0][2]) +
		   a[2][0] * (a[0][1] * a[1][2] - a[0][2] * a[1][1]);
}

pair<lld, lld> find(lld x1, lld y1, lld x2, lld y2, lld x3, lld y3) {
	lld len1 = sqr(x1) + sqr(y1);
	lld len2 = sqr(x2) + sqr(y2);
	lld len3 = sqr(x3) + sqr(y3);	
	vector<vector<lld>> a = { {len1, y1, 1} ,  {len2, y2, 1}, {len3, y3, 1} };
	vector<vector<lld>> b = { {x1, len1, 1} ,  {x2, len2, 1}, {x3, len3, 1} };
	vector<vector<lld>> c = { {x1, y1, 1} ,  {x2, y2, 1}, {x3, y3, 1} };
	lld sx = 0.5 * det(a);
    lld sy = 0.5 * det(b);
	lld A = det(c);
	if (_abs(A) < 1e-9) return {0, 0};
	sx /= A;
	sy /= A;
	if (_abs(sx) > 1000000 || _abs(sy) > 1000000) return {0, 0}; 
	return {sx, sy};
	
	
}	

int main() {
	ios_base::sync_with_stdio(0);

    int n;
	cin >> n;
	vector<long double> x(n);
    vector<long double> y(n);
	
	for (int i = 0; i < n; ++i) {
	    cin >> x[i] >> y[i];
	}
	
	long double ans = -1;
	for (int i = 0; i < n; ++i) {
	    for (int j = i + 1; j < n;  ++j) {
		    long double xr = (x[i] + x[j]) / 2;
			long double yr = (y[i] + y[j]) / 2;
			long double res = 0;
			for (int l = 0; l < n; ++l) {
			    res = max(res, sqr(xr - x[l]) + sqr(yr - y[l]));
			}
			if (ans < 0 || ans >= res) {
			    ans = res;
			}

			for (int k = j + 1; k < n; ++k) {
				auto p = find(x[i], y[i], x[j], y[j], x[k], y[k]);
				long double xr = p.first;
				long double yr = p.second;
				long double res = 0;
			
				for (int l = 0; l < n; ++l) {
					res = max(res, sqr(xr - x[l]) + sqr(yr - y[l]));
				}
				if (ans < 0 || ans >= res) {
					ans = res;
				}
				
				
			}
			
		}
	}
	cout.precision(15);
	cout << sqrt(ans) << endl;

    return 0;
}


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

int main(){
    string n,n2,n5;
    cin >> n;
    ll l;
    l=n.size();
    vector <int> ku(l,0);
    int n6,n7;
    int kk=0;

    rep(i,l){
        ku[i]=kk;
        //cout << kk << endl;
        if(i==0){
            n2=n[i];
            n6=atoi(n2.c_str());
            if(n6>=6){
                kk=1;
            }
        }
        else{
        n2=n[i];
        n6=atoi(n2.c_str());
        if(n6>=6){
            kk=1;
        }
        else if(n6==5 and kk==1){
            kk=1;
        }
        else{
            kk=0;
        }
        }
    }
    
    ll ans=0;
    int k=0;
    int n3,n4;
    rep(i,l){
        n2=n[l-i-1];
        if(i<l-1){
            n5=n[l-i-2];
        }
        n3=atoi(n2.c_str())+k;
        n4=atoi(n5.c_str());
        //cout << n3 << endl;
        if(n3>=6){
            ans+=10-n3;
            k=1;
        }
        else if(n3==5 and n4>=5 and i<l-1){
            ans+=5;
            k=1;
        }
        else{
            ans+=n3;
            k=0;
        }

        if(i==l-1){
            ans+=k;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 8168
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front

typedef long long ll;

using namespace std;

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

vector<vector<int>> edge;
vector<int> even,odd;

void dfs(ll now, ll par, ll d){
    if(d%2 == 0)even.PB(now);
    else odd.PB(now);
    for(auto nxt : edge[now]){
        if(nxt == par)continue;
        dfs(nxt, now, d+1);
    }
}

int main(){
    ll N;
    cin>>N;
    edge.resize(N);
    vector<queue<int>> rest(3);
    rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edge[a].PB(b);
        edge[b].PB(a);
    }
    dfs(0,-1,0);

    rep(i,1,N+1){
        rest[i%3].push(i);
    }

    vector<int> ans(N);
    if(even.size()>odd.size())swap(even,odd);

    if(even.size() <= N/3){
        for(auto i:even){
            ans[i] = rest[0].front();
            rest[0].pop();
        }
        for(auto j:odd){
            if(!rest[0].empty()){
                ans[j] = rest[0].front();
                rest[0].pop();
                continue;
            }
            if(!rest[1].empty()){
                ans[j] = rest[1].front();
                rest[1].pop();
                continue;
            }
            if(!rest[2].empty()){
                ans[j] = rest[2].front();
                rest[2].pop();
                continue;
            }
        }
    }


    else{
        for(auto i:even){
            if(!rest[1].empty()){
                ans[i] = rest[1].front();
                rest[1].pop();
                continue;
            }
            if(!rest[0].empty()){
                ans[i] = rest[0].front();
                rest[0].pop();
                continue;
            }
        }
        for(auto j:odd){
            if(!rest[0].empty()){
                ans[j] = rest[0].front();
                rest[0].pop();
                continue;
            }
            if(!rest[2].empty()){
                ans[j] = rest[2].front();
                rest[2].pop();
                continue;
            }
        }
    }

    
    rep(i,0,N){
        cout<<ans[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 20980
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int N = 100005;
  const int INF = 1e16;
  const double PI = acos(-1);

int32_t main()
{


    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++)
    {
      if(s[i] == '7')
      {
        cout << "Yes";
        return 0;
      }

    }

    cout << "No";
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <stack>
using namespace std;
const char memo[] = "abcdefghijklmnopqrstuvwxyz";
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n == 0) break;
    string str;
    cin >> str;
    stack< pair<int,int> > s;
    for(int i=0; i<n; i++){
      int a,b;
      cin >> a >> b;
      s.push( make_pair<int,int>(a,b) );
    }
    while(!s.empty()){
      pair<int,int> p = s.top(); s.pop();
      char c = str[p.second-1];
      str[p.second-1] = str[p.first-1];
      str[p.first-1] = c;
      int d = p.second - p.first;
      str[p.first-1] = memo[(str[p.first-1] - 'a' + d) % 26];
      str[p.second-1] = memo[(str[p.second-1] - 'a' + d) % 26];
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int time = sc.nextInt();
        int score1 = 0, score2 = 0;

        for(int i = 0; i < time; i++){
            String p1 = sc.next();
            String p2 = sc.next();

            if(p1.compareToIgnoreCase(p2) < 0)
                score2 += 3;
            else if(p1.compareToIgnoreCase(p2) == 0){
                score1++;
                score2++;
            }
            else
                score1 += 3;
        }

        System.out.println(score1 + " " + score2);

        sc.close();
    }
}



Measured memory_bytes: 29816
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;


int main()
{	
	ll H, W;
	scanf("%lld %lld", &H, &W);
	char masu[H][W];			//まず文字列を読み込む
	for(ll i=0;i<H;i++){
			scanf("%s", &masu[i]);
	
	}
	
	ll deep[H][W];
	ll tansakulist[H*W+10];
	ll start=0;
	ll ireru=0;
	ll answer=1;
	for(ll i=0;i<H;i++){
		for(ll j=0;j<W;j++){
			if(masu[i][j]=='#')
			{	
				deep[i][j]=0;
				tansakulist[ireru]=1001*i+j;
				ireru++;
			}
			else
			{
				deep[i][j]=1000009;
			}
		}
	}
	ll x;
	ll y;
	ll deepchange=ireru;
	
	while(ireru>start){
		
		x=tansakulist[start]/1001;
		y=tansakulist[start]%1001;
		//右
		if(x!=0)
		{
			if(deep[x-1][y]>answer)
			{
				deep[x-1][y]=answer;
				tansakulist[ireru]=1001*(x-1)+y;
				ireru++;
			}	
		}
		//左
		if(x!=H-1)
		{
			if(deep[x+1][y]>answer)
			{
				deep[x+1][y]=answer;
				tansakulist[ireru]=1001*(x+1)+y;
				ireru++;
			}	
		}
		//上
		if(y!=0)
		{
			if(deep[x][y-1]>answer)
			{
				deep[x][y-1]=answer;
				tansakulist[ireru]=1001*(x)+y-1;
				ireru++;
			}	
		}
		//下
		if(y!=W-1)
		{
			if(deep[x][y+1]>answer)
			{
				deep[x][y+1]=answer;
				tansakulist[ireru]=1001*(x)+y+1;
				ireru++;
			}	
		}
		start++;
		if(start==deepchange)
		{
			answer++;
			deepchange=ireru;
		}
		// answerを切り替えるタイミング
		// start
	}
	printf("%lld", answer-2);
	
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, K, ans = 0;
    cin >> N >> K;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(rALL(A));
    for (int i = K; i < N; i++){
        ans += A.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
m = int(input())
b = list(map(int, input().split()))
a = [-1 for i in range(m)]

for i in range(m//2+1,m+1):
        a[i-1] = b[i-1]

for i in range(m//2,m//3,-1):
    if b[i-1] == b[i*2-1]:
        a[i-1] = 0
    else:
        a[i-1] = 1



for i in range(m//3,0,-1):
#     print(i,a)
    suma = b[i*2-1]
    for ii in range(i*3-1,m,i*2):
        suma += a[ii]
#         print(ii,suma)
    if b[i-1] == suma%2:
        a[i-1] = 0
    else:
        a[i-1] = 1

print(a.count(1))
c= []
for i in range(m):
    if a[i] == 1:
        c.append(str(i+1))

print(' '.join(c))


Measured memory_bytes: 17204
#include<iostream>
 #include<cmath>
 #define LIMIT 50000
 using namespace std;
 int a, b , d, mx, my;
 
 void update( int x, int y, int &mx, int &my ){
     if ( y < 0 ) return;
     if ( x + y == mx + my && a*x + b*y < a*mx + b*my ){
         mx = x; my = y;
     } else if ( x + y < mx + my ){
         mx = x; my = y;
     }
 }

 main(){
     while( cin >> a >> b >> d, (a || b || d) ){
         mx = my = LIMIT;
         for ( int y, x = 0; x <= a + d; x++ ){
             if ( (a*x - d)%b == 0 ){
                 y = (a*x - d)/b; update( x, y, mx, my );
             }
             if ( (a*x + d)%b == 0 ){
                 y = (a*x + d)/b; update( x, y, mx, my );
             }
             if ( (d - a*x)%b == 0 ){
                 y = (d - a*x)/b; update( x, y, mx, my );
             }
         }
         cout << mx << " " << my << endl;
     }
 }

Measured memory_bytes: 868
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e6+10;
const int N=2e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

ll dp[66][2][2],L,R;
ll dfs(int x, bool Left, bool Right, bool keep) {
    if(x < 0) return 1;
    if( ~ dp[x][Left][Right] )
        return dp[x][Left][Right];
    ll ans = 0;
    int l = 0, r = 1;
    if(Left) l = L >> x & 1;
    if(Right) r = R >> x & 1;
    for(int i = l ; i <= 1 ; i++) {
        for (int j = i ; j <= r ; j++) {
            if (j == 1 && keep) {
                if(i == 1) ans += dfs(x-1, Left && i == l, Right && j == r, keep && j == 0);
            }
            else ans += dfs(x-1, Left && i == l, Right && j == r, keep && j == 0);
        }
    }
    ans %= mod;
    return dp[x][Left][Right] = ans;
}
int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    cin>>L>>R;
    mst(dp,-1);
    cout<<dfs(60,1,1,1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                                                  
#include <algorithm>                                                                                 
#include <vector>                                                                                    
#include <cmath>                                                                                     
#include <string>                                                                                    
#include <stdio.h>                                                                                   
#include <bits/stdc++.h>                                                                             
using namespace std;                                                                                 
                                                                                                     
int main()                                                                                           
{                                                                                                    
    int n, a;                                                                                        
    long long ans = 0;                                                                               
    cin >> n;                                                                                        
    map<int, int> cnt;                                                                               
    for(int i = 0; i < n; i++){                                                                      
        cin >> a;                                                                                    
        ans += cnt[i - a];                                                                           
        cnt[i + a]++;                                                                                
    }                                                                                                
    cout << ans << endl;                                                                             
                                                                                                     
    return 0;                                                                                        
} 

Measured memory_bytes: 20500
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d= static_cast<double>(a);
    b_d= static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2760
#include <stdio.h>

int main(void)
{

  int i;
  int x[10000];

  for (i = 0; i < 10000; i++) {
    scanf("%d", &x[i]);
    if (x[i] == 0) break;
  }

  for (i = 0; i < 10000; i++) {
    if (x[i] == 0) break;
    printf("Case %d: %d\n", i+1, x[i]);
  }

/*
  int i = 1;
  int x;

  while (1) {
    scanf("%d", &x);
    if (x == 0) {
      break;
    } else {
      printf("Case %d: %d\n", i, x);
      i++;
    }
  }
*/
  return 0;
}

Measured memory_bytes: 632
fun main(args: Array<String>) {
    var n= readLine()!!
    var k= readLine()!!.toInt()
    var tmp=0
    var size=n.length
    var dp=Array(2) {Array( size+1) {LongArray( k+1) {0} } }
    dp[1][0][0]=1L
    for(i in 1..size){
        dp[0][i][0]= 1L
        tmp=Character.getNumericValue(n[i-1])
        for(j in 1..k){
            if(tmp==0){
                dp[1][i][j]=dp[1][i-1][j]
                dp[0][i][j]=dp[0][i-1][j-1]*9+dp[0][i-1][j]
            }else{
                dp[1][i][j]=dp[1][i-1][j-1]
                dp[0][i][j]=dp[0][i-1][j-1]*9+dp[0][i-1][j]+dp[1][i-1][j-1]*(tmp-1)+dp[1][i-1][j]
            }
        }
    }
    println(dp[0][size][k]+dp[1][size][k])
}

Measured memory_bytes: 31776
#include <iostream>
    #include <cstdio>
    using namespace std;
    const int N=5e2+5;

    int n,m;
    int w,h;

    int tab[N][N];


    int main()
    {
        int i,j;
        int sum=0;

        cin>>n>>m>>h>>w;

        if(n%h==0 && m%w==0)
        {
            cout<<"No"<<endl;
            return 0;
        }

        for(i=1;i<=n;i++)
            for(j=1;j<=m;j++)
            {
                if(i%h==0 && j%w==0)
                    tab[i][j]=-(h*w-1)*4000-1;
                else
                    tab[i][j]=4000;

               // sum+=tab[i][j];
            }


     /*   if(sum<=0)
        {
            cout<<"No"<<endl;;
            return 0;
        }*/

        cout<<"Yes"<<endl;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
                printf("%d ",tab[i][j]);
            printf("\n");
        }


        return 0;
    }


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2*1e5;
const long long inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

vector<ll> adj[maxn];

void solve(){
	
	ll n,m;
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		ll a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	set<ll> s;
	for (int i=2;i<=n;i++) s.insert(i);
	queue<ll> q;
	q.push(1);
	
	vector<ll> ans(n+1, 0);
	
	while(!q.empty()){
		ll u=q.front();
		q.pop();
		for (auto v:adj[u]){
			if (s.find(v)!=s.end()){
				s.erase(s.find(v));
				q.push(v);
				ans[v]=u;
			}
		}
	}
	
	
		cout<<"Yes"<<endl;
		for (int i=2;i<=n;i++) cout<<ans[i]<<endl;
	
	
	
	
	
	return;
}

 
int main(){ 
    
    #ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	
	return 0;
	
}

Measured memory_bytes: 19796
#include<bits/stdc++.h>
using namespace std;
const long long md=998244353;
const int maxn=1e7+10;
long long fac[maxn],inv[maxn];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long C(int x,int y){
	return fac[x]*inv[y]%md*inv[x-y]%md;
}
int main(){
	int n;
	scanf("%d",&n);
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%md;
	inv[n]=powd(fac[n],md-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
	long long ans=powd(3,n);
	for(int i=n/2+1;i<=n;i++)
		ans=(ans-C(n,i)*powd(2,n-i)*2%md+md)%md;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 156544
from collections import defaultdict
from string import ascii_lowercase
from collections import Counter


def main():
    n = int(input())
    counter_list = [Counter(input()) for _ in range(n)]

    d = defaultdict(int)
    for a in ascii_lowercase:
        d[a] = 10 ** 10
    for a in ascii_lowercase:
        for c in counter_list:
            d[a] = min(d[a], c[a])

    print("".join([a * d[a] for a in ascii_lowercase]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using vl = vector<ll>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
vector<vector<pair<int, int>>> G;
void Dij(ll v, vl &dist) {
	dist[v] = 0;
	priority_queue<pl, vector<pl>, greater<pl>> que;
	que.emplace(0, v);
	while (que.size()) {
		ll d = que.top().first, v = que.top().second;
		que.pop();
		for (auto nv : G[v]) {
			if (dist[nv.first] > dist[v] + nv.second) {
				dist[nv.first] = dist[v] + nv.second;
				que.emplace(dist[nv.first], nv.first);
			}
		}
	}
}
int main() {
	int n, e, r;
	scanf("%d%d%d", &n, &e, &r);
	vl dist(n, INF);
	G = vector<vector<pair<int, int>>>(n, vector<pair<int, int>>());
	rep(i, e) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		// a--, b--;
		G[a].push_back({b, c});
		// G[b].push_back({a, c});
	}
	Dij(r, dist);
	for (int i = 0; i < n; i++) {
		if (dist[i] == INF)
			printf("INF\n");
		else
			printf("%lld\n", dist[i]);
	}
	return 0;
}


Measured memory_bytes: 14408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

bool Map[3][3];
int A[3][3];

void find(int v)
{
    for (size_t i=0; i<3; i++) {
        for (size_t j=0; j<3; j++) {
            if (v == A[i][j]) Map[i][j] = true;
        }
    }
}

int main()
{
    for (size_t i=0; i<3; i++) {
        for (size_t j=0; j<3; j++) {
            cin >> A[i][j];
            Map[i][j] = false;
        }
    }
    size_t N; cin >> N;
    for (size_t i=0; i<N; i++) {
        int b; cin >> b;
        find(b);
    }
//    bool check[3][3];
//    for (size_t i=0; i<3; i++) {
//        for (size_t j=0; j<3; j++) {
//            check[i][j] = Map[i][j];
//        }
//    }


    for (size_t i=0; i<3; i++) {
        bool judge = true;
        for (size_t j=0; j<3; j++) {
            if (Map[i][j] == false) {
                judge = false;
            }
        }
        if (judge == true) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (size_t j=0; j<3; j++) {
        bool judge = true;
        for (size_t i=0; i<3; i++) {
            if (Map[i][j] == false) {
                judge = false;
            }
        }
        if (judge == true) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    bool judge = true;
    for (int i=0; i<3; i++) {
        if (Map[i][i] == false) {
            judge = false;
        }
    }
    if (judge == true) {
        cout << "Yes" << endl;
        return 0;
    }

    judge = true;
    for (int i=0; i<3; i++) {
        int k = 2 - i;
        if (Map[i][k] == false) {
            judge = false;
        }
    }
    if (judge == true) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::iter::repeat;

struct SumSegTree {
    n: usize,
    nodes: Vec<(u64, u64)>,
}

impl SumSegTree {
    fn new(n: usize) -> SumSegTree {
        let n = 1 << f64::log2(n as f64).ceil() as usize;
        SumSegTree {
            n,
            nodes: repeat((0, 0)).take(2 * n - 1).collect(),
        }
    }

    fn add(&mut self, s: usize, t: usize, x: u64, ni: usize, l: usize, r: usize) {
        self.eval(ni);
        if r <= s || t <= l {
            return;
        }
        if s <= l && r <= t {
            self.nodes[ni].1 = (r - l) as u64 * x;
            self.eval(ni);
            return;
        }
        let m = (l + r) / 2;
        self.add(s, t, x, 2 * ni + 1, l, m);
        self.add(s, t, x, 2 * ni + 2, m, r);
        self.nodes[ni].0 = self.nodes[2 * ni + 1].0 + self.nodes[2 * ni + 2].0;
    }

    fn eval(&mut self, ni: usize) -> u64 {
        self.nodes[ni].0 += self.nodes[ni].1;
        if ni < self.n - 1 {
            self.nodes[2 * ni + 1].1 += self.nodes[ni].1 / 2;
            self.nodes[2 * ni + 2].1 += self.nodes[ni].1 / 2;
        }
        self.nodes[ni].1 = 0;
        self.nodes[ni].0
    }

    fn get_sum(&mut self, s: usize, t: usize, ni: usize, l: usize, r: usize) -> u64 {
        self.eval(ni);
        if s <= l && r <= t {
            self.nodes[ni].0
        } else if r <= s || t <= l {
            0
        } else {
            self.get_sum(s, t, 2 * ni + 1, l, (l + r) / 2)
                + self.get_sum(s, t, 2 * ni + 2, (l + r) / 2, r)
        }
    }
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let line0 = lines.next().unwrap().unwrap();
    let n = line0.split_whitespace().next().unwrap().parse().unwrap();

    let mut mst = SumSegTree::new(n);

    for l in lines.map(Result::unwrap) {
        let mut words = l.split_whitespace();
        let com = words.next().unwrap().parse().unwrap();
        let s: usize = words.next().unwrap().parse().unwrap();
        let t: usize = words.next().unwrap().parse().unwrap();
        let n = mst.n;
        match com {
            0 => {
                let x = words.next().unwrap().parse().unwrap();
                mst.add(s - 1, t, x, 0, 0, n);
            }
            1 => println!("{}", mst.get_sum(s - 1, t, 0, 0, n)),
            _ => (),
        }
    }
}



Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
int x[100];
int main()
{
    int n, m;

    scanf("%d%d", &n, &m);
    int a, b;
    for (int i = 1; i <= n; i++)
        x[i] = 10;
    for (int i = 1; i <= m; i++)
    {
        scanf("%d%d", &a, &b);
        if (a == 1 && b == 0 && n != 1)
        {
            printf("-1\n");
            return 0;
        }
        else if ((x[a] == 10 || x[a] == b))
        {
            x[a] = b;
        }
        else
        {
            printf("-1\n");
            return 0;
        }
    }
    if (n == 1)
    {
        printf("%d", x[1] % 10);
    }
    else
    {
        printf("%d", max(1, x[1] % 10));
    }
    for (int i = 2; i <= n; i++)
    {
        printf("%d", x[i] % 10);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [[0 for _ in range(k + 1)] for __ in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = 1

    for i in range(1, n + 1):
        for j in range(1, k + 1):
            if j - 1 - a[i - 1] >= 0:
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1 - a[i - 1]]
            else:
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
            dp[i][j] %= MOD

    print(dp[n][k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 223792
#include<iostream>
#include<vector>
#include<set>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

typedef unsigned long long ull;

class RollingHash {
private:
  const static ull base = 1111111121;
  string s;
  vector<ull> hash, pow;
  
public:
  RollingHash(string s) : s(s), hash(s.size() + 1, 0), pow(s.size() + 1, 1) {
    rep (j, s.size()) hash[j + 1] = hash[j] * base + s[j];
    rep (j, s.size()) pow[j + 1] = pow[j] * base;
  }

  // [x,y)のハッシュを求める
  ull get(int x, int y) {return hash[y] - hash[x] * pow[y - x];}
};

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  set<ull> st;
  RollingHash rh(s);
  int l = 0, r = 0;
  rep (i, m) {
    string q;
    cin >> q;
    if (q == "L++") ++l;
    if (q == "L--") --l;
    if (q == "R++") ++r;
    if (q == "R--") --r;
    st.insert(rh.get(l, r + 1));
  }
  cout << st.size() << endl;
}

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

int x[100010], l[100010];

int main(void){
	int n, m, ans=0;
	cin >> n >> m;
	if(n>=m){
		cout << 0 << endl;
		return 0;
	}
	for(int i=0; i<m; i++) cin >> x[i];
	sort(x, x+m);
	for(int i=0; i<m-1; i++){
		l[i] = x[i+1]-x[i];
		ans += l[i];
	}
	sort(l, l+m-1);
	for(int i=0; i<n; i++) ans -= l[m-i-1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int> int in() {
  T x;
  cin >> x;
  return x;
}
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CGacha {
  public : static void solve(std::istream & cin, std::ostream &cout){
      int N;
      cin>>N;
      unordered_map<string, bool> check;
      int ans = 0;
      rep(i, N){
        string temp;
        cin>>temp;
        if (!check[temp]){
          ans += 1;
          check[temp] = true;
        }
      }
      cout<<ans<<endl;
  }
};


signed main() {
  CGacha solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 17612
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void) {
    int n;
    cin >> n;

    bool carry = 0, inv = n < 0;
    vector<bool> result;
    while (n) {
        result.push_back(n%2);
        n /= 2;
    } 

    result.push_back(0);
    result.push_back(0);
    rep(i, result.size()) {
        bool r = result[i];
        // cout << r << carry << inv << endl;
        r ^= carry;
        carry &= result[i];
        carry ^= (r&inv);
        result[i] = r;
        inv ^= 1;
    }

    int i = result.size()-1;
    while (i > 0 and result[i] == 0) i--;
    for (; i >= 0; i--) {
        cout << result[i];
    }
    cout << endl;

}


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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  int sumA = 0;
  int sumB = 0;
  
  for(int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  for(int i = 0; i < N; i++) {
    if((i + 1) % 2 > 0) {
      sumA += card.at(i);
    }
    else {
      sumB += card.at(i);
    }
  }
  cout << sumA - sumB << endl;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int gcd(int a, int b) {
    while (1) {
        if (a < b)swap(a, b);
        if (!b)break;
        a %= b;
    }
    return a;
}

int main() {
    int N, X;
    cin >> N >> X;
    vector<int>x;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        x.push_back(abs(X - a));
    }

    int ans = x[0];
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, x[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
use std::collections::*;
// use std::io::prelude;
use std::io;
use std::io::Read;
use std::cmp::*;

fn main(){
    let t_cases = 1;
    for _ in 0..t_cases{
        solve();
    }
}

fn solve(){
    // let MOD = 10i32.pow(9)+7;
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().to_owned().parse::<usize>().unwrap();
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<f64>().unwrap())
                .collect::<Vec<_>>();
    let mut dp = vec![vec![0f64;n+1];n+1];
    dp[0][0] = 1.0;
    for i in 1..(n+1){
        dp[i][0] = dp[i-1][0] * (1.0-a[i-1]);
        for j in 1..(i+1){
            dp[i][j]+=dp[i-1][j]*(1.0-a[i-1])+dp[i-1][j-1]*a[i-1];
        }
    }
    let mut res = 0.0f64;
    for i in (n/2+1)..(n+1){
        res+=dp[n][i];
    }
    println!("{}",res);
}

Measured memory_bytes: 90364
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int count = 0;
		
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i=0;i<n;) {
			if(a[i] % 2 == 1) {
				count++;
			}
			i += 2;
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 35904
using static System.Console;
using static System.Math;
public static class Program
{
  public static void Main()
  {
    var n = long.Parse(ReadLine());
    int t;
    long count = 0;
    for (t = 1; ; ++t)
    {
      if (n <= count + (long)Pow(26, t)) break;
      count += (long)Pow(26, t);
    }
    n -= count;
    long temp = n;
    string ans = "";
    for (int i = t - 1; 0 <= i; --i)
    {
      var temp1 = temp;
      var c = 0;
      while(temp1 > 0)
      {
        temp1 -= (long)Pow(26, i);
        c++;
      }
      temp -= (c-1) * (long)Pow(26, i);
      if(i == 0) ans += (char)('a' + c - 1);
      else ans += (char)('a' + c - 1);
    }
    WriteLine(ans);
  }
}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define fs first
#define sc second

const int nmax = 1e5;
int t = 1;
int n;
string s;
int ans = 1;

void INPUT()
{
     cin >> n;
     cin >> s;
}

void INIT()
{

}

void SOLVE()
{
     for(int i = 1; i < n; i++) {
          if(s[i] != s[i - 1]) ans++;
     }
     cout << ans;
}

int main()
{
    //freopen("test.inp","r",stdin);
    INPUT();
    INIT();
    while (t--) SOLVE();
    return 0;
}


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

int setGcd(int a, int b) {
    int gcd;
    
    if(a == 0 || b == 0) return 0;
    
    while(a != b) {
        if(a > b) a -= b;
        else b -= a;
    }
    gcd = a;
    return gcd;
}

int setLcm(int a, int b) {
    int lcm;
    
    if(a == 0 || b == 0) return 0;
    lcm = a / setGcd(a,b) * b;
    
    return lcm;
}

int main() {
    int a,b;
    int gcd,lcm;
    while (cin >> a >> b) {
        gcd = setGcd(a,b);
        lcm = setLcm(a,b);
        cout << gcd << " " << lcm << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        }
        else if(i/10==3){
            printf(" %d",i);
        }
        else if(i/100==3){
            printf(" %d",i);
        }
        else if(i/10%10==3){
            printf(" %d",i);
        }
        else if(i/100%10==3){
            printf(" %d",i);
        }
        else if(i/1000%10==3){
            printf(" %d",i);
        }
        else if(i%10==3){
            printf(" %d",i);
        }
    }
    printf("\n");
    return 0;
}

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

int main(){
    int w, h, n;
    cin >> w >> h >> n;

    pair<int, int> a = make_pair(0, 0);
    pair<int, int> b = make_pair(w, h);
    int x, y, cond;
    for (auto i = 0; i < n; i++) {
        cin >> x >> y >> cond;
        switch (cond) {
            case 1:
                a.first = max(x, a.first);
                break;
            case 2:
                b.first = min(x, b.first);
                break;
            case 3:
                a.second = max(y, a.second);
                break;
            case 4:
                b.second = min(y, b.second);
                break;
            default: ;
        }
    }

    if(a >= b) {
        cout << 0 << endl;
        return 0;
    }

    cout << (b.first - a.first) * (b.second - a.second) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int h,w,k,z,ans=1e9,c[15];
string a[15];
bool f(int j){
	int id=0,fl=0;
	for(int i=0;i<h;i++){
		c[id]+=a[i][j]=='1';
		if(c[id]>k)fl=1;
		if(z>>i&1)id++;
	}
	return fl;
}
int main(){
	int i,j,cnt,re;
	cin>>h>>w>>k;
	for(i=0;i<h;i++)cin>>a[i];
	for(z=0;z<1<<h-1;z++){
		memset(c,0,sizeof(c));
		cnt=__builtin_popcount(z);
		re=0;
		for(j=0;j<w;j++){
			if(f(j)){
				cnt++;
				memset(c,0,sizeof(c));
				re=f(j);
			}
		}
		if(!re)ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007

def solve(N: int, A: "List[int]"):
    from collections import defaultdict
    M = N // 2
    def get_range(idx):
        r = (N - idx) // 2 + 1        
        return range(max(0, M-r), idx//2+1+1)
    
    dp_a = defaultdict(lambda:-float('inf'))
    dp_s = defaultdict(lambda:-float('inf'))
    dp_s[(0, -1)] = 0 
    for i in range(N):
        for j in get_range(i):
            dp_s[(j, i)] = max(dp_s[(j, i)], dp_a[(j, i-1)], dp_s[(j, i-1)])
            dp_a[(j, i)] = max(dp_a[(j, i)], dp_s[(j, i)], dp_s[(j-1, i-1)]+A[i])
    print(max(max(v for (j, i), v in dp_a.items() if j == M),
              max(v for (j, i), v in dp_s.items() if j == M)))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 305244