akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////
struct ed{
    ll to;ll cos;
};
int main(){
    ll n,m;cin>>n>>m;
    vector<ed> edge[n];
    bool used[n];rep(i,0,n-1)used[i]=false;
    rep(i,1,m){
        
        ll u,v,s;cin>>u>>v>>s;
        u--;v--;
        ed e;
        e.to=v;e.cos=s;
        edge[u].push_back(e);
        e.to=u;
        edge[v].push_back(e);
    }
    
    
    queue<int>q;
    q.push(0);
    
    set<l_l> ans[n];
    ans[0].insert(make_pair(1,0));
    used[0]=true;
    while(!q.empty()){
        int top=q.front();q.pop();
        used[top]=true;
        for(auto x:edge[top]){
            if(used[x.to]==true);
            else{
                
                ans[x.to].insert(make_pair(-1*(*(ans[top].begin())).first, x.cos-(*(ans[top].begin())).second));
                
                q.push(x.to);
            }
        }
        
    }
    
  
    ll A=inf;
/*   rep(i,0,n-1){
        cout<<i<<endl;
        for(auto x:ans[i]){
            cout<<x.first<<" "<<x.second<<endl;
        }
        cout<<endl;
    }*/
    for(int i=0;i<=n-1;i++){
        if(ans[i].size()>=3){cout<<0;return 0;}
        if(ans[i].size()==2){
            auto itr=ans[i].begin();
            if((*itr).first!=-1){cout<<0;return 0;}
            itr++;
            if((*itr).first!=1){cout<<0;return 0;}
            ll a=-(*itr).second;
            itr--;
            a+=(*itr).second;
            if(a%2!=0){cout<<0;return 0;}
            a/=2;
            if(A!=inf&&A!=a){cout<<0;return 0;}
            A=a;
        }
    }
    if(A!=inf){
        rep(i,0,n-1){
            auto itr=ans[i].begin();
            if(ans[i].size()==1){
                if((A*((*itr).first))+((*itr).second)<0){cout<<0;return 0;}
            }else{
                if((A*((*itr).first))+((*itr).second)<0){cout<<0;return 0;}
                itr++;
                if((A*((*itr).first))+((*itr).second)<0){cout<<0;return 0;}
            }
        }
        
        cout<<1;return 0;
        
    }
    
    ll ma=inf,mi=-inf;
    rep(i,0,n-1){
        ll whi=(*(ans[i].begin())).first;
        ll cost=(*(ans[i].begin())).second;
        if(whi==1){
            mi=max(mi,-cost);
        }else{
            ma=min(ma,cost);
        }
    }
    cout<<max(0,ma-mi-1)<<endl;
    
    
    
    return 0;
}


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

typedef long long Int;

inline Int orz(int e) { return 1LL << e; }
template<typename T> inline void y(T & t) { t++; }
template<typename T> inline void j(T & t) { t--; }
int main() {
	int n,k;cin>>n>>k;
	vector<Int>ca(n+1);for(int i=0;i<n;y(i)){int x;cin>>x;ca[i+1]=ca[i]+x;}
	vector<Int> Orz; for (int l=0; l<n; y(l)) for(int r=l; r<n; y(r)) Orz.push_back(ca[r+1] - ca[l]);
	Int S = 0;
	for (int b=60; b>=0; j(b)) {
		int cnt=0; for (Int v : Orz) if (v & orz(b)) y(cnt);
		if (cnt >= k) {
			S |= orz(b);
			vector<Int> Orz2;
			for (Int v : Orz) if (v & orz(b)) Orz2.push_back(v);
			Orz = Orz2;
		}
	}
	cout << S << endl;
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    int N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> dif(N-1);
    for(int i=0;i<N;i++)
    {
        cin >> A.at(i);
    }
    ll all = accumulate(ALL(A),0LL);
    for(int i=0;i<N-1;i++)
    {
        all -= 2 * A.at(i); 
        dif.at(i) = abs(all);
    }

    ll mindif = *min_element(ALL(dif));

    cout << mindif << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int s=0;
  int m=0;
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    s+=p;
    m=max(m,p);
  }
  cout<<s-m/2<<endl;
}

Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define N 305
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
bool del[N];
int cnt[N],now[N];
int n,m,a[N][N];
bool check(int x)
{
	memset(del,0,sizeof del);
	memset(cnt,0,sizeof cnt);
	for(int i=1;i<=n;++i)
	{
		now[i]=1;
		++cnt[a[i][1]];
	}
	int last=m;
	while(1)
	{
		bool ok=1;
		for(int i=1;i<=m;++i)
			if(cnt[i]>x)
			{
				cnt[i]=0;
				del[i]=1;
				--last;
				if(!last)return 0;
				for(int j=1;j<=n;++j)
					if(a[j][now[j]]==i)
					{
						while(del[a[j][now[j]]])++now[j];
						++cnt[a[j][now[j]]];
					}
				ok=0;
				break;
			}
		if(ok)return 1;
	}
	return 0;
}
int main()
{
	re(n),re(m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			re(a[i][j]);
	int l=1,r=n;
	while(l < r)
	{
		int m=l+r>>1;
		if(check(m))r=m;
		else l=m+1;
	}
	printf("%d\n",l);
}


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

#define inf 1e9+7
typedef long long ll;

int n;
vector<vector<int> > cost;

void solve(int s){
    vector<bool> flg(n,false);
    flg[s]=true;
    vector<int> vc;
    vc.push_back(s);


    int sum=0;
    int mi,next;
    while(1){
        mi=inf;
        next=-1;
        for(int i=0;i<vc.size();i++){
            for(int j=0;j<n;j++){
                if(flg[j]||cost[vc[i]][j]<0)continue;
                if(mi>cost[vc[i]][j]){
                    mi=cost[vc[i]][j];
                    next=j;
                }
            }
        }
        if(next==-1)break;
        else{
            sum+=mi;
            flg[next]=true;
            vc.push_back(next);
        }
    }
    cout << sum << endl;
}

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

    cin >> n;
    cost.resize(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int a;
            cin >> a;
            cost[i].push_back(a);

        }
    }

    solve(0);
    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> e(a),r(b),t(c);
    rep(i,a) cin >> e[i];
    rep(i,b) cin >> r[i];
    rep(i,c) cin >> t[i];
    sort(all(e));
    reverse(all(e));
    sort(all(r));
    reverse(all(r));
    sort(all(t));
    reverse(all(t));
    ll ans=0;
    rep(i,x) ans+=e[i];
    rep(i,y) ans+=r[i];
    ll o=x+y;
    x--;
    y--;
    ll u=ans;
    for (ll i=0;i<o;i++){
        bool w;
        if (i>=c) break;
        if (x==-1) w=true;
        else if (y==-1) w=false;
        else if (e[x]>r[y]) w=true;
        else w=false;
        if (w){
            u+=t[i]-r[y];
            ans=max(ans,u);
            y--;
        }
        else {
            u+=t[i]-e[x];
            ans=(max(ans,u));
            x--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

ll func(ll a, ll b, ll sum) {
	ll n = b / a;
	ll ans;
	if(b % a == 0) return (n - 1) * a * 2 + a + sum;
	else ans = n * a * 2 + sum;
	
	return func(b % a, a, ans);
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll N, X;
	cin >> N >> X;
	
	ll ans = N;
	if(X < N - X) ans += func(X, N - X, 0);
	else ans += func(N - X, X, 0);
	
	cout << ans << "\n";
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s ;
  cin >> s;
  int counter = 0;
  if( s[0] == '1'){counter++;}
  if( s[1] == '1'){counter++;}
  if( s[2] == '1'){counter++;} 
  cout << counter << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {


    public static void solve() {
        int n = in.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];

        for(int i = 0; i < n; i += 1) {
            a[i] = in.nextInt(); b[i] = in.nextInt(); c[i] = in.nextInt();
        }

        int[][] store = new int[n][3];

        store[0][0] = a[0];
        store[0][1] = b[0];
        store[0][2] = c[0];

        for(int i = 1; i < n; i += 1) {
            for(int j = 0; j < 3; j += 1) {
                if(j == 0) {
                    store[i][j] = a[i] + Math.max(store[i-1][1], store[i-1][2]);
                } else if(j == 1) {
                    store[i][j] = b[i] + Math.max(store[i-1][0], store[i-1][2]);
                } else {
                    store[i][j] = c[i] + Math.max(store[i-1][0], store[i-1][1]);
                }
            }
        }

        out.println(Math.max(store[n-1][0], Math.max(store[n-1][1], store[n-1][2])));
    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

Measured memory_bytes: 46784
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<ll> D(19,1);


ll count(ll d,ll k,ll dist){
    if(d*2>k){
        if(k&1){return (dist==0?10:0);}
        return (dist==0?1:0);
    }
    ll K=D[k-d]-D[d-1];
    dist=abs(dist);
    if(d==1){
        if(dist%K==0){
            if(dist/K>=9){return 0;}
            return count(d+1,k,0)*(9-dist/K);
        }
        ll ret=0;
        if(dist/K<9){ret+=count(d+1,k,dist%K)*(9-dist/K);}
        if(dist/K+1<9){ret+=count(d+1,k,K-dist%K)*(9-dist/K-1);}
        return ret;
    }
    if(dist%K==0){
        if(dist/K>=10){return 0;}
        return count(d+1,k,0)*(10-dist/K);
    }
    ll ret=0;
    if(dist/K<10){ret+=count(d+1,k,dist%K)*(10-dist/K);}
    if(dist/K+1<10){ret+=count(d+1,k,K-dist%K)*(10-dist/K-1);}
    return ret;
}



int main(){
    for(int i=1;i<19;i++){D[i]=D[i-1]*10;}
    ll d;
    cin>>d;
    ll ans=0;
    for(ll i=1;i<=18;i++){
        ans+=count(1,i,d);
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n, t[100009], x[100009], y[100009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];
	bool flag = true;
	for (int i = 1; i <= n; i++) {
		int dist = abs(x[i - 1] - x[i]) + abs(y[i - 1] - y[i]);
		int dt = t[i] - t[i - 1];
		if (dt < dist || (dt - dist) % 2 == 1) flag = false;
	}
	cout << (flag ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 1408
try:
    while True:
        x = str(input())
        if int(x) == 0 :
            exit()
        digit_list = list(x)
        i = 0
        sum = 0
        while i < len(digit_list):
            sum = sum + int(digit_list[i])
            i += 1
        print(sum)
except EOFError:
    pass


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

/*template<typename T> void read(T &x) {
	T s=0,w=1;
	char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c>='0'&&c<='9') s=s*10+c-'0',c=getchar();
	x=s*w;
}
*/unsigned long long read() {
	unsigned long long s=0,w=1;
	char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c>='0'&&c<='9') s=s*10+c-'0',c=getchar();
	return s*w;
}

int n=read();
set<string> Set;
int main() {
	string str;
	for(int i=1;i<=n;++i) {
		cin>>str;
		Set.insert(str);
	}
	printf("%d",Set.size());
	return 0;
}


Measured memory_bytes: 19356
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
10 7 5
1 2 3 4 6 8 9
)");
#define cin input
#endif

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int count1,count2;
	count1 = count2 = 0;
	
	vector<int> vec(m);
	for (int i=0; i<m; i++)
		cin >> vec[i];

	for (int j=0; vec[j]<x; j++)
		count1++;

	for (int k=m-1; vec[k]>x; k--)
		count2++;

	if (count1>=count2)
		cout << count2 << endl;
	else
		cout << count1 << endl;

return 0;	
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

vector<int> edges[200005];
int aAdj[200005];
int bAdj[200005];
bool bad[200005];

void solve() {
  int n, m;
  string s;
  cin >> n >> m >> s;
  while(m--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
    (s[b] == 'A' ? aAdj : bAdj)[a]++;
    (s[a] == 'A' ? aAdj : bAdj)[b]++;
  }
  queue<int> q;
  for(int i = 0; i < n; i++) {
    if(aAdj[i] == 0 || bAdj[i] == 0) {
      q.push(i);
      bad[i] = true;
    }
  }
  while(!q.empty()) {
    int curr = q.front();
    q.pop();
    for(int out: edges[curr]) {
      if(--((s[curr] == 'A' ? aAdj : bAdj)[out]) == 0) {
        if(!bad[out]) {
          bad[out] = true;
          q.push(out);
        }
      }
      assert((s[curr] == 'A' ? aAdj : bAdj)[out] >= 0);
    }
  }
  int good = 0;
  for(int i = 0; i < n; i++) if(!bad[i]) good++;
  if(good) cout << "Yes\n";
  else cout << "No\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/2

#define MAX_N (1<<18)

//// RangeMinimum(Segtree) (0-indexed)
struct RangeMinQuery{
	int dat[2*MAX_N-1];
	int size;

	void init(int n_){
		size=1;
		while(size<n_) size*=2;
		for(int i=0;i<2*size-1;i++)dat[i]=INT_MAX;
	}

	void update(int k,int a){
		k+=size-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=min(dat[k*2+1],dat[k*2+2]);
		}
	}

	int subquery(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return INT_MAX;
		if(a<=l&&r<=b)return dat[k];
		else{
			return min(subquery(a,b,k*2+1,l,(l+r)/2),subquery(a,b,k*2+2,(l+r)/2,r));
		}
	}
	
	int query(int a,int b){
		return subquery(a,b,0,0,size);
	}
};

//// RangeMaximum(Segtree) (0-indexed)
struct RangeMaxQuery{
	int dat[2*MAX_N-1];
	int size;

	void init(int n_){
		size=1;
		while(size<n_)size*=2;
		for(int i=0;i<2*size-1;i++)dat[i]=0;
	}

	void update(int k,int a){
		k+=size-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=max(dat[k*2+1],dat[k*2+2]);
		}
	}

	int subquery(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return 0;
		if(a<=l&&r<=b)return dat[k];
		else{
			return max(subquery(a,b,k*2+1,l,(l+r)/2),subquery(a,b,k*2+2,(l+r)/2,r));
		}
	}
	int query(int a,int b){
		return subquery(a,b,0,0,size);
	}
};

RangeMaxQuery rmq2;
RangeMinQuery rmq;

int n,t;
int a[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>t;
	rmq.init(n);
	rmq2.init(n);
	t/=2;
	rep(i,n){
		cin>>a[i];
		rmq.update(i,a[i]);
		rmq2.update(i,a[i]);
	}
	int maxcost=0;
	int res=0;
	repl(i,1,n){
		maxch(maxcost,rmq2.query(i,n)-rmq.query(0,i));
	}
	repl(i,1,n){
		if(a[i]-rmq.query(0,i)==maxcost)res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 2816
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

class solution {
private:
	int n, k;
	int ar[105];
	int dp[100005];
	void reset() {
		for (int i = 0; i <= k; i++) {
			dp[i] = -1;
		}
	}
public:
	solution() {
		scanf("%d %d", &n, &k);
		for (int i = 0; i < n; i++) {
			scanf("%d", &ar[i]);
		}
		reset();
		for (int i = 1; i <= k; i++) {
			for (int j = 0; j < n; j++) {
				if (i - ar[j] >= 0 && dp[i - ar[j]] < 0) {
					dp[i] = -dp[i - ar[j]];
				}
			}
		}
		printf("%s\n", dp[k] == 1 ? "First" : "Second");
	}
};

#ifndef L0C4L
int main() {
	solution();
	return 0;
}
#endif

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <cmath>
#include <cstring>
#include <cstdio>
#define mst(a) memset(a,0,sizeof(a))
#define rev(a) reverse(a,a+strlen(a))
using namespace std;
typedef long long ll;
int main()
{
   double w,h,x,y;
   cin>>w>>h>>x>>y;
   if(x==w/2&&y==h/2)printf("%.6f 1\n",w*h/2);
   else printf("%.6f 0\n",w*h/2);
   return 0;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
int main(){

    string s;
    cin >> s;
    int cnt_0, cnt_1;
    cnt_0 = cnt_1 = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == '0') cnt_0++;
        else cnt_1++;
    }
    cout << 2 * min(cnt_0, cnt_1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	while(1){
        int n;
        scanf("%d",&n);
        if(n == 0) break;
        int cnt = 0;
        for(int i = 1; i < n; i++){
            int sum = 0;
            for(int j = i; j <= n; j++){
                if(sum == n) cnt++;
                if(sum > n) break;
                sum += j;
            }
        }
        cout << cnt << endl;
	}
	return 0;
}

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

int main(){
    int h, a;
    cin >> h >> a;
    int ans = h / a;
    if(h % a > 0) ans++;
    cout << ans << endl;
    return 0;
}

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

class Node
{
    internal int left, right, parent, id;
    public Node() {
        id = -1;
        left = -1;
        right = -1;
        parent = -1;
    }
}

class B
{
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n; i++) {
            int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            nodes[data[0]].id = data[0];
            nodes[data[0]].left = data[1];
            nodes[data[0]].right = data[2];
            if (data[1] != -1) {
                nodes[data[1]].parent = data[0];
            }
            if (data[2] != -1) {
                nodes[data[2]].parent = data[0];
            }
        }
        int root=-1;
        foreach (Node node in nodes) {
            if (node.parent == -1) {
                root = node.id;
                break;
            }
        }
        StringBuilder output = new StringBuilder();
        output.AppendLine("Preorder");
        Preorder(nodes, root, output);
        Console.WriteLine(output);

        output = new StringBuilder();
        output.AppendLine("Inorder");
        Inorder(nodes, root, output);
        Console.WriteLine(output);

        output = new StringBuilder();
        output.AppendLine("Postorder");
        Postorder(nodes, root, output);
        Console.WriteLine(output);
    }
    static void Preorder(Node[] nodes, int num, StringBuilder output) {
        if (num == -1) {
            return;
        }
        output.Append(" " + num);
        Preorder(nodes, nodes[num].left, output);
        Preorder(nodes, nodes[num].right, output);
    }

    static void Inorder(Node[] nodes, int num, StringBuilder output) {
        if (num == -1) {
            return;
        }
        Inorder(nodes, nodes[num].left, output);
        output.Append(" " + num);
        Inorder(nodes, nodes[num].right, output);
    }

    static void Postorder(Node[] nodes, int num, StringBuilder output) {
        if (num == -1) {
            return;
        }
        Postorder(nodes, nodes[num].left, output);
        Postorder(nodes, nodes[num].right, output);
        output.Append(" " + num);
    }
}


Measured memory_bytes: 9268
#include<stdio.h>
#include<math.h>
int main(void){
  int i,n,x[100],y[100];
  double D1=0,d2=0,Dm=0,d3=0,ab[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    { scanf("%d",&x[i]);}
  for(i=0;i<n;i++)
    { scanf("%d",&y[i]);}
  for(i=0;i<n;i++)
    {
	ab[i]=abs(x[i]-y[i]);
	/*Dm*/
	if(i == 0){Dm = ab[0];}
	else if(ab[i]>Dm){Dm = ab[i];}
	/*D1*/
	D1 += ab[i];
	  /*D2*/
	  d2 += ab[i]*ab[i];
	  /*d3*/
	  d3 += pow(ab[i],3.0);
    }
  printf("%f\n%f\n%f\n%f\n",D1,sqrt(d2),pow(d3,1.0/3.0),Dm);
  return 0;
}

Measured memory_bytes: 696
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
#define Endl endl
int main(){
	int n,a[100000],last=1,count=0,dim,ans=0;
	cin>>n;
	REP(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	last=a[0];
	for(int i=0;i<n;i++){
		if(last==a[i]){
			count++;
		}
		if(count==last && last==a[i]){
			ans+=last;
			//cout<<"a"<<Endl;
		}
		if(a[i]!=last)count=1;
		DEB(count)DEB(last)DEB(ans)ARDEB(i,a)END
		last=a[i];
	}
	cout<<n-ans<<Endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<int> p(N);
	repp(i,0,N){
		cin >> p[i];
		--p[i];
	}
	int x = 0;
	while(x < N){
		while(x < N && p[x] == x) ++x;
		if(x == N) break;
		int i = x;
		int l = 0, r = p[x];
		while(x+2 < N && p[x+1] == x+1 && p[x+2] != x+2){
			x += 2;
			if(p[x] < x){
				if(l > p[x]) return cout << "No" << endl, 0;
				l = p[x];
			} else {
				if(r > p[x]) return cout << "No" << endl, 0;
				r = p[x];
			}
		}
		if(max(l,r) > x) return cout << "No" << endl, 0;
		++x;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
# 入力を2つの数値として扱う
a, b = map(int, input().split())

# 最大公約数を求める関数(ユークリッド互除法)
def gcd(i, j):
    while j != 0:
        i, j = j, i % j
    return i

# 公約数のリストを返す関数(最大公約数の約数)
def divisor(n):
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            ret.append(n//i)
        i += 1
    ret = list(set(ret))
    ret.sort()
    return ret

# 互いに素(最大公約数が1)の場合Trueを返す関数
def coprime(i, j):
    return gcd(i, j) == 1

# 最大公約数を求める
g = gcd(a, b)

# 公約数のリストを求める
dl = divisor(g)

# 公約数を調べる
cnt = 1
# 1より大きい約数について
while cnt < len(dl):
    lc = 1
    # 次の約数と比較
    while cnt + lc < len(dl):
        # for debug:print(str(dl[cnt]) + ',' + str(dl[cnt + lc]))
        # 素でない場合は削除
        if not coprime(dl[cnt], dl[cnt + lc]):
            dl.remove(dl[cnt + lc])
            lc -= 1
        lc += 1
    cnt += 1

# 答えの出力
print(len(dl))

Measured memory_bytes: 3956
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	s=input()
	n=len(s)
	ans="Yes"

	if s!=s[::-1] or s[:(n-1)//2]!=s[:(n-1)//2][::-1] or s[(n+3)//2-1:]!=s[(n+3)//2-1:][::-1]:
		ans="No"

	print(ans)

if __name__ == "__main__":
	main()


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

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

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int x = pow(2, k);

  int ans = max({a * x + b + c, b * x + a + c, c * x + a + b});
  cout << ans << endl;
}


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

using namespace std;

int main() {
	int n;
	stack<int> s;
	while (cin >> n) {
		if (n == 0) {
			cout << s.top() << endl;
			s.pop();
		} else {
			s.push(n);
		}
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int A,B;
void input(){
    cin>>A>>B;
    return;
}

void solve(){
    int ans=0;
    int tap=1;
    while(tap<B){
        tap+=A-1;
        ++ans;
    }
    cout<<ans<<endl;
    return;
}

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

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

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string N;
    cin >> N;

    YESNO(((N[0] == N[1] && N[1] == N[2])
        || (N[1] == N[2] && N[2] == N[3])), "Yes", "No");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s;
  cin>>s;
  bool f=0;
  f|=(s[0]==s[1]&&s[1]==s[2]);
  f|=(s[1]==s[2]&&s[2]==s[3]);
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    long long x,y;
    cin>>x>>y;
    
    long long a=abs(abs(x)-abs(y));
    
    long long ans = a;
    
    if(x==y){}
    else if(x<y){
        if(x>=0){}
        else if(x<0 && y>0){ans++;}
        else if(y==0){
            
        }else if(y<0){
            
        }
    }
    else if(y<x){
        if(y>0){
            ans+=2;
        }else if(y==0){
            ans++;
        }else if(y<0 && x>0){
            ans++;
        }else if(x==0){
            ans++;
        }else if(x<0){
            ans+=2;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            string s = Console.ReadLine();
            int k = ReadAndParseInt();
            HashSet<string> hash = new HashSet<string>();
            hash.Add(s);

            List<char> candidates = new List<char>();
            for(int c= (int)'a'; c<=(int)'z';++c)
            {
                for(int i=0;i<s.Length;++i)
                {
                    if(s[i] == c)
                    {
                        candidates.Add(s[i]);
                        break;
                    }
                }
                if(candidates.Count >= k)
                {
                    break;
                }
            }

            // 候補charを基準に部分文字列を追加していく
            foreach(char c in candidates)
            {
                for(int i=0;i<s.Length;++i)
                {
                    if(s[i] == c)
                    {
                        // 部分文字列は高々k
                        int maxLen = Math.Min(5, s.Length - i);
                        for (int len = 1; len <= maxLen; ++len)
                        {
                            string sz = s.Substring(i, len);
                            if (!hash.Contains(sz))
                            {
                                hash.Add(sz);
                            }
                        }
                    }
                }
            }

            List<string> list = new List<string>(hash);
            list.Sort();
            string ans = list[k-1];
            Console.WriteLine(ans);
         }
    }
}


Measured memory_bytes: 13792
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  ll cu=0;
  for(int i=1;;i++){
    cu+=i;
    if(cu>=n){
      COUT(i);
      return 0;
    }
  }
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (x < r || y < r || x + r > W || y + r > H) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  
  return 0;
}
  

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

using namespace std;

const int MAX = 10000;

vector<int> V;
int n,a,b,c,x,pos;

void init(){
  V.clear();
  pos = 0;
}

int main(){

  
  while(cin >> n >> a >> b >> c >> x && n+a+b+c+x){
    init();
    for(int i = 0; i < n; i++){
      int num;
      cin >> num; 
      V.push_back(num);
    }

    bool fin = false;

    for(int i = 0; i <= MAX; i++){
      if(x == V[pos]) pos++;
      x = (a*x+b)%c;
      if(pos == V.size()){
	cout << i << endl;
	fin = true;
	break;
      }
    }

    if(fin == false) cout << "-1" << endl;
   
  }
  
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

void flip(vvi& a,int i,int j)
{
	int di[]={-1,0,0,0,1};
	int dj[]={0,-1,0,1,0};
	rep(k,5){
		int ni=i+di[k],nj=j+dj[k];
		if(0<=ni && ni<10 && 0<=nj && nj<10)
			a[ni][nj]^=1;
	}
}

int main()
{
	int tc; cin>>tc;
	while(tc--){
		vvi a(10,vi(10));
		rep(i,10) rep(j,10)
			cin>>a[i][j];
		rep(k,1<<10){
			vvi b=a;
			vvi res(10,vi(10));
			rep(i,10)
				if(k&(1<<i)){
					flip(b,0,i);
					res[0][i]=1;
				}
			repi(i,1,10)
				rep(j,10)
					if(b[i-1][j]){
						flip(b,i,j);
						res[i][j]=1;
					}
			int count1=0;
			rep(i,10)
				count1+=count(allof(b[i]),1);
			if(count1==0){
				rep(i,10)
					rep(j,10)
						cout<<res[i][j]<<(j==9?'\n':' ');
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 908
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a[50];
int main(){
    int t, c=0;
     scanf("%d", &t);
     vector<int> v1(t), v2(t);
    for(int i=0;i<t;i++) scanf("%d", &v1[i]);
    v2=v1;
    sort(v1.begin(), v1.end());
     for(int i=0;i<t;i++) c+= (v1[i]!=v2[i]);
     if(c==2 || c==0) printf("YES\n");
     else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
l=[s[i] for i in range(n)]
if l[k-1]=="A":
    l[k-1]="a"
elif l[k-1]=="B":
    l[k-1]="b"
else:
    l[k-1]="c"
    
print("".join(l))
    
    
        
    
    
    
        
        
    
    
    
    
        

        
   
    
    
    
        
        
    
    
    
    
        

      
    
    
        
        
    
    
    
    
        


Measured memory_bytes: 9144
import scala.io.StdIn.{readLine,readInt}

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val s = readLine.split(" ").map(_.toInt)
    val q = readInt
    val t = readLine.split(" ").map(_.toInt)
    println(t.filter(s.contains(_)).length)
  }
}

Measured memory_bytes: 51868
#include<stdio.h>

int main(void){
    int m,d;
    scanf("2019/%d/%d",&m,&d);
    if(m<=4){
        printf("Heisei");
    }else{
        printf("TBD");
    }


    return 0;
}
/*test
1.
2019/04/30
->Heisei
2.
2019/11/01
->TBD
*/

Measured memory_bytes: 128
def call(n):
  CHECK_NUM     = 1
  INCLUDE3      = 2
  END_CHECK_NUM = 3
  i = 1
  goto = CHECK_NUM
  while True:
    if goto == CHECK_NUM:
      x = i
      if (x % 3 == 0):
        print(' ' + str(i), end='')
        goto = END_CHECK_NUM
    if goto <= INCLUDE3:
      if (x % 10 == 3):
        print(' ' + str(i), end='')
        goto = END_CHECK_NUM
      else:
        x = int(x / 10)
        if (x != 0):
          goto = INCLUDE3
          continue
    if goto <= END_CHECK_NUM:
      i += 1
      if (i <= n):
        goto = CHECK_NUM
      else:
        print('')
        break

call(int(input()))


Measured memory_bytes: 5872
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;
    cin>>n>>d;
    int count = 0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        ll t1 = x*x;
        ll t2 = y*y;
        ll sum = t1+t2;
        ll comp = d*d;
        if(sum <= comp){
            count++;
        }
    }
    cout<<count;
}

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

int main(){
    int r,c;
    cin >> r >> c;
    int table[r][c];
    int sumr[r];
    int sumc[c];
    int sumrc=0;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> table[i][j];
            sumc[j]=0;
        }
        sumr[i]=0;
    }
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            sumr[i]+=table[i][j];
            sumc[j]+=table[i][j];
            cout << table[i][j] << " ";
        }
        cout << sumr[i] << endl;
    }
    for(int i=0; i<c; i++){
        cout << sumc[i] << " ";
        sumrc+=sumc[i];
    }
    cout << sumrc << endl;
}


Measured memory_bytes: 3132
n = int(input())
dc = 0
c = 0
for i in range(1,n+1):
  if i % 2 == 1:
    for j in range(1,i+1):
      if i % j == 0:
        dc += 1
      else:
        pass
    
    if dc == 8:
      c += 1
    else:
      dc = 0
    
  else:
    pass
  
print(c)
      

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

int main()
{
	int nN, nM, nL;
	cin >> nN >> nM >> nL;
	long int nLeft[100][100] = { 0 };
	long int nRight[100][100] = { 0 };
	long int nResult[100][100] = { 0 };

	for (int i = 0; i < nN; i++)
	{
		for (int j = 0; j < nM; j++)
		{
			cin >> nLeft[i][j];
		}
	}
	for (int i = 0; i < nM; i++)
	{
		for (int j = 0; j < nL; j++)
		{
			cin >> nRight[i][j];
		}
	}
	for (int i = 0; i < nN; i++)
	{
		for (int j = 0; j < nL; j++)
		{
			long  int nSum = 0;
			for (int k = 0; k < nM; k++)
			{
				nSum += nLeft[i][k] * nRight[k][j];
			}
			nResult[i][j] = nSum;
		}
	}
	for (int i = 0; i < nN; i++)
	{
		for (int j = 0; j < nL; j++)
		{
			cout << nResult[i][j];
			if (j != nL - 1)
			{
				cout << " ";
			}
		}
		cout << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3336
N = int(input())
B = list(map(int, input().split()))

A = [0] * N

A[0] = B[0]
A[1] = B[0]

for index in range(N - 1):
    i = index + 1
    if A[i-1] > B[index]:
        A[i-1] = B[index]
    
    A[i] = B[index]

print(sum(A))

Measured memory_bytes: 3064
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val cbuf = ArrayBuffer.empty[Int]
    val sbuf = ArrayBuffer.empty[Int]
    val fbuf = ArrayBuffer.empty[Int]
    for (_ <- 0 until n - 1) {
      cbuf.append(sc.nextInt())
      sbuf.append(sc.nextInt())
      fbuf.append(sc.nextInt())
    }

    (n, cbuf.toVector, sbuf.toVector, fbuf.toVector)
  }


  def main(args: Array[String]): Unit = {
    val (n, c, s, f) = read()

    // n: 駅の数
    // c(i): i→i+1の所要時間
    // s(i): 開通式開始から駅iを出発するまでの時間
    // f(i): i駅での発車間隔 (f(i) | s(i)。f(i)が駅iにおける単位時間)
    def calcTime(start: Int): Int = {
      var time = 0
      for (i <- start until n - 1) {
        time = math.max(time, s(i))

        val waitTime = if (time % f(i) == 0) 0 else f(i) - (time % f(i))
        time = time + waitTime

        time = time + c(i)
      }
      return time
    }

    for (i <- 0 until n) {
      println(calcTime(i))
    }
  }
}

Measured memory_bytes: 30000
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort(reverse=True)
Q.sort(reverse=True)

res = P[:X] + Q[:Y] + R
res.sort(reverse=True)

print(sum(res[:X+Y]))

Measured memory_bytes: 23200
package main
import "fmt"

func main() {
  var S string
  fmt.Scan(&S)

  a := 0
  b := 0
  c := 0

  for i := 0; i < 3; i++ {
    if string(S[i]) == "a" {
      a++
    } else if string(S[i]) == "b" {
      b++
    } else if string(S[i]) == "c" {
      c++
    }
  }

  if a == 1 && b == 1 && c == 1 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
  
}


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

const int maxn = 2005;
bitset<maxn*maxn/2> f;
int n, a, sum, cur;

int main() {
	scanf("%d", &n); f[0] = 1;
	for (int i=1; i<=n; i++) {
		scanf("%d", &a); sum += a;
		f = f | (f << a);
	}
	cur = (sum + 1) / 2;
	while (!f[cur]) cur++;
	printf("%d\n", cur);
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
//your code here!


int main(void){
    ll N, ans=1;
    in(N);
    rep(i,N){
        ans *= i+1;
        ans = ans%MOD;
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = []
    b = []
    for i in range(n):
        x,y = readInt()
        a.append(x)
        b.append(y)
    ans = 0
    for i in range(n-1,-1,-1):
        a[i] += ans
        if a[i]%b[i]!=0:
            x = a[i]//b[i]
            ans += (x+1)*b[i]-a[i]
    print(ans)
    return

if __name__=='__main__':
    main()


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

int dp[10][8][2], D[10]; // dp[i][j][k]: k=1 => last i digits less or equal than last i digits of N

int main()
{
    int N, C;
    cin >> N;
    C = N;
    dp[0][0][0] = dp[0][0][1] = 1;
    for (int i = 1; i < 8; i++) dp[0][i][0] = dp[0][i][1] = 0;
    for (int i = 1; i < 10; i++)
    {
        D[i] = C % 10;
        C /= 10;
    }
    for (int i = 1; i < 10; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            dp[i][j][0] = dp[i - 1][j & 3][0] + dp[i - 1][j & 5][0] + dp[i - 1][j & 6][0];
            if (D[i] > 7) dp[i][j][1] = dp[i][j][0];
            else if (D[i] == 7) dp[i][j][1] = dp[i - 1][j & 3][1] + dp[i - 1][j & 5][0] + dp[i - 1][j & 6][0];
            else if (D[i] > 5) dp[i][j][1] = dp[i - 1][j & 5][0] + dp[i - 1][j & 6][0];
            else if (D[i] == 5) dp[i][j][1] = dp[i - 1][j & 5][1] + dp[i - 1][j & 6][0];
            else if (D[i] > 3) dp[i][j][1] = dp[i - 1][j & 6][0];
            else if (D[i] == 3) dp[i][j][1] = dp[i - 1][j & 6][1];
            else dp[i][j][1] = 0;
        }
    }
    int res = 0, h = 1;
    for (int i = 1; i < 10; i++)
    {
        h *= 10;
        if (N >= h) res += dp[i][7][0];
        else res += dp[i][7][1];
    }
    cout << res << '\n';
    return(0);
}

Measured memory_bytes: 256