akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
bool ldp[5005][5005], rdp[5005][5005];
int n, k;
int a[5005];

// 二分探索判定条件 O(k^2)
bool C(int id){
    for(int i = 0; i < k; ++i){
        for(int j = 0; j < k; ++j){
            if((ldp[id][i]&rdp[id + 1][j]) && ((i+j)>=k-a[id]&&(i+j)<k)){
                return true;
            }
        }
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    if(n == 1){
        cout << (a[0] < k) << endl;
        return 0;
    }
    
    sort(a, a + n);
    
    ldp[0][0] = true;
    rdp[n][0] = true;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < k; ++j){
            if(j - a[i] >= 0){
                ldp[i + 1][j] |= ldp[i][j] | ldp[i][j - a[i]];
            }
            else{
                ldp[i + 1][j] |= ldp[i][j];
            }
        }
    }
    for(int i = n - 1; i >= 0; --i){
        for(int j = 0; j < k; ++j){
            if(j - a[i] >= 0){
                rdp[i][j] |= rdp[i + 1][j] | rdp[i + 1][j - a[i]];
            }
            else{
                rdp[i][j] |= rdp[i + 1][j];
            }
        }
    }
    
    int lb = -1, ub = n;
    while(ub - lb > 1){     // 二分探索 O(logn)
        int mid = (lb + ub) / 2;
        if(C(mid))  ub = mid;
        else        lb = mid;
    }
    
    cout << ub << endl;
}

Measured memory_bytes: 49152
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}


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

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#define int long long
main()
{
  int N = 0;
  scanf("%lld",&N);

  int A[N];
  int i = 0;
  for(i = 0; i < N ; i++)
  {
	  scanf("%lld", &A[i]);
  }
  int CntPair = 0;

  for(i = 0; i < N ; i++)
  {
	 CntPair += A[i]/2;
	 if(i==N-1)break;
	 if(A[i]%2 == 1 && A[i+1]>0)
	 {
		 CntPair++;
		 A[i+1]--;
	 }
  }
  printf("%lld\n",CntPair);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include <typeinfo>
#include <stdlib.h>
#define ll long long
const int MOD = 1000000007;
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a.length() > b.length()) {
		cout << "GREATER" << endl;
	} else if (a.length() < b.length()) {
		cout << "LESS" << endl;
	} else {
		for (int i = 0;; i++) {
			if (a[i] - 48 > b[i] - 48) {
				cout << "GREATER" << endl;
				break;
			}
			if (a[i] - 48 < b[i] - 48) {
				cout << "LESS" << endl;
				break;
			}
			if (i == a.length() - 1) {
				cout << "EQUAL" << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
//using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
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 ll INF=10000000000000000;

int N;
int F[105][5][2];
ll P[105][11];
ll ans=-INF;

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<2;k++) cin>>F[i][j][k];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<=10;j++) cin>>P[i][j];
    }
    for(int i=1;i<(1<<10);i++){
        ll cnt=0;
        for(int j=0;j<N;j++){
            int sum=0;
            for(int k=0;k<10;k++){
                if(i>>k&1){
                    int u=k/2,v;
                    if(k%2==0){
                        v=0;
                    }else{
                        v=1;
                    }
                    if(F[j][u][v]==1) sum++;
                }
            }
            cnt+=P[j][sum];
        }
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}

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

using i64 = long long;

struct Edge{
    int from, to;
};

int indegree[100005]={0}, parent[100005]={0};

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<Edge>> graph(n+1);
    for(int i=0;i<n-1+m;++i){
        int a, b;
        cin >> a >> b;
        indegree[b]++;
        graph[a].push_back((Edge){a, b});
    }

    int root = 0;
    for(int i=1;i<=n;++i){
        if(indegree[i] == 0){
            root = i;
            break;
        }
    }

    queue<Edge> que;
    que.push((Edge){0,root});
    while(!que.empty()){
        Edge curr = que.front(); que.pop();
        for(auto e: graph[curr.to]){
            int next = e.to;
            indegree[next]--;
            if(indegree[next] == 0){
                parent[next] = e.from;
                que.push(e);
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define f first
#define s second
#define INF 1e9
using namespace std;
typedef pair <double,int> P;
vector <P> G[10001];

int used[10001];
double prim(int start){
  double res=0;
  priority_queue <P> Q;
  Q.push(P(0,start));
  while(!Q.empty()){
    P t=Q.top();Q.pop();
    double cost=t.f;
    int pos=t.s;
    if(used[pos])continue;
    used[pos]=1;
    res+=cost;
    for(int i=0;i<G[pos].size();i++)Q.push(P(G[pos][i]));
    }
  return res;
}

int main(){
  int n,m;
  cin>>n>>m;
  complex <double>  p[10001];
  for(int i=0,a,b;i<n;i++)cin>>a>>b,p[i].real()=a,p[i].imag()=b;

  double sum=0;
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    a--,b--;
    G[a].push_back(P(abs(p[a]-p[b]),b));
    G[b].push_back(P(abs(p[a]-p[b]),a));
    sum+=abs(p[a]-p[b]);
  }

  double ans=0;
  for(int i=0;i<n;i++) if(!used[i]) ans+=prim(i);
  printf("%f\n",sum-ans);
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
char s[100009];
long long a[100009];
long long mod=1000000007;
int main()
{

	scanf("%s",s);
	int i,len=strlen(s);
	long long ans,t;
	a[0]=1;
	for (i=1;i<100009;i++)
	{
		a[i]=a[i-1]*3;
		a[i]%=mod;
	}
	ans=0;
	t=1;
	for (i=0;i<len;i++)
	{
		if (s[i]==49)
		{
			ans+=t*a[len-i-1];
			ans%=mod;
			t*=2;
			t%=mod;
		}
	}
	ans+=t;
	ans%=mod;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int plus = a + b;
            int minus = a - b;
            int multi = a * b;
            System.out.println(Math.max(plus, Math.max(minus, multi))); 
          }
}

Measured memory_bytes: 22612
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def calcMod(a, m):
  return sum([m % v for v in a])


def mul(a, b):
  return a*b


#print(calcMod(a, reduce(mul, a)-1))
print(sum(a)-n)


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


int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0; i<n; i++){
    cin >> v.at(i);
  }  

  sort(v.begin(), v.end());

  double dp=0;

  for(int i=0; i<n-1; i++){
    dp = (v.at(i)+v.at(i+1))/2;
    v.at(i+1) = dp;
  }

  cout <<  fixed << setprecision(10) << dp << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int x;
    cin >> x;
    if (x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;

    return 0;
}

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

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double v = a*a*b;
    double rad;
    if(2*x < v){
        rad = atan(a*b*b/2/x);
    }else if(2*x == v){
        rad = M_PI / 4;
    }else{
        rad = atan(2*(v-x)/a/a/a);
    }
    double ans = rad/2/M_PI*360;
    cout << fixed << setprecision(10) << ans; 
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ma = 0;
  int num = 0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='I') num++;
    else num--;
    ma = max(ma,num);
  }
  cout << ma << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

ll D,G;
ll p[10];
ll c[10];

int main ()
{
    cin >> D >> G;
    REP(i,D) cin >> p[i] >> c[i];

    ll ans = 1e18;
    REP(i,(1 << D)) {
        ll sumG = 0;
        ll sump = 0;
        ll left_p[10];
        REP(j,D) left_p[j] = p[j];
        REP(j,D) {
            if ((i >> j) & 1) {
                sumG += 100LL * (j + 1LL) * p[j] + c[j];
                sump += p[j];
                left_p[j] = 0;
            }
        }
        vector < ll > lt;
        REP(j,D) REP(k,left_p[j]) lt.push_back(100LL * (j + 1LL));
        sort(lt.begin(), lt.end());
        reverse(lt.begin(), lt.end());
        int cnt = 0;
        while (sumG < G) {
            sumG += lt[cnt];
            ll idx = (lt[cnt] / 100LL) - 1LL;
            left_p[idx]--;
            if (left_p[idx] == 0) sumG += c[idx];
            cnt++;
            sump++;
        }
        ans = min(ans, sump);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  AGC023 ProblemF 01 on Tree
//
//  Created by 范泽玥 on 2018/6/30.
//  Copyright © 2018年 范泽玥. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
int n;
int p[200005],v[200005];
long long c1[200005],c0[200005];
int fa[200005];
struct Node{
    long long c0,c1;
    int id;
};
bool operator <(const Node &X,const Node &Y){
    return X.c1*Y.c0<X.c0*Y.c1 ||(X.c1*Y.c0==X.c0*Y.c1 && X.id<Y.id);
}
int getfather(int x){
    if (fa[x]==x){
        return x;
    }
    else{
        return fa[x]=getfather(fa[x]);
    }
}
long long ans;
set<Node>s;
int main() {
    cin>>n;
    for (int i=2;i<=n;i++){
        cin>>p[i];
    }
    for (int i=1;i<=n;i++){
        cin>>v[i];
        if (v[i]==1){
            c1[i]=1;
            c0[i]=0;
        }
        else{
            c1[i]=0;
            c0[i]=1;
        }
        fa[i]=i;
    }
    for (int i=2;i<=n;i++){
        s.insert({c0[i],c1[i],i});
    }
    while (s.size()){
       // cout<<"?"<<endl;
        Node u=*s.begin();
        s.erase(s.begin());
        int x=u.id;
        int y=fa[x]=getfather(p[x]);
        ans+=(long long)c1[y]*(long long)c0[x];
        if (y!=1){
            s.erase({c0[y],c1[y],y});
        }
        c0[y]+=c0[x];
        c1[y]+=c1[x];
        if (y!=1){
            s.insert({c0[y],c1[y],y});
        }
//        cout<<x<<" "<<y<<endl;
    }
    cout<<ans;
    return 0;
}


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

long long dp[1000005];

const long long MOD = 1e9+7;

int main(){
    int N, H, D;
    scanf("%d%d%d", &N, &H, &D);

    long long retainWays = 0;
    long long fact = 1;
    for(int i = 1; i <= N; i ++){
        fact = fact*i%MOD;
        retainWays += fact;
    }
    retainWays %= MOD;

    //printf("retainWays=%lld\n", retainWays);

    dp[0] = fact;
    long long slidingWindowSum = dp[0];
    for(int i = 1; i <= H; i ++){
        dp[i] = slidingWindowSum;

        dp[i] %= MOD;

        if(i == H){break;}

        dp[i] = dp[i]*retainWays%MOD;
        slidingWindowSum += dp[i];
        if(i >= D){slidingWindowSum -= dp[i-D];}

        slidingWindowSum = (slidingWindowSum+MOD);
        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }

    printf("%lld", dp[H]);
    return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int mon=sc.nextInt();
		int taim=sc.nextInt();
		int mon2=sc.nextInt();
		
		if(mon*taim<mon2) {
			System.out.println(mon*taim);
		}else {
			System.out.println(mon2);
		}
	}
}



Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val dp = IntArray(n + 1)
    for (i in 1..n) {
        var s = Int.MAX_VALUE
        var j = 1
        while (j <= i) {
            s = Math.min(s, dp[i - j] + 1)
            j *= 6
        }
        j = 1
        while (j <= i) {
            s = Math.min(s, dp[i - j] + 1)
            j *= 9
        }
        dp[i] = s
    }
    println(dp[n])
}


Measured memory_bytes: 33608
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll cost[2010];
ll res[2010]; 
int main()
{
	ll n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&cost[i]);
		res[i]=cost[i];
	}
	ll ans=inf;
	for(int k=0;k<n;k++)//xiugai k ci
	{
		ll temp=0;
		for(int i=1;i<=n;i++)//mei ge slime
		{
			ll low;
			if(i<=k)
			{
				low=min(res[i],cost[n-(k-i)]);
			}
			else
			{
				low=min(res[i],cost[i-k]);
			}
			res[i]=low;
			temp+=low;
		}
		temp+=k*x;
		ans=min(ans,temp);
	}
	printf("%lld",ans);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> sum;
    ll sum_tmp = 0;
    sum.pb(sum_tmp);
    rep(i,n){
        ll a;
        cin >> a;
        sum_tmp = (sum_tmp + a)%m;
        sum.pb(sum_tmp);
    }
    sort(sum.begin(),sum.end());
    vector<pair<ll,ll>> summary;
    rep(i,n+1){
        if(i >= 1 && sum[i]==sum[i-1]){
            summary[summary.size()-1].second++;
        }
        else{
            summary.pb(make_pair(sum[i],1));
        }
    }
    ll summary_len = summary.size();
    ll ans = 0;
    rep(i,summary_len){
        ans += ((summary[i].second)*(summary[i].second-1))/2;
    }
    cout << ans;
}


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

using namespace std;

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

	int n;
	cin >> n;
	set<vector<int>> s;
	for( int i = 0; i < n; i++ )
	{
		int p[3];
		cin >> p[0] >> p[1] >> p[2];
		sort(p, p + 3);
		s.insert(vector<int>{ p[0], p[1], p[2] });
	}
	cout << n - s.size() << endl;

	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int l = S.size(), d = 0, x = 0;
    for(int i=0;i<l;i++){
        // d : '('の個数 – ')' の個数
        if(S[i] == '(')
            d++;
        else{
            d--;
            // x = min(d0, d1, ..., dn)
            if(d < x)
                x = d;
        }
    }

    // x = 0
    x = -x;
    for(int i=0;i<x;i++)
        cout << '(';
    cout << S;
    // d|s| = 0 
    for(int i=0;i<d+x;i++)
        cout << ')';
    cout << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')

int N,A;

int main()
{
	scanf("%d",&N);
	int c1=0,c2=0,c4=0;
	rep(i,N)
	{
		scanf("%d",&A);
		if(A%2==1)c1++;
		else if(A%4==2)c2++;
		else c4++;
	}
	if(c1-(c1+c4==N)<=c4)puts("Yes");
	else puts("No");
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, m, k;
	cin >> n >> m >> k;

	vector<ll> a(n+1, 0), b(m+1, 0);

	for(ll i=1; i<=n; i++){
        cin >> a[i];
        a[i]+=a[i-1];
	}

	for(ll j=1; j<=m; j++){
        cin >> b[j];
        b[j]+=b[j-1];
	}

	ll i=0, ans=0;
	while(i<=n){
        if(a[i]>k)
            break;
        ll j=lower_bound(b.begin(), b.end(), k-a[i])-b.begin();
        if(j>m || b[j]>k-a[i])
            j--;
        ans=max(ans, i+j);
        i++;
	}
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6380
#include<iostream>
#include<cmath>

using namespace std;


int main(){
	int N;double D;
	double x,y,distance;
	int i;
	int count=0;

	cin >> N >> D;
	for(i=0;i<N;i++){
		cin >> x >> y;
		x = pow(x,2);
		y = pow(y,2);
		distance = pow(x+y,0.5);
		if(distance <= D){
			count++;
		}
	}

	cout << count;

	return 0;
}

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

int main()
{
  ll n, k;cin>>n>>k;
  // map<int, int> a;
  int a[n+1];
  rep(i, n+1) {
    a[i] = 300000;
  }

  int type_num = 0;
  for(int i=1; i < n+1; i++){
    int tmp; cin>>tmp;
    if (a[tmp] == 300000) {
      type_num ++;
      a[tmp] = 1;
    } else {
      a[tmp] ++;
      // cout << "a[" << tmp << "]: " << a[tmp] << endl;
    }
  }

  // cout << "type_num: " << type_num << endl;
  // cout << a[0] << endl;
  // sort(begin(a), end(a));
  sort(a, a+n+1);
  // cout << a[1] << endl;

  int ans = 0;
  rep(i, type_num-k) {
    ans += a[i];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
import string
import sys
english = sys.stdin.read()
table = [0] * 26
index = 0
for s in string.ascii_lowercase:
    for t in english:
        if s == t or s.upper() == t:
            table[index] += 1
    index += 1

index = 0
for s in string.ascii_lowercase:
    print("%s : %d"%(s, table[index]))
    index += 1


Measured memory_bytes: 6676
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 1000

int main(void) {
  cin >> n;

  cout << n / 3 << endl;

  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500 * i + 100 * j + 50 * k == X:
        
        count += 1
        
print(count)

Measured memory_bytes: 9104
#include <stdio.h>
#include <math.h>
#define N_MAX 999999
 
int main(void){
    /* eratosthenes */
    char a[N_MAX+1];
    int i, j,n;
    a[0]=0, a[1]=0;
    n=(int)sqrt(N_MAX);
    
    for(i=2; i<=N_MAX; i++)
      a[i]=1;
    
    for(i=2; i<=n; i++){
      if(a[i]!=0){
	  for(j=2*i; j<=N_MAX; j+=i)
	    a[j]=0;
      }
    }
    
    while(scanf("%d",&i)==1){
      int sum=0;
      for(;i>=1;i--) sum+=a[i];
      printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1572
#include <stdio.h>


// YYMM 00 ~ 99 && 01 ~ 12
// MMYY 01 ~ 12 && 00 ~ 99
int main(void) {
    int a,b,c,d,s,no1,no2;
    a = b = c = d = no1 = no2 = 0;
    scanf("%d",&s);
    a = s % 10;
    s = s / 10;
    b = s % 10;
    s = s / 10;
    c = s % 10;
    s = s / 10;
    d = s % 10;
    no1 = d * 10 + c;
    no2 = b * 10 + a;
    if ((no1 > 12 && no2 > 12) || (no1 == 0 && no2 == 0) || (no1 == 0 && no2 > 12) || (no2 == 0 && no1 > 12)){
        printf("NA");
    }else if ((no1 == 0 && no2 != 0)|| (no1 > 12 && no2 != 0)){
        printf("YYMM");
    }else if ((no2 == 0 && no1 != 0)|| (no2 > 12 && no1 != 0 )){
        printf("MMYY");
    }else{
        printf("AMBIGUOUS");
    }
return 0;
}

Measured memory_bytes: 128
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

a, b = map(int, input().split())

if a == b:
    print('0')
elif (a + b)%2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 5344
while True:
    h, w = list(map(int, input().split()))
    if h == 0 and w == 0:
        break
    
    for i in range(h):
        if i == 0 or i + 1 == h:
            print("#" * w)
        else:
            print(f'#{"." * (w - 2)}#')
    print()


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

 using namespace std;

 int main() {
   int i, j, k, K, S, ans;
   cin >> K >> S;

   ans = 0;
   for (i = 0; i <= K; i++) {
     for (j = 0; j <= K; j++) {
       if (S - i - j >= 0 && S - i - j <= K) ans++;
     }
   }

   cout << ans << endl;

 }


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	for (auto &i : a) cin >> i;
	int xe = 0;
	for (int i = 0; i < n; ++i){
	xe ^= a[i];
	}
	for (int i = 0; i < n; ++i){
	cout << (xe ^ a[i]) << " ";
	}
	cout << "\n";	
	return 0;
}


Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {   
    long long int n, p;
    cin >> n >> p;
    unordered_map<long long int, int> um;
    for (long long int i = 2; i * i <= p; i++) {
        while (p % i == 0) {
            um[i]++;
            p /= i;
        }
    }
    if (p > 1) {
        um[p]++;
    }
    long long int res = 1;
    for (auto pp : um) {
        res *= pow(pp.first, pp.second / n);
    }
    cout << res << endl;
}




Measured memory_bytes: 4072
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 a[200000];

void solve() {
    indef(i32, n);
    times(n, ai) {
        in(a[ai]);
    }
    vec<i32> b;
    for (i32 ai = n-1; ai >= -1; ai-=2) {
        if (ai == -1)  {
            ai = 0;
        }
        b.append(a[ai]);
        if (ai == 0) {
            break;
        }
    }
    if (odd(n)) {
        for (i32 ai = 1; ai <= n-2; ai+=2) {
            b.append(a[ai]);
        }
    }
    else {
        for (i32 ai = 2; ai <= n-2; ai+=2) {
            b.append(a[ai]);
        }
    }
    times(b.size()-1, bi) {
        cout << b[bi] << " ";
    } cout << b[b.size()-1] << endl;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    cout << fixed << setprecision(9);
    solve();

    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

ll oddsolve(ll a){
    return (a+1)/2%2;
}
ll solve(ll a){
    if(a%2==1) return oddsolve(a);
    else return oddsolve(a+1)^(a+1);
}

int main(void) {
    ll A,B;
    cin>>A>>B;
    cout<<(solve(B)^solve(A-1))<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

int solve() {
    if (s == "RRR") return 3;
    if (s == "RRS" || s == "SRR") return 2;
    if (s == "SSS") return 0;
    return 1;
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

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

#define MAX_N 45
vector<int> v(MAX_N,-1);

int fibo(int n){
	if(v[n]<0){
		v[n]=fibo(n-1)+fibo(n-2);
	}
	return v[n];
}


int main(){
	int n;
	cin>>n;
	v[0]=1;
	v[1]=1;
	cout<<fibo(n)<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
using namespace std;

int M,N;
char s[135][15];
map < pair< vector<int>,int > ,int> MAP;

int flere(vector <int> list,int level,int used){
	int i,j,k=M;
	if(MAP.find(make_pair(list,used))!=MAP.end())
		return MAP[make_pair(list,used)];
	if(list.size()==1)
		return level;
	for(i=0;i<M;i++){
		if(used & (1<<i))
			continue;
		vector <int> a,b;
		for(j=0;j<list.size();j++){
			if(s[list[j]][i]=='0')
				a.push_back(list[j]);
			else
				b.push_back(list[j]);
		}
		if(a.size()==0 || b.size()==0)
			continue;
		k = min(k,max(flere(a,level+1,used|(1<<i)),flere(b,level+1,used|(1<<i))));
	}
	return MAP[make_pair(list,used)] = k;
}

main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	int n,m,i,j;
	while(~scanf(" %d %d",&M,&N) && (M+N)){
		gets(s[0]);
		for(n=0;n<N;n++)
			gets(s[n]);
		vector <int> list;
		MAP.clear();
		for(n=0;n<N;n++)
			list.push_back(n);
		printf("%d\n",flere(list,0,0));
	}

}

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

const int N = 1e5;
vector<vector<int>> g(N);
using Value = int;
map<int, int> allBlack[N];
map<int, int> deg[N];
map<int, Value> dp[N][2];
map<int, Value> dp2[N][2];
using P = pair<Value, int>;
vector<P> mi0(N, P(0, -1)), mi1(N, P(0, -1));
int calced[N];
int n;
string col;
Value dfs(int i, int back, int p, int f) {
  if(dp[i][back].count(p)) return dp[i][back][p];
  int cnt = 0;
  Value res = 0;
  int now = 'W' == col[i];
  now ^= p != -1;
  allBlack[i][p] = 'B' == col[i];
  if(f || p == -1) {
    // O(deg(i))
    // go only child
    P mi(0, -1);
    for(int j : g[i]) if(j != p) {
      dfs(j, 1, i, f);
    }
    for(int j : g[i]) if(j != p) if(!allBlack[j][i]) {
      int d = 2 + dfs(j, 1, i, f);
      cnt++;
      now ^= 1;
      res += d;
      P m(- d + (1 + dfs(j, 0, i, f)), j);
      mi = min(mi, m);
      if(!calced[i] && p == -1) {
        if(mi0[i] > m) mi1[i] = mi0[i], mi0[i] = m;
        else if(mi1[i] > m) mi1[i] = m;
      }
    }
    deg[i][p] = cnt;
    if(p == -1) calced[i] = 1;
    if(back == 0 && mi.second != -1) {
      res += mi.first;
      now ^= 1;
    }
  } else {
    // O(1)
    dfs(i, 1, -1, f);
    dfs(p, 1, i, f);
    cnt = deg[i][-1];
    if(!allBlack[p][i]) cnt--;
    now ^= cnt&1;
    dfs(i, back, -1, f);
    res = dp2[i][back][-1];
    if(!allBlack[p][i]) {
      if(!back) {
        now ^= 1;
        if(mi0[i].second == p) {
          res -= mi0[i].first;
          res += mi1[i].first;
        }
      }
      res -= 2 + dfs(p, 1, i, f);
    }
  }
  deg[i][p] = cnt;
  allBlack[i][p] &= cnt == 0;
  if(allBlack[i][p]) res = 0;
  dp2[i][back][p] = res;
  return dp[i][back][p] = res + now;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  cin >> col;
  for(int x = 0; x < 2; x++) dfs(0, x, -1, 1);
  int ans = 1e9;
  for(int i = 0; i < n; i++) for(int x = 0; x < 2; x++) ans = min(ans, dfs(i, x, -1, 0));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 134352
#2019/09/26
A, B = map(int, input().split())

# try:
#     print(max(A+B, A-B, A*B, A/B))
# except ZeroDivisionError:
#     print(max(A+B, A-B, A*B))

print(max(A+B, A-B, A*B))

Measured memory_bytes: 2940
#include <stdio.h>

int main (void)
{
    int N,M,a[50],b[50],road[50],i,j,cnt=0;
    scanf("%d\t%d",&N,&M);
    for(i=0;i<M;i++)
    {
        scanf("%d\t%d",&a[i],&b[i]);
    }
    for(i=1;i<=N;i++)
    {
        for(j=0;j<M;j++)
        {
            if(a[j]==i)
            {
                cnt++;
            }else{
                if(b[j]==i)
                {
                    cnt++;
                }
            }
        }
        road[i]=cnt;
        cnt=0;
    }
    for(i=1;i<=N;i++)
    {
        printf("%d\n",road[i]);
    }
    return 0;
}


Measured memory_bytes: 128
import heapq

N = int(input())
iXY = [[i] + list(map(int, input().split())) for i in range(N)]

G = [set() for _ in range(N)]
for k in [1, 2]:
  iXY.sort(key=lambda a: a[k])
  for i in range(1, N):
    i0 = iXY[i - 1][0]
    i1 = iXY[i][0]
    G[i0].add((i1))
    G[i1].add((i0))

Q = [(0, 0)]
B = set()
a = 0
iXY.sort()

while True:
  d, v = heapq.heappop(Q)
  while v in B:
     d, v = heapq.heappop(Q)
  a += d
  B.add(v)
  if len(B) == N:
    break
  for i in G[v]:
    if i not in B:
      heapq.heappush(Q, (min(abs(iXY[v][1] - iXY[i][1]), abs(iXY[v][2] - iXY[i][2])), i))
print(a)

Measured memory_bytes: 62824
#include <stdio.h>
#include <stdlib.h>

const int Mod = 998244353;
int bit[21];
long long root[21], root_inv[21];

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

long long pow_mod(long long n, int k)
{
	long long N, ans = 1;
	for (N = n; k > 0; k >>= 1, N = N * N % Mod) if (k & 1) ans = ans * N % Mod;
	return ans;
}

void NTT(int k, long long a[], long long z[])
{
	if (k == 0) {
		z[0] = a[0];
		return;
	}
	
	int i, d = bit[k-1];
	long long tmp, *b = (long long*)malloc(sizeof(long long) * d), *c = (long long*)malloc(sizeof(long long) * d), *x = (long long*)malloc(sizeof(long long) * d), *y = (long long*)malloc(sizeof(long long) * d);
	for (i = 0; i < d; i++) {
		b[i] = a[i*2];
		c[i] = a[i*2+1];
	}
	NTT(k - 1, b, x);
	NTT(k - 1, c, y);
	for (i = 0, tmp = 1; i < d; i++, tmp = tmp * root[k] % Mod) {
		z[i] = (x[i] + y[i] * tmp) % Mod;
		z[i+d] = (x[i] - y[i] * tmp % Mod + Mod) % Mod;
	}
	
	free(b);
	free(c);
	free(x);
	free(y);
}

void NTT_reverse(int k, long long z[], long long a[])
{
	if (k == 0) {
		a[0] = z[0];
		return;
	}
	
	int i, d = bit[k-1];
	long long tmp, *b = (long long*)malloc(sizeof(long long) * d), *c = (long long*)malloc(sizeof(long long) * d), *x = (long long*)malloc(sizeof(long long) * d), *y = (long long*)malloc(sizeof(long long) * d);
	for (i = 0; i < d; i++) {
		x[i] = z[i*2];
		y[i] = z[i*2+1];
	}
	NTT_reverse(k - 1, x, b);
	NTT_reverse(k - 1, y, c);
	for (i = 0, tmp = 1; i < d; i++, tmp = tmp * root_inv[k] % Mod) {
		a[i] = (b[i] + c[i] * tmp) % Mod;
		a[i+d] = (b[i] - c[i] * tmp % Mod + Mod) % Mod;
	}
	
	free(b);
	free(c);
	free(x);
	free(y);
}

void prod_poly_NTT(int d, long long a[], long long b[], long long c[])
{
	int i, k;
	for (k = 0, bit[0] = 1; bit[k] < d; k++) bit[k+1] = bit[k] * 2;
	for (i = k - 1, root[k] = pow_mod(3, (Mod - 1) / bit[k]), root_inv[k] = pow_mod(3, Mod - 1 - (Mod - 1) / bit[k]); i >= 0; i--) {
		root[i] = root[i+1] * root[i+1] % Mod;
		root_inv[i] = root_inv[i+1] * root_inv[i+1] % Mod;
	}
	
	long long *x = (long long*)malloc(sizeof(long long) * bit[k]), *y = (long long*)malloc(sizeof(long long) * bit[k]), *z = (long long*)malloc(sizeof(long long) * bit[k]);
	NTT(k, a, x);
	NTT(k, b, y);
	for (i = 0; i < bit[k]; i++) z[i] = x[i] * y[i] % Mod;
	NTT_reverse(k, z, c);
	for (i = 0; i < d; i++) c[i] = div_mod(c[i], bit[k], Mod);
	
	free(x);
	free(y);
	free(z);
}

int main()
{
	int i, N, M;
	long long a[1048576] = {}, b[1048576] = {}, c[1048576];
	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) scanf("%lld", &(a[i]));
	for (i = 0; i < M; i++) scanf("%lld", &(b[i]));
	prod_poly_NTT(N + M, a, b, c);
	for (i = 0; i < N + M - 2; i++) printf("%lld ", c[i]);
	printf("%lld\n", c[N+M-2]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 75220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k=0;
    scanf("%d %d",&n,&m);
    if(n==1)
    k=300000;
    else if(n==2)
        k+=200000;
    else if(n==3)
        k+=100000;
    if(m==1)
        k+=300000;
    else if(m==2)
        k+=200000;
    else if(m==3)
        k+=100000;
    if(n==1 && m==1)
        k+=400000;
    printf("%d",k);

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    var count = 0
    for (i in 1 until n + 1){
        val a = i.toString().length
        if (a == 1){
            count++
        } else if (a == 3){
            count++
        } else if (a == 5){
            count++
        }
    }
    println(count)
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// N M
// S
//
// 9 3
// 0001000100
ll N,M;
string s;
set<ll> emptyPos;

signed main() {
  cin >> N >> M >> s;
  rep(i, N+1) {
    if (s[i] == '0') {
      emptyPos.insert(i);
    }
  }

  vector<ll> ans;
  ll pos = N;
  while (pos > 0) {
    auto it = emptyPos.lower_bound(pos-M);
    if (*it == pos) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(pos - (*it));
    pos = *it;
  }
  reverse(begin(ans), end(ans));

  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}


Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main()
{
	for(int i=0;i<3;i++)
		cin>>a[i];
	sort(a,a+3);
	int ans=0;
	ans+=abs(a[0]-a[1]);
	ans+=abs(a[1]-a[2]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <math.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    char array[N];
    for(int i = 0; i < N; i++){
        cin >> array[i];
    }
    int count = N;
    for(int i = 0; i < N - 1; i++){
        if(array[i] == array[i + 1]){
            count--;
        }
    }
    cout << count;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
const int maxn=105;
int n,m,cnt[26];
char s[maxn];
int main(){
	scanf("%d%d",&n,&m);
	REP(i,1,n){
		scanf("%s",s+1);
		REP(j,1,m)cnt[s[j]-'a']++;
	}
	int c1,c2,c4;
	c1=(n&1)&(m&1);
	c2=(n&1)*(m/2)+(m&1)*(n/2);
	c4=(n/2)*(m/2);
	bool ans=1;
	REP(i,0,25)
		if(cnt[i]&1){
			if(c1)--cnt[i],--c1;
			else ans=0;
		}
	REP(i,0,25)
		if(cnt[i]%4==2){
			if(c2)cnt[i]-=2,--c2;
			else ans=0;
		}
	if(c2&1)ans=0;
	puts(ans?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> W >> H >> N;
	vector<vector<int>>x(W + 2);
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		x[a].push_back(b);
	}
	for (int i = 1; i <= H; i++)x[W + 1].push_back(i);
	bitset<200001>bs;
	bs.flip(0);
	for (int i = 1; i <= W; i++) {
		bs |= bs << 1;
		for (auto j : x[i])bs.set(j, 0);
		for (auto j : x[i + 1]) {
			if (bs.test(j)) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12412
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;
pair<int, int> dis[N];
vector<pair<int, int>> vp[N];
int ans[N][N];
int vis[N];
int n, m;
void solve(int s, int L)
{
	MEM(dis, 0x3f);
	dis[s] = make_pair(0, -L);
	MEM(vis, 0);
	while (1)
	{
		tuple<int, int, int> key(int(0x3f3f3f3f), int(0x3f3f3f3f), -1);
		for (int i = 1; i <= n; i++)
		{
			if (vis[i]) continue;
			key = min(key, make_tuple(dis[i].first, dis[i].second, i));
		}
		int cost, rest, x;
		tie(cost, rest, x) = key;
		if (x == -1) break;
		vis[x] = 1;
		for (auto& p : vp[x])
		{
			int y, w;
			tie(y, w) = p;
			pair<int, int> res;
			if (w > L) continue;
			if (rest + w <= 0) res = make_pair(cost, rest + w);
			else res = make_pair(cost + 1, -L + w);
			if (dis[y] > res)
			{
				dis[y] = res;
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		ans[s][i] = dis[i].first;
		if (ans[s][i] == 0x3f3f3f3f)
			ans[s][i] = -1;
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int L;
	cin >> n >> m >> L;
	while (m--)
	{
		int x, y, w;
		cin >> x >> y >> w;
		vp[x].emplace_back(y, w);
		vp[y].emplace_back(x, w);
	}
	for (int i = 1; i <= n; i++)
		solve(i, L);
	int q;
	cin >> q;
	while (q--)
	{
		int s, t;
		cin >> s >> t;
		printf("%d\n", ans[s][t]);
	}
	return 0;
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int N = sc.nextInt();
		int digitSum=0;
		int n =N;
		while (n>0) {
			digitSum += n%10;
			n /= 10;
		}
		if (N%digitSum==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
//------------------------------------------------------------
	}
}

Measured memory_bytes: 23636
#include<stdio.h>
#include<stdlib.h>
int f[100000];
typedef struct{
	long a;
	long b;
} ver;
ver v[200000];
long c[100000],s[100000],e[100000];

int cmp(const void *a,const void *b){
	return ((ver *)a)->a-((ver *)b)->a;
}

int main(int argc, char const *argv[]){
	long n,m,a,b,sn=1,en=0,i;
	scanf("%ld %ld",&n,&m);
	for(i=0;i<m;i++){
		scanf("%ld %ld",&a,&b);
		v[i*2].a=a;
		v[i*2].b=b;
		v[i*2+1].a=b;
		v[i*2+1].b=a;
		c[a-1]++;
		c[b-1]++;
	}
	qsort(v,m*2,sizeof(ver),cmp);
	for(i=1;i<n;i++){
		c[i]+=c[i-1];
	}
	s[0]=1;
	b=v[0].b;
	f[0]=1;
	while(1){
		s[sn]=b;
		sn++;
		f[b-1]=1;
		for(i=c[b-2];i<c[b-1];i++){
			if(v[i].a==b && f[v[i].b-1]==0) break;
		}
		if(i>=c[b-1]) break;
		b=v[i].b;
	}
	for(i=1;i<c[0];i++){
		if(f[v[i].b-1]==0) break;
	}
	if(i<c[0]){
		b=v[i].b;
		while(1){
			e[en]=b;
			en++;
			f[b-1]=1;
			for(i=c[b-2];i<c[b-1];i++){
				if(v[i].a==b && f[v[i].b-1]==0) break;
			}
			if(i>=c[b-1]) break;
			b=v[i].b;
		}
	}
	printf("%ld\n",sn+en);
	a=0;
	for(i=en;i>0;i--){
		if(a==1) printf(" ");
		else a=1;
		printf("%ld",e[i-1]);
	}
	for(i=0;i<sn;i++){
		if(a==1) printf(" ");
		else a=1;
		printf("%ld",s[i]);
	}
	printf("\n");
	return 0;
}

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

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>>a(H,vector<char>(W));
  vector<vector<char>>b(H+2,vector<char>(W+2,'#'));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
      b[i+1][j+1]=a[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout<<b[i][j];
    }
  cout<<endl;
  }
}
                     

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> next(n);
    rep(i, m) {
        int fr, to;
        cin >> fr >> to;
        fr--; to--;
        next[fr].push_back(to);
        next[to].push_back(fr);
    }

    int nq;
    cin >> nq;
    priority_queue<tuple<int, int, int, int>> q;
    rep(i, nq) {
        int fr, d, col;
        cin >> fr >> d >> col;
        q.emplace(d, i, fr - 1, col);
    }

    vector<int> ans(n, 0), vprio(n, -1), vdist(n, -1);
    while (not q.empty()) {
        int dist, prio, pos, color;
        tie(dist, prio, pos, color) = q.top();
        q.pop();

        if (vprio[pos] >= prio) {
            continue;
        }
        vprio[pos] = prio;
        ans[pos] = color;
        vdist[pos] = dist;

        if (dist > 0) {
            int ndist = dist - 1;
            for (int npos : next[pos]) {
                if (vprio[npos] < prio) {
                    q.emplace(ndist, prio, npos, color);
                }
            }
        }
    }

    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 17516