akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
	int n,k;
	cin>>n>>k;
	vi a(n);
	fi(n)cin>>a[i];
	double prod = 0;
	for(int i=0;i<k;i++)
		prod+=log(a[i]);
	double prev = prod;
	for(int i=k;i<n;i++)
	{
		prod +=log(a[i])-log(a[i-k]);
		if(prev<prod)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		prev = prod;
	}
	
}

int main()
{
	fastio;
	int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int s;
    cin >> s;
    int a = s;
    vector<int>vec({a});
    int ans = 1;
    while(true){
        ans += 1;
        if(a%2 == 0) a /= 2;
        else a = 3*a + 1;
        if(count(vec.begin(), vec.end(), a)) break;
        vec.push_back(a);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>v[1005];
int n,q,a,b,c;
int main(){
	cin>>n>>q;
	while(q--){
		cin>>a;
		if(a==0){
			cin>>b>>c;
			v[b].push_back(c);
		}else if(a==1){
			cin>>b;
			for(int i=0;i<v[b].size();i++)i>=1&&putchar(' '),cout<<v[b][i];
			cout<<"\n";
		}else cin>>b,v[b].clear();
	}
	return 0;
}



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

int main() {
  llong n;
  cin >> n;
  llong ans = 1e13;
  for (llong i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    llong j = n / i;
    ans = min(ans, i + j - 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
//Compiler version g++ 6.3.0

int main()
{
    int N;
    int ans = 0;
    float t, a;
    cin >> N >> t >> a;
    float y = 999999;
    for (int i = 0; i < N; i++) {
        float z = 0;
        cin >> z;
        z = a - t + z * 0.006;
        if (fabs(z) <= fabs(y)) {
            ans = i + 1;
            y=z;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
h = list(map(int,input().split()))
dic = {}
for i in range(len(h)):
    dic[i] = 0
for i in range(m):
    a, b = map(int,input().split())
    if h[a-1] > h[b-1]:
        dic[b-1] = 1
    elif h[a-1] < h[b-1]:
        dic[a-1] = 1
    elif h[a-1] == h[b-1]:
        dic[b-1] = 1
        dic[a-1] = 1
ans = 0
for i in range(len(h)):
    if dic[i] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 24572
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, _ : $t:tt $($r:tt)*) => {
            let _ = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        n : u64,
        a : u64,
        b : u64,
    }

    let c = a + b;
    let res = n / c * a + std::cmp::min(n % c, a);
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
	int i,cnt,cut;
	char a[10001]={0};
	while(scanf("%s",a)!=EOF){
		cnt=0,cut=0;
		for(i=2;a[i]!='\0';i++){
			if(a[i-2]=='J' && a[i-1]=='O' && a[i]=='I')cnt++;
			if(a[i-2]=='I' && a[i-1]=='O' && a[i]=='I')cut++;
		}
		printf("%d\n%d\n",cnt,cut);
	}
	return 0;
}


Measured memory_bytes: 2000
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i=0; i<n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};


int main(){
    int a,b,q; cin >> a >> b >> q;
    vector<long long> s(a+2),t(b+2),ans(q);
    s[0] = -1e15,s[a+1] = 1e15;
    t[0] = -1e15,t[b+1] = 1e15;
    for (int i = 1; i <= a; i++) cin >> s[i];
    for (int i = 1; i <= b; i++) cin >> t[i];

    //cout << "--------------" << endl;

    for (int i = 0; i < q; i++){
        long long x; cin >> x;
        int s2 = upper_bound(s.begin(), s.end(), x) - s.begin();
        int s1 = s2 - 1;
        int t2 = upper_bound(t.begin(), t.end(), x) - t.begin();
        int t1 = t2 - 1;   
        long long mn = 1e15;
        mn = min(mn, max(s[s2],t[t2]) - x);
        mn = min(mn, min(s[s2] - x + abs(s[s2]-t[t1]), abs(s[s2]-t[t1]) + x - t[t1]));
        mn = min(mn, min(t[t2]-x + abs(t[t2]-s[s1]) , x-s[s1] + abs(t[t2]-s[s1])));
        mn = min(mn, x - min(s[s1],t[t1]));
        ans[i] = mn;
    }
    for (auto i : ans){
        cout << i << endl;
    }
        
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M,K;
vector<pair<int,int> >G[2020];
int dp[2020],dq[2020];
int now[2020][2];
bool vis[2020];
main()
{
	cin>>N>>M>>K;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	for(int i=1;i<=K;i++)dp[i]=-1e9;
	for(int i=0;i<N;i++)if(!vis[i]&&G[i].size()<=1)
	{
		for(int j=0;j<=K;j++)now[j][0]=now[j][1]=-1e9;
		int k=1;
		now[0][0]=now[1][1]=0;
		int u=i,p=-1;
		vis[u]=true;
		while(true)
		{
			int v=-1,c;
			for(pair<int,int>e:G[u])if(e.first!=p)
			{
				v=e.first;
				c=e.second;
				break;
			}
			if(v<0)break;
			p=u;u=v;k++;
			vis[u]=true;
			for(int j=k-1;j>=0;j--)
			{
				if(c==0)
				{
					now[j+1][1]=max(now[j+1][1],now[j][0]);
					now[j][0]=max(now[j][0],now[j][1]);
					now[j][1]=-1e9;
				}
				else
				{
					now[j+1][1]=max(now[j+1][1],max(now[j][0],now[j][1]+c));
					now[j][0]=max(now[j][0],now[j][1]);
					now[j][1]=-1e9;
				}
			}
		}
		for(int j=K-1;j>=0;j--)for(int l=min(k,K-j);l>0;l--)dp[j+l]=max(dp[j+l],dp[j]+max(now[l][0],now[l][1]));
	}
	for(int i=0;i<N;i++)if(!vis[i])
	{
		for(int j=0;j<=K;j++)dq[j]=dp[j];
		for(int fst=0;fst<2;fst++)
		{
			for(int j=0;j<=K;j++)now[j][0]=now[j][1]=-1e9;
			int k=1;
			if(fst==0)now[0][0]=0;
			else now[1][1]=0;
			int u=i,p=G[i][0].first;
			vis[u]=true;
			while(true)
			{
				int v=-1,c;
				for(pair<int,int>e:G[u])if(e.first!=p)
				{
					v=e.first;
					c=e.second;
					break;
				}
				if(v==i)break;
				p=u;u=v;k++;
				vis[u]=true;
				for(int j=k-1;j>=0;j--)
				{
					if(c==0)
					{
						now[j+1][1]=max(now[j+1][1],now[j][0]);
						now[j][0]=max(now[j][0],now[j][1]);
						now[j][1]=-1e9;
					}
					else
					{
						now[j+1][1]=max(now[j+1][1],max(now[j][0],now[j][1]+c));
						now[j][0]=max(now[j][0],now[j][1]);
						now[j][1]=-1e9;
					}
				}
			}
			int c=G[i][0].second;
			for(int j=K-1;j>=0;j--)for(int l=min(k,K-j);l>0;l--)
			{
				if(fst==0)dq[j+l]=max(dq[j+l],dp[j]+max(now[l][0],now[l][1]));
				else
				{
					if(c==0)dq[j+l]=max(dq[j+l],dp[j]+now[l][0]);
					else dq[j+l]=max(dq[j+l],dp[j]+max(now[l][0],now[l][1]+c));
				}
			}
		}
		for(int j=0;j<=K;j++)dp[j]=dq[j];
	}
	int ans=dp[K];
	if(ans<-1e8)cout<<"Impossible"<<endl;
	else cout<<ans<<endl;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,K;
    cin >> N >> K;
    ll ans = 0;
    Rep(i, K+1, N+1){
        ans += (N/i)*(i-K);
        ans += max(0,(N%i+1)-K-(K==0?1:0));
    }
    pr(ans);
}

Measured memory_bytes: 3520
from math import gcd
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

N = int(input())
pp = defaultdict(int)
pn = defaultdict(int)
p_zero = 0
zero_p = 0
zero = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == b == 0:
        zero += 1
    elif a == 0:
        zero_p += 1
    elif b == 0:
        p_zero += 1
    elif a * b > 0:
        g = gcd(a, b)
        a = abs(a) // g
        b = abs(b) // g
        pp[(a, b)] += 1
    else:
        g = gcd(a, b)
        a = abs(a) // g
        b = abs(b) // g
        pn[(a, b)] += 1

checked = defaultdict(bool)
ans = 1

#(a,b), (c,d)
for (x, y), v in pp.items():
    checked[(x, y)] = True
    R = 0
    R += pow(2, v, mod) - 1
    R += pow(2, pn[(y, x)], mod) - 1
    R += 1
    ans = ans * R % mod

for (x, y), v in pn.items():
    if checked[(y, x)]:
        continue
    R = pow(2, v, mod)
    ans = ans * R % mod

#(0, x), (y, 0)
R = pow(2, zero_p, mod) - 1
R += pow(2, p_zero, mod) - 1
R += 1
ans = ans * R % mod

# (0,0)
ans = (ans + zero) % mod

# 空はダメ
ans = (ans - 1 + mod) % mod

print(ans)

Measured memory_bytes: 89492
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int a,b;
  cin >> a >> b;
 
  if( a%b == 0 ){
    
  cout << a/b << endl;
  
}
  
  else{
    
  cout << a/b + 1 << endl;
    
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int BIG_INT = 1000000000;
const ll BIG_NUM = 1000000000000000000;



int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = a * a + b * b + c * c - 2 * (a * b + b * c + c * a);
	cout << ((d > 0) && (c >= a + b) ? "Yes" : "No") << endl;

}




Measured memory_bytes: 256
#include<stdio.h>
int ggd(int, int);
int main(void){
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", ggd(x, y));
    return 0;
}
int ggd(int x, int y){
    int t, u, v;
    if(y > x){
        t = x; x = y; y = t;
    }
    if(x%y == 0){
        return y;
    }
    t = x % y;
    while(1){
        u = t;
        t = y % u;
        //printf("%d %d %d\n", y, t, u);
        if(t == 0){
            return u;
        }else if(t == 1){
            return 1;
        }
        y = u;
    }
} 


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

int main(){
	long n;
	cin >> n;
	vector<long> T(n + 1);
	for (long i = 1; i <= n; i++) cin >> T[i];
	for (long i = 1; i <= n; i++){
		cout << "node " << i << ": ";
		cout << "key = " << T[i] << ", ";
		if (i != 1){
			long parent = i / 2;
			cout << "parent key = " << T[parent] << ", ";
		}
		if (2 * i <= n) cout << "left key = " << T[2 * i] << ", ";
		if (2 * i + 1 <= n) cout << "right key = " << T[2 * i + 1] << ", ";
		cout << endl;
	}
	return 0;
}

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

int main()
{
  string S;
  cin >> S;
  
  int delta = 1000;
  for(int i = 0; i < S.length() - 2; ++i)
  {
    if(delta > abs(753 - stoi(S.substr(i, 3))))
    {
      delta = abs(753 - stoi(S.substr(i, 3)));
    }
  }
  
  cout << delta << endl;
  
  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

vector<vector<int>> G;
vector<pair<int, int>> es;
set<int> wvis;

void dfs(int curr, set<int>& vis, int unuse) {
  rep(i, G[curr].size()) {
    int next = G[curr][i];
    if (es[unuse].first == curr && es[unuse].second == next) { continue; }
    if (es[unuse].first == next && es[unuse].second == curr) { continue; }
    if (vis.count(next)) { continue; }
    vis.insert(next);
    wvis.insert(next);
    dfs(next, vis, unuse);
    vis.erase(next);
  }
}

int main() {
  int N; cin >> N;
  int M; cin >> M;
  G.resize(N);
  rep(i, M) {
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
    es.emplace_back(a, b);
  }

  int ans = 0;
  rep(i, M) {
    set<int> vis;
    wvis.clear();
    vis.insert(0);
    wvis.insert(0);
    dfs(0, vis, i);
    ans += wvis.size() != N;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 384
#[test]
fn test_solve() {
    assert_eq!(solve("3 3\n...\n...\n...\n"), "4\n");
    assert_eq!(solve("3 5\n...#.\n.#.#.\n.#...\n"), "10\n");
    assert_eq!(solve("1 2\n..\n"), "1\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let s: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();
    let mut nbr: Vec<Vec<(usize, i64)>> = vec![Vec::new(); h*w];
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                continue;
            }
            if i > 0 && s[i-1][j] == '.' {
                nbr[i*w+j].push(((i-1)*w+j, 1));
            }
            if i < h-1 && s[i+1][j] == '.' {
                nbr[i*w+j].push(((i+1)*w+j, 1));
            }
            if j > 0 && s[i][j-1] == '.' {
                nbr[i*w+j].push((i*w+(j-1), 1));
            }
            if j < w-1 && s[i][j+1] == '.' {
                nbr[i*w+j].push((i*w+(j+1), 1));
            }
        }
    }

    let d= shortest_dists(&nbr);

    let mut ans = 0;

    for i in 0..h*w {
        for j in 0..h*w {
            if i != j && d[i][j] > ans && d[i][j] <= 400 {
                ans = d[i][j]
            }
        }
    }

    format!("{}\n", ans)
}

fn shortest_dists(neighbor: &[Vec<(usize, i64)>]) -> Vec<Vec<i64>> {
    let n = neighbor.len();
    let mut d = vec![vec![i64::max_value() >> 1; n]; n];
    for v in 0..n {
        for &(w, c) in &neighbor[v] {
            d[v][w] = c;
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j])
            }
        }
    }
    d
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,D,X;
    cin>>N>>D>>X;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int ans = X;
    for(int i=0;i<N;i++){
        ans += (int)((D+A.at(i)-1)/A.at(i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    P,Q,R = map(int,input().split())

    if P+Q <= Q+R and P+Q <= R+P:
        print(P+Q)
    elif Q+R <= R+P and Q+R <= P+Q:
        print(Q+R)
    elif R+P <= P+Q and R+P <= Q+R:
        print(R+P)

resolve()

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

int main() {
    int n;
    cin >> n;
    int num = 100;
    vector<int> v(10005);
    for (int x = 1; x <= num; ++x) {
        for (int y = 1; y <= num; ++y) {
            for (int z = 1; z <= num; ++z) {
                ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if (tmp <= 10000) v[tmp]++;
            }
        }
    }
    for(int i = 1; i <= n; ++i) {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SIZE 200005
#define Z(x) (((x)>0)?(x):0)
#define INF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

int main(){
    int N,K;
    cin>>N>>K;
    if(N>=2*K-1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>

int main(){
	int n;
	std::cin>>n;
	int F=0;
	for(int i=0;i<n;++i){
		int a;
		std::cin>>a;
		F|=a;
	}
	int ans=0;
	while(~F&1){
		F>>=1;
		ans++;
	}
	std::cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    int N,K; cin >> N >> K;
    vector<ll> x(N), y(N);
    rep(i,N) cin >> x[i] >> y[i];

    ll ans = INF;

    rep(i,N){
        rep(j,N){
            rep(k,N){
                rep(l,N){
                    ll x1 = x[i];
                    ll x2 = x[j];
                    ll y1 = y[k];
                    ll y2 = y[l];
                    int count = 0;
                    rep(m,N){
                        if (x1 <= x[m] && x[m] <= x2 && y1 <= y[m] && y[m] <= y2){
                            count++;
                        }
                    }

                    if (count >= K){
                        ans = min(ans, abs(x1-x2)*abs(y1-y2));
                    }

                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n,x;
    int cnt = 0;
    bool flag = false;
    while (scanf("%d",&x)!=EOF) {
        if (flag)
            continue;
        cnt++;
        if (x==0) {
            flag = true;
            n = cnt;
        }
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,c,k,ans=0;
cin>>a>>b>>c>>k;
for (int i = 0; i < k; i++)
{
if (a>0)
{
         a--;
        ans++;
}
else if (b>0)
{
    b--;
}
else if (c>0)
{
    c--;
    ans--;
}
else
{
    continue;
}
 
}
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

long modinv(long a) {
    long  b = MOD, u = 1, v = 0;
    while (b) {
        long  t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

int main(){
    long N,M;
    cin>>N>>M;
    
    multiset<long> d;
    long divisor=2;
    while(M>1){
        while(M%divisor==0){
            M/=divisor;
            d.insert(divisor);
        }
        divisor++;
    }
    
    vector<long> kai(1000000);
    kai.at(0)=1;
    for(long i=1;i<1000000;i++) kai.at(i)=(kai.at(i-1)*i)%MOD;
    
    
    long ans=1;
    while(d.size()>0){
        auto ite=d.begin();
        long p=*ite,nump=d.count(p);
        ans*=(((kai.at(N-1+nump)*modinv(kai.at(N-1)))%MOD)*modinv(kai.at(nump)))%MOD;
        ans%=MOD;
        d.erase(p);
    }
    
    cout<<ans<<endl;
}

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

struct Edge {
    int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k = 1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u == p) continue;
        if (k == c) k++;
        ans[ei] = k; k++;
        dfs(u,ans[ei],v);
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    ans = vector<int>(n-1);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int mx = 0;
    rep(i,n) mx = max(mx, (int)g[i].size());
    cout << mx << endl;
    rep(i,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11084
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#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 = 1LL << 60;

int main(){
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll ans = max(A*C, A*D);
    ans = max(ans, B*C);
    ans = max(ans, B*D);
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int N, a, b, c, d;
   cin >> N;
   a = N / 1000;
   b = (N - 1000 * a) / 100;
   c = (N - 1000 * a - 100 * b) / 10;
   d = N - 1000 * a - 100 * b - 10 * c;
   if (a == b && b == c) {
     cout << "Yes" << endl;
   }
   else if (b == c && c == d) {
     cout << "Yes" << endl;
   }
   else {
     cout << "No" << endl;
   }
 }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
#define N 1000000007



int main(){
    string s,t;
    int i,n,l;
    n=0;
    cin>>s>>t;
    l=s.length();
    for(i=0;i<l;i++){
        if(s[i]!=t[i])
            n++;
    }
    cout<<n;
    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define flush fflush(stdout)
using namespace std;

#define N 100007

int n, a, b;

VI G[N];

int l[N];
bitset<N> vis;

void dfs(int v)
{
	vis[v] = 1;

	for(auto it:G[v])
	{
		if(!vis[it])
		{
			dfs(it);
			l[v] ^= (l[it]+1);
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i < n; ++i)
	{
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}

	dfs(1);

	if(l[1])
		cout << "Alice";
	else
		cout << "Bob";
}


Measured memory_bytes: 10880
import sys
range = xrange
input = raw_input
 
def main():
  n = int(input())
  A = [int(x) for x in input().split()]
  B = [int(x) for x in input().split()]

  DP = [0]*(n+1)
  DP[n] = n
  for j in range(3):
      sell = A[j]
      extra = B[j] - sell
      if extra > 0:
          for i in reversed(range(sell,len(DP))):
              if DP[i] + extra > DP[i - sell]:
                  DP[i-sell] = DP[i] + extra
  n = max(DP)
  A,B = B,A

  DP = [0]*(n+1)
  DP[n] = n
  for j in range(3):
      sell = A[j]
      extra = B[j] - sell
      if extra > 0:
          for i in reversed(range(sell,len(DP))):
              if DP[i] + extra > DP[i - sell]:
                  DP[i-sell] = DP[i] + extra

  print(max(DP))

main()

Measured memory_bytes: 227820
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
     
    ll n,m;
    cin>>n>>m;
    ll ans=(n*(n-1))/2;
    ans+=(m*(m-1)/2);
    cout<<ans;
}

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

const int maxn = 1e5 + 5;

int n, ans, cnt, root;
int tail[maxn], deg[maxn];
bool p[maxn];
struct edge
{
    int v, next;
}e[maxn << 1];

void ins(int u, int v)
{
    e[++cnt] = (edge){v, tail[u]};
    tail[u] = cnt;
}

void dfs(int u, int pa)
{
    int tot = deg[u] - (pa != 0);
    for(int i = tail[u]; i; i = e[i].next)
        if(e[i].v != pa)
        {
            dfs(e[i].v, u);
            p[u] |= p[e[i].v];
            tot -= p[e[i].v];
        }
    if(tot > 1)
    {
        ans += tot - 1;
        p[u] = 1;
    }
}

int main()
{
    int u, v;
    scanf("%d", &n);
    for(int i = 1; i < n; i++)
    {
        scanf("%d%d", &u, &v);
        u++, v++;
        ins(u, v);
        ins(v, u);
        deg[u]++, deg[v]++;
        if(deg[u] > 2)
            root = u;
        else if(deg[v] > 2)
            root = v;
    }
    if(!root)
        ans = 1;
    else
        dfs(root, 0);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4736
class NC:
  """ 整数計算 """

  @staticmethod
  def gcd(x, y, *z):
    """ 最大公約数 """

    from fractions import gcd as _gcd

    if z:
      from functools import reduce
      return reduce(_gcd, (x, y) + z)
    else:
      return _gcd(x, y)

    @staticmethod
    def lcm(x, y, *z):
      """ 最小公倍数 """

      from fractions import gcd as _gcd

      def _lcm(a, b):
        return a * b // _gcd(a, b)
      if z:
        from functools import reduce
        return reduce(_lcm, (x, y) + z)
      else:
        return _lcm(x, y)
          
def main():
  _ = int(input())
  ts = list(map(int, input().split()))
  nc = NC()
  g = nc.gcd(*ts)
  print(g)
main()

Measured memory_bytes: 14484
#include<stdio.h>
int main(void)
{
    int a,b,c,max=0;
    scanf("%i %i %i",&a,&b,&c);
    if(max<(a*10+b+c))max=a*10+b+c;
    if(max<(b*10+a+c))max=b*10+a+c;
    if(max<(c*10+b+a))max=c*10+a+b;
    printf("%i",max);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
#define PI 3.14159265
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  double ans = 0;
  rep(i,n){
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY"){
      ans+=x;
    }

    if (u == "BTC"){
      ans+=x * 380000.0;
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;
const double PI = 3.14159265359;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  double a, b, x; cin>>a>>b>>x;

  if (a*a*b/2 >= x) {
    double rad = atan(a*b*b/(2*x));
    double ans = (180*rad)/PI;
    print(ans);
  } else {
    double rad = atan(2*(a*a*b-x)/(a*a*a));
    double ans = (180*rad)/PI;
    print(ans);
  }

  return 0;
}

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

ll psum(std::vector<ll> S, int i, int j)
{
  return S[j+1] - S[i];
}



void print(vector<int> v[2])
{
  for(int i=0; i<(int)v[0].size(); i++)
  {
    cout << v[0][i] << " ";
  }
  cout << endl;
  for(int i=0; i<(int)v[1].size(); i++)
  {
    cout << v[1][i] << " ";
  }
  cout << endl;
}

int main()
{
  int n,k;
  cin >> n >> k;
  string S;
  cin >> S;
  std::vector<int> v[2];
  std::vector<ll> ASum;
  int tmp=1,cont=0;

  for(int i=0; i<n; i++)
  {
    int s = S[i]-'0';
    if(s==tmp){
      cont++;
    } else {
      v[tmp].push_back(cont);
      tmp = s;
      cont = 1;
    }
  }
  v[tmp].push_back(cont);
  if(tmp==0) v[1].push_back(0);

  std::vector<ll> psum[2];

  int div = (int)v[0].size();
  ll tmp0=0,tmp1=0;
  for(int i=0; i<div; i++)
  {
    psum[0].push_back(tmp0);
    psum[1].push_back(tmp1);
    tmp0+=v[0][i];
    tmp1+=v[1][i];
  }
  psum[0].push_back(tmp0);
  psum[1].push_back(tmp1);
  tmp1 += v[1][div];
  psum[1].push_back(tmp1);

  ll max=0;
  for(int i=0; i+k<=div; i++)
  {
    ll tmp = psum[0][i+k]-psum[0][i];
    tmp += psum[1][i+k+1]-psum[1][i];
    if(max<tmp) max = tmp;
  }
  if(max==0) cout << n << endl;
  else cout << max << endl;
  return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

const int MAX_N = 1e5 + 7;


void solve()
{
        string s; cin >> s;
        int res = INT_MAX;
        for (int i = 2; i < s.length(); ++i)
        {
                res = min(abs(res), abs(((s[i - 2] - '0') * 100) + ((s[i - 1] - '0') * 10) + (s[i] - '0') - 753));
                //cout << res << endl;
        }
        cout << res << endl; 
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


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

long long int N, M, d[364364], t[364364], i, j;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", d + i);
    }
    scanf("%lld", &M);
    for(i = 0; i < M; ++i){
        scanf("%lld", t + i);
    }
    sort(d, d + N);
    sort(t, t + M);
    //for(i = 0; i < N; ++i)cout << d[i] << " ";
    //cout << endl;
    //for(i = 0; i < M; ++i)cout << t[i] << " ";
    //cout << endl;
    for(i = 0; i < N && j < M; ++j, ++i){
        while(t[j] > d[i])++i;
        //cout << t[j] << " " << d[i] << " " << j << " " << i << endl;
        if(t[j] != d[i])return 0 & puts("NO");
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<string.h>

#define N 36

int main(){
  char bubble[N][3];
  int i,j,num,minj;
  char temp[3];
  char sel[N][3];
  int flag = 0;
  

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf(" %s",bubble[i]);
    strcpy(sel[i],bubble[i]);
  }
  
  //bubble
  for(i=0;i<=num-1;i++){
    for(j=num-1;j>=i+1;j--){
      if(bubble[j][1] < bubble[j-1][1]){
	strcpy(temp,bubble[j]);
	strcpy(bubble[j],bubble[j-1]);
	strcpy(bubble[j-1],temp);	
      }
    }
  }
  
  //selection
  for(i=0;i<=num-1;i++){
    minj = i;
    for(j=i;j<=num-1;j++){
      if(sel[j][1] < sel[minj][1]){
	minj = j;
      }
    }
    strcpy(temp,sel[minj]);
    strcpy(sel[minj],sel[i]);
    strcpy(sel[i],temp);
  }

  //bubble
  for(i=0;i<num;i++){
    if(i) printf(" ");
    printf("%s",bubble[i]);
  }
  printf("\n");
  printf("Stable\n");

  //selection
    for(i=0;i<num;i++){
    if(i) printf(" ");
    printf("%s",sel[i]);
  }
  printf("\n");
  for(i=0;i<num;i++){
    if(strcmp(sel[i],bubble[i]) != 0) flag = 1;
  }
  
  if(flag == 1) printf("Not stable\n");
  else if (flag == 0) printf("Stable\n");
 
  return 0;

}
  



Measured memory_bytes: 2848
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N, long long x, std::vector<long long> a){
    ll sum = 0;
    REP(i, N) sum+= a[i];
    sort(ALL(a));

    if(x > sum){
        cout << N-1<<endl;
        return;
    }

    ll cnt = 0;
    REP(i, N){
        if(x >= a[i]){
            x -= a[i];
            cnt++;
        }
        else{
            break;
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long x;
    scanf("%lld",&x);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, x, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  int a;
  int b[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin>>a;
  cout<<b[a-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= x; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define REPZ(i, x) for (int i = 0; i <= x; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
using namespace std;
#define DUMPOUT cerr
// vector
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  REP(i, (int)vec.size())
  os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
  os << "}";
  return os;
}
// map
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  FORA(itr, map_var) {
    os << *itr;
    itr++;
    if (itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  FORA(itr, set_var) {
    os << *itr;
    itr++;
    if (itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if (sizeof...(Tail) > 0) DUMPOUT << ", ";
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define DUMP(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define DUMP(...)
#endif

#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec<int> a(N);
  REP(i, N) cin >> a[i];
  int ans = 0;
  REP(i, N) {
    FOR(j, i + 1, N) { ans += a[i] * a[j]; }
  }
  print(ans);
}

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

int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }else if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
    }else{
        cout<<"Sunny"<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long n,a,b,tmp,ans=0;
  scanf("%lld%lld%lld", &n, &a, &b);
  
  tmp  = n / (a+b);
  ans += (tmp*a);
  
  tmp  = n % (a+b);
  if( tmp > a ){ ans += a; }
  else		   { ans += tmp; }
  
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
using namespace std;

int main() {
	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << 0 << endl;
	}
	else if (X >= A) {
		cout << 10 << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

signed main(){
    int H1,M1,H2,M2,K;

    cin>>H1>>M1>>H2>>M2>>K;

    int to=0;
    while(1){
        if(H1==H2&&M1==M2) break;
        to++;
        M1++;
        if(M1>=60){
            M1=0;
            H1++;
        }
        if(H1>=24) H1=0;
    }

    cout<<max(0ll,to-K)<<endl;
}



Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n,k;
	cin >> n >> k;
	vector<lld> a(n+1);
	for(int i = 0; i < n; i++)
	{
		lld x;
		cin >> x;
		a[x]++;
	}

	vector<lld> b;
	for(int i = 1; i <= n; i++)
	{
		if(a[i]!=0) b.push_back(a[i]);
	}

	sort(b.begin(),b.end(),greater<lld>());
	lld ans = accumulate(b.begin(),b.end(),(lld)0);
	for(int i = 0; i < min(k,(lld)b.size()); i++)
	{
		ans -= b[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3956
from copy import deepcopy
s=list(map(int,input()))
t=deepcopy(s)
if t[0]==1:
    t[0]=0
else:
    t[0]=1

cnt=0
rev_cnt=1

for i in range(1,len(s)):
    if s[i-1]==s[i]:
        if s[i]==0:
            s[i]=1
        else:
            s[i]=0
        cnt+=1

for i in range(1,len(t)):
    if t[i-1]==t[i]:
        if t[i]==0:
            t[i]=1
        else:
            t[i]=0
        rev_cnt+=1

print(min(cnt, rev_cnt))

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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;
}

void solve()
{
  string S, T;
  cin >> S >> T;

  if (S.length() > 10)
  {
    cout << "No" << endl;
  }
  else
  {
    bool flag = true;
    rep(i, 0, S.length())
    {
      if (S[i] != T[i])
      {
        flag = false;
      }
    }
    if (flag == false)
    {
      cout << "No" << endl;
    }
    else
    {
      if (T.length() != S.length() + 1)
      {
        cout << "No" << endl;
      }
      else
      {
        cout << "Yes" << endl;
      }
    }
  }
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 3612
S = input()
cnt = 0
for i in range(3):
    if S[i] == 'R':
        # count, 前の文字列がR or nullならcnt+1、そうでない場合、1
        if i == 0 or S[i - 1] == 'R':
            cnt += 1
        else:
            cnt = 1
print(cnt)


Measured memory_bytes: 9092