akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <regex>
#include <cmath>
#include <bitset>
#include <array>
#include <deque>
#include <list>
#include <stack>
#include <iterator>
#include <random>

using namespace std;

extern void* enabler;

using LL=long long int;
using ULL=unsigned long long int;
using Complex=complex<double>;

template<class T>
using asc_pqueue=std::priority_queue<T,vector<T>, std::greater<T>>;
template<class T>
using desc_pqueue=std::priority_queue<T,vector<T>, std::less<T>>;
template<class T>
using asc_set=std::set<T,vector<T>, std::greater<T>>;
template<class T>
using desc_set=std::set<T,vector<T>, std::less<T>>;

const LL INF = (1ll << 62);

template<class T>
T read(){
    T tmp;
    cin >> tmp;
    return tmp;
}

//#include "library/graph.h"
//#include "library/interval.h"
//#include "library/maybe.h"
//#include "library/utility.h"
//#include "library/rectangle.h"
//#include "library/bit.h"

//==========

int main(){
    int N, K;
    N = read<int>();
    K = read<int>();
    vector<int> a(N + 1);
    for(int i=0;i<N;i++){
        a[read<int>()-1]++;
    }
    std::sort(a.begin(), a.end());

    //dump(a);


    int num = 0;
    for(int i=0;i<=N;i++){
        if(a[i] > 0)
            num++;
    }
    //cerr << "num:" << num << endl;
    int res = 0;
    for(int i=0;i<=N;i++){
        if(num <= K)
            break;
        if(a[i] == 0)
            continue;
        res += a[i];
        num--;
    }
    cout << res << endl;

    return 0;
}
















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

using namespace std;

int main()
{
        int i;
        int n, a;
        int num = 0;

        vector<int> evens;

        cin >> n;

        for (i=0; i<n; i++) {
                cin >> a;
                if (a % 2 == 0) {
                        evens.push_back(a);
                }
        }


        for (i=0; i<evens.size(); i++) {
                while (evens[i] % 2 == 0) {
                        num++;
                        evens[i] = evens[i]/2;
                }
        }


        cout << num << endl;

        return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int k, a, b;
    cin >> k >> a >> b;

    bool ok = false;
    for(int i=a; i<=b; i++){
        if(i % k == 0) ok = true;
    } 

    if(ok) cout << "OK\n";
    else cout << "NG\n";

    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int a[3][3];
    rep(i, 3)rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    int b[n];
    rep(i, n) cin >> b[i];
    rep(i, n){
        rep(j, 3){
            rep(k, 3){
                if (a[j][k] == b[i]) {
                    a[j][k] = 0;
                }
            }
        }
    }
 
    // rep(i, 3){
    //     rep(j, 3) cout << a[i][j] << " ";
    //     cout << endl;
    // }

    rep(i, 3){
        bool flag = true;
        rep(j, 3){
            if(a[i][j] != 0){
                flag = false;
            }

        }
        if (flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    // cout << 1 << endl;
    rep(i, 3){
        bool flag = true;
        rep(j, 3){
            if(a[j][i] != 0){
                flag = false;
            }
        }
        if (flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    // cout << 2 << endl;
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
        cout << "Yes" << endl;
        return 0;        
    }
    // cout << 3 << endl;
    if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        cout << "Yes" << endl;
        return 0;        
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
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>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)output(a[i],i!=n-1?',':10);}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

int dp[1001][1001];
int c[1001];
int d[1001];
int a[1001];
int main() {
  int n,m;
  while(cin >> n >> m) {
    memset(a,-1,sizeof(a));
    REP(i,m) {
      cin >> c[i] >> d[i];
      chmax(a[c[i]-1], d[i]-1);
    }
    memset(dp,0x3f,sizeof(dp));
    REP(i,n)dp[0][i] = i*2;
    REP(i,n) {
      // output(dp[i], n);
      for (int j=i+1; j<=n; ++j) {
        if (j>=a[i]) {
          chmin(dp[i+1][j], dp[i][j] + 1);
        } else {
          chmin(dp[i+1][a[i]], dp[i][j] + 1 + (a[i]-i)*2);
        }
      }
      for (int j=max(i+1,a[i]); j<=n; ++j) {
        chmin(dp[i+1][j], dp[i][i] + 1 + (j-i)*2);
        if (a[i] >= i)
          chmin(dp[i+1][j], dp[i][a[i]] + 1 + (j-i-1)*2);
        if (a[i] == -1)
          chmin(dp[i+1][j], dp[i][i] + 1 + (j-i-1)*2);
      }
    }
    int ans = dp[n][n];
    cout << ans+1 << endl;
  }
}

Measured memory_bytes: 5096
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
    ll N, W;
    cin >> N >> W;
    vector<pair<ll, ll>> wv(N);
    rep(i, N){
        ll w, v;
        cin >> w >> v;
        wv[i] = make_pair(w, v);
    }
    // dp[i][j] := i番目までの商品を選んだ時に価値jを超えない時の重さの総和の最小値
    ll dp[N+4][100500];
    rep(i, N+1)rep(j, 100500){
        dp[i][j] = INF;
    }
    dp[0][0] = 0;
    rep(i, N)rep(j, 100500){
        pair<ll, ll> tmp = wv[i];
        if (j-tmp.second>=0) {
            dp[i+1][j] = min(dp[i][j], dp[i][j-tmp.second] + tmp.first);
        }else{
            dp[i+1][j] = dp[i][j];
        }
    }
    ll ans = 0;
    rep(i, 100500){
        if (dp[N][i]<=W) chmax(ans, (ll)i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i = 0;i < N; i++){
    cin >> vec[i];
  }
  
  sort(vec.begin(),vec.end());
  
  int sum = 0;
  for(int i = 0;i < N-1; i++){
    sum += vec[i];
  }
  
  
  if( sum > vec[N-1]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
  
}
    

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

int main() {
  int N,x,y,a;
  a=0;
  cin>>N;
  for (int i = 0; i < N; i++) {
    cin>>x>>y;
     a+=y-x+1;
    
  }
  cout<<a<<endl;
  }

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
a_max = max(a)
a_num = [0 for i in range(a_max+1)]

a = sorted(a)
shurui = 0

for i in a:
    if a_num[i] == 0:
        shurui += 1
    a_num[i] += 1

a_num = sorted(a_num)
ans = 0
i = 0

while shurui > k:
    if a_num[i] != 0:
        ans += a_num[i]
        shurui -= 1
    i += 1

print(ans)


Measured memory_bytes: 32224
const Main = (input) => {
  const dataArray = input.split("\n");
  const count = dataArray[0];
  const numberArray = dataArray[1].split(' ');
  var sumNumber = 0;
  for (var i = 0; i < numberArray.length; i ++){
  	sumNumber += (1 / numberArray[i]);
  }
  var answer = 1/sumNumber;
  
  console.log(answer);
  
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, f1[2007][2007], f2[2007][2007], f3[2007][2007], f4[2007][2007];
char  a[2007][2007];
li h, w, ans;

int main () {
    fastIO;
    cin >> h >> w;
    for(li i = 0; i < h; i ++) {
        for(li j = 0; j < w; j ++) {
            cin >> a[i][j];
        }
    }


    for(li i = 0; i < h; i ++) {
        for(li j = 0; j < w; j ++) {
            if(a[i][j]=='#') continue;
            if(j > 0 && f1[i][j-1] != 0) f1[i][j] = f1[i][j-1]-1;
            else {
                li k = j;
                for(k = j; k < w; k ++) { if(a[i][k] == '#') break; }
                f1[i][j] = k-j;
            }
        }
    }

    for(li i = 0; i < w; i ++) {
        for(li j = 0; j < h; j ++) {
            if(a[j][i]=='#') continue;
            if(j > 0 && f2[j-1][i] != 0) f2[j][i] = f2[j-1][i]-1;
            else {
                li k = j;
                for(k = j; k < h; k ++) { if(a[k][i] == '#') break; }
                f2[j][i] = k-j;
            }
        }
    }

    for(li i = 0; i < h; i ++) {
        for(li j = w-1; j >= 0; j --) {
            if(a[i][j]=='#') continue;
            if(j < w-1 && f3[i][j+1] != 0) f3[i][j] = f3[i][j+1]-1;
            else {
                li k = j;
                for(k = j; k >= 0; k --) { if(a[i][k] == '#') break; }
                f3[i][j] = j-k;
            }
        }
    }

    for(li i = 0; i < w; i ++) {
        for(li j = h-1; j >= 0; j --) {
            if(a[j][i]=='#') continue;
            if(j < h-1 && f4[j+1][i] != 0) f4[j][i] = f4[j+1][i]-1;
            else {
                li k = j;
                for(k = j; k >= 0; k --) { if(a[k][i] == '#') break; }
                f4[j][i] = j-k;
            }
        }
    }
//system("pause");
//    system("pause");

    ans = 0;
    for(li i = 0; i < h; i ++) {
        for(li j = 0; j < w; j++) ans = max(ans, f1[i][j]+f2[i][j]+f3[i][j]+f4[i][j]);
    }
    cout << ans-3;
}


Measured memory_bytes: 129920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vvin=vector<vector<int>>;
using vll=vector<long long>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;
vin dy={0,1,0,-1};
vin dx={1,0,-1,0};

int main(){
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    int res=0;
    while(b<=a){
        b*=2;
        res++;
    }
    while(c<=b){
        c*=2;
        res++;
    }
    if(res<=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
D,G = map(int,input().split())
l = list(list(map(int, input().split())) for _ in range(D))

#得点の大きい順に並び替えておく
l = l[::-1]

ans = float("inf")
for i in range(2**D):
    total = 0
    cnt = 0
    for j in range(D):
        if (i>>j)&1:
            total += 100*(D-j)*l[j][0] + l[j][1]
            cnt += l[j][0]
    if total >= G:
        ans = min(ans,cnt)
        continue
    for j in range(D):
        if (i>>j)&1 == False:
            for k in range(l[j][0]):
                total += 100*(D-j)
                cnt+=1
                if total >= G:
                    ans = min(ans,cnt)
                    break
            else:
                continue
            break
print(ans)

Measured memory_bytes: 42992
using System;
using System.Collections.Generic;
using System.Linq;

public static class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long sum = 0;
        long cur = A.First();
        foreach (var a in A)
        {
            if (cur < a)
            {
                cur = a;
            }
            if (cur > a)
            {
                sum += cur - a;
            }
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 47720
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define mk make_pair
# define fr first
# define sc second

using namespace std;
int n,ans,x,y;
int main(){
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		
		if(x>y)x--;
		if(x<y){cout<<"No";return 0;}
		y=x;
	}
	cout<<"Yes";
}


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

int main() {
    long long int n, k, ans = 0;
    map<long long int, long long int> mp;
    cin >> n >> k;
    long long int a[n], b[n+1] = {0};
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i) {
        b[i+1] += (b[i] + a[i] - 1)%k;
    }

    for(int i = 0; i < n+1; ++i) {
        mp[b[i]]++;
        if(i >= k) {
            mp[b[i-k]]--;
        }
        if(mp[b[i]]-1 > 0) ans += mp[b[i]]-1;
    }
    cout << ans << '\n';
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M),b(M);
    for(int i =0;i < M;i++)
        cin >> a.at(i);
    for(int i =0;i < M;i++)
        cin >> b.at(i);
    
    for(int i = 1;i <= N;i++){
        int count =0;
        for(int j = 0;j < M;j++){
            if(a.at(j)==i)
                count++;
            if(b.at(j)==i)
                count++;     
        }
         cout << count << endl;
    }
     
}

Measured memory_bytes: 256
'''input
100000 1
1 100000 100
'''
import sys
sys.setrecursionlimit(100100)
N, M = [int(x) for x in input().split()]

vien = [[] for _ in range(N)]

for _ in range(M):
	a, b, w = [int(x) for x in input().split()]
	a -= 1
	b -= 1
	w = w & 1
	vien[a].append(b)
	vien[b].append(a)

been = [False]*N
ats = 0
def dfs(x):
	been[x] = True
	for u in vien[x]:
		if not been[u]:
			dfs(u)


for i in range(N):
	if been[i]: continue

	ats += 1
	dfs(i)

print(ats)

Measured memory_bytes: 104700
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)


int n,a,b,c;
int L[10], mn;

int dfs(int pos, int A, int B, int C){
	if(pos==n){
		int tmp = abs(a-A)+abs(b-B)+abs(c-C)-30;
		if(A && B && C) return tmp;
		else return 1000000000;
	}

	int tmp1 = dfs(pos+1, A, B, C);
	int tmp2 = dfs(pos+1, A+L[pos], B, C)+10;
	int tmp3 = dfs(pos+1, A, B+L[pos], C)+10;
	int tmp4 = dfs(pos+1, A, B, C+L[pos])+10;
	return min(tmp1, min(tmp2, min(tmp3, tmp4)));
}


int main(){
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		cin>>L[i];
	}
	cout<<dfs(0, 0, 0, 0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;

struct mint {
    long long x;
    mint(long long x = 0):x((x % mod + mod) % mod){}
    mint operator-() const { return mint(-x);}
    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;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint choose(int n, int k) {
    mint x = 1, y = 1;
    rep(i, k) y *= i+1;
    rep(i, k) x *= (n-i);
    return x / y;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n) - 1;
    ans -= choose(n, a) + choose(n, b);
    cout << ans.x << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S; cin >> S;
    int ans = 0;
    F0R(i, sz(S) / 2) {
        if (S[i] != S[sz(S) - 1 - i]) ans++;
    }
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll x;
    cin>>x;
    ll ze=x/11;
    ll sur=x-ze*11;
    if(sur==0){
        cout<<2*ze<<endl;
    } else if(sur<=6) cout<<2*ze+1<<endl;
    else cout<<2*ze+2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define SENTINEL 1000000000

int count=0;

void merge(int A[],int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int A[500000];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 5596
fun main(array: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var arr = Array(n){0}
    var ans = 0
    var llist = mutableListOf<Int>()
    var rlist = mutableListOf<Int>()
    repeat(m) {
        val (l, r) = readLine()!!.split(" ").map { it.toInt()}
        llist.add(l)
        rlist.add(r)
    }
    val max = llist.max()
    val min = rlist.min()
    if(max!! <= min!!) print(min - max!! + 1)
    else print(0)
}

Measured memory_bytes: 60400
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll fcn(ll b, ll n){
	if(n<b) return n;
	else return fcn(b, n/b)+n%b;
}

int main(){
	ll n, s;
	cin >> n >> s;
	if(n<s){
		cout << -1 << endl;
		return 0;
	}else if(n==s){
		cout << n+1 << endl;
		return 0;
	}

	ll ans=1e11+1;
	for(ll a=1; a*a<=n-s; a++){
		if((n-s)%a==0){
			ll b=(n-s)/a;
			if(fcn(a+1, n)==s) ans=min(ans, a+1);
			if(fcn(b+1, n)==s) ans=min(ans, b+1);
		}
	}
	if(ans<1e11+1) cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] d = new int[k];
        for (int i = 0; i < k; i++) {
            d[i] = sc.nextInt();
        }

        int ans = solve(n, k, d);
        System.out.println(ans);
    }

    private static int solve(int n, int k, int[] d) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < d.length; i++) {
            set.add(d[i]);
        }

        int ans = 0;
        for (int i = n; i < n * 10; i++) {
            int tmp = i;
            boolean isAns = true;
            while (tmp > 0) {
                int t = tmp % 10;
                if (set.contains(t)) {
                    isAns = false;
                    break;
                }
                tmp /= 10;
            }
            if (isAns) {
                ans = i;
                break;
            }
        }
        return ans;
    }
}


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

int main(){
  string s,t;
  cin>>s>>t;
  string k=t.substr(0,t.size()-1);
  if(k==s){
     cout<<"Yes"<<endl;
  }
  else{
     cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3556
#include <stdio.h>

int main(void){
    
    int a,b;
    
    scanf( "%d %d",&a,&b );
    
    if( a + b < 24 ){
        printf( "%d",a+b );
    }
    else if( a + b >= 24 ){
        printf( "%d",a+b-24 );
    }
    
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp
{ 
    class Program
    {
        public static int gcd(int a, int b)
        {
            return (b != 0) ? gcd(b, a % b) : a;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]), m = int.Parse(s[1]), k = int.Parse(s[2]);
            int ans = gcd(n, m);
            List<int> div = new List<int> { };
            for (int i = 1; i <= ans; i++)
            {
                if (ans % i == 0)
                {
                    div.Add(i);
                }
            }
            div.Reverse();
            //Console.WriteLine(ans);
            Console.WriteLine(div[k - 1]);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;



int main(){
     int n; cin >> n;
     string ans = "ABC";
     if(n/1000==1){ans="ABD";}
    cout << ans << endl;
}

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

int main() {
string s,t;
cin >> s;
t=s;
if(s=="keyence"){
    cout << "YES";
    return 0;
}
else {
    for(int i=0;i<t.size();i++){
        
        for(int j=1;i+j<t.size();j++){
            s=t;
            s.erase(i,j);
        if(s=="keyence"){
            cout << "YES";
            return 0;}
        }
        
    }
}
cout << "NO";
}


Measured memory_bytes: 256
import itertools
a=list(map(int,input().split()))
ans=999
l=[0,1,2]
for x in itertools.permutations(l,3):
  tmp=abs(a[x[0]]-a[x[1]])+abs(a[x[1]]-a[x[2]])
  if tmp <=ans:
    ans =tmp
print(ans)

Measured memory_bytes: 3060
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")

a = k()
if a == 3 or a == 5 or a == 7:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 10040
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if x == i+j+k:
                    count += 1
    print(count)


Measured memory_bytes: 5592
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
p = 10**9+7

n = int(input())

from functools import lru_cache
@lru_cache(None)
def dfs(v=0, parent=-1):# どこからきたかの情報を入れとく

    if v == n:
        return 1

    if parent[-3] == 'A' and parent[-1] == 'G':
        return sum([dfs(v+1, parent[-2:]+'A'), dfs(v+1, parent[-2:]+'G'), dfs(v+1,parent[-2:]+'T')])%p
    elif parent[-3:-1] == 'AG':
        return sum([dfs(v+1,parent[-2:]+'A'), dfs(v+1,parent[-2:]+'G'), dfs(v+1,parent[-2:]+'T')])%p
    elif parent[-2:] == 'AC':
        return sum([dfs(v+1,'ACA'), dfs(v+1,'ACC'), dfs(v+1,'ACT')])%p
    elif parent[-2:] == 'GA':
        return sum([dfs(v+1,'GAG'), dfs(v+1,'GAA'), dfs(v+1,'GAT')])%p
    elif parent[-2:] == 'AG':
        return sum([dfs(v+1,'AGA'), dfs(v+1,'AGG'), dfs(v+1,'AGT')])%p
    else:
        return sum([dfs(v+1, parent[-2:]+'A')%p, dfs(v+1,parent[-2:]+'G')%p, dfs(v+1,parent[-2:]+'C')%p, dfs(v+1,parent[-2:]+'T')%p])%p


ans = 0

agc = 'AGCT'

for i in range(4):
    for j in range(4):
        word = 'T' +agc[i] + agc[j]
        ans += dfs(2,word)%p

print(ans%p)


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll ans = 0;
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  rep(i, N-1){
    if(a[i]%2==1 && a[i+1]>0){
      a[i]--;
      a[i+1]--;
      ans++;
    }

  }

  rep(i, N){
    ans += a[i]/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

type dice struct {
	top, bottom, right, left, up, down int
}

func move(d *dice, dir byte) {
	now := d.top
	switch dir {
	case 'N':
		d.top = d.down
		d.down = d.bottom
		d.bottom = d.up
		d.up = now
	case 'S':
		d.top = d.up
		d.up = d.bottom
		d.bottom = d.down
		d.down = now
	case 'W':
		d.top = d.right
		d.right = d.bottom
		d.bottom = d.left
		d.left = now
	case 'E':
		d.top = d.left
		d.left = d.bottom
		d.bottom = d.right
		d.right = now
	}
}

func roll(d *dice) {
	// tob-bottomを軸にして右回転する
	now := d.up
	d.up = d.right
	d.right = d.down
	d.down = d.left
	d.left = now
}

func check(d1 *dice, d2 *dice) bool {
	return d1.top == d2.top && d1.bottom == d2.bottom &&
		d1.up == d2.up && d1.down == d2.down &&
		d1.left == d2.left && d1.right == d2.right
}

func fullcheck(d0 *dice, d1 *dice) bool {
	found := false
	// d1を転がしてd0と上面を一致させる。一致させられなければその時点で終わり
	ops := "NNNNEEEE"
	for i := 0; i < len(ops); i++ {
		// fmt.Printf("DBG0 - i %d - d0 %v, d1 %v\n", i, *d0, *d1)
		if d0.top == d1.top { // 上面は一致した
			d1c := *d1 // snapshot
			for j := 0; j < 4; j++ {
				// fmt.Printf(" DBG1 - j %d - d0 %v, d1 %v\n", j, *d0, d1c)
				if check(d0, &d1c) {
					found = true
					break
				} else {
					roll(&d1c)
				}
			}
			if found {
				break
			}
		}
		if found {
			break
		}
		move(d1, ops[i])
	}
	return found
}

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]dice, n)
	for i := 0; i < len(d); i++ {
		fmt.Scan(&d[i].top, &d[i].down, &d[i].right, &d[i].left, &d[i].up, &d[i].bottom)
	}
	for i := 0; i < len(d); i++ {
		for j := 0; j < len(d); j++ {
			if i != j && fullcheck(&d[i], &d[j]) {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}



Measured memory_bytes: 1184
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    Integer[] array = new Integer[N];
    int sum = 0;
    for(int i=0; i<N; i++){
      array[i] = sc.nextInt();
    }
    Arrays.sort(array,Collections.reverseOrder());
    for(int j=0; j<K; j++){
      sum += array[j];
    }
    System.out.println(sum);
  }
}

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

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

void logic()
{
    int d,n;
    cin>>d>>n;
    if(d==0)
    {
        if(n<=99) cout<<n;
        else if(n==100) cout<<101;
    }
    else if(d==1)
    {
        if(n<=99) cout<<n*100;
        else cout<<101*100;
    }
    else if(d==2) 
    {
        if(n<=99) cout<<n*10000;
        else cout<<101*10000;
    }
    cout<<"\n";
    //incase of wrong answer...stress test your code...do not stress test yourself
    //overflow,bounds,size,constraints
    //sample tests,corner case/special case(n==0 or n==1 or negative numbers...),some hand written tests
    //read statement carefully
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


Measured memory_bytes: 3636
require 'set'

class Graph
	def initialize
		@nodes = Set.new
		@edges = Set.new
	end

	def add_node(label = nil)
		Node.new(label)
	end

	def add_edge(u, v)
		e = Edge.new(u, v)
		u.outgoings << e
		v.incomings << e
		e
	end
	
	def del_edge(e)
		u, v = e.from, e.to
		u.outgoings.delete(e)
		v.incomings.delete(e)
		e
	end

	class Node
		def initialize(label)
			@label = label
			@outgoings = Set.new
			@incomings = Set.new
		end
		
		def to_s
			@label
		end
		attr_accessor :incomings, :outgoings, :label
	end

	class Edge
		def initialize(u, v)
			@from = u	
			@to = v
		end
		attr_reader :from, :to
	end

	def get_path_dfs(s, t, reached = Set.new)
		reached << s	
		s.outgoings.each{|e|
			v = e.to
			next if reached.include?(v)
			return [e] if v == t
			
			path = get_path_dfs(v, t, reached) 
			return [e] + path if path
		}
		nil
	end
end

def get_ints
	gets.split.map(&:to_i)
end

def min_cost(v, root)
	return v.label if v.incomings.empty? || v.incomings.any?{|e| e.from == root}
	compose_cost = v.incomings.map{|e| min_cost(e.from, root)}.inject(&:+)
	[v.label, compose_cost].min
end

loop {
	n = gets.to_i
	break if n == 0

	g = Graph.new
	nodes = {}

	n.times {
		name, price = gets.split
		price = price.to_i
		nodes[name] = g.add_node(price)
	}

	m = gets.to_i
	m.times {
		a = gets.split
		v = nodes[a.shift]
		a.shift
		a.each {|name| g.add_edge(nodes[name], v)}
	}

	target = nodes[gets.chomp]
	
	p min_cost(target, target)
}

Measured memory_bytes: 6256
import collections
import sys

n,q = map(int,input().split())
data = [[i for i in input().split()]for i in range(n)]
time = 0
while data:
    task = data[0]
    del data[0]
    if int(task[1]) <= q:
        time += int(task[1])
        print(task[0],time)
      
    else:
        time += q
        task[1] = str(int(task[1]) - q)
        data.append(task)

Measured memory_bytes: 16940
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
const int Z=200100;
const int N=Z*2;
int n,q,a[N],b[N],c[N],ans;
int main(){
    for (int i=0;i<=Z;i++)	c[i]=1;
    scanf("%d%d",&n,&q);
    for (int i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[a[i]]++;
        int x=Z+a[i]-b[a[i]]+1;
        c[x]++;
        if (c[x]>1)	ans++;
    }
    while (q--){
        int v,w;
        scanf("%d%d",&v,&w);
        v--;	b[a[v]]--;
        int x=Z+a[v]-b[a[v]];
        c[x]--;
        if (c[x]>=1)	ans--;
        a[v]=w;	b[a[v]]++;
        x=Z+a[v]-b[a[v]]+1;
        c[x]++;
        if (c[x]>1)ans++;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define n 300000
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
struct edge{
	int to, weight;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
vector<edge> V[n + 50];
lli a, b, c, d, e, f;
lli arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;
bool check(lli mid)
{
	lli temp = 0;
	for(int i=0; i<a; i++)
	{
		lli hehe = mid / arr2[i];
		temp += max(0ll, arr1[i] - hehe);
	}
	return temp <= b;
}
bool cmp(int a, int b)
{
	return a > b;
}
void solve()
{
	cin >> a >> b;
	for(int i=0; i<a; i++)
		cin >> arr1[i];
	for(int i=0; i<a; i++)
		cin >> arr2[i];
	sort(arr1, arr1 + a, cmp);
	sort(arr2, arr2 + a);
	lli left = 0, right = 1e12;
	while(left < right)
	{
//		cout << left << ' ' << right << '\n';
		lli mid = (left + right) / 2;
		lli temp = mid;
		if(check(mid)) right = mid;
		else		   left = mid + 1;
	}
	cout << left << '\n'; 
}

Measured memory_bytes: 11904
def solve():
    n, w = map(int, input().split())
    l = [list(map(int, input().split())) for i in range(n)]

    lim = n * 10 ** 3 + 1
    dp = [[10**15 for i in range(lim)] for i in range(n+1)]

    for i in range(n+1):
        dp[i][0] = 0

    for i in range(n):
        for sum_v in range(lim):
            if sum_v-l[i][1]>=0:
                dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - l[i][1]] + l[i][0])
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

    ans = 0
    for sum_v in range(lim):
        if dp[n][sum_v] <= w:
            ans = sum_v

    print(ans)

if __name__ == '__main__':
    solve()

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

int main(void) {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    if((2*n)<m)
    {
        cout<<(n+(m-(2*n))/4)<<"\n";
    }
    else
    {
        cout<<(m/2)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 384
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を返す
    def group_count(self):
        return len(self.roots())

    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    # print()での表示用 ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    com,x,y = map(int, input().split())
    if com == 0:
        uf.union(x,y)
    else:
        if uf.same(x,y):
            print(1)
        else:
            print(0)


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

typedef long long ll;

const int M = (int)2e5;

int a[M + 5];

struct node
{
    int c;
    ll sum;
}tree[M * 4 + 5];

inline int lc(int k)    {return k<<1;}
inline int rc(int k)    {return k<<1|1;}

void update(int k, int l, int r, int a, int b)
{
    if(l == r)
    {
        tree[k].c += b;
        tree[k].sum = 1ll * tree[k].c * (tree[k].c - 1) / 2;
        return;
    }
    int mid = (l + r) >> 1;
    if(a <= mid)    update(lc(k), l, mid, a, b);
    else            update(rc(k), mid + 1, r, a, b);
    tree[k].sum = tree[lc(k)].sum + tree[rc(k)].sum;
}

int main()
{
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; ++i)  scanf("%d", &a[i]);
    for(int i = 2; i <= n; ++i)  update(1, 1, n, a[i], 1);
    printf("%lld\n", tree[1].sum);
    for(int i = 2; i <= n; ++i)
    {
        update(1, 1, n, a[i - 1], 1);
        update(1, 1, n, a[i], -1);
        printf("%lld\n", tree[1].sum);
    }
    return 0;
}


Measured memory_bytes: 12672
#include <stdio.h>

int first_tower(int diff, int height){
    if (diff == 1){
        return (height+1);
    } else {
        return first_tower(diff-1, height+diff);
    }
}

int main(void){
    int first, second, first_height;
    scanf("%d %d", &first, &second);
    first_height = first_tower(second - first - 1, 0);
    printf("%d\n", (first_height - first));
}

Measured memory_bytes: 1704
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;



int main(){
		
		double s;
		cin>>s;
		
		double outp=(s*s*s)/27;
		
		printf("%.12f",outp);
			
		
		

	
		return 0;
}



Measured memory_bytes: 256
def cross(a,b):
    return (a.conjugate()*b).imag
def is_in_triangle(X1,Y1,X2,Y2,X3,Y3,Xp,Yp):
    z1 = complex(X1-Xp,Y1-Yp)
    z2 = complex(X2-Xp,Y2-Yp)
    z3 = complex(X3-Xp,Y3-Yp)
    if cross(z1,z2) * cross(z2,z3) > 0:
        if cross(z2,z3) * cross(z3,z1) > 0:
            return True
    else:
        return False
lst = []
try:
    while True:
        P = tuple(map(float,input().strip().split()))
        lst.append(P)
except EOFError:
    pass
N = len(lst)
for i in range(N):
    if is_in_triangle(*lst[i]):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
n,a,b,c = map(int,input().split())
ans = []
s = [input() for i in range(n)]
for i in range(n):
    
    if s[i] == "AB":
        if a > b:
            a -= 1
            b += 1
            ans.append("B")
        elif a==b:
            if i < n-1:
                if s[i+1] == "AB":
                    a -= 1
                    b += 1
                    ans.append("B")
                elif s[i+1] == "AC":
                    a += 1
                    b -= 1
                    ans.append("A")
                else:
                    a -= 1
                    b += 1
                    ans.append("B")
            else:
                a -= 1
                b += 1
                ans.append("B")

        else:
            a += 1
            b -= 1
            ans.append("A")
    if s[i] == "AC":
        if a > c:
            a -= 1
            c += 1
            ans.append("C")
        elif a==c:
            if i < n-1:
                if s[i+1] == "AC":
                    a -= 1
                    c += 1
                    ans.append("C")
                elif s[i+1] == "AB":
                    a += 1
                    c -= 1
                    ans.append("A")
                else:
                    a -= 1
                    c += 1
                    ans.append("C")
            else:
                a -= 1
                c += 1
                ans.append("C")
        else:
            a += 1
            c -= 1
            ans.append("A")
    if s[i] == "BC":
        if c > b:
            c -= 1
            b += 1
            ans.append("B")
        elif c==b:
            if i < n-1:
                if s[i+1] == "AB":
                    c -= 1
                    b += 1
                    ans.append("B")
                elif s[i+1] == "AC":
                    c += 1
                    b -= 1
                    ans.append("C")
                else:
                    c -= 1
                    b += 1
                    ans.append("B")
            else:
                b -= 1
                c += 1
                ans.append("C")
        else:
            c += 1
            b -= 1
            ans.append("C")
    if a < 0 or b < 0 or c < 0:
        print("No")
        exit()
print("Yes")
for i in ans:
    print(i)


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

int main(){
    ll q, h, s, d;
    ll n;
    cin >> q >> h >> s >> d >> n;

    q *= 4;
    h *= 2;
    ll min = q;
    if(min > h){
        min = h;
    }
    if(min > s){
        min = s;
    }

    ll k = n / 2;
    if(n % 2 == 0){
        if(min * 2 < d){
            cout << min * n << endl;
        }else{
            cout << d * k << endl;
        }
    }else{
        if(min * 2 < d){
            cout << min * n << endl;
        }else{
            cout << d * k + min << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define t(x) cerr<<#x<<":"<<x<<'\n';
#define t2(a,n) { cerr<<#a<<" = "; for(int i=0; i<n; ++i){ cerr << a[i] << ' '; } ; cerr <<'\n'; }
#define t3(a){ cerr<<#a<<" = "; for(auto i: a){ cerr<<i<<" "; } cerr<<'\n'; }
const ll mod = 1e9+7;
// A G C T
// 0 1 2 3
// Not Allowed : AGC
// Return true if state is bad

bool check3(int a, int b, int c ){
	if( a == 0 and b == 1 and c == 2 ){ return true; } // AGC
	if( a == 0 and b == 2 and c == 1 ){ return true; } // ACG
	if( a == 1 and b == 0 and c == 2 ){ return true; } // GAC
	return false;
}
bool check4(int a, int b, int c, int d){
	if( check3(b,c,d) ){ return true; }
	if( a == 0 and c == 1 and d == 2 ){ return true; } // AXGC
	if( a == 0 and b == 1 and d == 2 ){ return true; } // AGXC
	return false;
}

ll dp[105][4][4][4];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(int a=0; a<4; ++a){
		for(int b=0; b<4; ++b){
			for(int c=0; c<4; ++c){
				if(check3(a,b,c)){ continue; }
				dp[3][a][b][c] = 1;
			}
		}
	}

	for(int i=3; i<=n; ++i){
		for(int a=0; a<4; ++a){
			for(int b=0; b<4; ++b){
				for(int c=0; c<4; ++c){
					for(int d=0; d<4; ++d){
						if( check4(a,b,c,d) ){ continue; }
						dp[i+1][b][c][d] += dp[i][a][b][c];
						dp[i+1][b][c][d] %= mod;
					}
				}
			}
		}
	}

	ll ans = 0;
	for(int a=0; a<4; ++a){
		for(int b=0; b<4; ++b){
			for(int c=0; c<4; ++c){
				ans += dp[n][a][b][c];
				ans %= mod;
			}
		}
	}
	cout<<ans<<endl;

	#ifdef LOL
	    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
AB.sort(key=lambda ab: -ab[1])
count = 1
l = AB[0][0]
for a, b in AB[1:]:
    if l < a:
        l = a
    if b <= l:
        l = a
        count += 1
print(count)


Measured memory_bytes: 32264