akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n, d; cin >> n >> d;
    int tmp = 2*d+1;
    cout << (n+tmp-1)/tmp << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7748
package main

import "fmt"

func main() {
	var k, q int
	fmt.Scan(&k, &q)

	d := make([]int, k)
	for i := 0; i < k; i++ {
		fmt.Scan(&d[i])
	}

	for i := 0; i < q; i++ {
		var n, x, m int
		fmt.Scan(&n, &x, &m)

		q := (n - 1) / k
		r := (n - 1) % k
		nz := 0
		al := x

		for j := 0; j < k; j++ {
			md := d[j] % m
			if md == 0 {
				nz += q
				if j < r {
					nz++
				}
			} else {
				al += q * md
				if j < r {
					al += md
				}
			}
		}

		ret := (n - 1) - nz - (al/m - x/m)
		fmt.Println(ret)
	}
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
//#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)   int x; cin>>x; while(x--)

const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}


int32_t main()
{
	very_fast();
	//no_of_test(x)
	{
		int a, b;
		cin >> a >> b;
		if (b % 2 == 0)
		{
			if (b >= 2 * a && b <= 4 * a)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}
	return 0;
}





Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>

using namespace std;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int a[105];
        for(int i=0; i<n; i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int x=a[0],y=a[n-1];
        int s=0;
        for(int i=x; i<=y; i++)
        {
            int s0=0;
            for(int j=0; j<n; j++)
                s0+=(a[j]-i)*(a[j]-i);
            if(i==x)
                s=s0;
            if(s>s0)
                s=s0;
        }
        printf("%d\n",s);
    }
    return 0;
}

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

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("avia.in", "r", stdin); freopen("avia.out", "w", stdout);
#define _GLIBCXX_DEBUG
#define s second
#define f first
#define pb push_back
#define add insert
#define del erase
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define res resize
#define PI acos(-1)
const ll INF = 1e9;//9223372036854775807L; //LONG_MAX;
constexpr ll mod = 1e9 + 7;


void solve() {
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b)<<'\n';
}

signed main() {
    ioss
    //file
    //id.resize(3e5);
    int t = 1;                                                                                                                                                                        //ll
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int D=scanner.nextInt();
        long G=scanner.nextLong();
        int[] p=new int[D];
        int[] c=new int[D];
        for(int i=0;i<D;i++){
            p[i]=scanner.nextInt();
            c[i]=scanner.nextInt();
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<(1<<D);i++){
            //System.out.println("---"+i);
            int tmpResult=0;
            int sum=0;
            List<Integer> costs=new ArrayList<>();
            for(int j=0;j<D;j++){
                if((i>>(D-j-1))%2!=0){
                    sum+=(j+1)*100*p[j]+c[j];
                    tmpResult+=p[j];
                }else{
                    for(int k=0;k<p[j]-1;k++){
                        costs.add((j+1)*100);
                    }
                }
            }
            Collections.sort(costs);
            //System.out.println("sum="+sum);
            //System.out.println(costs);
            boolean flag=false;
            while(sum<G){
                if(costs.size()==0){
                    flag=true;
                    break;
                }
                sum+=costs.get(costs.size()-1);
                costs.remove(costs.size()-1);
                tmpResult++;
            }
            if(flag) continue;
            if(ans>tmpResult){
                ans=tmpResult;
            }

        }
        System.out.println(ans);

    }
}


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

int main() {
  long N, A, B;
  cin >> N >> A >> B;
  vector<long> X(N);
  for (long i = 0; i < N; i++) cin >> X.at(i);
  long tmp = X.at(0);
  for (long i = 0; i < N; i++) X.at(i) -= tmp;
  long ans = 0;
  for (long i = 0; i + 1 < N; i++) {
    if ((X.at(i + 1) - X.at(i)) * A > B) ans += B;
    else ans += (X.at(i + 1) - X.at(i)) * A;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
from collections import deque
import sys
input = sys.stdin.readline

n, q = map(int, input().split())

graph = [deque() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

counter = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

stack = [0]
seen = [0]*n
seen[0] = 1
while True:
    rute = stack[-1]
    if graph[rute]:
        leaf = graph[rute].popleft()
        if seen[leaf] == 0:
            seen[leaf] = 1
            counter[leaf] += counter[rute]
            stack.append(leaf)
    else:
        stack.pop()
    if not stack:
        break

print(' '.join(map(str, counter)))


Measured memory_bytes: 166708
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			100011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}

ll a[M];



int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    lp(1,n)cin>>a[i];
    p=0;
    k=0;
    lp(2,n){if(a[i]<0)++p;}
    lp(2,n)a[i]=abs(a[i]);
    if(p%2)a[1]*=-1;
    ll ans=0;
    	ll mx=inf;
    if(a[1]<0){
    	a[1]*=-1;
    	lp(1,n)mx=min(mx,a[i]);
    }
    // trace(mx);
    lp(1,n)ans+=a[i];
    if(mx==inf)cout<<ans<<"\n";
    else cout<<ans-2*mx<<"\n";




    	






    

}



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

const int INF = (1<<31)-1, MAX = 1<<17;

int n, D[2*MAX-1];

void init( int n_ )
{
    n = 1;
    while( n < n_ )
        n *= 2;

    for(int i=0; i < 2*n-1; i++)
        D[i] = INF;

    return;
}


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


int query(int a, int b, int k, int l, int r){
    if( r <= a || b <= l ){
        return INF;
    }
    if( a <= l && r <= b ){
        return D[k];
    }else{
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

int findMin(int a, int b){
  return query(a, b+1, 0, 0, n);
}

int main(void){
    int p, q;

    cin >> p >> q;
    init(p);

    for(int i=0; i<q; i++){
        long long com, x, y;
        cin >> com >> x >> y;

        if(com == 0){
            update(x, y);
        }else{
            cout << findMin(x,y) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4088
k = gets.to_i
 
dp = Array.new(k,46)
dp[1] = 1
deq = [1]
 
v = 0
loop  do
  
  break if deq[0] == 0 
  
  v = deq[0]
  
  deq.shift
  u = ( v * 10 ) % k
  if dp[u] > dp[v] then
    dp[u] = dp[v]
    deq.unshift(u)
  end
  
  u = ( v + 1 ) % k
  if dp[u] > dp[v] + 1 then
    dp[u] = dp[v] + 1
    deq.push(u)
  end
end
 
puts dp[0]

Measured memory_bytes: 3836
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

long pow(long a, long e, long m) {
    long r = 1;
    long t1, t2;
    while(e != 0) {
        if(e%2 == 1) r = (r*a)%m;
        e /= 2;
        a = (a*a)%m;
    }
    return r;
}


void euclid(long a, long b, long *s, long *t) {
    if(a==0) {
        *s = 0;
        *t = 1;
        return;
    }
    if(b==0) {
        *s = 1;
        *t = 0;
        return;
    }
    if(a>b) {
        euclid(a%b, b, s, t);
        *t -= a/b*(*s);
        return;
    }
    euclid(a, b%a, s, t);
    *s -= b/a*(*t);
    return;
}


long inv(long n, long m) {
    long s,t;
    euclid(n, m, &s, &t);
    return s%m;
}


int main(void){

    

    long n,m,k;
    cin >>n>>m>>k;
    long ans;
    long mod = 998244353;


    long c = 1;
    long sum = (m*pow(m-1,n-1,mod))%mod;
    for(int i = 1; i <=k; i++) {
        c = (((c*(n-i))%mod)*inv(i,mod))%mod;
        sum = sum+((c*m)%mod)*pow(m-1,n-1-i,mod);
        sum = sum%mod;
    }



    cout<< (sum+mod)%mod;


    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;
int N,K;
const int MOD = (1e9) + 7;
vector<int> G[200005];
struct data{
   int first,second,third;
};
deque<data> dp[200005];
int pw2[200005];
int lvl[200005];
int nrlvl[200005];
int adun(int a,int b){
   a += b;
   if(a >= MOD){
      a -= MOD;
   }
   return a;
}
int scad(int a,int b){
   a -= b;
   if(a < 0){
      a += MOD;
   }
   return a;
}
int mult(int a,int b){
   return 1LL * a * b % MOD;
}
void dfs(int nod){
   nrlvl[lvl[nod]]++;
   int bigChild = -1,mx = -1;
   for(auto it:G[nod]){
      lvl[it] = 1 + lvl[nod];
      dfs(it);
      if((int)dp[it].size() > mx){
         mx = (int)dp[it].size();
         bigChild = it;
      }
   }
   if(bigChild != -1){
      swap(dp[nod],dp[bigChild]);
   }
   mx = -1;
   for(auto it:G[nod]){
      if(it == bigChild){
         continue;
      }
      mx = max(mx,(int)dp[it].size());
      for(int j = 0;j < (int)dp[it].size();j++){
         int new1 = 0,new2 = 0,new3 = 0;
         new1 = mult(dp[nod][j].first,dp[it][j].first);
         new2 = adun( mult(dp[nod][j].second,dp[it][j].first) , mult(dp[nod][j].first,dp[it][j].second) );
         new3 = adun( mult(dp[nod][j].third,dp[it][j].first + dp[it][j].second + dp[it][j].third) , adun( mult(dp[nod][j].second,dp[it][j].second + dp[it][j].third) , mult(dp[nod][j].first,dp[it][j].third) ) );
         dp[nod][j] = {new1,new2,new3};
      }
   }
   dp[nod].push_front({1,1,0});
   for(int j = 0;j <= mx;j++){
      dp[nod][j].first = adun( dp[nod][j].first , dp[nod][j].third );
      dp[nod][j].third = 0;
   }
}
int main() {
    cin >> N;N++;
    pw2[0] = 1;
    for(int i = 1;i <= N;i++){
       pw2[i] = adun(pw2[i - 1] , pw2[i - 1]);
    }
    for(int i = 2;i <= N;i++){
       int a;
       cin >> a;
       a ++;
       G[a].push_back(i);
    }
    dfs(1);
    int rez = 0;
    for(int i = 0;i < (int)dp[1].size();i++){
       rez = adun(rez,mult(dp[1][i].second,pw2[N - nrlvl[i]]));
       cerr << i << " " << dp[1][i].first << " " << dp[1][i].second << " "  << dp[1][i].third << "\n";
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 238580
//BISMILLAHIR RAHMANIR RAHIM
                                               //BY THE NAME OF ALLAH
                                               //FAISAL AHAMMED SHAWON
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<set>
#include<map>
#include<iterator>
#include<numeric>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define SQ(a) (a)*(a)
#define pi acos(-1.0)
const int MAX=1000001;
const int MOD=1e9+7;
typedef long long ll;
typedef unsigned long long ull;
ll ara[MAX],n,m;
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

bool f(ll a,ll b)
{
    return a>b;
}
ll max_sum_subarrays(ll ara[],ll n)
{
    ll ans=0,sum=0;
    for(ll k=0;k<n;k++){
        sum=max(ara[k],sum+ara[k]);
        ans=max(ans,sum);
    }
    return ans;
}
ll num_divisors(ll n)
{
    long long cnt=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0 && i*i==n)
            cnt+=1;
        if(n%i==0 && i*i!=n)
                cnt+=2;
    }
    return cnt;
}
ll comb(ll m, ll n)
{
    ll x = max(m-n,n),ans = 1,i=1;
    for(ll k=m;k>=x+1;k--){
        ans*=k;
        ans/=i;
        i++;
    }
    return ans;
}
bool binsearch(ll mid,ll target)
{
   ll collected=0;

   for(ll i=0;i<n;i++)
   {
       if(ara[i]>=mid)
         collected+=(ara[i]-mid);
   }
   if(collected>=target)
    return true;
   else
   return false;

}
void solve()
{
    string s;
    cin>>s;
    int l;
    l=s.size();
    if(s[l-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }
}
int main()
{
    fast();
    solve();
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll a, b, c, k; cin >> a >> b >> c >> k;
	ll ans = 0;
	
	{ ll g = min(a, k); a -= g; k -= g; ans += g; }
	{ ll g = min(b, k); b -= g; k -= g; ans += 0; }
	{ ll g = min(c, k); c -= g; k -= g; ans -= g; }

	cout << ans << endl;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll arr[1009],sum,cnt=0,mx=0,f=0,n;
    //int f=0,n;
    scanf("%lld",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&arr[i]);
    }
    for(int i=0; i<n-1; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            f=0;
            sum=arr[i]*arr[j];
           // cout<<sum<<" 11"<<endl;
           ll sum1=sum;
           ll val1=sum%10;

           sum=sum/10;
            while(sum!=0)
            {
                ll val=sum%10;
                if(val+1!=val1)
                {
                    f=1;
                    break;
                }
                val1=val;
                //cout<<val<<endl;
                //in[cnt++]=val;
                sum=sum/10;
            }
            if(f==0)
            {
                mx=max(mx,sum1);
            }
        }
    }
    if(mx==0)
        printf("-1\n");
    else
        printf("%lld\n",mx);

    return 0;
}

Measured memory_bytes: 3240
#include <iostream>
using namespace std;
int main() {
    int D, G, p[11], c[11];
    cin >> D >> G;
    for (int i = 0; i < D; ++i) {
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;
    for (int mask = 0; mask < (1 << D); ++mask) {
        int s = 0, num = 0, rest_max = -1;
        for (int i = 0; i < D; ++i) {
            if (mask >> i & 1) {
                s += 100 * (i + 1) * p[i] + c[i];
                num += p[i];
            } else {
                rest_max = i;
            }
        }
        if (s < G) {
            int s1   = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if (need >= p[rest_max]) {
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}


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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(N);
    ll ans = 0;
    rep(i,N){
        scanf("%d",&a[i]);
        ans += a[i];
    }
    
    vector<int> x;
    for (int i = 0; i < N; i++)
    {
        while(a[i] >=1){
            int X = a[i]%2;
            a[i] /= 2;
            x.push_back(a[i] + X);
        }
    }
    sort(x.begin(),x.end(),greater<int>());
    for (int i = 0; i < M; i++)
    {
        ans -= x[i];
        if(ans < 0){
            ans = 0; break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18792
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	string s;
	cin >> s;
	int count = 0, count2 = 0;;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] != '0') {
				count++;
			}
		}
		else {
			if (s[i] != '1') {
				count++;
			}
		}
	}
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] != '1') {
				count2++;
			}
		}
		else {
			if (s[i] != '0') {
				count2++;
			}
		}
	}
	cout << min(count, count2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m;
	while(cin>>m,m){
    	int c[]={1,5,10,50,100,500};
    	m=1000-m;
    	int ans=0;
    	for(int i=5;i>=0;i--){
    		ans+=m/c[i];
    		m%=c[i];
    	}
    	cout<<ans<<endl;
	}
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inps(n, m);
    out(ceil(1.0*n/m));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long ll[87];
int main(void) {
    int n;
    cin >> n;
    ll[0]=2;
    ll[1]=1;
    for (int i=2;i<=n;i++) {
        ll[i]=ll[i-2]+ll[i-1];
    }
    cout << ll[n] << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<ll> d(N);
	rep(i,N) cin >> d[i];

	ll ans = 0;
	rep(i,N) {
		for (int j = i+1; j < N; ++j) {
			ans += d[i]*d[j];
		}
	}

	cout << ans << ln;
}


Measured memory_bytes: 256
#=
A:
- Julia version:
- Author: abap
- Date: 2020-01-12
=#
A = "abcdefghijklmnopqrstuvwxyz"
C = (chomp(readline()))
C = C[1]

for i in 1:26
  s = A[i]
  if C == s
    println(A[i+1])
    end
end


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

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

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class DSumOfDivisors {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    int ans = 0;
    vector<int> num(N + 1);
    rep(i, N) {
      rep(j, INF) {
        if ((i + 1) * (j + 1) - 1 >= N) break;
        num[(i + 1) * (j + 1) - 1]++;
      }
      ans += (i + 1) * num[i];
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DSumOfDivisors solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 81336
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> xs(n);
  for(int i=0;i<n;i++) cin>>xs[i];

  using M = Mint<int>;
  M ans{1};
  int cnt=0;
  for(int i=0;i<n;i++){
    if(cnt*2+1<=xs[i]){
      cnt++;
      continue;
    }
    ans*=M(cnt+1);
  }
  while(cnt) ans*=M(cnt--);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
s=list(input())
 
if( s[0] == s[1] and s[1] == s[2] and s[2] == s[3] ):
  print('No')
elif(( s[0]==s[1] and s[2]==s[3] )or( s[0]==s[2] and s[1]==s[3] )or( s[0]==s[3] and s[1]==s[2] )):
    print('Yes')
else:
    print('No')
   

Measured memory_bytes: 3064
from itertools import combinations


def dist(i, j):
    return ((i[0]-j[0])**2+(i[1]-j[1])**2)**0.5


n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
l = combinations([i for i in range(n)], 2)
length = [dist(xy[i], xy[j]) for i, j in l]

print(2*sum(length)/n)


Measured memory_bytes: 3188
import bisect
INF=10**18
n,*a=map(int,input().split())
l=[int(input()) for _ in range(n)]
ans=INF
for i in range(4**n):
  x=[[] for _ in range(3)]
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:x[0].append(l[j])
    if not (i>>2*j)&1 and (i>>2*j+1)&1:x[1].append(l[j])
    if (i>>2*j)&1 and (i>>2*j+1)&1:x[2].append(l[j])
  cnt=0
  for j in range(3):
    if len(x[j])==0:cnt=INF
    cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j])
  ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 74148
#include <iostream>
#include <algorithm>
#include <cmath>

int n, r;
int ch[3];

void solve() {
    double a, b, c;
    a = pow(ch[0], 2);
    b = pow(ch[1], 2);
    c = pow(2*r,   2);

    if (a+b < c) {
        std::cout << "OK" << std::endl;
    } else {
        std::cout << "NA" << std::endl;
    }
}

int main() {
    while (true) {
        for (int i=0; i<3; i++) std::cin >> ch[i];
        
        if (!ch[0] && !ch[1] && !ch[2]) break;
        
        std::sort(ch, ch+3);

        std::cin >> n;
        
        for (int i=0; i<n; i++) {
            std::cin >> r;
            solve();
        }
    }
}



Measured memory_bytes: 3148
#include <cstdio>
#include<cstring>
int main(){
    char s[200000];
    scanf("%s",s);
    int len=strlen(s);
    int sum=0;
    for(int i=0;i<len;i++) sum+=s[i]-'0';
    if(sum%9==0){
        puts("Yes");
    }else{
        puts("No");
    }
}

/*
#include <iostream>
int64_t mul_9(int64_t n){
    int64_t sum=0;
    //std::cin >> n;
    while(n!=0){
        sum=sum+n%10;
        std::cout <<" "<<sum<<std::endl;
        n=n/10;
        std::cout <<" "<<n<<std::endl;
    }
    
    return sum;
}
int main(){
    int64_t n,sum;
    std::cin >> n;
    sum=mul_9(n);
    //std::cout <<sum<<std::endl;
    if(sum%9==0){
        std::cout <<"Yes"<<std::endl;
    }else{
        std::cout <<"No" <<std::endl;
    }
    return 0;
}
*/

Measured memory_bytes: 1804
N,x = [int(i) for i in input().split(' ')]

a = [int (i) for i in input().split(' ')]
ans =0
if a[0] > x:
    ans += a[0]-x
    a[0]=x
for i in range(N-1):
    if a[i]+a[i+1] > x:
        ans += (a[i]+a[i+1])-x
        a[i+1] -= (a[i]+a[i+1])-x

print(ans)


Measured memory_bytes: 14252
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long a, b;
  int lcm, rem;
  scanf("%ld %ld", &a, &b);
  long x = a * b;
  if (a < b) {
    swap(a, b);
  }
  rem = a % b;
  while (rem != 0) {
	a = b;
    b = rem;
    rem = a % b;
  }
  rem = b;
  cout << x / rem << endl;
  return 0; 
}

Measured memory_bytes: 256
N = int(input())
p = [int(x) for x in input().split()]
p_test = p
Flag = False

for i in range(N-1) :
    for j in range(i,N) :
        p[i],p[j] = p[j],p[i]
        if p == sorted(p) :
            Flag = True 
            break
        p[i],p[j] = p[j],p[i]
    if Flag == True :
        break

if Flag == True :
    print('YES')
else :
    print('NO')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String S = in.next();
        int[] face = new int[N];
        for(int i=0;i<N;i++){
            if(S.charAt(i)=='W') face[i]=1;
            else face[i] = 0;
        }
        int[] sum = new int[N];
        sum[0]=face[0];
        for(int i=1;i<N;i++){
            sum[i]=sum[i-1]+face[i];
        }
        int result = N-1-(sum[N-1]-sum[0]); // attention to the far left
        for(int i=1;i<N-1;i++){
            int left = sum[i-1]; // the i-1 people on the left attention to east
            int right = (N-1-i) -(sum[N-1]-sum[i]); // the N-i-1 people the the right attention to west
            result = Math.min(result,left+right);
        }
        result = Math.min(result, sum[N-2]); // attention to far right

        System.out.println(result);

    }
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct btinfo {
	int pa, pb, pc;
};

bool dp[100005][8][8][8];
btinfo bt[100005][8][8][8];
char op[100005][8][8][8];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, a, b, c; cin >> n >> a >> b >> c;
	a = min(a, 7);
	b = min(b, 7);
	c = min(c, 7);

	dp[0][a][b][c] = 1;

	rep(i, 1, n + 1) {
		string s; cin >> s;
		rep(aa, 0, 8) rep(bb, 0, 8) rep(cc, 0, 8) if (dp[i - 1][aa][bb][cc]) {
			//printf("%d : %d %d %d\n", i - 1, aa, bb, cc);
			if (s == "AB") {
				if (aa) {
					dp[i][aa - 1][min(bb + 1, 7)][cc] = 1;
					bt[i][aa - 1][min(bb + 1, 7)][cc] = {aa, bb, cc};
					op[i][aa - 1][min(bb + 1, 7)][cc] = 'B';
				}
				if (bb) {
					dp[i][min(aa + 1, 7)][bb - 1][cc] = 1;
					bt[i][min(aa + 1, 7)][bb - 1][cc] = {aa, bb, cc};
					op[i][min(aa + 1, 7)][bb - 1][cc] = 'A';
				}
			} else if (s == "AC") {
				if (aa) {
					dp[i][aa - 1][bb][min(cc + 1, 7)] = 1;
					bt[i][aa - 1][bb][min(cc + 1, 7)] = {aa, bb, cc};
					op[i][aa - 1][bb][min(cc + 1, 7)] = 'C';
				}
				if (cc) {
					dp[i][min(aa + 1, 7)][bb][cc - 1] = 1;
					bt[i][min(aa + 1, 7)][bb][cc - 1] = {aa, bb, cc};
					op[i][min(aa + 1, 7)][bb][cc - 1] = 'A';
				}
			} else if (s == "BC") {
				if (bb) {
					dp[i][aa][bb - 1][min(cc + 1, 7)] = 1;
					bt[i][aa][bb - 1][min(cc + 1, 7)] = {aa, bb, cc};
					op[i][aa][bb - 1][min(cc + 1, 7)] = 'C';
				}
				if (cc) {
					dp[i][aa][min(bb + 1, 7)][cc - 1] = 1;
					bt[i][aa][min(bb + 1, 7)][cc - 1] = {aa, bb, cc};
					op[i][aa][min(bb + 1, 7)][cc - 1] = 'B';
				}
			}
		}
	}

	rep(i, 0, 8) rep(j, 0, 8) rep(k, 0, 8) if (dp[n][i][j][k]) {
		cout << "Yes" << endl;
		int s = n, a = i, b = j, c = k;
		string st;

		while (s >= 1) {
			st.push_back(op[s][a][b][c]);
			btinfo bb = bt[s][a][b][c];
			s--;
			a = bb.pa, b = bb.pb, c = bb.pc;
		}

		reverse(all(st));
		
		for (char c : st) cout << c << endl;

		return 0;
	}

	cout << "No" << endl;
}


Measured memory_bytes: 703792
#include <stdio.h>
int n, r, p, c, d[50], e[50];
int main() {
	while (true) {
		scanf("%d%d", &n, &r);
		if (n == 0 && r == 0) break;
		for (int i = 0; i < n; i++) d[i] = n - i;
		for (int i = 0; i < r; i++) {
			scanf("%d%d", &p, &c); p--;
			for (int j = 0; j < c; j++) {
				e[j] = d[j + p];
			}
			for (int j = c; j < p + c; j++) {
				e[j] = d[j - c];
			}
			for (int j = 0; j < p + c; j++) {
				d[j] = e[j];
			}
		}
		printf("%d\n", d[0]);
	}
	return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
    // 整数の入力
    int n;
    cin >> n;
    // スペース区切りの整数の入力
    int d;
  cin >> d;
  int data[n][d];
  int a;
  for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
    cin >> a;
    data[i][j] = a;
  	}  
  }
  
  
  int count = 0;
  for(int i = 0;i< n ;i++){
      for(int j = i+1;j<n;j++){
           int sum =0;
         for(int m = 0;m<d;m++){
    sum += (data[i][m] - data[j][m])*(data[i][m] - data[j][m]);
         }
        
   
      
    bool flag = false;
 	for (int k = 0; k <= sum; ++k) {
 	if (k * k == sum) {
 	flag = true;
	 }
	}
if (flag) ++count;
  }
  }
  cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    int N, M;
    cin>>N>>M;
    vector<int> S(M), C(M);  
    vector<int> K(N, -1);
    bool OK=true;
    rep(i, M){
        cin>>S[i]>>C[i];
        S[i]--;
        if(K[S[i]]==-1){
            K[S[i]]=C[i];
        }
        else{
            if(K[S[i]]!=C[i]){
                OK=false;
            }
        }
    }
  	if(M==0){
      	if(N==1)cout<<0<<endl;
      	if(N==2)cout<<10<<endl;
      	if(N==3)cout<<100<<endl;
      	return 0;
    }
    if(!OK){
        cout<<-1<<endl;
        return 0;
    }

    if(K[0]==0){
        if(N==1){
            cout<<0<<endl;
        return 0;
        }
        cout<<-1<<endl;
        return 0;
    }

    rep(i, N){
        if(K[i]==-1){
            cout<<(i==0?1:0);
        }
        else{
            
            cout<<K[i];
        }
    }
    cout<<endl;
    return 0;

}



Measured memory_bytes: 256
#include<stdio.h>
int cnt[32];
int main() {
	int N, M, K;
	int A[32];
	int ans = 0;
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &K);
		for (int i = 0; i < K; i++)
		{
			scanf("%d", &A[i]);
			cnt[A[i]]++;
		}
	}

	for (int i = 0; i <= M; i++)
	{
		if (cnt[i] == N)
		{
			ans++;
		}

	}
	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923
vi exist(1000005, 0);

int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, h, u, v, x, y, t = 0;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string s; 

    time_t tic, toc;
    tic = clock();

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        vi arr(n);
        loop(z, arr) cin >> z;
        sort(arr.B, arr.E);

        if(n == 1){
            cout << 1 << nl;
        }
        else{
            for(i = 0; i < n; i++){
                exist[arr[i]]++;
            }
            ans = 0;
            for(i = 0; i < n; i++){
                exist[arr[i]]--;

                poss = true;
                for(j = 1; j*j <= arr[i] and poss; j++){
                    if(arr[i]%j == 0){
                        if(exist[j] or exist[arr[i]/j]){
                            poss = false;
                            break;
                        }
                    }
                }
                exist[arr[i]]++;
                if(poss) ans++;
            }

            cout << ans << nl;
        }

    }   
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

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

int flag[1000000];

int main(void)
{
	int a, L;
	int num[10];
	int max, min;
	int cnt;
	int i, j;
	int k;
	
	while (1){
		scanf("%d%d", &a, &L);
		if (a == 0 && L == 0){
			break;
		}
		
		memset(flag, -1, sizeof(flag));
		
		cnt = 0;
		do {
			flag[a] = cnt++;
			
			memset(num, 0, sizeof(num));
			for (i = 0; i < L; i++){
				num[a % 10]++;
				a /= 10;
			}
			
			max = 0;
			for (i = 9; i >= 0; i--){
				for (j = 0; j < num[i]; j++){
					max = max * 10 + i;
				}
			}
			
			min = 0;
			for (i = 0; i <= 9; i++){
				for (j = 0; j < num[i]; j++){
					min = min * 10 + i;
				}
			}
			
			a = max - min;
// printf("%d - %d = %d(%d)\n", max, min, a, cnt);

		} while (flag[a] == -1);
		printf("%d %d %d\n", flag[a], a, cnt - flag[a]);
	}
	
	return (0);
}

Measured memory_bytes: 4512
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int a[N], max=-1, min=1001;
    for(int i=0; i<N; i++){
        scanf("%d", &a[i]);
        if(a[i]>max){
            max=a[i];
        }
        if(a[i]<min){
            min=a[i];
        }
    }
    
    printf("%d", max-min);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int a;double b;
	cin>>a>>b;
	
	
	int p=round(b*100);
	
	int q=a*p;
	q/=100;
	
	
	cout<<(int)q<<endl;
	
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 3700
N,M,X =map(int,input().split())
A =[]
for m in range(N):
    A.append([int(j) for j in input().split()])
ans = 10**10
import numpy as np
from itertools import product,compress
for i in list(product([True,False],repeat=N)):
    tmp = np.sum(list(compress(A, i)),axis=0)
    if type(tmp)!=np.float64:
    	if tmp[0]< ans and min(tmp[1:])>=X:
            ans =tmp[0]
if ans ==10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27432
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    map<int, int> m;
    rep(i,0,N) {
        int p; cin >> p;
        m[p]++;
    }

    vector<int> v;
    for(auto x : m) {
        if(x.second >= 2) {
            int val = x.second / 2;
            rep(i,0,val) v.push_back(x.first);
        }
    }
    sort(v.begin(), v.end(), greater<int>());

    if(v.size() < 2) cout << 0 << endl;
    else cout << v[0] * v[1] << endl;
    return 0;
}

Measured memory_bytes: 6528
n = int(input())

for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-n*i-n*j) != 0:
            w = i*j*n/(4*i*j-n*i-n*j)
            if w%1 == 0 and w > 0:
                print(i,j,int(w))
                exit()

Measured memory_bytes: 67996
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    for(int i = 0; i<=K; i++){
        for(int j=0 ;j <=K-i;j++){
            for(int k = 0; k <= K-i-j; k++){
                double r = A* pow(2,i);
                double g = B *pow(2,j);
                double b = C *pow(2,k);
                if(i+j+k > K)continue;

                if(i == 0) r =A;
                if(j == 0) g =B;
                if(k == 0) b =C;

                if(r < g && g < b){
                    cout <<"Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;


}


Measured memory_bytes: 3896