akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>

#define sqr(x) ((x)*(x))

using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> Line;

P operator-(P a,P b){
  return {a.first-b.first,a.second-b.second};
}

bool is_on(Line l,P p){
  P lv=l.second-l.first;
  P pv=p-l.first;
  return lv.first*pv.second-lv.second*pv.first==0&&(l.first<=p&&p<=l.second||l.second<=p&&p<=l.first);
}
    
int main(){
  for(int n;cin>>n,n;){
    int xs,ys,xg,yg;
    cin>>xs>>ys>>xg>>yg;
    Line l[200];
    for(int i=0;i<n;i++){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      l[i]={{a,b},{c,d}};
    }
    bool sig[200]={};
    vector<P> v;
    map<P,int> vtoi;
    for(int i=0;i<n;i++){
      bool f=false,s=false;
      auto fp=l[i].first;
      auto sp=l[i].second;
      for(int j=0;j<n;j++){
	if(i==j)continue;
	f|=is_on(l[j],fp);
	s|=is_on(l[j],sp);
      }
      if(f&&s){
	if(vtoi.count(fp)==0){
	  vtoi[fp]=v.size();
	  v.push_back(fp);
	}
	if(vtoi.count(sp)==0){
	  vtoi[sp]=v.size();
	  v.push_back(sp);
	}
      }else{
	sig[i]=true;
      }
    }
    const int INF=1<<29;
    vector<vector<double> > d(v.size(),vector<double>(v.size(),INF));
    for(int i=0;i<d.size();i++){
      d[i][i]=0;
    }
    for(int i=0;i<n;i++){
      if(!sig[i]){
	vector<P> vol;
	for(auto e:v){
	  if(is_on(l[i],e)){
	    vol.push_back(e);
	  }
	}
	sort(begin(vol),end(vol));
	for(int j=0;j+1<vol.size();j++){
	  int x1=vtoi[vol[j]];
	  int x2=vtoi[vol[j+1]];
	  d[x1][x2]=d[x2][x1]=sqrt(sqr(vol[j].first-vol[j+1].first)+sqr(vol[j].second-vol[j+1].second));
	  for(int k=0;k<n;k++){
	    Line cl{vol[j],vol[j+1]};
	    if(sig[k]){
	      P on,open;
	      if(is_on(cl,l[k].first)){
		on=l[k].first;
		open=l[k].second;
	      }else if(is_on(cl,l[k].second)){
		on=l[k].second;
		open=l[k].first;
	      }else{
		continue;
	      }
	      P lv=vol[j+1]-vol[j];
	      P sv=open-on;
	      auto dot=lv.first*sv.first+lv.second*sv.second;
	      if(dot>=0){
		d[x1][x2]=INF;
	      }
	      if(dot<=0){
		d[x2][x1]=INF;
	      }
	    }
	  }
	}
      }
    }
    vector<vector<int> > next(v.size(),vector<int>(v.size()));
    for(int i=0;i<v.size();i++){
      for(int j=0;j<v.size();j++){
	next[i][j]=j;
      }
    }
    for(int i=0;i<v.size();i++){
      for(int j=0;j<v.size();j++){
	for(int k=0;k<v.size();k++){
	  auto c=d[j][i]+d[i][k];
	  if(c<d[j][k]){
	    next[j][k]=next[j][i];
	    d[j][k]=c;
	  }
	}
      }
    }
    int sidx=vtoi[P(xs,ys)];
    int gidx=vtoi[P(xg,yg)];
    if(d[sidx][gidx]>INF/2){
      cout<<-1<<endl;
    }else{
      for(int x=sidx;;){
	cout<<v[x].first<<' '<<v[x].second<<endl;
	if(x==gidx)break;
	x=next[x][gidx];
      }
      cout<<0<<endl;
    }
  }
}

    

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

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

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

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

    ll a, b;
    cin >> a >> b;

    ll g = gcd(a, b);

    map <ll, int> mp = prime_factor(g);

    cout << 1 + mp.size() << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        vl d(n);
        REP(i, n) cin >> d[i];
        ll sum = accumulate(ALL(d), 0ll);
        ll ans = 1ll << 60;
        ll s = 0;
        REP(i, n) {
            s += d[i];
            ans = min(ans, abs(sum - 2 * s));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

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

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());

	//cout << a << b << endl;
	if (a < b)  cout << "Yes" << endl;
	else  cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
total = []

for i in range(M):
    P, X = [int(j) for j in input().split()]
    tmp = T[:]

    tmp[P-1] = X
    total.append(sum(tmp))

for i in range(M):
    print(total[i])


Measured memory_bytes: 3060
a,b = map(int, input().split())
max = 0
arr = list(map(int, input().split()))
cumsum = [0] * (a + 1)
for i in range(a):
  cumsum[i+1] = cumsum[i] + arr[i]
for i in range(a - b + 1):
  sum = 0
  sum = cumsum[i + b] - cumsum[i]
  if sum > max:
    max = sum
print((max + b) / 2)

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

int main() {
  vector<int> vs(3);
  for(int i = 0; i < 3; ++i) {
    cin >> vs[i];
  }
  sort(vs.begin(), vs.end());
  cout << vs[0] + vs[1] << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> cnt(26,0);
    for(int i=0;i<n;++i){
        cnt[s[i]-'a']++;
    }
    bool flag = true;
    for(int i=0;i<26;++i){
        if(cnt[i]%2==1)flag = false;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n ; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n - 1);
    ll res = 0;
    ll pre = INF;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    rep(i, n){
        ll idx = a[i] - 1;
        if(pre == idx - 1) res += c[pre];
        res += b[idx];
        pre = idx;
    }
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	if(n%k != 0)
		printf("1\n");
	else
		printf("0\n");
	
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let n: u32 = read();
    let a: u32 = read();
    let b: u32 = read();

    let pa = n*a;
    let pb = b;

    if pa >= pb {
        println!("{}", pb);
    } else {
        println!("{}", pa);
    }
}



use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed toparse token")
}

Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const ll inf=1e18+10;
ll n,k,ans,a[200005];
ll find1(int now,ll x){
	int l=now+1,r=n,best=now;
	while(l<=r){
		int mid=l+r>>1;
		if(a[now]*a[mid]<=x){
			l=mid+1;
			best=mid;
		}
		else r=mid-1;
	}
	return best;
}
ll find2(int now,ll x){
	int l=now+1,r=n,best=n+1;
	while(l<=r){
		int mid=l+r>>1;
		if(a[now]*a[mid]<=x){
			r=mid-1;
			best=mid;
		}
		else l=mid+1;
	}
	return best;
}
bool check(ll x){
	ll cnt=0;   //找比 x 小的积 
	for(int i=1;i<n;i++){
		if(a[i]>=0) cnt+=find1(i,x)-i;
		else cnt+=n-find2(i,x)+1;
	}
	return cnt>=k;
}
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	ll l=-inf,r=inf;
	while(l<=r){
		ll mid=l+r>>1;
		if(check(mid)){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4760
# -*- coding: utf-8 -*-

S = list(input())
N = len(S)-1

ans = 0
# 間に+を入れるかどうかでビット全検索
for i in range(1 << N):
    offset = 0
    for j in range(N):
        if (i>>j) & 1 == 1:
            # 該当のビットが1なら+を挿入
            S.insert(j+1+offset, '+')
            # +を入れた分リストが長くなるので、次回の位置を調整
            offset += 1
            # リスト→文字列→式にして答えに足す
    ans += eval(''.join(S))
    # +を削除
    S = [j for j in S if j != '+']

print(ans)

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

int main () {
  string o,e;
  cin >> o >> e;

  int l = e.size();
  rep(i,l) {
    cout << o[i] << e[i];
  }
  if(l != o.size()) cout << o[l];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e18;
int main(){
	int H,W,K;cin>>H>>W>>K;
	char s[H][W];int color[H][W];
	int t=0;
	rep(i,0,H){
		bool flag=false;
		rep(j,0,W){
			cin>>s[i][j];
			if(s[i][j]=='#'){ t++; flag=true; }
			if(flag) color[i][j]=t;
			else color[i][j]=0;
		}
	}
	rep(i,0,H){
        if(color[i][W-1]==0) continue;
		for(int j=W-1;j>=0;j--){
			if(color[i][j]==0) color[i][j]=color[i][j+1];
		}
	}rep(j,0,W)rep(i,1,H){
        if(color[i][j]==0) color[i][j]=color[i-1][j];
    }rep(j,0,W)for(int i=H-2;i>=0;i--){
        if(color[i][j]==0) color[i][j]=color[i+1][j];
    }
    pprint(color,H,W);
}

Measured memory_bytes: 1152
#include <stdio.h>

using namespace std;
int main(void){
    // Your code here!
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d=static_cast<double>(a);
    b_d=static_cast<double>(b);
    printf("%d %d %.8f\n",a/b,a%b,a_d/b_d);
    return 0;
}


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

struct UnionFind{
    vector<int> data;
    int __size;
    UnionFind(int sz) {
    data.assign(sz, -1);
    __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
      return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int unum() {
    return (__size);
  }
};

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<P> edge;
  rep(i,m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    edge.push_back(make_pair(u, v));
  }
  int res = 0;
  for (int i = 0; i < m; i++) {
    UnionFind uf(n);
    for (int j = 0; j < m; j++) {
      if (i == j) continue;
      uf.unite(edge[j].first, edge[j].second);
    }
    if (uf.unum() != 1) res++; 
  }
  cout << res << endl;
  return 0;
} 

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

//public class Problem0002_DigitNumber {
public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String line;
			while((line = reader.readLine()) != null) {
				try {
					String[] data = line.split(" ");
					int[] numbers = new int[2];
					for(int i = 0; i < 2; i++) {
						numbers[i] = Integer.parseInt(data[i]);
					}
					int sum = numbers[0] + numbers[1];
					int result = 0;
					while(sum > 0) {
						sum = sum / 10;
						result++;
					}
					System.out.println(result);
				} catch(NumberFormatException e) {
					break;
				}
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 10000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <set>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int q, com;
	long x;
	std::set<long> s;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif
	
	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> com >> x;
#else
		std::cin >> com >> x;
#endif
		if(com == 0){
			s.insert(x);
			std::cout << s.size() << std::endl;
		}
		else{
			std::cout << s.count(x) << std::endl;
		}
	}
	return 0;
}


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

int main(){

  int N;

  cin >> N;

  int a[55556];
  a[0] = 2;
  int nind = 1,num = 3;

  int flag = 0,npri = 0;

  while (npri < N){

    flag = 1;

    for (int i = 0 ; i < nind ; i++){

      if (num % a[i] == 0){
	flag = 0;
	break;
      }

    }

    if (flag == 1){
      a[nind] = num;
      nind += 1;

      if (num % 5 == 1){
	cout << num << endl;
	npri += 1;
      }

    }

    num += 1;

  }
  
  return 0;

}


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

const int MOD = 1000000007;

int main() {
    ll n, k;
    cin >>n >>k;
    if (n>k)
        cout <<0 <<endl;
    else
        cout <<1 <<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans_m = INF;
int W[6] = {200, 300, 500, 1000, 1200, 1500};
int P[6] = {380, 550, 850, 1520, 1870, 2244}; 

void dfs (int k, int rest, int x) {
    if (rest == 0) {
        ans_m = min(ans_m, x);
        return;
    }
    if (k == 6 || rest < 0) {
        return;
    }
    for (int i = 0; i <= 25; i++) {
        if (rest - W[k] * i < 0) break;
        dfs(k + 1, rest - W[k] * i, x + P[k] * i);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int weight;
    cin >> weight;
    while (weight != 0) {
        ans_m = INF;
        dfs(0, weight, 0);
        cout << ans_m << endl;
        cin >> weight;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    string s,t;
    cin>>s>>t;
    int l=s.size();
    int ans=l;
    rep(i,l)if(s[i]==t[i])ans--;
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

P F(ll h,ll w){
    if(abs(h/2*w-((h-h/2)*w))<abs(w/2*h-((w-w/2)*h)))
    return P(h/2*w,((h-h/2)*w));
    return P(w/2*h,((w-w/2)*h));
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    ll ans=INF;
    chmin(ans,max({F(H-H/3,W).first,F(H-H/3,W).second,H/3*W})-min({F(H-H/3,W).first,F(H-H/3,W).second,H/3*W}));
    chmin(ans,max({F(H-H/3-1,W).first,F(H-H/3-1,W).second,(H/3+1)*W})-min({F(H-H/3-1,W).first,F(H-H/3-1,W).second,(H/3+1)*W}));
    chmin(ans,max({F(W-W/3,H).first,F(W-W/3,H).second,W/3*H})-min({F(W-W/3,H).first,F(W-W/3,H).second,W/3*H}));
    chmin(ans,max({F(W-W/3-1,H).first,F(W-W/3-1,H).second,(W/3+1)*H})-min({F(W-W/3-1,H).first,F(W-W/3-1,H).second,(W/3+1)*H}));
    prt(ans)

    return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiroqn on 13/10/12.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function dijkstra(g, s) {
  var d = [],
      use = [],
      i,
      n = g.length,
      v, u;
  for (u = 0; u < n; u++) {
    d[u] = Infinity;
    use[u] = false;
  }
  d[s] = 0;
  while (true) {
    v = -1;
    for (u = 0; u < n; u++) {
      if (!use[u] && (v === -1 || d[v] > d[u])) {
        v = u;
      }
    }
    if (v === -1) {
      break;
    }
    use[v] = true;
    for (u = 0; u < n; u++) {
      d[u] = d[u] < d[v] + g[v][u] ? d[u] : d[v] + g[v][u];
    }
  }
  return d;

}
function makeGraph(n) {
  var i, j, g;
  g = [];
  for (i = 0; i < n; i++) {
    g[i] = [];
    for (j = 0; j < n; j++) {
      g[i][j] = i === j ? 0 : Infinity;
    }
  }
  return g;
}

function main() {
  var temp,
      n, m, l, k, a, h,
      llist,
      i, j,
      edeges,
      g, g2,
      d,
      n1, n2;

  while (true) {
    temp = input.shift().split(' ');
    n = +temp[0];
    m = +temp[1];
    l = +temp[2];
    k = +temp[3];
    a = +temp[4];
    h = +temp[5];
    if (n === 0) {
      break;
    }
    if (l !== 0) {
      llist = input.shift().split(' ').map(Number);
    } else {
      input.shift();
      llist = [];
    }
    g = makeGraph(n);
    for (i = 0; i < k; i++) {
      edeges = input.shift().split(' ').map(Number);
      g[edeges[0]][edeges[1]] = g[edeges[1]][edeges[0]] = edeges[2];
    }
    g2 = makeGraph(n);
//    da = dijkstra(g, a);
    llist.push(a);
    llist.push(h);
    for (i = 0; i < l + 2; i++) {
      n1 = llist[i];
      d = dijkstra(g, n1);
      for (j = 0; j < l + 2; j++) {
        n2 = llist[j];
        if (d[n2] <= m) {
          g2[n1][n2] = g2[n2][n1] = d[n2]
        }
      }
    }
    d = dijkstra(g2, a);
    if (d[h] === Infinity) {
      console.log('Help!');
    } else {
      console.log(d[h] + Math.max(0, d[h] - m));
    }

//    console.log(d);
  }
}

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

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        x+=(d-1)/a+1;
    }
    cout<<x<<endl;
    return 0;
}

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

int main() {
    int N, A, B, maxA = 0, ans = 0;
    cin >> N;
    rep(i, N) {
        cin >> A >> B;
        if (A > maxA) {
            maxA = A;
            ans = A + B;
        }
    }
    cout << ans << endl;
}

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

int search(int first,int last,int k, std::vector<int> &S){
	if (first==last){
		if (S[first]==k){
			return 1;
		}else{
			return 0;
		}
	}else{
		int m;
		m=(first + last)/2;
		if(S[m]==k){
			return 1;
		}
		else if(S[m]>k){
			return search(first,m,k,S);
		}else{
			return search(m+1,last,k,S);
			}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int i,j,n,q;
	int count=0;
	
	cin >> n;
	vector<int> S(n);
	for (i=0;i<n;i++){
		cin >> S[i];
	}
	cin >> q;
	int T[q];
	for (i=0;i<q;i++){
		cin >> T[i];
	}
	
	for (j=0;j<q;j++){
		count+=search(0,n-1,T[j],S);
	}
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 1532
D = int(input())
C = [int(x) for x in input().split()]
S = [[int(i) for i in input().split()] for D in range(D)]

T = [0]*D
for i in range(D):
    T[i] = S[i].index(max(S[i]))+1
    print(T[i])

score = [0]*26
last = [-1]*26

for i in range(D):
    score[T[i]-1] += S[i][T[i]-1]
    last[T[i]-1] = i

    for j in range(26):
        score[j] -= C[j]*(i-last[j])


Measured memory_bytes: 68304
import qualified Data.ByteString.Char8 as B
import Data.List

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readInts :: B.ByteString -> [Int]
readInts = map readInt . B.words

main = do
  n <- readLn
  as <- readInts <$> B.getLine
  print (eater n as)

eater n = (\x -> if odd x then n-(x+1) else n-x) . sum . map (pred . length) . group . sort

Measured memory_bytes: 15740
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> P(N);
    rep(i, N) cin >> P[i];
    vector<double> value(N);
    rep(i, N) { value[i] = (P[i] * (P[i] + 1.0)) / P[i]; }
    rep(i, N) { value[i] /= 2.0; }

    vector<double> Psum(N + 1), valueSum(N + 1);
    rep(i, N) {
        Psum[i + 1] = Psum[i] + P[i];
        valueSum[i + 1] = valueSum[i] + value[i];
    }
    double res = 0;
    for(int i = 0; i + K <= N; i++) {
        res = max(res, (valueSum[i + K] - valueSum[i]));
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    for(int i = 0; i<N; i++){
    cin >> P[i]; 
    }
    int mini = P[0];
    int ans = 0;
    for(int i=0; i<N; i++){
        mini = min(mini,P[i]);
        if(mini == P[i]){
            ans += 1;
        }
    }
    cout << ans;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll n;
mat dp(410,vec(410,0));
vec a(410);

ll solve(ll l,ll r) {
  if(l==r) return 0;
  if(dp[l][r]!=0) return dp[l][r];
  ll res=inf;
  for(ll i=l;i<r;i++) {
    res=min(res,solve(l,i)+solve(i+1,r));
  }
  res+=a[r];
  if(l>0) res-=a[l-1];
  return dp[l][r]=res;
}

int main() {
  cin >> n;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    if(i) a[i]+=a[i-1];
  }
  cout << solve(0,n-1) << endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n;
               cin>>n;
               if(n%1000==0)
                    cout<<"0";
               else
                    cout<<1000-(n-1000*(n/1000));
       }
}


Measured memory_bytes: 3648
def solve(n, k, q, a)
  return 1 if n == 0
  return 0 if k == 0
  ret = 0
  t = [q, a].min
  t.downto(t/k) do |x|
    ret += solve(n - x * x, k - 1, Math.sqrt(n - x * x).to_i, x)
  end
  ret
end

while n = gets.to_i
  break if n == 0
  puts solve(n, 4, Math.sqrt(n).to_i, n)
end

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

int main() {
  string a;
  cin>>a;
  int p=a.size();
  int answer=99999;
  int s;
  
  for(int i=0;i<p-2;i++){
    s=(a.at(i)-'0')*100+(a.at(i+1)-'0')*10+(a.at(i+2)-'0')*1;
    answer=min(abs(753-s),answer);
  }
  
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
const long long MaxN = 1e18;
long long a[105];
long long Max = 0, ans = 1;
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		if (a[i] > Max) Max = a[i];
	}

	for (int i = 1; i <= n; i++){
		for (int j = 1;;j++){
			if (((j * Max) % a[i] )== 0){
				//	printf("%d\n",a[i]);
				Max = j * Max;
				break;
			}
		}
	}

	printf("%lld\n", Max);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[3];
int main(){
    cin>>s;
    if(strcmp(s,"AAA")==0 || strcmp(s,"BBB")==0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN (100010)
using namespace std;
int p[MAXN], y[MAXN];
vector<int> vec[MAXN];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> p[i] >> y[i];
        vec[p[i]].push_back(y[i]);
    }
    for (int j = 1; j <= n; ++j) {
        sort(vec[j].begin(), vec[j].end());
    }
    for (int k = 1; k <= m; ++k) {
        printf("%06d%06d\n", p[k], lower_bound(vec[p[k]].begin(), vec[p[k]].end(), y[k]) - vec[p[k]].begin() + 1);
    }
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int i = 0, j = 0;
        while (i < n && j < n) {
            if (s[i] == t[j]) {
                boolean ok = true;
                for (int k = 0; i + k < n; k++) {
                    if (s[i + k] != t[j + k]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }
            i++;
        }
        int ans = n + i;
        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: 21332
#include <iostream>
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    char str1[3],str2[3];
    for(int i=0;i<3;i++)
    {
        cin>>str1[i];
    }

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

    int Count=0;
    for(int i=0;i<3;i++)
    {
        if(str1[i]==str2[i])
        {
            Count++;
        }
    }
    cout<<Count<<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>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e6+5;
            const ll mod = 1e9+7;
            const ll inf = 1e18;
            ll   n  , k  , s , m  , l , r  , x  , w  , u , z , d  , q , a[N] , lp[N];

    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2) ;
        pt *= pt  ;
        if(n&1)
            pt *= a ;
        return pt;
    }


    int main()
    {
         IOS;
         int ts =1;
        /// cin >> ts ;
         while(ts--)
         {
            cin >> x >> k >> d;
            x = llabs(x);
            if( x/d >= k )
            {
                cout << llabs(x - k*d) << endl;
            }
            else
            {
                if(x  >= 0)
                {
                    ll val = x % d;
                    ll tot = (x - val) / d;
                    if( (k & 1) == (tot & 1))
                    {
                        cout << val << endl;
                    }
                    else
                    {
                        cout << abs(val - d) << endl;
                    }
                }
                else
                {

                    ll val = x % d;
                    ll tot = (x - val) / d;
                    if( (k & 1) == (tot & 1))
                    {
                        cout << val << endl;
                    }
                    else
                    {
                        cout << -val + d << endl;
                    }
                }
            }
         }
    }


Measured memory_bytes: 3664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AEntranceExamination solver = new AEntranceExamination();
        solver.solve(1, in, out);
        out.close();
    }

    static class AEntranceExamination {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.printf("%.10f", (double) a / b);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 22484
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    L_lsit = list(map(int, input().split()))

    L_lsit.sort()

    answer = 0
    for i in range(N):
        for j in range(i+1, N):
            if L_lsit[i] != L_lsit[j]:
                for k in range(j+1, N):
                    if (L_lsit[j] != L_lsit[k]) and (L_lsit[i] + L_lsit[j] > L_lsit[k]):
                        answer += 1
    print(answer)


if __name__ == "__main__":
    main()



Measured memory_bytes: 9196
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var t string
	var s = bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if s.Scan() {
		t = s.Text()
	}

	N, err := strconv.Atoi(t)
	if err != nil {
		return
	}

	H := map[int]int{}
	// j-i = Ai + Aj
	// Ai +i = j-Aj
	L := map[int]int{}
	R := map[int]int{}
	for i := 1; i <= N; i++ {
		if s.Scan() {
			t = s.Text()
		}

		d, err := strconv.Atoi(t)
		if err != nil {
			return
		}

		H[i] = d
		L[d+i]++
		R[i-d]++
	}

	count := 0
	// fmt.Println(L)
	// fmt.Println(R)
	for i := range L {
		if _, ok := R[i]; ok {
			count = count + L[i]*R[i]
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 31888
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define si(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define in(x) cin >> x
using pii = pair<int,int>;
using psi = pair<string,int>;
using pis = pair<int,string>;
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;


int main() {
 int N;
  in (N);
  vl a(N);
  rep(i,N) in(a[i]);
  int ans =0;
  rep(i,N){
   if(a[a[i]-1] == i+1) ans++ ;
    
  }
out(ans/2);	
}
  


Measured memory_bytes: 1024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    long n, m;
    scan(n, m);
    writeln((n * (n - 1)) / 2 + (m * (m - 1)) / 2);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
N = int(input())
A = input().split(" ")
ans =0
judge = True
while judge:
    temp = 0
    for i in range(len(A)):
        if int(A[i])%2 == 0:
            temp +=1
            A[i]=int(A[i])/2
    if temp == len(A):
        ans += 1
    else:
        judge=False
        
        print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int a[100005],dp[100005];
int main() {
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(int i=3; i<=n; i++) dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n];
}

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

using namespace std;

const int MAXN = 200005;

int n, a[MAXN];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
        scanf("%d", &a[i]);

    long long sumL = accumulate(a, a+n, 0LL);
    long long sumR = 0;
    long long ans = sumL;

    for(int i = 0; i < n; ++i) {
        sumL -= a[i];
        sumR += a[i];
        ans = min(ans, abs(sumL - sumR));
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a<b && b<c) {
            System.out.println("Yes");
            
        } else {
            System.out.println("No");
        }
    }
    
}




Measured memory_bytes: 26388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, W;
ll weight[110];
ll value[110];
ll dp[110][100010] = {0}; /////変数宣言はmain()の外側でしないとSegmentation faultが発生？

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];
    
    for (int i = 0; i < N; i++)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            if (sum_w >= weight[i]) dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-weight[i]] + value[i]);
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }       
    }
    cout << dp[N][W] << endl;
    
    return 0;
}

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

using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)


// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};



// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int min_cost = 0;

    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};


int main()
{
  Graph g;
  
  cin >> g.n;
  
  vector<pair<int,int>> p(g.n);
  vector<pair<int,int>> x(g.n),y(g.n);
  
  vector<pair<int,pair<int,int>>> v(0);
  
  for(int i=0;i<g.n;i++){
	  cin >> p[i].first >> p[i].second;
	  x[i].first = p[i].first;
	  x[i].second = i;
	  y[i].first = p[i].second;
	  y[i].second = i;
  }
  
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  
  
  for(int i=0;i<g.n-1;i++){
	  Edge e;
	  e.a = x[i].second;
	  e.b = x[i+1].second;
	  e.cost = abs(x[i].first - x[i+1].first);
	  g.es.push_back(e);
  }
  for(int i=0;i<g.n-1;i++){
	  Edge e;
	  e.a = y[i].second;
	  e.b = y[i+1].second;
	  e.cost = abs(y[i].first - y[i+1].first);
	  g.es.push_back(e);
  }
  
  
  
  cout << g.kruskal() << endl;
  return 0;
}

Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first 
#define se second
#define pi pair<ll,ll> 
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
bool checker(vector<int>v, int x){
   for(int i=0;i<int(v.size());i++){
   	  if(v[i]<x)return false;
   }
   return true;
}
int main(){ 
  #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m,x;
  cin>>n>>m>>x;
  ll cost[n];
  ll a[n][m];
  for(int i=0;i<n;i++){
       cin>>cost[i];
       for(int j=0;j<m;j++){
       	  cin>>a[i][j];
       }
  }
  ll res=1e9+7;
  for(int mask=0;mask<(1<<n);mask++){
    vector<int>v(m,0);
  	ll ans=0;
  	 for(int i=0;i<n;i++){
  	 	 if(mask & (1<<i)){
  	 	 	 ans+=cost[i];
  	 	 	for(int k=0;k<m;k++){
  	 	 		v[k]+=a[i][k];
  	 	 }
  	 	 if(checker(v,x)==true){
  	 	 	res=min(ans,res);
  	 	 }
  	 }
  }
 }
 if(res==1e9+7)res=-1;
 cout<<res<<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;	
	
}





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

int main() {
  string S;
  bool t=false;
  
  cin >> S;
  for (int i =0 ; i < S.size() ; ++i ){
    for (int j = i+1; j<S.size() ; ++j){
      if (S[i] == S[j]){
        t=true;
      }
    }
  }
  if (t) {
  cout << "no" << endl;}
  else {
   cout << "yes" << endl;
  }
  }



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

#ifdef AZN

#include "Azn.cpp"

#else
#define pln(...)
#endif

using namespace std;

typedef long long ll;
typedef double dd;

void solve(ll test_num) {
  (void) test_num;
  int N;
  cin >> N;
  vector<int> arr(N);
  for (int& a : arr) cin >> a;
  int xsum = 0;
  set<int> have;
  for (int a : arr) {
    xsum ^= a;
    have.insert(__builtin_ctz(a));
  }
  int res = 0;
  for (int bit = 30; bit >= 0; --bit) {
    if (xsum >> bit & 1) {
      if (!have.count(bit)) {
        cout << "-1\n";
        return;
      }
      ++res;
      xsum ^= (1 << bit) - 1;
    }
  }
  cout << res << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

Measured memory_bytes: 640
ls = input().split()
l = [int(s) for s in ls]
if l[0]>l[1]:
    l[0],l[1]=l[1],l[0]
if l[1]>l[2]:
    l[1],l[2]=l[2],l[1]
if l[0]>l[1]:
    l[0],l[1]=l[1],l[0]
print("%d %d %d"% (l[0],l[1],l[2]))


Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,X;
    cin >> A >> B >> X;
    
    if((A+B)<X){
        cout << "NO" <<endl;
    }else if (A > X){
        cout << "NO" <<endl;
        
    }else {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int n, x, y, dist;
    cin>>n>>x>>y;
    int ct[n];
    for(int i = 0; i < n; i++){
        ct[i] = 0;
    }
    for(int d = 1; d < n; d++)
    {
        for(int i = 1; i+d <= n; i++){
            int a = i, b = i+d;
            if((a <= x && b <= x) || (a >= y && b >= y)){
                dist = d;
            }
            else if(a <= x && b >= y){
                dist = x - a + b - y + 1;    
            }else if(a >= x & b <= y){
                int t1, t2;
                t1 = d;
                t2 = 1 + (a-x) + (y-b);
                dist = min(t1, t2);
            }else if(a <= x && b >= x && b <= y){
                int t1, t2;
                t1 = d;
                t2 = (x-a)+1+(y-b);
                dist = min(t1, t2);
            }else{
                int t1, t2;
                t1 = d;
                t2 = (b-y)+1+(a-x);
                dist = min(t1, t2);
            }
            ct[dist]++;
        }
    }
    for(int i = 1; i < n; i++){
        cout<<ct[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592