akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/abc153/tasks/abc153_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    ll N,K; cin>>N>>K;
    vector<ll> hn(N);
    for(auto&&h:hn){
        cin>>h;
    }    
    sort(hn.begin(),hn.end(),greater<ll>());
    ll ans=0;
    FOR(i,K,hn.size()){
        ans += hn.at(i);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define pb push_back

const int MAXN = 101;

long long int n, w, w1, we, va, pref[5][MAXN], sol = 0;

vector<long long int> tez[5];

bool cmp(int a, int b){
    return b < a;
}

int main(void){
    cin >> n >> w;
    cin >> we >> va;
    w1 = we;
    tez[0].pb(va);
    for (int i = 1; i < n; i++){
        cin >> we >> va;
        tez[we - w1].pb(va);
    }
    for (int i = 0; i < 4; i++) {
        sort(tez[i].begin(), tez[i].end(), cmp);
        for (int j = 1; j <= tez[i].size(); j++) pref[i][j] = pref[i][j - 1] + tez[i][j - 1];
    }
    for (int i = 0; i <= tez[0].size(); i++){
        for (int j = 0; j <= tez[1].size(); j++){
            for (int k = 0; k <= tez[2].size(); k++){
                long long int tempsol = pref[0][i] + pref[1][j] + pref[2][k], temptez = w - (i * w1 + j * (w1 + 1) + k * (w1 + 2));
                if (temptez < 0) continue;
                long long int ka = temptez / (w1 + 3);
                sol = max(sol, tempsol + pref[3][ka]);
            }
        }
    }
    cout << sol << endl;
}


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

int main() {
	ios::sync_with_stdio(false);
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
    int n,b;
    cin>>n;
    for(int i=1;i<n+1;i++){
        if (i%3==0) cout<<" "<<i;
        else if (i%10==3) cout<<" "<<i;
        else{
            int a=1;
            for(int j=0;j<3;j++){
                a=a*10;
                b=i/a;
                if (b%10==3){
                    cout<<" "<<i;
                    break;
                }
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3088
function product_Range(a,b) {
    var prd = a,i = a;

    while (i++< b) {
        prd*=i;
    }
    return prd;
}
  
  
function combinations(n, r) 
{
    if (n==r) 
    {
        return 1;
    } 
    else 
    {
        r=(r < n-r) ? n-r : r;
        return product_Range(r+1, n)/product_Range(1,n-r);
    }
}
  
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
    var N = Number(tmp[0])
    s = []
    for(var i=1; i<=N; i++)
    {
        s.push(input[i])
    }
    for(var i=0; i<N; i++)
    {
        s[i] = s[i].split("").sort().join("")
    }
    s.sort()

    var source = s[0]
    var matchCnt=0
    var ans=0
    for(var i=1; i<N; i++)
    {
        if(s[i] === source)
        {
            matchCnt++
        }else{
            if(matchCnt>0){
                ans+=combinations(matchCnt+1, 2)
            }
            matchCnt=0
            source = s[i]
        }
    }
    if(matchCnt>0){
        ans+=combinations(matchCnt+1, 2)
    }

    console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 51500
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
	double ans;
	int n, i, j;
	double x[10], y[10];

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	ans = 0;
	double tmp;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			tmp = pow(x[j] - x[i], 2.0) + pow(y[j] - y[i], 2.0);
			ans += sqrt(tmp);
		}
	}

	long nkai = 1;
	for (i = 1; i <= n; i++) {
		nkai *= i;
	}

	long nkake = 2 * nkai / n;

	ans = ans * nkake / nkai;
	cout << fixed;
	cout << setprecision(10)<<ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main(void){
    int MAX=1000000;
    int MIN=-1000000;
    int K,X;
    cin>>K>>X;
    for(int i=max(MIN,X-K+1);i<=min(MAX,X+K-1);i++){
        cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}



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

int main(){
    long long  q,h,s,d;
    cin>>q>>h>>s>>d;
    long long p1,p2;
    p1=min(4*q,min(2*h,s));
    p2=min(2*p1,d);
    long long n;
    cin>>n;
    long long ans;
    if(n%2==0)ans=p2*n/2;
    else ans=p1+(n/2)*p2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll X; cin >> X;
    vector<ll> nums; nums.push_back(1);
    for(ll x = 2; x*x <= X; x++){
        ll T = x*x;
        while(T <= X){
            nums.push_back(T);
            T*=x;
        }
    }
    sort(nums.begin(),nums.end());
    cout << *(upper_bound(nums.begin(),nums.end(),X)-1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;


public class Main{
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        int[] table = new int[N+1];
        table[0] = 0;
        int M = 0;
        for(int i=1;i<=N;i++){
            table[i] = table[i-1] + i;
            if(table[i]>=N){
                M = i;
                break;
            }
        }
        HashSet<Integer> s = new HashSet<>();
        for(int i=1;i<=M;i++){
            s.add(i);
        }
        s.remove(table[M]-N);
        for(int a : s){
            out.println(a);
        }

        // out.println(result);

        out.flush();
    }
        
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 62548
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
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);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    int N=0,K=0;
    string S;
    cin >> N >> K >> S;
    S[K-1] += 32;
    cout << S << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int vs[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  int sum = 0;
  REP(i, n) {
    scanf("%d", &vs[i]);
    sum += i == 0 ? abs(vs[i]) : abs(vs[i]-vs[i-1]);
  }
  sum += abs(vs[n-1]);
  REP(i, n) {
    int x = i > 0 ? vs[i-1] : 0;
    int y = vs[i];
    int z = i+1 < n ? vs[i+1] : 0;
    printf("%d\n", sum - abs(x-y) - abs(y-z) + abs(x-z));
  }

  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
#define abs(x) (x>0?x:-x)
#define decimal(x) cout<<fixed<<setprecision(x)
#define gc getchar//_unlocked
#define pc putchar//_unlocked
const ll mod=998244353;
int solve(); void precomp();

#define multitest 0
#define usecase 0
int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	if(multitest) cin>>t;
	precomp();
	for(int tc=1; tc<=t; tc++){
		if(multitest && usecase)
			cout<<"Case #"<<tc<<": ";
		solve();
	}
}
void precomp(){	
	return;
}
int solve(){
	int x; cin>>x;
	int ans=0;
	while(x>0){
		x-=ans+1;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
for i in range(4):
    t1,n1=map(int,input().split())
    if t1==1:
        print(n1*6000)
    elif t1==2:
        print(n1*4000)
    elif t1==3:
        print(n1*3000)
    elif t1==4:
        print(n1*2000)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,x;
    cin>>a>>b>>x;
    if(a%x==0)
        a=a/x;
    else
        a=(a/x)+1;
    b=b/x;
    x=b-a+1;
    printf("%lld",x);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int power(int x,int y){
    int ans=1;
    for (;y;y>>=1,x=mul(x,x))
        if (y&1) ans=mul(ans,x);
    return ans;
}
int n,x[N],L[N],R[N],q[N],head,tail;
pair<int,int> a[N],b[N];
#define lc x<<1
#define rc x<<1|1
int k[N*4],sum[N*4];
void multiply(int x,int times){
    sum[x]=mul(sum[x],times);
    k[x]=mul(k[x],times);
}
void down(int x){
    if (k[x]!=1){
        multiply(lc,k[x]);
        multiply(rc,k[x]);
        k[x]=1;
    }
}
void add(int x,int l,int r,int p,int d){
    sum[x]=inc(sum[x],d);
    if (l==r) return;
    down(x);
    int mid=(l+r)>>1;
    if (p>mid) add(rc,mid+1,r,p,d);
        else add(lc,l,mid,p,d);
}
void multiply(int x,int l,int r,int L,int R){
    if (l>=L&&r<=R) return multiply(x,2);
    down(x);
    int mid=(l+r)>>1;
    if (L<=mid) multiply(lc,l,mid,L,R);
    if (R>mid) multiply(rc,mid+1,r,L,R);
    sum[x]=inc(sum[lc],sum[rc]);
}
int query(int x,int l,int r,int L,int R){
    if (l>=L&&r<=R) return sum[x];
    down(x);
    int mid=(l+r)>>1,ans=0;
    if (L<=mid) ans=inc(ans,query(lc,l,mid,L,R));
    if (R>mid) ans=inc(ans,query(rc,mid+1,r,L,R));
    return ans;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d%d",&a[i].second,&a[i].first);
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) x[i]=a[i].second;
    tail=0;
    for (int i=1;i<=n;i++){
        if (!tail||x[i]>x[q[tail]]) q[++tail]=i;
        int l=1,r=tail;
        while (l<r){
            int mid=(l+r)>>1;
            if (x[q[mid]]>=x[i]) r=mid;else l=mid+1;
        }
        b[i].first=q[l];
    }
    tail=0;
    for (int i=n;i;i--){
        if (!tail||x[i]<x[q[tail]]) q[++tail]=i;
        int l=1,r=tail;
        while (l<r){
            int mid=(l+r)>>1;
            if (x[q[mid]]<=x[i]) r=mid;else l=mid+1;
        }
        b[i].second=q[l];
    }
    sort(b+1,b+n+1);
    add(1,0,n,0,1);
    for (int i=1;i<=n;i++){
        int L=b[i].first,R=b[i].second;
        multiply(1,0,n,R,n);
        add(1,0,n,R,query(1,0,n,L-1,R-1));
    }
    printf("%d\n",query(1,0,n,n,n));
    return 0;
}


Measured memory_bytes: 12800
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String a=sc.next();
String b=sc.next();
if(a.charAt(0)==b.charAt(2)&&a.charAt(1)==b.charAt(1)&&a.charAt(2)==b.charAt(0)){System.out.println("YES");
}else{
System.out.println("NO");
}
}}

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

int main() {
	int n;
	cin >> n;
	vector<pii> d(n);
	rep(i, n) {
		cin >> d[i].first >> d[i].second;
	}
	int mx = 0, cnt = 0;
	rep(i, n) {
		if (d[i].first == d[i].second) cnt++;
		else cnt = 0;
		mx = max(mx, cnt);
	}
	if (mx >= 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

int a[200000];
int a_sorted[200000];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a_sorted[i] = a[i];
    }
    sort(a_sorted, a_sorted + n);

    for (int i = 0; i < n; i++) {
        if (a_sorted[n - 1] == a[i]) {
            cout << a_sorted[n - 2] << endl;
        } else {
            cout << a_sorted[n - 1] << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int L = sc.nextInt();
		long[][] A = new long[N][M];
		long[][] B = new long[M][L];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = sc.nextLong();
			}
		}
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < L; j++) {
				B[i][j] = sc.nextLong();
			}
		}

		// 行列の掛け算
		long[][] C = new long[N][L];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < L; j++) {
				for(int k = 0; k < M; k++) {
					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}

		for(int i = 0; i < N; i++) {
			System.out.print(C[i][0]);
			for(int j = 1; j < L; j++) {
				System.out.print(" " + C[i][j]);
			}
			System.out.println();
		}

		sc.close();
	}
}



Measured memory_bytes: 52924
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 20 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int n;
int a[maxN][maxN];
int dp[maxN][1 << 21];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	FIO
	cin >> n;
	FOR(i, n) {
		FOR(j, n)
		cin >> a[i][j];
	}
	// set bit represents that the woman has not been paired up
	dp[n][0] = 1;
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < n; ++j) {
			for (int mask = (1 << n) - 1; mask >= 0; --mask) {
				if (a[i][j] == 1 && (mask & (1 << j))) {
					dp[i][mask] += dp[i + 1][mask ^ (1 << j)];
					if (dp[i][mask] >= MOD) dp[i][mask] -= MOD;
				}
			}
		}
	}
	cout << dp[0][(1 << n) - 1];
	return 0;
}

Measured memory_bytes: 175664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    ll A,B;
    cin >> A >> B;
    vector<ll> X(N);
    rep(i,N) cin >> X[i];
    
    ll ans = 0;
    
    for (int i = 1; i < N; i++) {
        ans += min((X[i]-X[i-1])*A, B);
    }
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int i = (a + b) / 2;
	if (abs(a - i) == abs(b - i)) cout << i << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int figures[N];
  rep(i,N) figures[i] = S[i]-'0';

  ll ans=0;
  for(int tmp = 0;tmp<(1<<N-1);tmp++){
    bitset<9> s(tmp);
    //あるパターンでの和
    ll sums = 0;
    ll sump =figures[0];
    reps(i,N-1){
      if(s.test(N-1-i)){
        sums += sump;
        sump=figures[i];
      }else{
        sump = sump*10+figures[i];
      }
    }
    ans += sums+sump;
  }
  cout << ans;
}

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

int main() {
    int t_hp, t_at, a_hp, a_at;
    cin >> t_hp >> t_at >> a_hp >> a_at;
    int count = 0;
    while (0 < t_hp && 0 < a_hp) {
        count++;
        if (count % 2 == 1) {
            a_hp -= t_at;
        } else {
            t_hp -= a_at;
        }
    }
    if (t_hp <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();

        System.out.println(solve(N));

        sc.close();
    }

    static int solve(int N) {
        return (int) IntStream.rangeClosed(1, N)
                .filter(x -> x % 2 != 0 && IntStream.rangeClosed(1, x).filter(d -> x % d == 0).count() == 8).count();
    }
}

Measured memory_bytes: 36204
#include<bits/stdc++.h>
#define LL long long
#define M 105
#define N 31630
using namespace std;
const int P=1e9+7; 
int dp[M][2*N];
int sum[M][2*N];
void Add(int &x,int y){
	x+=y;
	if(x>=P)x-=P;
}
struct node{
	int x,y;
};
vector<node>num;
int main(){
	int m,n;
	cin>>m>>n;
	int x=1;
	num.push_back((node){0,0});
	while(x<=m){
		int t=m/x;
		int y=m/t;  
		num.push_back((node){x,y}); 
		x=y+1; 
	}  
	int k=num.size()-1;
	for(int i=1;i<=k;i++){
		dp[1][i]=num[i].y-num[i].x+1; 
		dp[1][i]+=dp[1][i-1];
	} 
	for(int i=2;i<=n;i++){ 
		for(int j=1;j<=k;j++){
			dp[i][j]=1LL*dp[i-1][k-j+1]*(num[j].y-num[j].x+1)%P; 
			Add(dp[i][j],dp[i][j-1]);
		}
	}
	int ans=dp[n][k];
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif

int main(){
	bool flag=false;
	int n;
	while(cin>>n){
		if(n==0)break;
		if(flag)cout<<endl;
		flag=true;
		int m=0;
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		m+=a*10 + b*50 + c*100 + d*500;

		m=m-n;

		int w,x,y,z;
		z=m/500;
		y=m%500/100;
		x=m%100/50;
		w=m%50/10;

		w=max(0,a-w);
		x=max(0,b-x);
		y=max(0,c-y);
		z=max(0,d-z);
		if(w)cout<<"10 "<<w<<endl;
		if(x)cout<<"50 "<<x<<endl;
		if(y)cout<<"100 "<<y<<endl;
		if(z)cout<<"500 "<<z<<endl;
	}
	return 0;
}

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

#define ll   long long

int main() {

    int N,M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);

    for(int i=0; i<M; i++){
        cin >> L[i] >> R[i];
    }

    int mn = 0;
    int mx = 1000000;
    for(int i=0; i<M; i++){
        if(L[i] > mn){
            mn = L[i];
        }
        if(R[i] < mx){
            mx = R[i];
        }
    }

    int res = mx-mn+1;
    if(res < 1) res = 0;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
N=int(input())
s=[input() for _ in range(N)]

S=[""]*N
T={}
count=0

for i in range(N):
    S[i]=sorted(s[i])
    S[i]="".join(S[i])
    if S[i] not in T:
        T[S[i]]=1
    else:
        count+=T[S[i]]
        T[S[i]]+=1

print(count)




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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000
#define ORD_MONEY 1000000000000000

struct Edge {
    ll from;
    ll to;
    ll cost;
    Edge(ll f, ll t, ll c)
        : from(f)
        , to(t)
        , cost(c)
    {
    }
    bool operator<(const Edge& o) const
    {
        return cost < o.cost;
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P; // first:最短距離，second:頂点番号

typedef pair<ll, int> P_ll;

struct UnionFind {
    // par[i]:データiが属する木の親の番号．i==par[i]のとき，データiは木の根ノード
    vector<int> par;
    // sizes[i]:根ノードiの木に含まれるデータの数．iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n)
        : par(n)
        , sizes(n, 1)
    {
        // 最初はすべてのデータiがグループiに存在するものとして初期化
        rep(i, n) par[i] = i;
    }

    // データxが属する木の根を得る
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx,yが属する木をマージ
    void unite(int x, int y)
    {
        //データの根ノードを得る
        x = find(x);
        y = find(y);

        // すでに同じ木に属しているならマージしない
        if (x == y)
            return;
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y])
            swap(x, y);

        // xがyの親になるように連結
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx,yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x)
    {
        return sizes[find(x)];
    }
};

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N)
    {
        cin >> h.at(i);
    }

    vector<int> dp(N, INF_32);

    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));

    for (int i = 2; i < N; i++) {
        dp.at(i) = min(dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
    }

    cout << dp.at(N - 1) << endl;
}


Measured memory_bytes: 1024
import itertools


N, M, Q = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
for p in itertools.combinations_with_replacement(range(1, M+1), N):
    A = list(p)
    s = 0
    for a, b, c, d in query:
        s += d if A[b-1]-A[a-1] == c else 0
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 9208
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int K = int.Parse(Console.ReadLine());
    int X = int.Parse(Console.ReadLine());
    int Y = int.Parse(Console.ReadLine());
    Console.WriteLine(Math.Min(N, K) * X + Math.Max(0, N - K) * Y);
  }
}

Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] P = new int[42];
	static int[] T = new int[42];

	public static void main(String[] args) {
		while (true) {
			int P = sc.nextInt();
			if (P == 0) break;
			int Q = sc.nextInt();
			sc.nextLine();
			int[] depth = new int[3];
			int[][] indent = new int[P][4];
			for (int i = 0; i < P; ++i) {
				char[] line = sc.nextLine().toCharArray();
				indent[i][0] = depth[0];
				indent[i][1] = depth[1];
				indent[i][2] = depth[2];
				for (int j = 0;; ++j) {
					if (line[j] != '.') {
						indent[i][3] = j;
						break;
					}
				}
				updateDepth(line, depth);
			}
			ArrayList<Amount> list = new ArrayList<Amount>();
			for (int R = 1; R <= 20; ++R) {
				for (int C = 1; C <= 20; ++C) {
					for (int S = 1; S <= 20; ++S) {
						boolean match = true;
						for (int i = 0; i < P; ++i) {
							if (indent[i][0] * R + indent[i][1] * C + indent[i][2] * S != indent[i][3]) {
								match = false;
								break;
							}
						}
						if (match) {
							list.add(new Amount(R, C, S));
						}
					}
				}
			}
			for (int i = 0; i < Q; ++i) {
				char[] line = sc.nextLine().toCharArray();
				int ans = -9999;
				for (Amount a : list) {
					int c = a.a[0] * depth[0] + a.a[1] * depth[1] + a.a[2] * depth[2];
					if (ans > 0 && ans != c) {
						ans = -9999;
						break;
					}
					ans = c;
				}
				if (i != 0) System.out.print(" ");
				System.out.print(ans < 0 ? -1 : ans);
				updateDepth(line, depth);
			}
			System.out.println();
		}
	}

	static void updateDepth(char[] line, int[] depth) {
		for (int i = 0; i < line.length; ++i) {
			switch (line[i]) {
			case '(':
				depth[0]++;
				break;
			case '{':
				depth[1]++;
				break;
			case '[':
				depth[2]++;
				break;
			case ')':
				depth[0]--;
				break;
			case '}':
				depth[1]--;
				break;
			case ']':
				depth[2]--;
				break;
			}
		}
	}

	static class Amount {
		int[] a = new int[3];

		Amount(int R, int C, int S) {
			a[0] = R;
			a[1] = C;
			a[2] = S;
		}
	}

}

Measured memory_bytes: 29100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<P> r(n);
    rep(i,n){
        int x, l;
        cin >> x >> l;
        r[i] = make_pair(x+l, x-l);
    }

    sort(all(r));
    int cur = -1e9;
    int ans = 0;
    rep(i,n){
        if (cur <= r[i].second){
            ans++;
            cur = r[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4004
import java.util.*;
public class Main {
	

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);


		int n = sc.nextInt();
		
		String[] names = new String[n];
		int[] scores = new int[n];
		
		List<String> nameList = new ArrayList<>();
		Set<String> nameSet = new TreeSet<>();
		
		Map<String, Integer> dic = new HashMap<>();
		
		
		for(int i=0;i<n;i++) {
			names[i] = sc.next();
			scores[i] = sc.nextInt();
			
			nameSet.add(names[i]);
			dic.put(names[i] + scores[i],i );
			
		}
		
		for(Iterator<String> userIter = nameSet.iterator(); userIter.hasNext();) {
			String name = userIter.next();
			
			List<Integer> list = new ArrayList<>();
			for(int i=0;i<n;i++) {
				if(names[i].equals(name)) {
					
					list.add(scores[i]);
				}
				
			}
			Collections.sort(list);
			Collections.reverse(list);
			
			for(Integer i: list) {
				System.out.println(dic.get(name+i) + 1);
			}
			
			
		}
		
		
		

		
		
	}
	

}

Measured memory_bytes: 23124
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		ABC057DD solve = new ABC057DD();
		solve.main();
	}
}

class ABC057DD {
	
	int N;
	int A;
	int B;
	long[] values;
	
	ABC057DD() {
		// Input values
		Scanner cin = new Scanner(System.in);
		this.N = cin.nextInt();
		this.A = cin.nextInt();
		this.B = cin.nextInt();
		this.values = new long[N];
		for (int i = 0; i < N; i++) {
			values[i] = cin.nextLong();
		}
	}
	
	void main() {
	
		Arrays.sort(values);
		
		long sum = 0;
		for (int i = N - 1; i >= N - A; i--) {
			sum += values[i];
		}
		double average = sum / (double) A;
		
		long lastNum = values[N - A];
		int allRepetitionCount = 0;
		int repetitionCountToA = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (values[i] == lastNum) {
				allRepetitionCount++;
				if (i >= N - A) {
					repetitionCountToA++;
				}
			}
		}
		
		PascalTriangle pascal = new PascalTriangle(N);
		long count = 0;
		int maxHand = Math.min(B, allRepetitionCount);
		if (lastNum == values[N - 1]) {
			for (int i = A; i <= maxHand; i++) {
				count += pascal.combination(allRepetitionCount, i);
			}
		} else {
			count = pascal.combination(allRepetitionCount, repetitionCountToA);
		}
		
		System.out.println(average);
		System.out.println(count);
	}
	
	class PascalTriangle {
		
		int N;
		long[][] dp;
		
		PascalTriangle(int N) {
			this.N = N;
			this.dp = new long[N + 1][N + 1];
			makeTriangle();
		}
		
		void makeTriangle() {
			dp[0][0] = 1;
			dp[1][0] = 1;
			dp[1][1] = 1;
			
			for (int i = 2; i <= N; i++) {
				for (int j = 0; j <= i; j++) {
					if (j == 0) {
						dp[i][j] = 1;
					} else {
						dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
					}					
				}
			}
		}
		
		long combination(int n, int k) {
			return dp[n][k];
		}
		
	}
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

#define N 3001
bool vis[N][N];
lli dp[N][N], linf = 1LL<<60;
int a[N];
int n;

lli fun(int l , int r){

    if(l>r) return 0;

    if(vis[l][r]) return dp[l][r];

    vis[l][r] = true;
    int baki = n-(r-l+1);

    if(baki%2 == 0) return dp[l][r] = max(a[l] + fun(l+1,r) , a[r] + fun(l,r-1));
    else return dp[l][r] = min(fun(l+1,r) - a[l] , fun(l,r-1) - a[r]);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    scn(n);

    for(int i=1; i<=n; i++){
        scn(a[i]);
    }
    Fill(vis,false);
    cout<<fun(1, n);
    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 79616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int menu[5];

int main(){
    rep(i,5) cin>>menu[i];

    int ans=100100;
    rep(i,5){
        int sum=0;
        rep(j,5){
            if(i==j || menu[j]%10==0){
                sum+=menu[j];
            }else{
                sum+=(menu[j]+10)/10*10;
            }
        }
        ans=min(ans,sum);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
loop do
    n = gets.to_i
    break if n == 0
    a = gets.split.map(&:to_i)
    (0..n).each do |i|
        b = a.dup
        b.delete_at(i)
        if b.each_cons(2).map {|x, y| y - x}.uniq.size == 1
            p a[i]
            break
        end
    end
end


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007ll
#define INF (1 << 28)    // for x <= 10^9
#define INFL (1ll << 60) // for x <=10^19
#define EPS (1e-10)

using namespace std;

using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = n + 1 - k;
  cout << ans;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {

	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t), greater<char>());
	cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
	char da[102][102];
	int d,n,i,j,x,y,c,f=0,dx,dy,dm;
	cin >> d; 
	for (;d>0;d--) {
		cin >> n;
		for (i=0;i<n+1;i++) for (j=0;j<n+1;j++) da[i][j]=' ';
		for (i=0;i<n+2;i++) {da[i][n+1]='#'; da[n+1][i]='#';}
		dx=0; dy=-1; x=0; y=n-1; c=0;
		while(true) {
			da[y][x]='#';
			if (da[y+dy*2][x+dx*2]=='#' || y+dy==-1) {
				c++; dm=dx; dx=-dy; dy=dm;
				if (c==n) break;
			}
			x+=dx; y+=dy;
		}
		if (f==1) cout << endl; else f=1; 
		for (i=0;i<n;i++) {
			for (j=0;j<n;j++) cout << da[i][j];
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
(function(undefined){
	'use strict';
	(function init() {
		this.output = function() {
			console.log.apply( console, arguments );
		};
		this.stdin = process.openStdin();
		stdin.setEncoding('utf8');
	}).call( this );
	(function solver(){
		var input_list = [];
		(function reciever() {
			stdin.on('data', function(chunk){
				var regexp = /\d+/g;
				var result = chunk.match(regexp);
				input_list = input_list.concat(result);
				setTimeout( solve, 0 );
			});
		})();
		function solve() {
			var a = parseInt( input_list.splice(0, 1)[0] );
			var b = parseInt( input_list.splice(0, 1)[0] );
			var sum = a + b;
			output( sum.toString().length );
			if ( input_list.length )
				setTimeout( solve, 0 );
		}
	})();
}).call(global);

Measured memory_bytes: 9996
def eratos(n):
	is_prime = [True for i in range(n+1)]
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, n+1):
		if i * i > n:
			break
		for j in range(i*i, n+1, i):
			is_prime[j] = False
	return is_prime

is_prime = eratos(10000)
primes = []
for i in range(10001):
    if is_prime[i] is True:
        primes.append(i)

n = int(input())
ans = 0
for _ in range(n):
    x = int(input())
    if x <= 10000:
        if is_prime[x] is True:
            ans += 1
    else:
        ok = True
        for i in primes:
            if i * i > x:
                break
            if x % i == 0:
                ok = False
                break
        if ok is True:
            ans += 1
    
print(ans)


Measured memory_bytes: 5704
L,R= map(int,input().split())

if R-L>2019:
    print(0)
else:
#    print(R,L)
    ijmin=2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            ij =(i*j)%2019
            if ij<ijmin :
                ijmin=ij
    print(ijmin)            
            
    

Measured memory_bytes: 2940
S = input()
left0 = 0
# 0101010...
left1 = 0
# 1010101...

for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == '0':
      left1 += 1
    else:
      left0 += 1
  else:
    if S[i] == '0':
      left0 += 1
    else:
      left1 += 1
      
print(min(left1,left0))

Measured memory_bytes: 3188
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=105;

int deg[SIZE];
int n,xa[SIZE],ya[SIZE],xb[SIZE],yb[SIZE];
vector<int> path[SIZE];
bool choose1[SIZE],choose2[SIZE];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d%d",xa+i,ya+i);
	for(int i=0;i<n;i++) scanf("%d%d",xb+i,yb+i);
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(xa[i]<xb[j] && ya[i]<yb[j]){
				path[i].push_back(j);
				ans++;
				deg[j]++;
			}
		}
	}
	for(;;){
		int MIN=INF;
		int p=-1;
		for(int j=0;j<n;j++){
			if(choose1[j]) continue;
			if(MIN>path[j].size()){
				p=j;
				MIN=path[j].size();
			}
		}
		int i=p;
		if(i==-1) break;
		MIN=INF;
		p=-1;
		choose1[i]=true;
		for(int j=0;j<path[i].size();j++){
			int tmp=path[i][j];
			if(choose2[tmp]) continue;
			if(MIN>deg[tmp]){
				p=tmp;
				MIN=deg[tmp];
			}
		}
		for(int j=0;j<path[i].size();j++) deg[path[i][j]]--;
		if(p==-1){
			ans-=path[i].size();
			continue;
		}
		choose2[p]=true;
		ans-=path[i].size()-1;
	}
	for(int i=0;i<n;i++){
		
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > connection(200010);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int l;
            cin >> l;
            connection[l].push_back(i + 100001);
            connection[i + 100001].push_back(l);
        }
    }
    vector<bool> ischecked(200010, false);
    queue<int> qu;
    qu.push(100001);
    ischecked[100001] = true;
    while(!qu.empty()){
        int nownode = qu.front();
        qu.pop();
        for(int i = 0; i < connection[nownode].size(); i++){
            int nextnode = connection[nownode][i];
            if(ischecked[nextnode]) continue;
            ischecked[nextnode] = true;
            qu.push(nextnode);
        }
    }
    bool isallchecked = true;
    for(int i = 100001; i < 100001 + n; i++){
        if(!ischecked[i]){
            isallchecked = false;
            break;
        }
    }
    if(isallchecked) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
#define get fjlzfs
typedef long long ll;
const int maxN = (int)1e5 + 10;
const ll INF = (ll)1e17;
vector < pair < int, ll > > g[maxN];
pair < ll, ll > val[maxN];
bool used[maxN];
ll vv = INF;
ll get[maxN];
void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        if (vv != INF) return;
        int to = g[v][i].first;
        ll w = g[v][i].second;
        if (used[to]) {
            if (val[v].first + val[to].first != 0) {
                ll q = w - val[v].second - val[to].second;
                ll coef = val[v].first + val[to].first;
                if (coef < 0) {
                    q = -q;
                    coef = -coef;
                }
                if ((q % coef) != 0) {
                    cout << 0;
                    exit(0);
                }
                vv = q / coef;
                return ;
            }
            else {
                if (val[v].second + val[to].second != w) {
                    cout << 0;
                    exit(0);
                }
            }
        }
        else {
            val[to].first = -val[v].first;
            val[to].second = w - val[v].second;
            dfs(to);
        }
    }
}
void last_dfs(int v) {
    used[v] = true;
    if (get[v] <= 0){
        cout << 0;
        exit(0);
    }
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i].first;
        if (used[to]) {
            if (get[v] + get[to] != g[v][i].second) {
                cout << 0;
                exit(0);
            }
        }
        else {
            get[to] = g[v][i].second - get[v];
            used[to] = true;
            last_dfs(to);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    srand(time(0));
    //freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }
    val[1] = {1, 0};
    dfs(1);
    if (vv != INF) {
        get[1] = vv;
        memset(used, 0, sizeof used);
        last_dfs(1);
        cout << 1;
        return 0;
    }
    ll l = 1;
    ll r = 1e18;
    for (int i = 1; i <= n; i++) {
        if (val[i].first > 0) {
            l = max(l, -val[i].second + 1);
        }
        else {
            r = min(val[i].second - 1, r);
        }
    }
    cout << max(r - l + 1, 0LL);
    return 0;
}


Measured memory_bytes: 14208
#include<stdio.h>
int main(){
long long x,y,i=1,flag=0;
scanf("%lld%lld",&x,&y);
while(flag==0){
if(x*2<=y){
x=x*2;
i++;
}
else
flag=1;
}
printf("%lld\n",i);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
#define pll pair<ll,ll>
using namespace std;
const int maxn=200010;
const int mod=1000000007;
int n,id[maxn],d[maxn],num;
ll mor[maxn];
vector<pll > f[maxn];
struct edge
{
    int t;
    edge *next;
}*con[maxn];
void ins(int x,int y)
{
    edge *p=new edge;
    p->t=y;
    p->next=con[x];
    con[x]=p;
}
void dp(int v,int fa)
{
    int mx=n+1;
    for(edge *p=con[v];p;p=p->next)
        if(p->t!=fa)
        {
            dp(p->t,v);
            if(d[p->t]>d[mx]) mx=p->t;
        }
    if(mx<=n) id[v]=id[mx],d[v]=d[mx]+1;
    else id[v]=++num;
    f[id[v]].push_back(make_pair(1,1));
    bool flag=0;
    for(edge *p=con[v];p;p=p->next)
        if(p->t!=fa&&p->t!=mx)
        {
            flag=1;
            for(int i=d[v]-d[p->t]-1;i<d[v];i++)
            {
                pll t=f[id[p->t]][i-d[v]+d[p->t]+1];
                mor[i]=(mor[i]*(t.first+t.second)%mod+f[id[v]][i].second*t.second%mod)%mod;
                f[id[v]][i].second=(f[id[v]][i].second*t.first%mod+f[id[v]][i].first*t.second%mod)%mod;
                f[id[v]][i].first=f[id[v]][i].first*t.first%mod;
            }
        }
    if(flag) 
        for(int i=d[v] - 1;i>=0;--i) {
			if (!mor[i]) break;
            f[id[v]][i].first=(f[id[v]][i].first+mor[i])%mod,mor[i]=0;
		}
}
int main()
{
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("std.out", "w", stdout);
#endif
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        ins(i,x);
        ins(x,i);
    }
    d[n+1]=-1;
    dp(0,-1);
    ll tot=1,sum=0;
    for(int i=0;i<=d[0];i++)
    {
        int sz=(f[id[0]][i].first+f[id[0]][i].second)%mod;
        sum=(sum*sz%mod+f[id[0]][i].second*tot%mod)%mod;
        tot=tot*sz%mod;
    }
    printf("%lld",sum);
    return 0;
}


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

int main()
{
	int64_t X, Y;
	cin >> X >> Y;
	int64_t simu = X;
	int cnt = 0;
	while ( simu <= Y ) {
		simu *= 2;
		cnt++;
	}
	cout << cnt << endl;
	return ( 0 );
}


Measured memory_bytes: 256