akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL H, N;
	cin >> H >> N;
	LL SUM = 0;
	for (LL n = 0; n < N; n++) {
		LL a;
		cin >> a;
		SUM += a;
	}
	if (H <= SUM)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String str1 = null;
        String str2 = null;
        int cntR = 0;
        int cntB = 0;

        try {
            str1 = br.readLine();
            str2 = br.readLine();
            int intA = Integer.parseInt(str1);

            for (int i = 0 ; i < intA ; i++) {
            	if ( str2.charAt(i) == 'R' ) {
            		cntR++;
            	}else {
            		cntB++;
            	}
            }

            if (cntR > cntB) {
            	System.out.println("Yes");
            }else {
            	System.out.println("No");

            }







        } catch (IOException e) {

        }


    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)

vector <ll> dp_a;
vector <ll> dp_b;
vector <ll> dp_c;
vector <ll> A;
vector <ll> B;
vector <ll> C;
bool used_a;
bool used_b;
bool used_c;

ll dfs(ll i){
  if (i==0) {
    if (used_a){
      used_a = false;
      return max(B[0], C[0]);
    } else if (used_b) {
      used_b = false;
      return max(C[0], A[0]);
    } else if (used_c) {
      used_c = false;
      return max(A[0], B[0]);
    }
  }

  if (used_a) {
    used_a = false;
    if (dp_a[i]>=0) {return dp_a[i];}
    ll ans_b = 0;
    ll ans_c = 0;
    used_b = true;
    ans_b = dfs(i-1) + B[i];
    used_c = true;
    ans_c = dfs(i-1) + C[i];
    return dp_a[i] = max(ans_b, ans_c);
  } else if (used_b) {
    used_b = false;
    if (dp_b[i]>=0) {return dp_b[i];}
    ll ans_c = 0;
    ll ans_a = 0;
    used_c = true;
    ans_c = dfs(i-1) + C[i];
    used_a = true;
    ans_a = dfs(i-1) + A[i];
    return dp_b[i] = max(ans_c, ans_a);
  } else if (used_c) {
    used_c = false;
    if (dp_c[i]>=0) {return dp_c[i];}
    ll ans_a = 0;
    ll ans_b = 0;
    used_a = true;
    ans_a = dfs(i-1) + A[i];
    used_b = true;
    ans_b = dfs(i-1) + B[i];
    return dp_c[i] = max(ans_a, ans_b);
  }
}

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
  dp_a = vector<ll> (N+1, -1);
  dp_b = vector<ll> (N+1, -1);
  dp_c = vector<ll> (N+1, -1);
  A = a;
  B = b;
  C = c;
  ll ans_a = 0;
  ll ans_b = 0;
  ll ans_c = 0;
  used_a = true;
  // ans_a = dfs(N-1) + a[N-1];
  ans_a = dfs(N-1);
  used_b = true;
  ans_b = dfs(N-1);
  used_c = true;
  ans_c = dfs(N-1);
  cout << max({ans_a, ans_b, ans_c}) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c));
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef long double LD;


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

  LL NK = max(N, K);
  vector <LL> A(NK + 1);
  for (LL i = 1; i <= NK; ++i) {
      LD nBai = (LD)K / (LD)i;
      LL nKai = (LL)ceil(log2l(nBai));
      if (nKai <= 0) {
        nKai = 0;
      }
      //cerr <<i << " : " << nKai << endl;
      A[i] = nKai;
  }


  LD rate = 0.0;
  for (LL n = 1; n <= N; ++n) {
    rate += ((LD)1.0 / (LD)N) / powl((LD)2.0, (LD)A[n]);
  }
  cout << fixed << setprecision(16) << rate;



  return 0;
}






Measured memory_bytes: 1024
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>
#include <set>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  int res = 0;
  for (size_t i = 1; i+1 < n; ++i) {
    int min, max;
    std::tie(min, max) = std::minmax({a[i-1], a[i], a[i+1]});
    if (a[i] != min && a[i] != max) ++res;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e6+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, m, k, p[N], sz[N];

void solve(){
	cin >> m >> k;
	if(m == 1){
		if(k > 0) deb1(-1)
		else deb4(1,1,0,0)
		return;
	}
	if(k > (1<<m)-1){
		deb1(-1)
		return;
	}
	vll ans;
	for(int i = 0; i < (1<<m); i++){
		if(i == k) continue;
		ans.pb(i);
	}
	ans.pb(k);
	for(int i = (1<<m)-1; i >= 0; i--){
		if(i == k) continue;
		ans.pb(i);
	}
	ans.pb(k);
	debv(ans)
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 5400
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
int main(){
    int L, R, d, count = 0;
    cin >> L >> R >> d;
    for (int i = L; i <= R; i++)
    {
        if(i % d == 0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> divisors(0);
    for (ll i = 2; i * i <= N; i++){
        if (N % i == 0){
            divisors.push_back(i);
            if (i != N / i) divisors.push_back(N / i);
        }
    }
    divisors.push_back(N);
    ll ans = 0;
    ll len = divisors.size();
    rep(i,len){
        ll N_copy = N;
        while(true){
            if (N_copy % divisors[i] != 0) break;
            else N_copy /= divisors[i];
        }
        if ((N_copy - 1) % divisors[i] == 0) ans++;
    }
    vector<ll> divisors2(0);
    for (ll i = 2; i * i <= N - 1; i++){
        if ((N - 1) % i == 0){
            divisors2.push_back(i);
            if (i != (N - 1) / i) divisors2.push_back((N - 1) / i);
        }
    }
    divisors2.push_back(N - 1);
    ll len2 = divisors2.size();
    ans += len2;
    if (N == 2) cout << 1 << endl;
    else cout << ans << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    int taps = a;
    int ans = 0;
    if(b>1)
        ans += 1;
    for(int i=0;i<20;i++){
        if(taps<b){
            taps += a-1;
            ans += 1;
        }else{
            break;
        }
    }
    cout <<  ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n;
	int a[32] = {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};
	scanf("%d",&n);
	printf("%d",a[n-1]);
	
	return 0;
} 

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	string s,t; cin >> s >> t;
	ll n = s.size();
	if(s == t.substr(0,n))  cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3612
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//222
	int n,d,x;
	cin>>n>>d>>x;
	int ch = x;
	while(n--) {
		int val;
		cin>>val;
		REP(i,0,d) {
			if(i*val+1<=d)ch++;
			else break;
		}
	}
	cout<<ch;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

void solve(){

    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;

    ll a1 = n/a + (n%a!=0);
    ll b1 = n/b + (n%b!=0);
    ll c1 = n/c + (n%c!=0);
    ll d1 = n/d + (n%d!=0);
    ll e1 = n/e + (n%e!=0);
    
    ll ans = max({a1,b1,c1,d1,e1})+4;
    cout<<ans<<endl;
}


signed main(){

 
    FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    FOR(tt,1,t){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
    
}

Measured memory_bytes: 256
// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll j=(a);j>=b;j--)

// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// #include <iostream> 
// using namespace __gnu_pbds; 
// using namespace std; 
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) : Value at kth index in sorted array. 
// order_of_key(k) : Index of the value k.

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}


const ll N = 1, M = 1e9 + 7;
ld r;

void solve(){
	cin >> r;
	ld pi = 3.14159265358979323846;
	cout << setprecision(10) << fixed;
	cout << pi * r * 2 << "\n";
}

int main(){
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
string s;
long long sum = 0;
long long pows[11];
long long func(int i, vector<string> vec){
    if (i == s.size()){
        long long mysum = 0;
        for (string p : vec){
            mysum += stoll(p);
        }
        return mysum;
    }
    long long ret = 0;
    if (vec.size() == 0){
        string ss;
        ss += s[0];
        vec.push_back(ss);
        ret = func(i+1, vec);
    }else{
        string ss = vec[vec.size()-1];
       
        // no take
        string sss;
        sss += s[i];
        vec.push_back(sss);
        ret += func(i+1, vec);
        vec.pop_back();
        // take
        ss += s[i];
        vec[vec.size()-1] = ss;
        ret += func(i+1, vec);
        
    }
    return ret;
}
int main ()
{
  prep();
  
  cin >> s;
  long long cur = 1;
  for (int i=0; i<11; i++){
      pows[i] = cur;
      cur *= 10;
  }
  vector<string> empt;
  cout << func(0, empt);
  return 0; 
}

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

int a[10][6];
int flag[10][5];

void revise(int h) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < 5; j++) {
      if (flag[i][j]) a[i][j] = -1;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < 5; j++) {
      if (a[i][j] == -1) {
	for (int k = i; k > 0; k--)
	  a[k][j] = a[k - 1][j];
	a[0][j] = 0;
      }
    }
  }
}

int search(int h) {
  int t = 0;
  for (int i = 0; i < h; i++) {
    int count = 0;
    int fig = 0;
    for (int j = 0; j < 5; j++) {
      if (a[i][j] == a[i][j + 1]) {
	count++;
	if (count == 2) {
	  fig = a[i][j];
	  flag[i][j - 1] = flag[i][j] = flag[i][j + 1] = 1;
	} else if (count > 2) flag[i][j + 1] = 1;
      }
      else if (!fig) count = 0;
      else break;
    }
    if (count >= 2) t += (count + 1) * fig;
  }
  return t;
}

void clear(int h) {
  for (int i = 0; i < h; i++)
    for (int j = 0; j < 5; j++)
      flag[i][j] = 0;
}

int main() {
  for ( ; ; ) {
    int h;
    cin >> h;
    if (h == 0) return 0;

    for (int i = 0; i < h; i++)
      for (int j = 0; j < 5; j++)
	cin >> a[i][j];

    for (int i = 0; i < h; i++)
      a[i][5] = 0;

    int point = 0;
    clear(h);
    for ( ; ; ) {
      int t = search(h);
      if (t == 0) break;
      point += t;
      revise(h);
      clear(h);
    }
    cout << point << endl;
  }
}

Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void) {
	long long n, y, temp, i, j;
	bool flag = false;
	long long a = 0;
	long long b = 0;
	long long c = 0;
	long long max = 0;

	cin >> n >> y;
 
	if (y / 1000 < n || y / 10000 > n) {
		flag = false;
	}
	else {
		temp = 1000 * n;
		if (temp == y) {
			flag = true;
		}

		for (i = 0;i <= n;i++) {
			b = i;
			for (j = 0;j <= n - i;j++) {
				c = j;
				temp = 1000 * (n - b - c) + 5000 * b + 10000 * c;
				if (temp == y) {
					flag = true;
					break;
				}
			}
			if (flag == true) {
				break;
			}
		}
	}

	if (flag == false) {
		cout << "-1 -1 -1" << endl;
	}
	else {
		cout << c << " " << b << " " << n - b - c << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

string string_int_0_delete(string s){

  for(int i=0;!s.empty()&&s[i]=='0';i++) s.erase(s.begin());
  return s;

}

string string_int_max(string s1,string s2){

  s1=string_int_0_delete(s1);
  s2=string_int_0_delete(s2);
  if(s1.size()>s2.size()) return s1;
  else if(s1.size()<s2.size()) return s2;
  else if(s1>s2) return s1;
  else return s2;

}

int main(){

  for(int h,w;cin>>w>>h,w;){
  string s[70],dp[70][70];
  for(int i=0;i<h;i++) cin>>s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(isdigit(s[i][j])){
	string s1,s2;
	s1=s2=s[i][j];
	if(i) s1=dp[i-1][j]+s[i][j];
	if(j) s2=dp[i][j-1]+s[i][j];
	dp[i][j]=string_int_max(s1,s2);
      }
    }
  }

  string sr;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) sr=string_int_max(sr,dp[i][j]);
  cout<<sr<<endl;
  }
  return 0;

}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(long long i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 2019;
const ll INF = 10000000000000000;

int main() {
    ll l,r; cin >> l >> r;
    ll ans = INF;
    FOR(i,l,min(r,l+2019)) {
        FOR(j,i+1,min(r,l+2019)+1) {
            ans = min(i*j%MOD,ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int n;
  cin >> n;
  if (400 <= n && n <= 599) cout << 8 << endl;
  if (600 <= n && n <= 799) cout << 7 << endl;
  if (800 <= n && n <= 999) cout << 6 << endl;
  if (1000 <= n && n <= 1199) cout << 5 << endl;
  if (1200 <= n && n <= 1399) cout << 4 << endl;
  if (1400 <= n && n <= 1599) cout << 3 << endl;
  if (1600 <= n && n <= 1799) cout << 2 << endl;
  if (1800 <= n && n <= 1999) cout << 1 << endl;
}


Measured memory_bytes: 3644
from heapq import heappush, heappop


class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self.parents[y] = x

N = int(input())
q = []
ans = 0
S = UnionFind(N)
x = []
y = []

for i in range(N):
    p,r = map(int, input().split())
    x.append([p,i])
    y.append([r,i])

x.sort()
y.sort()
for i in range(N-1):
    x1, i1 = x[i]
    y1, j1 = y[i]
    x2, i2 = x[i+1]
    y2, j2 = y[i+1]
    heappush(q, (abs(x1-x2), i1, i2))
    heappush(q, (abs(y1-y2), j1, j2))

heappush(q, (abs(x[N-1][0]-x[0][0]), x[N-1][1], x[0][1]))
heappush(q, (abs(y[N-1][0]-y[0][0]), y[N-1][1], y[0][1]))
# クラスカル法
while len(q) > 0:
    d, a, b = heappop(q)
    if S.find(a) != S.find(b):
        ans += d
        S.union(a, b)
print(ans)

Measured memory_bytes: 61676
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  ll a,b;
  cin>>a>>b;

  if((a+b)%2==0){
    cout<<(a+b)/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }

}



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

using namespace std;
#define int long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
#define l_b lower_bound
#define u_b upper_bound

string A;
bool c[26];
vector<int> idx[26];

int leng[200200];

void calc_length() {
    int syu = 0;
    int res = 1;
    for (int i = A.size() - 1; i >= 0; --i) {
        if (!c[A[i] - 'a']) {
            syu++;
            c[A[i] - 'a'] = true;
            if (syu == 26) {
                syu = 0;
                memset(c, 0, sizeof(c));
                res++;
            }
        }
        leng[i] = res;
    }
}

int length(int start) {
    if (start >= A.size())return 0;
    return leng[start];
}

signed main() {
    cin >> A;
    rep(i, A.size()) {
        idx[A[i] - 'a'].push_back(i);
    }
    rep(i, 26) {
        idx[i].push_back(INF);
    }
    calc_length();
    int k = length(0);
    int current = -1;
    string ans = "";
    for (; k > 0; --k) {
        rep(j, 26) {
            int pc = *u_b(idx[j].begin(), idx[j].end(), current);
            if (length(pc + 1) == k - 1) {
                ans.push_back(j + 'a');
                current = pc;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3972
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<functional>

using namespace std;

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

	long long n;

	scanf("%lld", &n);

	long long d3, d5, d15, tot;

	d3 = n / 3;
	d5 = n / 5;
	d15 = n / 15;

	tot = n*(n + 1) / 2 - d3*(d3 + 1) / 2 * 3 - d5*(d5 + 1) / 2 * 5 + d15 * (d15 + 1) / 2 * 15;

	printf("%lld\n", tot);

	return 0;
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long l = 0;
		for(int i=0;i<n;i++) {
			a[i] = sc.nextLong();
			l = l^a[i];
		}
		if(l==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}		
	}
}

Measured memory_bytes: 55792
N, L = map(int, input().split())

t = [L + _ - 1 for _ in range(1, N+1)] # 絶対値が一番小さい要素を0に変えてsumをとりたい
t = sorted(t, key=lambda x: abs(x))

"""
abseat = 299
eat = 299

for i in range(N):
    abst = abs(t[i])
    if abst < abseat:
        abseat = abs(t[i])
        eat = t[i]

ans = sum(t) - eat
"""
ans = sum(t) - t[0]
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

int Max(int x, int y)
{
    return (((y-x)>>(32-1))&(x^y))^y;
}

int Min(int x, int y)
{
    return (((y-x)>>(32-1))&(x^y))^x;
}

vector<int> a, b;
int n, m;
int memo[2005][2005];

int f(int i, int j)
{
    if(i==n)
        return 0;
    if(j==m)
        return 0;
    if(memo[i][j]!=-1)
        return memo[i][j];
    if(a[i]==b[j])
        return memo[i][j]=(1+f(i+1, j)+f(i, j+1))%mod;
    else
        return memo[i][j]=(f(i+1, j)+f(i, j+1)-f(i+1, j+1)+mod)%mod;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //Initialize variables while declaring them
    for(int i=0; i<2005; i++)
        for(int j=0; j<2005; j++)
            memo[i][j]=-1;
    cin>>n>>m;
    a.resize(n);
    b.resize(m);
    for(auto &x:a)
        cin>>x;
    for(auto &y:b)
        cin>>y;
    cout<<(f(0, 0)+1)%mod;
    return 0;
}

Measured memory_bytes: 31872
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < W; i++) printf("#");
        printf("\n");
 
        for(int i = 1; i < H-1; i++){
            printf("#");
            for(int j = 1; j < W-1; j++) printf(".");
            printf("#\n");
        }
 
        if(H > 1){
            for(int i = 0; i < W; i++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


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

int n,k,x = 1;

int main()
{
	cin>>n;
	cin>>k;
	for(int i = 0 ; i < n; i++)
	{
		if(x * 2 > x + k)
			x += k;
		else x *= 2;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,k;
  	double ans = 0.0;
	cin >> n >> k;
  	if(n>=k) {
    	ans += (double)(n-k+1)/n;
    }
	rep(i, min(n, k-1)){
      	int kk = 0;
      	while(pow(2.0, kk)*(i+1)<k) kk++;
      	ans += pow(0.5, kk)/ n;
	}
	printf("%.9lf\n", ans);
}


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

void trace(int a[], int n) {
    int i;
    for(i = 0; i < n; i++) {
        if(i > 0) {
            cout << " ";
        }
        cout << a[i];
    }
    cout << "\n";
}

void insertionSort(int a[], int n) {
    for(int i = 1; i < n; i++) {
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        trace(a, n);
    }
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }

    trace(a, n);
    insertionSort(a, n);

    return 0;
}


Measured memory_bytes: 3088
/*
 *  author: chw0501
 *  reference: 
 *  created: 18.04.2020 10:46:26(UTC)
*/
#include <bits/stdc++.h>

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

#define MOD 1000000007
int n;
vector<int> adj[100001];

//dp[col][i]: vertex i에서 시작하는 색칠 가짓수(i의 색깔은 col이다.)
ll dp[2][100001];

ll solve(int curr,int prev,int col){
	ll & ret=dp[col][curr];
	if(ret!=-1ll) return ret;
	ret=1;
	for(int next:adj[curr]){
		if(next!=prev){
			/*white*/
			if(col==0){
				ll x=(solve(next,curr,0)+solve(next,curr,1))%MOD;
				ret=(ret*x)%MOD;
			}
			/*black*/
			else ret=(ret*solve(next,curr,0))%MOD;
		}
	}
	return ret;
}

int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	memset(dp,-1ll,sizeof(dp));
	cout<<(solve(1,0,0)+solve(1,0,1))%MOD;
	return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<P> G[MAX_N];

int main() {
    int n;
    cin >> n;
    int f[n + 1] = {};

    rep(i,n - 1){
        int a, b;
        cin >> a >> b;
        f[a]++; f[b]++;
        G[a].push_back(P(b,i));
        G[b].push_back(P(a,i));
    }

    int ans = 0;
    rep(i,n+1)ans = max(ans, f[i]);
    cout << ans << endl;

    int c[n + 1];
    int use[n + 1] = {};

    queue<P> que;
    rep(i,G[1].size()){
        c[G[1][i].second] = i;
        que.push(P(G[1][i].first, i));
    }
    use[1] = 1;
    while(que.size() > 0){
        P p = que.front(); que.pop();
        int x = p.first; int ii = p.second;
        use[x] = 1;
        int cnt = 1;
        rep(i,G[x].size()){
            if(use[G[x][i].first] == 0){
                c[G[x][i].second] = (ii + cnt) % ans;
                que.push(P(G[x][i].first, c[G[x][i].second]));
                cnt++;
            }
        }
    }


    rep(i,n-1){
        cout << c[i] + 1 << endl;
    }
    return 0;
}
 
 


Measured memory_bytes: 10240
n, k = map(int, input().split())

li_h = list(map(int, input().split()))


dp = [float("inf")] * n

dp[0] = 0

for i in range(1, n):
    w = i - k if i - k > 0 else 0
    dp[i] = min([cost + abs(height - li_h[i]) for cost, height in zip(dp[w:i], li_h[w:i])])

print(dp[-1])



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

int main() {
	int N, T;
	cin >> N >> T;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int Min = 1e9;
	int dist = -1e9;
	int count = 0;
	for (int i = 1; i < N; ++i) {
		Min = min(Min, A[i - 1]);
		if (dist == (A[i] - Min)) {
			count++;
		}
		else if (dist < (A[i] - Min)) {
			dist = A[i] - Min;
			count = 1;
		}
	}
	cout << count <<endl;
	return 0;
}


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

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int l = sc.nextInt();
		String s[] = new String[n];
		String ans = null;
		
		for (int i = 0; i < n ;i++) {
			s[i] = sc.next();
		}

		Arrays.sort(s);
		
		for (int i=0;i<n;i++){
			System.out.print(s[i]);
		}

		System.out.println("");


		sc.close();
	}
}

Measured memory_bytes: 10060
a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  #max weild
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)


throws=[]
for i in range(1,a+1):
  if ab[i][1]>=ma:
    throws.append(ab[i][1])
throws.sort(reverse=True)


def cel(x):
  if x//1==x:
    return int(x)
  else:
    return int(x)+1


count=0
for i in throws:
  if b>0:
    b-=i
    count+=1
if b>0:
  count+=(cel(b/ma))
print(count)





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

int main(){
  int n,m,i,c=0,p;//p=テδァテつ湘つセテδ・テつ愿つィテδ・テつ愿つー
  int mas[1001];//テδ」テつεつ榲δ」テつづつケテδ」テつつョテδヲテつ古つδァテつ、テつコ
  int go[1001];//テδ」テつつ陛δ」テつつδ」テつつ禿δ」テつづつ催δ」テつつョテδァテつ崚つョ

    while(1){

      cin>>n>>m;
      if(n==0&&m==0)break;
         for(i=0;i<n;i++){
      	cin>>mas[i];
      }

      for(i=0;i<m;i++){
	cin>>go[i];
      }

      c=0;
      p=0;//テδァテつ湘つセテδ・テつ愿つィテδ・テつ愿つー
      while(p<n-1){
	p+=go[c];
	if(p>n){c++;break;}
	c++;
	p+=mas[p];	
      }
      cout<<c<<endl;
    }
return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import static java.lang.Integer.parseInt;

/**
 * Bus Timetable
 * PCK2014 ??????4
 */
public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		boolean[][] table = new boolean[24][60];

		for (int i = 0; i < 2; i++) {
			words = br.readLine().split(" ");
			for (int j = 1; j < words.length; j += 2) {
				table[parseInt(words[j])][parseInt(words[j + 1])] = true;
			}
		}

		List<String> list = new ArrayList<>();
		for (int i = 0; i < 24; i++) {
			for (int j = 0; j < 60; j++) {
				if (table[i][j]) {
					list.add(String.format("%d:%02d", i, j));
				}
			}
		}
		System.out.println(String.join(" ", list));

	}//end main
}

Measured memory_bytes: 25436
/*
 * @Author: BilyHurington
 * @Date: 2020-05-30 19:58:05
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-05-30 20:03:16
 */ 
#include<bits/stdc++.h>
using namespace std;
int H1,H2,M1,M2,K;
int main(){
    scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
    printf("%d",(H2-H1)*60+(M2-M1)-K);
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

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

    int ans = INF;
    for(long long i = 1; i * i <= n; i++){
        if(n % i == 0){
            ans = min(ans, static_cast<int>(max(log10(i) + 1, log10(n / i) + 1)));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	vector <int> a(3);
	for (int i=0; i<3; i++){
		cin >> a.at(i); //数字の読み込み
	}
    int K, ANSWER;
	cin >> K;
	sort(a.begin(), a.end());
	for (int i=0; i<K; i++){
		a.at(2)=a.at(2)*2;
	}
	ANSWER = a.at(0)+a.at(1)+a.at(2);

    cout << ANSWER << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>

namespace rika
{
  template <typename T>
  class edge
  {
  public:
    int to;
    T cost;
    
    edge() = default;
    edge(const edge<T>&) = default;
    edge(edge<T>&&) = default;
    edge& operator =(const edge<T>&) = default;
    edge& operator =(edge<T>&&) = default;

    ~edge() = default;

    edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
namespace rika
{
  namespace internal
  {
    template <typename TValue, typename TGraph>
    std::pair<TValue, int> visit(int from, int v, const TGraph &g)
    {
      auto r = std::make_pair(TValue(), v);
      try
      {
      for(auto it = g[v].begin(); it != g[v].end(); ++it)
      {
        if(it->to == from)
          continue;
        auto r2 = visit<TValue>(v, it->to, g);
        if(r2.first + it->cost >= r.first)
          r = std::make_pair(r2.first + it->cost, r2.second);
      }
      }
      catch(const std::out_of_range& e)
      {
        exit(1);
      }
      return r;
    }
  }

  template <typename TValue, typename TGraph>
  TValue tree_diameter(const TGraph &g)
  {
    using namespace internal;
    auto r1 = visit<TValue>(-1, 0, g);
    auto r2 = visit<TValue>(-1, r1.second, g);
    return r2.first;
  }
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
int main()
{
  int N;
  cin >> N;
  vector<vector<edge<int>>> g(N * 10);
  for(int i = 0; i < N - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge<int>(t, w));
    g[t].push_back(edge<int>(s, w));
  }
  cout << tree_diameter<int>(g) << endl;
}

Measured memory_bytes: 35428
def solve():
    N = int(input())

    count_1 = 0
    for i in [_ for _ in range(1, N+1) if _ % 2 == 1]:
        count_2 = 0
        for j in range(1, i+1):
            if i % j == 0:
                count_2 += 1
        if count_2 == 8:
            count_1 += 1
    print(count_1)


if __name__ == "__main__":
    solve()

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

ll comb(ll a, ll b){
    ll x = 1, y = 1;
    for(ll i = 0; i < b; i++){
        x *= (a - i);
        y *= i + 1;
    }
    return x / y;
}

int main() {
    map<string, ll> mp;
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        ans += comb(itr->second, 2);
    }
    cout << ans << endl;
    

    
}


Measured memory_bytes: 11136
#include <stdio.h>

#define N 1200

int main(void)
{
	char str[N];
	int i = 0;

	while (1) {
		scanf("%c", &str[i]);
		if (str[i] == '\n') {
			break;
		}
		if ('a' <= str[i] && str[i] <= 'z') {//小文字
			str[i] -= 32;
		}
		else if ('A' <= str[i] && str[i] <= 'Z') {//大文字
			str[i] += 32;
		}
		printf("%c", str[i]);
		i++;
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define rr return 0;
const int N = (int)(1*1e6+10);
int fen[N];
typedef long long ss;
int main()
{
    start;
   int a,n,b,i,j,cnt=0,c=0,s=0,f=1,k;
   cin>>n;
   for(i=1;i<=n;i++)
   {
       a=1+log10(i);
       if(a%2!=0) cnt++;
   }
   cout<<cnt<<endl;
   rr
}


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

int main() {
  int d, n;
  cin >> d >> n;
  if (d==0) {
    if (n<100) cout << n;
    else cout << 101;
  }
  else if (d==1) {
    if (n<100) cout << n*100;
    else cout << 101*100;
  }
  else {
    if (n<100) cout << n*10000;
    else cout << 101*100*100;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


class BipartiteMatch(object):

    def __init__(self, n):
        self.n = n
        self.conns = [[] for _ in range(n)]
        self.matched = [-1] * n
        self.visited = None
    def add_edge(self, s, t):
        self.conns[s].append(t)
        self.conns[t].append(s)

    def _dfs(self, i):
        self.visited[i] = True
        for j in self.conns[i]:
            k = self.matched[j]
            if (k < 0 or (not self.visited[k] and self._dfs(k))):
                self.matched[i] = j
                self.matched[j] = i
                return True
        return False

    def run(self):
        ret = 0
        for i in range(self.n):
            if self.matched[i] >= 0:
                continue
            self.visited = [False] * self.n
            if self._dfs(i):
                ret += 1
        return ret

def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    bm = BipartiteMatch(N * 2)
    for i, (x, y) in enumerate(zip(a, b)):
        for j, (xx, yy) in enumerate(zip(c, d)):
            if x < xx and y < yy:
                #print(i, N + j)
                bm.add_edge(i, N + j)
    ret = bm.run()
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (N)  # type: "List[int]"
    d = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42460
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>

using namespace std;

int main()
{
    int N, M;

    cin >> N >> M;
    int s[M];
    for ( int i = 0; i < M; i ++ ) {
        s[i] = 0;
        int k;
        cin >> k;
        int t = 0;
        for ( int j = 0; j < k; j ++ ) {
            cin >> t;
            int bit = 1;
            bit <<= (t-1);
            s[i] |= bit;
        }
    }

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


for ( int i = 0; i < M; i ++ ) {
//    cout << bitset<10> (s[i]) << endl;
}

    int swbit;
    int swbitmax;
    for ( int i = 0; i < N; i ++ ) {
        swbitmax <<= 1;
        swbitmax |= 1;
    }
    int count = 0;
    for ( swbit = 0; swbit <= swbitmax; swbit ++ ) {
// cout << bitset<10>( swbit ) << endl;
        bool off = false;
        for ( int i = 0;i < M; i ++ ) {
            int b = s[i] & swbit;
            bitset<10> bs = b;
            if ( (bs.count() & 0x01) == p[i] ) {

            } else {
                off = true;
                break;
            }
        }
        if ( !off )  count ++;
    }

    cout << count << endl;


    return 0;
}

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

typedef pair<int,int> pii;

int h, w, c;
vector<vector<int> > p;

int merged[8][8];
bool check[8][8];

int dfs(int i, int j) {
	if(check[i][j]) return 0;
	int res = 0;
	check[i][j] = true;
	res++;

	int dxy[] = {1,0,-1,0,1};
	for(int k = 0; k < 4; k++) {
		int ii = i+dxy[k], jj=j+dxy[k+1];
		if(0 <= ii && ii < h && 0 <= jj && jj < w) {
			if(merged[ii][jj]) {
				res += dfs(ii,jj);
			}
		}
	}

	return res;
}

void mer(int i, int j, int col, vector<pii>&rv) {
	if(merged[i][j] == 2) return;
	if(merged[i][j] == 0) rv.push_back(pii(i,j));
	merged[i][j] = 2;

	int dxy[] = {1,0,-1,0,1};
	for(int k = 0; k < 4; k++) {
		int ii = i+dxy[k], jj=j+dxy[k+1];
		if(0 <= ii && ii < h && 0 <= jj && jj < w && (col == p[ii][jj] || merged[ii][jj])) {
			mer(ii,jj,col,rv);
		}
	}
}

int solve(int ii, int jj, int col, int d) {
	vector<pii> tmp;
	if(d == 5) {
		if(col != c) return 0;
		for(int i = 0; i < 8; i++) {
			for(int j = 0; j < 8; j++){
				check[i][j] = 0;
			}
		}
		for(int i = 0; i < h; i++)
			for(int j = 0; j < w; j++)
				merged[i][j] = !!merged[i][j];
		mer(ii,jj,col,tmp);
		int res;
		res = dfs(ii,jj);

		for(int i = 0; i < tmp.size(); i++)
			merged[tmp[i].first][tmp[i].second] = 0;

		return res;
	}

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			merged[i][j] = !!merged[i][j];
		}
	}

	mer(ii,jj,col,tmp);

	int res = 0;
	for(int i = 0; i < 6; i++) {
		res = max(res,solve(ii,jj,i,d+1));
	}

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			merged[i][j] = !!merged[i][j];
		}
	}
	for(int i = 0; i < tmp.size(); i++)
		merged[tmp[i].first][tmp[i].second] = 0;
	return res;
}
void clear() {
	for(int i = 0; i < 8; i++) {
		for(int j = 0; j < 8; j++){
			merged[i][j] = 0;
			check[i][j] = 0;
		}
	}
}

int main() {
	while(cin >> h >> w >> c, h || w || c) {
		p.clear(); p.resize(h);
		c--;
		for(int i = 0; i < h; i++) {
			p[i].resize(w);
			for(int j = 0; j < w; j++){
				cin >> p[i][j]; p[i][j]--;
			}
		}

		int res = 0;
		clear();
		res = max(res,solve(0,0,p[0][0],0));

		cout << res << endl;
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;

void solve1()
{
    int n, k; cin >> n >> k;
    long double ans = 0;

    for(int i = 1; i <= n; i++) {
        
            int cnt = 0; 
            ll p = i;
            while (p < k)
            {
                p *= 2;
                cnt++;
            }
        
        long double d = pow((long double)0.5, cnt);
        ans += ((long double)1.0/(long double)(1.0*n))*(d);
        /*cout << i << endl;*/
    }

    

    cout << fixed << setprecision(12) << ans << endl;
}

int main()
{
    solve1();
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp*/
#include<iostream>

using namespace std;

void println(int *a,int n){
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i<n-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

int main()
{
    int n;
    int j=0;
    int a[100];
    int count=0;
    bool flag= true;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    while(flag == true){
        flag = false;
        for(int i=n-1;j<i;i--){
            if(a[i]<a[i-1]){
                int tmp=a[i];
                a[i]=a[i-1];
                a[i-1]=tmp;
                flag=true;
                count++;
            }
        }
        j++;
    }
    println(a,n);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1160
n=int(input())
P=[int(input()) for _ in range(n)]
Q=[0]*n
for i,j in enumerate(P):
    Q[j-1]=i
cresc=1
cnt=1
for i in range(1,n):
    if Q[i-1]<Q[i]:
        cnt+=1
    else:
        cresc=max(cresc,cnt)
        cnt=1
    cresc=max(cresc,cnt)
print(n-cresc)

Measured memory_bytes: 19016