akhauriyash/Code-Regression huggingface dataset:
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int r;
    int g;
    cin >> r >> g;
    cout << g - r + g << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<short,short> P;
int main(void){
	int n,m;
	cin>>n>>m;
	P a[n],b[m];
	short x,y;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		a[i]=P(x,y);
	}
	for(int i=0;i<m;i++){
		cin>>x>>y;
		b[i]=P(x,y);
	}
	vector<P> cost[n+1];
	vector<short> rin[n+1];
	for(int i=0;i<m;i++){
		P p=b[i];
		rin[p.first].push_back(p.second);
		rin[p.second].push_back(p.first);
	}
	for(int i=0;i<n;i++){
		int lim=a[i].second;
		int flg[n+1]; fill(flg,flg+n+1,0);
		queue<P> q;
		q.push(P(i+1,0));
		while(!q.empty()){
			P p=q.front(); q.pop();
			for(int j=0;j<rin[p.first].size();j++){
				if(rin[p.first][j]!=i+1){
					cost[i+1].push_back(P(rin[p.first][j],a[i].first));
					if(p.second<lim-1&&flg[rin[p.first][j]]!=1){
						flg[rin[p.first][j]]=1;
						q.push(P(rin[p.first][j],p.second+1));
					}
				}
			}
		}
	}
/*	for(int i=1;i<=n;i++){
		for(int j=0;j<cost[i].size();j++){
			cout<<cost[i][j].first<<':'<<cost[i][j].second<<' ';
		}
		cout<<endl;
	}*/
	int leng[n+1]; fill(leng,leng+n+1,M);
	priority_queue<P,vector<P>,greater<P> > que;
	leng[1]=0; que.push(P(0,1));
	while(!que.empty()){
		P p=que.top(); que.pop();
		int v=p.second;
		if(leng[v]<p.first) continue;
		for(int i=0;i<cost[v].size();i++){
			P u=cost[v][i];
			int t=leng[v]+u.second;
			if(leng[u.first]>t){
				leng[u.first]=t;
				que.push(P(t,u.first));
			}
		}
	}
	cout<<leng[n]<<endl;
	return 0;
}


Measured memory_bytes: 209664
#include <iostream>

using namespace std;

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

	for (int i = 3; i <= n; i++)
	{
		bool is = false;
		if (i % 3 == 0)
		{
			is = true;
		}
		else
		{
			for (int j = i; j > 0; j /= 10)
			{
				if (j % 10 == 3)
				{
					is = true;
				}
			}
		}

		if (is)
		{
			cout << " " << i;
		}
	}
	cout << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int64 A, B, N;
int64 f(int64 x) {
    return floor(A * x / B) - A * floor(x / B);
}

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

    // rep(i, N + 1) {
    //     cerr << i << " = " << f(i) << endl;
    // }

    if (B <= N) {
        cout << f(B - 1) << endl;
    } else {
        cout << f(N) << endl;
    }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e+9+7;
long long qpow(long long p,long long q) {
    long long r=1;
    for(;q;p*=p,p%=mod,q>>=1){
    	if(q&1){
    		r*=p,r%=mod;
		}
	}
    return r;
}
long long inv(long long p) {
    return qpow(p,mod-2);
}
const long long N = 1e+6+5;
int f[N],g[N];
int solve(long long i,long long m) {
    memset(f,0,sizeof f);
    memset(g,0,sizeof g);
    g[0]=i+1; 
	f[1]=i+1;
    for(int k=2;k<=m+1;k++){
    	f[k]=f[k-1]*(i+k)%mod*inv(k)%mod;
	}
    for(int j=1;j<=m;j++){
    	g[j]=(g[j-1]+f[j+1])%mod;
	}
    return g[m];
}
signed main(){
    int r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    --r1; 
	--c1;
    cout<<((solve(r2,c2)-solve(r1,c2)-solve(r2,c1)+solve(r1,c1)%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

const ll MAXN=200101;
ll par[MAXN];
ll rnk[MAXN];
ll Size[MAXN];

void init(){
    for(ll i=0;i<MAXN;i++) {par[i]=i; rnk[i]=0; Size[i]=1;}
}

ll sch(ll x){
    if(par[x]==x) return x;
    else return par[x]=sch(par[x]);
}

void con(ll A,ll B){
    A=sch(A);
    B=sch(B);
    if(A==B) return;
    if(rnk[A]>rnk[B]) swap(A,B);
    par[A]=B;
    Size[B]+=Size[A];
    Size[A]=Size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return;
}

ll is_size(ll k){
    return Size[sch(k)];
}

bool same(ll A,ll B){
    return sch(A)==sch(B);
}


int main(){
    init();
    ll N,K; cin>>N>>K;
    vec d(N); rep(i,N) cin>>d[i];
    set<ll> SET,SET2;
    vector<bool> g(N-1,true);
    ll i=0;
    ll MAXFALSE=-INF;
    while(i<N-1){
        if(d[i]<d[i+1]) i++;
        else{
            ll a=max((ll)0,i+2-K), b=min(i+1,N-K+1);
            a=max(a,MAXFALSE);
            REP(j,a,b) g[j]=false;
            MAXFALSE=b-1;
            i++;
            
        }
        if(i>=N-1) break;
    }
    ll memory=INF;
    rep(i,N-K+1) if(g[i]){
        //cout<<i<<endl;
        if(memory==INF) memory=i;
        else con(memory,i);
    }


    rep(i,N){
        SET.insert(d[i]);
        SET2.insert(-d[i]);
        if(SET.size()>K+1) {
            SET.erase(d[i-K-1]);
            SET2.erase(-d[i-K-1]);
            //cout<<"out "<<d[i-K-1];
        }
        //cout<<"in "<<d[i]<<':'<<*SET.begin()<<' '<<-(*SET2.begin())<<endl;
        if(SET.size()==K+1) {
            if(*SET.begin()==d[i-K] && *SET2.begin()==-d[i]) {
                //cout<<*SET.begin()<<' '<<-(*SET2.begin())<<endl;
                con(i-K,i-K+1);
            }
        }
    }
    vector<bool> used(N,false);
    ll ans=0;
    rep(i,N-K+1) if(!used[sch(i)]){
        used[sch(i)]=true;
        //cout<<i<<':'<<sch(i)<<endl;
        ans++;
    }
    cout<<ans<<endl;
    
}


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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);
  rep(i,n-1) {
    int a;
    cin >> a;
    ans[a-1]++;
  }
  for (int x : ans) {
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int K = in.nextInt();
        int res = Integer.MAX_VALUE;
        int prev = 1;
        for (int i = 0; i < N; i++) {
            int A = prev * 2;
            int B = prev + K;
            if (A < B) prev = A;
            else prev = B;
        }
        System.out.println(prev);
    }
}


Measured memory_bytes: 21844
void main() {
	auto ip = readAs!(ulong[]), N = ip[0], A = ip[1], B = ip[2];
	res(N, A, B).writeln;
}

ulong res(ulong N, ulong A, ulong B) {
	if (N == 1) {
		return A == B;
	}

	if (A > B) return 0;
	return (A + B * (N - 1)) - (B + A * (N - 1)) + 1;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
const int  N = 1e6+66;
#define  LL long long

int x[100020];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	sort(x+1,x+1+n);
	int Min=1e9+7;
	for(int i=1;i<=n-k+1;i++){
		Min=min(Min,x[i+k-1]-x[i]);
	}
	printf("%d\n",Min);
	return 0;
}



Measured memory_bytes: 640
<?php
/*
    URL    : http://agc005.contest.atcoder.jp/tasks/agc005_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
    Memo   :
    　文字列操作関数で元の$Xを縮めていくと、それだけでTLEになる。
　　　文字列を1回なめるだけで答えを出す方法を考えないといけない。
 */

fscanf(STDIN, "%s", $X);
$lenX = strlen($X);
$ans = 0;
$s = 0;

for ($i = 0; $i < $lenX; $i++) {
	if ($X[$i] == "S") {
		// Sの在庫を増やす
		$s++;
	}
	if ($X[$i] == "T") {
		if ($s == 0) {
			// もし直近のSがなければ不良在庫として溜まることが確定
			$ans++;
		} else {
			// 直近のSを消費
			$s--;
		}
	}
}

// echo $W . PHP_EOL;
echo ($ans * 2) . PHP_EOL;


Measured memory_bytes: 3960
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<cstring>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
const int N=1e5+10;

template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll a,b,c;

int main() {
	qr(a); qr(b); qr(c);
	if(c-a-b>=0&&4*a*b<(c-a-b)*(c-a-b)) puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 128
def main():
    N,W=map(int,input().split())
    w=[0]*(N+1)
    v=[0]*(N+1)
    for i in range(1,N+1):
        a,b=map(int,input().split())
        w[i]=a
        v[i]=b
    dp=[[0]*(W+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(W+1):
            if j-w[i]>=0:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
            else:
                dp[i][j]=dp[i-1][j]

    print(dp[N][W])

if __name__=="__main__":
    main()

Measured memory_bytes: 118512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    rep(i,n) cin >> A[i];
    rep(i,n) cin >> B[i];
    rep(i,n) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll ans = 0;
    rep(i,n){
        ans += (lower_bound(all(A), B[i]) - A.begin())*
               (C.end() - upper_bound(all(C), B[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
# 選択ソート


def selectionSort(A, N):
    cnt = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if A[i] != A[minj]:
            A[i], A[minj] = A[minj], A[i]
            cnt += 1
    return cnt


N = int(input())
A = list(map(int, input().split()))

cnt = selectionSort(A, N)
print(' '.join(map(str, A)))
print(cnt)



Measured memory_bytes: 5600
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

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

using namespace std;

int main() {
    int n,m;
    cin >>n>>m;
    pair<long, long> p;
    priority_queue<pair<long, long>, vector<pair<long, long> >, greater<pair<long, long> > > qu;
    REP(i,n) {
        cin >> p.first >> p.second;
        qu.push(p);
    }
    
    priority_queue<long> fee;
    long cnt =0;
    REP(i,m+1) {
        while(qu.size() > 0) {
            if(qu.top().first <= i) {
                fee.push(qu.top().second);
                qu.pop();
            } else break;
        }
        if (fee.size() > 0 ) {
            cnt += fee.top();
            fee.pop();
        }
    }
    cout <<cnt << endl;
}

Measured memory_bytes: 3568
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
#  Disjoint Set: Union Find Tree : python3
#  2018.12.23 yonezawa

#from collections import deque
import sys
input = sys.stdin.readline
#import cProfile
#from math import cos,sin,radians,sqrt
from collections import deque

def main():
    (n,q) = map(int,input().split())
    s = [i for i in range(n)]
    dq = [deque() for i in range(n)]
    for i in range(n):
        dq[i].append(i)
    
    
    for i in range(q):
        (a,b,c) = map(int,input().split())
        #print (a,b,c)
        if a == 0:
            sb = s[b]
            sc = s[c]
            if sb == sc:
                continue
            dq[sb].extend(dq[sc])
            dq[sc] = None
            for j in dq[sb]:
                s[j] = sb
        elif a == 1:
            if c in dq[s[b]]:
                print ("1")
            else:
                print("0")
    
if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


Measured memory_bytes: 13736
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int a[3];
int main()
{
    
    int f1=0,f2=0,flag=0;
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
        if(a[i]!=5&&a[i]!=7)
        {
           // cout<<"NO"<<endl;
            flag=1;
            break;
        }
        else
        {
            if(a[i]==5)
                f1++;
            if(a[i]==7)
                f2++;
            if(f1>2||f2>1)
            {
                flag=1;
                break;
            }
        }
    }
    if(flag==1)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//

int main() {
	ll S;
	cin >> N >> K >> S;
	vl A(N);
	for (i = 0; i < K; i++) {
		A[i] = S;
	}
	for (i = K; i < N; i++) {
		if (S == 1000000000) {
			A[i] = 1;
		}
		else {
			A[i] = S + 1;
		}
	}
	for (i = 0; i < N; i++) {
		cout << A[i] << " ";
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

class LazySegmentTree{
public:
	int n = 1;
	vector<int> node[3], lazy;
	vector<bool> lazyF;
	void init(int N){
		while(n < N)n *= 2;
		rep(i,3)node[i].resize(2*n-1);
		lazy.resize(2*n-1);lazyF.resize(2*n-1, false);
	}
	void lazy_evaluate(int k){
		if(lazyF[k] == false)return;
		rep(i,3)node[i][k] = lazy[k];
		if(k < n-1){
			lazy[2*k+1] = lazy[2*k+2] = lazy[k];
			lazyF[2*k+1] = lazyF[2*k+2] = true;
		}
		lazyF[k] = false;
	}
	void update(int a, int b, int x, int k, int l, int r){
		lazy_evaluate(k);
		if(r <= a || b <= l)return;
		if(a <= l && r <= b){
			lazy[k] = x;
			lazyF[k] = true;
			lazy_evaluate(k);
			return;
		}
		update(a, b, x, k*2+1, l, (l+r)/2);
		update(a, b, x, k*2+2, (l+r)/2, r);
		node[0][k] = max(node[0][k*2+1], node[0][k*2+2]);
		node[1][k] = min(node[1][k*2+1], node[1][k*2+2]);
		node[2][k] = node[2][k*2+1]+node[2][k*2+2];
	}
	int calc(int a, int b, int k, int l, int r, int f){
		lazy_evaluate(k);
		if(r <= a || b <= l)return !f ? -INF : f==1 ? INF : 0;
		if(a <= l && r <= b)return node[f][k];
		int vl = calc(a, b, k*2+1, l, (l+r)/2, f);
		int vr = calc(a, b, k*2+2, (l+r)/2, r, f);
		return !f ? max(vl, vr) : f==1 ? min(vl, vr) : vl+vr;
	}
	void replace(int a, int b, int x){update(a, b, x, 0, 0, n);}
	int get_max(int a, int b){return calc(a, b, 0, 0, n, 0);}
	int get_min(int a, int b){return calc(a, b, 0, 0, n, 1);}
	int get_sum(int a, int b){return calc(a, b, 0, 0, n, 2);}
};

signed main(){
	int n, q, MAX = (1LL<<31)-1;
	scanf("%lld%lld", &n, &q);
	LazySegmentTree seg;
	seg.init(n+1);
	rep(i,n)seg.replace(i, i+1, MAX);
	
	rrep(i,q){
		int c, s, t, x;
		scanf("%lld",&c);
		if(c == 0){
			scanf("%lld%lld%lld", &s, &t, &x);
			seg.replace(s, t+1, x);
		}else{
			scanf("%lld", &x);
			printf("%lld\n", seg.get_min(x, x+1));
		}
	}
	return 0;
}








Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

ll diff(ll x, ll y) {
	if (x < y) return y - x;
	else return x - y;
}

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, z, w;
	cin >> n >> z >> w;
	vl a(n); REP(i, n) cin >> a[i];

	if (n == 1) {
		cout << diff(a[0], w) << endl;
		return 0;
	}

	vvl dp(n, vl(2));
	REP(i, n) dp[i][0] = -1;
	REP(i, n) dp[i][1] = TEN(10);
	REP(turn, 2) dp[n - 1][turn] = diff(a[n - 2], a[n - 1]);
	for (ll i = n - 1; i >= 0; --i) REP(turn, 2) {
		if (turn == 0) {
			FOR(j, i + 1, n)dp[i][turn] = max(dp[i][turn], dp[j][!turn]);
			dp[i][turn] = max(dp[i][turn], diff((i == 0 ? w : a[i - 1]), a[n - 1]));
		} else {
			FOR(j, i + 1, n) dp[i][turn] = min(dp[i][turn], dp[j][!turn]);
			dp[i][turn] = min(dp[i][turn], diff((i == 0 ? z : a[i - 1]), a[n - 1]));
		}
	}

	cout << dp[0][0] << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.*;

import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        int apple[] = new int[N+1];
        int sub = 0;
        int min = 1000;
        int c = 0;
        int pie = 0;


        for (int i = 1; i<=N; i++){
            apple[i] = L + i - 1;
            
            if(apple[i] < 0){
                sub = -apple[i];
            }else{
                sub = apple[i];
            }

            if(sub <= min){
                min = sub;
                c = i;
                //System.out.println(c);
            }
            //System.out.println(min);
        }   

        for (int i = 0; i<=N; i++){
            if(i != c){
                pie += apple[i];
            }
            //System.out.println(pie);
        }

        System.out.println(pie);
        
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int N = 2e5 + 1;
//ll int freq[100001];
void findAns()
{
    ll int n;
    cin >> n;

    ll int ans[n];

    ll int actual[n];

    ll int toXor = 0;

    for (int i = 0; i < n; i++) {cin >> actual[i]; toXor ^= actual[i];}

    for (int i = 0; i < n; i++)
    {
        ans[i] = actual[i] ^ toXor;
    }

    for (auto C : ans) cout << C << " ";




}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
// #endif

    fastio;

    // ll int t;
    // cin >> t;

    // while (t--)
    findAns();
}

Measured memory_bytes: 6760
/*GRATITUDE*/
/*1916057*/
//Arise Awake and Stop Not Till the Goal is reached. 
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

/*************************************************************************************************/
//Write your functions here..............................
 


/***************************************************************************************************/

void solve() {
/*Write your code here*/
 int n,x,t;
 cin>>n>>x>>t;
 if(n%x==0) cout<<t*(n/x);
 else cout<<t*(floor(n/x)+1);

}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define CHAL_BC_APNE_BAAP_KO_MAT_SIKHA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fr first
#define se second
signed main()
{
	CHAL_BC_APNE_BAAP_KO_MAT_SIKHA;		
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		if(i%2!=0)
			sum+=a[i];
		else
			sum-=a[i];
	}
	int pos=1;
	cout<<sum<<" ";
	int x=2*a[pos]-sum;
	for(int i=2;i<=n;i++){
		cout<<x<<" ";
		x=2*a[i]-x;
	}
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string a[105],b[105];
    int n,m,c[105],d[105],s[105],vis[105];
    while(cin>>n)
    {
        memset(c,0,sizeof(c));
        memset(d,0,sizeof(d));
        memset(s,0,sizeof(s));
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++)
            cin>>a[i];
            cin>>m;
            for(int i=0;i<m;i++)
            cin>>b[i];
            for(int j=0;j<n;j++)
            for(int i=0;i<n;i++)
                if(a[j]==a[i])
                    {c[j]++;
                    //cout<<a[j]<<c[j]<<endl;
                    }
            for(int j=0;j<m;j++)
            for(int i=0;i<m;i++)
                if(b[j]==b[i])
                    {d[j]++;
                    //cout<<b[j]<<d[j]<<endl;
                    }
                   /* for(int i=0;i<n;i++)
                                cout<<"c"<<c[i]<<endl;
                                for(int i=0;i<m;i++)
                                cout<<"d"<<d[i]<<endl;*/

                    for(int i=0;i<n;i++)
                        for(int j=0;j<m;j++)
                        if(a[i]==b[j])
                        {
                            s[i]=c[i]-d[j];
                            vis[i]=1;
                        }
                        for(int i=0;i<n;i++)
                            if(vis[i]==0)
                        {
                            s[i]=c[i];
                        }

                        int maxn;
                        maxn=0;
                        for(int i=0;i<n;i++)
                           {
                               if(s[i]>maxn)
                            maxn=s[i];}
                            //for(int i=0;i<n;i++)
                             //   cout<<s[i]<<endl;
                        cout<<maxn<<endl;





    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<double, int> P;

int main()
{
    int N; cin>>N;
    int cost[100][100];

    rep(i, N) rep(j, N) cin>>cost[i][j];

    long long ans = 0;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            ans += min(cost[i][j], cost[j][i]);
        }
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 998244353;
const int N = 3e3+10;

ll dp[N][N];
int main(){
fast;

int a,b,c,d;
cin>>a>>b>>c>>d;

fill(dp,0);

for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++) {
        dp[i][j]=1;
    }
}

for(int i=a+1;i<=c;i++) {
    dp[i][b] = (dp[i-1][b]*b)%mod;
}
for(int i=b+1;i<=d;i++) {
    dp[a][i] = (dp[a][i-1]*a)%mod;
}

for(int i=a+1;i<=c;i++) {
    for(int j=b+1;j<=d;j++) {
        dp[i][j]=(i*dp[i][j-1]+j*dp[i-1][j])%mod;
        ll val = (dp[i-1][j-1]*(i-1))%mod;
        val = val*(j-1)%mod;
        dp[i][j]=(dp[i][j]-val)%mod;
        if(dp[i][j]<0)
        dp[i][j]+=mod;
    }
}

cout<<dp[c][d]<<endl;
return 0;
}

Measured memory_bytes: 74340
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))

a=[-i for i in a]
heapq.heapify(a)
for _ in range(m):
     b=heapq.heappop(a)
     heapq.heappush(a,-((-b)//2))

print(-sum(a))

Measured memory_bytes: 20352
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    list<int> ls;
    rep(i, 0, N) {
        string s;
        cin >> s;
        if (s == "insert") {
            int x;
            cin >> x;
            ls.push_front(x);
        } else if (s == "delete") {
            int x;
            cin >> x;
            for (auto it = ls.begin(); it != ls.end(); it++) {
                if (*it == x) {
                    it = ls.erase(it);
                    break;
                }
            }
        } else if (s == "deleteFirst") {
            ls.pop_front();
        } else if (s == "deleteLast") {
            ls.pop_back();
        }
    }

    vector<int> ans;
    for (auto l : ls)
        ans.push_back(l);
    dump_vec(ans);
}



Measured memory_bytes: 33940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;

ll M, D;
ll M2, D2;

void input() {
  IN(M);
  IN(D);
  IN(M2);
  IN(D2);
}

void solve() {
  // if (M == 2 && D == 28) {
  //   ret = 1;
  // } else if ((M == 4 || M == 6 || M == 9 || M == 11) && D == 30) {
  //   ret = 1;
  // } else if (D == 31) {
  //   ret = 1;
  // }
  if (M != M2) {
    ret = 1;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int cnt = 0;

        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                for (int k = 1; k < 10; k++) {
                    int i1 = Integer.parseInt(""  + k + j + i + j + k );
                    if (A <= i1 && i1 <= B) cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_042
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            var ngs = new int[k];
            input = Console.ReadLine().Split(' ');
            for (int i = 0; i < k; i++)
            {
                ngs[i] = int.Parse(input[i]);
            }

            int digit = (int)Math.Log10(n) + 1;
            
            int itel = n;
            while (n < 100000)
            {
                int sub = itel;
                bool isNG = false;
                for (int j = 0; sub>0; j++)
                {
                    int val = sub % 10;
                    for(int l = 0; l < k; l++)
                    {
                        if (val == ngs[l])
                        {
                            isNG = true;
                            break;
                        }
                    }
                    if (isNG) break;
                    sub /= 10;
                }
                if (!isNG) break;
                itel++;
            }
            Console.WriteLine(itel);
        }
    }
}


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int c[3][3],a[3],b[3];
    rep(i,0,3){
        rep(j,0,3){
            cin>>c[i][j];
        }
    }
    a[0]=0;
    rep(i,0,3){
        b[i]=c[0][i]-a[0];
    }
    a[1]=c[1][0]-b[0];
    a[2]=c[2][0]-b[0];

    bool can=true;
    rep(i,0,3){
        rep(j,0,3){
           // cout<<a[i]+b[j]<<" ";
            if(a[i]+b[j]!=c[i][j])can=false;
        }
        //cout<<endl;
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
bool ok(ll tar,vector<ll>&a,vector<ll>&b,ll k)
{
    int n = a.size();
    ll now = 0;
    for(int i=0;i<n;++i)
    {
        if(a[i]*b[n-i-1]>tar)
        {
            now += a[i]-tar/b[n-i-1];
            if(now>k)
            {
                return 0;
            }
        }
    }
    return 1;
}


int main()
{
    
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n),b(n);
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;++i)
    {
        cin>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll l=0,r=1e12;
    while(l<r)
    {
        ll mid=(l+r)/2;
        if(ok(mid,a,b,k))
        {
            r=mid;
        }else{
            l=mid+1;
        }
    }
    cout<<l<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N, K;
  int l[50];
  cin >> N >> K;
  rep(i, N) {
    cin >> l[i];
  }
  sort(l, l+N);
  int ans = 0;
  for(int i = N-1; i >= N - K; i--) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(){
  int N, M;
  scanf("%d %d", &N, &M);

  int like[M];
  int c;
  int i;
  for(i = 0; i < M; i++) like[i] = 0;
  int K, j;

  for(i = 0; i < N; i++){
    scanf("%d", &K);
    for(j = 0; j < K; j++){
      scanf("%d", &c);
      like[c-1]++;
    }
  }
  int sum = 0;
  for(i = 0; i < M; i++){
    if(like[i] == N){
      sum++;
    }
  }

  printf("%d\n", sum);

  return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 W,H,x,y;
    cin >> W >> H >> x >> y;

    cout << ((long double)(H*W))/2;
    cout << " ";
    cout << (W==2*x and H==2*y ? 1 : 0) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import math

A, B, H, M = list(map(int, input().split()))
theta = 2 * math.pi * (H + M / 60) / 12
phi = 2 * math.pi * M / 60
print(((A * math.cos(theta) - B * math.cos(phi))**2 + (A * math.sin(theta) - B * math.sin(phi))**2)**(1/2))

Measured memory_bytes: 9512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n){
    ll j = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll k = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    j = max((ll)0, j);
    ans += j * (n - k);
  }
  cout << ans << endl;

}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    int n,cc=0,ans=0,sum=0;
    cin>>n;
    int a[n+2];
    for (int i=1; i<=n; i++) cin>>a[i];
    a[n+1]=0; a[0]=0;
    for (int i=1; i<=n+1; i++)
    {
        sum+=abs(cc-a[i]);
        cc=a[i];
    }
    for (int i=1; i<=n; i++)
    {
        ans=sum-(abs(a[i-1]-a[i])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]);
        cout<<ans<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1664
h,w,a,b=map(int,input().split())
factorials=[]
inverses=[]
MOD=10**9+7
factorials.append(1)
curr=1
for i in range(1,h+w+1):
  curr=(curr*i)%MOD
  factorials.append(curr)
for i in range(h+w+1):
  inverses.append(pow(factorials[i],MOD-2,MOD))
ans=0
for i in range(h-a):
  ans=(ans+factorials[b-1+i]*factorials[h-2-i+w-b]*inverses[i]*inverses[b-1]*inverses[h-1-i]*inverses[w-b-1])%MOD
print(ans)

Measured memory_bytes: 55500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)  for(ll i = 0; i < (n); ++i)
#define rep1(i,n)  for(ll i = 1;i <= (n); ++i)
#define pb push_back
#define M 1000000007
unordered_map<ll,ll>mp;

int main()
{
    fastIO
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t)
    cout<<"Yes";
    else
    cout<<"No";
	return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n, count=0;cin>>n;
  map<int, bool> d;
  for(int i=0;i<n;i++){
    int x;cin>>x;
    if(d[x])count++;
    else d[x]=true;
  }
  cout << n-count << endl;
}


Measured memory_bytes: 256
N = int(input())
S = N
B = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A = []
li = [0]
li2 = []
for i in range (14):
    li.append(26**(1+i))
a = 0
for j in range (14):
    a += li[j]
    li2.append(a)
k = 0
while(N > li2[k]):
    k+=1

S -= (li2[k-1] +1)
amari = S % 26
K = S
for l in range (k):
    A.append(B[(K//li[k - l])])

    K = K % li[k - l]
A.append(B[amari])
print(''.join(A[1:]))




Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    
    double l, s;
    s = 30.0*h + m/2.0;
    l = 6.0*m;

    double ad, bd, rad;
    ad = a; bd = b;
    rad = M_PI * (l-s) / 180.0;
    // printf("%lf\n", rad);
    printf("%.14lf\n",  sqrt(ad*ad + bd*bd - 2*ad*bd*cos(rad)));
    return 0;
}

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

int main(){
    int N, M; cin >> N >> M;
    int low = -1, high = N, L, R;

    while(cin >> L >> R){
    low = max(low, L);
    high = min(high,R);
    }
    
    cout << max(high - low + 1, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> G[200020];
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int used[200020] = {0}, P[200020] = {0};
    for(int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        P[p] += x;
    }
    used[1]++;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int p = que.front();
        que.pop();
        for (auto x: G[p]){
            if(used[x]) continue;
            P[x] += P[p];
            used[x]++;
            que.push(x);
        }
    }
    for(int i = 1; i <= n; i++){
        cout << P[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 16372