akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,szeof(a))
#define pp pair<ll,ll>
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  ma0t vector<vector<ll>>
#define el cout<<'\n';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N=2*(1e5)+10;
int sze[N];
int par[N];
void ini(){
  for(int i=0;i<N;i++)
  sze[i]=1,par[i]=i;
}
int parent(int x){
  if(par[x]==x)
  return x;
  return par[x]=parent(par[x]);
}
void uni(int x,int y){
  x=parent(x);
  y=parent(y);
  if(x==y)
  return ;
  if(sze[x]<sze[y])
  swap(x,y);
  par[y]=x;
  sze[x]+=sze[y];
  sze[y]=0;
}
void solve(){
  ll n,m;
  cin>>n>>m;
  ini();
  ll u,vv;
  fr(i,0,m){
    cin>>u>>vv;
    uni(u,vv);
  }
vll v(n);
fr(i,1,n+1){
  v[i-1]=sze[i];
}
sort(all(v));
ll ans=0;
ll curr=0;
for(int i=0;i<n;i++){  
  //d1(v[i]);
  if(curr+v[i]>(ll)0){
   
  
    ans+=curr+v[i];
  
    curr-=curr+v[i];
  }

}
cout<<ans;


}
int main()
{
    ll t=1;
  //  cin>>t;
    while(t--)
    {
     solve();
     cout<<endl;
    }
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n+100];
  int temp=0;
  for (int i=0;i<n;i++){
    cin >> temp;
    if (temp<400){
      a[i]=1;
    }
    else if (temp<800){
      a[i]=2;
    }
    else if (temp<1200){
      a[i]=3;
    }
    else if (temp<1600){
      a[i]=4;
    }
    else if (temp<2000){
      a[i]=5;
    }
    else if (temp<2400){
      a[i]=6;
    }
    else if (temp<2800){
      a[i]=7;
    }
    else if (temp<3200){
      a[i]=8;
    }
    else a[i]=9;
  }
  int cnt=0;
  for (int i=1;i<9;i++){
    for (int j=0;j<n;j++){
      if(a[j]==i){
        cnt++;
        break;
      }
    }
  }
  int acnt=0;
  for (int i=0;i<n;i++){
    if(a[i]==9){
      acnt++;
    }
  }
  int minc=0;
  int maxc=0;
  if(cnt==0){
    cnt=1;
  }
  if (n==1){
    cout<<1<<" "<<1<<endl;
    return 0;
  }
  minc=cnt;
  maxc=cnt+acnt;
  if (maxc>n){
    maxc=n;
  }
  
  cout<<minc<<" "<<maxc<<endl;
  
  return 0;
}

      
      
  
  

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

int main() {
  int a,b,c;
  cin >> a >> b >> c ;
  int ans =3;
  if(a==c)
   ans--;
  if(a==b)
    ans--;
  if(c== b)
    ans--;
  if((a == b) && (b == c))
    ans ++ ;
  cout << ans ;
}


Measured memory_bytes: 256
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn next_permutation(v: &mut [i64]) -> bool {
    if v.len() < 2 {
        return false;
    }

    let mut i = v.len() - 1;
    while i > 0 && v[i - 1] >= v[i] {
        i -= 1;
    }

    if i == 0 {
        return false;
    }

    let mut j = v.len() - 1;
    while j >= i && v[j] <= v[i - 1] {
        j -= 1;
    }

    v.swap(j, i - 1);

    v[i..].reverse();

    true
}

fn main() {
    input! {
        n: usize,
        ps: [i64; n],
        qs: [i64; n],
    }
    let mut v = vec![];
    for i in 1..n + 1 {
        v.push(i as i64);
    }

    let mut a = 1i32;
    loop {
        if v == ps {
            break;
        }
        next_permutation(v.as_mut_slice());
        a += 1;
    }

    v.sort();
    let mut b = 1;
    loop {
        if v == qs {
            break;
        }
        next_permutation(v.as_mut_slice());
        b += 1;
    }
    let ans = (a - b).abs();
    println!("{}", ans);
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

employee = {}  # { int : List[int] }

for i,v in enumerate(A_list):
    employee.setdefault(v,[])
    employee[v].append(i+2)

for i in range(1,len(A_list)+2):
    if i in employee:
        print( len(employee[i]) )
    else:
        print(0)


Measured memory_bytes: 55224
#include <bits/stdc++.h>
#define IN(a) scanf("%d",&a);
#define OUT(a) printf(a);
#define REPT(i,n) for (int i=1;i<=(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define BR break;

using namespace std;

int main(){
	
	REPT(i,9)
	{
		REPT(j,9)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}

	return 0;
 }

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 111;
int n, W;
int w[maxn], v[maxn];

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

  cin>>n>>W;
  for (int i=0; i<n; i++) {
    cin>>w[i]>>v[i];
  }

  map<int,int> mp;
  mp[0] = 0;
  
  for (int i=0; i<n; i++) {
    map<int,int> _mp = mp;
    for (auto p: mp) {
      if (p.first + w[i] > W) continue;
      _mp[p.first+w[i]] = max(_mp[p.first+w[i]], p.second+v[i]);
    }
    mp = _mp;
  }

  int val=0;
  for (auto p: mp) {
    if (p.first <= W) {
      val = max(val, p.second);
    }
  }

  cout<<val<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll a[n];
  vector<vector<vector<ll>>> v(n);

  for(ll i=0;i<n;i++){
    cin >> a[i];
    for(ll j=0;j<a[i];j++){
      ll x,y;
      cin >> x >> y;
      v[i].push_back({x-1,y});
    }
  }

  ll m=0;

  for(ll b=0;b<(1<<n);b++){
    bool ok=true;
    for(ll i=0;i<n;i++){
      if(b & (1<<i)){
        for(ll j=0;j<a[i];j++){
          if(v[i][j][1]==0 && (b & (1<<v[i][j][0]))==0);
          else if(v[i][j][1]==1 && (b & (1<<v[i][j][0]))!=0);
          else{
            ok=false;
            break;
          }
        }
      }
      if(!ok)break;
    }
    if(ok)m=max(m,(ll)__builtin_popcount(b));
  }

  cout << m << endl;

}

Measured memory_bytes: 3632
h1, m1, h2, m2, k = map(int,input().split())
if h1 > h2:
    t = 24 * 60 - (h1 * 60 + m1) + h2 * 60 + m2 - k
else:
    t = h2 * 60 + m2 - (h1 * 60 + m1) - k

print(t)

Measured memory_bytes: 61652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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 long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];


int main() {
    int n,ac = 0,wa = 0,tle = 0,re = 0;
    cin >> n;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        if(s == "AC") ac++;
        if(s == "WA") wa++;
        if(s == "TLE") tle++;
        if(s == "RE") re++;
    }
    cout << "AC  x " << ac << endl;
    cout << "WA  x " << wa << endl;
    cout << "TLE  x " << tle << endl;
    cout << "RE  x " << re << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    
    cin>>s;
    for (ll i=0; i<s.size(); i++) {
        if (i%2==s[i]-'0') {
            o++;
        }
    }
    if (o<s.size()-o) {
        ans=o;
    }
    else{
        ans=s.size()-o;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 512
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define along long(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define per(i,a,b) for(long long i=b-1long long;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  n--;
  b -= a;
  a = 0;
  vector<ll> v;
  rep(i,0,n+1){
    ll e = 0;
    e = c*i-d*(n-i);
    v.pb(e);
  }
  ll flag = 0;
  ll f = (d-c)*n;
  rep(i,0,v.sz){
    if(v[i]<=b&&b<=v[i]+f){
      flag = 1;
    }
  }
  if(flag==1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 6128
if __name__=="__main__":
    [N, A, B] = map(int,input().split())
    xs = list(map(int,input().split()))
    d_xs = [xs[i] - xs[i-1] for i in range(1,len(xs))]
    s = 0
    for d in d_xs:
        if(d*A < B):
            s+=d*A
        else:
            s+=B
    print(s)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  char last = '#';
  char first = '#';
  rep(i,n){
    string s;
    cin >> s;
    first = s[0];
    if(i == 0) last = first;
    if(last != first){
      cout << "No" << endl;
      return 0;
    }
    if(mp.count(s)){
      cout << "No" << endl;
      return 0;
    }
    mp[s] ++;
    last = s[s.size()-1];
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,n1;
	cin >> n1;
	n=n1;
	int t=0;
	while(n1/10){
		n1=n1/10;
		t++;
	}
	if(t==5){
		cout <<"90909";
	}else if(t==4){
		cout <<9+900+n%100000-10000+1;
	}else if(t==3){
		cout <<9+900;
	}else if(t==2){
		cout <<9+n%100+1;
	}else if(t==1){
		cout <<"9";
	}else{
		cout<<n%10;
	}
	
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	all := make(map[int]struct{})
	all[a] = struct{}{}
	all[b] = struct{}{}
	all[c] = struct{}{}
	fmt.Println(len(all))
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EPS (1e-8)

typedef complex<double> P;
typedef complex<double> Vec;

struct Line {
	P p;
	Vec v;
	
	Line(P p, Vec v) : p(p), v(v) {}
	
	P getPoint(double t) {
		return p + v * t;
	}
};

struct Circle {
	P p;
	double r;
	
	Circle() {}
	Circle(P p, double r) : p(p), r(r) {}
};

double dot(Vec a, Vec b) {
	return a.real() * b.real() + a.imag() * b.imag();
}

double cross(Vec a, Vec b) {
	return a.real() * b.imag() - a.imag() * b.real();
}

bool isInCircle(P p, Circle c) {
	return norm(c.p - p) < c.r*c.r + EPS;
}

bool isIntersectionSC(Line s, Circle c) {
	if (isInCircle(s.p, c) && isInCircle(s.getPoint(1.0), c)) return false;
	
	Vec a = c.p - s.p, b = c.p - s.getPoint(1.0);
	
	if (dot(s.v, a) < -EPS) return abs(a) < c.r - EPS;
	if (dot(s.v, a) > dot(s.v, s.v) + EPS) return abs(b) < c.r - EPS;
	else return abs(cross(s.v, a)) / abs(s.v) < c.r + EPS;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (!n) break;
		
		Circle wall[100];
		REP(i, n) {
			double x, y, r;
			scanf("%lf %lf %lf", &x, &y, &r);
			wall[i] = Circle(P(x, y), r);
		}
		
		int m;
		cin >> m;
		REP(i, m) {
			double tx, ty, sx, sy;
			scanf("%lf %lf %lf %lf", &tx, &ty, &sx, &sy);
			
			Line s(P(sx, sy), P(tx, ty) - P(sx, sy));
			
			int flag = false;
			REP(j, n) if (isIntersectionSC(s, wall[j])) flag = true;
			
			if (flag) puts("Safe");
			else puts("Danger");
		}
	}
	return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n,ans=0;
    double d;
    cin >> n >> d;
    double x[n],y[n];
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        if(sqrt( x[i]*x[i] + y[i]* y[i] ) <= d)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6828
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> v(h+2, vector<char>(w+2, '#'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> v[i][j];
        }
    }
    for(auto i : v){
        for(auto j : i){
            cout << j;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#import
#import math
#import numpy as np
#= int(input())
#= input()
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

def mod(num):
    return num % (10 ** 9 + 7)

H, W = map(int, input().split())
dp = [[0] * W for _ in range(H)]

for i in range(H):
    a = input()
    for j in range(W):
        if a[j] == "#":
            dp[i][j] = -1

dp[0][0] = 1
for row in range(H):
    for col in range(W):
        if row != 0 or col != 0:
            if row == 0:
                if dp[row][col] != -1:
                    dp[row][col] = dp[row][col - 1]
                else:
                    dp[row][col] = 0
            elif col == 0:
                if dp[row][col] != -1:
                    dp[row][col] = dp[row - 1][col]
                else:
                    dp[row][col] = 0
            else:
                if dp[row][col] != -1:
                    dp[row][col] = mod(dp[row - 1][col] + dp[row][col - 1])
                else:
                    dp[row][col] = 0

print(dp[-1][-1])

Measured memory_bytes: 48308
#include<bits/stdc++.h>
using namespace std;
 
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
bool sortinrev(const pair<int, int>& a, const pair<int, int>& b) {
    return a.first + a.second > b.first + b.second;
}
 
int main()
{
    fast();
    long long  n  , i  ;
    cin>>n;
    long int a[n] ;
    for(i=0;i<n;i++)
    	cin>>a[i] ;
    sort(a,a+i) ;
    double last = a[0] ; 
    for(i=1;i<n;i++)
    	last = ( (double)(last+a[i] )/ (double)2 );
	cout<<last ;
	
	return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;



int main() {
    int a,b,c;
    cin >>a>>b>>c;
    if(a<b && b<c){
        cout<<"Yes"<<endl;
    }
   
    else{
        cout<<"No"<<endl;
    }
 
}


Measured memory_bytes: 3124
// THANK YOU MR SOLVING!!!!!!!!

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define push_back emplace_back
#define endl '\n'

class solver {
private:
    double TIME;

    static const ll INF = static_cast<ll>(1e9) + 7;
    static const int MAXN = static_cast<ll>(1e2) + 17;
    const int MAGIC = 62;

    int n, q;
    vector< pair<int, int> > Q;

public:
    static bool FLAG;

    solver() {
        TIME = static_cast<double>(clock()) / CLOCKS_PER_SEC;
    }

    bool read() {
        if (!(cin >> n >> q))
            return false;

        Q.resize(q);

        forn (i, q)
            cin >> Q[i].first >> Q[i].second;

        return true;
    }

    void solve() {
        vector<int> x(n);

        forn (i, q) {
            x[Q[i].first - 1] ^= 1;
            x[Q[i].second - 1] ^= 1;
        }

        int ans = 0;

        forn (i, n)
            ans |= x[i];

        if (ans == 1)
            cout << "NO\n";
        else
            cout << "YES\n";
    }

    ~solver() {
#ifdef SEREZHKA
        if (FLAG)
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC - TIME << endl;
#endif
    }
};

bool solver::FLAG = true;

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    cerr << std::fixed << std::setprecision(5);

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');
#else
    std::mt19937 rand(time(NULL));
#endif

    while (solver::FLAG) {
        solver solution;

        if (!solution.read())
            solver::FLAG = false;
        else
            solution.solve();
    }

    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int L[N];
  int i, sum, max;

  max = 0;
  sum = 0;

  for(i = 0; i < N; i++){
    scanf("%d", &L[i]);
    sum += L[i];
    if(L[i] > max) max = L[i];
  }

  if(sum - max > max) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, k = load_list()
H = load_list()

h = list(reversed(sorted(H)))
print(sum(h[k:]))

Measured memory_bytes: 27664
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;

  if(N != 1) {
    ll d = (N - 1) % MOD;
    ll n = ((M + 1) / (N - 1) + 1) % MOD;
    ll x1 = ((M + 1) % (N - 1)) % MOD;
    ll xn = (M + 1) % MOD;

    // cout << d << " " << n << " " << x1 << " " << xn << endl;

    ll sum = (((((x1 + xn) % MOD) * n) % MOD) * ((MOD + 1) / 2)) % MOD;

    // cout << sum << endl;

    cout << (xn + (((sum - xn + MOD) % MOD) * 2) % MOD) % MOD << endl;;
  } else {
    cout << (M + 1) % MOD << endl;
  }
}

Measured memory_bytes: 3092
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
const int MaxN = 1e5;
using namespace std;
int ind[MaxN + 5];
int n , m;
void Init(){
	memset(ind , 0 , sizeof(ind));
	for(int i = 1;i <= m;i++){
		int u , v;
		scanf("%d%d" , &u , &v);
		ind[u]++;
		ind[v]++;
	}
}
void Solve(){
	for(int i = 1;i <= n;i++){
		if(ind[i] & 1) {
			printf("NO\n");
			return;
		}
	}
	printf("YES\n");
}
int main()
{
	while(~scanf("%d%d" , &n , &m)){
		Init();
		Solve();
	}
}

Measured memory_bytes: 512
A,B,C,X,Y = map(int,input().split())

ans = 0
  
if (A + B >= C * 2):
  ans += C * 2 * min(X,Y)
  if (X > Y):
      ans += min(C * 2 * (X-Y), A * (X-Y))
  elif (X < Y):
      ans += min(C * 2 * (Y-X), B * (Y-X))
else:
  ans += A * X + B * Y
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, int> pli;
 
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif
 
#define X first
#define Y second
bool iscubic(ll num){
  ll rt = pow((double)num, 1.0/3.0);
  for (ll i = max(0LL, rt - 2); i <= rt + 2; i++){
    if (i * i * i == num) return true;
  }
  return false;
}
const int MAXN = 100100;
const ll SQRT = sqrt(1e10) + 10;
const ll CBRT = cbrt(1e10) + 10;

bool isprime[MAXN];
vector<int> primes;
map<ll, int> sq;

void sieve(){
  memset(isprime, true, sizeof isprime);
  isprime[0] = isprime[1] = false;
  for (ll i = 2; i < MAXN; i++){
    if (isprime[i]){
      primes.push_back(i);
      for (ll j = i * i; j < MAXN; j += i){
	isprime[j] = false;
      }
    }
  }
  for (int x : primes){
    sq[(ll)x * x] = x;
  }
}

vector<pii> factorise(ll num){
  vector<pii> ans;
  for (int x : primes){
    ll cb = (ll)x * x * x;
    if (cb > num) break;
    while (num % cb == 0) num /= cb;
  }
  assert(num != 1);
  for (int x : primes){
    int f = 0;
    if (x > CBRT) break;
    while (num % x == 0) {
      f += 1;
      num /= x;
    }
    f %= 3;
    if (f) ans.emplace_back(x, f);
  }
  if (num == 1) return ans;
  if (sq.count(num)){
    ans.emplace_back(sq[num], 2);
  } else {
    ans.emplace_back(num, 1);
  }
  return ans;
}
 
vector<pii> invert(vector<pii> v){
  for (pii &x : v){
    x.Y = 3 - x.Y;
  }
  return v;
}
 
int main(){
  sieve();
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<ll> tmp(n);
  for (int i = 0; i < n; i++) cin >> tmp[i];
  vector<pli> arr;
  sort(tmp.begin(), tmp.end());
  for (int L = 0, R; L < n; L = R){
    R = L + 1;
    while (R < n && tmp[L] == tmp[R]) R++;
    arr.emplace_back(tmp[L], R - L);
  }
  n = (int)arr.size();
  int cube = 0;
  map<vector<pii>, pii> mmap;
  for (int i = 0; i < n; i++){
    if (iscubic(arr[i].X)) cube = 1;
    else {
      vector<pii> ori = factorise(arr[i].X);
      vector<pii> inv = invert(ori);
      if (mmap.count(ori)){
	mmap[ori].X += arr[i].Y;
      } else if (mmap.count(inv)){
	mmap[inv].Y += arr[i].Y;
      } else {
	mmap[ori] = {arr[i].Y, 0};
      }
    }
  }
  int res = cube;
  for (auto &it : mmap){
    res += max(it.second.X, it.second.Y);
  }
  cout << res << endl;
 
 
  return 0;
}


Measured memory_bytes: 14960
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int M = 1000000 + 5;
const int N = 5111;
const LL mod = 1000000007;
const int MAXM = 1e6 + 5;
const int MAXV = 100000 + 5;
const LL INF = 1e15 + 5;
const int inf = 6000000;

int main() {
#ifdef local
    freopen("input", "r", stdin);
    // freopen("input", "w", stdout);
#endif // local
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n, l, r;
    cin >> n >> l >> r;
    if(r < l) {
        cout << 0 << endl;
    } else if(n == 1) {
        if(l == r)cout << 1 << endl;
        else cout << 0 << endl;
    } else {
        n -= 2;
        cout << (n * (r - l) + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    long long ans=(n/k)*(n/k)*(n/k);
    if(k%2==0 && n>=k/2){
        ans+=(long long)pow((n-k/2)/k+1,3);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp::min;
const MAX: usize = 100004;

#[fastout]
fn main() {
    input! {
        x: usize,
    }
    let mut table = vec![true; MAX];
    for i in 2..min(x, 317) {
        if !table[i] {
            continue;
        }
        for j in (i..MAX).step_by(i).filter(|j| *j >= x) {
            table[j] = false;
        }
    }
    println!("{}", (x..MAX).find(|i| table[*i]).unwrap());
}


Measured memory_bytes: 2300
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int fir=(s[0]-'0')*10+(s[1]-'0');
    int sec=(s[2]-'0')*10+(s[3]-'0');
    if(fir>=1&&fir<=12)
    {
        if(sec>=1&&sec<=12)
            cout<<"AMBIGUOUS";
        else
            cout<<"MMYY";
    }
    else
    {
        if(sec>=1&&sec<=12)
            cout<<"YYMM";
        else
            cout<<"NA";
    }
    cout<<endl;
}

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

int main(){
    int n,k,c=0,ans;
    int i = 1;
    int tmp;
    cin>>n;
    while(i < 10){
        tmp = i * 111;
        i += 1;
        if(tmp - n >= 0){
            ans = tmp;
            cout<<ans<<endl;
            break;
        }
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

#define pll pair<ll,ll>

int main(){
  ll N; cin>>N;
  pll p[N];
  REP(i,N){
    ll x,l; cin>>x>>l;
    p[i] = make_pair(x+l,x-l);
  }
  sort(p,p+N);
  ll f = -pow(10,10);
  ll count = 0;
  for(ll i=0;i<N;i++){
    if(p[i].second>=f){ f = p[i].first; ++count;}
  }
  cout << count<<"\n";
}

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

int main() {
	int N , M;
	cin >> N >> M;
	vector<int>P(M);
	vector<int>Y(M);
	vector<tuple<int, int, int>> vc;
	for (int n = 0;n<M;++n) {
		cin >> P[n]>>Y[n];
		vc.emplace_back(P[n], Y[n], n);
	}
	sort(begin(vc), end(vc));
	vector<pair<int, int>>Ans(M);
	int count = 1;
	for (int n = 0; n < M; ++n) {
		//cout << get<0>(vc[i]) << " " << get<1>(vc[i]) << " " << get<2>(vc[i]) << endl;
		if (0 == n) {
		}
		else {
			if (get<0>(vc[n]) != get<0>(vc[n - 1])) {
				count = 1;
			}
		}
		Ans[get<2>(vc[n])] = make_pair(get<0>(vc[n]),count);
		count++;
	}
	for (int n = 0;n<M;++n) {
		cout << setfill('0') << right << setw(6) << Ans[n].first;
		cout << setfill('0') << right << setw(6) << Ans[n].second << endl;
	}
	return 0;
}

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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const int64_t LINF = 1000000000000000; // = 10^15

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり
 
int main() {
  int N;
  cin >> N;
  vector<int> M(100000, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    M.at(A - 1)++;
  }
  int ans = 0;
  int C = 0;
  for (int i = 0; i < 100000; i++) {
    if (M.at(i) > 0) {
      ans++;
    }
    if (M.at(i) > 1) {
      if ((M.at(i) + C) % 2 == 0) {
        C = 1;
      }
      else {
        C = 0;
      }
    }
  }
  cout << ans - C << endl;
}

Measured memory_bytes: 3772
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

ll dp[N][4], a[N], b[N], c[N];
ll solve(ll i, ll d);
ll n;

int main() {
    fast_io();
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < 4; j++) {
            dp[i][j] = -1;
        }
    }
    cout << solve(0, 0) << "\n";
    return 0;
}

ll solve(ll i, ll d) {
    auto &ans = dp[i][d];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    if (i == n) {
        return ans;
    }
    if (d == 1) {
        ans = max(solve(i + 1, 2) + b[i], solve(i + 1, 3) + c[i]);
    } else if (d == 2) {
        ans = max(solve(i + 1, 1) + a[i], solve(i + 1, 3) + c[i]);
    } else if (d == 3) {
        ans = max(solve(i + 1, 1) + a[i], solve(i + 1, 2) + b[i]);
    } else {
        ans = max({solve(i + 1, 1) + a[i], solve(i + 1, 2) + b[i], solve(i + 1, 3) + c[i]});
    }
    return ans;
}


Measured memory_bytes: 10368
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

int_list = [A, B, C, D, E]
min_int = min(int_list)

if min_int >= N:
    print(5)
else:
    if N%min_int == 0:
        aaa = N // min_int
        print(4+aaa)
    if N%min_int != 0:
        aaa = N // min_int
        print(5+aaa)

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def make_fac_tables_mod_p(n, p):
    fac = [0] * (n + 1)
    fac_inv = [0] * (n + 1)
    mod_inv = [0] * (n + 1)
    fac[0] = fac[1] = 1
    fac_inv[0] = fac_inv[1] = 1
    mod_inv[1] = 1
    for i in range(2, n + 1):
        fac[i] = (fac[i - 1] * i) % p
        mod_inv[i] = p - mod_inv[p % i] * (p // i) % p
        fac_inv[i] = fac_inv[i - 1] * mod_inv[i] % p
    return fac, fac_inv


def nCk_mod_p(fac, fac_inv, n, k, p):
    return ((fac[n] * fac_inv[n - k]) % p) * fac_inv[k] % p


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if K == 1:
        print(0)
        exit()
    if N == 2:
        A.sort()
        print((A[1] - A[0]) % P)
        exit()

    A.sort()

    fac, fac_inv = make_fac_tables_mod_p(N - 2, P)

    n_f = N - K + 1
    f = [0] * (n_f + 1)
    k = K - 2
    for i, n in enumerate(range(k, N - 2 + 1), 1):
        f[i] = (f[i - 1] + nCk_mod_p(fac, fac_inv, n, k, P)) % P

    ans = 0
    for i in range(1, n_f + 1):
        ans = (ans - (f[i] * A[n_f - i]) % P) % P

    for i in range(1, n_f + 1):
        ans = (ans + (f[i] * A[N - n_f + i - 1]) % P) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24628
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

int main () {
	int N, K;
	vector <int> v, d;
	cin >> K >> N;
	for (int i=0; i<N; i++) {
		int tmp;
		cin >> tmp;
		v.push_back (tmp);
	}
	sort (v.begin(), v.end());
	for (int i=0; i<N-1; i++) {
		d.push_back (v[i+1]-v[i]);
	}
	d.push_back (v[0]+K-v[N-1]);
	sort (d.rbegin(), d.rend());
	cout << (K-d[0]) << endl;
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

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

const ll mod = 1e9 + 7;

vector<string> g;

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<vector<ll>> num(3, vector<ll>(n));
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); ++j)
        {
            num[s[j] - 'A'][i]++;
        }
    }
    string ret = "";
    vector<ll> cur = {a, b, c};
    bool f = 0;
    for (int i = 0; i < n; ++i)
    {
        vector<ll> next;
        for (int j = 0; j < 3; ++j)
        {
            if (num[j][i] % 2)
            {
                next.push_back(j);
            }
        }
        if (cur[next[0]] == 0)
        {
            swap(next[0], next[1]);
            if (cur[next[0]] == 0)
            {
                f = 1;
                break;
            }
        }
        if (cur[next[0]] != 0 && cur[next[1]] != 0)
        {
            if (i == n - 1)
            {
                ret += 'A' + next[1];
                break;
            }
            vector<ll> nnext;
            for (int j = 0; j < 3; ++j)
            {
                if (num[j][i + 1] % 2)
                {
                    nnext.push_back(j);
                }
            }
            bool ff = 1;
            for (int j = 0; j < nnext.size(); ++j)
            {
                if (nnext[j] == next[1])
                {
                    ff = 0;
                    break;
                }
            }
            if (ff)
            {
                swap(next[0], next[1]);
            }
        }
        ret += 'A' + next[1];
        cur[next[0]]--;
        cur[next[1]]++;
    }
    
    if (f)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        for (int i = 0; i < ret.size(); ++i)
        {
            cout << ret[i] << endl;
        }
    }
 

    return 0;
}


Measured memory_bytes: 6380
#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>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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;

#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()
#define shandom_ruffle random_shuffle

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);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    if(n < 4) cout << "No";
    else if(n%4 == 0 || ((n-7)%4==0 && n >= 7) || ((n-14)%4 == 0 && n >= 14) || ((n-21)%4 == 0 && n >= 21)) cout << "Yes";
    else cout << "No";
    cout << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
#define MAX 500000
#define INF 2e9
int L[MAX/2+2],R[MAX/2+2];
int cnt;
void merge(int A[],int n,int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)
	{
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++)
	{
		R[i]=A[mid+i];
	}
	L[n1]=INF;
	R[n2]=INF;
	int i=0,j=0;
	for(int k=left;k<right;k++)//合并
	{
     cnt++;
     if(L[i]<=R[j])
     A[k]=L[i++];
     else
     A[k]=R[j++];
}
}
void mergeSort(int A[],int n,int left,int right)
{
	if(left+1<right)
	{
		int mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right); 
	}
}
int main()
{
int A[MAX],n;
cnt=0;
cin>>n;
for(int i=0;i<n;i++)
cin>>A[i];
mergeSort(A,n,0,n);
for(int i=0;i<n;i++)
{
	if(i)
	cout<<" ";
	cout<<A[i];
}
cout<<endl;
cout<<cnt<<endl;
return 0;
 } 


Measured memory_bytes: 6960
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var hn = Sarray();
            var h = hn[0];
            var n = hn[1];
            var dp = Enumerable.Range(0,h+1).Select(x=>100100100).ToArray();
            dp[0] = 0;
            for(var i=0;i<n;i++)
            {
                var ab = Sarray();
                var a = ab[0];
                var b = ab[1];
                for(var j=0;j<h;j++)
                {
                    var nj = Math.Min(j + a, h);
                    dp[nj] = Math.Min(dp[nj], dp[j] + b);
                }
            }
            WriteLine(dp[h]);
        }
    }
}


Measured memory_bytes: 19096
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <string>
#include <math.h>
using namespace std;

int main(){
    long long int n,k,s=0;
    cin>>n>>k;
    vector<long long int>a(10);
    vector<long long int>b(10);
    for(int i=0;i<k;i++){
        cin>>a[i];
        b[a[i]]=1;
    }
    for(int i=n;i<1000000;i++){
        s=i;
        while(s>=10){
            if(b[s%10]==1){
                break;
            }
            s/=10;
        }
        if(b[s%10]==0){
            cout<<i<<endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;



void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	int ans = 0;
	REP(i, N) {
		if ((~i & 1) && (A[i] & 1))ans++;
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> tetra;
vector<int> oddTetra;
int dp[1000000];
int oddDp[1000000];
int N;

const int MAX = 1000000;

void initialize() {
  for (int i = 1;;i++) {
    int n = i * (i + 1) * (i + 2) / 6;
    if (n > MAX) {
      break;
    }
    tetra.push_back(n);
    if (n % 2 == 1) {
      oddTetra.push_back(n);
    }
  }
  fill(dp, dp + 1000000, MAX);
  fill(oddDp, oddDp + 1000000, MAX);
  /*
  for (int i = 0; i < tetra.size(); i++) {
    printf("%d\n", tetra[i]);
  }
  */
}

void solve() {
  dp[0] = oddDp[0] = 0;
  for (int i = 1; i < MAX; i++) {
    for (int j = 0; j < tetra.size(); j++) {
      if (tetra[j] > i) {
        break;
      }
      dp[i] = min(dp[i], 1 + dp[i - tetra[j]]);
    }
    for (int j = 0; j < oddTetra.size(); j++) {
      if (oddTetra[j] > i) {
        break;
      }
      oddDp[i] = min(oddDp[i], 1 + oddDp[i - oddTetra[j]]);
    }
  }
}

int main() {
  initialize();
  solve();
  while (true) {
    scanf("%d ", &N);
    if (N == 0) {
      break;
    }
    printf("%d %d\n", dp[N], oddDp[N]);
  }
}

Measured memory_bytes: 8604
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
//typedef long long LL;
using namespace std;

struct Work{
    int w_time;
    int deadline;

    Work(int w_time_i, int deadline_i){
        w_time = w_time_i;
        deadline = deadline_i;
    }
};

int main(){
    int n;
    int tmp_1;
    int tmp_2;
    int n_time = 0;
    int possible = true;
    vector<Work> work;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_1 >> tmp_2;
        work.push_back(Work(tmp_1, tmp_2));
    }
    sort(work.begin(), work.end(), [](Work &a, Work &b){
        return a.deadline < b.deadline;
    });

    for(int i=0; i<n; i++){
        n_time += work[i].w_time;
        if(n_time>work[i].deadline){
            possible = false;
            break;
        }
    }

    if(possible){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define NUM 200

int main() {
	int n;
	cin >> n;
	int sum = 0;
	rep(i, n) {
		int l, r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum  << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a; cin >> a;
    cout << a + a*a + a*a*a << enld;
    return 0;
}

Measured memory_bytes: 3604