akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
    int l[5], k;
    for (int i = 0; i < 5; i++)
    {
        cin >> l[i];
    }
    cin >> k;
    if (l[4] - l[0] <= k)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
}

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

int main(){
int H, W, i, j; cin >> H >> W; string s[H+2], t;
s[0]=string(W+2, '.');
for(i=1; i<=H; i++){ cin >> t; s[i]="."+t+"."; }
s[H+1]=string(W+2, '.');
  
for(i=1; i<=H; i++){ for(j=1; j<=W; j++){ 
  if(s[i][j]=='#'&&s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'){  
    cout << "No\n";
    return 0;
  }
} }
cout << "Yes\n";
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=3007;
const ll mod=1000*1000*1000+7;

int n, m;

char wcz[nax][nax];

ll dp[nax][nax];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; i++)
	{
		scanf("%s", wcz[i]+1);
		for (int j=1; j<=m; j++)
		{
			if (wcz[i][j]=='#')
				continue;
			dp[i][j]=dp[i-1][j]+dp[i][j-1]+(i==1 && j==1);
			dp[i][j]%=mod;
		}
	}
	printf("%lld\n", dp[n][m]);
	return 0;
}


Measured memory_bytes: 27904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  /**
   * Iterate through each line of input.
   */
	public static void main(String[] args) throws IOException {
		OriginScanner os = new OriginScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		if (os.next().indexOf('7') > -1) pw.println("Yes");
		else pw.println("No");
		pw.close();
	}
	static class OriginScanner {
		private BufferedReader br;
		private StringTokenizer st;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		String next() {
			if (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(nextLine());
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long res = 0;
    for (int i = 0; i < N; i++) {
        int middle = B[i];
        int num_uppers = (int)(lower_bound(A.begin(), A.end(), middle) - A.begin());
        int num_lowers = (int)(N - (upper_bound(C.begin(), C.end(), middle) - C.begin()));

        res += (long long)num_uppers * num_lowers;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
while 1:
    n = int(input())
    if n == 0:break
    m = []
    f = 1
    for _ in range(n):
        _, a, _, v, b = input().split()
        v = int(v[3:])
        x, y = -1, -1
        for i in range(len(m)):
            if a in m[i]:x = i
            if b in m[i]:y = i
        if x >= 0:
            if y >= 0:
                if x == y:
                    if m[x][a] - v != m[x][b]:f = 0
                else:
                    for i in m[y]:
                        m[x][i] = m[y][i] + m[x][a] - m[y][b] - v
                    m.pop(y)
            else:
                m[x][b] = m[x][a] - v
        elif y >= 0:
            m[y][a] = m[y][b] + v
        else:
            m.append({a:v, b:0})
    print("Yes" if f else "No")


Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main()
{
    int H, W;
    char map[1000][1000];
    ll dp[1000][1000];
    bool flag = true;

    int i, j;
    cin >> H >> W;

    rep(i, 0, H - 1)
    {
        rep(j, 0, W - 1)
        {
            cin >> map[i][j];
        }
    }

    rep(i, 0, H - 1)
    {
        if (map[i][0] == '#')
        {
            flag = false;
        }

        if (flag)
        {
            dp[i][0] = 1;
        }
        else
        {
            dp[i][0] = 0;
        }
    }

    flag = true;

    rep(i, 0, W - 1)
    {
        if (map[0][i] == '#')
        {
            flag = false;
        }

        if (flag)
        {
            dp[0][i] = 1;
        }
        else
        {
            dp[0][i] = 0;
        }
    }

    dp[H - 1][j - 1] = 0;

    rep(i, 1, H - 1)
    {
        rep(j, 1, W - 1)
        {
            if (map[i][j] == '.')
            {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
            else
            {
                dp[i][j] = 0;
            }
        }
    }

    cout << dp[H - 1][j - 1] << endl;
}

Measured memory_bytes: 9088
// バケット法による解
#include <iostream>
#include <string>
using namespace std;

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int XY[N][3];
    for (int i = 0; i < N; ++i) cin >> XY[i][0] >> XY[i][1] >> XY[i][2];

    int a[4] = {0};  // バケット
    a[0] = 0; // left
    a[1] = W; // right
    a[2] = 0; // bottom
    a[3] = H; // top
    for (int i = 0; i < N; ++i) {
        if (XY[i][2]==0+1 & a[0]<=XY[i][0]) a[0] = XY[i][0];
        if (XY[i][2]==1+1 & a[1]>=XY[i][0]) a[1] = XY[i][0];
        if (XY[i][2]==2+1 & a[2]<=XY[i][1]) a[2] = XY[i][1];
        if (XY[i][2]==3+1 & a[3]>=XY[i][1]) a[3] = XY[i][1];
    }
    
    for (int i = 0; i < 4; ++i) {
        //cout << a[i] << endl;
    }
    int area = (a[1] - a[0]) * (a[3] - a[2]);
    if (a[1] - a[0] <=0 | a[3] - a[2] <=0) area = 0;
    cout << area << endl;
}



Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;


int main() {
	int n;
	int s[110];
	vector<int> ans(110, 0);
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		
	}
	sort(s, s + n);
	rep(i, n) {
		ans[i + 1] = s[n-1-i] + ans[i];
	}
	
	int sum = ans[n];

	if (sum % 10 == 0) {

	
	rep(i, n) {
		if (s[i] % 10 == 0) {
			continue;
		}
		else {
			sum -= s[i];
			cout << sum << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	}

	else cout << sum << endl;
	/*
	for (int i = n; i > 0; i--) {
		if (ans[i] % 10 == 0) {
			
			continue;
		}
		else if(ans[i] % 10 != 0){
			cout << ans[i]<< endl;
			return 0;
		}
	}
	*/
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
using namespace std;

int main(void){
    // Your code here!
    double A,B;
    cin >> A >> B;

    for(double i = 1; i < 1250; i++){
        if(floor(i * 0.08) == A && floor(i * 0.1) == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}

int main()
{
	ll a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='-') cout<<a-b;
	else cout<<a+b;
	return 0;
}

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

long long n, x, a[200];
int main() {
    cin >> n >> x;
    for (int i = 1; i <= n; ++i)
        scanf("%lld", a + i);
    sort(a + 1, a + n + 1);
    long long res = 0;
    int i;
    for (i = 1; i <= n; ++i) {
        if (x - a[i] < 0) break;
        x -= a[i]; res++;
    }
    if (i == n + 1 && x != 0) res--;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
//
//	Created by shamim_nik
//

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

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define br printf("\n")

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

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

	int a, b;
	cin >> a >> b;
	cout << a * b << '\n';
	return 0;
}

Measured memory_bytes: 3608
# -*- coding utf-8 -*-
N = int(input())

ans = 0
if N < 10:
    ans = N
elif N < 100:
    ans = 9
elif N < 1000:
    ans += 9
    ans += max(0, N - 99)
elif N < 10000:
    ans += 9 + 900
elif N < 100000:
    ans += 9 + 900
    ans += max(0, N - 9999)
else:
    ans += 9 + 900 + 90000

print(ans)


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

int main(){

    int n, x, y;
    cin >> n >> x >> y;
    // the question actually tests the logical ability. there's no need of making the graph actually.

    int distance[n]={0};

    for(int i=1; i<=n-1; i++){
        int count=0;
        for(int j=i+1; j<=n; j++){
            int dist = min(abs(j-i),abs(x-i)+abs(y-j)+1);
            dist=min(dist, abs(y-i)+abs(x-j)+1);
            distance[dist]++;
        }
    }
    for(int i=1; i<n; i++) cout << distance[i] << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 26120
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
//const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=2*1e5+4;

signed main(){
    fast_io;
    ll k,a,b;
    cin>>k>>a>>b;
    bool ok=0;
    for(ll i=a;i<=b;i++){
        if(i%k==0) ok=1;
    }
    if(ok) cout<<"OK";
    else cout<<"NG";
    return 0;
}
/*

    если WA , то чекер говно, поэтому почекай l8 строчку

*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a[3][3];
    bool c[3][3];
    rep(0,i,3)rep(0,j,3)c[i][j]=false;
    rep(0,i,3)rep(0,j,3){
        cin>>a[i][j];
    }
    ll n;
    cin>>n;
    rep(0,i,n){
        ll b;
        cin>>b;
        //cout<<b<<endl;
        rep(0,j,3){
            rep(0,k,3){
                if(a[j][k]==b)c[j][k]=true;
            }
        }
    }
    /*rep(0,i,3){
        rep(0,j,3)cout<<c[i][j];
        cout<<endl;
    }*/
    rep(0,i,3){
        bool T=true;
        rep(0,j,3){
            if(!c[i][j])T=false;
        }
        if(T){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    rep(0,i,3){
        bool T=true;
        rep(0,j,3){
            if(!c[j][i])T=false;
        }
        if(T){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    bool T=true;
    rep(0,i,3){
        if(!c[i][i])T=false;
    }
    if(T){
        cout<<"Yes"<<endl;
        return 0;
    }
    T=true;
    rep(0,i,3){
        if(!c[i][2-i])T=false;
    }
    if(T){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll calc(ll a) {
    ll cnt1 = (a + 1) / 2;
    ll ans = cnt1 % 2;
    if (a % 2 == 0) ans ^= a;
    return ans;
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll ans = calc(B) ^calc(A - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    rep(a,0,5)
    {
        ll b=nxt();
        if(b==0)
            cout<<a+1<<endl;
    }
	printclock;
	return 0;
}

Measured memory_bytes: 3764
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

int main() {
  int t;
  cin >> t;
  vi results;
  for (int dataset = 0 ; dataset < t ; dataset++) {
    string a, b;
    cin >> a;
    cin >> b;
    vvi len(a.length()+1, vi(b.length()+1, 0));
    for (int ia = 0 ; ia < a.length() ; ia++) {
      for (int ib = 0 ; ib < b.length() ; ib++) {
        if (a[ia] == b[ib]) {
          len[ia+1][ib+1] = len[ia][ib]+1;
        } else {
          len[ia+1][ib+1] = max(len[ia+1][ib], len[ia][ib+1]);
        }
      }
    }
    results.pb(len[a.length()][b.length()]);
  }

  for (int it = 0 ; it < t ; it++) {
    printf("%d\n", results[it]);
  }

  return 0;
}

Measured memory_bytes: 6780
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<vector<int>> v;
    string s;
    while(getline(cin, s)){
        stringstream ss;
        ss << s;
        string t;
        v.emplace_back();
        while(getline(ss, t, ',')){
            v.back().emplace_back(stoi(t));
        }
    }
    for (int i = 0; i+1 < v.size(); ++i) {
        if(v[i].size() < v[i+1].size()){
            for (int j = 0; j < v[i+1].size(); ++j) {
                int a = 0;
                if(j) a = max(a, v[i][j-1]);
                if(j+1 != v[i+1].size()) a = max(a, v[i][j]);
                v[i+1][j] += a;
            }
        }else {
            for (int j = 0; j < v[i+1].size(); ++j) {
                v[i+1][j] += max(v[i][j], v[i][j+1]);
            }
        }
    }
    cout << v.back().back() << "\n";
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a+3);
  cout << a[0]+a[1] <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    bool flg=true;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin >> s[i];

    for(int i=0; i<n-1; i++){
        if(s[i].back() != s[i+1].front()) flg=false;
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(s[i] == s[j]) flg=false;
        }
    }
    if(flg) out("Yes");
    else out("No");
    return 0;
}

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

int main() {
  int N,src;
  int deg = 1,sum = 0;
  cin >> N;
  src = N;
  for(int i=1;N/i>10;i*=10)
    deg++;

  while(deg){
    int pow = 1;
    for(int i=deg-1;i;i--)
      pow *= 10;
    sum += N/pow;    
    N-=(N/pow)*pow;
    deg--;
  }

  if(src%sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;
    ll K;
    cin>>N>>K;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
        A[i]--;
    }
    vector<int> cyc;
    vector<bool> used(N,false);
    int now=0;
    while(!used[now]){
        used[now] = true;
        cyc.push_back(now);
        now = A[now];
    }
    int ct;
    if(K<cyc.size()){
        cout<<cyc[K]+1<<endl;
        return 0;
    }
    REP(i,cyc.size()){
        if(cyc[i]==now) ct = i;
    }
    K -= ct;
    cyc.erase(cyc.begin(),cyc.begin()+ct);
    cout<<cyc[K%cyc.size()]+1<<endl;
}


Measured memory_bytes: 5068
import sys
imput=sys.stdin.readline
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(b)]
d=[[]for i in range(a+1)]
for i,k in enumerate(c):
  d[k[0]].append([i,k[1]])
  
e=[[]for i in range(b)]  
for i in range(a+1):
  d[i]=sorted(d[i], key=lambda x: x[1])
  for j,k in enumerate(d[i]):
    e[k[0]]=[i,j+1]
    
for i in range(b):
  print(str(e[i][0]).zfill(6)+str(e[i][1]).zfill(6))


Measured memory_bytes: 60932
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    int n, m;
    while (cin >> n >> m) {
        string s;
        cin >> s;
        vector<int> a(n + 1, -1);
        int x = n;
        int y = n;
        for (int i = n - 1; i >= 0; --i) {
            if (s[i] == '1') {
                continue;
            }

            if (i + m >= x) {
                a[i] = x;
                y = i;
            } else if (i + m >= y) {
                a[i] = y;
                x = y;
                y = i;
            }
        }
        if (a[0] == -1) {
            cout << -1 << endl;
        } else {
            x = 0;
            vector<int> ans;
            while (x < n) {
                ans.push_back(a[x] - x);
                x = a[x];
            }
            for (int i = 0; i < (int)ans.size(); ++i) {
                if (i) {
                    cout << " ";
                }
                cout << ans[i];
            }
            cout << endl;
        }
    }


    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 1480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, count = 1;
  
  cin >> N;
  vector<string> S(N);
  
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  
  sort(S.begin(), S.end());
  
  for(int i = 0; i < N-1; i++){
    if(S[i] != S[i+1]){
      count++;
    }
  }
  
  cout << count << endl;
  
  /*
  for(int i = 0; i < N; i++){
    cout << S[i] << endl; //文字列の配列が出来ているか確認
  }
  */
  
  return 0;
}

Measured memory_bytes: 9568
$debug = false
flag = ARGV.shift
if flag == "-d"
  $debug = true
end

def dputs str
  p str if $debug
end

def max(n, m)
  if n > m
    return n
  else
    return m
  end
end

def min(n, m)
  if n < m
    return n
  else
    return m
  end
end

def gets_all_int
  return gets.chomp.split.map{|v| v.to_i}
end

## start

K, X = gets_all_int
if (500 * K) >= X
  puts "Yes"
else
  puts "No"
end

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

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1, 0);
  dp[0] = 1;
  for (int i = 100; i <= 105; i++) {
    for (int j = i; j <= n; j++) {
      dp[j] |= dp[j - i];
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int isprime(int num){
  int i;
  
  if(num == 2) return 1;

  if(num < 2 || num % 2 == 0) return 0;
		   

    i = 3;
    while(i <= sqrt((double)num) ){
      if(num % i == 0) return 0;
      i = i + 2;
    }
    
    return 1;
}

int main(){
  int i,N,A[10000],c=0;
  
  scanf("%d", &N);
  for(i = 0 ; i < N ; i++){
    scanf("%d", &A[i]);
    c += isprime(A[i]);
  }

  printf("%d\n", c);
  return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
int ans1,ans2;
int a,b,c,d,e,f;
double nong;
int main()
{
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	if (a<=b) ans1=a*100;
	else ans1=b*100;
	for (int a1=0;a1<=30;a1+=a)
	    for (int b1=0;b1<=30;b1+=a)
	    {
	    	int wa=a1*100+b1*100;
	    	for (int i=0;i<=3000;i+=c)
	    	    for (int j=0;j<=3000;j+=d)
	    	    {
	    	    	int su=i+j;
	    	    	if (su+wa>f) continue;
	    	    	if (su>(a1+b1)*e) continue;
	    	    	if (nong*(su+wa)<(100.0)*su) 
	    	    	{
	    	    		nong=(su*100.0)/(su+wa);
	    	    		ans1=su+wa;
	    	    		ans2=su;
	    	    	}
	    	    }
	    }
	printf("%d %d",ans1,ans2);
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <utility>
#include <cassert>
using namespace std;

vector<array<int,8>> G;
vector<int> colors;
vector<int> gens;
int gen;

int getcolor(int u){
	int c = 15;
	for(int v : G[u]){
		if(v >= 0 && colors[v] >= 0){
			c &= ~(1 << colors[v]);
		}
	}
	if(c == 0){ return -1; }
	for(int i = 0; ; ++i){
		if(c >> i & 1){ return i; }
	}
}

template <class A>
void dfs(int u, int c1, int c2, A action){
	++gen;
	vector<int> s;
	s.push_back(u);
	gens[u] = gen;
	while(!s.empty()){
		u = s.back();
		s.pop_back();
		action(u);
		for(int v : G[u]){
			if(v >= 0 && gens[v] != gen && (colors[v] == c1 || colors[v] == c2)){
				gens[v] = gen;
				s.push_back(v);
			}
		}
	}
}

void flip(int from, int other){
	assert(from >= 0 && other >= 0);
	int c1 = colors[from], c2 = colors[other];
	dfs(from, c1, c2, [&](int x){ colors[x] ^= c1 ^ c2; });
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	gens.assign(n, -1);

	vector<pair<int,int>> pts(n);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &pts[i].second, &pts[i].first);
	}

	array<int,8> defarr;
	fill(defarr.begin(), defarr.end(), -1);
	G.assign(n, defarr);
	for(int i = 0; i < m; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		--u;
		--v;
		
		int d;
		if(pts[u].first == pts[v].first){
			d = pts[u].second < pts[v].second ? 0 : 4;
		}
		else if(pts[u].second == pts[v].second){
			d = pts[u].first < pts[v].first ? 2 : 6;
		}
		else if(pts[u].first < pts[v].first){
			d = pts[u].second < pts[v].second ? 1 : 3;
		}
		else{
			d = pts[u].second < pts[v].second ? 7 : 5;
		}

		G[u][d] = v;
		G[v][(d + 4) & 7] = u;
	}

	vector<int> ids(n);
	iota(ids.begin(), ids.end(), 0);
	sort(ids.begin(), ids.end(), [&](int x, int y){ return pts[x] > pts[y]; });
	colors.assign(n, -1);
	for(int u : ids){
		int c = getcolor(u);
		if(c >= 0){
			colors[u] = c;
			continue;
		}
		int from = G[u][0], to = G[u][2];
		assert(from >= 0 && to >= 0);
		bool vis = false;
		dfs(from, colors[from], colors[to], [&](int x){ vis |= x == to; });
		if(!vis){
			flip(from, to);
		}
		else{
			flip(G[u][1], G[u][3]);
		}
		c = getcolor(u);
		assert(c >= 0);
		colors[u] = c;
	}
	for(int c : colors){ printf("%d\n", c + 1); }
}



Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

double calc(int x,double pp){
    return ((double)x/2.0)/pp;
}

int main(){
    int x;
    int p;
    cin >> x >> p;
    double pp = (double)p/100.0;
    if(x%2==0){
        cout << fixed << setprecision(10) << calc(x,pp) << endl;
    }else{
        cout << fixed << setprecision(10) << 1.0+pp*calc(x-1,pp)+(1.0-pp)*calc(x+1,pp) << endl; 
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll h,ans=0ll,n=1ll;
	cin >> h;
	while(h){
		ans += n;
		h /= 2;
		n *= 2;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

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

int main() {
    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int hp;
    int ans = 10000000;
    for(int i = 1; i <= 100; i++) {
        hp = 0;
        for(int j = 0; j < n; j++) {
            hp += pow((x[j]-i),2);
        }
        ans = min(hp,ans);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M,X; cin>>N>>M>>X;
    vector<int> P(N);
    vector<vector<int64_t>> A(N,vector<int64_t>(M));
    rep(n,0,N){
        cin>>P.at(n);
        rep(m,0,M) cin>>A.at(n).at(m);
    }

    int64_t ans=INT64_MAX;
    rep(i,0,1<<N){
        bitset<12> b(i);
        vector<int64_t> sum(M,0);
        int64_t p=0;
        rep(n,0,N){
            if(b.test(n)){
                p+=P.at(n);
                rep(m,0,M) sum.at(m)+=A.at(n).at(m);
            }
        }

        bool f=true;
        rep(m,0,M) if(sum.at(m)<X) f=false;
        if(f) ans=min(ans,p);
    }

    if(ans==INT64_MAX) ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
#define pb push_back

int n;

void gen(string str, int mx) {
	if (str.length() == n) {cout << str << "\n"; return;}
	FOR(i, 0, mx + 1) {
		gen(str + (char) (i+'a'), max(i, mx));
	}
}

int main() {
	cin >> n;
	gen("a", 0);
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    fast_io
    
    int n;
    cin>>n;
    int t[n+1], x[n+1], y[n+1];
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
    
    bool flag=true;

    rep(i,n){
        int dt=t[i+1]-t[i];
        int diff=abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
        if(diff<=dt&&(dt%2==diff%2)){

        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>


int main(void) {
    int n, a, v, vid, vcnt = -1;

    scanf("%d", &n);
    while (n--) {
        scanf("%d%d", &a, &v);
        if (vcnt < v || (vcnt == v && a < vid)) {
            vid = a;
            vcnt = v;
        }
    }
    printf("%d %d\n", vid, vcnt);

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  string s,t; cin>>s>>t;
  int n  =0;
  forn(i,s.size()){
  	n+=(s[i]!=t[i]);
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 3796
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)

bc = [[] for _ in range(m)]
for i in range(m):
    b, c = map(int, input().split())
    bc[i] = [b, c]
bc = sorted(bc, key=lambda x : x[1], reverse=True)

i = 0
for b, c in bc:
    for j in range(1, b+1):
        if i >= n:
            print(s)
            quit()
        next = s - a[i] + c
        if next > s:
            s = next
            i += 1
        else:
            print(s)
            quit()
print(s)

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

int main(){
    long long n, l;
    cin >> n;
    long long k = 1; long long h = 26; int i = 1;
    while(n > h){
        i++;
        h += 1;
        k = h;
        h *= 26;
    }
    n -= k;
    string ans = "";
    while(i > 0){
        l = n % 26;
        n /= 26;
        l += 97;
        ans = (char)l + ans;
        i--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
# include <algorithm>
# include <iostream>
# include <vector>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n];
    ll b[n-1];
    for (int i = 0; i < n-1; i++) {
        cin >> b[i];
        if (i == 0) {
            a[0] = b[i];
        } else {
            a[i] = min(b[i-1], b[i]);
        }
        if (i == n-2) {
            a[n-1] = b[i];
        }
    }
    ll ans = 0;
    for (auto& aa : a) ans += aa;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        System.out.println(Math.min(N*A,B));
    }
}


Measured memory_bytes: 21716
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

struct RoadWork {
    int s, t, x;
} rws[200005];

int d[200005];

struct Block {
    int s, t, x;
} blocks[200005];

struct Comp{
    bool operator()(const Block& a, const Block& b){
        return a.x > b.x;
    }
};

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) {
        int s, t, x;
        scanf("%d%d%d", &s, &t, &x);
        blocks[i].s = s - x;
        blocks[i].t = t - x;
        blocks[i].x = x;
    }
    sort(blocks, blocks + n, [](Block a, Block b){return a.s < b.s;});
    for (int i = 0; i < q; i++) {
        scanf("%d", &d[i]);
    }

    priority_queue<Block, vector<Block>, Comp> pq;
    int cur = 0;
    for (int i = 0; i < q; i++) {
        while (cur < n && d[i] >= blocks[cur].s) {
            pq.push(blocks[cur++]);
        }
        while (!pq.empty()) {
            Block b = pq.top();
            if (b.t <= d[i]) {
                pq.pop();
            } else {
                break;
            }
        }
        if (pq.empty()) {
            printf("-1\n");
        } else {
            printf("%d\n", pq.top().x);
        }
    }
}


Measured memory_bytes: 7792
n, k = map(int, input().split())
a = list(map(int,input().split()))

bin_digit = [0]*50
for ai in a:
    i = 0
    bin_ai = bin(ai)
    for i in range(len(bin_ai)-2):
        if bin_ai[-1-i] == '1':
            bin_digit[i] += 1
        i += 1

bin_k = list(map(int, bin(k)[-1:1:-1]))
length_k = len(bin_k)
x_k = [None]*length_k
for i in range(length_k):
    if 2*bin_digit[i]>=n:
        x_k[i] = 0
    else:
        x_k[i] = 1

for i in range(length_k-1,-1,-1):
    if x_k[i]>bin_k[i]:
        x_k[i] = 1-x_k[i]
    elif x_k[i]<bin_k[i]:
        break

x = sum(x_k[i]*2**i for i in range(len(x_k)))
ans = sum(x^ae for ae in a)
print(ans)


Measured memory_bytes: 15144
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        v: [usize; n]
    }
    let mut v: Vec<usize> = v;
    v.sort();
    let mut res = v[0] as f64;
    for i in 1..n {
        res = (res + v[i] as f64) / 2.;
    }
    println!("{:.12}", res);
}


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

int a, b;
int x[4],y[2];

int ans = 0;

int main() {

  for(int i = 0; i < 4; i++){
    cin >> a;
    x[i] = a;
  }

  for(int i = 0; i < 2; i++){
    cin >> b;
    y[i] = b;
  }

  sort(x, x+4);
  sort(y, y+2);
  reverse(x, x+4);
  reverse(y, y+2);

  for(int i = 0; i < 3; i++){
    ans += x[i];
  }

  ans += y[0];

  cout << ans << endl;
}

Measured memory_bytes: 3136
// answered_by_prim

import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    class Pop{
	int point, number;
	String name;
	Pop(String s, int i){
	    number = i;
	    name = s;
	    point = 0;
	}
	void addPoint(int a){ point += a; }
	String getName(){ return name; }
	int getPoint(){ return point; }
    }

    int n, m;
    String s;
    boolean[][] times; // chara/time
    int[] points;
    Pop[] pop;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==0) break;

	    pop = new Pop[n];
	    times = new boolean[n][30];
	    points = new int[30];

	    for(int i=0; i<n; i++){
		s = sc.next();
		m = sc.nextInt();
		pop[i] = new Pop(s, i);
		for(int k=0; k<m; k++){
		    int t = sc.nextInt();
		    times[i][t] = true;
		    if(points[t]==0) points[t] = n;
		    else points[t]--;
		}
	    }

	    // テ」ツδ敕」ツつ、テ」ツδウテ」ツδ暗・ツ環?ァツョツ?
	    for(int i=0; i<n; i++)
		for(int k=0; k<30; k++)
		    if(times[i][k])
			pop[i].addPoint(points[k]);

	    // テ」ツつステ」ツδシテ」ツδ?
	    Arrays.sort(pop, new Comparator<Pop>(){
		    public int compare(Pop c1, Pop c2){
			int p1 = c1.getPoint();
			int p2 = c2.getPoint();
			if(p1!=p2) return p1-p2;
			String s1 = c1.getName();
			String s2 = c2.getName();
			return s1.compareToIgnoreCase(s2);
		    }
		}
		);
	    
	    //show();
	    System.out.println(pop[0].getPoint()+" "+pop[0].getName());
	}
    }

    void show(){
	for(int i=0; i<n; i++){
	    for(int k=0; k<30; k++)
		System.out.print(times[i][k] ? "o " : "x ");
	    System.out.println();
	}
	for(int i=0; i<30; i++)
	    System.out.print(points[i]+" ");
	System.out.println();
    }
}

Measured memory_bytes: 31740
#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() {
  string t;
  cin >> t;

  for(int i = 0; i < t.size(); i++) {
    if(t[i] == '?') {
      t[i] = 'D';
    }
  }
  cout << t << endl;
  return 0;
}


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

typedef long long LL;
typedef std::pair<LL, LL> pair;
const int N = 150000;

int n, lc[N], rc[N], lv[N], rv[N];
LL mid;

std::vector<pair> ret[N];

void shrink(std::vector<pair> &A) {
	std::vector<pair> q;
	for (auto p : A) if (q.empty() || p.second < q.rbegin()->second) q.emplace_back(p);
	A = q;
}

void dfs(int x) {
	if (!lc[x]) return ret[x].clear(), ret[x].emplace_back(0, 0);
	dfs(lc[x]), dfs(rc[x]), ret[x].clear();
	if (ret[lc[x]].size() > ret[rc[x]].size())
		std::swap(lc[x], rc[x]), std::swap(lv[x], rv[x]);
	auto &L = ret[lc[x]], &R = ret[rc[x]], &M = ret[x];
	int k = -1, s = lv[x], t = rv[x];
	std::vector<std::pair<LL, LL>> A, B;
	for (auto p : L) {
		LL a, b; std::tie(a, b) = p;
		LL limit = mid - b - s - t;
		while (k + 1 < R.size() && R[k + 1].first <= limit) ++k;
		if (k >= 0) A.emplace_back(a + s, R[k].second + t);
	}
	k = 0;
	for (auto p : L) {
		LL a, b; std::tie(a, b) = p;
		LL limit = mid - a - s - t;
		while (k < R.size() && R[k].second > limit) ++k;
		if (k < R.size()) B.emplace_back(R[k].first + t, b + s);
	}
	std::reverse(B.begin(), B.end());
	B.resize(std::unique(B.begin(), B.end(), [] (pair A, pair B) {return A.first == B.first;}) - B.begin());
	std::reverse(B.begin(), B.end());
	std::merge(A.begin(), A.end(), B.begin(), B.end(), std::back_inserter(M));
	M.resize(std::unique(M.begin(), M.end(), [] (pair A, pair B) {return A.first == B.first;}) - M.begin());
	shrink(M);
}

bool check() { return dfs(1), ret[1].size(); }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 2; i <= n; ++i) {
		int f, v; std::cin >> f >> v;
		lc[f] ? (rc[f] = i, rv[f] = v) : (lc[f] = i, lv[f] = v);
	}
	LL l = 0, r = 1e13, ans = -1;
	while (l <= r) {
		mid = l + r >> 1;
		if (check()) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 31068
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	//final static long MOD = 1000000007;
	final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N=nextInt();
		long[] A = nextLongs();
		Arrays.sort(A);

		int ans = N;
		long sum=0;
		for(int i=0;i<N-1;i++) {
			sum+=A[i];
			if(sum*2 <A[i+1]) {
				ans=N-i-1;
			}
		}

		pw.println(ans);


	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 50936
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,o,g,x,t,k;
    cin>>x>>t>>r;
    o=abs(x-t);
    g=abs(x-r);
    k=min(o,g);
    if(k==o)cout<<"A";
    else if(k==g)cout<<"B";
return 0;}


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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;



int main() {
	int N;cin>>N;
	vector<int>as(N);
	for(int i=0;i<N;++i)cin>>as[i];
	vector<int>needs(as);
	sort(needs.begin(),needs.end());
	int cnt=0;
	for (int i = 0; i < N; ++i) {
		if(as[i]==needs[i])cnt++;
	}
	int Q;cin>>Q;
	int ans=-1;
	if (cnt == N) {
		ans=0;
		
	}
	else {
		for(int i=0;i<Q;++i) {
			int a,b;cin>>a>>b;a--;b--;
			if(as[a]==needs[a])cnt--;
			if(as[b]==needs[b])cnt--;

			if(as[a]==needs[b])cnt++;
			if(as[b]==needs[a])cnt++;
			swap(as[a],as[b]);
			if (cnt == N) {
				ans=i+1;
				break;
			}
		}
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 5236