akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj;
ll n,m,num,ans;
ll a,b,c,d,e,g,h,r,bag;
ll wn1,wn2,wn3,wn4;
ll w[5005],v[5005];
ll dp[5][5005];
ll inde[5];

int main(){
    cin >> n >> bag;
	for(i=0;i<n;i++){
		cin >> w[i] >> v[i];
	}
	for(i=0;i<=3;i++){
		inde[i] = 1;
	}
	for(i=0;i<n;i++){
		for(num = 0;num <= 3;num ++){
			if(w[i] == w[0] + num){
				dp[num][inde[num]++] = v[i];
			}
		}
	}
	for(num=0;num<=3;num++){
		sort(dp[num] + 1,dp[num] + inde[num] + 1);
		reverse(dp[num] + 1,dp[num] + inde[num] + 1);
	}
	for(i=0;i<=3;i++){
		for(j=1;j<=inde[i];j++){
			dp[i][j] += dp[i][j-1];
			//pe(dp[i][j]);
		}
		//el;
	}
	for(int num1=0;num1 <= inde[0];num1 ++){
		for(int num2=0;num2 <= inde[1];num2 ++){
			for(int num3=0;num3 <= inde[2];num3++){
				if((bag-w[0]*num1-w[0]*num2-num2-w[0]*num3-2*num3) < 0)continue;
				ll kosuu = (bag-w[0]*num1-w[0]*num2-num2-w[0]*num3-2*num3) / (w[0] + 3);
				ll kati = dp[0][num1] + dp[1][num2] + dp[2][num3] + dp[3][kosuu];
				ans = max(ans,kati);
			}
		}
	}

	p(ans);
    return 0;
}

Measured memory_bytes: 23680
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;
fn main() {
    input! {
        n: usize,
        s: [String; n],
        m: usize,
        t: [String; m],
    };
    let mut map = HashMap::new();
    for st in s {
        *map.entry(st).or_insert(0i32) += 1;
    }
    for st in t {
        *map.entry(st).or_insert(0) -= 1;
    }
    println!(
        "{}",
        map.values()
            .map(|&n| if n > 0 { n } else { 0 })
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int w[11],k[11],i,j;
	int temp;
	for(i=0;i<10;i++){
	scanf("%d",&w[i]);
	}
	for(j=0;j<10;j++){
		scanf("%d",&k[j]);
	}
	for(i=0;i<10;i++){
		for(j=9;j>i;j--){
			if(w[i]<w[j]){
			temp=w[i];
			w[i]=w[j];
			w[j]=temp;
		}
	}
}
for(i=0;i<10;i++){
		for(j=9;j>i;j--){
			if(k[i]<k[j]){
			temp=k[i];
			k[i]=k[j];
			k[j]=temp;
			}
		}
		}
printf("%d %d\n",w[0]+w[1]+w[2],k[0]+k[1]+k[2]);
			return 0;
}

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

int main()
{
        ll a, b, c;
        cin >> a >> b >> c;
        ll ans = a*100 + b*10 + c;
        if (ans % 4 == 0) {
                cout << "YES" << endl;
        }
        else cout << "NO" << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<unordered_map<int, int>>num(n);
  vector<ed>es(m);
  if(m==0){cout<<-1<<endl;return 0;}

  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    num[a][c]++;
    num[b][c]++;
  }
  int cnt=0;
  rep(i,n)
  {
    int tn=cnt++;
    for(auto &p:num[i])
    {
      p.second=cnt++;
    }
    num[i][-1]=tn;
  }
  vector<int>dist(cnt+2,-1);
  vector<vector<P>>edge(cnt+2);
  rep(i,n)for(auto p:num[i])
  {
    if(p.first==-1)continue;
    int t=num[i][-1];
    int tn=p.second;
    edge[t].push_back({1,tn});
    edge[tn].push_back({0,t});
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    edge[to].push_back({0,from});
    edge[from].push_back({0,to});
  }
  int start=num[0][-1],end=num[n-1][-1];
  priority_queue<P,vector<P>,greater<P>>q;
  q.push({0,start});
  while(!q.empty())
  {
    P tp=q.top();q.pop();
    if(dist[tp.second]!=-1)continue;
    dist[tp.second]=tp.first;
    for(P nn:edge[tp.second])
    {
      if(dist[nn.second]!=-1)continue;
      q.push({nn.first+tp.first,nn.second});
    }
  }
  cout<<dist[end]<<endl;



  return 0;

}


Measured memory_bytes: 65016
# -*- coding: utf-8 -*-
import sys

#n= int(input())
#tmp= float(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

min=1000000
max=-1000000
total=0

while(1):
    tmp = input().split()
    h,w = list(map(lambda a: int(a), tmp))
    if((h==0)and(w==0)):
        sys.exit()
    for i in range(h):
        tmp=""
        for j in range(w):
            tmp+="#"
        print(tmp)
    print("")





Measured memory_bytes: 5620
#include <iostream>
#include <string.h>
#include <map>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll n;
ll p3[65];
map<pair<ll,int>,ll> dp;

ll dfs(ll n,int i) {
    if (dp.find(mp(n,i))!=dp.end()) {
        return dp[mp(n,i)];
    }
    if (n<0) return 0;
    if (i==0) return 1;
    ll tot=(1LL<<(i+1))-2;
    if (n>=tot) return dp[mp(n,i)]=p3[i];
    ll a=dfs(n,i-1);
    ll b=dfs(n-(1LL<<(i-1)),i-1);
    ll c=dfs(n-(1LL<<i),i-1);
    return dp[mp(n,i)]=(a+b+c)%MOD;
}

int main() {
    scanf("%lld",&n);
    memset(p3,0,sizeof(p3));
    p3[0]=1;
    for (int i=1;i<=60;i++) {
        p3[i]=p3[i-1]*3;
        p3[i]=p3[i]%MOD;
    }
    ll ans=dfs(n,60);
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();
    ll cnt = 0;
    ll ans = 0;
    rep(i,N) {
        if (S[i] == 'B') cnt++;
        else ans += cnt;
    }

    cout << ans << endl;
}

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

void rec(vector<vector<int>> &L, int l, int r, int t){
  int m = (l+r)/2;
  for(int i = l; i < m; ++i){
    for(int j = m; j < r; ++j){
      L[i][j] = t;
    }
  }
  if(l+1 < m) rec(L,l,m,t+1);
  if(m+1 < r) rec(L,m,r,t+1);
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> L(N,vector<int>(N,0));
  rec(L,0,N,1);
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j < N; ++j){
      cout << L[i][j];
      if(j < N-1) cout << " ";
      else cout << endl;
    }
  }
}


Measured memory_bytes: 1536
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool check(ll b, ll n, ll s){
	if(n<b) return s==n;
	return check(b, n/b, s-n%b);
}


void mainmain(){
	ll n,s;
	cin>>n>>s;
	if(s==n){
		cout<<n+1<<endl;
		return;
	}
	int nn = sqrt(n)+100;
	ll ans = INFL;
	rep(i,2,nn){
		if(check(i,n,s)){
			mins(ans, (ll)i);
		}
	}
	rep(i,1,nn+10){
		ll b = (n+i-s)/i;
		if(2<=b && check(b,n,s)) mins(ans, b);
	}
	if(ans==INFL) ans=-1;
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc;

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

		System.out.println(calc(age,price));
	}

	private static Integer calc(Integer age, Integer price) {
		if (age<6) {
			return 0;
		} else if (age<13) {
			return (price / 2);
		} else {
			return price;
		}
	}


}


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

func main() {
	var M int
	var D int
	var ans int
	fmt.Scan(&M, &D)
	for m:=4; m<=M; m++ {
		for d1:=2; d1<=9; d1++ {
			if m%d1 == 0 && d1+10*(m/d1)<=D && m/d1>=2  && m/d1<=9{
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001

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

    ll n;
    cin>>n;
    string s = to_string(n);
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        print("Bad");
    }
    else print("Good");
        
    
}



Measured memory_bytes: 256
import java.util.*;

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

		      int a = sc.nextInt();
		      int b = sc.nextInt();
		      int c = sc.nextInt();
		         
		      if(a <= b && b <= c) {
		        min = a;
		        middle = b;
		        max = c;
		      }else if(a <= c && c <= b) {
		        min = a;
		        middle = c;
		        max = b;
		      }else if(b <= a && a <= c) {
		        min = b;
		        middle = a;
		        max = c;
		      }else if(b <= c && c <= a) {
		        min = b;
		        middle = c;
		        max = a;
		      }else if(c <= a && a <= b) {
		        min = c;
		        middle = a;
		        max = b;
		      }else if(c <= b && b <= a) {
		        min = c;
		        middle = b;
		        max = a;
		      }

		        System.out.println(min + " " + middle + " " + max);
			 
    }
}


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

int main(){
    int N, K;
    int d[100];
    int ans = 0;
    int A[100] = {0};
    int p;
    cin >> N >> K;
    for(int i = 0; i < K; i++){
        cin >> d[i];
        for(int j = 0; j < d[i]; j++){
            cin >> p;
            A[p-1] = 1;
        }
    }

    for(int l = 0; l < N; l++){
        ans += A[l];
    }
    ans = N-ans;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b){
    if(a.first!=b.first){
        return a.first<b.first;
    }
    else{
        return a.second<b.second;
    }
}

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > red;
    vector<pair<int,int> > blue;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >>b;
        red.push_back(make_pair(a,b));
    }
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        blue.push_back(make_pair(a,b));
    }
    sort(red.begin(),red.end(),cmp);
    sort(blue.begin(),blue.end(),cmp);

    
    int ans = 0;
    int i=0;
    for(int i=0;i<blue.size();i++){
        int tmp = red.size();
        int max = -1;
        for(int k=red.size()-1;k>=0;k--){
           if(blue[i].first>red[k].first&&blue[i].second > red[k].second){
               if(max <  red[k].second){
                   max = red[k].second;
                   tmp = k;
               }
           }
        }
        if(max != -1){
            ans ++;
            red.erase(red.begin()+tmp);
        }
        /*cout << i << endl;
        for(int i=0;i<red.size();i++){
        cout <<red[i].first << " " << red[i].second << endl;
    }*/

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fname "C"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<double, double> dd;
const int Nmax = 100, R = 3000, T = 2500;
int n, A, arr[Nmax];

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(0);
	scanf("%d %d", &n, &A);
	REP1(i, n) {
		scanf("%d", &arr[i]);
		arr[i] -= A;
	}
	vector<ll> current(2*T + R, 0), next;
	REP1(i, n) {
		bug(i);
		next.resize(2*T + R, 0);
		next[arr[i] + R] = 1;
		FOR(j, -T, T) {
			/*if (next[j + R]) {
				bug(j);
				bug(next[j + R]);
			}*/
			next[j + R] += current[j + R] + current[j - arr[i] + R];
			/*if (next[j + R]) {
				cout << "current[" << j << '+' << R << "] = " << current[j + R] << '\n';
				cout << "current[" << j << '-' << arr[i] << '+' << R << "] = " << current[j - arr[i] + R] << '\n';
				cout << "next[" << j << '+' << R << "] = " << next[j + R] << '\n';
			}*/
		}
		current = next;
		next.clear();
	}
	cout << next[R];
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main (){
	int a,b;
	
	scanf ("%d %d",&a,&b);
	
	if (b%a==0){
		printf ("%d",a+b);
	}
	else if (a==1 && b==1){
		printf ("1");
	}
	else {
		printf ("%d",b-a);
	}
	return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
int n;
int a[N];
map<int, int> b;

bool solve(int S) {
	b.clear();
	for (int i = 1; i < n; i++) {
		if (a[i] > a[i - 1]) continue;
		while(!b.empty()) {
			auto it = b.end();
			it--;
			if (it->first < a[i]) break;
			b.erase(it);
		}
		int p = a[i] - 1;
		while(true) {
			if (p < 0) return false;
			b[p]++;
			if (b[p] == S) {
				b[p] = 0;
				p--;
			} else break;
		}
	}
	return true;
}

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

	scanf("%d", &n);
	bool ok = true;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (i > 0 && a[i] <= a[i - 1])
			ok = false;
	}
	if (ok) {
		printf("1\n");
		return 0;
	}
	int l = 1, r = n;
	while(r - l > 1) {
		int x = (l + r) / 2;
		if (solve(x))
			r = x;
		else
			l = x;
	}
	printf("%d\n", r);

	return 0;
}


Measured memory_bytes: 1024
/*
 *  Created on: 28 / 6 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
void solve()
{
    string a, b; cin >> a >> b;
    ll ans = 0;
    for (int i = 0; i < sz(a); i++)
    {
        if (a[i] != b[i])ans++;
    }
    cout << ans;
}
int main()
{
    //stp(0)
    Eslam__Waheed
    solve();
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int x,n;cin >> x>>n;
  set<int> st;
  for(int i=0;i<n;++i){
    int t;cin>>t;
    st.insert(t);
  }
  int out;
  if(st.find(x)==st.end()){
    out = x;
  } else {
    int d=1;
    while(true){
      int p = x + d;
      int m = x - d;
      if(st.find(m)==st.end()){
        out = m;
        break;
      } else {
        if(st.find(p)==st.end()){
          out = p;
          break;
        }
      }
      ++d;
    }
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 3628
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# functions
class UnionFind:
    def __init__(self, n):
        self.par  = [i for i in range(n)]
        self.rank = [0] * (n)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

# main
from collections import defaultdict
N,K,L = map(int,input().split())
PQ = [list(map(int,input().split())) for _ in range(K)]
RS = [list(map(int,input().split())) for _ in range(L)]

# 道路
A = UnionFind(N)
for p,q in PQ:
    A.unite(p-1,q-1)

# 鉄道
B = UnionFind(N)
for r,s in RS:
    B.unite(r-1,s-1)

dic = defaultdict(int)
for i in range(N):
    dic[A.find(i), B.find(i)] += 1

Ans = list(dic[A.find(i), B.find(i)] for i in range(N))
print(" ".join(map(str,Ans)))

Measured memory_bytes: 109552
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin >> k;
    string x;
    queue<string> q;
    for(char c='1';c<='9';c++) q.push({c});
    int cnt = 0;
    while(true){
        cnt++;
        string x = q.front();q.pop();
        if(cnt == k){
            cout << x << endl;
            return 0;
        }
        for(int i = -1; i <= 1; i++){
            char c = x[x.size()-1] + i;
            if(c < '0' || '9' < c) continue;
            q.push(x + c);
        }
    }
}

Measured memory_bytes: 13824
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

char cal[3];
char b[4];


int main()
{
	
	scanf("%s",b);
	int a[4];
	rep(i,4)a[i]=b[i]-'0';
	//rep(i,4)cout<<a[i]<<endl;
	     if(a[0]+a[1]+a[2]+a[3]==7)cout<<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
	else if(a[0]+a[1]+a[2]-a[3]==7)cout<<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
	else if(a[0]+a[1]-a[2]+a[3]==7)cout<<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
	else if(a[0]+a[1]-a[2]-a[3]==7)cout<<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
	else if(a[0]-a[1]+a[2]+a[3]==7)cout<<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
	else if(a[0]-a[1]+a[2]-a[3]==7)cout<<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
	else if(a[0]-a[1]-a[2]+a[3]==7)cout<<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
	else if(a[0]-a[1]-a[2]-a[3]==7)cout<<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
	return 0;
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())

E=[[] for i in range(N)]

for i in range(N-1):
  E[i].append(i+1)
  E[i+1].append(i)
  
E[X-1].append(Y-1)
E[Y-1].append(X-1)

INF=10**4

ans=[0 for i in range(N)]
from collections import deque
for i in range(N):
  score=[INF for i in range(N)]
  q=deque([[i,0]])
  while q:
    v,dist=q.pop()
    if score[v]>dist:
      score[v]=dist
    else:
      continue
    for child in E[v]:
      q.append([child,dist+1])
  for s in score:
    ans[s]+=1
    
for i in range(1,N):
  print(ans[i]//2)
    


Measured memory_bytes: 62556
#include <functional>
#include <queue>
#include <vector>
#include <iostream>
#include <cstdint>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	vector<int> l;
	int cnt = 0;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int in;
		cin >> in;
		l.push_back(in);
	}

	std::sort(l.begin(), l.end());

/*	for (int i = 0; i < n; i++)
	{
		cout << l[i] << endl;
	}*/
	
	for (int x = 0; x < n; x++)
	{
		int a = l[x];
		for (int y = x + 1; y < n; y++)
		{
			int b = l[y];
			for (int z = y + 1; z < n; z++)
			{
				int c = l[z];

				if (a + b > c)
				{
					if (a < b + c)
					{
						if (b < c + a)
						{
							cnt++;
						}
					}
				}
				else
				{
					break;
				}
			}
		}
	}

	cout << cnt;

	return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;
    yn(!(s == "AAA" or s == "BBB"));

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[20],c[100],tp,ans;
int chk(){
    int ret=10007;
    for(int i=0;i<=tp;++i)
        for(int j=i+1;j<=tp;++j)
            ret=min(ret,min(abs(c[i]-c[j]),24-abs(c[i]-c[j])));
    return ret;
}
void dfs(int x){
    if(x==13){
        ans=max(ans,chk());
        return ;
    }
    if(a[x]==2)c[++tp]=x,c[++tp]=24-x,dfs(x+1),tp-=2;
    else if(a[x]==1)c[++tp]=x,dfs(x+1),c[tp]=24-x,dfs(x+1),tp--;
    else dfs(x+1);
}
int main(){
    scanf("%d",&n);
    for(int i=1,x;i<=n;++i)
        scanf("%d",&x),a[x]++;
    for(int i=0;i<=12;++i)
        if(a[i]>2)return puts("0"),0;
    dfs(0);
    printf("%d",ans);
}

Measured memory_bytes: 3812
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(sys.stdin.readline())

ok = False
for i in range(50):
    for j in range(25):
        ok |= 4*i + 7 *j == N

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13664
from bisect import bisect

A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF]
T = [-INF]
for i in range(A):
    S.append(int(input()))
for i in range(B):
    T.append(int(input()))
S.append(INF)
T.append(INF)
for i in range(Q):
    x = int(input())
    sr = bisect(S, x)
    sl = sr - 1
    tr = bisect(T, x)
    tl = tr - 1
    def d(y): return abs(x - y)
    ans = min(d(max(S[sr], T[tr])), d(min(S[sl], T[tl])))
    ans = min(ans, 2 * d(S[sr]) + d(T[tl]))
    ans = min(ans, d(S[sr]) + 2 * d(T[tl]))
    ans = min(ans, 2 * d(S[sl]) + d(T[tr]))
    ans = min(ans, d(S[sl]) + 2 * d(T[tr]))
    print(ans)


Measured memory_bytes: 101912
#include <bits/stdc++.h>
using namespace std ;
int main()
{
  long long n , m ;
  cin >> n >> m ;
  long long ans = ((n + 1) / 2) * ((m + 1) / 2)  ;
  long long res = (n / 2 )* (m / 2) ;
  //cout << ans << " " << res << endl ;
  if(n == 1 || m == 1) cout << 1 << endl ;
  else 
  cout << ans + res << endl ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

long long N;
long long dp[61][3];

long long search(int digit = 60, int prevDif = 0){
	if(prevDif < 0) return 0;
	if(digit < 0) return 1;
	if(dp[digit][prevDif] >= 0) return dp[digit][prevDif];
	long long res = 0;
	for(int add=0;add<=2;add++){
		int newDif = min<int>(2, 2 * prevDif + (N>>digit)%2 - add);
		res = (res + search(digit-1, newDif)) % 1000000007;
	}
	return dp[digit][prevDif] = res;
}

int main(){
	while(cin >> N){
		memset(dp, -1, sizeof(dp));
		cout << search() << endl;
	}
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	ans := 999999999
	for i := 0; i < n-1; i++ {
		left := 0
		for j := 0; j <= i; j++ {
			left += ar[j]
		}
		right := 0
		for j := i + 1; j < n; j++ {
			right += ar[j]
		}
		v := left - right
		if v < 0 {
			v = -v
		}
		if v < ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
/**
*    created: 03.07.2020 01:54:48
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;
    int cnt = 1;
    while (true) {
        if (x*2 > y) break;
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    vector<int> cand(n-2);
    for(int i=0; i<n-2; i++){
        cand[i] = stoi(s.substr(i,3));
    }

    int count = 0;
    for(int i=0; i<n-2; i++){
        cand[i] = abs(cand[i] - 753);
    }
    sort(cand.begin(), cand.end());
    cout << cand[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]) {
    int n;
    int p[200000];
    int i, min = 1000000;
    int r;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &p[i]);
    }
    
    r = 0;
    for (i = 0; i < n; i++) {
        if (p[i] < min) {
            min = p[i];
            r++;
        }
    }
    
    printf("%d\n", r);
    
    return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }
//while( ){  }

/*
int N, i;
int H[100];
scanf("%d", &N);
for (i = 0; i < N; i++) scanf("%s", &H[i]);
*/

int main()
{
	char S[10];
	scanf("%s",&S);

	if (S[0] == 'S' && S[1] == 'u' && S[2] == 'n' && S[3] == 'n' && S[4] == 'y') {
		printf("Cloudy");
	}
	if (S[0] == 'C' && S[1] == 'l' && S[2] == 'o' && S[3] == 'u' && S[4] == 'd'&&S[5]=='y') {
		printf("Rainy");
	}
	if (S[0]=='R'&&S[1]=='a'&&S[2]=='i'&&S[3]=='n'&&S[4] == 'y') {
		printf("Sunny");
	}

}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define maxn 200000
#define maxe 1000000
#define MAX 999999999
struct bian
{
	int u,v,flow,cap;
	int next,pair;
}edge[maxe];
int head[maxn];
int n,m;
int ans[1100];
int top;
int dis[maxn];
int s,t;
int have[310][310];
int lc[maxn];
int pre[maxn];
int ce[maxn];
int num;
int sap()
{
	int a,f,u,tmp,neck,h;
	int i;
	memset(dis,0,sizeof(dis));
	memset(lc,0,sizeof(lc));
	memset(pre,-1,sizeof(pre));
	for(i=1;i<=n;i++)
		ce[i]=head[i];
//	lc[n]=n;
	lc[0]=n;
	f=0;
	u=s;
	while(dis[s]<n)
	{
		if(u==t)
		{
			a=MAX;
			for(i=s;i!=t;i=edge[ce[i]].v)
			{
				if(a>edge[ce[i]].cap)
				{
					neck=i;
					a=edge[ce[i]].cap;
				}
			}
			for(i=s;i!=t;i=edge[ce[i]].v)
			{
				tmp=ce[i];
				edge[tmp].cap-=a;
				edge[tmp].flow+=a;
				tmp=edge[tmp].pair;
				edge[tmp].cap+=a;
				edge[tmp].flow-=a;
			}
			f+=a;
			u=neck;
		}
		for(h=ce[u];h!=-1;h=edge[h].next)
		if(edge[h].cap>0&&dis[u]==dis[edge[h].v]+1)
			break;
		if(h!=-1)
		{
			ce[u]=h;
			pre[edge[h].v]=u;
			u=edge[h].v;
		}
		else
		{
			if(--lc[dis[u]]==0)
				break;
			ce[u]=head[u];
			tmp=n-1;
			for(h=head[u];h!=-1;h=edge[h].next)
				if(edge[h].cap>0)
					tmp=min(tmp,dis[edge[h].v]);
			dis[u]=tmp+1;
			lc[dis[u]]++;
			if(u!=s)
				u=pre[u];
		}
	}
	return f;
}
void add(int u,int v,int w)
{
	edge[num].u=u;
	edge[num].v=v;
	edge[num].flow=0;
	edge[num].cap=w;
	edge[num].next=head[u];
	edge[num].pair=num+1;
	head[u]=num++;
	edge[num].u=v;
	edge[num].v=u;
	edge[num].flow=0;
	edge[num].cap=1;
	edge[num].next=head[v];
	edge[num].pair=num-1;
	head[v]=num++;
}
int main()
{
//	freopen("1.txt","r",stdin);
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		num=0;
		memset(head,-1,sizeof(head));
		memset(have,0,sizeof(have));
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v,1);
			have[u][v]=i;
		}
		scanf("%d%d",&s,&t);
		printf("%d\n",sap());
		top=0;
		for(int i=0;i<num;i++)
		{
			if(edge[i].flow<0)
			{
				int u=edge[i].u;
				int v=edge[i].v;
				if(have[u][v])
					ans[top++]=have[u][v];
			}
		}
		printf("%d\n",top);
		for(int i=0;i<top;i++)
			printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D

int main()
{
    int n;
    cin >> n;
    int l=(360*n)/__gcd(360,n);
    cout<<l/n<<endl;
}

Measured memory_bytes: 3640
//
// Created by miyoshi on 2019/05/23.
//

#include <iostream>

using namespace std;

int Heap[500001];
int NIL = -2000000001;
int Heap_size;

int get_parent_index(int i) {
    if (i == 1) {
        return NIL;
    } else {
        return (i - (i % 2)) / 2;
    }
}

int get_left_child_index(int i){
    int a = 2 * i;
    if (a >= Heap_size) {
        return NIL;
    } else {
        return  a;
    }
}

int get_right_child_index(int i) {
    int a = 2 * i + 1;
    if (a >= Heap_size) {
        return NIL;
    } else {
        return a;
    }
}

int max(int i, int l, int r) {
    int large=i;

    if (l != NIL) {
        if (Heap[i] < Heap[l]) {
            large = l;
        }
    }
    if (r != NIL) {
        if (Heap[large] < Heap[r]) {
            large = r;
        }
    }

    return large;
}

void max_heapify(int i) {
    int left_index = get_left_child_index(i);
    int right_index = get_right_child_index(i);

    int largest_index = max(i, left_index, right_index);

    if (largest_index != i) {
        int temp = Heap[i];
        Heap[i] = Heap[largest_index];
        Heap[largest_index] = temp;
        max_heapify(largest_index);
    }
}

void build_max_heap() {
    for (int i = Heap_size/2; i >= 1; i--) {
        max_heapify(i);
    }
}

int main() {
    int h;
    cin >> h;
    h++;
    Heap_size = h;
    for (int n=1; n < h; n++) {
        cin >> Heap[n];
    }
    build_max_heap();
    for (int n=1; n < h; n++) {
        int key = Heap[n];
        cout << " " << key;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, N = MAP()
A = np.array(LIST())

if np.sum(A) >= H:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 24020
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int N, A, B, C;
vector<int> L;

int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c)
            return 1e9;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int res = rec(i + 1, a, b, c);

    res = min(res, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
    res = min(res, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
    res = min(res, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));

    return res;
}

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

    cin >> N >> A >> B >> C;
    L.resize(N);
    rep(i, N) { cin >> L[i]; }

    cout << rec(0, 0, 0, 0) << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

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

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

  if(X >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}





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

	int tt = T /A ;

	cout << tt * B << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			String s = sc.next();
			int[][] map = new int[3][3];
			
			int n = 0;
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					String t = s.substring(n,n+1);
					if(t.compareTo("o")==0){
						map[i][j]=1;
					}else if(t.compareTo("x")==0){
						map[i][j]=2;
					}
					n++;
				}	
			}
			n=0;
			int count=0;
			for(int i=1;i<=2;i++){
				for(int j=0;j<3;j++){
					count=0;
					for(int k=0;k<3;k++){
						if(map[j][k]==i)count++;
					}
					if(count==3){
						n=i;
						j=3;
					}
				}
				for(int j=0;j<3;j++){
					count=0;
					for(int k=0;k<3;k++){
						if(map[k][j]==i)count++;
					}
					if(count==3){
						n=i;
						j=3;
					}
				}
				if(map[1][1]==i){
					if((map[0][0]==i && map[2][2]==i) || (map[0][2]==i && map[2][0]==i))n=i;
				}
				if(n!=0)i=3;
			}

			if(n==0){
				ans.push("d");
			}else if(n==1){
				ans.push("o");
			}else{
				ans.push("x");
			}
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

Measured memory_bytes: 17144
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static final int mod = 1000000007;

    public static void main(String[] args) {

        int  n = sc.nextInt();
         int x = sc.nextInt();
         int t = sc.nextInt();
         
         int ans = t*(n/x);
         if(n%x!=0)
         ans+= t;
         System.out.println(ans);




    }
















    static int max(int a, int b)
    {
        return Math.max(a,b);
    }
    static int max(int a, int b, int c)
    {
        return Math.max(max(a,b), c);
    }
    static int max(int a, int b, int c, int d)
    {
        return Math.max(max(a,b), max(c,d));
    }

    static int min(int a, int b)
    {
        return Math.min(a, b);
    }

    static int min(int a, int b, int c )
    {
        return Math.min(a, min(b,c));
    }

    static int min(int a, int b, int c, int d )
    {
        return Math.min(min(a,d), min(b,c));
    }

    static boolean isPower(int a, int b)
    {
        double temp = Math.log(a)/Math.log(b);
        return temp == (int) temp;
    }
    static boolean isPrime(int n)
    {
        if(n==1) return false;
        if(n==2) return true;
        if(n%2==0) return false;

        if(n<9)return true;
        if(n%3==0) return false;

        int r = (int)Math.sqrt(n);

        for(int i = 5; i<=r; i +=6)
        {
            if(n%i==0) return false;
            if(n%(i+2)==0) return false;
        }
        return true;



    }
}


Measured memory_bytes: 35620
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		int N, K;
		cin >> N >> K;
		if (cin.fail()) break;

		deque<int> V(N);
		for (int i = 0; i < N; i++) {
			cin >> V[i];
		}

		ll result = -INF;
		for (int L = 0; L <= min(K, N); L++) {
			for (int R = 0; R <= min(N - L, K - L); R++) {
				int P = K - L - R;
				deque<int> T;
				for (int i = 0; i < L; i++) {
					T.push_back(V[i]);
				}
				for (int i = 0; i < R; i++) {
					T.push_back(V[N - 1 - i]);
				}
				sort(T.begin(), T.end());
				while (P--) {
					if (T.empty() || T.front() >= 0) break;
					T.pop_front();
				}
				ll sum = 0;
				for (auto v : T) {
					sum += v;
				}
				result = max(sum, result);
			}
		}
		cout << result << endl;
	}

	return 0;
}


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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a>b){
		cout<<"a > b"<<endl;
	}
	else{
		cout<<"a == b"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned int uii;
int n,a[100005],k,res,d[100005];
vector<int> vec[100005];
void dfs(int u) {
    for (uii i=0;i<vec[u].size();++i) {
        dfs(vec[u][i]);
        d[u]=max(d[u],d[vec[u][i]]+1);
    }
    if (a[u]!=1&&d[u]==k-1) {
        ++res;
        d[u]=-1;
    }
}
int main()
{
    scanf("%d%d%d",&n,&k,&a[1]);
    if (a[1]!=1) {
        ++res;
        a[1]=1;
    }
    for (int i=2;i<=n;++i) {
        scanf("%d",&a[i]);
        vec[a[i]].push_back(i);
    }
    dfs(1);
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 11136