akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	cout << n/3 << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {

    char s[12];
    char s1[6];
    char s2[6];
    
    fgets(s, 12, stdin);
    
    sscanf(s, "%s %s", s1, s2);
    
    int a=  atoi(s1);
    int b = atoi(s2);
    
    if(a % 2 == 1 && b%2==1){
        printf("Odd");
    }else{
        printf("Even");
    }

    return 0;

}


Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m = 60;
    let mut cnt = vec![0usize; m];
    for s in it {
        let a: usize = s.parse().unwrap();
        for k in 0..m {
            cnt[k] += (a >> k) & 1;
        }
    }
    const MOD: usize = 1_000_000_007;
    let mut ans = 0;
    for k in 0..m {
        let v = (1usize << k) % MOD;
        ans += v * cnt[k] % MOD * (n - cnt[k]) % MOD;
    }
    ans %= MOD;
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 13560
N = int(input())
W = list(map(int,input().split()))
xmin = 10000

for i in range(N):
    S1=sum(W[:i+1])
    S2=sum(W[i+1:])
    x = abs(S1-S2)
    if x < xmin:
        xmin = x
print(xmin)

Measured memory_bytes: 3060
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
const int MAXN = 100010;
using namespace std;

int N, F[MAXN], T[MAXN];
vector<int> G[MAXN];

void dfs(int u) {
	int i, v;
	for(i = 0; i < G[u].size(); i++) dfs(G[u][i]);

	int Tn = 0;
	for(i = 0; i < G[u].size(); i++) T[++Tn] = F[G[u][i]];
	sort(T + 1, T + Tn + 1);

	for(i = 1; i <= Tn; i++) F[u] = max(F[u], i + T[Tn - i + 1]);
}

int main() {
	int i, u;
	scanf("%d", &N);
	for(i = 2; i <= N; i++) {
		scanf("%d", &u), G[u].push_back(i);
	}
	dfs(1);
	printf("%d", F[1]);
	return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>

int main(void)
{
	unsigned long long int cnt=1;
	unsigned short i, n;

	scanf("%lld", &n);
	getchar();
	for(i=2; i<=n; i++){
		cnt *= i;
	}

	printf("%lld\n", cnt);
	getchar();
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int a(int A, int B) {
  if(A > 9) {
    return -1;
  }

  if(B > 9) {
    return - 1;
  }

  return A * B;
}

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

  cout << a(A, B);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
#include<set>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

int main(void)
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  sort(h.begin(), h.end());
  ll result = 0;
  rep(i,n-k) result += h[i];

  cout << result << endl;
}


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

int main() {
  int n,m,x;
  cin >> n >> m >> x;

  int c[n];
  int a[n][m];

  rep(i,n){
      cin >> c[i];
      rep(j,m){
          cin >> a[i][j];
      }
  }

  int ans = INT_MAX;

  rep(s,1<<n){
      int cost =0;
      vector<int> d(m);
      rep(i,n){
          if(s>>i & 1){
            cost += c[i];
            rep(j,m) d[j] += a[i][j];
          }
      }
      bool ok = true;
      rep(j,m) if(d[j]<x) ok = false;
      if(ok) ans = min(ans,cost);
  }
  if(ans==INT_MAX) cout << -1 << endl;
  else cout << ans << endl;

  
  
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
inline int read(){
	int ret=0,p=1;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') p=-1;
	for (;isdigit(ch);ch=getchar()) ret=ret*10+ch-'0';
	return ret*p;
}
int n,m;
int a[100000+3];
int N;
LL s[100000+3],S[10000],t[10000];
inline int X(int x){return (x-1)/N+1;}
void add(int l,int r,LL p){
	for (;l<=r && (l-1)%N!=0;l++){
		s[l]+=p;p++;
	}
	for (;l<=r && l+N-1<=r;l+=N){
		S[X(l)]+=p;t[X(l)]++;
		p+=N;
	}
	for (;l<=r;l++){
		s[l]+=p;p++;
	}
}
int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	LL ans=0;
	N=sqrt(m);
	for (int i=2;i<=n;i++){
		if (a[i]>a[i-1]){
			ans=ans+a[i]-a[i-1];
			add(a[i-1]+1,a[i],0);
		}
		if (a[i]<a[i-1]){
			ans=ans+m-a[i-1]+a[i];
			add(a[i-1]+1,m,0);
			add(1,a[i],m-a[i-1]);
		}
	}
	for (int i=1;i<=m;i++){
		s[i]+=S[X(i)];
		S[X(i)]+=t[X(i)];
	}
	LL mx=0;
	for (int i=1;i<=m;i++) if (mx<s[i]) mx=s[i];
	ans-=mx;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#define PI 3.14159265359

using namespace std;

int main(){
int a,b;
char op;

while(1){
cin>>a>>op>>b;
if(op=='+')cout<<a+b<<endl;
else if(op=='-')cout<<a-b<<endl;
else if(op=='*')cout<<a*b<<endl;
else if(op=='/')cout<<a/b<<endl;
else break;
}

}




Measured memory_bytes: 3088
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<i64>();
    let b = input::<i64>();
    println!("{}", if a <= b { a } else { a - 1 });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;
struct gragh{
	int V,E;
	vector<vector<pair<int,int>>> edge; //edge[from][i] ={to,cost}
	//only for 0-indexed 
	gragh(int v,int e,int *from,int *to,int *cost){
		V=v;E=e;	pair<int,int>p;
		for(int i=0;i<e;i++){
			//if(edge.size()<=from[i])edge.resize(from[i]+1);
			edge.resize(v);
			p.first=to[i];	p.second=cost[i];	edge[from[i]].push_back(p);
		} }
	int dijkstra(int start,int goal){
		int done[V];	for(int i=0;i<V;i++)done[i]=0;	done[start]=1;
		int vertex[V];	for(int i=0;i<V;i++)vertex[i]=inf;	vertex[start]=0;
		queue<int> que;	que.push(start);
		int from, to, cost;
		while(que.size()!=0){
			from=que.front();
			for(int i=0; i<edge[from].size(); i++){
				to=edge[from][i].first;	cost=edge[from][i].second;
				if( vertex[to]>vertex[from]+cost){
					vertex[to]=vertex[from]+cost;
					que.push(to);
				}
			}
			que.pop();
		}
		return vertex[goal];	}
	};
	
	
int main(){
	int n;cin>>n;
	int a[n];for(int i=0;i<n;i++){cin>>a[i]; a[i]--;} 
	int b[n];for(int i=0;i<n;i++)b[i]=i;
	int c[n];for(int i=0;i<n;i++)c[i]=1;

	gragh g(n,n,b,a,c);
	if(g.dijkstra(0,1)==inf)cout<<-1<<endl;
	else cout<<g.dijkstra(0,1);
}

Measured memory_bytes: 7680
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int n_query = 0;

int ask(int y1, int x1, int y2, int x2)
{
	++n_query;
	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
	fflush(stdout);
	int a;
	scanf("%d", &a);
	return a;
}

int score(int q)
{
	if (q > 2500) return 0;
	if (q >= 930) return max((int)(1e-8 + 125 - 3.2 * sqrt(q - 920)), 40);
	if (q >= 880) return (int)(1e-8 + 288 - 22 * sqrt(q - 870));
	return min(2860 - 3 * q, 300);
}

int H, W, N, K;
int C[50][50];

void solve(int y1, int x1, int y2, int x2, int cnt)
{
	if (y2 - y1 == 1 && x2 - x1 == 1) {
		C[y1][x1] = cnt;
		return;
	}
	if (cnt == 0) return;
	if ((y2 - y1) * (x2 - x1) == cnt) {
		for (int i = y1; i < y2; ++i) {
			for (int j = x1; j < x2; ++j) {
				C[i][j] = 1;
			}
		}
		return;
	}

	if (x2 - x1 == 1) {
		int ym = (y2 + y1) / 2;
		int a = ask(y1, x1, ym, x2);
		solve(y1, x1, ym, x2, a);
		solve(ym, x1, y2, x2, cnt - a);
	} else {
		int xm = (x2 + x1) / 2;
		int a = ask(y1, x1, y2, xm);
		solve(y1, x1, y2, xm, a);
		solve(y1, xm, y2, x2, cnt - a);
	}
}

int main()
{
	scanf("%d%d%d%d", &H, &W, &N, &K);
	solve(0, 0, H, W, N);

	int ret = 0;
	int pw = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret += C[i][j] * pw;
			ret %= K;
			pw = pw * 2 % K;
		}
	}
	int aa = ask(15, 15, 35, 45);
	while (score(n_query) > aa) {
		ask(0, 0, 1, 1);
	}

	printf("! %d\n", ret);
	return 0;
}


Measured memory_bytes: 596
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin >> n >> k;ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];a[i]--;
    }
    ll b[n];
    bool vis[n];memset(vis,0,sizeof(vis));
    ll d=0;ll cnt=1;
    while(!vis[d] and k)
    {
        b[d]=cnt;cnt++;vis[d]=1;d=a[d];k--;
    }
    //trace(d);
    if(k==0)cout << d+1;
    else
    {

        ll g=cnt-b[d];
        k%=g;
        while(k--)d=a[d];
        cout << d+1;
    }
    }

Measured memory_bytes: 6968
#include <iostream>

using namespace std;

int main(){
    string stations;
    cin >> stations;
    bool bRet=false;

    for(int i=0;i<2;i++){
        if(stations[i]!=stations[i+1]){
            bRet = true;
            break;
        }
    }

    if(bRet){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

int n,k,x[110000],y[110000],t[2100][2100];

int f(int a, int b, int c, int d){
  return t[c][d] - t[c][b] - t[a][d] + t[a][b];
}

signed main(){
  cin>>n>>k;
  rep(i,n){
    int xx,yy;char cc;cin>>xx>>yy>>cc;
    if(cc == 'W')yy += k;
    xx %= 2*k;yy %= 2*k;
    x[i] = xx;y[i] = yy;
  }
  rep(i,n)t[x[i]+1][y[i]+1]++;
  rep(i,2*k+1)rep(j,2*k)t[i][j+1] += t[i][j];
  rep(i,2*k+1)rep(j,2*k)t[j+1][i] += t[j][i];

  int ans = 0;
  rep(i,k)rep(j,k){
    int sum = f(0,0,i,j) + f(i,j,i+k,j+k) + f(i+k,j+k,2*k,2*k);
    sum += f(i+k,0,2*k,j) + f(0,j+k,i,2*k);
    chmax(ans, sum);
    chmax(ans, n-sum);
  }
  cout << ans << endl;
}



Measured memory_bytes: 36224
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;

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

    // check

    int bh = stoi(s.substr(0,2));
    int lh = stoi(s.substr(2,4));

    if (bh > 0 && bh <= 12) {
        // MM
        if(lh > 0 && lh <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
        
    } else {
        // YY
        if(lh > 0 && lh <= 12) {
            // YYMM
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int h,w,a[501][501],ls;
string s[501];
main(){
	while(cin>>h>>w,h){
		r(i,h)cin>>s[i];
		memset(a,0,sizeof(a));
		r(i,h)r(j,w){
			if(!i&&s[i][j]=='.')a[i][j]++;
			if(i&&s[i][j]=='.')a[i][j]=a[i-1][j]+1;
		}
		int ans=0;
		r(i,h){
			stack<P>st;
			r(j,w+1){
				if(st.empty())st.push(P(a[i][j],j));
				else{
					if(st.top().fi==a[i][j])continue;
					else if(st.top().fi<a[i][j])st.push(P(a[i][j],j));
					else{
						while(!st.empty()&&st.top().fi>a[i][j]){
							ans=max(ans,(j-st.top().se)*st.top().fi);
							ls=st.top().se;
							st.pop();
						}
						st.push(P(a[i][j],ls));
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int main() {
    vector<int> d(10001);
    int stop = 0;
    for (int i = 0; i < 10002; i++) {
        cin >> d[i];
        if (d[i] == 0) {
            stop = i;
            break;
        }
    }
    for (int i = 0; i < stop; i++) {
        cout << "Case " << i+1 << ": " << d[i] << endl;
    }
}



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

int n, m, a, b, c, ans, dist[105][105];
vector<pair<int, pair<int, int>>> edgeList;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i == j) {
				dist[i][j] = 0;
			}
			else {
				dist[i][j] = 1e9;
			}
		}
	}

	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		dist[a][b] = c;
		dist[b][a] = c;
		edgeList.push_back({a, {b, c}});
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	ans = m;
	for (int i = 0; i < m; i++) {
		int u = edgeList[i].first, v = edgeList[i].second.first, w = edgeList[i].second.second;
		bool used = 0;
		for (int j = 1; j <= n; j++) {
			if (dist[j][u] + w == dist[j][v]) {
				used = 1;
			}
		}

		if (used) {
			ans--;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

ll dp[100005][2][105];
int ctoi(char c) { return c - '0'; }
int main() {
   string K;
   int D;
   cin >> K >> D;

   dp[0][0][0] = 1;
   rep(i, 0, K.size()) rep(j, 0, D) {
      int k = ctoi(K[i]);
      rep(digit, 0, 10)(dp[i + 1][1][(j + digit) % D] += dp[i][1][j]) %= mod;
      rep(digit, 0, k)(dp[i + 1][1][(j + digit) % D] += dp[i][0][j]) %= mod;
      (dp[i + 1][0][(j + k) % D] += dp[i][0][j]) %= mod;
   }
   int ans = (dp[K.size()][0][0] + dp[K.size()][1][0] - 1 + mod) % mod;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 18688
//RITIK RAI:
//#pragma GCC optimize("O3")
 
/*----------------------------------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
/*----------------------------------------------------------------------------------------------------------*/
 
#define ll long long int
#define ull unsigned long long int
#define ld long double

/*----------------------------------------------------------------------------------------------------------*/
 
#define pll pair<ll,ll>
#define mp make_pair
#define fir first
#define sec second
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search

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

#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>b;i--)
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define print1(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl
#define print(arr,a,b)  for(ll i=a;i<b;i++) cout<<arr[i]<<endl
#define print2d(dp,r,c) for(ll i=0;i<r;i++){for(ll j=0;j<c;j++) cout<<dp[i][j]<<" "; cout<<endl;}
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define ritik ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
 /*--------------------------------------------FUNCIONS--------------------------------------------------------------*/
 
ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
ll max3(ll a,ll b,ll c)
{
    return max(max(a,b),c);
}


ll nCr(ll n, ll r)
{
    ll x=n-r,y=0,z=1;
    while(y<r)
    {
        z=(z*(x+1))/(y+1);
        x++;y++;
    }
    return z;
}
 
/*-----------------------------------------------write your code here-----------------------------------------------------------*/


int main()
{
    ll n,m; cin>>n>>m;
    vector<ll> v(n);
    ll sm=0;
    f(i,0,n) 
    {
        cin>>v[i];
        sm+=v[i];
    }
    ll cnt=0;
    f(i,0,n)
    {
        if(4*m*v[i]>=sm) cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int n, h;

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    
    cin >> n >> h;
    
    vector<int> a(n);
    vector<int> b(n);
    
    int maxHit = 0;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        maxHit = max(maxHit, a[i]);
    }
    
    int ret = 0;
    
    sort(b.begin(), b.end());
    
    int i = n-1;
    
    while (h > 0)
    {
        if (b[i] > maxHit) //throw katana
        {
            h -= b[i];
            i--;
        }
        else h -= maxHit;
        ret++;
    }
    
    cout << ret << '\n';
    
    return 0;
    
}



Measured memory_bytes: 1024
import java.util.Scanner;

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

        String nk = sc.nextLine();

        int N = Integer.parseInt(nk.split(" ")[0]);
        int K = Integer.parseInt(nk.split(" ")[1]);

        int t = N;
        int ans = 1;
        while(true) {
            if(t / K == 0){
                break;
            }
            t = t / K;
            ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
program battle;
var
    a, b, c, d : longint;

function dothejob(x : longint; y : longint) : longint;
begin
    if (x mod y) <> 0 then dothejob := trunc(x / y) + 1
        else dothejob := (x div y);
end;

begin
    readln(a, b, c, d);
    if (dothejob(a, d)) < (dothejob(c, b)) then writeln('No')
        else writeln('Yes');
end.

Measured memory_bytes: 1388
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int F[210][210], n, A[210], B[210], CA, CB, sink, v[210], cur = 1;
map<int,int>Map;
bool Prime(int a){
    if(a<0)a=-a;
    if(a==1)return false;
    int i;
    for(i=2;i*i<=a;i++)if(a%i==0)return false;
    return true;
}
int MaxFlow(int a){
    if(a==sink)return 1;
    v[a] = cur;
    int i;
    for(i=0;i<=sink;i++){
        if(F[a][i] && v[i]!=cur){
            if(MaxFlow(i)){
                F[a][i]--;
                F[i][a]++;
                return 1;
            }
        }
    }
    return 0;
}
int main(){
    int i, a, j, f = 0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        Map[a]++;
        Map[a+1]++;
    }
    for(auto &p : Map){
        if(p.second%2 == 1){
            if(p.first%2 == 0) A[++CA] = p.first;
            else B[++CB] = p.first;
        }
    }
    sink = CA+CB+1;
    for(i=1;i<=CA;i++){
        for(j=1;j<=CB;j++){
            if(Prime(B[j]-A[i])){
                F[i][CA+j] = 1;
            }
        }
        F[0][i]=1;
    }
    for(i=CA+1;i<=CA+CB;i++)F[i][sink]=1;
    while(MaxFlow(0)){
        f++,cur++;
    }
    printf("%d\n", f + (CA-f)/2*2 + (CB-f)/2*2 + (CA-f)%2*3);
}

Measured memory_bytes: 384
def f(n):
    if n == 0:
        return "0"
    if n == 1:
        return "1"
    a = n // -2
    b = n % -2
    if b == -1:
        a += 1
        b += 2
    return f(a) + str(b)


def main():
    N = int(input())
    print(f(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  1 18:56:53 2018
ABC108B
@author: maezawa
"""

x1, y1, x2, y2 = list(map(int, input().split()))

v1 = [x2-x1, y2-y1]
v2 = [y1-y2, x2-x1]
v3 = [x1-x2, y1-y2]

[x3,y3] = [x2+v2[0], y2+v2[1]]
[x4,y4] = [x3+v3[0], y3+v3[1]]

print(x3, y3, x4, y4)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main(){
    int i,k; cin >> k;
    int res = 0;
    for(i=0;i<=k;i++){
        res *= 10;
        res += 7;
        res %= k;
        if(res==0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var ba = ab[1] - ab[0];
            Console.WriteLine(ba * (ba + 1) / 2 - ab[1]);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long

using namespace std;

const int oo = 3e5;

int n;
char a[3005];
char b[3005];
int f[3005][3005];
main()
{
    scanf("%s",a+1);
    scanf("%s",b+1);

    int n=strlen(a+1);
    int n1=strlen(b+1);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n1;j++)
            {
            if(a[i]==b[j]) f[i][j]=f[i-1][j-1]+1;
            else f[i][j]=max(f[i-1][j],f[i][j-1]);
            }
    }
    int i=n,j=n1;
    string s="";
    while(i>0&&j>0)
    {
        while(f[i][j]==f[i][j-1]&&j>0) j--;
        while(f[i][j]==f[i-1][j]&&j>0) i--;
        if(i>0&&j>0)
        s=a[i]+s;
        i-=1;
        j-=1;
    }
    cout<<s;


}



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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  int n, t;
  cin>>n>>t;
  int ans = 0;
  int st = 0;
  int arr[n];
  rep(i, 0, n)
  {
    cin>>arr[i];
  }
  int ed = t;
  rep(i, 1, n)
  {
    int nx = arr[i];
    if(nx <= ed)
    {
      ans += (nx - st);
      ed = nx + t;
      st = nx;

    }
    else
    {
      ed = nx + t;
      ans += t;
      st = nx;
    }
  }
  //cout<<ans<<endl;
  ans += t;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12928
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    vector<double> P(n);
    for(int i = 0; i < n; i++)
    {
        cin >> P[i];
    }
    
    vector<vector<double>> dp(n+1,vector<double>(n+1));
    
    dp[n][0] = 1;
    for(int i = n-1; i >= 0; i--)
    {
        dp[i][0] = dp[i+1][0]*(1-P[i]);
    }
    
    for(int i = n-1; i >= 0; i--)
    {
        for(int j = 1; j <= n-i; j++)
        {
            dp[i][j] = P[i]*dp[i+1][j-1]+(1-P[i])*dp[i+1][j];
        }
    }
    
    double ans = 0;
    for(int i = n; i >= (n+1)/2; i--)
    {
        ans += dp[0][i];
    }
    
    cout << fixed << setprecision(12) << ans << '\n';

    return 0;
}


Measured memory_bytes: 70656
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0]
prev = 0

for i in range(1, N+1):
    cur = prev + L[i-1]
    D.append(cur)
    if cur > X:
        print(i)
        break
    prev = cur
else:
	print(N+1)

Measured memory_bytes: 3060
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * N
for i in range(1, N):
    dp[i] = dp[i-1] + abs(h[i]-h[i-1])
    for j in range(2, K+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]))

# print(dp)
print(dp[-1])


Measured memory_bytes: 52704
# coding: utf-8

# https://atcoder.jp/contests/abc098/tasks/arc098_a


def main():
    N = int(input())
    S = input()
    
    ans = len([1 for s in S[1:] if s == "E"])
    now = ans
    for i in range(1, N):
        now += 1 if S[i-1] == "W" else 0
        now -= 1 if S[i] == "E" else 0

        if now < ans:
            ans = now
    
    return ans


print(main())


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    rep(i,3) {
        if (s.at(i) == 'o') counter++;
    }
    cout << 700 + counter*100 << endl;
}

Measured memory_bytes: 256
n=int(input())
s=[[]for _ in range(n)]
d={}
f=[]
for i in range(n-1):
  a,b=map(int,input().split())
  d[min(a,b)*1000000+max(a,b)]=10**7
  s[a-1].append(b-1)
  s[b-1].append(a-1)
  f.append((a-1,b-1))
se={0}
mc=max(len(s[i])for i in range(n))
print(mc)
Q=[(0,i)for i in s[0]]
r=[-1]*n
r[0]=0
while Q:
  P=[]
  b=-1
  for i,j in Q:
    if j in se:continue
    if b!=i:x=1
    else:x+=1
    if r[i]==x:x+=1
    b=i
    se.add(j)
    for k in s[j]:
      P.append((j,k))
    d[min(i,j)*1000000+max(i,j)]=x
    r[j]=x
  Q=P
for i,j in f:print(d[min(i,j)*1000000+max(i,j)])

Measured memory_bytes: 66556
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i,amin=300000,bmax=1,lon;
	char s[210000];
	scanf("%s",s);
	
	lon=strlen(s);
	
	for(i=0;i<lon;i++){
		if(s[i]=='A'){
			if(i<=amin){
				amin=i;
			}
		}
		if(s[i]=='Z'){
			if(i>=bmax){
				bmax=i;
			}
		}
	}
	
	printf("%d\n",bmax-amin+1);
	return 0;
}

Measured memory_bytes: 384
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else cout << "Impossible";
}


Measured memory_bytes: 256
ct=-1
a=[0]*100000
b=[0]*100000
c=[0]*100000
while True:
    ct+=1
    a[ct],b[ct],c[ct]=map(str,raw_input().split())
    if b[ct]=="?":
        break
    else:
        continue
for i in xrange(ct):
    if b[i]=="+":
        print(int(a[i])+int(c[i]))
    elif b[i]=="-":
        print(int(a[i])-int(c[i]))
    elif b[i]=="*":
        print(int(a[i])*int(c[i]))
    else:
        print(int(a[i])/int(c[i]))
    

Measured memory_bytes: 8452
N = int(input())
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    j = i - 1
    k = 0
    while j > k:
        if L[i] < L[j] + L[k]:
            res += j - k
            j -= 1
        else:
            k += 1
print(res)

Measured memory_bytes: 3188
def len_LCS(X,Y):
    x_l = len(X)
    y_l = len(Y)
    lcs_row = [0 for _ in range(x_l+1)]
    for j in range(y_l):
        y_j = Y[j]
        lcs_row_p = lcs_row[:]
        # lcs_row_p: [i] [i+1]
        # lcs_row  : [i] [i+1]
        for i in range(x_l):
            if X[i] == y_j:
                lcs_row[i+1] = lcs_row_p[i] + 1
            elif lcs_row[i] > lcs_row_p[i+1]:
                lcs_row[i+1] = lcs_row[i]
    return lcs_row[-1]
        
if __name__=='__main__':
    n = int(input())
    for _ in range(n):
        X = input()
        Y = input()
        print(len_LCS(X,Y))

Measured memory_bytes: 7744
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		if(x<y && y<z){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17172
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  int sum=0;
  for(int i=0;i<n-1;i++)
    for(int j=i+1;j<n;j++)
      sum += a[i]*a[j];
  printf("%d",sum);
  return 0;
}


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

int main(void){
  int i,x,y;

  while(1){
    cin>>x>>y;
    if(!x && !y) break;

    if(x<y) swap(x,y);
    for(i=0;y;i++){
      x = x % y;
      swap(x,y);
    }
    cout<<x<<" "<<i<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

r = int(input())
print(r * r)

Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n,m,k;
	cin >> n >> m >> k;

	rep(i,n+1) {
		rep(j,m+1) {
			int now = i*m+j*n-2*i*j;
			if (now == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

int gcd( int m, int n ) {
	// 引数に０がある場合は０を返す
	if( (0 == m) || (0 == n) )
		return 0;

	// ユークリッドの方法
	while( m != n ) {
		if( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

int main() {
	long long int N, MA, MB;
	cin >> N >> MA >> MB;
	vector<vector<long long int>>dp( 401, vector<long long int>( 401, LLONG_MAX / 6 ) );
	dp[0][0] = 0;
	for( size_t idx = 0; idx < N; idx++ ) {
		long long int a, b, c;
		cin >> a >> b >> c;
		for( int i = 400 - a; i >= 0; i-- ) {
			for( int j = 400 - b; j >= 0; j-- ) {
				dp[i + a][j + b] = min( dp[i + a][j + b], dp[i][j] + c );
			}
		}
	}
	long long int gcdv = gcd( MA, MB );
	MA /= gcdv;
	MB /= gcdv;
	long long int ans = LLONG_MAX / 6;
	for( size_t i = 1; i *MA <= 400 && i*MB <= 400; i++ ) {
		ans = min( ans, dp[i*MA][i*MB] );
	}
	if( ans == LLONG_MAX / 6 ) {
		ans = -1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1536
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  out(sin()[0]+sin()[1]+sin()[2])
}
main()

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define w first
#define v second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
std::vector<ll> g[N];
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll lp[N];
bool vis[N];
void dfs(ll v){
     ll ans = 1;
     vis[v] = 1;
     for(auto i:g[v]){
          if(!vis[i])dfs(i);
          ans=max(ans,lp[i]+1);
     }
     lp[v] = ans;
}
int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    

     ll q = 1;
     // cin>>q;
     while(q--){
          ll n,m;cin>>n>>m;
          memset(lp,0,sizeof(lp));

          memset(vis,0,sizeof(vis));
          for(int i = 0;i<m;i++){
               ll u,v;cin>>u>>v;u--;    v--;
               g[u].pb(v);
          }
          for(int i = 0;i<n;i++){
               if(!vis[i]){
                    dfs(i);
               }
          }
          ll ans = 0;
          for(int i = 0;i<n;i++){
               ans = max(ans,lp[i]);
          }
          cout<<ans-1<<'\n';
     }
}         

Measured memory_bytes: 37632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 101415
#define  vi vector<int>
#define  v  vector
#define die exit(0)
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 
gp_hash_table<int, int> table;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};


int seive[N];


void solve()
{
	forn(i,1,N-20)seive[i] = i;

    for(int i = 2 ; i*i <= N-20 ; i++)
    {
    	if(seive[i] > MOD)continue;
    	seive[i] = i;
    	for(int j = i+i ; j<=N-10 ; j+=i)seive[j] = MOD*MOD;
    }
	

	
	rfor(i,N-30,1)
	{
		seive[i] = min(seive[i],seive[i+1]);
	}
	seive[1] = 2;
	int x;
	cin>>x;
	cout<<seive[x];
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       g++ -g c.cpp ; timeout 2s ./a.out

Measured memory_bytes: 1024
#include <iostream>
#include<iomanip>
#include <vector>
#include <algorithm>
#include<math.h>
using namespace std;

int main(){
	int n;
	vector <int> g;
	while(cin>>n){
		if(n!=0){
			g.push_back(n);
		}else{
			n=g.back();
			g.pop_back();
			cout<<n<<endl;
		}
	}
	return 0;
} 

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

int main()
{
	int N;
	cin >> N;
	vector<ll> a(N), b(N);
	ll suma = 0, sumb = 0;
	ll les = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		suma += a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		sumb += b[i];
	}
	for (int i = 0; i < N; i++) {
		les += max(a[i] - b[i], 0ll);
		if (a[i] < b[i] && (b[i] - a[i]) % 2) les++;
	}
	cout << (les <= sumb - suma ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int n,w;
        cin >> n >> w;
        vector<long long int> v(w+1);
        for(int i=0;i<n;i++)
        {
                int weight,value;
                cin >> weight >> value;
                for(int j=w-weight;j>=0;--j)
                {
                        v[j+weight]=max(v[j+weight],v[j]+value);
                }
        }
        long long int ans=0;
        for(int i=0;i<=w;i++)
        ans=max(ans,v[i]);
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 1024
l,r = gets.split.map(&:to_i)
M = 10**9+7
ans, lb, rb = 0, l.bit_length-1, r.bit_length-1
(lb..rb).each{|i|
  d1,d2,d3,d4,lc,rc = 1,0,0,0,lb==i ? ~l : ~0,rb==i ? r : ~0
  (i-1).downto(0){|j|
    d4 = (d4 * 3 + rc[j] * d2 + lc[j] * d3) % M
    d2 = (d2 * 2 + lc[j] * d1) % M if rc[j] == 1
    d3 = (d3 * 2 + rc[j] * d1) % M if lc[j] == 1
    d1 &= lc[j] | rc[j]
  }
  ans += d1 + d2 + d3 + d4
}
p ans % M

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define maxn 200002
using namespace std;
int main(){
    map<int,int>x;
    int n,temp;
    cin>>n;
    vector<int> arr;
    vector<int> brr;
    for(int i=0;i<n;i++){
        cin>>temp;
        arr.push_back(temp);
    }
    brr=arr;
    sort(arr.begin(),arr.end());
    int a ,b;
    for(int i=0;i<n;i++){
        if(brr[i]<arr[n/2]){
            cout<<arr[n/2]<<"\n";
        }
        else{
            cout<<arr[n/2-1]<<"\n";
        }
    }    
}

Measured memory_bytes: 3828
//-----------------------------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
//-----------------------------------------------------------------------------

int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cinsc;
}

//-----------------------------------------------------------------------------
 
 
int is_prime(int x){
    if(x<=1)    return 0;
    for(int i=2;i*i<=x;i++)
        if(x%i==0)  return 0;
    return 1;
}

int main(){
    //in_o();
    int x;
    cin>>x;
    while(!is_prime(x++));
    cout<<--x<<endl;
    return 0;
}


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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while(first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if(last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}

V h;
int N, K;

int main() {
    cin >> N >> K;
    h.resize(N);
    FOREACH(x, h) cin >> x;
    sort(All(h));
    int ans = INF;
    REP(i, N - K + 1) { ans = min(ans, h[i + K - 1] - h[i]); }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
N=int(input())
A=list(map(int,input().split()))
Odd,Four=0,0
for a in A:
    if a%2==1:Odd+=1
    elif a%4==0:Four+=1
if Odd+Four==N and Odd-Four==1:print("Yes")
elif Odd<=Four:print("Yes")
else:print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    double radius, area, circumference;

    cin >> radius;

    area = M_PI * radius * radius;
    circumference = 2 * M_PI * radius;

    printf("%lf %lf\n", area, circumference);

    return 0;
}

Measured memory_bytes: 1236
i = int(input()); 
j = input();
list = j.split(" ", i-1)
for y in list:
  y = int(y)
results = [0]*i
for x in range(0,i):
  while (int(list[x]) % 2 == 0):
    if (int(list[x]) % 2 == 0):
      list[x] = int(list[x]) /2 
      results[x] += 1
print(min(results))


    

Measured memory_bytes: 3064