akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);


ll hex_to_dec(char n){
	if(isdigit(n)){
		return n-'0';
	}else{
		return n-'a'+10;
	}
}

ll hex_to_dec(string n){
	ll ret=0;
	for(ll i=0;i<n.size();i++){
		ret+=hex_to_dec(n[i]);
		if(i<n.size()-1){
			ret*=16;
		}
	}
	return ret;
}

char dec_to_hex_c(ll n){
	if(n<10){
		return '0'+n;
	}else{
		return 'a'+n-10;
	}
}

string dec_to_hex(ll n){
	string ret;
	REP(i,32){
		ll num=n%16;
		ret=dec_to_hex_c(n%16)+ret;
		n/=16;
		if(n==0){
			break;
		}
	}
	return ret;
}

int main(){
	ll s;
	cin>>s;
	REP(_,s){
		vi nums(8);
		ll key=0;
		REP(i,8){
			string n;
			cin>>n;
			nums[i]=hex_to_dec(n);
		}
		string n;
		cin>>n;
		ll cs=hex_to_dec(n);
		ll carry=0;
		REP(i,32){
 			ll sum=0;
			REP(j,8){
				sum+=(nums[j]>>i)&1;
			}
			if(((sum+carry%2)&1)==((cs>>i)&1)){
			}else{
				key+=(1LL<<i);
				sum=8-sum;
			}
			sum+=carry;
			carry=sum/2;
			assert(key>=0);
		}
		cout<<dec_to_hex(key)<<endl;
	}
}

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

int n;
bool flag;
int a[15] = { 0, 111, 222, 333, 444, 555, 666, 777, 888, 999 };

int main() {
	scanf("%d", &n);
	flag = n > a[n / 100];
	printf("%d\n", a[n / 100 + flag]);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

double r[505];
double ans=0,x[505];
double dfs(int stand,int now,double xx){
	double ans_tmp=0;
	//stand番目の円が取りうる最大のx座標がx.
	//now番目の円とstand番目の円を比較する.
	if(now<0||x[now]+r[now]<x[stand]-r[stand])return xx;
	double dist_tmp=sqrt(pow(r[stand]+r[now],2)-pow(r[stand]-r[now],2));
	ans_tmp=max(ans_tmp,dfs(stand,now-1,max(xx,x[now]+dist_tmp)));
	return ans_tmp;
}

int main(){
	int n;
	//r[i]=i番目の円の半径.
	//x[i]=i番目の円のx座標.
	cin>>n;
	rep(i,0,n)cin>>r[i];
	x[0]=r[0];
	//x座標を決めていく.
	rep(i,1,n)x[i]=dfs(i,i-1,max(r[i],x[i-1]));
	rep(i,0,n)ans=max(ans,x[i]+r[i]);
	print(setprecision(15)<<ans);
}


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

using namespace std;

#define PRIME 1000000007

typedef long long ll;

ll powMod(ll base, ll pow) {
  ll result = 1;
  
  while (pow != 0) {
    if (pow & 1 == 1) {
      result = result * base;
      result %= PRIME;
    }
    
    base = base * base;
    base %= PRIME;
    
    pow >>= 1;
  }
  
  return result;
}

ll combinationMod(int n, int m) {
  ll result = 1;
  
  for (int i = 1; i <= m; i++) {
    result *= n - m + i;
    result %= PRIME;
    
    result *= powMod(i, PRIME - 2);
    result %= PRIME;
  }
  
  return result;
}

int main() {
  int N, K;
  
  cin >> N >> K;
  
  for (int i = 1; i <= K; i++) {
    cout << (combinationMod(N - K + 1, i) * combinationMod(K - 1, i - 1)) % PRIME << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t q,h,s,d;
    cin>>q>>h>>s>>d;
    q*=4;
    h*=2;
    int64_t onelmin=min(min(q,h),s);
    int64_t n;
    cin>>n;
    if(n%2==0){
        cout<<min(onelmin*n,n/2*d)<<endl;
    }
    else{
        cout<<min(onelmin*n,onelmin+(n-1)/2*d)<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
//#define ff fi.fi
//#define fs fi.se
//#define sf se.fi
//#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cerr << ">>>>>> " << #x << " -> " << x << endl
#define nani(x) cerr <<  "Line " << __LINE__ << ": " << #x << " is " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 2000;

int n,q,ans[MAX],bit[MAX],le,ri,mid,a,b,ret,sz;
psi x[MAX];
string pr[MAX],sf[MAX];
pii res[MAX];
vector<int> kur[MAX],tam[MAX];

inline int cmp(string &a,string &b){
	sz = min(a.size(),b.size())-1;
	rep(i,0,sz){
		if(a[i]<b[i])return 1;
		if(a[i]>b[i])return -1;
	}
	return a.size()<b.size();
}

inline void f(string &s){
	le = 1, ri = n, a = 0;
	while(le<=ri){
		mid = le+ri>>1;
		ret = cmp(x[mid].fi,s);
		if(ret==1)le = mid+1;
		else if(ret==-1)ri = mid-1;
		else a = mid, ri = mid-1;
	}
	if(!a)return;
	le = 1, ri = n, b = 0;
	while(le<=ri){
		mid = le+ri>>1;
		ret = cmp(x[mid].fi,s);
		if(ret==1)le = mid+1;
		else if(ret==-1)ri = mid-1;
		else b = mid, le = mid+1;
	}
	return;
}

inline void upd(int i){
	for(; i<=n; i+=(i&-i))++bit[i];
	return;
}

inline int que(int i){
	ret = 0;
	for(; i>0; i-=(i&-i))ret+=bit[i];
	return ret;
}

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>q;
    rep(i,1,n)cin>>x[i].fi;
    sort(x+1,x+1+n);
//    cout<<"___________\n";
//    rep(i,1,n)cout<<x[i].fi<<endl;
    rep(i,1,q){
    	cin>>pr[i]>>sf[i];
    	f(pr[i]);
    	res[i] = {a-1,b};
//    	cout<<a<<' '<<b<<endl;
	}
	rep(i,1,n)reverse(all(x[i].fi)), x[i].se = i;
    sort(x+1,x+1+n);
//    cout<<"___________\n";
//    rep(i,1,n)cout<<x[i].fi<<endl;
    rep(i,1,q){
    	if(res[i].fi==-1)continue;
    	reverse(all(sf[i]));
    	f(sf[i]);
    	if(!a)continue;
//    	cout<<a<<' '<<b<<endl;
    	kur[a-1].pb(i);
    	tam[b].pb(i);
	}
	rep(i,1,n){
		upd(x[i].se);
		for(auto j:kur[i])ans[j]-= que(res[j].se) - que(res[j].fi);
		for(auto j:tam[i])ans[j]+= que(res[j].se) - que(res[j].fi);
	}
	rep(i,1,q)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 29576
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int H, W;
vector<vector<char> > field;
int dist[30][30];
const int INF = -1e9;
const vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int bfs(int sx, int sy){
    queue<P> que;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) dist[i][j] = INF;
    }
    que.push(P(sx, sy));
    dist[sx][sy] = 0;
    while(que.size()){
        P p = que.front(); que.pop();
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] != '#' && dist[nx][ny] == INF){
                que.push(P(nx, ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) ans = max(ans, dist[i][j]);
    }
    return ans;
}
signed main(){
    cin >> H >> W;
    field.resize(H, vector<char> (W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> field[i][j];
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(field[i][j] != '#'){
                ans = max(ans, bfs(i, j));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Array
import Data.Array.ST
import Control.Monad.ST

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h,w] <- getIntList
    cs <- concat <$> replicateM 10 getIntList
    as <- replicateM h getIntList
    let ds :: [((Int,Int),Int)]
        ds = zip [(i,j)| i <- [0..9], j <- [0..9]] cs
    let wf :: Array (Int,Int) Int
        wf = runSTArray $ do
               arr <- newArray ((0,0),(9,9)) 1000
               sequence_ [writeArray arr ij d | (ij,d) <- ds ]
               forM_ [0..9] $ \k -> do
                   forM_ [0..9] $ \i -> do
                       forM_ [0..9] $ \j -> do
                           dij <- readArray arr (i,j)
                           dik <- readArray arr (i,k)
                           dkj <- readArray arr (k,j)
                           writeArray arr (i,j) $ min dij (dik + dkj)
               return arr
    print . sum $ map (sum . (map (\i -> if i == (-1) then 0 else wf ! (i,1)))) as

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL INF = 1e8;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

VPII g[MX];
int ans[MX];

void dfs(int u)
{
    for(PII p : g[u])
    {
        if(ans[p.FF] == -1)
        {
            if(p.SS & 1) {ans[p.FF] = ans[u] ^ 1;}
            else ans[p.FF] = ans[u];
            dfs(p.FF);
        }
    }
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, u, v, w;
    cin>>n;
    loop(i,1,n)
    {
        cin>>u>>v>>w;
        g[u].PB({v,w});
        g[v].PB({u,w});
    }

    mset(ans, -1);
    ans[1] = 0;
    dfs(1);
    loop(i,1,n+1) cout<<ans[i]<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 11576
#include <stdio.h>

void main()
{
    int m=9, carr[m];
    while(m--){
        scanf("%d",&carr[m]);
    }
    int n,k;
    scanf("%d", &n);
    int brr[n];
    for(k=0;k<n;k++){
        scanf("%d", &brr[k]);
        //printf("barra= %d ",brr[k] );
    }
    int arr[1000];
    for(m=0;m<9;m++){
        for(k=0;k<n;k++){
            if(brr[k]==carr[m])
            {
                arr[m]=1;
                break;
                //printf("dd\n");
            }
            else
                arr[m]=0;
            //printf("%d %d \n", arr[m], m);
        }
    }

        if(arr[0]*arr[1]*arr[2]==1) printf("Yes");
    else if(arr[3]*arr[4]*arr[5]==1) printf("Yes");
    else if(arr[6]*arr[7]*arr[8]==1) printf("Yes");
    else if(arr[0]*arr[3]*arr[6]==1) printf("Yes");
    else if(arr[1]*arr[4]*arr[7]==1) printf("Yes");
    else if(arr[2]*arr[5]*arr[8]==1) printf("Yes");
    else if(arr[0]*arr[4]*arr[8]==1) printf("Yes");
    else if(arr[2]*arr[4]*arr[6]==1) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll inf=9223372036854775807ll;
int a[100010],b[100010],L[200010],M;
ll s[100010];
struct pr{
	int x,y;
	pr(int x=0,int y=0):x(x),y(y){}
}p[200010];
bool operator<(pr a,pr b){return a.x==b.x?a.y<b.y:a.x<b.x;}
int main(){
	int n,i,x,y;
	ll sa,sb,res;
	scanf("%d",&n);
	sa=sb=0;
	for(i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		p[++M]=pr(a[i],i);
		p[++M]=pr(b[i],i+n);
		sa+=a[i];
		sb+=b[i];
	}
	res=min(sa,sb);
	sort(p+1,p+M+1);
	for(i=1;i<=n;i++)s[i]=s[i-1]+p[i].x;
	for(i=1;i<=M;i++)L[i]=p[i].x==p[i-1].x?L[i-1]:i;
	for(i=1;i<=n;i++){
		x=L[lower_bound(p+1,p+M+1,pr(a[i],i))-p];
		y=L[lower_bound(p+1,p+M+1,pr(b[i],i+n))-p];
		if(x<=n&&y<=n)
			res=min(res,s[n]);
		else if(x<=n)
			res=min(res,(x==n?s[n]-p[n-1].x:s[n-1])+b[i]);
		else if(y<=n)
			res=min(res,(y==n?s[n]-p[n-1].x:s[n-1])+a[i]);
		else
			res=min(res,s[n-2]+a[i]+b[i]);
	}
	printf("%lld",res);
}

Measured memory_bytes: 4096
#include<stdio.h>
main(){
  int a=0;
  int W,H,x,y,r=0;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W){
    if(y-r>=0&&y+r<=H){
      a=1;
    }
  }
  else{
    a=0;
  }
  if(a==1){
    printf("Yes\n");
  }
  else if(a==0){
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var mod0 = 0;
        var modk = 0;
        for(var i = 1; i <= nk[0]; i++)
        {
            if (i % nk[1] == 0) mod0++;
            if (i % nk[1] == nk[1] / 2) modk++;
        }
        if (nk[1] % 2 != 0)
            WriteLine((long)Pow(mod0, 3));
        else WriteLine((long)Pow(mod0, 3)+ (long)Pow(modk, 3));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11092
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
 
while (line = lines.shift()) {
    const [n, max] = line.split(' ').map(Number);
    if (n === 0 && max === 0) {break;}
    let prices = lines.shift().split(' ').map(Number);
    let maxPrice = 0;
 
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < n; j++) {
            if (i === j) continue;
 
            var sum = prices[i] + prices[j]; 
            if (sum > max) continue;
            maxPrice = Math.max(maxPrice, sum);
        }
    }
 
    console.log(maxPrice === 0 ? 'NONE': maxPrice);
}


Measured memory_bytes: 18344
S = input()
T = input()

s = len(S)
t = len(T)

ans = 1e10

for i in range(s - t + 1):
    a = 0
    for j in range(t):
        if S[i+j] != T[j]:
            a += 1
    ans = min(a, ans)

print(ans)

Measured memory_bytes: 9084
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int score_Alice=0;
        int score_Bob = 0;
        int N = sc.nextInt();
        ArrayList<Integer> List = new ArrayList<Integer>();
        for(int a=0;a<N;a++){
            List.add(sc.nextInt());
        }
        Collection<Integer> num_List = new ArrayList<Integer>(List);

        for(int a=0;a<N;a++){
            int score = Collections.max(num_List);
           if(a%2==0){
               score_Alice +=score;
           }
           else{
               score_Bob +=score;
           }
           num_List.remove(score);
        }
        int score = score_Alice - score_Bob;
        System.out.println(score);
    }
}


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

using namespace std;

const int MX = 200000;

vector<int> G[MX];
int neigh[MX][2];
char s[MX + 1];
bool deleted[MX];

void dfs(int v) {
	if (deleted[v]) return;
	deleted[v] = true;
	for (int u : G[v]) {
		neigh[u][s[v] - 'A']--;
		if (neigh[u][s[v] - 'A'] == 0) dfs(u);
	}
}

int main() {
	int n, m;
	ignore = scanf("%d %d %s", &n, &m, s);
	for (int i = 0, u, v; i < m; i++) {
		ignore = scanf("%d %d", &u, &v);
		u--; v--;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
		neigh[u][s[v] - 'A']++;
		neigh[v][s[u] - 'A']++;
	}
	
	for (int i = 0; i < n; i++)
		if (neigh[i][0] == 0 || neigh[i][1] == 0)
			dfs(i);
	
	int v = 0;
	while (v < n && deleted[v]) v++;
	
	printf("%s\n", v == n ? "No" : "Yes");
	
	return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while (!S.empty()) {
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) {
        color[i] = NIL;
    }
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) {
            dfs(u, id++);
        }
    }
}

int main() {
    int s, t, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8968
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	}
}

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))


int main()
{
    ll i,j,k,l,m,n,l1,l2,l3;

    cin >> n >> k;

   ll ar[n+10],cnt;

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

    ll low = 1 , high = 1e10 , mid;

    while(low <= high)
    {
        mid = (low+high)/2;
        cnt = 0;


        for(i=0;i<n;i++)
        {
            cnt += (ar[i]-1)/mid;
        }

       // cout << mid << " " << cnt << endl;

        if(cnt <= k)
        {
            //cout << mid << endl;
            l1 = mid;
            high = mid-1;
        }
        else low = mid+1;

    }

    cout << l1 << endl;

}


Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= 14&&n>=i*7; i++) {
		if ((n - i * 7) % 4 == 0) {
			cout << "Yes" << endl;
			system("PAUSE");
			return 0;
		}
	}
	cout << "No" << endl;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int i,j,n,k,a[100000],b,ans;
  bool f;
  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    f = false;
    for(i=0;i<k;i++){
      cin >> a[i];
      if(a[i] == 0) f = true;
    }
    sort(a,a+k);

    ans = 1;
    b = 1;
    for(i=1;i<k;i++){
      if(a[i-1] == 0) continue;
      else if(a[i] == a[i-1] + 1) b++;
      else if(f){
	b++;
	if(a[i] == a[i-1] + 2){
	  b++;
	  for(j=i+1;j<k;j++){
	    if(a[j] != a[j-1] + 1) break;
	    b++;
	  }
	}
	ans = max(ans,b);
	b = 1;
      }
      else if(!f){
	ans = max(ans,b);
	b = 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int n,s=0;
	vector<int> a;
	scanf("%d",&n);
	a.resize(n);
	for(int i=0; i<n; ++i) {
		scanf("%d",&a[i]);
	}
	for(int i=0; i<n-1; ++i) {
		for(int j=n-1; j>=i+1; --j) {
			if(a[j]<a[j-1]) {
				swap(a[j],a[j-1]);
				++s;
			}
		}

	}
	for(int i=0; i<n-1; ++i) {
		printf("%d ",a[i]);
	}
	printf("%d\n%d\n",a[n-1],s);
	return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;

  int num = 0;
  for(int i = A; i <= B; ++i)
  {
    string s = to_string(i);
    if(s[0]==s[4] && s[1]==s[3]) num++;
  }
  
  cout << num << endl;
}

Measured memory_bytes: 3708
n, m = map(int, input().split())

tree = [0 for _ in range(n+1)]
for _i in range(m):
    a, b = map(int, input().split())
    tree[a] += 1
    tree[b] += 1
if all(i%2==0 for i in tree):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 45872
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>
#include<stack>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = min(b, n*a);
    cout << ans;

}

Measured memory_bytes: 256
x,y=map(int,input().split())
dict={1:300000,2:200000,3:100000}
if x==1 and y==1:
  print(1000000)
else:
  if x<=3 and y<=3:
    print(dict[x]+dict[y])
  elif x<=3:
    print(dict[x])
  elif y<=3:
    print(dict[y])
  else:
    print(0)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll h, a[100010];

int main() {
    cin >> h >> n;
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using ll = long long;
#define max_num 1000000000000000000
#define max_itr 10000000

int  main(){

	ll x,k,d;
	cin >> x >> k >> d;
	if(x<0) x=-x;//xを正にする


	//k回移動しても0を超えない場合
 	if(x/d>k){
		x-=d*k;
		cout << x << endl;
		return 0;
	}else{
		ll step = x/d;
		k-=step;
		x-=step*d;
		if(k%2 == 1) x = abs(x-d);
		cout << x << endl;
		return 0;
	}
}


Measured memory_bytes: 3640
N, M=map(int, input().split())
ks=[]
for _ in range(M):
    k,*s=input().split()
    ks.append((k, list(map(int, s))))
P=list(map(int, input().split()))

def judge():
    ans=0
    for switches in range(0, 2**N):
        b=bin(switches)[2:].zfill(N)

        for i in range(M):
            s=ks[i][1]
            p=P[i]
            on=0
            for j in s:
                if b[j-1]=="1":
                    on+=1
            if on%2!=p:
                break
        else:
            ans+=1
    return ans
        
print(judge())

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

long long n , a[100001] , dp[100001];
bool b[100001];

long long choose (int i , int j) {
    return abs(a[i] - a[j]);
}

long cal(int i) {
    if (i == n) return 0;
    if (b[i] == true) return dp[i];
    b[i] = true;
    if (i < n - 1) dp[i] = min(cal(i + 1) + choose(i , i + 1) , cal(i + 2) + choose(i , i + 2));
    else if (i == n - 1) dp[i] = choose(i , i + 1);
    return dp[i];
}
int main() {
    cin >> n;
    for (int i = 1 ; i <= n; i++) cin >> a[i];
    cout << cal(1);
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tot=0, a,b;
	cin >> a >> b;
	if (a == 3){
		tot += 100000;
	}
	if (a == 2){
		tot += 200000;
	}
	if (a == 1){
		tot += 300000;
	}
	if (b == 3) tot += 100000;
	if (b == 2) tot += 200000;
	if (b == 1) tot += 300000;
	if (a == 1 and b == 1) tot += 400000;
	cout << tot;
	return 0;
}


Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll a,b;cin>>a>>b;
    cout << a*b << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3656
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  ll N; cin >> N;  
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;

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

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int N;
int K;
vector<pair<int,int>> v;

bool operator<(pair<int,int> a,pair<int,int> b){
    return a.first < b.first;
}

bool compare_y(pair<int,int> a,pair<int,int> b){
    return a.second < b.second;
}

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

    for(int i=0;i<N;i++){
        int x,y;
        cin >> x;
        cin >> y;
        pair<int,int> p(x,y);
        v.push_back(p);
    }
    sort(v.begin(),v.end());

    long min=-1;
    for(int i=0;i<N;i++){
        for(int j=N-1;j-i+1>=K;j--){
            long xmin=v[i].first;
            long xmax=v[j].first;
            int rect_size=j-i+1;
            vector<pair<int,int>> rect;
            for(int k=i;k<=j;k++){
                rect.push_back(v[k]);
            }

            sort(rect.begin(),rect.end(),compare_y);
            for(int k=0;k<rect_size;k++){
                for(int l=rect_size-1;l-k+1>=K;l--){
                    long ymax=rect[l].second;
                    long ymin=rect[k].second;
                    long area=(xmax-xmin)*(ymax-ymin);
//std::cerr<<"debug:xmin="<<xmin<<endl;
//std::cerr<<"debug:xmax="<<xmax<<endl;
//std::cerr<<"debug:ymin="<<ymin<<endl;
//std::cerr<<"debug:ymax="<<ymax<<endl;
//std::cerr<<"debug:area="<<area<<endl;
                    if(min==-1 || min>area){
                        min=area;
                    }
                }
            }
        }
    }

    cout << min << endl;
    return 0;
}



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

int main(){
    int n;
    bool isOk;
    vector<int> list(n), sortedList(n);
    cin >> n;
    rep(0,n)    cin >> list[i];
    rep(0,n){
        if(list[i] % 2 == 0){
            sortedList[i] = list[i];
        }
    }
    rep(0,n){
        if(sortedList[i]%3 == 0 || sortedList[i]%5 == 0)    isOk = true;
        else    isOk = false;
        if(!isOk){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  short int A, B, C, D;
  string s; cin >> s;
  A = s[0] - '0', B = s[1] - '0', C = s[2] - '0', D = s[3] - '0';
  char op1, op2, op3;
  for(int i=0; i<2; ++i){
    op1 = (i&1) ? '-' : '+';
    for(int j=0; j<2; ++j){
      op2 = (j&1) ? '-' : '+';
      for(int k=0; k<2; ++k){  
        int a = A, b = B, c = C, d = D;
        op3 = (k&1) ? '-' : '+';
        if(op1 == '-')
          b *= -1;
        if(op2 == '-')
          c *= -1;
        if(op3 == '-')
          d *= -1;
        if((a + b + c + d) == 7){
         cout << A << op1 << B << op2 << C << op3 << D << "=7\n";
         return 0; 
        }
      }
    }
  }
  assert(true);
  return 0;  
}



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

int main(void){
    int n,x;
    cin >> n >> x;
    int w[n],v[n];
    for(int i = 0;i < n;i++)cin >> w[i] >> v[i];
    
    ll dp[n+1][x+1];
    memset(dp,0,sizeof(dp));
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= x;j++){
            if(j >= w[i]){
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
            } else dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][x] << endl;
}

Measured memory_bytes: 82484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;



int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  ll a, b;
  cin >> a >> b;
  if((a+b)%2) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (a+b)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,k = readline() |> split |> parseMap
	s = readline() |> chomp
	for i in 1:n
		if i==k
			print(lowercase(s[i]))
		else
			print(s[i])
		end
	end
end
main()


Measured memory_bytes: 115212
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, X, Y; cin >> N >> X >> Y;
  X--; Y--;
  vector<int> ans(N+1,0);

  for (int i=0;i<N;i++){
    vector<int> G(N,-1);
    G[i] = 0;
    queue<int> q;
    q.push(i);

    while (!q.empty()){
      int node = q.front(); q.pop();
      if (node>0 && G[node-1]==-1){
        G[node-1] = G[node]+1;
        q.push(node-1);
      }
      if (node<N-1 && G[node+1]==-1){
        G[node+1] = G[node]+1;
        q.push(node+1);
      }
      if (node==X && G[Y]==-1){
        G[Y] = G[node]+1;
        q.push(Y);
      }
      if (node==Y && G[X]==-1){
        G[X] = G[node]+1;
        q.push(X);
      }
    }

    rep(j,N) ans[G[j]]++;
  }

  rep(j,N-1) cout << ans[j+1]/2 << endl;
  
  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005],xflag=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0)
				xflag=0;
		}
	}
	if(xflag==1) cout<<"APPROVED";
	else cout<<"DENIED";
	return 0;
} 

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


long long f(int N, long long X) {
    vector<long long> sum = {1};
    vector<long long> pat = {1};
    for (int i = 0; i < N; i++) {
        sum.push_back(sum[i] * 2 + 3);
        pat.push_back(pat[i] * 2 + 1);
    }
    if (N == 0) {
        if (X <= 0) {
            return 0;
        }
        else {
            return 1;
        }
    }
    else if (X <= 1 + sum[N - 1]) {
        return f(N - 1, X - 1);
    }
    else {
        return pat[N - 1] + 1 + f(N - 1, X - 2 - sum[N - 1]);
    }
}

int main() {
    int N;
    cin >> N;
    long long X;
    cin >> X;
    cout << f(N, X) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;
    
    if ( ((x - r) < 0) || ((x + r) > W) || ((y - r) < 0) || ((y + r) > H)) {
            cout << "No" << endl;
}   else{
            cout << "Yes" << endl;
}

    return 0;		 
}



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


string S;


void input()
{
    cin>>S;
}




void solve()
{

    input();

    if(S=="Sunny") cout<<"Cloudy"<<endl;
    if(S=="Rainy") cout<<"Sunny"<<endl;
    if(S=="Cloudy") cout<<"Rainy"<<endl;



}

int main()
{

    solve();


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector< long long > h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    bool OK = false;
    for (int i = 0; i < n; i++) {
        int j = i;
        while (j < n - 1 && (h[j] > h[j + 1] || (OK && h[j] == h[j + 1]))) {
            if (h[j] > h[j + 1])
                OK = true;
            j++;
        }
        if (h[i] - h[j] >= 2) {
            cout << "No" << endl;
            return 0;
        }
        if (i < j) {
            i = j - 1;
        }
    }
    // for (int i = 0; i < n; i++) {
    //     cout << h[i] << " ";
    // }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
int n,K,dp[1<<21][21],nxt[1<<21][2],Log[1<<21];
bool inq[1<<21][21];
struct node
{
	int S,pos;
};
queue<node>q;
void init()
{
	for(int S=1;S<(1<<21);S++)
	{
		Log[S]=log2(S);
		nxt[S][0]=nxt[S][1]=-1;
		for(int i=0,f0=0,f1=0;i<Log[S]&&(!f0||!f1);i++)
			if(S&(1<<i))
			{
				if(!f1)nxt[S][1]=S>>i;
				f1=1;
			}
			else
			{
				if(!f0)nxt[S][0]=S>>i;
				f0=1;
			}
	}
}
void bfs()
{
	while(!q.empty())
	{
		int S=q.front().S,pos=q.front().pos;
		q.pop();
		if(pos==Log[S])continue;
		int L=S&((1<<pos)-1),R=S>>pos;
		int T=L+(1<<pos),pos2=pos;
		dp[T][pos2]+=dp[S][pos];
		if(!inq[T][pos2])
			inq[T][pos2]=1,q.push((node){T,pos2});
		if(nxt[R][0]!=-1)
		{
			T=L+(nxt[R][0]<<pos);
			pos2=pos+1;
			dp[T][pos2]+=dp[S][pos];
			if(!inq[T][pos2])
				inq[T][pos2]=1,q.push((node){T,pos2});
		}
		if(nxt[R][1]!=-1)
		{
			T=L+(nxt[R][1]<<pos);
			pos2=pos+1;
			dp[T][pos2]+=dp[S][pos];
			if(!inq[T][pos2])
				inq[T][pos2]=1,q.push((node){T,pos2});
		}
	}
	int maxn=-1,ans=0;
	for(int S=1;S<(1<<21);S++)
		if(dp[S][Log[S]]>=K&&Log[S]>maxn)
			maxn=Log[S],ans=S;
	for(int i=Log[ans]-1;i>=0;i--)
		printf("%d",(ans>>i)&1);
	puts("");
}
int main()
{
	init();
	scanf("%d %d",&n,&K);
	for(int i=1;i<=n+1;i++)
		for(int j=1,x;j<=(1<<(i-1));j++)
		{
			scanf("%1d",&x);
			if(x==1)
			{
				int S=j-1+(1<<(i-1));
				dp[S][0]++;
				if(!inq[S][0])
					inq[S][0]=1,q.push((node){S,0});
			}
		}
	bfs();
	return 0;
}
/*
3 4
1
01
1011
01001110

10
*/

Measured memory_bytes: 257204
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int ans=0;
    vector <vector<bool>> red( 210,vector <bool>(210,false));
    vector <vector<bool>> blue( 210,vector <bool>(210,false));
    int n; cin>>n;
    for(int i=0;i<n;i++){
        int a, b; scanf("%d %d",&a,&b);
        red[a][b]=true;
        //cout<<b<<endl;
    }
    for(int i=0;i<n;i++){
        int a, b; scanf("%d %d",&a,&b);
        blue[a][b]=true;
    }
    priority_queue<int> q; //x,y 
    queue<int> tmp;
    for(int i=0;i<201;i++){
        for(int j=0;j<201;j++){
            if(red[i][j]) {
                q.push(j);
                //cout<<i<<' '<<j<<endl;
            }
              if(blue[i][j]){
                  //cout<<q.size()<<endl;
                //cout<<'*'<<endl;
                while(q.size()!=0) {
                    int a;
                    a=q.top();
                    q.pop();
                    if(a<j) { ans++; break;}
                    else{ tmp.push(a); }
                }
                while(tmp.size()!=0) {
                    //cout<<"tmp"<<tmp.size()<<endl;
                    int t = tmp.front();
                    tmp.pop();
                    q.push(t);
                }
              
            }
            
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> hmap = new HashMap<Integer, Integer>();
		hmap.put(sc.nextInt(), 1);
		hmap.put(sc.nextInt(), 1);
		hmap.put(sc.nextInt(), 1);
		
		System.out.println(hmap.size());

		
	}
	

}


Measured memory_bytes: 23892
import java.util.Scanner;


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

		String s = scan.next();
		String t = scan.next();
		int ans = 0;
		for(int i = 0; i < s.length(); i++) {
			String tempS = s.substring(i, i+1);
			String tempT = t.substring(i, i+1);
			if(!tempS.equals(tempT)) {
				ans++;
			}
		}
		System.out.print(ans);
	}
}

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

bool a[21][21];

int main() {
	int n;
	while (cin >> n, n) {
		memset(a, 0, sizeof(a));
		rep(i, n) {
			int x, y; cin >> x >> y;
			a[x][y] = true;
		}
		int m; cin >> m;
		int x = 10, y = 10;
		if (a[x][y]) {
			a[x][y] = false;
			n--;
		}
		rep(i, m) {
			char c;int d; cin >> c >> d;
			if (c == 'N')rep(j, d) {
				y++;if (a[x][y]) { a[x][y] = false; n--; }
			}
			if (c == 'E')rep(j, d) {
				x++; if (a[x][y]) { a[x][y] = false; n--; }
			}
			if (c == 'S')rep(j, d) {
				y--; if (a[x][y]) { a[x][y] = false; n--; }
			}
			if (c == 'W')rep(j, d) {
				x--; if (a[x][y]) { a[x][y] = false; n--; }
			}
		}
		puts(n ? "No" : "Yes");
	}
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<pair<int,int> >s;
	int n,k;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k;
		s.push_back(make_pair(k,i+1));
	}
    sort(s.begin(),s.end());
	vector< pair<int,int> >::iterator it;
	for(it=s.begin();it!=s.end();it++){
		cout<<it->second<<" ";
	}
}

Measured memory_bytes: 1780
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (s[2] == s[3] && s[4] == s[5])
	{
		println("Yes");
	}
	else
	{
		println("No");
	}
}


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

int main(void) {
  int i, j, k, cnt = 2, a[26], now = 2;
  char be[200][20], s[20], n[20];
  printf("?a\n"); fflush(stdout);
  scanf("%s", s);
  for(i = 0; i < 26; ++i) a[i] = 0;
  if(s[0] != 'a' || strlen(s) == 1) {
    printf("!OUT\n");
    fflush(stdout);
    return 0;
  }
  be[0][0] = 'a', be[0][1] = 0;
  for(i = 0; i <= strlen(s); ++i) be[1][i] = s[i];
  a[s[strlen(s) - 1] - 'a']++;
  while( 1 ) {
    n[0] = s[strlen(s) - 1];
    if(n[0] != 'a') {
      if(a[n[0] - 'a'] < 26) n[1] = a[n[0] - 'a'] + 'a', n[2] = 'a', n[3] = 0;
      else n[1] = a[n[0] - 'a'] % 26 + 'a', n[2] = 'a', n[3] = 'a', n[4] = 0;
      a[n[0] - 'a']++;
    } else {
      while( 1 ) {
        int sa = 1;
        if(a[n[0] - 'a'] < 26) n[1] = a[n[0] - 'a'] + 'a', n[2] = 'a', n[3] = 0;
        else n[1] = a[n[0] - 'a'] % 26 + 'a', n[2] = 'a', n[3] = a[n[0] - 'a'] / 26 + 'a', n[4] = 0;
         ++a[n[0] - 'a'];
         for(i = 0; i < now; ++i) if(!strcmp(n, be[i])) sa = 0;
         if(sa) break;
      }
    }
    for(i = 0; i <= strlen(n); ++i) be[now][i] = n[i];
    now++;
    printf("?%s\n", n); fflush(stdout);
    scanf("%s", s);
    if(s[0] != 'a') {
      printf("!OUT\n"); fflush(stdout);
      return 0;
    }
    for(i = 0; i < now; ++i) if(!strcmp(be[i], s)) {
      printf("!OUT\n"); fflush(stdout);
      return 0;
    }
    for(i = 0; i < strlen(s); ++i) be[now][i] = s[i];
    ++now;
  }
  return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector <int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int i = 0, sum=0;
	while (k != 0) {
		sum += a[i];
		k--;
		i++;
	}
	cout << sum;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N];
map<string ,int> memo;
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;

		memo[s]++;
	}
	int max1=0;

	for(const auto& x: memo)
	{
		max1=max(max1,x.second);
	}
	for(auto it =memo.begin();it!=memo.end();it++)
	{
		if(it->second==max1)cout<<it->first<<endl;
	}
    return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;
const int mod = 1e9 + 7;

int64_t mod_pow(int64_t x, int64_t n, int64_t mod) {
  int64_t ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}

int64 N, A[100];
int64 dp1[100][101], dp2[100][101];

void dfs(int l, int r) {
  int64 ret = INF;
  int w = r - l;
  for(int i = l; i < r; i++) ret = min(ret, A[i]);
  for(int i = l; i < r; i++) A[i] -= ret;
  vector< pair< int, int > > child;
  for(int i = l; i < r; i++) {
    if(A[i] == 0) continue;
    int left = i;
    while(left < r && A[left] > 0) ++left;
    child.emplace_back(i, left);
    w -= left - i;
    i = left - 1;
  }
  dp1[l][r] = dp2[l][r] = 1;
  for(auto &p : child) {
    dfs(p.first, p.second);
    (dp1[l][r] *= dp1[p.first][p.second]) %= mod;
    (dp2[l][r] *= dp1[p.first][p.second] + dp2[p.first][p.second]) %= mod;
  }
  (dp2[l][r] = dp2[l][r] * mod_pow(2, w, mod) % mod + ((mod_pow(2, ret, mod) + mod - 2) % mod) * dp1[l][r] % mod) %= mod;
  (dp1[l][r] *= mod_pow(2, ret, mod)) %= mod;
  for(int i = l; i < r; i++) A[i] += ret;
}

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  dfs(0, N);
  cout << dp2[0][N] << endl;
}

Measured memory_bytes: 384