akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)
#define sf .second.first
#define ss .second.second
#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INF  1000000000

#define N 100005

int n,k,a[N],dp[N];


int main() {

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

    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        int r1=MOD;
        for(int j=1;j<=min(i,k);j++){
            r1=min(r1,abs(a[i-j]-a[i])+dp[i-j]);
        }
        dp[i]=r1;
    }


    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

    string str;
    cin >> str;

    string wa = "WA";
    string ac = "AC";

    REP(i, str.size())
    {
        if (i == 0){
            if(str[i] != 'A'){
                cout << wa << endl;
                return 0;
            }else{
                continue;
            }
        }

        if (i == 1 || i == str.size()-1)
        {
            if(str[i] == 'C'){
                cout << wa << endl;
                return 0;
            }
        }

        if (!islower(str[i]))
        {
            if (str[i] != 'C')
            {
                cout << wa << endl;
                return 0;
            }
        }
    }

    int cnt = 0;
    FOR(i,2,str.size()-1){
        if (str[i] != 'C' && isupper(str[i]))
        {
            cout << wa << endl;
            return 0;
        }
        if (str[i] == 'C')
        {
            cnt++;
        }
    }

    if (cnt == 1)
    {
        cout << ac << endl;
    }
    else
    {
        cout << wa << endl;
    }
    return 0;
}


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

int dx[4] = {0,0,1,1};
int dy[4] = {0,1,0,1};

int main()
{
   char s[1010][1010];
   int b[1010][2];
   int h,w,ans=0;
   
   cin >> h >> w;
   for(int i=0;i<h;i++){
       scanf("%s",s[i]);
       b[i][0] = -1;
       b[i][1] = -1;
       for(int j=0;j<w;j++){
           if(s[i][j] == 'B'){
               b[i][1] = j;
               if(b[i][0] == -1) b[i][0] = j;
           }
       }
       ans = max(ans,b[i][1]-b[i][0]);
   }

    for(int i=0;i<h;i++){
        for(int j=i+1;j<h;j++){
            for(int k=0;k<4;k++){
                if(b[i][dx[k]] == -1 || b[j][dy[k]] == -1) continue;
                ans = max(ans,(j-i)+abs(b[i][dx[k]]-b[j][dy[k]]));
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



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

int main(){
	int A,B,C,ans;
	cin>>A>>B>>C;
	if(A==B){
		ans=C;
	}else if(A==C){
		ans=B;
	}else if(B==C){
		ans=A;
	}
	cout<<ans<<endl;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int N_MAX = 100000;
    int N;
    int A[N_MAX + 1];
    cin >> N;
    A[0] = 0;
    REP(i, N) cin >> A[i + 1];
    int total = 0;
    REP(i, N + 1) {
        total += abs(A[(i + 1) % (N + 1)] - A[i % (N + 1)]);
    }
    PRINT(total);
    FOR(i, 1, N + 1) {
        int j = (i + 1) % (N + 1);
        int k = (i + N) % (N + 1);
        cout << total - abs(A[i] - A[j]) - abs(A[i] - A[k]) + abs(A[j] - A[k]) << endl;

    }
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	unsigned lost = 0;
	for (int i = 0; i < s.size(); ++i){
		if(s[i] == 'x') lost++;
	}
	if(lost >= 8) printf("NO\n");
	else printf("YES\n");
	return 0;
}

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

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

  if (A > B) {
    cout << 0 << endl;
    return 0;
  }

  if (N == 1 && A != B) {
    cout << 0 << endl;
    return 0;
  }

  cout << (N - 1) * (B - A) + (A - B) + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
char _;


int main(){
	int N, X, diff = INT_MAX, cur = 0; cin >> X >> N;
	vector<bool> arr(202);
	for(int i = 0; i < N; i++){
		int x; cin >> x; arr[x] = true;
	}
	for(int i = 0; i < 200; i++){
		if(X-i >= 0 && !arr[X-i]){
			cout << X-i << '\n'; return 0;
		}
		else if(!arr[X+i]){
			cout << X + i << '\n'; return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;int h,w,m=0,D[1401][1401]={},f,i=0;main(){cin>>h>>w;for(;i<h*w;i++)cin>>f,m=max(m,D[i/w+1][i%w+1]=(min(D[i/w][i%w],min(D[i/w+1][i%w],D[i/w][i%w+1]))+1)*(!f));cout<<m*m<<endl;}


Measured memory_bytes: 10756
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
vector<LL> t, a;
LL t_num = 0, a_num = 0;
/**********************************************/
int main(){
    cin >> n;
    t.resize(n); a.resize(n);
    REP(i, n) cin >> t[i] >> a[i];
    
    t_num = t[0]; a_num = a[0];
    
    FOR(i, 1, n){
        LL j = 1;
        if(t_num <= t[i] && a_num <= a[i]){
            j = 1;   
        }else{
            j = max(t_num/t[i] + min(t_num%t[i], 1LL), a_num/a[i] + min(a_num%a[i], 1LL));
        }
        t_num = t[i]*j; a_num = a[i]*j;
    }
    
    cout << t_num+a_num << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<long long,int> m;
int prm[3000],pcnt;
int main(){
	for(int i=2;i<3000;i++){
		bool gg=false;
		for(int j=2;j*j<=i;j++){
			if(i%j==0) gg=true;
		}
		if(!gg) prm[pcnt++]=i;
	}
	int ans=0;
	int n;
	long long x,up=1e11;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		for(int j=0;j<pcnt;j++){
			int c=0;
			while(x%prm[j]==0) x/=prm[j],c++;
			c%=3;
			while(c--) x*=prm[j];
		}
		m[x]++;
	}
	if(m.count(1)) ans++,m.erase(1);
	for(auto it=m.begin();it!=m.end();it=m.erase(it)){
		long long now=it->first,rev=1,tr=1;
		bool tb=false;
		for(int j=0;j<pcnt;j++){
			int c=0;
			while(now%prm[j]==0) now/=prm[j],c++;
			if(c) c=3-c;
			while(c--){
				if(up/rev>prm[j]) rev*=prm[j];
				else tb=true;
			}
		}
		if(now>1){
			long long sq=round(sqrt(now));
			if(sq*sq==now) tr=sq;
			else if(now<up/now) tr=now*now;
			else tb=true;
		}
		if(!tb&&rev<up/tr){
			rev*=tr;
			ans+=max(it->second,m[rev]);
			m.erase(rev);
		}
		else ans+=it->second;
	}
	printf("%d\n",ans);
	return 0;
}

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

int num,r,d;

signed main()
{
	cin>>r>>d>>num;
	for (int i=2001;i<=2010;i++)
	{
		num=(num*r)-d;
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var v = o.l();
  var a = {}, b = {};
  for(var i = 0; i < n; i++){
    if(a[v[i]])a[v[i]]++;
    else a[v[i]] = 1;
    i++;
    if(b[v[i]])b[v[i]]++;
    else b[v[i]] = 1;
  }
  var c = [], d = [];
  for(i in a){
    c.push([i,a[i]]);
  }
  for(i in b){
    d.push([i,b[i]]);
  }
  c.sort((a,b)=>b[1]-a[1]);
  d.sort((a,b)=>b[1]-a[1]);
  if(c[0][0] !== d[0][0])return n-c[0][1]-d[0][1];
  if(c.length !== 1){
    if(d.length !== 1){
      return n-Math.max(c[1][1]+d[0][1],c[0][1]+d[1][1]);
    }else return n-c[1][1]-d[0][1];
  }
  if(d.length !== 1)return n-c[0][1]-d[1][1];
  return n / 2;
}

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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};

int main() {
	ll i,j,k;
	string s;
	cin >> s;
	ll n = s.length();
	string prev = "";
	string curr = "";
	ll ans = 0;
	fo(i,0,n) {
		curr += s[i];
		if (curr != prev) {
			ans++;
			prev = curr;
			curr = "";
		}
	}
	if (prev != curr && curr != "") {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<string> ws(n);
  for (int i = 0; i < n; ++i) {
    cin >> ws[i];
  }

  bool ans = true;
  for (int i = 1; i < n; ++i) {
    if (ws[i - 1].back() != ws[i].front()) {
      ans = false;
      break;
    }

    auto w_it = find(ws.begin(), ws.begin() + i, ws[i]);
    if (w_it != ws.begin() + i) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';

  return 0;
}

Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();

        for(int i=0; i<n.length(); i++){
            if(n.charAt(i) == '1') System.out.print('9');
            if(n.charAt(i) == '9') System.out.print('1');
        }
        System.out.println();
    }
}


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



void solve(vector<int>& a){
  int f[3]={};
  int s[]={0,1,2};
  int t[]={1,2,0};
  for(int i=0;i<a.size();i++){
    f[a[i]-1]=1;
  }
  if( (f[0]+f[1]+f[2])%2 == 1 )
    for(int i=0;i<5;i++) cout << "3\n";

  else
    for(int j=0;j<3;j++){
      if( f[s[j]]==1 && f[t[j]]==1 ){
	for(int i=0;i<5;i++){
	  if(a[i] == s[j]+1) cout << "1\n";
	  if(a[i] == t[j]+1) cout << "2\n";
	}
      }
    }
}

int main(){
  bool f=true;
  while(1){
    vector<int> x;
    for(int i=0;i<5;i++){
      int tmp;
      cin >> tmp;
      if(i==0 && tmp == 0){
	f=0;
	break;
      }
      x.push_back(tmp);
    }
    if(!f) break;
    solve(x);
  }
}

Measured memory_bytes: 1172
fn main() {
    let n = read::<usize>();
    let v = read_vec::<u32>();
    let mut b4 = 0;
    let mut b2 = 0;
    for a in v {
        if a % 4 == 0 {
            b4 += 1;
        } else if a % 2 == 0 {
            b2 += 1;
        }
    }
    yn(b4 >= n / 2 || b2 >= n - 2 * b4);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
  double w1 , w2 , s1 , s2 , n , s;
  cin >> w1 >> w2 >> s1 >> s2 >> n >> s;
  int bs=0;
  int bw=w1*100;
  map<double,double> mw;
  map<double,double> ms;
  for (double i=0;i<=s;i+=w2*100) {
    for (double j=i;j<=s;j+=w1*100) {
      mw[j]=1;
    }
  }
  for (double i=0;i<=s;i+=s2) {
    for (double j=i;j<=s;j+=s1) {
      ms[j]=1;
    }
  }
  for (auto pw:mw) {
    for (auto ps:ms) {
      if (pw.first+ps.first > s) {
        continue;
      }
      else if (ps.first <= pw.first / 100 * n 
          && double(bs) / double(max(1,bw)) < double(ps.first) / double(pw.first)) {
        bs = ps.first;
        bw = pw.first;
      }
    }
  }
  cout << bw+bs << " " << bs;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int m=scanner.nextInt();
		long[] imos=new long[n];
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=scanner.nextInt();
		}
		imos[0]=a[0];
		for(int i=1;i<n;i++){
			imos[i]=a[i]+imos[i-1];
		}
		Map<Long,Integer>map=new HashMap<>();
		map.put((long) 0, 1);
		for(int i=0;i<n;i++){
			long key=imos[i]%m;
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}
		long ans=0;
		for(int val:map.values()){
			ans+=(long)val*(val-1)/2;
		}
		System.out.println(ans);
	}
}

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


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

void sort2vectors(vector<long long> &av, vector<long long> &bv)
{
    int n = av.size();
    vector<long long> p(n), av2(n), bv2(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });
    for (int i = 0; i < n; i++) {
            bv2[i] = bv[p[i]];
            av2[i] = av[p[i]];
    }
    av = av2;
    bv = bv2;
}

int main()
{
    long long n, m, ans = 0;
    cin >> n >> m;
    vector<long long> a(n, 0), b(n, 0);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a[i], &b[i]);
    }
    sort2vectors(a, b);
    for(int i = 0; i < n && m > 0; i++){
        if(b[i] <= m) {
            ans += a[i] * b[i];
            m -= b[i];
        }
        else {
            ans += a[i] * m;
            m = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
   set<int> list;
   int n;
   cin >> n;
   for(int i = 0; i < n; i++){
      int k;
      cin >> k;
      list.insert(k);
   }
   if(list.size() == n){
      cout << "YES";
   }
   else{
      cout << "NO";
   }
   cout << endl;
   return 0;
}


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

int main() {
  int n,m,k,a;cin>>n>>m;
  int ans=0;
  vector<int> se(m,0);
  for(int i=0;i<n;++i){
    cin>>k;
    for(int j=0;j<k;++j){
      cin>> a;
      ++se[a-1];
    }
  }
  for(int u:se) if(u==n)++ans;
  cout<<ans<<endl;
  return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        cin >>N;
        int S=0;
        Rep1(i, N) {
                int a;
                cin >>a;
                if ((1==a%2)&&(1==i%2))
                        S++;
        }
        cout <<S <<endl;
        return 0;
}


Measured memory_bytes: 3596
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, m;
    cin >> n >> m;

    vector<pair<int,int>> sc(m);

    for(int i = 0; i < m; i++){
        cin >> sc[i].first >> sc[i].second;
    }

    for(int i = 0; i <= 999; i++){
        string s = to_string(i);
        if(s.size() != n) continue;
        bool ok = true;
        for(int j = 0; j < m; j++){
            if(s[sc[j].first - 1] - '0' != sc[j].second){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}   

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) {
    cout << s << endl;
  }
  else {
    for(int i=0; i<k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3624
n = int(input())
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[i] = str(chr(c)).lower()


ans = []
def dfs(s, mx, ans):
  if len(s) == n:
    ans += [s]
    return 
  else:
    for i in range(mx+1):
      dfs(s+alpha_dict[i], max(i+1, mx), ans)

dfs("", 0, ans)
ans = sorted(ans)
for a in ans:
  print(a)


Measured memory_bytes: 12684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll ch[200010],ans[200010];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll now;
		cin>>now;
		ch[i]=now;
	}
	ll ANS=0;
	for(ll i=n;i>=1;i--){
		ll cnt=0;
		ll now=1;
		while(now*i<=n){
			cnt+=ans[i*now];
			now++;
		}
		if(cnt%2!=ch[i]){
			ans[i]=1;
			ANS++;
		}
	}
	cout << ANS<<endl;
	for(ll i=1;i<=n;i++){
		if(ans[i]){
			cout << i<<endl;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3968
x=int(input())

anses = set()
i = 0
while True:
    anses.add(i)
    anses.add(-i)
    if i**5 > 10**18:
        break
    i += 1

for a in list(anses):
    for b in list(anses):
        if a**5 - b**5 == x:
            print(a,b)
            exit(0)

Measured memory_bytes: 9788
#include <iostream>
#include<algorithm>
using namespace std;
int main(void)
{	int N, A, B,P,P1,P2,P3;
	P1 = P2 = P3 = 0;
	cin >> N;
	cin >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> P;
		if (P <= A) {
			P1++;
		}
		else if (A + 1 <= P && P <= B) {
			P2++;
		}
		else if (B + 1 <= P) {
			P3++;

		}

	}

	cout << min({ P1,P2,P3 }) << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int solve(){}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int k,n ;cin>>k>>n;
	v arr(n);in(arr,n);
	int mx=0;
	f(i,n-1)
	{
		mx=max(mx,abs(arr[i+1]-arr[i]));
	}
	cout<<min(k-mx,arr[n-1]-arr[0])<<endl;
	return 0;
}

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

int main() {
vector<int> vec(32);
vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int K;
cin >> K;
cout << vec.at(K-1) << endl;

return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
mod = 10 ** 9 + 7

N, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

memo = []
for p in range(C + 1):
    tmp = [pow(i, p, mod) for i in range(401)]
    memo.append(tuple(accumulate(tmp)))


dp = [[0] * (C + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i, (a, b) in enumerate(zip(A, B)):
    for j in range(C + 1):  # 累計でj個配ったことにする
        for k in range(j + 1):  # i番目の子にk個あげる
            dp[i + 1][j] += dp[i][k] * (memo[j-k][b] - memo[j-k][a-1])
            dp[i + 1][j] %= mod

print(dp[N][C])

Measured memory_bytes: 93388
import java.util.Scanner;

public class Main {

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

		String id = sc.next(); //ID
		String id2 = sc.next(); //ID

		int cnt = id.length();
		int cnt2 = id2.length();

		String id3 = id2.substring(cnt);

		if(id.equals(id2.substring(0, cnt)) && id3.length() == 1) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
	}

}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    string s;
    cin >> s;

    bool ok = 1;
    int i = 0;
    while(i < s.length()){
        if (s[i] == 'h' && (i+1) < s.length() && s[i+1] == 'i')
            i+=2;
        else{
            ok = 0;
            break;
        }
    }

    if(ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#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 oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	string s;
	cin >> s;
	
	int sum=0;
	for(int i=0 ; i<s.size() ; ++i)sum += (s[i]-'0');
	
	cout << ((sum%9) ? "No" : "Yes");
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

using namespace std;

#define ll long long

#define DEBUG (0)

int main()
{
  ll H = 0, N = 0;
  cin >> H >> N;

  vector<ll> A(N,0);
  ll sum = 0;

  for(ll i = 0 ; i < N; i++){
    cin >> A[i];
    sum += A[i];
  }

  if(H <= sum){
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }



}

Measured memory_bytes: 1024
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  vl a(n+1), b(m+1);
  rep(i, n) {
    cin >> a[i+1];
  }
  rep(i, m) {
    cin >> b[i+1];
  }

  rep(i, n) {
    a[i+1] += a[i];
  }
  rep(i, m) {
    b[i+1] += b[i];
  }

  ll ans = 0;
  rep(i, n+1) {
    if (a[i] > k) break;
    ll cnt = i+(upper_bound(all(b), k-a[i])-b.begin())-1;
    cmax(ans, cnt);
  }
  cout << ans << el;
}


Measured memory_bytes: 6336
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define pb push_back
#define mp make_pair
#define rep(i,n) for(long long i=0;i<n;i++)
#define repr(i,j,n) for(long long i=j;i<=n;i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
const ll maxn = 1000;
ll a[maxn];
//ll dp[1024][1024];

int main()
{
	std::ios::sync_with_stdio(0);
	ll i,j,k,t,q,m,l,r,n;
	cin>>n;
	rep(i,2*n)cin>>a[i];
	m=2*n;
	sort(a,a+m);
	ll out=0;
	for(i=0;i<m;i+=2)
	{
		out+=a[i];
	}
	cout<<out<<endl;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC109 {
    class C {
        static void Main() => CustomMain();

        static void Solve() {
            int n, x;
            ReadMulti(out n, out x);
            var xi = ReadIntArray();

            long ans = Math.Abs(xi[0] - x);
            for (int i = 1; i < n; i++) {
                var g = GCD(ans, Math.Abs(xi[i] - x));
                ans = Math.Min(ans, g);
            }

            WriteAnswer(ans);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

Measured memory_bytes: 18528
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

struct edge{
  int to,cost;
};
const int INF = 1<<30;
vector<vector<edge>> G; //グラフ
vector<int> d; //最短距離を格納する
int N,E; //N=ノード数,E=辺の数
vector<int> to[2505];
vector<int> rto[2505];
bool reachFrom1[2505],reachToN[2505],ok[2050];

bool bellman_ford(int s){
  for(int i = 0; i < N; i++) d[i] = INF;
  d[s] = 0;
  for(int i = 0; i < N; i++){
    for(int v = 0; v < N;v++){
      if(!ok[v]) continue;
      for(auto e:G[v]){
        if(!ok[e.to]) continue;
        if(d[v] != INF && d[e.to] > d[v] + e.cost){
          d[e.to] = d[v] + e.cost;
          //n回目にも更新があるなら負の経路が存在する
          if(i == N-1) return true;
        }
      }
    }
  }
  return false;
}

void dfs(int s){
  if(reachFrom1[s]) return;
  reachFrom1[s] = true;
  for(int v:to[s]){
    dfs(v);
  }
}
void rdfs(int s){
  if(reachToN[s]) return;
  reachToN[s] = true;
  for(int v:rto[s]){
    rdfs(v);
  }
}

int main(){
  int p; cin >> N >> E >> p;
  d.resize(N);
  G.resize(N);
  
  rep(i,E){
    int a,b,c; cin >> a >> b >> c;
    a--,b--;
    c -= p;
    c = -c;
    to[a].push_back(b);
    rto[b].push_back(a);
    edge e; e.to = b, e.cost = c;
    G[a].push_back(e);
  }
  
  dfs(0);
  rdfs(N-1);
  rep(i,N) ok[i] = reachFrom1[i] & reachToN[i];
  
  if(bellman_ford(0)){
    cout << "-1" << endl;
  }else{
    cout << max(-d[N-1],0) << endl;
  }
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
/*{{ x | (1 << k) sets the kth bit of x to one
x & ~(1 << k) sets the kth bit of x to zero
x ^ (1 << k) inverts the kth bit of x.
x & (x-1) sets the last one bit of x to zero
x & -x sets all the one bits to zero, except for the last one bit. 
x | (x-1) inverts all the bits after the last one bit.}} SOME BIT MANIPULATION*/
//__builtin_clz(x): the number of zeros at the beginning of the number
//__builtin_ctz(x): the number of zeros at the end of the number
//__builtin_popcount(x): the number of ones in the number
//__builtin_parity(x): the parity (even or odd) of the number of ones 
struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
	{
        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);
    }
};
/*//DSU 
int parent[200005];
int rankr[200005];
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rankr[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rankr[a] < rankr[b])
            swap(a, b);
        parent[b] = a;
        if (rankr[a] == rankr[b])
            rankr[a]++;
    }
} */

int main()
{  
	fast; 
	ll a,b,c; cin>>a>>b>>c;
	ll k; cin>>k;
	while((a >= b || b >= c) && k > 0)
	{
		if(b >= c)
		{
			c *= 2;
			k--;
		}
		if(a >= b)
		{
			b *= 2;
			k--;
		}
	}
//	cout << a << " " << b << " " << c << endl;
	if(b > a && c > b)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        v[i] = i + 1;
    }

    string a, b, c;
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        a += c;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        b += c;
    }

    string s;
    int x = 0, y = 0, i = 0;
    do
    {
        for (int j = 0; j < n; j++)
        {
            s += to_string(v[j]);
        }

        if (s == a)
        {
            x = i + 1;
        }
        if (s == b)
        {
            y = i + 1;
        }
        if (x > 0 && y > 0)
        {
            break;
        }
        s.clear();
        i++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(x - y) << endl;
}

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

vector<vector<int>> v;
vector<int> dp;

void dfs(int source)
{    
    int maxx = -1;
    for(auto i:v[source])
    {
        if(dp[i] == -1)
            dfs(i);
        maxx = max(maxx , dp[i]);
    }
    dp[source] = maxx+1;
    return;
}

 
int32_t main()
{
    int n,m;
    cin>>n>>m;
    v.resize(n);
    
    for(int i=0;i<m;++i)
    {
        int x,y;
        cin>>x>>y;
        v[x-1].push_back(y-1);
    }

    dp.resize(n);
    fill(dp.begin() , dp.end() , -1);

    int maxx = 0;
    for(int i=0;i<n;++i)
    {
        if(dp[i] == -1)
            dfs(i);
        maxx = max(maxx, dp[i]);
    }

    cout<<maxx<<endl;

    return 0;
}

Measured memory_bytes: 9216
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, c[1001][1001];
	/*
	c = malloc(sizeof(int)*(m+1));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(n+1));
	*/
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	//for (i = 0; i < m; i++)free(c[i]);
	//free(c);
	
}

int main(){
	int i, n;
	char x[2000], y[2000];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 4524
#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(){
    ll n, d, r = 0;
    cin >> n >> d;
    for (int i = 0; i < n;++i){
        ll x,y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ++r;
    }
    cout << r;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n,i,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=30;i>=1;i--)
	{
		int p=0;
		int q=n-1;
		while(p<q)
		{
			if(a[p]+a[q]==(1<<i))
			{
				ans++;
				a[p++]=0;
				a[q--]=0;
			}
			else if(a[p]+a[q]<(1<<i))
				p++;
			else 
				q--;
		}
    	int len=0;
    	for(p=0;p<n;p++)
		{
			if(a[p])
				a[len++]=a[p];
		}
		n=len;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector <int> edges[200005];
vector <ll> counter(200005);

void dfs(int cur, int par) {
    for (int e : edges[cur]) {
        if (e == par) continue;
        counter[e] += counter[cur];
        dfs(e, cur);
    }
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, Q, a, b, p;
    ll x;
    cin >> N >> Q;

    for (int i = 1; i < N; i++) {
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    for (int q = 0; q < Q; q++) {
        cin >> p >> x;
        counter[p] += x;
    }

    dfs(1, 0);

    for (int i = 1; i <= N; i++) {
        cout << counter[i] << ' ';
    }

    return 0;
}


Measured memory_bytes: 24320
odd = ['#','.']
even = ['.','#']
while True:
    h,w = map(int, raw_input().split())
    if h == w == 0:
        break 
    ret = []
    for i in range(h):
        ret += [odd[j%2] if i % 2 == 0 else even[j%2] for j in range(w)]
        ret += ['\n']
    print(''.join(ret))

Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD 1000000007
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define get(...) int __VA_ARGS__; bulk(__VA_ARGS__);
int main(){
	get(w,a,b);
	if(a>b)swap(a,b);
	cout<<max(b-a-w,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
D = []
luck = []
raku = []
for i in range(N):
    d = A[i]-B[i]
    if d < 0:
        luck.append(d)
    else:
        raku.append(d)
    D.append(d)
Luck = sum(luck)
raku.sort(reverse=True)
R = len(raku)
L = len(luck)
flag = 0
for j in range(R):
    if Luck >= 0:
        print(0)
        flag = 1
        break
    Luck+=raku[j]
    if Luck >= 0:
        print(j+1+L)
        flag = 1
        break
    else:
        pass
if flag == 0:
    print(-1)

Measured memory_bytes: 18356
from collections import Counter

MOD = 10 ** 9 + 7

N = int(input())
a = list(map(int, input().split()))

ans = 2 ** (N // 2) % MOD
flg = True
b = Counter(a)
if N % 2 == 1:
    for i in range(0, N, 2):
        if i == 0:
            if b[i] != 1:
                flg = False
                break
        else:
            if b[i] != 2:
                flg = False
                break

else:
    for i in range(1, N, 2):
        if b[i] != 2:
            flg = False
            break

print(ans if flg else 0)


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<ll> A(n+1), B(n);
	rep(i, n+1) cin >> A[i];
	rep(i, n) cin >> B[i];

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(B[i] >= A[i]){
			ans += A[i];
			B[i] -= A[i];
			ans += min(A[i+1], B[i]);
			A[i+1] -= min(A[i+1], B[i]);
		}else{
			ans += B[i];
			A[i] -= B[i];
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 1792