akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define mkp make_pair
#define fi first
#define se second
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,m,cnt;
vector<pii>G[100004];
vector<int>mycol[100004];
vector<pii>g[500004];
int dist[500004];
bool vis[500004];
map<pii,int>mp;
int main(){
	read(n),read(m);
	for (int i=0;i<m;i++){
		int a,b,c;read(a),read(b),read(c);
		G[a].push_back(mkp(b,c));
		G[b].push_back(mkp(a,c));
	}
	for (int i=1;i<=n;i++)
		for (int j=0;j<G[i].size();j++)
			if (mp.find(mkp(i,G[i][j].se))==mp.end())
				mp[mkp(i,G[i][j].se)]=++cnt,mycol[i].push_back(cnt);
	for (int i=1;i<=n;i++){
		for (int j=0;j<G[i].size();j++)
			g[mp[mkp(i,G[i][j].se)]].push_back(mkp(mp[mkp(G[i][j].fi,G[i][j].se)],0));
		for (int j=0;j<mycol[i].size();j++) g[mycol[i][j]].push_back(mkp(cnt+i,0)),g[cnt+i].push_back(mkp(mycol[i][j],1)); 
	}
	for (int i=1;i<=cnt+n;i++)dist[i]=1e8;
	deque<int>dq;dist[1+cnt]=0,dq.push_back(1+cnt);
	while (!dq.empty()){
		int x=dq.front();dq.pop_front();
		if (vis[x]) continue;vis[x]=1;
		for (int i=0;i<g[x].size();i++) if (dist[g[x][i].fi]>dist[x]+g[x][i].se){
			dist[g[x][i].fi]=dist[x]+g[x][i].se;
			if (g[x][i].se==0) dq.push_front(g[x][i].fi);
			else dq.push_back(g[x][i].fi);
		}
	}
	if (dist[cnt+n]==1e8) puts("-1");
	else write(dist[cnt+n]);
}

Measured memory_bytes: 72192
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    LL n,k;cin>>n>>k;
    VI a(n);
    REP(i,n){
        cin>>a[i];
    }

    REP(kk,k){
        VI imos(n);
        REP(i,n){
            imos[max(i-a[i],0)] ++;
            if(i+a[i]+1 < n){
                imos[i+a[i]+1] --;
            }
        }
        FOR(i,1,n){
            imos[i] += imos[i-1];
        }
        bool f = true;
        REP(i,n){
            if(a[i] != imos[i]){
                f = false;
            }
        }
        a = imos;
        if(f){
            break;
        }
        
        //LL sum = accumulate(ALL(a),0);
        //dump(sum)
        //if(sum == n*n){
        //    break;
        //}
    }

    REP(i,n){
        if(i!=0){
            cout<<" ";
        }
        cout<<a[i];
    }
    cout<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 4808
def calc(vy,t):
     return vy*t - g/2*t*t

def cmp(lb,ub,x):
     if x < lb + eps:
          return -1
     elif x > ub - eps:
          return 1
     return 0

def check(qx,qy):
     if qx == 0:
          return 0
     a = g*g/4
     b = qy*g-V*V
     c = qx*qx+qy*qy
     D = b*b-4*a*c
     if D < -eps:
          return 0
     if -eps<=D<0:
          D = 0
     for d in (-1,1):
          tt = (-b+d*D**.5)/(2*a)
          if tt <= 0:
               continue
          t = tt**.5
          vx = qx/t
          vy = qy/t+g*t/2
          if calc(vy,X/vx) < Y - eps:
               return 0
          for L,B,R,T in obstacles:
               l = cmp(B,T,calc(vy,L/vx))
               r = cmp(B,T,calc(vy,R/vx))
               xh = cmp(L,R,vx*(vy/g))
               yh = cmp(B,T,calc(vy,vy/g))
               if l*r <= 0 or not xh and yh*l <= 0:
                    break
          else:
               return 1
     return 0

g = 9.8
eps = 1e-10
N,V,X,Y = map(int,input().split())
obstacles = []
for i in range(N):
     L,B,R,T = map(int,input().split())
     if L < X:
          obstacles.append((L,B,min(R,X),T))

if check(X,Y):
     print('Yes')
     exit()
for L,B,R,T in obstacles:
     if not L or not R:
          continue
     if check(L,T) or check(R,T):
          print('Yes')
          exit()
print('No')



Measured memory_bytes: 5684
#include<bits/stdc++.h>
using namespace::std;
using ll =long long;
#define int ll
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define INF 1000000099
template<class T> using V=vector<T>;

vector<int> finddivisor(int x){
  vector<int> d;
  for(int i=1;i*i<=x;i++){
    if(x%i==0){
      d.push_back(i);
      if(i*i!=x)d.push_back(x/i);
    }
  }
  return d;
}

int quest(int x,int y){
  cout<<'?'<<' '<<x<<' '<<y<<endl;

  int res;cin>>res;
  if(res==-1)exit(0);
  return res;

}

V<ll> dfrs,dfrt;

signed main(){
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int n,s,t;cin>>n>>s>>t;
  int sps=quest(s,t);

  dfrs.assign(n+1,INF);
  dfrt.assign(n+1,INF);
  dfrs[s]=0;
  dfrt[t]=0;


  V<int> ans(1,s);
struct comp{
  bool operator ()(int  x,int y){
    return dfrs[x]>dfrs[y];
  }  
};

  priority_queue<int,vector<int>,decltype(comp())> q;

  rep(i,1,n+1){
    if(i==s || i==t)continue;

    dfrs[i]=quest(s,i);
    dfrt[i]=quest(i,t);
    if(dfrs[i]+dfrt[i]==sps){
      q.push(i);
    }
  }
  q.push(t);

  int now=q.top();q.pop();
  ans.push_back(now);

  while(q.size()){
    int nex=q.top(),dis;
    if(nex==t)dis=dfrt[now];
    else dis=quest(now,nex);

    q.pop();

    if(dfrs[now]+dis+dfrt[nex]==sps){
      ans.push_back(nex);
      now=nex;
    }
    if(now==t)break;
  }

  cout<<'!'<<' ';
  rep(i,0,(int)(ans.size()-1)){
    cout<<ans[i]<<' ';
  }
  cout<<ans.back()<<endl;
}


Measured memory_bytes: 4672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String day = sc.next();
		int i = 0;
		switch (day) {
		case "SUN":
			i = 7;
			break;
		case "MON":
			i = 6;
			break;
		case "TUE":
			i = 5;
			break;
		case "WED":
			i = 4;
			break;
		case "THU":
			i = 3;
			break;
		case "FRI":
			i = 2;
			break;
		case "SAT" :
			i = 1;
			break;
		}

		System.out.println(i);
	}
}

Measured memory_bytes: 21840
#include<stdio.h>
int main(void)
{
	int x,y;
	
	while(1){
		scanf("%d",&x);
		if(x==0) break;
		y=0;
		x=1000-x;
		while(1){
			if(x<1) break;
			if(x>=500){
				x=x-500; y++;
			}
			else if(x>=100){
				x=x-100; y++;
			}
			else if(x>=50){
				x=x-50; y++;
			}
			else if(x>=10){
				x=x-10; y++;
			}
			else if(x>=5){
				x=x-5; y++;
			}
			else{
				x=x-1; y++;
			}
		}
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a1,a2,a3;
  int p;
  
   cin >> n;
   a1 = n / 100;
   a2 = ( n % 100 ) / 10;
   a3 = ( n % 10 );
   p = a1 + a2 + a3;
  
   cout << p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rn0(const i64 e) noexcept { return ran(e); }
constexpr ran rn0(const i64 b, const i64 e) noexcept { return ran(b, e); }
constexpr ran rn1(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rn1(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }


int main() {
  i64 a, b, x;
  cin >> a >> b >> x;
  i64 ten = min(a, b * 2);
  cout << min( 
      { (x / 1000 + !!(x % 1000)) * ten, 
        (x / 1000) * ten + ((x  % 1000) / 500 + !!((x % 1000) % 500)) * b 
        } )
    << endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
using namespace std;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

inline int gcd_of_vector(int *A, int begin, int end){
  int result = A[begin];
  for(int i=begin;i<end;i++){
    result = gcd(A[i],result);
  }
  return result;
}

inline int gcd_of_vector_with_skip(int *A, int skip, int size){
  int result = A[0];
  if(skip==0)result=A[1];
  for(int i=1;i<size;i++){
    if(i==skip)continue;
    result = gcd(A[i],result);
  }
  return result;
}

int main() {
  int N=getint();
  int A[100000];
  for(int i=0;i<N;i++)A[i]=getint();

  if(N>=100){
    cout<<max(gcd_of_vector(A,0,N/2),gcd_of_vector(A,N/2,N))<<"\n";
  }else{
    int ans=0;
    for(int i=0;i<N;i++){
      ans=max(ans,gcd_of_vector_with_skip(A,i,N));
    }
    cout<<ans<<"\n";
  }
  return 0;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 2e3 + 10;

int n;
int A[N], sum;
bitset<N*N> S;

int main(){

	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &A[i]), sum += A[i];

	S[0] = 1;
	For(i, 1, n) S |= S << A[i];
	For(i, (sum + 1) / 2, sum) if(S[i]){
		printf("%d\n", i);
		return 0;
	}

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int h[n];
  rep(i,n) cin>>h[i];
  int dp[n];
  dp[0] = 0;dp[1] = abs(h[1] - h[0]);
  FOR(i, 2, n) {
    dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
import bisect
import math
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    A_sum = sum(A)
    A_cumsum_l = [0 for _ in range(N)]
    A_cumsum_l[0] = A[0]
    for i in range(1,N):
        A_cumsum_l[i] = A_cumsum_l[i-1] + A[i]
    A_cumsum_r = [0 for _ in range(N)]
    for i in range(N):
        A_cumsum_r[i] = A_sum - A_cumsum_l[i]
    
    index = 0
    sub = 10**12
    for i in range(N):
        if abs(A_cumsum_l[i]-A_cumsum_r[i])<sub:
            index = i
            sub = abs(A_cumsum_l[i]-A_cumsum_r[i])


    print(sub)


if __name__ == "__main__":
    main()

Measured memory_bytes: 102016
#include <stdio.h>
#define MAX 100000

int n,k;
long long T[MAX];
int check(long long P);
int solve();

int main(void){
	scanf("%d %d",&n,&k);
	for(int i; i < n; i++){
	scanf("%d", &T[i]);
	}
	long long ans = solve();
	printf("%d\n",ans);


}

int check(long long P){
	int i = 0;
	for(int j = 0;j < k ;j++){
	long long s=0;
		while( s + T[i] <= P){
		s += T[i];
		i++;
		if(i == n) return n;
		}
	}
	return i;
}

int solve(){
	long long left = 0;
	long long right = 100000 * 10000;
	long long mid;
	while(right - left > 1){
	mid = (left + right) / 2;
	int v = check(mid);
	if(v >= n) right = mid;
	else left = mid;
	}
	return right;
}


Measured memory_bytes: 2584
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

//
// solution 
//
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        M: usize,
    }
    
    for r in (1..M/N+1).rev() {
        if M % r == 0 && M / r >= N {
            println!("{}", r);
            break;
        }
    }

}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    map<string, int> t;
    int k;
    cin >> s >> k;
    int n = s.length();
    int m = min(n, k);
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (i+j >= n+1) break;
            string u = s.substr(i, j);
            t[u] = 1;
        }
    }
    int count = 0;
    for (auto x: t) {
        if (count == k-1) cout << x.first << std::endl;
        count++;
    }
    return 0;
}

Measured memory_bytes: 1920
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;

void main()
{
	foreach (i; 1..10) {
		foreach (j; 1..10) {
			writefln("%dx%d=%d", i, j, i * j);
		}
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}



Measured memory_bytes: 2320
use std::io::*;
use std::str::FromStr;
use std::char::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;

fn func(x: i64) -> i64 {
    match x {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    }
}

fn main(){
    let x: i64 = read();
    let y: i64 = read();

    let mut ans = 0;
    ans += func(x);
    ans += func(y);
    println!("{}", if x==1 && y==1 {ans+400000} else {ans});
}

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

using namespace std;

int dp[3000+2][3000+2];
string s, t;

string backtrack(int i, int j){
 if(i == 0 || j == 0)
   return "";
 if(s[i] == t[j])
   return backtrack(i-1, j-1) + s[i];
 if(dp[i][j-1] > dp[i-1][j])
   return backtrack(i, j-1);
 return backtrack(i-1, j);
}

int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cin >> s >> t;
 s = ' ' + s;
 t = ' ' + t;
 for(int i=1; i<(int)s.length(); ++i){
   for(int j=1; j<(int)t.length(); ++j){
      if(s[i] == t[j]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
   }
 }
 cout << backtrack(s.length()-1, t.length()-1) << "\n";
 return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    if(n < b){
        cout << floor(a * (double)n / b) - a * floor((double)n / b) << endl;
    }else{
        cout << max(floor(a * (double)n / b) - a * floor((double)n / b), floor(a * (double)(b - 1) / b) - a * floor((double)(b - 1) / b)) << endl;
    }
}


Measured memory_bytes: 3872
#include<bits/stdc++.h>
#define ll long long
#define reg(i,x) for(ll i=0;i<x;i++)
#define regi(i,a,x) for(ll i=a;i<x;i++)
#define rev(i,n) for(ll i=n-1;i>0;i--)
#define vi vector<ll>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define pb push_back
//bool sortbysec(const std::pair<int,int> &a, const std::pair<int,int> &b) return (a.second < b.second);
// sort(v.begin(),v.end(),sortbysec);
//vector<vector<char>>v(n,vector<char>(m));
using namespace std;
int main()
{
    int n;
    cin>>n;
    vi v(2*n);
    reg(i,2*n) cin>>v[i];
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<2*n;i+=2)
    {
        ans+=min(v[i],v[i+1]);
    }
    cout<<ans;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  int x;
  cin>>x;
  cout<<abs(x-1)<<endl;
return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				list.add(in.nextInt());
			}
			Collections.sort(list);
			long total = 0;
			for (int i = 0; i < n - k; i++) {
				total += list.get(i);
			}
			out.println(total);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 60592
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int n, p[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	int an = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] > p[i + 1] && p[i] < p[i - 1]) || (p[i] < p[i - 1] && p[i + 1] == p[i - 1]) || (p[i] < p[i - 1] && p[i + 1] == p[i - 1])) {
			an++;
		}
	}
	printf("%d", an);
	return 0;
}

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

using namespace std;

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

    vector<int> a(n);
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] > x) {
            int tmp = a[i] - x; //はじめからxを超えている分は除く
            a[i] -= tmp;
            ans += tmp;
        }
    }

    for (int i = 0; i < n - 1; ++i) {
        int diff = a[i] + a[i + 1] - x;
        if (diff > 0) {
            ans += diff;
            if (a[i + 1] >= diff) {
                a[i + 1] -= diff;
            } else {
                a[i + 1] = 0; //残りはa[i]からとる。ここには書かない
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
/* 
* ID: juryc
* PROG: Next Prime
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int x; cin>>x;
int i=2;
while(true){
int flag=1;
for(int j=2;j*j<=i;j++){ if(i%j==0) flag=0;}
if(flag&&i>=x) { cout<<i<<"\n"; return 0;}
i++; 
}
return 0;
}

Measured memory_bytes: 3600
/* Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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



ll calc(string s){
    if(s.size() == 1){
        ll c = s[0]-'0';
        return c/2;
    }
    ll val = 0;
    ll ans = 4LL;
    if(s.size() > 2){
      ll prod = 10LL*(pow(10LL, s.size()-2)-1LL)/9LL;
      ans *= prod;
    }
    for(int i = 0; i < s.size()-1; i++){
        ll c = s[i] - '0';
        c = 9LL-c;
        c /= 2LL;
        ll prod = 10LL*(pow(10LL, i)-1LL)/9LL;
        val -= c*prod;
    }
    ll c = s[s.size()-1] - '0';
    c /= 2LL;
    ll prod = 10LL*(pow(10LL, s.size()-1)-1LL)/9LL;
    val += c*prod;
    cout << ans << " " << val << endl;
    if(c > 1) ans += val;
    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector <int> vec(n);
    int cur = 1;
    for(int i = 0; i < n; i++){
       cin >> vec[i];
       if(cur == vec[i]) cur++;
    }
    cur--;
    if(cur == 0){
        cout << -1;
        return 0;
    }
    cout << n-cur;

}


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

int main() {
    int x;
    cin >> x;
    vector<bool> dp(x + 1);
    dp.at(0) = true;
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < x; j++) {
            if (!dp.at(j)) continue;

            if (j + 100 + i <= x) dp.at(j + 100 + i) = true;
        }
    }

    cout << (dp.at(x) ? 1 : 0) << endl;
}

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

int main()
{
	int n,sat=0;
	cin >> n;
	
	int a[n+5],b[n+5],c[n+5], before=0;
	
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++) cin >> b[i];
	for(int i=1;i<=n-1;i++) cin >> c[i];
	
	for(int i=1;i<=n;i++)
	{
		if( before+1==a[i] && before!=0)
		{
			sat+=c[before];
		}
		sat += b[a[i]];
		before = a[i];
	}
	cout << sat << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
  
#define INF 2000000010
#define mod7 1000000007
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define INF_LL 9223372036854775
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double 
 
using namespace std;

#define MAX_N 105

int N;
int A[MAX_N];

void input(){

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

}

int main(){

  input();

  int ans = INF;
  for(int i = -100; i <= 100; i++){
    int tmp = 0;
    for(int j = 0; j < N; j++){
      tmp += pow(i-A[j], 2);
    }
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;

}


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

int main() {
  ll x;
  cin >> x;

  const ll xmax = 1e6;
  vector<ll> primes(xmax, true);

  ll i = 1;
  while (true) {
    i++;
    if (!primes[i]) continue;
    for (ll j = i; j < xmax; j += i) {
      primes[j] = false;
    }
    if (x <= i) break;
  }

  cout << i << endl;
}


Measured memory_bytes: 8064
n = gets.to_i
as = []
max = -1
n.times do
  as << gets.to_i
end
max_num = as.sort[-1]
max2_num = as.sort[-2]
max_cnt = as.count { |a| a == max_num }

as.each do |a|
  if max_cnt >= 2
    puts max_num
  elsif a == max_num
    puts max2_num
  else
    puts max_num
  end
end

Measured memory_bytes: 10076
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef double ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
long long int gcd(long long int a,long long int b)
{
    ///here gcd(a,b) == gcd(a-b,b);

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

  ///  return (a*b)/gcd(a,b);
  ///same line

  return (a/gcd(a,b)*b);

}



  int main(){
  double n,a,ans=0;cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    ans+=1/a;
  }
  cout<<fixed<<setprecision(10)<<1/ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int S; cin >> S;
  bool x = (S/100<=12&&S/100!=0);
  bool y = (S%100<=12&&S%100!=0);
  string result = "NA";
  if (x&y) result = "AMBIGUOUS";
  else if (!x&y) result = "YYMM";
  else if (x&!y) result = "MMYY";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int  N;
    cin >>N;
    vector <char> A(N,0);//入力
    for(int j=0; j<N; j++){
       cin>>A[j];
     }

    int hal;//中心の値
    hal=N/2;

    int jud=0;//判定0=Yes 1=No

    if(N%2!=0){
       jud=1;
       
    }else{
     for(int i=0; i<hal; i++){
        if(A[i]!=A[hal+i]){
            jud=1;
        }
     }

    }
    
    if(jud==0){
        cout<< "Yes" <<endl;
    }else{
         cout <<"No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  else:
    print(2)
elif a == 2:
  if b == 1:
    print(3)
  else:
    print(1)
else:
  if b == 2:
    print(1)
  else:
    print(2)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 string S;
 cin>>S;
 string a=S.substr(0,2);
 string b=S.substr(2,2);
 if(a=="00"&&b>="13"){cout<<"NA"<<endl;}
 else if(a>="13"&&b=="00"){cout<<"NA"<<endl;}
 else if(a=="00"&&b=="00"){cout<<"NA"<<endl;}
 else if(a>="13"&&b>="13"){cout<<"NA"<<endl;}
 else if(a>="13"&&b<"13"){cout<<"YYMM"<<endl;}
 else if(a=="00"&&b<"13"){cout<<"YYMM"<<endl;}
 else if(a<"13"&&b>="13"){cout<<"MMYY"<<endl;}  
 else if(a<"13"&&b=="00"){cout<<"MMYY"<<endl;}
 else if(a<"13"&&b<"13"){cout<<"AMBIGUOUS"<<endl;}


 return 0;}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
def main():
    A = deque(list(input().rstrip()))
    B = deque(list(input().rstrip()))
    C = deque(list(input().rstrip()))
    A.append('e')
    B.append('e')
    C.append('e')
    tmp = A.popleft()
    last = ''
    while True:
        if tmp == 'e':
            print(last.upper())
            return
        if tmp == 'a':
            last = tmp
            tmp = A.popleft()
        if tmp == 'b':
            last = tmp
            tmp = B.popleft()
        if tmp == 'c':
            last = tmp
            tmp = C.popleft()

if __name__ == '__main__':
    main()

Measured memory_bytes: 9308
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String head = s.substring(0,2);
		String tail = s.substring(2,4);

		int intHead = Integer.parseInt(head);
		int intTail = Integer.parseInt(tail);

		if(1 <= intHead && intHead <= 12 && 1 <= intTail && intTail <= 12) {
			System.out.println("AMBIGUOUS");
		}else if(1 <= intHead && intHead <= 12) {
			System.out.println("MMYY");
		}else if(1 <= intTail && intTail <= 12) {
			System.out.println("YYMM");
		}else {
			System.out.println("NA");
		}
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
#define ARRAY_MAX 100

/*dp[i+1][j]:i問目まで解いて得点がj点*/

int n;
int p[ARRAY_MAX+1];
int dp[ARRAY_MAX + 1][ARRAY_MAX*ARRAY_MAX + 1];

void solve(){

    dp[0][0] = 0;
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= ARRAY_MAX*ARRAY_MAX;j++){
            if(j < p[i]){
                dp[i+1][j] = dp[i][j];//ない
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i][j-p[i]]+p[i]);//解くか解かないか
            }
        }

    }
    
    int ans = 0;
    for(int i = 0;i < ARRAY_MAX*ARRAY_MAX;i++){
        if(dp[n][i] % 10 != 0){
            //cout << "a" << endl;
            ans = max(ans,dp[n][i]);
        }
        //cout << "b" << endl;
    }
    cout << ans << endl;

}

int main(){    

    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> p[i];
    }
    solve();

    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <algorithm>
#include <string.h>

int main(){
	int nagasa;
	int tile_num;
	scanf("%d%d", &nagasa, &tile_num);
	int x, y;
	for (int a = 0; a < tile_num; a++){
		scanf("%d%d", &x, &y);
			if(nagasa - std::max(x, y) > std::min(x, y)){
			switch (std::min(x, y) % 3){
			case 0:
				puts("3");
				break;
			case 1:
				puts("1");
				break;
			case 2:
				puts("2");
				break;
			}
		}
		else{
			switch ((nagasa - std::max(x, y)) % 3){
			case 0:
				puts("1");
				break;
			case 1:
				puts("2");
				break;
			case 2:
				puts("3");
				break;
			}
		}
	}

	return 0;
}

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

int A, B;
string S;

int main() {
    cin >> A >> B >> S;
    stringstream stream;
    stream << "^[0-9]{" << A << "}-[0-9]{" << B << "}$";
    regex r = regex(stream.str());

    if (regex_match(S, r)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define MAX 10000
#define NIL -1
using namespace std;
struct Node { int p, l, r; };
Node T[MAX];
int n;
void preParse(int u) {
    if (u == NIL)return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}
void inParse(int u) {
    if (u == NIL)return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}
void postParse(int u) {
    if (u == NIL)return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}
int main() {
    int i, v, l, r, root;
    cin >> n;
    for (i = 0; i < n; i++)T[i].p = NIL;
    for (i = 0; i < n; i++) {
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if (l != NIL)T[l].p = v;
        if (r != NIL)T[r].p = v;
    }
    for (i = 0; i < n; i++)if (T[i].p == NIL)root = i;
    puts("Preorder");
    preParse(root);
    puts("");
    puts("Inorder");
    inParse(root);
    puts("");
    puts("Postorder");
    postParse(root);
    puts("");
    return 0;
}


Measured memory_bytes: 3220
def is_753(N):
    x=[0,0,0,1]
    s=str(N)
    for i in s:
        if(i == '3'):
            x[0]+=1
        elif(i == '5'):
            x[1]+=1
        elif(i == '7'):
            x[2]+=1
        else:
            x[3]=0
    if(x[0]*x[1]*x[2]*x[3]!=0):
        return True
    else:
        return False

def dfs(li,x,lim):
    if(is_753(x) and x<=lim):
        li.append(x)
    if(x<=10**9):
        dfs(li,10*x+3,lim)
        dfs(li,10*x+5,lim)
        dfs(li,10*x+7,lim)



N = int(input())
li = []
dfs(li,0,N)
print(len(li))

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;++i){
        string s=to_string(i);
        int c=s.size();
        int sum=0;
        rep(j,c){
            int d=ctoi(s[j]);
            sum+=d;
        }
        if(a<=sum&&sum<=b)ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	ll r = 0, l = 1e9;
	while (l - r > 1) {
		ll mid = (l + r) / 2;
		ll cnt = 0;
		rep(i, n) {
			if (mid * b < h[i]) {
				cnt += ((h[i] - b * mid) % (a - b) == 0 ? (h[i] - b * mid) / (a - b) : (h[i] - b * mid) / (a - b) + 1);
			}
		}
		if (cnt <= mid) l = mid;
		else r = mid;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && m == 0)
				break;
			int[] d = new int[n];
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {
				d[i] = sc.nextInt();
				p[i] = sc.nextInt();
			}
			int[] pr = new int[n];
			for (int i = 0; i < n; i++)
				pr[i] = p[i];
			Arrays.sort(pr);
			for (int i = n - 1; i >= 0; i--) {
				for (int j = 0; j < n; j++) {
					if (pr[i] == p[j]) {
						if (d[j] == 0)
							continue;
						if (d[j] < m) {
							m -= d[j];
							d[j] = 0;
							break;
						}
						if (d[j] >= m) {
							d[j] -= m;
							m = 0;
							break;
						}
					}
				}
				if (m == 0)
					break;
			}
			int result = 0;
			for (int i = 0; i < n; i++)
				result += p[i] * d[i];
			System.out.println(result);
		}
		sc.close();
	}
}

Measured memory_bytes: 93968
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	lli n, k; cin >> n >> k;
	vector<mp> v;
	
	rep(i, n){
		int a, b; cin >> a >> b;
		v.push_back(mp(a, b));
	}
	sort(v.begin(), v.end());
	
	lli s = 0, c = 0;
	while(k > s+v[c].sec){
		s += v[c].sec;
		c++;
	}
	cout << v[c].fir << endl;
	
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin >> s;
	int i;
	int n = s.length();
	int cnt[2] = {0,0};
	for(i=0;i<n;i++){
		if(s[i] == '0') cnt[i%2]++;
		else cnt[(i+1)%2]++;
	}
	if(cnt[0]>cnt[1]) cout << cnt[1];
	else cout << cnt[0];
} 

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

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

	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	sort(a.begin(), a.end());

	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	
	for (int i = 0; i < n; i++) {	
		if ((sum - a[i]) % 10 != 0) {
			cout << sum - a[i] << endl;
			return 0;
		}	
	}
		
	cout << 0 << endl;
	return 0;
}

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

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

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

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

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

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

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

  double L;
  cin >> L;

  double T = L / 3;

  cout << setprecision(20) << T * T * T << endl;




  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef pair<int,int> pint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

string s;

int main() {
	
	cin>>s;
	if(s[0]=='a'&&s[1]=='b'&&s[2]=='c') cout<<"Yes"<<endl;
	else if(s[0]=='a'&&s[2]=='b'&&s[1]=='c') cout<<"Yes"<<endl;
	else if(s[1]=='a'&&s[0]=='b'&&s[2]=='c') cout<<"Yes"<<endl;
	else if(s[1]=='a'&&s[2]=='b'&&s[0]=='c') cout<<"Yes"<<endl;
	else if(s[2]=='a'&&s[0]=='b'&&s[1]=='c') cout<<"Yes"<<endl;
	else if(s[2]=='a'&&s[1]=='b'&&s[0]=='c') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll a,b,c,ans=0;
    cin>>a>>b>>c;
    //cを全部食えるか
    if(c<=a+b){
        //この場合cを全部食って、おいしい解毒ｸｯｷｰ全部食べて終わり
        ans+=c;
        ans+=b;
        cout<<ans<<endl;return 0;
    }
    //毒を全部くらえなかった
    //食えるだけ毒を食う
    ans+=a+b;
    ans++;ans+=b;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
// Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    double a, b, c;
    cin >> a >> b >> c;
    dump(a * b / 2);
    return 0;  
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

string S;
int N;
int main(void){
    cin >> S;
    N=S.length();

    vector<int> v;
    rep(i,N-1){
        if(S[i] == 'R' and S[i+1] == 'L') v.push_back(i);
    }
    int r=0, l=0;
    vector<PI> VP;
    rep(i,N){
        if (S[i] == 'R') r++;
        if (S[i] == 'L') l++;
        if(i==N-1 or (S[i]=='L' and S[i+1]=='R')){
            VP.push_back(PI(r, l));
            r = 0;
            l = 0;
        }
    }

    int results[N];
    rep(i,N) results[i] = 0;
    for(int i=0;i<v.size();i++){
        int a = v[i];
        PI b = VP[i];
        results[a] = ceil(b.first/2.0) + b.second/2;
        results[a+1] = b.first/2 + ceil(b.second/2.0);
    }
     rep(i,N) cout << results[i] << " ";
    cout << endl;

    return 0;
}



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

bool isprime(int n){
  if(n==2)
    return true;
  else if(n<2||n%2==0)
    return false;
  for(int i=3;i<=sqrt(n);i++)
    if(n%i==0)
      return false;
  return true;
}
int main(void){
  int n,m,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>m;
    if(isprime(m))
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3060