akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
        #define s(a) cin >> a;
        #define s2(a,b) cin >> a>> b;
        #define s3(a,b,c) cin >> a>> b>> c;
        #define s4(a,b,c,d) cin >> a>> b >> c >> d;
        #define sp(b) cout << b << "\n";
        #define sp2(b,c) cout << b << " "<<c <<endl; 
        #define sp3(a,b,c) cout <<a <<" "<< b << " "<<c <<endl; 
        #define p(a) //////printf("%lld\n",a);
        #define p2(a,b) //////printf("%lld %lld",a,b);
        #define pm(a) //////printf("a\n");
        #define test(t) while(t>0)
        #define sl(a) a.length()
        #define f(a,b,c) for(a=b;a<c;a++)
        #define fr(a,b,c) for(a=c-1;a>=0;a--)
        #define v(a,b) vector<a> b;
        #define pb(a,b) a.push_back(b);
        #define ll long long
        #define mem(a,b) memset(a,b,sizeof(a));
        #define fillar(ar,n) f(i,0,n) s(ar[i]);
        #define diff(a,b) abs(a-b);
        using namespace std;
        #define MOD 1000000007
        #define flush fflush(stdout);
struct flist
{
    int val;
    int pos;
    
};
ll mincomp[100001];
ll maxcomp[100001];
ll mx=1e5+1;
ll getans(ll start,ll end,ll minn,ll maxx,ll com,ll *ar){
    //printf("start=%lld,end=%lld\n",start,end );
    //printf("mnn=%lld,maxx=%lld\n",minn,maxx );
    if(start>end){
        return 0;
    }
    if(start==end){
        if(com==0){
            ar[start]=minn;
            //printf("1.ar[%lld]=%lld\n",start,ar[start] );
        }
        else{
            return 0;
        }
    }
    ll range=end-start+1;
    ll maxxx=maxcomp[range];
    ll minnn=mincomp[range];
    if(com<minnn || com > maxxx){
        return 0;
    }
    int i;
    ll remain=com-(range-1);
    f(i,minn,maxx+1){
        ll left=i-minn;
        ll right=maxx-i;
        ll minbound=mincomp[left]+mincomp[right];
        ll maxbound=maxcomp[left]+maxcomp[right];
        //printf("left=%lld,right=%lld\n",left,right );
        if(remain>=minbound&&remain<=maxbound){
            if(remain-mincomp[left] <=maxcomp[right]){
                ar[start]=i;
                //printf("2.ar[%lld]=%lld\n",start,ar[start] );
                getans(start+1,start+left,minn,i-1,mincomp[left],ar);
                getans(start+left+1,end,i+1,maxx,remain-mincomp[left],ar);
                break;
            }
            else if(remain-maxcomp[left]>=mincomp[right]){
                ar[start]=i;
                //printf("3.ar[%lld]=%lld\n",start,ar[start] );

                getans(start+1,start+left,minn,i-1,maxcomp[left],ar);
                getans(start+left+2,end,i+1,maxx,remain-maxcomp[left],ar);
                break;
            }
        }

    }
    return 1;


}
int main(){
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        int i,j,k;
        int n;
        s(n);
        ll x=n*800;
        ll y=(n/15)*200;
        printf("%lld\n",x-y);

}

          

Measured memory_bytes: 892
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
int main() {
   string s;
   cin>>s;
   long long sum=0;
   long long bsum=0;
   rep(i,s.size()){
      if(s.at(i)=='B'){
         bsum++;
      }
      else{
         sum+=bsum;
      }
   }
   cout<<sum<<endl;
}



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

@SuppressWarnings("unchecked")
public class Main {
    private static final long MOD = (int)1e9 + 7;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        int[] cnt = new int[n + 1];
        int[] cnt2 = new int[n + 1];

        int[] start = new int[n + 1];
        Arrays.fill(start, -1);

        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
            ++cnt2[a[i]];
        }
        for (int i = 0; i < n; ++i) {
            b[i] = in.nextInt();
            if (a[i] == b[i]) {
                ++cnt[a[i]];
                if (start[a[i]] == -1) start[a[i]] = i;
            }
            ++cnt2[b[i]];
        }
        for (int i = 0; i <= n; ++i) {
            if (cnt2[i] > n) {
                System.out.println("No");
                return;
            }
        }
        PriorityQueue<Pair> pq = new PriorityQueue<>();
        for (int i = 1; i <= n; ++i) {
            if (cnt[i] != 0) pq.add(new Pair(i, cnt[i]));
        }
        while (pq.size() > 1) {
            Pair p1 = pq.poll();
            Pair p2 = pq.poll();

            int i1 = start[p1.val];
            int i2 = start[p2.val];

            b[i1] = p2.val;
            b[i2] = p1.val;

            p1.cnt--;
            p2.cnt--;

            start[p1.val]++;
            start[p2.val]++;

            if (p1.cnt != 0) pq.add(p1);
            if (p2.cnt != 0) pq.add(p2);
        }
        if (!pq.isEmpty()) {
            Pair p = pq.poll();
            int x = p.val;
            int i = 0;
            while (i < n && p.cnt != 0) {
                if (b[i] != x && x != a[i]) {
                    int temp = b[i];
                    b[i] = x;
                    b[start[x]] = temp;
                    start[x]++;
                    p.cnt--;
                }
                ++i;
            }
        }
        System.out.println("Yes");
        for (int i = 0; i < n; ++i) {
            System.out.print(b[i] + " ");
        }
    }

    static class Pair implements Comparable<Pair> {
        int val, cnt;

        Pair(int val, int cnt) {
            this.val = val;
            this.cnt = cnt;
        }

        public int compareTo(Pair p) {
            return p.cnt - this.cnt;
        }
    }
}

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

#define ll long long
using namespace std;
void solve()
{
	string S;
	cin>>S;
	for(int i=0; i<3; ++i)
		cout<<S[i];
	cout<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//int T;
    //cin>>T;
    //while(T--)
        solve();

	return 0;
}

Measured memory_bytes: 3652
#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 a, b;
	cin >> a >> b;
	if (a <= 8 && a >= 0 && b <= 8 && b >= 0)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()) {
			int c = numOfCase(sc.nextInt(), sc.nextInt(), sc.nextInt());
			System.out.println(c > 3? "YES": "NO");
		}
		sc.close();
	}
	
	static int numOfCase(int c1, int c2, int c3) {
		int sum = (c1 + c2 <= 10)? 10: (20 - (c1 + c2));
		int n = 0;
		if(c1 <= sum) n++;
		if(c2 <= sum) n++;
		if(c3 <= sum) n++;
		return sum - n;
	}
}

Measured memory_bytes: 25864
#include <iostream>
#include <string>
using namespace std;

int isagct(char C){
  if('A'==C || 'G'==C || 'C'==C || 'T'==C){return 1;}
  else{return 0;}
}

int main(){
  string S; cin >> S;
  int c,d; c=0; d=0;
  
  for(int i=0; i<S.size(); i++){
    if(isagct(S[i])==1){
      c++;
      if(i<S.size()-1 && isagct(S[i+1])==0 && c>d){d=c; c=0;}
    }
  }
  if(c!=0 && c>d){d=c;}
  cout << d;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    a[0]=1000000000;

    ll dp[n+1];
    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k&&i-j>=1;j++)
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
int main(){
    char ch;
    while((ch = getchar()) != EOF){
            if(ch >= 97 && ch <= 122)
                printf("%c",ch-32);
            else if(ch >= 65 && ch <= 90)
                printf("%c",ch+32);
            else
                printf("%c",ch);
    }
}


Measured memory_bytes: 2628
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int cnt = 0;
        for(int i = 0;i < n.length();i++){
            if(n.charAt(i) == '2'){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> k;

	l_ans = ceil(k / 2.0f) * (k / 2);

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << a[n / 2] - a[n / 2 - 1];
}

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

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int ans = INT_MAX;

    for (int i = 0;i <= s.length() - t.length();i++) {
        int tmp = 0;
        for (int j = 0;j < t.length();j++) {
            if (s[i + j] != t[j]) tmp++;
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 3588
import java.util.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

class Main {

    static int[] makePrimes( final int lim ) {

	BitSet isPrime = new BitSet( lim + 1 );
	isPrime.set( 0, lim + 1, true );
	isPrime.set( 0, 2, false );
	final int limIndex = ( int )sqrt( lim );
	for ( int index = 2; index <= limIndex; index++ ) {
	    if ( isPrime.get( index ) ) {
		for ( int i = index * index; i <= lim; i += index ) {
		    isPrime.set( i, false );
		}
	    }
	}
	final int count = isPrime.cardinality();
	int[] ans = new int[count];
	int index = 0;
	for ( int i = 0; i <= lim; i++ ) {
	    if ( isPrime.get( i ) ) {
		ans[index++] = i;
	    }
	}
	return ans;
    } 
    
    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final int n = stdin.nextInt();

	int[] primes = makePrimes( n + 1 );
	
	BigInteger b = lcmAll( primes ).add( new BigInteger( "2" ) );
	System.out.println( b );
	for ( int i = 2; i <= n + 1; i++ ){
	    boolean success = false;
	    for ( int j = 0; j <= primes.length && primes[j] <= i; j++ ) {				    
		if ( i % primes[j] == 0 ) {
		    System.out.println( primes[j] );
		    success = true;
		    break;
		}
	    }
	    if ( !success ) {
		System.out.println( i );
	    }
	}	    
    }

    static BigInteger lcmAll( int[] primes ) {

	BigInteger ans = BigInteger.ONE;
	for ( int i : primes ) {
	    final BigInteger val = new BigInteger( Integer.toString( i ) );
	    ans = ans.multiply( val );
	}	
	return ans;	
    }    
}

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

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;
#define mod 1e9 + 7;

int main(){
	int x[5];
	rep(i,5) cin >> x[i];
	rep(i,5){
		if(x[i] == 0){
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
	int n, h, m, s;
	scanf("%d", &n);
	h=n/3600;
	m=(n-3600*h)/60;
	s=n-(3600*h)-(60*m);
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2084
fun main(args: Array<String>){
    var n = readLine()!!.toInt()
    var la = readLine()!!.split(" ").map(String::toInt).toMutableList()
    la = la.sorted().toMutableList()
    while(n > 1){
        la[1] %= la[0]
        if(la[1] > 0) {
            val tmp = la[0]
            la[0] = la[1]
            la[1] = tmp
        }else{
            la.removeAt(1)
            n--
        }
    }
    println(la[0])
}

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

int n, t;
int head[10] = {0};
int rsv[5][20];
vector<vector<int> > crsv(5);

bool mCheck(int head){
	for(int a = 0; a < 5; a++){
		for(int b = 0; b < n; b++){
			if(crsv[a][head+b] == 1 && rsv[a][b] == 1) return false;
		}
	}
	return true;
}

void set_crsv(int head){
	for(int a = 0; a < 5; a++){
		for(int b = 0; b < n; b++){
			if(rsv[a][b] == 1) crsv[a][head+b] = 1;
		}
	}
}

void clear_crsv(int head){
	for(int a = 0; a < 5; a++){
		for(int b = 0; b < n; b++){
			if(rsv[a][b] == 1) crsv[a][head+b] = 0;
		}
	}
}

int main(){
	int i, j;
	string str;
	
	for(i = 0; i < crsv.size(); i++) crsv[i] = vector<int>(201);
	while(1){
		int ans = 99999;

		cin >> n;
		if(n == 0) break;
		for(i = 0; i < 5; i++){
			for(j = 0; j < 201; j++){
				crsv[i][j] = 0;
			}
		}
		for(i = 0; i < 5; i++){
			cin >> str;
			for(j = 0; str[j] != 0; j++){
				if(str[j] == 'X') {
					rsv[i][j] = 1;
					crsv[i][j] = 1;
				}
				else {
					rsv[i][j] = 0;
					crsv[i][j] = 0;
				}
			}
		}
		
		stack<pair<int, int> > stk;
		stack<vector<vector<int> > > stk2;
		
		stk.push(make_pair(0,0));
		stk2.push(crsv);
		while(!stk.empty()){
			pair<int, int> tv = stk.top();
			crsv = stk2.top();
			stk.pop();
			stk2.pop();
			set_crsv(tv.second);
			
			if(tv.second > ans) continue;
			if(tv.first == 9){
				//cout << "A" << tv.first << " " << tv.second << endl;
				ans = min(ans, tv.second);
				/*
				for(i = 0; i < 5; i++){
					for(j = 0; j < 30; j++){
						cout << crsv[i][j];
					}
					cout << endl;
				}
				*/
				continue;
			}
			/*
			cout << "POP: ";
			cout << tv.first << " " << tv.second;
			cout << endl;
			*/
			
			tv.first++;				
			for(i = n-1; i >= 0; i--){
				if(mCheck(tv.second + i)){
					tv.second += i;
					/*
					cout << "PUSH: ";
					cout << tv.first << " " << tv.second;
					cout << endl;
					*/
					stk.push(tv);
					stk2.push(crsv);
					tv.second -= i;
				}
			}
					
			//if(stk.top().second <= tv.second) clear_crsv(tv.second);			
		}
		
		ans += n;
		cout << ans << endl;
		
	}

}

Measured memory_bytes: 1364
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
string s,t;
bool ac(){
	return s[0]==t[2] && s[1]==t[1] && s[2]==t[0];
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>s>>t;
	if(ac()) cout<<"YES";
	else cout<<"NO";
	return cout<<endl,0;
}

Measured memory_bytes: 256
s = raw_input()
n=len(s)
pos=True
if s[0]!="1" or s[-1]!="0":
    pos=False
else:
    if n%2==0:
        for i in range(n/2 - 1):
            if s[i]!=s[n-i-2]:
                pos=False
                break
    else:
        for i in range((n-1)/2):
            if s[i]!=s[n-i-2]:
                pos=False

res_list = []
if pos==False:
    print -1
else:
    rep=1
    if n%2==0:
        for i in range(n/2):
            if s[i]=="1":
                res_list.append([rep,i+2])
                rep=i+2
            else:
                res_list.append([rep,i+2])
        for i in range(n/2-1):
            res_list.append([rep,i+n/2+2])
    else:
        for i in range((n-1)/2):
            if s[i]=="1":
                res_list.append([rep,i+2])
                rep=i+2
            else:
                res_list.append([rep,i+2])
        for i in range((n-1)/2):
            res_list.append([rep,i+(n-1)/2+2])

    for res in res_list:
        print str(res[0]) + " " + str(res[1])

Measured memory_bytes: 19964
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    string S; cin >> S;
    int N = S.size();
    vi A;
    REP(i,N){
        A.push_back(S[i] - '0');
    }

    int M = 0x01 << 3;
    string ans = "";
    REP(i,M) {
        int ptn = i;
        int mask = 0x01;
        int res = A[0];
        for(int j=0; j<3; j++) {
            if (ptn&mask) res += A[j + 1];
            else res -= A[j + 1];
            mask <<= 1;
        }

        if (res==7) {
            mask = 0x01;
            ans += to_string(A[0]);
            for(int j=0; j<3; j++) {
                if (ptn&mask) ans += "+" + to_string(A[j + 1]);
                else ans += "-" + to_string(A[j + 1]);
                mask <<= 1;
            }
            break;
        }
    }
    ans += "=7";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

int main(){
    int N, M;
    int LONG_EXECUTION_TIME = 1900;
    int SHORT_EXECUTION_TIME = 100;

    cin >> N >> M;
    int POSSIBLY_TLES_NUM = M;
    int ALWAYS_SUCCESS_NUM = N - M;

    ll T = (LONG_EXECUTION_TIME * POSSIBLY_TLES_NUM + SHORT_EXECUTION_TIME * ALWAYS_SUCCESS_NUM);

    cout << T * pow(2, M) << endl;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC083B {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = input[0];
            int A = input[1];
            int B = input[2];
            int answer = 0;
            for(int i = 1; i < N + 1; i++) {
                int sum = 0;
                int j = 0;
                while(Math.Pow(10, j) <= i) {
                    if(j == 0) {
                        sum += i % 10;
                    } else {
                        sum += ((i % (int)Math.Pow(10, j + 1)) - (i % (int)Math.Pow(10, j))) / (int)Math.Pow(10 , j);
                    }
                    j++;
                }
                if(A <= sum && sum <= B) {
                    answer += i;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


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



int main(){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int x;
    cin >> x;
    ans += 2 * min(x, k - x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a != b && b != c && a != c)
        cout << 3;
    else
    {
        if (a != b || b != c)
            cout << 2;
        else
            cout << 1;
    }
}


Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

int main()
{
#ifdef __DEBUG
    freopen("A.in", "r", stdin);
    freopen("A.out", "w", stdout);
#endif

    LL a, b, c, d, n;
    read(a); read(b); read(c); read(d); read(n);
    chkmin(c, std::min(a * 4, b * 2));
    LL ans = std::min(n * c, (n / 2) * d + (n % 2) * c);
    printf("%lld\n", ans);

    return 0;
}

// 子贡曰：“贫而无谄，富而无骄，何如？”
// 子曰：“可也。未若贫而乐，富而好礼者也。”
// 子贡曰：“《诗》云：‘如切如磋，如琢如磨’，其斯之谓与？”
// 子曰：“赐也，始可与言《诗》已矣，告诸往而知来者。” -- 论语


Measured memory_bytes: 256
import sys

def main():
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    n, q = map(int, input().split())
    #n, q = map(int, "4 3".split())
    g = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        #a, b = map(int, ["1 2", "2 3", "2 4"][i].split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)


    add = [0] * n
    for i in range(q):
        p, v = map(int, input().split())
        #p, v = map(int, ["2 10", "1 100", "3 1"][i].split())
        #dfs(p-1, v)
        add[p-1] += v

    ans = [0] * n
    def dfs(v,p,value): #p: parent of v
        value += add[v]
        ans[v] = value
        for c in g[v]:
            if c == p: continue
            dfs(c,v,value)
    dfs(0, -1, 0)
    """
    def dfs(start, point):
        stack = [start]
        while stack:
            x = stack.pop()
            ans[x] += point
            stack += g[x]
    """

    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 289564
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

dp = [0] * (1 << n)
dp[0] = 1

bitcount = [0]
for _ in range(n):
    bitcount += [i+1 for i in bitcount]

# 配るDP # TLE
for bit in range((1 << n) - 1):
    i = bitcount[bit]
    for j in range(n):
        if a[i][j] and ((bit >> j) & 1 ^ 1):
            newbit = bit | (1 << j)
            dp[newbit] += dp[bit]
            dp[newbit] %= mod
print(dp[(1 << n) - 1])


Measured memory_bytes: 130048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		vp a;
		vip b;
		a.pb(pii(0,1000000007));
		while(n--){
			char c;
			cin>>c;
			if(c=='R'){
				int r;cin>>r;
				bool h=false;
				rep(i,b.size())if(b[i].second.first<=r&&r<b[i].second.second){
					h=true;
					cout<<b[i].first<<endl;
				}
				if(!h)cout<<-1<<endl;
			}else if(c=='D'){
				int r;cin>>r;
				rep(i,b.size())if(b[i].first==r){
					a.pb(b[i].second);
					b.erase(b.begin()+i);
					i--;
				}
			}else{
				int s,t;
				cin>>s>>t;
				rep(i,a.size()){
					if(t==0)break;
					int r=min(t,a[i].second-a[i].first);
					b.pb(pip(s,pii(a[i].first,a[i].first+r)));
					t-=r;
					a[i].first+=r;
					if(a[i].first==a[i].second){
						a.erase(a.begin()+i);
						i--;
					}
				}
			}
			sort(all(a));
			rep(i,a.size()-1){
				if(a[i].second==a[i+1].first){
					a[i].second=a[i+1].second;
					a.erase(a.begin()+1+i);
					i--;
				}
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1288
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll n,i,j,cc=0,k;
    cin>>n>>k;
    map<ll,pair<ll ,ll>>check;
    for(i=0;i<k;i++){
        string str;
        cin>>j>>str;
        if(str=="WA"){
            if(check[j].first==0)check[j].second+=1;
        }
        else{
            check[j].first=1;
        }
    }
    ll ac=0,pl=0;
    for(i=0;i<check.size();i++){
        if(check[i].first==1)ac++;
        if(check[i].first==1){
            pl+=check[i].second;
        }
    }
    cout<<ac<<spc<<pl<<endl;
return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int LMT = 23;
vector<int> pos;
int n,d[N];
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d",&d[i]);
    }
    sort(d,d+n);
    int sta = 0;
    pos.push_back(0);
    for(int i=0;i<n;i++) {
        if(sta) pos.push_back((24-d[i])%24);
        else pos.push_back(d[i]);
        sta ^=1;
    }
    sort(pos.begin(),pos.end());
    int diff = 500;
    for(int i=0;i<pos.size()-1;i++) {
        diff = min(pos[i+1]-pos[i], diff);
    }
    diff = min(24-pos.back(), diff);
    printf("%d\n", diff);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
        ll n,i,j;
        cin>>n;
        
        ll a[n+1];
        ll mx=1e18;
        mx++;
        ll z=mx;
        int y=0;
        int z1=0;
        for(i=0;i<n;i++)
        {
        	cin>>a[i];
        	if(a[i]>=mx)
        	{
        		z1=1;
			}
        	if(a[i]==0)
        	{
        		y=1;
			}
        	
		}
		if(y==1)
		{
			cout<<0;
			return 0;
		}
		if(z1==1)
		{
			cout<<-1;
			return 0;
		}
		__int128 x=1LL;
		y=0;
		ll x1=1;
		for(i=0;i<n;i++)
		{
			x=x*a[i];
			x1=x1*a[i];
			if(x>=mx)
			{
				y=1;
				break;
			}
			
		}
		if(y)
		{
			cout<<-1;
		}
		else
		{
			cout<<x1;
		}
		
		
	

    }

}


Measured memory_bytes: 4440
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int i;
	int lt=0;
	for(i=0;i<(int)a.size()-1;i++)
		if(a[i]=='A'&&a[i+1]=='C')
		{
			lt=1;
			break;
		}
	if(lt)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int A, B;
void solve()
{
	int res;
	if(13 <= A)
		res = B;
	else if(6 <= A && A <= 12)
		res = B/2;
	else
		res = 0;
	cout << res << endl;
}
int main()
{
	cin >> A >> B;
	solve();
	return 0;
}


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

int main(){
    int numa , numb , numk ;

    cin >> numa >> numb >> numk ;

    int number , count ;
    
    count = 1 ;
    
    number = numa ;

    if(numb <= numa)
        number = numb;

    while (count <= numk){
        if(0 == numa % number)
            if (0 == numb % number)
                count ++ ;

        number -- ;
    }

    number ++ ;
    
    cout << number ;


    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

rev_maze = [[0] * H for i in range(W)]
for i in range(W):
    for j in range(H):
        #rev_maze = 
        rev_maze[i][j] = maze[j][i]

ans_yoko = []
for i in range(H):
    if maze[i].count('.') == W:
        ans_yoko.append(i)
        
ans_tate = []
for i in range(W):
    if rev_maze[i].count('.') == H:
        ans_tate.append(i)

for i in range(H):
    ans = ''
    for j in range(W):
        #ans = ''
        if i in ans_yoko:
            continue
        if j in ans_tate:
            continue
        else:
            ans += maze[i][j]
    if i == any(ans_yoko) - 1:
        print(ans, end='')
    else:
        print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


int main(void){
    int N;
    cin >> N;
    cout << N / 3 << endl;
}



Measured memory_bytes: 256
#


def main():
    n = int(input())
    a = [int(s) for s in input().split(" ")]
    counts = {}
    for i in a:
        if i in counts:
            counts[i] += 1
        else:
            counts[i] = 1
    # これだとTLE
    # results = {}
    # for i in a:
    #     if i in results:
    #         print(results[i])
    #         continue
    #     count = 0
    #     for k, v in counts.items():
    #         if k == i:
    #             v -= 1
    #         if v > 1:
    #             count += (v * (v - 1) // 2)
    #     print(count)
    #     results[i] = count
    total = 0
    comb = {}
    for k in counts:
        if counts[k] > 1:
            y = counts[k]
            x = (y * (y - 1)) // 2
            total += x
            comb[k] = x
        else:
            comb[k] = 0
    for i in a:
        print(total - (counts[i] - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 31880
#include <stdio.h>
#include <string.h>

int main(){
    int N;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", &S);
    int len = strlen(S);
    if(len<2 || len%2==1){
        printf("No\n");
        return 0;
    }
    for(int i=0;i<(len/2);i++){
        if(S[i] != S[(len/2)+i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define long long long
using namespace std;
long n,a,b,x;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>a>>b;
    x=abs(a-b);
    if(x%2==0)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
  long long n,d;
  cin >> n >> d;
  long long ans = 0;
  for(int i = 0; i < n; i++){
    long long x,y;
    cin >> x >> y;
    if (x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
  int s;
  cin >> s;
  list<int> a;
  a.push_back(s);
  int index = 2;
  while(true){
    s = (s%2==0) ? s/2 : 3*s+1;
    auto b = find(a.begin(), a.end(), s);
    if(b != a.end()){
      cout << index << endl;
      return 0;
    }
    a.push_back(s);
    index++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    string s;
    cin >> s;
    int flag = 0;
    long long cnt = 0;
    long long cntR = 0;
    for(int i = 0; i < N; i++){
        if(flag == 0 && s[i] == 'R') cntR++;
        if(s[i] == 'W') flag = 1;
        if(flag == 1 && s[i] == 'R') cnt++;
    }
    long long res = 0;
    for(int i = 0; i < cnt + cntR; i++){
        if(s[i] == 'W') res++;
    }
    cout << min(res, cnt) << endl;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int main(){
  int a,b,c;
  ll n;
  cin >> a >> b >> c >> n;
  
  if (n%2 == 0){
    cout << a - b << endl;
  } else {
    cout << (b+c) - (a+c) << endl;
  }

  
  return 0;
}



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

int main()
{
     char nd[15],date[15];
     int l,i;

     scanf("%s",date);
     l=strlen(date);

     for(i=0;i<l;i++)
     {    if(i<3 || i>3)
          nd[i]=date[i];
          if(i==3)
              nd[i]='8';
     }

     printf("%s",nd);


}


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

int main() { 
    int N;
    cin >> N;
    int x[N], y[N];
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

    int mx_xpy = -2e9, mn_xpy = 2e9, mx_xmy = -2e9, mn_xmy = 2e9;
    for (int i = 0; i < N; i++) {
        mx_xpy = max(mx_xpy, x[i] + y[i]);
        mn_xpy = min(mn_xpy, x[i] + y[i]);
        mx_xmy = max(mx_xmy, x[i] - y[i]);
        mn_xmy = min(mn_xmy, x[i] - y[i]);
    }

    cout << max(mx_xpy - mn_xpy, mx_xmy - mn_xmy) << endl;
    return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

lli par[200001],sz[200001];

lli find(lli a)
{
	if(par[a]<0)
		return a;
	return par[a]=find(par[a]);
}

void Union(lli a,lli b)
{
	par[b]=a;
	sz[a]+=sz[b];
}

int main()
{
	fastio;
	lli n,m,i,j,a,b,one=0,ans=0;
	map<lli,lli> mp;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		par[i]=-1, sz[i]=1;
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		a=find(a);
		b=find(b);
		if(a!=b)
		{
			Union(a,b);
		}
	}
//	for(i=1;i<=n;i++)
//		cout<<par[i]<<" ";
//	cout<<endl;
//	for(i=1;i<=n;i++)
//		cout<<sz[i]<<' ';
//	cout<<endl;
	for(i=1;i<=n;i++)
	{
		if(par[i]==-1 && sz[i]>1)
			mp[sz[i]]++;
		else if(sz[i]==1)
			one++;
	}
	for(auto it : mp)
	{
		ans=max(ans,it.first);
//		cout<<it.first<<" "<<it.second<<endl;	
	}
	if(one==n)
		cout<<1;
	else
		cout<<ans;	
	return 0;
}


Measured memory_bytes: 6684
#include<bits/stdc++.h>
using namespace std;
int a[15][15];
int n, m, x;
int c[15];
int xx[15]; //记录在dfs过程中各算法的掌握情况
int sum; 	//记录在dfs过程中买书的花费 
int ans = 1e9;//满足每个算法掌握情况>=x的最少花费 

void sel(int k)
{
	sum += c[k];
	for(int i = 1; i <= m; i++)
		xx[i] += a[k][i];
}

void unsel(int k)
{
	sum -= c[k];
	for(int i = 1; i <= m; i++)
		xx[i] -= a[k][i];
}

bool ok()
{
	for(int i = 1; i <= m; i++)
		if(xx[i] < x) return 0;
	return 1;
}

void dfs(int k)
{
	if(k > n)
	{
		if(ok()) ans = min(ans, sum);
		return;
	} 
	
	//不选第k本 
	dfs(k+1);
	//选第k本 
	sel(k);
	dfs(k+1);
	unsel(k);	
}

int main()
{
	cin >> n >> m >> x;
	for(int i = 1; i <= n; i++)
	{
		cin >> c[i];
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	}
	dfs(1);
	cout << (ans==1e9?-1:ans);
	return 0;
} 

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, M, p, x;
	int aux1, aux2, aux3;
	cin >> N;
	int T[100000];
	int suma[1001];
	int tiaux[100000];
		for (int i = 0; i < N;i++) {
			cin >> aux1;
			T[i] = aux1;
			tiaux[i] = aux1;
			suma[i] = 0;
		}
		cin >> M;
		for (int j= 0; j < M; j++) {
			cin >> aux2;
			cin >> aux3;
			tiaux[(aux2)-1] = aux3;
			for (int x = 0; x < N; x++) {
				suma[j] += tiaux[x];
			}
			for (int o = 0; o < N; o++)
				tiaux[o] = T[o];
		}
		for (int e = 0; e < M; e++)
			cout << suma[e] << endl;

	system("pause");
	return(0);
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	enum COLOR{
		R=1,
		W=2,
	};
	int N,M;
	cin>>N>>M;
	vector<int> x(M,0);
	vector<int> y(M,0);
	vector<int> B(N,W);
	vector<int> n(N,1);
	B[0]=R;
	n[0]=1;
	int i;
	for (i=0;i<M;i++){
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
	}
	for (i=0;i<M;i++){
		if (n[x[i]]>0){
			if (B[x[i]]==R){
				B[y[i]]=R;
			}else{
				if (n[y[i]]==0){
					B[y[i]]=W;
				}
			}
			n[y[i]]++;
			n[x[i]]--;
			if (n[x[i]]==0){
				B[x[i]]=W;
			}
		}
	}
	int num=0;
	for (i=0;i<N;i++){
		if (B[i]==R){
			num++;
		}
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> s;
    int i = 0;
    if(n==0){
        s.push_back(0);
    }
    while(n){
        if(i%4==0){
            s.push_back(abs(n % 2));
            n -= abs(n) % 2;
        }else if(i%4==2){
            s.push_back(abs(n % 2));
            n += abs(n) % 2;
        }else{
            n /= 2;
        }
        i++;
    }
    reverse(s.begin(), s.end());
    rep(i, s.size()) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[1] -a[0] == a[2]-a[1]:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3828
//	-*- mode: C++ -*-
//	Min, Max and Sum
//		Write a program which reads a sequence of n integers ai(i=1,2,...n), and prints the minimum value, maximum value and sum of the sequence.
//
//	Input
//		In the first line, an integer n is given. In the next line, n integers ai are given in a line.
//
//	Output
//		Print the minimum value, maximum value and sum in a line. Put a single space between the values.
//
//	Constraints
//		0<n≤10000
//		−1000000≤ai≤1000000
//	Sample Input
//		5
//		10 1 5 4 17
//	Sample Output
//		1 17 37

#include <iostream>
#include <vector>
#include <algorithm>

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	n	{0};
	long long int	sum	{0};
	int				ai	{0};
	std::vector<int>	v	{};
	std::cin >> n;

	for(unsigned int i = 0; i < n; i++){
		std::cin >> ai;
		sum	+= ai;
		v.push_back(ai);

		
	}

	auto	p	= std::minmax_element(v.begin(), v.end());

	std::cout << *(p.first) << ' ' << *(p.second) << ' ' << sum << '\n';
}



Measured memory_bytes: 3252
n,m=map(int, input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
ans=0
for i in range(n-m+1):
  for s in range(n-m+1):
    t = [k[s:s+m] for k in a[i:i+m]]
    if t==b:ans=1
print("Yes") if ans==1 else print("No")

Measured memory_bytes: 3064
#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;


class UnionFind {
    
public:
    vector<int> Parent;
  
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
  
    int root(int A){
        if(Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
  
    int size(int A){
        return -Parent[root(A)];
    }
    
  
    bool connect(int A, int B){
        A = root(A);
        B = root(B);
        if(A == B) return false;
        
      
        if(size(A) < size(B)) swap(A,B);
        
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
    
};




int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    
    vector<ll> ans(M);
    ans[M-1] = (ll) N*(N-1)/2;
    
    UnionFind Uni(N);
    
    for (int i = M-1; i >= 1; i--) {
        ans[i-1] = ans[i];
        if(Uni.root(A[i]) != Uni.root(B[i])){
            ans[i-1] -= (ll)Uni.size(A[i])*Uni.size(B[i]);
            Uni.connect(A[i],B[i]);
        }
    }
    rep(i,M) cout << ans[i] << endl;
    
    
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>

#define ALL(a)  (a).begin(),(a).end()

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

int main() {
    int r;
    int ans = 0;


    cin >> r;

    cout << r*r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI solve( int a, int b, int c )
{
	const int N = a + b + c;
	VI parts( N, 2 );

	int m;
	cin >> m;

	VVI nums( m, VI( 3 ) );
	VI rs( m );

	REP( i, 0, m )
	{
		REP( j, 0, 3 )
		{
			cin >> nums[i][j];
			nums[i][j]--;
		}
		cin >> rs[i];

		if ( !rs[i] )
		{
			continue;
		}

		REP( j, 0, 3 )
		{ 
			parts[ nums[i][j] ] = 1;
		}
	}

	REP( i, 0, m )
	{
		if ( rs[i] )
		{
			continue;
		}

		int count = 0;
		REP( j, 0, 3 )
		{
			count += parts[ nums[i][j] ] == 1;
		}

		if ( count != 2 )
		{
			continue;
		}

		REP( j, 0, 3 )
		{
			if ( parts[ nums[i][j] ] == 1 )
			{
				continue;
			}
			parts[ nums[i][j] ] = 0;
		}
	}

	return parts;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	
	while ( true )
	{
		int a, b, c;
		cin >> a >> b >> c;

		if ( !( a | b | c ) )
		{
			break;
		}

		VI res( solve( a, b, c ) );
		FOR( r, res )
		{
			cout << r << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1280
# 振るのは最強のやつだけ
# 投げるのは強い順
 
N,H = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
A,B = zip(*AB)
 
a = max(A) # 振る
B = [b for b in B if b > a] # 投げる価値あり
B.sort(reverse = True)

attack_cnt = 0
 
for b in B:
  if H <= 0:
    break
  attack_cnt += 1
  H -= b
  
if H > 0:
  attack_cnt += (H-1)//a + 1
  
print(attack_cnt)

Measured memory_bytes: 29820
///////////////////////////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

#define rep(i,n) for(ll i=0LL; i<n; ++i)
#define srep(i,s,n) for(ll i=s; i<n; ++i)
#define rrep(i,n) for(ll i=n-1LL; i>=0LL; --i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

typedef long long ll;

///////////////////////////////////////////////////////////////////////////////

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

    static ll cnts[10000007] = {};

    srep (val, 1, n+1) {
        for (ll lval = val; lval <= n; lval += val) {
            cnts[lval]++;
        }
    }

    ll ans = 0;
    srep (i, 1, n+1) ans += i * cnts[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81712
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
s = 0

def comb(n, k):
  if k > n - k:
    k = n - k
  de = 1
  nu = 1
  for i in range(k):
    de *= (n - i)
    de = de % MOD
    nu *= (i + 1)
    nu = nu % MOD
  nu = pow(nu, -1, MOD)
  return (de * nu) % MOD

def calc_from_step(step):
  temp = 0
  for i in range(1 + (step // 2)):
    temp += comb(step-i, i)
  return temp


arr = [1, 1]
steps = []
step = 0
s = 0
for i in range(M):
  l = int(input()) - 1
  steps.append(l-s)
  if s > l:
    print(0)
    exit()
  if step < l - s:
    step = l - s
  s = l + 2
l = N
steps.append(l-s)
if step < l - s:
  step = l - s

for i in range(step - 1):
  arr.append((arr[i] + arr[i+1])%MOD)
ans = 1

for i in steps:
  ans *= arr[i]
  ans = ans % MOD
print(ans)

Measured memory_bytes: 12636