akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main(void){
	
	int N,i;
	double T,H[1000],A,aveT[1000];
	
	scanf("%d",&N);
	scanf("%lf%lf",&T,&A);
	for(i=0;i<N;i++){
		scanf("%lf",&H[i]);
	}
	
	for(i=0;i<N;i++){
		aveT[i]=T-H[i]*0.006;
	}
	
	int bangou=0;
	double sub=fabs(A-aveT[0]);
	
	for(i=1;i<N;i++){
		if(fabs(A-aveT[i])<sub){
			sub=fabs(A-aveT[i]);
			bangou=i;
		}
	}	
		
	printf("\n%d\n\n",bangou+1);	
	
	
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust" << endl;
  else puts("win");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  if(x>=1800){
    cout<<1<<endl;
  }
  else if(x>=1600){
    cout<<2<<endl;
  }
  else if(x>=1400){
    cout<<3<<endl;
  }
  else if(x>=1200){
    cout<<4<<endl;
  }
  else if(x>=1000){
    cout<<5<<endl;
  }
  else if(x>=800){
    cout<<6<<endl;
  }
  else if(x>=600){
    cout<<7<<endl;
  }
  else if(x>=400){
    cout<<8<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <vector>

int main() {
	int n;
	std::cin >> n;

	// 選ぶ２つの値 (x > y)
	int x = -1, y = -1;

	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];

	}

	auto itr = std::max_element(a.begin(), a.end());
	x = *itr;
	a.erase(itr);
	
	int minDiff = std::numeric_limits<int>::max();
	for(int i : a) {
		if(std::abs(x / 2 - i) < minDiff) {
			minDiff = std::abs(x / 2 - i);
			y = i;
		}
	}

	std::cout << x << " " << y << std::endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(abs(c - a) <= d)
    {
        printf("Yes");
        return 0;
    }
    if(abs(b - a) <= d)
        if(abs(c - b) <= d)
        {
            printf("Yes");
            return 0;
        }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

class ABC{
    static void Main(string[] args){
        string line = Console.ReadLine();
        var l = line.Split(' ').Select(x => int.Parse(x)).ToList<int>();
        //foreach(var i in l){ Console.WriteLine(i); }
        int minM = 1001;
        int totalM = 0;
        for(var i = 0; i < l[0]; i++){
            var m = int.Parse(Console.ReadLine());
            totalM += m;
            minM = m < minM ? m : minM;
        }
        Console.WriteLine((l[1]-totalM)/minM + l[0]);
    }
}

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

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

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

    int ans = 0;
    rep(i, s.size()) if (s[i] == 'p') ans--;
    ans += s.size() / 2;
    cout << ans << endl;
}

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

#define ls(u) ((u) << 1)
#define rs(u) ((u) << 1 | 1)
#define fa(u) ((u) >> 1)

typedef long long int64;

const int N = 1 << 18, MOD = 1e9 + 7;

int n, m, h, p[N + 5], pro[N + 5], iPro[N + 5], tag[N + 5];

inline void getLeaf(int u, std::vector<int> &vec) {
	int len = 32 - __builtin_clz(u);
	for (int i = 0; i < (1 << (h - len)); i++) {
		vec.emplace_back((u << (h - len)) + i);
	}
}
inline int solve(int u) {
	std::vector<int> l, r;
	getLeaf(ls(u), l);
	getLeaf(rs(u), r);
	for (auto v : l) {
		int w = (int64)pro[v] * iPro[fa(u)] % MOD;
		for (v = p[v]; v > 0; v = fa(v)) {
			w = (int64)w * v % MOD;
			tag[v] = (tag[v] + w) % MOD;
		}
	}
	int ans = 0;
	for (auto v : r) {
		int w = (int64)pro[v] * iPro[u] % MOD;
		for (v = p[v]; v > 1; v = fa(v)) {
			w = (int64)w * v % MOD;
			ans = (ans + (int64)tag[v ^ 1] * w % MOD * fa(v) % MOD) % MOD;
		}
	}
	for (auto v : l) {
		for (v = p[v]; v > 0; tag[v] = 0, v = fa(v));
	}
	return ans;
}
int main() {
	scanf("%d", &h);
	n = 1 << h, m = n >> 1;
	for (int i = m; i < n; i++) {
		scanf("%d", &p[i]);
		p[i] += m - 1;
	}
	pro[0] = iPro[0] = iPro[1] = 1;
	for (int i = 2; i < n; i++) {
		iPro[i] = (int64)(MOD - MOD / i) * iPro[MOD % i] % MOD;
	}
	for (int i = 1; i < n; i++) {
		pro[i] = (int64)pro[fa(i)] * i % MOD;
		iPro[i] = (int64)iPro[fa(i)] * iPro[i] % MOD;
	}
	int ans = 0;
	for (int i = 1; i < m; i++) {
		ans = (ans + solve(i)) % MOD;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){

    long long int a,b,c,k;
    cin >> a >> b >> c >> k;
    /*
    for(long long int i = 0;i<k;i++){
        long long int a_temp = a,b_temp = b,c_temp = c;
        a = b_temp + c_temp;
        b = a_temp + c_temp;
        c = a_temp + b_temp;
    }
    */
    long long int ans;
    if(k % 2 == 0) ans = a-b;
    else ans = b-a;
    
    if(ans >= 100000000000000000 || ans <= -100000000000000000) cout << "Unfair" << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

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

  int divmax = -1;
  int maxi = 0;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    int num = i;
    while (num % 2 == 0) {
      count++;
      num /= 2;
    }

    if (divmax < count) {
      divmax = count;
      maxi = i;
    }
  }
  cout << maxi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
ll mod = 1e9 + 7;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> kane(n);
    vector<vector<int>> a(n);
    int ans = 100100100;
    rep(i, n) a[i].resize(m);
    rep(i, n)
    {
        cin >> kane[i];
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }
    for (int bit = 0; bit < (1 << n); ++bit)
    {
        vector<int> S;
        for (int i = 0; i < n; ++i)
        {
            if (bit & (1 << i))
            {
                S.push_back(i);
            }
        }
        int ma = 0;
        bool ok;
        for (int j = 0; j < m; j++)
        {
            int kk = 0;
            ma = 0;
            ok = true;
            for (int i : S)
            {
                kk += a[i][j];
                ma += kane[i];
            }

            if (kk < x)
            {
                ok = false;
                break;
            }
        }

        if (ok)
        {
            if (ma < ans)
            {
                ans = ma;
            }
        }
    }
    if (ans == 100100100)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vc vector<char>
    #define vs vector<string>
    #define pb push_back
    #define stll stack<ll>
    #define qll queue<ll>
    #define pqll priority_queue<ll>
    #define mpii map<int,int>
    #define mpll map<ll,ll>
    #define mpss map<string,string>
    #define mpsi map<string,int>
    #define mpis map<int,string>
    #define mpsll map<string,ll>
    #define mplls map<ll,string>
    #define rev(v) reverse(v.begin(),v.end())
    #define srt(v) sort(v.begin(),v.end())
    #define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
    #define mem(a,x) memset(a,x,sizeof(a))
    #define inf 0x3f3f3f3f
    const int mxn=2e5+9;
    const int mod=1e9+7;
    int main ()
    {
        fast;
        ll a, b;
        cin>>a>>b;
        if(a == b)
        {
            cout<<a<<endl;
        }
        else if(a>b)
        {
            cout<<a-1<<endl;
        }
        else
        {
            cout<<a<<endl;
        }
        return 0;
    }


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

#define MOD 1000000007
#define INF (0x7fffffff)
#define NINF (1<<31)
#define INFL (0x7fffffffffffffff)
#define NINFL (1LL<<63)

#define pe(str) return cout<<(str)<<endl,0
#define px(str) cout<<(str)<<endl,exit(0)
#define accu(ac,v) cout<<setprecision(ac)<<v<<endl
#define bpc(a) __builtin_popcount(a)
#define pr(str) cout<<(str)<<endl
#define prpr(str) cout<<str<<endl
#define db(str) cerr<<"debug:"<<(str)<<endl
#define dbdb(str) cerr<<"debugs:"<<str<<endl
#define re(i,n) for(int i=0;i<(n);i++)
#define rre(i,n) for(int i=(n);i>=0;i--)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b);i>=(a);i--)
#define bw(a,b,c) (((a)<=(b))&&((b)<=(c)))
#define hello cout<<"hello"<<endl
#define spre(a) setprecision(a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define IF(C,T,F) ((C)?(T):(F))
#define max3(a,b,c) max((a),max((b),(c)))
#define min3(a,b,c) min((a),min((b),(c)))
#define max4(a,b,c,d) max((a),max((b),max((c),(d))))
#define min4(a,b,c,d) min((a),min((b),min((c),(d))))
#define enl cout<<endl
#define declare(t,n) t n;cin>>n
#define EPS 1e-6
#define EPSIN(a,b) ((b)-EPS<=(a)&&(a)<=(b)+EPS)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<int> point;

template<class InputIterator>
void dump(InputIterator first,InputIterator last,char delim=' '){
	for(InputIterator it=first;it!=last;it++){
		if(it!=first)cout<<delim;
		cout<<*it;
	}
}

ull p(ull x,ull y){
	if(y==0) return 1;
	ull A=p(x,y/2)%MOD;
	// return (y&1?((A*A)%MOD*x)%MOD: (A*A)%MOD);
	return (y&1?((A*A)*x):(A*A));
}

template<class T>
void swp(T &a,T &b){
	T t=a; a=b; b=t;
}

template<class T>
int h(T first,string t){
	T it=first;
	int c=0;
	for(int i=0;i<t.size();i++){
		if(*it!=t[i]) c++;
		it++;
	}
	return c;
}

int main(void){
	ull x,y,i,j;
	cin>>x>>y;
	for(i=x,j=0;i<=y;i*=2,j++);
	pe(j);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
using ll = long long;

int main(void) {
    string S, T;
    cin >> S >> T;

    int tlen = T.size();
    int slen = S.size();

    int maxMatchCount = 0;
    for (int i = 0; i <= (slen- tlen); i++)
    {
        int matchCount = 0;
        for (int j = 0; j < tlen; j++)
        {
            if(T[j] == S[i+j]) {
                matchCount++;
            }
        }
        maxMatchCount = max(matchCount, maxMatchCount);
    }

    int ans = tlen - maxMatchCount;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

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

  if(n % 2 == 1 || n == 0){
    print(0);
    return 0;
  }
  
  ll ans = 0;
  while(n){
    ans += n/10;
    n /= 5;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  int ans=(n+2-1)/2;
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<tuple<string,int,int>> dic;
    string S;
    int P;
    for ( int i = 0; i < N; ++i){
        cin >> S >> P;
        dic.push_back(make_tuple(S,-P,i+1));
    }
    
    sort(dic.begin(),dic.end());
    for ( auto a: dic){
        int x;
        tie (S,P,x) = a;
        cout << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int[] A = new int[5];
		
		for(int i=0; i<5; i++) {
			A[i] = keyboard.nextInt();
		}
		
		int ans =0;
		for(int j=0; j<5; j++) {
			if(A[j] == 0) {
				ans = j+1;
				break;
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 35848
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int m,d,ans=0;
	cin>>m>>d;
	for(int i=1;i<=m;i++)
	for(int j=20;j<=d;j++)
		if(j%10>=2 && j/10>=2 && (j%10)*(j/10)==i) ans++;
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	static String[] field = new String[3];
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		label:while(true){
			field = new String[3];
			field[0]=cin.next();
			if(field[0].equals("0")){
				break;
			}
			field[1]=cin.next();
			field[2]=cin.next();
			for(int i = 0;i<3;i++){
				if(field[i].charAt(0)==field[i].charAt(1)
						&& field[i].charAt(2)==field[i].charAt(1)){
					if(field[i].charAt(0)!='+'){
						System.out.println(field[i].charAt(0));
						continue label;
					}
				}
				else if(field[0].charAt(i)==field[1].charAt(i)
						&& field[2].charAt(i)==field[1].charAt(i)){
					if(field[0].charAt(i)!='+'){
					System.out.println(field[0].charAt(i));
					continue label;
					}
				}
			}
			
			if(field[0].charAt(0)==field[1].charAt(1)
					&& field[1].charAt(1)==field[2].charAt(2)){
				if(field[0].charAt(0)!='+'){
				System.out.println(field[0].charAt(0));
				continue label;
				}
			}
			else if(field[0].charAt(2)==field[1].charAt(1)
					&& field[1].charAt(1)==field[2].charAt(0)){
				if(field[0].charAt(2)!='+'){
				System.out.println(field[0].charAt(2));
				continue label;
				}
			}
			System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int main(void){
  int a,b,r,d;
  double f;

  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = (double) a / b;
  printf("%d %d %f\n", d, r, f);
  return(0);
}

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

bool isVisited[101];

int dfs(const vector<vector<int>>& r, int pos) {
    if (isVisited[pos]) {
        return 0;
    }

    isVisited[pos] = true;
    int ret = 0;
    for (int i = 0; i < r[pos].size(); i++) {
        ret = max(ret, dfs(r, r[pos][i]));
    }
    isVisited[pos] = false;

    return ret+1;
}

int main(void) {
    for (int i = 0; i <= 100; i++) {
        isVisited[i] = false;
    }

    int n;
    while (cin >> n, n) {
        vector<vector<int>> rings(101);
        int a, b;
        for (int i = 0; i < n; i++) {
            cin >> a >> b;
            rings[a].push_back(b);
            rings[b].push_back(a);
        }

        int ans = 0;
        for (int i = 1; i <= 100; i++) {
            ans = max(ans, dfs(rings, i));
        }
        cout << ans << endl;
    }

    return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	if(n<=k){
		cout << n*x << "\n";
	}else{
		cout << k*x+(n-k)*y << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
//  LINK ZADATKA: http://arc082.contest.atcoder.jp/tasks/arc082_a

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;


#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9
const int maxn = 101000;

int n, p[maxn], br[maxn];
int main(){
	
	
	scanf("%d", &n);
	
	REP(i, n){
		scanf("%d", &p[i]);
		if(p[i] == 0){
			br[p[i]]++; br[p[i]+1]++;
		} else if(p[i] == 100000){
			br[p[i]]++; br[p[i]-1]++;
		} else{
			br[p[i]]++; br[p[i]-1]++; br[p[i]+1]++;
		}
	}
	
	sort(br, br+maxn);
	
	printf("%d\n", br[maxn-1]);
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1024
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


# print(make_divisors(N))
d = make_divisors(N)

ans = 10 ** 18

for i in d:
    p = N // i
    keta = max(len(str(i)), len(str(p)))
    ans = min(ans, keta)

print(ans)


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


template< typename flow_t >
struct Dinic {
  const flow_t INF;

  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

  void add_edge(int from, int to, flow_t cap) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty() && min_cost[t] == -1) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      flow_t f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};


signed main(){
    int h, w;
    cin >> h >> w;
    int sx, sy, ex, ey;
    vector<bitset<100>> bs(h);
    for(int i = 0; i < h; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < w; ++j){
            if(s[j] == 'S')
                sx = i, sy = j;
            if(s[j] == 'T')
                ex = i, ey = j;
            bs[i].set(j, s[j] == 'o');
        }
    }
    Dinic<i64> f(h + w + 2);
    f.add_edge(h + w, sx, MOD);
    f.add_edge(ex, h + w + 1, MOD);
    f.add_edge(h + w, h + sy, MOD);
    f.add_edge(h + ey, h + w + 1, MOD);
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(bs[i][j]){
                f.add_edge(i, h + j, 1);
                f.add_edge(h + j, i, 1);
            }
        }
    }
    auto ans = f.max_flow(h + w, h + w + 1);
    if(ans >= MOD)
        cout << -1 << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 1536
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C = I()
l = [i() for _ in range(N)]
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

struct edge
{
	lli to,cost;
};

vector<edge> g[100100];
lli dist[100100];

void dfs1(lli now,lli from)
{
	for(edge& e:g[now]){
		if(e.to == from)continue;
		dfs1(e.to,now);
		dist[now] = max(dist[now],dist[e.to]+e.cost);
	}
}

lli dfs2(lli now,lli d_from,lli from){
	vector<pair<lli,lli>>d_child;
	d_child.emplace_back(0,-1);

	for(auto &e:g[now]){
		if(e.to == from)d_child.emplace_back(d_from+e.cost,e.to);
		else d_child.emplace_back(e.cost+dist[e.to],e.to);
	}

	sort(d_child.rbegin(),d_child.rend());
	lli ret = d_child[0].first+d_child[1].first;
	for(auto &e:g[now]){
		if(e.to==from)continue;
		ret = max(ret,dfs2(e.to,d_child[d_child[0].second==e.to].first,now));
	}
	return ret;
}

signed main(){

	lli n;
	cin>>n;
	REP(i,0,n-1){
		lli a,b,w;
		cin>>a>>b>>w;
		g[a].push_back({b,w});
		g[b].push_back({a,w});
	}

	dfs1(0,-1);
	cout<<dfs2(0,0,-1)<<endl;

	return 0;
}


Measured memory_bytes: 32784
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    //S[i]:a_1からa_iまでの和
    ll S[200010];
    S[0]=0;
    ll a;
    for(int i=1;i<=N;i++){
        cin>>a;
        S[i]=S[i-1]+a;
    }
    ll x,y,ans=pow(10,18);
    for(int i=1;i<=N-1;i++){
        x=S[i];y=S[N]-x;
        ans=min(ans,abs(x-y));
    }
    cout<<ans<<endl;
    return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


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

    ll c = b / x;
    ll d = a / x;
    if (a % x == 0) d--;

    cout << c - d << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 200007
#define MOD 1000000007
#define MODL 1000000007LL
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

// Trace dinâmico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

// Debugador de recursão
int recNum = 0;
void prTabs() { for (int ii = 0; ii < recNum; ++ii) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}

int MD(int x) {
	if(x < 0) return x+MOD;
	if(x >= MOD) return x-MOD;
	return x;
}

ll MDL(ll x) {
	return (x%MODL+MODL)%MODL;
}

ll modpow(ll a, ll b, ll m) {
	if (!b) return 1LL;
	if (b&1LL) return a*modpow(a, b-1, m)%m;
	ll r = modpow(a, b>>1, m);
	return r*r%m;
}

//m prime
ll invmod(ll a , ll m) {
	return modpow(a, m-2, m);
}

int li[MAX];
deque<int> pos1;
deque<int> pos0;
int n, t, a, b, c;
int main(){
	sc("%d\n", &n);
	for(int i = 0; i < n; i++) {
		if (getchar() == 'W') {
			li[i] = 0;
			pos0.pb(i);
		} else {
			li[i] = 1;
			pos1.pb(i);
		}
	}
	int r = 0;
	while(!pos1.empty() && !pos0.empty() && pos0.front() < pos1.back()) {
		r++;
		pos0.pop_front();
		pos1.pop_back();
	}
	pr("%d\n", r);
 	return 0;
}


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

#define rep(i,n) for(i=0; i<n; i++)
#define repl(i,n) for(i=1; i<=n; i++)

#define sz(x) (int) x.size()
#define pb push_back
#define all(x) x.begin(),x.end()
#define uu first
#define vv second
#define mem(x, y) memset(x, y, sizeof(x))
#define un(x) x.erase(unique(all(x)), x.end())

#define sdi(x) scanf("%d", &x)
#define sdii(x, y) scanf("%d %d", &x, &y)
#define sdiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sdl(x) scanf("%lld", &x)
#define sdll(x, y) scanf("%lld %lld", &x, &y)
#define sdlll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define sds(x) scanf("%s", x)
#define pfi(x) printf("%d\n", x)
#define pfii(x, y) printf("%d %d\n", x, y)
#define pfiii(x, y, z) printf("%d %d %d\n", x, y, z)
#define pfl(x) printf("%lld\n", x)
#define pfll(x, y) printf("%lld %lld\n", x, y)
#define pflll(x, y, z) printf("%lld %lld %lld\n", x, y, z)

#define eps 1e-9
#define OK cerr << "ok\n"
#define DB(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;

inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int kx[] = {+2, +1, -1, -2, -2, -1, +1, +2};
//int ky[] = {+1, +2, +2, +1, -1, -2, -2, -1}; //Knight Direction
//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction


const LL MAX = 400005;
LL n, k, arr[MAX];

int main() {
//    assert(freopen("in.txt","r",stdin));
//    assert(freopen("out.txt","w",stdout));

    LL i, cnt, sum=0;

    sdl(n);
    k = n*3;
    rep(i, k) sdl(arr[i]);
    sort(arr, arr+k);
    reverse(arr, arr+k);

    for(i=1, cnt=0; cnt<n; i+=2, cnt++) {
        sum += arr[i];
    }
    pfl(sum);

    return 0;
}


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

int main() {
    int N,K; cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    int ans=0;
    for(int i=0; i<K; i++){
        ans=ans+p.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
int main()
{
	int H,N;
  	int a;
  scanf("%d %d",&H,&N);
  for(int i=0;i<N;i++){
    scanf("%d",&a);
    H-=a;
  }
  printf("%s",(H>0)?"No":"Yes");
}

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

using namespace std;

int main(){
    long N;
    string S;
    cin>>N>>S;
    int ans = 0;
    for(int i=0; i<N; ++i){
        if(S.substr(i, 3) == "ABC"){
            ans++;
        }
    }

    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();

        boolean isAns = s.matches(String.format("[0-9]{%d}-[0-9]{%d}", a, b));

        System.out.println(isAns ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
 
int main(void){
    int n,ans=0;
    scanf("%d",&n);
    int a;
    for (int i=0; i<n; i++){
        scanf("%d",&a);
        ans+=a-1;
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int N;
    int counter = 0;
    int A[100];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < N; i++) {
        int min_j = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[min_j]) {
                min_j = j;
            }
        }
        if (A[i] != A[min_j]) {
            int temp = A[i];
            A[i] = A[min_j];
            A[min_j] = temp;
            counter++;
        }
    }

    for (int i = 0; i < N-1; i++) {
        cout << A[i] << " ";
    }
    cout << A[N-1] << endl;
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;

	cin >> N;

	long long X = N;

	long long count = 0;

	if(N % 2 == 1) {
		cout << 0 << endl;
	} else {
		long long c = 10;
		while(X >= c) {
			count += X / c;
			c *= 5;
		}

		cout << count << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
lli calc(lli a)
{
    lli ans = 0;
    while (a) {
        ans += a % 10;
        a /= 10;
    }
    return ans;
}
int main()
{
    lli n;
    cin >> n;
    lli ans = calc(1) + calc(n - 1);
    for (int i = 1; i < n; i++) {
        ans = min(ans, calc(i) + calc(n - i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct Segtree{
    int siz=1;
    vector<int>dat,laz;
    vector<bool>lazf;
    Segtree(int n){
        while(siz<n)siz*=2;
        dat.resize(siz*2-1,0);
        laz.resize(siz*2-1,0);
        lazf.resize(siz*2-1,false);
    }
    void eval(int k,int l,int r){
        if(lazf[k]){
            dat[k]=laz[k]*(r-l);
            if(r-l>1){
                laz[2*k+1]=laz[k];
                laz[2*k+2]=laz[k];
                lazf[2*k+1]=true;
                lazf[2*k+2]=true;
            }
            lazf[k]=false;
        }
    }
    void update(int a,int b,int x,int k=0,int l=0,int r=-1){
        if(r==-1)r=siz;
        eval(k,l,r);
        if(b<=l||r<=a)return;
        if(a<=l&&r<=b){
            laz[k]=x;
            lazf[k]=true;
            eval(k,l,r);
            return;
        }
        update(a,b,x,2*k+1,l,(l+r)/2);
        update(a,b,x,2*k+2,(l+r)/2,r);
        dat[k]=dat[2*k+1]+dat[2*k+2];
    }
    int query(int a,int b,int k=0,int l=0,int r=-1){
        if(r==-1)r=siz;
        if(b<=l||r<=a)return 0;
        eval(k,l,r);
        if(a<=l&&r<=b)return dat[k];
        int vl=query(a,b,2*k+1,l,(l+r)/2);
        int vr=query(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,q;
    cin>>n>>q;
    Segtree seg(n);
    while(q--){
        int type;
        cin>>type;
        if(type==0){
            int s,t,x;
            cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }
        else{
            int s,t;
            cin>>s>>t;
            cout<<seg.query(s,t+1)<<endl;
        }
    }
    return 0;
}


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

#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 repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    cout << (a*b % 2 == 0 ? "Even":"Odd") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(D, G);
  G /= 100;
  vector<int> p(D), c(D);
  FOR(i, D) {
    GI2(x, y);
    p[i] = x;
    c[i] = y / 100;
  }
  vector<pair<int, vector<int>>> dp(
      G + 1, pair<int, vector<int>>(1 << 28, vector<int>(D)));
  dp[0] = pair<int, vector<int>>(0, vector<int>(D));
  FOR(i, G) {
    pair<int, vector<int>> x = dp[i];
    if (x.first == 1 << 28)
      continue;
    FOR(d, D) {
      if (x.second[d] < p[d] - 1) {
        pair<int, vector<int>> nw = x;
        nw.first++;
        nw.second[d]++;
        if (dp[min(G, i + d + 1)].first > nw.first) {
          dp[min(G, i + d + 1)] = nw;
        }
      }
      if (x.second[d] < p[d]) {
        pair<int, vector<int>> nw = x;
        nw.first = x.first + p[d] - x.second[d];
        nw.second[d] = p[d];
        if (dp[min(G, i + (d + 1) * (p[d] - x.second[d]) + c[d])].first >
            nw.first) {
          dp[min(G, i + (d + 1) * (p[d] - x.second[d]) + c[d])] = nw;
        }
      }
    }
  }
  print(dp[G].first);
  return 0;
}

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

int main() {
	int N, A, B;
	cin >> N;
	if (N == 1) cout << "Hello World";
	else {
		cin >> A >> B;
		cout << A + B;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	long long H, ans=0;
	cin>>H;
	for(long long i=1;H;i<<=1,H>>=1) ans+=i;
	cout<<ans<<'\n';
	return 0;
}

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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1);

	repn(i, N) cin >> A[i];

	ll ans = INF;

	repn(i, N) {
		ll v = 0;
		while (A[i] % 2 == 0) {
			v++;
			A[i] /= 2;
		}

		ans = min(ans, v);
	}

	cout << ans;

	system("PAUSE");

	

}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, K, Q;
    cin >> N >> K >> Q;
    ll a[N];
    for(ll i = 0; i < N; i++) cin >> a[i];
    if(Q == 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1145148931919180;
    for(ll i = 0; i < N; i++){
        vector<ll> b;
        for(ll j = 0; j < N; j++) if(i != j) b.push_back(a[j]);
        vector<ll> v;
        v.push_back(-1);
        for(ll j = 0; j < N - 1; j++) if(b[j] < a[i]) v.push_back(j);
        v.push_back(N - 1);
        vector<ll> u;
        for(ll j = 0; j < v.size() - 1; j++){
            vector<ll> tmp;
            for(ll k = v[j] + 1; k < v[j + 1]; k++) tmp.push_back(b[k]);
            sort(tmp.begin(), tmp.end());
            for(ll k = 0; tmp.size() - k >= K; k++) u.push_back(tmp[k]);
        }
        if(u.size() < Q - 1) continue;
        sort(u.begin(), u.end());
        ans = min(ans, u[Q - 2] - a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m, x;
    cin>>n>>m>>x;
    vvl cs(n, vl(m + 1));
    cin>>cs;
    ll ans = LINF;
    rep(i, 1<<n) {
        vl tot(m);
        ll temp = 0;
        rep(j, n) {
            if (i>>j&1) {
                temp += cs[j][0];
                rep(k, m) {
                    tot[k] += cs[j][k + 1];
                }
            }
        }
        bool f = true;
        rep(j, m) {
            if (tot[j] < x) f = false;
        }
        if (f) chmin(ans, temp);
    }
    if (ans == LINF) {
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3664
N,M=map(int,input().split())
def steps(N,M):
	a=[]
	b=[1,1]
	for j in range(N):
		b.append(b[-1]+b[-2])
	if M==0:
		return print(b[N]%1000000007)
	else:
		for i in range(M):
			a.append(int(input()))
		for i in range(M-1):
			if a[i+1]-a[i]==1:
				return print(0)
		ans=1
		a.append(N+1)
		a.insert(0,-1)
		for i in range(M+1):
				c=a[i+1]-a[i]-2
				ans*=(b[c])
		return print(ans%1000000007)
steps(N,M)

Measured memory_bytes: 464100
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	while (true) {
		cin >> s;
		if (s == "#")break;
		bool right = 0, left = 0;
		int cnt=0;
		for (int i = 0; i < s.size(); i++) {
			switch (s[i]) {
			case 'q':
			case 'w':
			case 'e':
			case 'r':
			case 't':
			case 'a':
			case 's':
			case 'd':
			case 'f':
			case 'g':
			case 'z':
			case 'x':
			case 'c':
			case 'v':
			case 'b':if (right) { right = false; left = true; cnt++; break; }if (!left && !right) { left = true; break; }break;
			case 'y':
			case 'u':
			case 'i':
			case 'o':
			case 'p':
			case 'h':
			case 'j':
			case 'k':
			case 'l':
			case 'n':
			case 'm':if (left) { left = false; right = true; cnt++; break; }if (!left && !right) { right = true; break; }break;
			default:break;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
map<long long,long long> m1;
long long res;
long long pref[200010];
std::map<long long, long long>::const_reverse_iterator test(std::map<long long, long long> &threshold, const long long value) {
  std::map<long long, long long>::const_reverse_iterator
    last_element_not_greater_than(threshold.upper_bound(value));

  return last_element_not_greater_than;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    long long curr = 0;
    pref[0] = 1;
    m1[0] = 1;
    for(long long i=1;i<=s.length();i++){
        pref[i] = pref[i-1]*10;
        pref[i]%=2019;
    }
    reverse(s.begin(),s.end());
    for(long long i=0;i<s.length();i++){
        long long dig = s[i] - '0';
        long long mult = pref[i];
        dig*=mult;
        dig%=2019;
        curr+=dig;
        curr%=2019;
      //  cout<<curr<<endl;
        res += m1[curr];
        m1[curr]++;
    }
    
    cout<<res<<endl;
}

Measured memory_bytes: 5296
#include <cstdio>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  int sum = 0;
  int max = 0;
  for (int i = 0; i < N; ++i) {
    int p;
    scanf("%d", &p);
    sum += p;
    max = std::max(max, p);
  }
  printf("%d\n", sum-max/2);
}

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int tt = c / b;
    if(c % b > 0) ++tt;

    int ta = a / d;
    if(a % d > 0) ++ta;

    if(tt <= ta)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int G[102][102];
int main(){
	int n;
	scanf("%d",&n); 
	for(int i=1;i<=n;i++){
		int k,v1,v2;scanf("%d%d",&v1,&k);
		for(int j=1;j<=k;j++){
			scanf("%d",&v2);G[v1][v2]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j!=n)
			printf("%d ",G[i][j]);
			else printf("%d",G[i][j]);
		}printf("\n");
	}
	return 0;
} 


Measured memory_bytes: 3236
open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let n_bonacci nn n =
    let rec fib_aux n res prevs =
      if n <= 0 then (prevs, 0) else
      if n = 1 then (prevs, res)
      else 
        let tl = List.tl prevs in
        let sum = List.fold_left (+) 0 prevs in
        fib_aux (n-1) (res+sum) (tl @ [res])
    in
    let n = n-nn+1 in
    fib_aux n 1 [2]
  in
  let lucas = n_bonacci 1 in
  let _, ans = lucas n in

  Printf.printf "%d\n" ans


Measured memory_bytes: 3072