akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    int H,W;
    cin>>H>>W;
    string a[H+1];
    REP(i,H){
    	cin>>a[i];
    }

    bool yoko[W+1];
    bool tate[H+1];
    bool oped=false;
    while(1){
    	bool oped=false;
	    REP(i,H){
	    	yoko[i]=true;
	    	REP(j,W){
	    		if(a[i][0]=='#') yoko[i]=false;
	    		if(a[i][j-1]!=a[i][0]) yoko[i]=false;
	    	}
	    	if(yoko[i]){
	    		oped=true;
	    		FOR(k,i,H-1){
	    			a[k]=a[k+1];
	    		}
	    		H--;
	    	}
	    }

	    REP(i,W){
	    	tate[i]=true;
	    	REP(j,H){
	    		if(a[1][i-1]=='#') tate[i]=false;
	    		if(a[j][i-1]!=a[1][i-1]) tate[i]=false;
	    	}
	    	if(tate[i]){
	    		oped=true;
	    		FOR(k,1,H){
	    			FOR(l,i,W-1){
	    				a[k][l-1]=a[k][l];
	    			}
	    			a[k].pop_back();
	    		}
	    		W--;
	    	}
	    }
	    if(!oped){
	    	REP(i,H){
	    		cout<<a[i]<<endl;
	    	}
	    	return 0;
	    }
	}
    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    n = len(S)
    key = 'keyence'
    if S == key:
        print('YES')
        return
    for i, k in enumerate(key):
        if S[i] != k:
            rest = key[i:]
            for j in range(i, n):
                # 後方完全一致
                if S[j:] == rest:
                    print('YES')
                    return
            prinｔ('NO')
            return
    print('NO')
main()

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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;


const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
   

const LL MOD = LL(1e9) + 7;



LL along1dim(int n, vector<int> &xs) {
    LL widths = 0;
    ii (n-1) {
        LL onleft = i+1;
        LL onright = n-1-i;
        LL w = xs[i+1] - xs[i];
        LL howmany = (onleft * onright) % MOD;
        LL here = (howmany * w) % MOD;
        widths = (widths + here) % MOD;
    }
    return widths;
}

int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';     //Avoid flushing with endl.
    cout.precision(16);


    int n, m;
    cin >> n >> m;

    vector<int> xs(n);
    vector<int> ys(m);
    ii (n)
        cin >> xs[i];
    ii (m)
        cin >> ys[i];

    cout << (along1dim(n, xs) * along1dim(m, ys)) % MOD << '\n';
    

    return 0;
}



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			printf("%lldx%lld=%lld\n", i, j, i*j);
		}
	}
}


Measured memory_bytes: 3092
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

typedef pair<int, int> P;

int N, A[300000];
P f[300000];

P merge(P& l, P& r) {
    vector<int> v = {l.first, l.second, r.first, r.second};
    sort(v.begin(), v.end());
    return {v[3], v[2]};
}

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

    cin >> N;
    REP(i, 1 << N) cin >> A[i];
    REP(i, 1 << N) f[i] = {A[i], 0};

    REP(i, N) REP(j, 1 << N) {
        if (j & 1 << i) {
            f[j] = merge(f[j], f[j ^ 1 << i]);
        }
    }

    int ans = 0;
    FOR(i, 1, (1 << N) - 1) {
        ans = max(ans, f[i].first + f[i].second);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<vector<int>> a(n,vector<int>(3));
    rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];

    vector<vector<int>> dp(n+1,vector<int>(3,0));

    for(int i = 1; i <= n; ++i){
        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 3; ++k){
                if(j != k)
                    dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i-1][j]);
            }
        }
    }

    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    rep(i,n){
        if((i+1) % 2 == 1 && a[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

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

tnum = 1
anum = 1
for i in range(n):
    t, a = list(map(int, input().split()))
    ct = tnum // t
    if tnum % t != 0:
        ct += 1
    ca = anum // a
    if anum % a != 0:
        ca += 1
    n = max(ct, ca)
    tnum = n * t
    anum = n * a
print(tnum + anum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std ;
int main() {
	long long A , B , Bit = 0 ;
	cin >> A >> B ;
	if( A == B ) return not printf( "1\n" ) ;
	for(register int i = 62 ; i-- ; ) {
		if( ( A xor B ) & ( 1ll << i ) ) {
			Bit = i ;
			break ;
		}
		if( A & ( 1ll << i ) ) {
			assert( B & ( 1ll << i ) ) ;
			A ^= 1ll << i ;
			B ^= 1ll << i ;
		}
	}
	for(register int i = Bit ; i-- ; )
		if( B & ( 1ll << i ) ) {
			B |= ( 1ll << i ) - 1 ;
			break ;
		}
	return not printf( "%lld\n" , ( ( 1ll << Bit ) - A ) + min( 1ll << Bit , B - A + 1ll ) ) ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 1e9+7, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;
 
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */
 
int k;
vector<ll> res;

int get_sum(ll x) {
	int sum = 0;
	ll tmp  = x;
	while(tmp) sum += tmp % 10, tmp /= 10;
	return sum;
}

int main() {
	iostream_optimize();
	cin >> k;

	ll p = 1, x = 1;
	while(res.size() < k) {
		res.pb(x);
		if(1.0 * (x+p) / get_sum(x+p) > 1.0 * (x+2*p) / get_sum(x+2*p)) p *= 10;
		x += p;
	}
	foreach(x, res) cout << x << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    vector<int>A(a),B(b);
    for(int i=0;i<a;i++)cin>>A[i];
    for(int i=0;i<b;i++)cin>>B[i];

    int Max=0;
    for(int i=0;i<b;i++){
        int cnt=0;
        int j=i;
        vector<int>::iterator ite=A.begin();
        while(true){
            ite=find(ite,A.end(),B[j]);
            if(ite!=A.end()){
                j++;
                ite++;

                cnt++;
                //cout<<B[j-1]<<":"<<ite-A.begin()-1<<" ";
            }
            else break;
        }
        
        Max=max(Max,cnt);
    }
    cout<<Max<<endl;
}

Measured memory_bytes: 1232
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (int w; cin >> w;) {
		string s; getline(cin, s);
		vector<int> c;
		stringstream ss(s);
		while (!ss.eof()) {
			int r; ss >> r;
			c.push_back(r);
		}
		int bend = 1 << c.size();
		vector<vector<double> > dp(bend, vector<double>(c.size(), INF));
		for (int i = 0; i < c.size(); i++) {
			dp[0][i] = c[i];
		}
		for (int bit = 0; bit < bend; bit++) {//1??±?????\??????
			for (int i = 0; i < c.size(); i++) {
				if ((bit & (1 << i)) == 0) {//??±?????\??£??????????????£??????
					for (int j = 0; j < c.size(); j++) {
						//cout << bitset<10>(bit) << endl;
						//cout << bitset<10>(1 << i) << endl;
						//cout << bitset<10>(1 << j) << endl;
						//cout << endl;
						if ((bit&(1 << j)) != 0) {//??±?????\??£????????????
							dp[bit][i] = min(
								dp[bit][i],
								dp[bit - (1 << j)][j]
								+ sqrt(
								(c[j] + c[i])*(c[j] + c[i]) - (c[j] - c[i])*(c[j] - c[i])
								)
							);
						}
						//cout << dp[bit][i] << endl;
					}
				}
			}
		}
		double m = INF;
		for (int i = 0; i < c.size(); i++) {
			//cout << dp[bend - 1 - (1 << i)][i] + c[i] << endl;
			m = min(m, dp[(bend - 1) - (1 << i)][i] + c[i]);
		}
		cout << (m <= w ? "OK" : "NA") << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  vector<int> cost(n);
  for(int i=0;i<n;i++)
    cost[i]=1e9+7;
  cost[0]=0;
  for(int i=0;i<n;i++){
    if(i+1<n && cost[i]+abs(v[i]-v[i+1])<cost[i+1])
      cost[i+1]=cost[i]+abs(v[i]-v[i+1]);
    if(i+2<n && cost[i]+abs(v[i]-v[i+2])<cost[i+2])
      cost[i+2]=cost[i]+abs(v[i]-v[i+2]);
  }
  cout<<cost[n-1];
}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a"<<" < "<<"b"<<endl;
    }
    else if(a>b){
        cout<<"a"<<" > "<<"b"<<endl;
    }
    else {
        cout<<"a"<<" == "<<"b"<<endl;
    }
    
}


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

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

vector<int> makeNextLink(const vector<int> &a) {
    vector<int> nxt(a.size(), -1);
    map<int, int> memo;
    for (size_t i = nxt.size() - 1; 1 <= i; --i) {
        if (memo.count(a[i]) != 0) nxt[i] = memo[a[i]];
        memo[a[i]] = i;
    }
    return nxt;
}

ll pow2(ll n) {
    ll p = 1;
    for (int i = 0; i < n; ++i) (p *= 2) %= MOD;
    return p;
}

ll Solve() {
    ll n;
    cin >> n;

    vector<int> a(n + 1), cnt_zero(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] ^= a[i - 1];
        if (a[i] == 0) ++cnt_zero[i];
        cnt_zero[i] += cnt_zero[i - 1];
    }

    // a[i] = a[nxt[i]]
    vector<int> nxt = makeNextLink(a);

    ll num_partition = 1;
    if (a.back() != 0) {
        int idx = 1;
        while (a[idx] != a.back()) ++idx;

        ll sum_a = 1, sum_b = 0;
        while (nxt[idx] != -1) {
            ll num_zero = cnt_zero[nxt[idx]] - cnt_zero[idx - 1];
            (sum_b += num_zero * sum_a) %= MOD;
            (sum_a += sum_b + 1) %= MOD;
            idx = nxt[idx];
        }
        num_partition += sum_b;
    }
    else {
        set<int> used;
        for (int i = 1; i + 1 <= n; ++i) {
            if (used.count(a[i]) != 0) continue;
            used.insert(a[i]);

            if (a[i] == 0) {
                int num_zero = cnt_zero[n] - cnt_zero[i - 1];
                (num_partition += pow2(num_zero - 1) - 1 + MOD) %= MOD;
            }
            else {
                ll sum_a = 1, sum_b = 0, idx = i;
                while (nxt[idx] != -1) {
                    ll num_zero = cnt_zero[nxt[idx]] - cnt_zero[idx - 1];
                    (sum_b += num_zero * sum_a) %= MOD;
                    (sum_a += sum_b + 1) %= MOD;
                    idx = nxt[idx];
                }
                (num_partition += sum_a) %= MOD;
            }
        }
    }

    return num_partition;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    string s; cin >> s;
    int n = SZ(s);
    int ans = 0;
    int i = 0, j = n - 1;
    while(i < j){
        if(s[i] == s[j]){
            i++;
            j--;
        }
        else if(s[i] == 'x'){
            ans++;
            i++;
        }else if(s[j] == 'x'){
            ans++;
            j--;
        }else{
            ans = -1;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    /**
     * 1 21
     * @param 1 ≤ a,b ≤ 100
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String a = sc.next();
            String b = sc.next();
            int ab = Integer.parseInt(a + b);

            int tmp = (int)Math.sqrt(ab);
            if (Math.pow(tmp, 2) == ab) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 21844
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=0
for i,j in enumerate(l):
    if j>k:
        l[i]=k
        ans+=j-k
for i in range(1,n):
    if l[i]+l[i-1]>k:
        ans+=l[i]-(k-l[i-1])
        l[i]=k-l[i-1]
print(ans)


Measured memory_bytes: 14472
def main():
    n,m,c = map(int,input().split())
    b = list(map(int,input().split()))
    a = [list(map(int,input().split())) for _ in range(n)]
    ans = 0
    for x in a:
        C = c
        for i in range(m):
            C += x[i]*b[i]
        if C > 0:
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9076
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next
  val K = sc.nextInt
  val b1 = new scala.util.control.Breaks

  // 全通りやってソート...?
  var list = List.empty[String]
  val len = if (s.length > 5) 5 else s.length
  for (i <- 0 until s.length) {
    b1.breakable {
      for (j <- i + 1 to s.length) {
        list = s.substring(i, j) :: list
        if (j == i + 5) b1.break()
      }
    }
  }

  val ans = list.sorted.distinct
  println(ans(K - 1))
}

Measured memory_bytes: 33824
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

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

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int n, k;
	string s;
	
	cin >> n >> s >> k;

	char kc = s[k - 1];

	for (int i = 0; i < n; i++){
		if (s[i] != kc){
			cout << '*';
		} else {
			cout << s[i];
		}
	}
	cout << endl;
} 


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

int main() {
	
	int n;
	double pb;
    cin >> n;
    double dp[n+1][n+1];

    dp[0][0] = 1;
    for(int j=1; j<=n; ++j)
    {
	    cin >> pb;
	    dp[j][0] = dp[j-1][0] * (1 - pb);
	    for(int i=1; i<j; ++i)
		    dp[j][i] = dp[j-1][i-1] * pb + dp[j-1][i] * (1 - pb);	
	    dp[j][j] = dp[j-1][j-1] * pb;
    }

    double sum = 0;
    // 11 - 6, 7, 8, 9, 10, 11
    // (n+1)/2 -
    for(int i=(n+1)/2; i<=n; ++i)
    {
	    sum += dp[n][i];
    }

    printf("%.10lf\n", sum);
	return 0;
}


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

int n, A[20], x[20][20], y[20][20];
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i=1; i<=n; ++i) {
        cin>>A[i];
        for (int j=1; j<=A[i]; ++j) cin>>x[i][j]>>y[i][j];
    }

    int ans=0;
    for (int mk=0; mk<(1<<n); ++mk) {
        bool ok=true;
        for (int i=1; i<=n; ++i) {
            if (((mk>>(i-1))&1)==0) continue;
            for (int j=1; j<=A[i]; ++j) {
                if (y[i][j]!=((mk>>(x[i][j]-1))&1)) {
                    ok=false;
                    break;
                }
            }
            if (!ok) break;
        }
        if (ok) ans=max(ans, __builtin_popcount(mk));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
set<int > s;
int main(){
		int a,b,c;
		cin >> a >> b >> c;
		s.insert(a);
		s.insert(b);
		s.insert(c);
		cout << s.size() <<endl;
		return 0;
	}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

void print_all(char str[], int cur, int n){
	char max = 0;

	if(cur == n){
		printf("%s\n", str);
		return;
	}

	for(int i = 0; i < cur; i++)
		max = (max < str[i]) ? str[i] : max;

	for(int i = 0; i <= max - 'a' + 1; i++){
		char temp[11];
		strcpy(temp, str);
		temp[cur] = 'a' + i;
		print_all(temp, cur+1, n);
	}
}
int main(void){
	int n;
	char str[11] = "aaaaaaaaaa";
	scanf("%d", &n);

	str[n] = 0;

	print_all(str, 1, n);

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string.h>
using namespace std;
#define N 100001

int arr[N];
int res[N];

void screenPrime(){
	memset(arr, 0, sizeof(arr));
	//埃氏筛素数 
	arr[0] = arr[1] = 1;
	for(int i = 2; i <=N; ++i){
		if(!arr[i]){
			for(int j = 2; i*j<=N; ++j){
				arr[i*j] = 1;
			}
		}
	}
	//构造前缀和
	res[0] = 0;
	for(int i = 1; i <= N; ++i){
		if(arr[i] == 0 && arr[(i+1)/2] == 0){
			res[i] = res[i-1] + 1;
		}else{
			res[i] = res[i-1];
		}
	}
	 
}


int main(){
	screenPrime();
	int t, m, n;
	cin >> t;
	while(t--){
		int count = 0;
		cin >> m >> n;
		cout << res[n]-res[m-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * 入力として、最初にデータの個数を受け取り、以後は最初の入力個数分1行単位で三角形の各辺の長さを受け取る(" "区切り).
 * 最初のデータおよび各データは1データあたり1行のデータとなっている
 *
 */
public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<String>();

		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String in = scan.nextLine();
			list.add(in);
		}
		scan.close();

		//一行1データなので、リストの個数分ループ
		for (String str : list) {
			//" "区切りなので、" "で分割
			String[] split = str.split(" ");

			//入力値を数値に変換
			long x1 = Long.valueOf(split[0]);
			long y1 = Long.valueOf(split[1]);
			long z1 = Long.valueOf(split[2]);
			long x2 = Long.valueOf(split[3]);
			long y2 = Long.valueOf(split[4]);
			long z2 = Long.valueOf(split[5]);

			//yを消去
			//式1側の数値をy2で乗算する
			long x1d = x1 * y2;
			long y1d = y1 * y2;
			long z1d = z1 * y2;
			//式2側の数値をy1で乗算する
			long x2d = x2 * y1;
			long y2d = y2 * y1;
			long z2d = z2 * y1;

			//yの係数が揃ったので、式1から式2を引く
			x1d -= x2d;
			y1d -= y2d;
			z1d -= z2d;

			//zをxで割って、xの値を算出
			//なお、結果が少数の可能性もあるのでdouble型にキャストして算出
			double x = ((double) z1d) / x1d;

			//式1に上記のxを代入してyを算出
			double y = ((double) z1 - ((double) x1) * x) / y1;

			//小数点台4位が5以上か判定し、5以上の場合は小数点第4位に5を加算して桁上げ
			x = ((double) Math.round(x * 10000)) / 10000;
			y = ((double) Math.round(y * 10000)) / 10000;

			System.out.println(String.format("%.3f %.3f", x, y));
		}

	}
}



Measured memory_bytes: 26064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const double PI=acos(-1);

int main(){
    double a,b,x;cin>>a>>b>>x;
    double theta,l=0.0,r=PI/2.0;
    if(2*x>=a*a*b){
        while(r-l>1e-8){
            double mid=(l+r)/2.0;
            if(pow(a,3)*tan(mid)>2*(a*a*b-x)) r=mid;
            else l=mid;
        }
    }
    else{
        while(r-l>1e-8){
            double mid=(l+r)/2.0;
            if(a*pow(b,2)>2*tan(mid)*x) l=mid;
            else r=mid;
        }
    }
    theta=(l+r)/2.0;
    printf("%.16f",theta*180.0/PI);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define MAX_N 10000000
#define ll int64_t
#define all(v) (v).begin(),(v).end()
using namespace std;

int main() {
    string s; cin>>s;
    int counta=0,countb=0;
    //0番目が0の場合
    rep(i,s.size()) {
    if(s[i]=='0' && i%2==1)
    counta++;
    else if(s[i]=='1' && i%2==0)
    counta++;
    }
    
    //0番目が1の場合
    rep(i,s.size()) {
    if(s[i]=='1' && i%2==1)
    countb++;
    else if(s[i]=='0' && i%2==0)
    countb++;
    }

    cout<<min(counta,countb)<<endl;
    return 0;
} 

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

int main(){
  int n;
  cin >> n;
  long long tcur,acur;
  long long trat,arat;
  cin >> tcur >> acur;
  for(int i=2;i<=n;i++){
    cin >> trat >> arat;
    if(tcur <= trat && acur <= arat){
      tcur = trat; acur = arat;
    }else{
      long long val;
      val = max((tcur+trat-1)/trat , (acur+arat-1)/arat);
      tcur = trat*val; acur = arat*val;
    }
  }
  cout << tcur+acur <<endl;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

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

    for i in 1..1300 {
        if ((i as f64 * 0.08).floor() as u16 == a) && ((i as f64 * 0.10).floor() as u16 == b) {
        // if (i * 8 == a * 100) && (i == b * 10) {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


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

int n;
vector <long long> L;

void solve(){
    sort(all(L));
    int ans = 0;

    for(int i=0; i<=n-3; i++){
        for(int j=i+1; j<=n-2; j++){
            for(int k=j+1; k<=n-1; k++){
                if(L[i] != L[j] && L[j] != L[k]){
                    if(L[k] < L[i] + L[j]){
                        ans ++;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> n;
    rep(i,n){
        int l;
        cin >> l;
        L.push_back(l);
    }

    solve();
}






Measured memory_bytes: 3644
import java.util.Scanner;
import java.lang.Math;
import java.util.ArrayList;
import java.util.List;
//List<String> color = new ArrayList<>();
//int[] n = new int[k];

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int h = stdIn.nextInt();
		int w = stdIn.nextInt();

		System.out.println((n-h+1)*(n-w+1));
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
int N,M,si,ti;
 
struct edge {
  int to,fi,se;
};
 
vector< edge > G[MAX_N];
 
vector< vector< edge > > nG[MAX_N];
 
vector< int > g[MAX_N];
vector< int > d[MAX_N];
 
typedef pair< int ,int > P;
typedef pair< int , P > PP;
 
int getId(int pos,int t){
  vector<int> :: iterator it;
  it= lower_bound( g[pos].begin() , g[pos].end() , t );
  assert(g[pos].end()!=it);
  assert(*it==t);
  return it-g[pos].begin();
}
 
int dijkstra(){
  for(int i=0;i<N;i++){
    d[i].resize(g[i].size());
    for(int j=0;j<(int)d[i].size();j++)
      d[i][j]=1e9;
  }
  d[si][0]=0;
  priority_queue< PP , vector<PP> , greater<PP> > Q;
  Q.push( PP( 0 , P(si,0) ) );
  while(!Q.empty()){
    PP pp=Q.top();Q.pop();
    int pos=pp.second.first;
    int tm=pp.second.second;
    int cost=pp.first;
    if( d[pos][tm] < cost )continue;
 
    if( pos == ti )return cost;
     
    for(int i=0;i<(int)nG[pos][tm].size();i++){
      edge e=nG[pos][tm][i];
      int ntm=getId(e.to,e.se);
 
      if(d[e.to][ntm]>cost){
        d[e.to][ntm]=cost;
        Q.push(PP(cost,P(e.to,ntm)));
      }
       
    }
 
    if(tm+1==(int)g[pos].size())continue;
     
    int ncost=cost+g[pos][tm+1]-g[pos][tm];
    if(d[pos][tm+1]>ncost){
      d[pos][tm+1]=ncost;
      Q.push( PP(ncost,P(pos,tm+1) ) );
    }
  }
  assert(0);
  return -1;
}
 
int main(){
  scanf("%d %d %d %d",&N,&M,&si,&ti);
  si--,ti--;
   
  g[si].push_back(0);
  for(int i=0;i<M;i++){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    a--,b--;
     
    G[a].push_back( (edge){b,c,c+d} );
    g[a].push_back(c);
    //    g[a].push_back(c+d);
    //    g[b].push_back(c);
    g[b].push_back(c+d);
  }
 
  for(int i=0;i<N;i++){
    sort(g[i].begin(),g[i].end());
    g[i].erase( unique(g[i].begin(),g[i].end()) , g[i].end() );
  }
 
  for(int i=0;i<N;i++){
    nG[i].resize( g[i].size() );
    for(int j=0;j<(int)G[i].size();j++){
      edge e=G[i][j];
      int id=getId(i,e.fi);
      nG[i][id].push_back(e);
    }
  }
 
  printf("%d\n",dijkstra());
  return 0;
}

Measured memory_bytes: 40340
#include <bits/stdc++.h>
using namespace std;
int f[22][(1<<22)+1],a[22][22];
int lowbit(int x)
{
    return x&(-x);
}
int count1(int sum)
{
    int ret=0;
    while(sum)
    {
        ret++;
        sum-=lowbit(sum);
    }
    return ret;
}
int main()
{
    int n,i,j,l;
    f[0][0]=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=(1<<n);j++)
        {
            if(count1(j)!=i)
                continue;
            for(l=0;l<=n-1;l++)
			{
				if((j&(1<<l))!=0&&a[i][n-l]==1)
					f[i][j]=(f[i-1][j^(1<<l)]+f[i][j])%(1000000007);
			}
        }
    }
    printf("%d",f[n][(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 178432
#include <iostream>

using namespace std;

int main()
{
   int h,w;
   while (true){
  cin >> h >> w;

   if (h==0&&w==0)break;

   for(int i=0;i<h;++i){
           for(int j=0;j<w;++j){
    cout << "#";}
    cout <<endl;
   }
   cout << endl;

   }

return 0;
}



Measured memory_bytes: 3124
//ITP1-9-C: Card Game
//2019.05.20

#include <stdio.h>
#include <string.h>

int main(void){
  int n, flag;
  char taro[1000], hanako[1000];
  int tp, hp;

  tp = 0;
  hp = 0;

  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s %s\n", taro, hanako);
    flag = strcmp(taro, hanako);
    if (flag > 0) tp = tp + 3;
    if (flag < 0) hp = hp + 3;
    if (flag == 0) {
      tp = tp + 1;
      hp = hp + 1;
    }
  }
  printf("%d %d\n", tp, hp);
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;
typedef long long ll;

int P, Q;
bool p[100000];
vector<int> v;

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

bool prime(int n) {
  REP(i, 0, v.size()) if(n % v[i] == 0) return false;
  return true;
}

ll solve() {
  ll ans = 1;
  REP(i, 0, v.size()) if(Q % v[i] == 0) {
    ans *= v[i];
    while(Q % v[i] == 0) Q /= v[i];
  }
  if(prime(Q)) ans *= Q;
  return ans;
}

int main(void) {
  REP(i, 0, 100000) p[i] = true;
  p[0] = p[1] = false;
  REP(i, 0, 100000) if(p[i]) for(int j = i * 2; j < 100000; j += i) p[j] = false;
  REP(i, 0, 100000) if(p[i]) v.push_back(i);

  cin >> P >> Q;
  Q = Q / gcd(P, Q);
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 3328
NMK=input().split(" ")
N=int(NMK[0])
M=int(NMK[1])
K=int(NMK[2])

def list2int(List):
    out=[]
    for i in range(len(List)):
        out.append(int(List[i]))
    return out

A=list2int(input().split(" "))
B=list2int(input().split(" "))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])   

result=0
j=M

for i in range(N+1):
    if(a[i]>K):
        break
    while(b[j]>K-a[i]):
        j-=1
    result=max(result,i+j)

print(result)

Measured memory_bytes: 48820
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << 6 - (a + b ) << endl;
	return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
a = [int(input()) for i in range(n)]
a.sort()
for i in range(n):
    x-=a[i]
cnt=n
while(1):
    if x-a[0]<0:
        break
    else:
        x-=a[0]
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	int g[13] = {0, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
	int x, y;
	scanf("%d%d", &x, &y);
	if(g[x] == g[y]){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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 (b < a) { a = b; return 1; } return 0; }

void func(string &S, long long K){

    REP(i,0,K){
        if(S[i]!='1'){
            cout<<S[i]<<endl;
            return;
        }
    }
    cout<<1<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    string S;
    cin>>S;
    long long K;
    scanf("%lld",&K);
    func(S, K);
    return 0;
}


Measured memory_bytes: 3680
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = 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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: [u32; 3],
    }
    let mut A = A;
    A.sort();
    println!("{}",A[0]+A[1]);
}

Measured memory_bytes: 4352
import numpy as np
n, m = map(int, input().split())
hh = list(map(int, input().split()))
aa = np.zeros(m, np.int32)
bb = np.zeros(m, np.int32)
for i in range(m):
    aa[i], bb[i] = map(int, input().split())

ha = np.array([hh[aa[i]-1] for i in range(m)])
hb = np.array([hh[bb[i]-1] for i in range(m)])
set_bad = set(aa[ha <= hb]).union(set(bb[ha >= hb]))
print(n - len(set_bad))

Measured memory_bytes: 43488
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) vc<vc<T>> xs(n, vc<T>(m)); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b);
    For(x, 20000){
        if(floor(x*0.08) == a && floor(x*0.1) == b) Return(x);
    }
    Cout(-1);
}


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

int a[15],i,j,b[5];

int comp(const void *p,const void *q){
	return *(int *)q-*(int *)p;
}

int main(){
	for(i=0;i<2;i++){
		for(j=0;j<10;j++)scanf("%d",&a[j]);
		qsort(a,10,sizeof(int),comp);
		b[i]=a[0]+a[1]+a[2];
	}
	printf("%d %d\n",b[0],b[1]);
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  reverse(ALL(a));
  ll ans = 0;
  ans += (ll)a[0];
  int j = 1;
  rep(i, n-2) {
    ans += (ll)a[j];
    if (i%2) j++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 10000000
using namespace std;
typedef long long ll;
const int MAXN=5e6+10;
const int MAX=1e3+10;
const double eps=1e-6;



int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif

    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a-b)%c<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main(){
	int a;
	cin >> a;
	map<int, int>s;
	for (int b = 1; b < a+1; b++) {
		int c;
		cin >> c;
		s.insert(pair<int, int>(b, c));
	}
	auto e = s.begin();
	int n = 0;
	for (int d = 1; d < a + 1; d++, e++) {
		if (s[e->second] == d)n++;
	}
	cout << n / 2 << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define endl '\n'
using namespace std;
ll mod = 1000000007;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector<ll> vec(n+1);
    vector<ll> p(n+1);
    for(int i = 1; i <= n; i++)cin >> vec[i];
    for(int i = 1; i <= n; i++){
        p[i] = p[i-1]+vec[i];
    }
    ll ans = 0;
    for(int i = 1; i <= n-1; i++){
        ans += (vec[i]%mod) * ((p[n]-p[i])%mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6348
from bisect import bisect_right
from itertools import accumulate

N,M,K=map(int,input().split())
A=list(accumulate([0]+[int(x) for x in input().split()]))
B=list(accumulate([0]+[int(x) for x in input().split()]))

m=0
for i in range(0,N+1):
  if K<A[i]:
    break
  m=max(m,i+bisect_right(B,K-A[i])-1)

print(m)


Measured memory_bytes: 46872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
ll M=1e18;
ll a[210000];
int main(){
	int n;
	ll sum=1,y;
	int flag=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	    if(a[i]==0){
	    	sum=0;;
		}
	}
	if(sum==0){
		cout<<"0"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(sum<=M/a[i]&&M/a[i]>=1){
			sum*=a[i];
			flag=0;
		}else{
			flag=1;
			break;
		}
	}
	if(flag) cout<<"-1"<<endl;
	else cout<<sum<<endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define pb push_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define rb(x) ((x)&(-(x)))
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define MOD (1000000007)
#define MAXN (100005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void fuk() { puts("0"); exit(0); }

int A[MAXN];
int N;

int main() {
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A+N);
	if(!(N&1)) {
		for(int i = 0; i < N; i++) {
			if(A[i] != i/2*2 + 1) fuk();
		}
		ll Ans = 1;
		for(int i = 0; i < N; i += 2)
			Ans = (Ans*2) % MOD;
		printf("%lld\n", Ans);
	} else {
		if(A[0] != 0) fuk();
		for(int i = 1; i < N; i++) {
			if(A[i] != (i-1)/2*2+2) fuk();
		}
		ll Ans = 1;
		for(int i = 1; i < N; i += 2)
			Ans = (Ans*2) % MOD;
		printf("%lld\n", Ans);
	}
	return 0;
}

Measured memory_bytes: 640
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<int,int>m;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  ---------------------------------MAIN-------------------------------------------*/

int main()
{
	pan;
	ll k,n,m,flag=0;
	cin>>k>>n>>m;
	for(ll i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			flag=1;
			break;
		}
	}
	if(flag==0)
		cout<<"NG"<<endl;
	else
		cout<<"OK"<<endl;
}

Measured memory_bytes: 3612
const lines=[];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
    const input = (lines[0] as string).split(" ");
    const a = +input[0];
    const b = +input[1];

    const res = a - b * 2;
    
    if (res > 0) {
        console.log(res);
    } else {
        console.log(0);
    }
});


Measured memory_bytes: 7628