akhauriyash/Code-Regression huggingface dataset:
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        String n=sc.next();
  		char a=n.charAt(0);
  		int b=(int) a;
  		b++;
  		char c= (char)b;    
  System.out.println(c);
    }
}

Measured memory_bytes: 23760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() << 14)+rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, a[200005], b[200005], p[2], c, x, ans;
bool cbit;
vector<int> v[2];
vector<pair<int, bool> > w;
int main(){
    cin >> n;
    fox(l, n) scanf("%i", a+l);
    fox(l, n) scanf("%i", b+l);
    sort(b, b+n);
    fox(l, 29){
        v[0]=v[1]=vector<int>(); p[0]=p[1]=0;
        fox(l2, n){
            //cout << a[l2]%(1<<l) << ' ';
            v[bool(a[l2]&(1<<l))].pb(a[l2]%(1<<l));
        }
        //cout << endl;
        sort(v[0].begin(), v[0].end());
        sort(v[1].begin(), v[1].end());
        int c=0;
        w.clear();
        fox(l2, n){
            x=b[l2]%(1<<l);
            cbit=(b[l2]&(1<<l));
            w.pb(mp(x, cbit));
        }
        sort(w.rbegin(), w.rend());
        fox(l2, w.size()){
            x=w[l2].x; cbit=w[l2].y;
            while(p[0]<v[0].size() && v[0][p[0]]+x<(1<<l)) p[0]++;
            while(p[1]<v[1].size() && v[1][p[1]]+x<(1<<l)) p[1]++;
            c=(c+(v[cbit].size()-p[cbit])+(p[!cbit]))%2;
        }
        ans+=c*(1<<l);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4836
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
#ifndef ONLINE_JUDGE
    scanf("%lld", &a);
#else
    scanf("%I64d", &a);
#endif
    return a;
}

#define L 2147483600
#define EXIT() printf("0\n"); exit(0)

vector<pair<int, ll> > ne[100000];
ll mnx, mxx;
int v[100000];
int resx[100000];
ll resc[100000];

void dfs(int a, int x, ll c) {
    if (v[a])
        return;
    v[a] = 1;
    resx[a] = x;
    resc[a] = c;
    if (x == 1)
        mnx = MAX(mnx, 1LL-c);
    else
        mxx = MIN(mxx, c-1LL);
    vector<pair<int, ll> > &vec = ne[a];
    int l = vec.size();
    for (int i = 0; i < l; i++) {
        pair<int, ll> &p = vec[i];
        int b = p.first;
        ll s = p.second;

        if (v[b]) {
            int rx = resx[b];
            ll tc = resc[b] + c;
            if (rx == x) {
                ll x2 = x*(s-tc);
                if (((x2 % 2)+4)%2) {
                    EXIT();
                }
                x2 /= 2;
                mnx = MAX(mnx, x2);
                mxx = MIN(mxx, x2);
            } else if (tc != s) {
                EXIT();
            }
        } else
            dfs(b, -x, s-c);
    }
}

int main() {
    int n = gi();
    int m = gi();
    for (int i = 0; i < m; i++) {
        int x = gi()-1;
        int y = gi()-1;
        ll s = gi();
        ne[x].push_back(make_pair(y, s));
        ne[y].push_back(make_pair(x, s));
    }

    mnx = 0;
    mxx = 1500000000;
    memset(v, 0, sizeof(v));
    dfs(0, 1, 0);

    cout << (mnx > mxx ? 0LL : mxx-mnx+1LL) << endl;

    return 0;
}


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

#define MAXN (100010)

int n, t;
int a[MAXN];

int main(){
	scanf("%d%d", &n, &t);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
	}
	int maxDelta = 0, nowmax = a[n];
	for(int i = n - 1; i; -- i){
		maxDelta = std::max(maxDelta, nowmax - a[i]);
		nowmax = std::max(nowmax, a[i]);
	}
	int ans = 0;
	nowmax = a[n];
	for(int i = n - 1; i; -- i){
		ans += nowmax - a[i] == maxDelta;
		nowmax = std::max(nowmax, a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
   int l[100], v[100], i, lon;
   double M, L, t, V;
   while ( (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &l[10], &v[1], &v[2])) != EOF ){
      L = 0;
      for ( i = 1; i < 11; i++ ) {
         L += l[i];
      }
      V = v[1] + v[2];
      t = L / V;
      M = v[1] * t;
      i = 1;
      lon = 0;
      while ( lon <= M ) {
         lon += l[i];
         i++;
      }
      i--;
      if ( lon - l[i] == M) i--;
      printf("%d\n", i);
   }
   return 0;
}

Measured memory_bytes: 1748
import itertools 
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in [0]*n]
cl, al = [], []
for c, *a in ca:
    cl += [c]
    al += [a]
za = [list(i) for i in zip(*al)]
if any(sum(i)<x for i in za):
    print(-1)
else:
    ans = sum(cl)
    for num in range(n-1, 0, -1):
        for i in itertools.combinations(ca, num):
            tmp = [0]*m
            c = 0
            for j in i:
                c += j[0]
                for k in range(m): tmp[k] += j[k+1]
            if all(i>=x for i in tmp):
                ans = min(ans, c)
    print(ans)

Measured memory_bytes: 9248
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>

using namespace std;

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

	stack<char> st;
	for (char c : x) {
		if (!st.empty() && st.top() == 'S' && c == 'T') {
			st.pop();
		} else {
			st.push(c);
		}
	}
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 644
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

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 map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

int a,b;

int main(){
	cin>>a>>b;
	if(b>=a) cout<<a<<endl;
	else cout<<a-1<<endl;
	return 0;
}

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

int N, M;
vector<vector<int> > adj;
vector<int> U, V;
vector<vector<bool> > need;
vector<bool> ok;
vector<bool> vis;

int f(int x, vector<int> &a) {
    int s = 0, e = (int)a.size() - 1;
    int ret = -1;
    while(s <= e) {
        int m = (s + e)>>1;
        if(a[m] < x) {
            ret = m;
            s = m + 1;
        }
        else e = m - 1;
    }
    return ret;
}

bool dfs(int u, int fe) {
    for(int i = 0; i <= f(fe, adj[u]); i++) {
        int e = adj[u][i];
        int v = U[e] + V[e] - u;

        if(vis[v]) return false;
        vis[v] = 1;
        if(!dfs(v, e)) return false;
    }
    return true;
}

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

    adj.resize(N);
    U.resize(M);
    V.resize(M);
    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(i);
        adj[v].push_back(i);
        U[i] = u;
        V[i] = v;
    }

    need.resize(N);
    ok.resize(N);

    for(int i = 0; i < N; i++) {
        vis = vector<bool>(N, false);
        vis[i] = 1;
        ok[i] = dfs(i, 1e9);
        need[i] = vis;
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            if(ok[i] && ok[j]) {
                bool good = true;
                for(int k = 0; k < N; k++) {
                    if(need[i][k] && need[j][k]) {
                        good = false;
                        break;
                    }
                }
                if(good) ans++;
            }
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
    using namespace std;
    int main(){
        long long int q,h,s,d,n,min1,min2;
        cin >> q >> h >> s >> d >> n;
        min1=min(4*q,min(2*h,s));
        min2=min(min1*2,d);
        cout << (n/2)*min2+(n%2)*min1 << endl;
        return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();

        int ans = 0;
        for (int i = 1; i <= N; i += 2) {
            int v = 0;
            for (int j = 1; j <= i; j += 2) {
                if (i % j == 0) v++;
            }

            if (v == 8) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    String n;
    Scanner sc = new Scanner(System.in);
    n = sc.next();
    if(n.contains("7")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int N, K;
 
int main(void){
	
	scanf("%d %d", &N, &K);
    
    ll ans = 0;
	if(K % 2 == 1){
	    for(int i = 1; i <= N; ++i) if(i % K == 0) ++ans;
	    ans = ans * ans * ans;
	}
	else{
	    ll a = 0, b = 0;
	    for(int i = 1; i <= N; ++i){
	        if(i % K == 0) ++a;
	        if(i % K == K / 2) ++b;
	    }
	    ans = pow(a, 3) + pow(b, 3);
	    ans = (a * a * a) + (b * b * b);
	}
	printf("%lld\n", ans);
	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int s[10], c[10];
int ans[10];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> s[i] >> c[i];
		s[i]--;
	}
	for (int j = 0; j < 3; j++) {
		int num = mod;
		for (int i = 0; i < M; i++) {
			if (j == s[i]) {
				if (num == mod) num = c[i];
				else if (num != c[i]) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
		if (num == mod) {
			if (j == 0) ans[j] = 1;
			else ans[j] = 0;
		}
		else {
			ans[j] = num;
		}
	}
	if (N == 1) {
		if (M == 0) {
			cout << 0 << endl;
		}
		else {
			cout << ans[0] << endl;
		}
		return 0;
	}
	if (ans[0] == 0) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

ll N, A, B;
vector<ll> X;
vector<ll> D;
int main(void) {
    cin >> N >> A >> B;
    X = vector<ll>(N);
    for (ll i = 0; i < N; i++) {
        cin >> X[i];
    }

    if (A >= B) {
        cout << B * (N - 1) << endl;
        return 0;
    }

    D = vector<ll>(N);
    D[0] = 0;
    for (ll i = 1; i < N; i++) {
        D[i] = min((X[i] - X[i - 1]) * A, B);
    }

    cout << accumulate(D.begin(), D.end(), 0LL) << endl;
    return 0;
}



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

using namespace std;

bool isP(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main()
{
    string s;   cin >> s;

    int n = s.size();

    int i = (n - 1) / 2;
    int j = (n + 3) / 2 - 1;

    bool Ok = isP(s) && isP(s.substr(0, i)) && isP(s.substr(j, n - j));

    puts(Ok ? "Yes" : "No");
}


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

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

using namespace std;

typedef struct _FRAC
{
	int x, y;	// x: Nom, y: Denom
	
	bool	operator ==(_FRAC &o)	{	return(x * o.y == o.x * y);	}
	bool	operator >(_FRAC &o)	{	return(x * o.y > o.x * y);	}
	_FRAC	&operator +=(_FRAC &o)	// Addition with reducing to a common denominator
	{
		x = x * o.y + o.x * y;
		y = y * o.y;
		return(*this);
	}
	
	_FRAC() {};
	_FRAC(int x_, int y_) : x(x_), y(y_) {};
} FRAC;

FRAC	g_frac;
int		g_maxDen;

int	Solve(FRAC current, int leftTerms, int initAdditionalFracDen = 1)
{
	if(g_frac == current)	{	return(1);	}
	if(leftTerms <= 0 || current > g_frac)		{	return(0);	}
	
	int count = 0;
	for(int i = initAdditionalFracDen; current.y * i <= g_maxDen; i ++)
	{
		FRAC	frac = current;
		FRAC	newTerm(1, i);

		count += ::Solve(frac += newTerm, leftTerms - 1, i);
	}
	return(count);
}

int main()
{
	int nom, den, maxDen, terms;
	
	while(cin >> nom >> den >> maxDen >> terms, nom)
	{
		g_frac = FRAC(nom, den);
		g_maxDen = maxDen;
		cout << ::Solve(FRAC(0, 1), terms) << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int n,m;
	cin >> n >> m;
	if(n==m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,Max,Min;
  cin>>N>>M;
  vector<int> L(M),R(M);
  for(int i;i<M;i++){
    cin>>L.at(i);
    cin>>R.at(i);
  }
  Max=*max_element(L.begin(),L.end());
  Min=*min_element(R.begin(),R.end());
  cout<<max(0,Min-Max+1);
}

Measured memory_bytes: 1024
import scala.io.Source.stdin

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<5000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]):Unit = {
    println(stdin.getLines.drop(1).count{x => isPrime(x.toInt)})
  }
}

Measured memory_bytes: 66960
#include<stdio.h>

int main(void)
{
	
	int a, b, c;
	int x;
	int count;
	
	scanf("%d %d %d", &a, &b, &c);
	
	
	for(x = a , count = 0 ; x <= b ; x++){
		if(c%x == 0)count ++;
	}
	
	printf("%d\n", count);
	
    return 0;
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <deque>
using namespace std;
#define int long long
signed main() {

	int n;
	cin >> n;

	vector <pair <int, int> > v;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < n; ++j) {
			int a;
			cin >> a;
			v.push_back(make_pair(a, i));
		}
	}
	sort(v.begin(), v.end());
	vector < vector <int> > cntl(v.size());
	vector < vector <int> > cntr(v.size());
	int ans = 0;
	for (int i = 0; i < cntl.size(); ++i) {
		cntl[i].resize(3);
		for (int j = 0; j < 3; ++j) {
			cntl[i][j] = (i == 0 ? 0 : cntl[i - 1][j]) + (v[i].second == j);
		}
	}
	for (int i = (int)cntr.size() - 1; i >= 0; --i) {
		cntr[i].resize(3);
		for (int j = 0; j < 3; ++j) {
			cntr[i][j] = (i == (int)cntr.size() - 1 ? 0 : cntr[i + 1][j]) + (v[i].second == j);
		}
	}
	for (int i = 0; i < v.size(); ++i) {
		int cntt = (v[i].second == 1);
		int j = i;
		while (j + 1 < v.size() && v[j].first == v[j + 1].first) {
			++j;
			if (v[j].second == 1) ++cntt;
		}
		ans += cntt * (i == 0 ? 0 : cntl[i - 1][0]) * ((j == (int)cntr.size() - 1) ? 0 : cntr[j + 1][2]);
		i = j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 39656
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {     
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

int main() {
  int A,P;
  cin >> A >> P;
  P += A*3;
  cout << P/2 << endl;
  return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, k int64
	fmt.Scan(&a, &b, &c, &k)

	var sums int64

	aNum := k - a
	bNum := k - a - b
	cNum := k - a - b - c

	if aNum <= 0 {
		sums = k
	} else {
		if bNum <= 0 {
			sums = a
		} else {
			if cNum <= 0 {
				sums = a - (k - a - b)
			} else {
				sums = a - c
			}
		}
	}
	fmt.Println(sums)
}


Measured memory_bytes: 1752
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    LL N,K;
    cin >> N >> K;
    LL H[N];
    REP(i,N) cin >> H[i];
    sort(H,H+N,greater<int>());
    LL ans=0;
    
    for(LL i=K;i<N;++i){
        ans+=H[i];
    }
    cout << ans;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


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


ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

const int SIZE = 1000000;
vector<int> primes;
bool isPrime[SIZE];

void make_primes() {
  if (primes.size() > 0) return;
  memset(isPrime, true, sizeof(isPrime));
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i * i < SIZE; i++) 
    if (isPrime[i])
      for (int j = i * i; j < SIZE; j += i)
        isPrime[j] = false;
  REP(i, SIZE) if (isPrime[i]) primes.push_back(i);
}

vector<int> divisors(int n) {
  vector<int> ds;
  for(int d = 1; d * d <= n; d++) {
    if (n % d == 0) {
      ds.push_back(d);
      if (d * d != n) ds.push_back(n/d);
    }
  }
  sort(ds.begin(), ds.end());
  return ds;
}

vector<int> factorize(int n) {
  vector<int> ps;
  for (int i = 0; primes[i] * primes[i] <= n; i++) {
    while (n % primes[i] == 0) {
      ps.push_back(primes[i]);
      n /= primes[i];
    }
  }
  if (n > 1) ps.push_back(n);
  sort(ps.begin(), ps.end());
  return ps;
}

map<int,int> mobius(int N) {
  map<int,int> res;
  vector<int> ps = factorize(N);
  ps.erase(unique(ALL(ps)), ps.end());
  int M = ps.size();
  REP(i, 1 << M) {
    int mu = 1, d = 1;
    REP(j, M) if (i >> j & 1) {
      mu *= -1;
      d *= ps[j];
    }
    res[d] = mu;
  }
  return res;
}

int N, K;

ll f(int t) {
  return mod_pow(K, (t+1)/2, MOD);
}

int main2() {
  cin >> N >> K;

  map<int,int> m = mobius(N);
  vector<int> ds = divisors(N);

  ll ans = 0;
  for (int t : ds) {
    ll cur = 0;
    for (int s : ds) if (t % s == 0) {
      cur += m[t/s] * f(s) % MOD;
      cur = (cur % MOD + MOD) % MOD;
    }
    ans += cur * (t % 2 == 0 ? t / 2 : t);
    ans = (ans % MOD + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  make_primes();
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(a,b) memset((a),(b),sizeof(a))
const int INF=0x3f3f3f3f;
const int N=305;
int g[N][N];
int d[N][N];
bool vis[N];
int n,m;

void Dijkstra(int s)
{
    mem(d[s],INF);
    mem(vis,false);
    d[s][s]=0;
    
    while(true)
    {
        int v=-1;
        for(int i=0;i<n;i++)
        if(!vis[i]&&(v==-1||d[s][i]<d[s][v]))v=i;
        
        if(v==-1)break;
        vis[v]=true;
        
        for(int i=0;i<n;i++)
        {
            d[s][i]=min(d[s][i],d[s][v]+g[v][i]);
        }
    }
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			cin>>g[i][j];
		}
	
	ll ans=0;
	bool flag=true;
	for(int i=0;i<n;i++)
	{
		Dijkstra(i);
		for(int j=i+1;j<n;j++)
		if(d[i][j]<g[i][j])flag=false;
	}
	
	if(!flag)cout<<-1<<endl;
	else 
	{
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				bool flag=false;
				for(int k=0;k<n;k++)
				{
					if(k==i||k==j)continue;
					if(d[i][k]+d[k][j]==d[i][j])flag=true;
				}
				if(!flag)ans+=d[i][j];
			}
		}
		cout<<ans<<endl;
	} 
	return 0;
}

Measured memory_bytes: 1024
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint64_t X;
  cin >> X;

  uint64_t i = 0;
  uint64_t max = 0;
  while (max < X) {
    i++;
    max += i;
  }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>

using namespace std;
int N;
const int MAX_N = 100000, INF = 1000000000;
int a[MAX_N];
int dp[MAX_N]; //dp????????????

void solve() {
	fill(dp, dp + N, INF);
	for (int i = 0; i < N; i++) {
		*lower_bound(dp, dp + N, a[i]) = a[i];
	}
	cout << lower_bound(dp, dp + N, INF) - dp << endl;
}

int main() {

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

Measured memory_bytes: 3872
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] + l[j] + l[k] > 2 * max(l[i],l[j],l[k]) and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]: 
                ans += 1
print(ans)

Measured memory_bytes: 9024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int>P;
int main(){
  int h,w;
  int n;
  int y_cnt[300005]={0};
  int x_cnt[300005]={0};
  vector<P>vec;
  cin>>h>>w>>n;
  for(int i=0;i<n;i++){
    int y,x;
    cin>>y>>x;y--;x--;
    y_cnt[y]++;
    x_cnt[x]++;
    vec.push_back(P(y,x));
  }
  
  vector<P>y_sorted;
  for(int i=0;i<h;i++){
    y_sorted.push_back(P(y_cnt[i],i));
  }
  sort(y_sorted.rbegin(),y_sorted.rend());
  sort(vec.begin(),vec.end());
  
  int maxim=0;
  for(int i=0;i<w;i++){
    int index=0;
    int check=upper_bound(vec.begin(),vec.end(),P(y_sorted[index].second,i)) -
      lower_bound(vec.begin(),vec.end(),P(y_sorted[index].second,i));
    while(index<h&&check!=0){
      maxim=max(maxim,x_cnt[i]+y_sorted[index].first-check);
      index++;
      check=upper_bound(vec.begin(),vec.end(),P(y_sorted[index].second,i)) -
	lower_bound(vec.begin(),vec.end(),P(y_sorted[index].second,i));
    }
    if(index<h){
      maxim=max(maxim,x_cnt[i]+y_sorted[index].first);
    }
  }
  
  cout<<maxim<<endl;
  return(0);
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (((c > b) || (a > d)) ? 0 : min(b, d) - max(a, c)) << endl;
    return 0;
}

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

int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> enter(n);
  rep(i, n) cin >> enter[i];
  
  for(int i = n-1; i > 0; i--){
    if(enter[i-1] - enter[i] > 1){
      ans = 1;
      break;
    }
    else if(enter[i-1] - enter[i] == 1) enter[i-1] -= 1;
  }
  
  if(ans == 1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 640
n = int(input())
s=list(input())



def f(k):
    if s[k] == 'o' and a[k] == 1:
        a[k+1] = a[k-1]
    elif s[k] == 'o' and a[k] == -1:
        a[k+1] = a[k-1]*(-1)
    elif s[k] == 'x' and a[k] == 1:
        a[k+1] = a[k-1]*(-1)
    else:
        a[k+1] = a[k-1]
judge = -1
for e in [[1,1],[1,-1],[-1,1],[-1,-1]]:
    if judge == -1:
        a = [0]*n
        a[0] = e[0]
        a[1] = e[1]
        for j in range(1,n-1):
            f(j)
        if s[0] == 'o' and a[0] == 1:
            if a[1] ==  a[-1]:
                judge = 1
        elif s[0] == 'o' and a[0] == -1:
            if a[1] == a[-1]*(-1):
                judge = 1
        elif s[0] == 'x' and a[0] == 1:
            if a[+1] == a[-1]*(-1):
                judge = 1
        else:
            if a[1] == a[-1]:
                judge = 1
        if judge == 1:
            if s[n-1] == 'o' and a[n-1] == 1:
                if a[0] != a[n-2]:
                    judge = -1
            elif s[n-1] == 'o' and a[n-1] == -1:
                if a[0] != a[n-2]*(-1):
                    judge = -1
            elif s[n-1] == 'x' and a[n-1] == 1:
                if a[0] != a[n-2]*(-1):
                    judge = -1
            else:
                if a[0] != a[n-2]:
                    judge = -1
if judge == -1:
    print(-1)
else:
    ans = ''
    for i in range(n):
        if a[i] == 1:
            ans += 'S'
        else:
            ans += 'W'
    print(ans)
    

Measured memory_bytes: 5672
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new A().doIt();
    }
    class A{
        void doIt(){
        	int a[] = {10,50,100,500};
        	int num[] = new int [4];
        	boolean first = true;
        	while(true){
        		int n = sc.nextInt();
        		if(n == 0)break;
        		if(!first)System.out.println();
        		int ans[] = new int [4];
        		for(int i = 0;i < 4;i++)num[i] = sc.nextInt();
        		n = num[0]*10 + num[1]*50+num[2]*100+num[3]*500 - n;
//        		System.out.println(n);
        		for(int i = 3;i >= 0;i--){
        			ans[i] = n / a[i];
        			n -= ans[i] * a[i];
        		}
        		for(int i = 0;i < 4;i++){
        			if(num[i] - ans[i] > 0)System.out.println(a[i]+" "+(num[i] - ans[i]));
        		}
        		first = false;
        	}
        }
    }
}

Measured memory_bytes: 39588
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        System.out.println(n + (int)Math.pow(n,2) + (int)Math.pow(n,3));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25264
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>

class TNode
{
	std::list<std::pair<TNode*, int> > FNexts;
	int  FDistance;
public:
	TNode()
	: FDistance(-1)
	{
	}
	
	int GetDistance()const {return FDistance;}
	void SetDistance(int Distance){FDistance = Distance;}
	
	void Push(TNode* New, int Weight)
	{
		FNexts.push_back(std::make_pair(New, Weight));
	}
	
	void Visit()
	{
		for(std::list<std::pair<TNode*, int> >::iterator It = FNexts.begin(); It != FNexts.end(); ++It){
			int NextDistance = It->first->GetDistance();
			if(NextDistance >= 0 && NextDistance < FDistance + It->second) continue;
			It->first->SetDistance(FDistance + It->second);
		}
	}
};

class TGraph
{
	std::vector<TNode*> FNodes;
	std::list<TNode*> FSearchList;
	
	std::list<TNode*>::iterator FindMinimum()
	{
		std::list<TNode*>::iterator Result = FSearchList.begin();
		int Distance = (*Result)->GetDistance();
		for(std::list<TNode*>::iterator It = FSearchList.begin(); It != FSearchList.end(); ++It){
			int TempDistance = (*It)->GetDistance();
			if(Distance < 0 || TempDistance >= 0 && TempDistance < Distance){
				Result = It;
				Distance = TempDistance;
			}
		}
		return Result;
	}
public:
	TGraph(int Count)
	: FNodes(Count)
	{
		for(int i = 0; i < Count; ++i){
			FNodes[i] = new TNode();
			FSearchList.push_back(FNodes[i]);
		}
		FNodes[0]->SetDistance(0);
	}
	
	~TGraph()
	{
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			delete FNodes[i];
		}
	}
	
	void InputNode()
	{
		int Index;
		std::cin >> Index;
		int BranchCount;
		std::cin >> BranchCount;
		for(int i = 0; i < BranchCount; ++i){
			int Target, Weight;
			std::cin >> Target >> Weight;
			FNodes[Index]->Push(FNodes[Target], Weight);
		}
	}
	
	void DijkstraSearch()
	{
		while(!FSearchList.empty()){
			std::list<TNode*>::iterator It = FindMinimum();
			TNode* Minimum = *It;
			FSearchList.erase(It);
			Minimum->Visit();
		}
	}
	
	int Distance(int Target)const
	{
		return FNodes[Target]->GetDistance();
	}
};

int main()
{
	int Count;
	std::cin >> Count;
	TGraph Graph(Count);
	for(int i = 0; i < Count; ++i){
		Graph.InputNode();
	}
	Graph.DijkstraSearch();
	
	for(int i = 0; i < Count; ++i){
		std::cout << i << " " << Graph.Distance(i) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 26560
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ABC = Console.ReadLine().Trim().Split(' ');

            if (ABC[0] == ABC[1] && ABC[0] != ABC[2])
            {
                Console.WriteLine("Yes");
            }
            else if (ABC[0] == ABC[2] && ABC[0] != ABC[1])
            {
                Console.WriteLine("Yes");
            }
            else if (ABC[1] == ABC[2] && ABC[1] != ABC[0])
            {
                Console.WriteLine("Yes");
            }
            else if (ABC[0] == ABC[1] && ABC[0] == ABC[2] && ABC[1] == ABC[2])
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,k;
    cin>>n>>k;
    lli ans;
    if(n<=k){
    	ans=min(n,abs(n-k));
	}
	else{
		n=n-(n/k)*k;
		if(n==0)
		ans=0;
		else{
			ans=min(n,(abs(n-k)));
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const string state[3] = {"Vacant", "Male", "Female"};

const int MAX_N = 99999;
int N;

int judge(string str) {
    if (str == state[0]) {
        return 0;
    } else if (str == state[1]) {
        return 1;
    } else if (str == state[2]) {
        return 2;
    } else {
        return -1;
    }
}

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

  cin >> N;
  string str;

  int lb = 0, ub = N, mid;
  cout << 0 << endl;
  cin >> str;
  int flag = judge(str);
  if (flag == 0) return 0;

  for (int n = 1; n < 20; ++n) {
      mid = (ub+lb)/2;
      cout << mid << endl;
      cin >> str;
      int newFlag = judge(str);
      if (newFlag == 0) break;
      int bet = mid-lb;
      if ((bet%2 == 0 && flag != newFlag) || (bet%2 == 1 && flag == newFlag)) {
          ub = mid;
      } else {
          lb = mid;
          flag = newFlag;
      }
  }

  return 0;
}


Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice dice = new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
		String str = sc.next();

		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i) == 'N') {
				dice.TurnN();
			}
			else if(str.charAt(i) == 'W') {
				dice.TurnW();
			}
			else if(str.charAt(i) == 'E') {
				dice.TurnE();
			}
			else {
				dice.TurnS();
			}
		}
		System.out.println(dice.Top);
	}
}


class Dice {
	int Top;
	int Bottom;
	int N;
	int S;
	int W;
	int E;
	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}

	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}

	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}

	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}

	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}

}


Measured memory_bytes: 26284
# 解説AC
INF = 10 ** 9
N,A,B,C = gets.split.map(&:to_i)
@lists = []
N.times do
  @lists << gets.to_i
end

def dfs(cur, a, b, c)
  # 全ての竹材を吟味したならば
  if cur == N
    # -30は１本目を追加した際にも合成コストである+10されている為
    # a,b,cそれぞれ余分に追加された合成コストの合計分を
    # 減算している。
    return [a, b, c].min > 0 ? (a - A).abs + (b - B).abs + (c - C).abs - 30 : INF
  end
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + @lists[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + @lists[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + @lists[cur]) + 10
  return [ret0, ret1, ret2, ret3].min
end
puts dfs(0,0,0,0)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a+b+c>=22)
   {
       cout<<"bust"<<endl;
   }
   else
   {
       cout<<"win"<<endl;
   }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int mat[4][N], val[N], n, num[2], v[N];
void add(int x, int val) {
	for (; x <= n; x += ((x) & (-(x))))
		v[x] += val;
}
int query(int x) {
	int ret = 0;
	for (; x; x -= ((x) & (-(x))))
		ret += v[x];
	return ret;
}
void fail() {
	puts("No");
	exit(0);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 3; ++i)
		for (int j = 1; j <= n; ++j)
			scanf("%d", &mat[i][j]);
	for (int i = 1; i <= n; ++i) {
		if (mat[1][i] % 3 == 0) {
			if (mat[2][i] == mat[1][i] - 1 && mat[3][i] == mat[1][i] - 2)
				val[i] = -mat[1][i] / 3;
			else fail();
		}
		else if (mat[3][i] % 3 == 0) {
			if (mat[2][i] == mat[3][i] - 1 && mat[1][i] == mat[3][i] - 2)
				val[i] = mat[3][i] / 3;
			else fail();
		}
		else fail();
	}
	for (int i = 1; i <= n; i += 2) {
		if (val[i] < 0) num[1] ^= 1, val[i] = -val[i];
		if (val[i] % 2 == 0) fail();
	}
	for (int i = 2; i <= n; i += 2) {
		if (val[i] < 0) num[0] ^= 1, val[i] = -val[i];
		if (val[i] & 1) fail();
	}
	for (int i = 1; i <= n; i += 2) {
		if ((query(n) - query(val[i])) & 1) num[0] ^= 1;
		add(val[i], 1);
	}
	memset(v, 0, sizeof v);
	for (int i = 2; i <= n; i += 2) {
		if ((query(n) - query(val[i])) & 1) num[1] ^= 1;
		add(val[i], 1);
	}
	if ((!num[0]) && (!num[1]))
		puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int even=(n/2);
	int odd=n-(n/2);
	float pr=(float(odd))/n;
	cout<<pr;
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	string s;
	int ans, cnt = 999;
	cin >> s;
	for(int i = 0; i < s.length()-2; i++){
		ans = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + s[i+2] - '0';
		cnt = min(cnt, abs(ans-753));
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		long[] A = GetLongs(N);
		Array.Sort(A);
		Array.Reverse(A);

		long MAX = 100000;
		long[] cnt = new long[MAX + 1];
		for(long i = 0; i < N; i++)
			cnt[A[i]]++;

		for(long i = 0; i < MAX; i++)
			cnt[i + 1] += cnt[i];

		long ok = 0;
		long ng = (long)1e16;
		while(Abs(ng -ok) > 1)
		{
			long mid = (ok + ng) / 2;
			long sum = 0;
			for(long i = 0; i < N; i++)
			{
				long lb = Max(1, mid - A[i]);
				if(lb > MAX)
					continue;

				sum += cnt[MAX] - cnt[lb - 1];
			}
			if(sum >= M)
				ok = mid;
			else
				ng = mid;
		}

		long[] B = new long[N + 1];
		for(long i = 0; i < N; i++)
			B[i + 1] = B[i] + A[i];

		long ans = 0;
		long rest = M;
		for(long i = 0; i < N; i++)
		{
			long lb = Max(1, ok + 1 - A[i]);
			if(lb > MAX)
				continue;

			long diff = Min(rest, cnt[MAX] - cnt[lb - 1]);
			ans += diff * A[i] + B[diff];
			rest -= diff;
			if(rest == 0)
				break;
		}
		ans += rest * ok;
		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 26976
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut a = vec![0; m];
    let mut c = vec![0; m];
    for i in 0..m {
        let v = read_vec::<i64>();
        a[i] = v[0];
        let cc = read_vec::<usize>();
        for num in cc {
            c[i] += 1 << (num - 1);
        }
    }

    let state_num = 1 << (n);
    debug!(state_num);
    let mut edges_2d = vec![vec![std::i64::MAX; state_num]; state_num];
    for i in 0..state_num {
        for j in 0..m {
            let dst = i | c[j];
            // debug!(i, c[j], dst);
            edges_2d[i][dst] = min(edges_2d[i][dst], a[j]);
        }
    }
    // println!("-1");
    let mut edges: Vec<Vec<Edge>> = vec![Vec::new(); state_num];
    for i in 0..state_num {
        for j in 0..state_num {
            if edges_2d[i][j] != std::i64::MAX {
                edges[i].push(Edge {
                    to: j,
                    cost: edges_2d[i][j],
                })
            }
        }
    }
    let res = solve(&edges, 0, state_num);

    if res[state_num - 1] == INF {
        println!("-1");
        return;
    }
    println!("{}", res[state_num - 1]);
}

const INF: i64 = 100000_00000_00000;

#[derive(PartialEq, Debug)]
struct MinInt {
    value: i64,
}

impl Eq for MinInt {}

impl PartialOrd for MinInt {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        other.value.partial_cmp(&self.value)
    }
}

impl Ord for MinInt {
    fn cmp(&self, other: &MinInt) -> Ordering {
        other.value.cmp(&self.value)
    }
}

fn make_pair(x: i64, y: usize) -> (MinInt, usize) {
    (MinInt { value: x }, y)
}

#[derive(Debug, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}

fn solve(edges: &Vec<Vec<Edge>>, start_idx: usize, num_apexes: usize) -> Vec<i64> {
    let mut d = vec![INF; num_apexes];
    d[start_idx] = 0;
    let mut que = BinaryHeap::new();
    que.push(make_pair(0, start_idx));

    while let Some((u, v)) = que.pop() {
        if d[v] < u.value {
            continue;
        }
        for e in &edges[v] {
            if d[v] != INF && d[e.to] > d[v] + e.cost {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
    d
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 162044