akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl v(9);
    rep(i, n) {
        ll a;
        cin >> a;
        if(a < 3200) {
            v[a/400]++;
        }
        else {
            v[8]++;
        }
    }

    ll mi = 0;
    rep(i, 8) {
        if(v[i]) {
            mi++;
        }
    }

    ll ma = mi + v[8];
    
    cout << max(mi, 1LL) << " " << ma << endl;
    re0;
}

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

using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}

int main(){
	ll N; cin>>N;
    printf("%.12f",(double)((N+1)/2)/N);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
	static long ans=0;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long S=sc.nextLong();
		boolean[] b=new boolean[10000000];
		int cnt=1;
		while(true) {
			if(!b[(int)S]) {
				b[(int)S]=true;
				if(S%2==0) {
					S/=2;
				}
				else {
					S=S*3+1;
				}
			}
			else {
				pl(cnt);
				break;
			}
			cnt++;
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 31444
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int main(){
    for(;;){
        int n,k;
        scanf("%d%d",&n,&k);
        if(n==0&&k==0)break;
        vector<vector<int> > edges(n,vector<int>(n,-1)),costs(n,vector<int>(n,-1));
        for(int i=0;i<n;i++){
            costs[i][i]=0;
        }
        for(int ix=0;ix<k;ix++){
            int mo;
            scanf("%d",&mo);
            if(mo==0){
                int st,go;
                scanf("%d%d",&st,&go);
                st--;go--;
                printf("%d\n",costs[st][go]);
            }else{
                int c,d,e;
                scanf("%d%d%d",&c,&d,&e);
                c--;d--;
                if(edges[c][d]==-1||edges[c][d]>e){
                    edges[c][d]=e;
                    edges[d][c]=e;
                    for(int i=0;i<n;i++){
                        for(int j=0;j<n;j++){
                            if(costs[i][c]!=-1&&costs[d][j]!=-1){
                                int newco=costs[i][c]+edges[c][d]+costs[d][j];
                                if(costs[i][j]==-1 || costs[i][j]>newco){
                                    costs[i][j]=costs[j][i]=newco;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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


int main(){
    int N, cnt;
    string text;
    cin>> N;
    map<string, int> base;
  rep(i , N){
      cin >> text;
      base[text]++;
  }

  cnt = base.size();

  cout << cnt << endl;
    
}

Measured memory_bytes: 19224
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int H,W;
    cin>>H>>W;

    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin>>S[i];
    }
    
    vector<vector<pair<int,int>>> light(H);
    for(int i=0;i<H;i++){
        light[i].resize(W);
        for(int k=0;k<W;k++){
            light[i][k].first=0;
            light[i][k].second=0;
        }
    }

    for(int i=0;i<H;i++){
        for(int k=0;k<W;k++){
            if(S[i][k]=='#'){continue;}

            if(light[i][k].first==0){
                int l=i;
                for(l=i;l<H;l++){
                    if(S[l][k]=='#'){break;}
                }l--;
                for(int m=i;m<=l;m++){
                    light[m][k].first=l-i+1;
                }
            }
            if(light[i][k].second==0){
                int l=k;
                for(l=k;l<W;l++){
                    if(S[i][l]=='#'){break;}
                }l--;
                for(int m=k;m<=l;m++){
                    light[i][m].second=l-k+1;
                }
            }
        }
    }

    int ans=0;
    for(int i=0;i<H;i++){
        for(int k=0;k<W;k++){
            ans=max(ans,light[i][k].first+light[i][k].second-1);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define RSort(a) reverse(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

signed main(){
    int n,m;
    cin >> n >> m;
    vec(a,m);
    vec(b,m-1);
    REP(i,m){
        cin >> a[i];
    }
    Sort(a);
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    REP(i,m-1){
        b[i] = a[i+1]-a[i];
    }
    Sort(b);
    int ans = 0;
    REP(i,m-n){
        ans += b[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
/*input
30 19
39 20
19 18
25 20
22 21
23 10
10 -10
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let mut v: Vec<i32>;
    for _ in 0..7 {
        v = read_line()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        println!("{}", (v[0] - v[1]).abs());
    }
}



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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  double all=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    all+=a.at(i);
  }
  sort(a.begin(),a.end());
  if(a.at(n-m)<all/(4*m)) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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


int main() {
    int d = 0;
    int t = 0;
    int s = 0;
    cin >> d;
    cin >> t;
    cin >> s;

    int amari = d % s;
    int wari = d / s;
    string res = "No";

    if(amari == 0){
      if(wari <= t){
        res = "Yes";
      }
    }else{
      if(wari < t){
        res = "Yes";
      }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 3612
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Map<String, Integer> map = new TreeMap<>();
		int max = 0;
		for (int i = 0; i < n; i++) {
			String z = s.next();
			if (map.containsKey(z)) {
				int v = map.get(z) + 1;
				max = Math.max(max, v);
				map.put(z, v);
			}else {
				map.put(z, 1);
				max = Math.max(max, 1);
			}
		}
		for(String k : map.keySet()) {
			if (map.get(k) == max) {
				System.out.println(k);
			}
		}
	}
	
	
}


Measured memory_bytes: 76720
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()
    B = sorted(LI(), reverse=True)
    tmp = []
    for i in range(N):
        if A[i] == B[i]:
            tmp.append((i, A[i]))

    j = 0
    while tmp:
        idx, x = tmp.pop()
        for i in range(j, N):
            b = B[i]
            j = i + 1
            if i == idx: continue
            if b != x and x != A[i]:
                B[i], B[idx] = B[idx], B[i]
                break
        else:
            print('No')
            return
    print('Yes')
    print(*B)


if __name__ == '__main__':
    solve()



Measured memory_bytes: 41256
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int ans=INF;
int x,y;

inline int change(string ss)
{
	if(ss=="R") return 0;
	if(ss=="G") return 1;
	if(ss=="B") return 2;
}

inline bool check(vector<vector<int> > tile)
{
	rep(i,tile.size())
	{
		rep(j,tile[i].size())
		{
			if(tile[0][0]!=tile[i][j])
				return false;
		}
	}

	return true;

}

inline void f(vector<vector<int> > &tile,int color)
{
	//x,y
	queue<P> que;
	int oldcolor=tile[0][0];
	tile[0][0]=color;

	que.push(P(0,0));

	while(que.size())
	{
		P p = que.front(); que.pop();

		rep(i,4)
		{
			int nx=p.fr+dx[i];
			int ny=p.sc+dy[i];

			if(0<=nx&&nx<x&&0<=ny&&ny<y&&tile[nx][ny]==oldcolor)
			{
				tile[nx][ny]=color;	
				que.push(P(nx,ny));
			}
		}
	}
}	

inline void dfs(vector<vector<int> > tile,int depth)
{
	if(check(tile))
	{
		ans=min(ans,depth);
		return;
	}
	//最大でも18手を越えないらしい
	if(depth==17) return;

	vector<vector<int> > tile1=tile;
	vector<vector<int> > tile2=tile;

	if(tile[0][0]==0)
	{
		f(tile1,1);
		f(tile2,2);
	}
	if(tile[0][0]==1)
	{
		f(tile1,0);
		f(tile2,2);
	}
	if(tile[0][0]==2)
	{
		f(tile1,1);
		f(tile2,0);
	}

	dfs(tile1,depth+1);
	dfs(tile2,depth+1);

}

inline void solve()
{
	vector<vector<int> > tile;

	tile.reserve(10);

	rep(i,x)
	{
		vector<int> vec;
		vec.reserve(10);
		rep(j,y)
		{
			string c;
			cin>>c;
			vec.pb(change(c));
		}
		tile.pb(vec);
	}

	dfs(tile,0);

}

int main()
{
	while(cin>>x>>y)
	{
		swap(x,y);
		if(x==0&&y==0)
			return 0;

		solve();
		cout<<ans<<endl;
		ans=INF;

	}
	return 0;
}

Measured memory_bytes: 1312
import sys
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
mod = 10 ** 9 + 7

if N == 1:
    print(1)
    sys.exit()

B = ['.'] * (N + 1) 
for a in A:
    B[a] = '#'
    
dp = [0] * (N + 1)
if B[1] == '.' and B[2] == '.':
    dp[1] = 1
    dp[2] = 2
elif B[1] == '#' and B[2] == '.':
    dp[2] = 1
elif B[1] == '.' and B[2] == '#':
    dp[1] = 1
    
for i in range(3, N + 1):
    if B[i] == '.':
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    
print(dp[N])

Measured memory_bytes: 50776
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define pow POW
int main(){
    int n,p;
    scanf("%d %d",&n,&p);
    int odd=0;
    for(int i= 0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(x&1)odd=1;
    }
    if(odd==0){
        if(p)printf("0\n");
        else printf("%lld\n",1ll<<n);
    }
    else{
        printf("%lld\n",1ll<<(n-1));
    }
}
/*
7 7
1 1 4 7
1 1 2 5
1 2 6 7
1 1 5 8
1 1 3 6
1 3 7 5
0 1 6 7
d-1 2-d 3-d=d
d-1 2-d 3-d 4-d
12 02 0 1
a1 a2 a3 a4
a1-a2-a3-a4
a1-a2-a3+a4
a1-a2+a3-a4
a1-a2+a3+a4
a1-a2-a3+a4
a1-a2+a3-a4
*/
//a+a+1=10a+1
//3a+2=10a+2

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

vector<vector<int>> matrix;
vector<vector<int>> memo;

int main(){
	int N;
	int a,b,c;
	cin>>N;
	matrix.resize(N);
	memo.resize(2);
	for(int i=0; i<N; i++){
		cin>>a>>b>>c;
		matrix[i] = {a,b,c};
	}
	memo[0] = matrix[N-1];
	memo[1] = matrix[N-1];
	int f = 1;
	for(int r = N-2; r >=0 ; r--){
		memo[f][0] = matrix[r][0] + 
					std::max(memo[(f+1)%2][1], memo[(f+1)%2][2]);
		memo[f][1] = matrix[r][1] + 
					std::max(memo[(f+1)%2][0], memo[(f+1)%2][2]);
		memo[f][2] = matrix[r][2] + 
					std::max(memo[(f+1)%2][1], memo[(f+1)%2][0]);
		f = (f+1)%2;
	}
	if(N%2==1){
		cout<<std::max(memo[0][0], std::max(memo[0][1], memo[0][2]));
	}
	else{
		cout<<std::max(memo[1][0], std::max(memo[1][1], memo[1][2]));
	}
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
int desc(const void *a,const void *b){
    return *(int *)b - *(int *)a;
}
int main(void){
    int N,M,i,j,ans=0;
    scanf("%d%d",&N,&M);
    int a[N];
    for(i=0;i<N;i++) scanf("%d",&a[i]);
    qsort(a,N,sizeof(a[0]),desc);
    for(i=0;i<M;i++){
        ans+=a[i];
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;

int main() {
  int a,b,c,k;cin>>a>>b>>c>>k;
  if(a+b>=k)cout<<min(k,a);
  else cout<<a-(k-a-b);
}

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

int main() {
    int r, D, x2000;
    cin >> r >> D >> x2000;
    int xi = x2000;
    for(int i=0;i<10;i++){
        xi = r * xi - D;
        cout << xi << endl;
    }
    return 0;
}

Measured memory_bytes: 256
require 'prime'
a = 10**9+7
n = gets.chomp.to_i
h = Hash.new(0)
(1..n).each do |i|
  x = Prime.prime_division(i)
  x.each do |n, e|
    h[n] += e
  end
end
ret = 1
h.values.each do |i|
  ret *= (i + 1)
end
 
puts ret % a

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int w,h,k,n;
  cin>>w>>h>>k>>n;
  k-=(w+1)/2;
  if(k<0){
    cout<<-1<<endl;
    return 0;
  }
  Int ans=((w+1)/2)*(h/2);
  Int cnt=0;
  vector<vector<Int> > vp(h+1);
  for(Int i=0;i<n;i++){
    Int x,y;
    cin>>x>>y;
    if(x&1) ans++;
    if(y&1) continue;
    vp[y].emplace_back(x);
  }
  const Int INF = 1e9;
  for(Int i=0;i<h+1;i++){
    if(vp[i].empty()) continue;
    vector<Int> dg(w+1,0);
    for(Int x:vp[i]) dg[x]=1;
    auto dp=make_v<Int>(2,w+1);
    fill_v(dp,-INF);
    dp[0][1]=0;
    for(Int j=1;j<w;j+=2){
      chmax(dp[0][j+2],dp[0][j]);
      chmax(dp[0][j+2],dp[1][j]);
      if(dg[j+1]) continue;
      chmax(dp[1][j+2],dp[0][j]+dg[j]+dg[j+2]);
    }
    ans-=max(dp[0][w],dp[1][w]);
    Int sum=0;
    for(Int x:vp[i]) if(x&1) sum++;
    cnt+=sum-max(dp[0][w],dp[1][w]);
  }
  chmin(cnt,k);
  ans-=min(ans,cnt*2);
  k-=cnt;
  ans-=min(ans,k);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4196
#include <bits/stdc++.h>
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	cout << min(b / a, c) << endl;
}

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

	solve();
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

vvll to;
vll c;

bool is_bipartite(ll cur,ll color){
	c[cur]=color;
	for(auto&& next:to[cur]){
		if(c[next]==color) return false;
		else if(!c[next] && !is_bipartite(next,-color)) return false;
	}
	return true;
}

int main()
{
	ll n;
	cin >> n;
	vvll d(n,vll(n,INF));
	to.resize(n);
	c.resize(n);
	rep(i,n){
		rep(j,n){
			char s;
			cin >> s;
			if(s=='1'){
				to[i].pb(j);
				to[j].pb(i);
				d[i][j]=1;
			}
		}
	}
	if(!is_bipartite(0,1)){
		cout << -1 << endl;
		return 0;
	}
	rep(i,n) d[i][i]=0;
	rep(k,n) rep(i,n) rep(j,n) chmin(d[i][j],d[i][k]+d[k][j]);
	ll ans=0;
	rep(i,n) chmax(ans,maxvec(d[i]));
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
vector<int>G[1<<17],RG[1<<17];
vector<int>s;
int n,m,dp[1<<17];
bool used[1<<17];
void dfs(int u)
{
	used[u]=1;
	for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
	s.push_back(u);
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].push_back(y);
	}
	for(int i=0;i<n;i++)
	{
		if(!used[i])dfs(i);
	}
	reverse(s.begin(),s.end());
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int u=s[i];
		ans=max(ans,dp[u]);
		for(int p:G[u])if(dp[p]<dp[u]+1)dp[p]=dp[u]+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11896
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint a, b, n; cin >> a >> b >> n;
  lint x = min(n, b - 1);
  cout << (a * x) / b - a * (x / b) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;
const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
vector <i64> a;
vector <i64> dp;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);
    
    string s;
    cin >> s;

    for (i64 i = 0; i < s.size(); ++i) {
        if (s[i] != '?') {
            cout << s[i];
        }
        else {
            cout << 'D';
        }
    }

    cout << endl;




    return 0;
}

Measured memory_bytes: 3488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int n, q, a, b;
	pair<int, int> pa[200000];
	cin >> n >> q;
	rep(i, n - 1) {
		cin >> a >> b;
		pa[i] = make_pair(a - 1, b - 1);
	}
	sort(pa, pa + n - 1);
	int z[200000] = {};
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		z[p - 1] += x;
	}
	rep(i, n - 1) z[pa[i].second] += z[pa[i].first];
	rep(i, n) cout << z[i] << " ";
}

Measured memory_bytes: 4736
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        
        
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

           
            long[] sum = new long[N];
            long[] ans = new long[2];
            long c = 1;
            for (var j = 0; j < 2; j++)
            {
                for (var i = 0; i < N; i++)
                {
                    if (i == 0)
                    {
                        sum[i] = a[i];
                    }
                    else
                    {
                        sum[i] = sum[i - 1] + a[i];
                    }
                    if (sum[i] * c <= 0)
                    {
                        ans[j] += 1 + Math.Abs(sum[i]);
                        sum[i] = c;
                    }
                    c *= -1;
                }
                c = -1;
            }

            Console.WriteLine(ans.Min());
            

            //Console.Out.Flush();

        }

        
    }

    public class Calculation
    {

    }

    public class Graph
    {
        
    }
}




Measured memory_bytes: 32092
#include <iostream>
#include <cstdio>
using namespace std;
char ff[3];
int a[4];
bool jud=0;
void prin()
{
    printf("%d%c%d%c%d%c%d=7\n",a[0],ff[0],a[1],ff[1],a[2],ff[2],a[3]);
}
void dfs(int n,int cnt)
{
    if(jud)return;
    if(cnt==4&&n==7) {prin();jud=1; return;}
    if(cnt>=4)return;
    for(int i=0;i<2;i++)
    {
        if(i==0)
        {
            ff[cnt-1]='+';
            dfs(n+a[cnt],cnt+1);
        }
        else
        {
                 ff[cnt-1]='-';
                 dfs(n-a[cnt],cnt+1);

        }

    }
}
int main()
{

    char s;
    for(int i=0;i<4;i++)
    {
        cin>>s;
        a[i]=s-'0';
    }
    dfs(a[0],1);

    //if(judge)
    return 0;
}


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

int main() {
  int d,g;
  cin >> d >> g;
  
  using pii = pair<int,int>;
  vector<pii> v;
  for (int i=0; i<d; i++) {
    int p,c;
    cin >> p >> c;
    v.push_back(pii(p,c));
  }
  
  int mincnt = 10000;
  for (int i=0; i<(1<<d); i++) {
    bitset<10> b = i;
    int count = 0;
    int sum = 0;
    for (int j=0; j<d; j++) {
      if (b.test(j)) {
        sum += 100*(j+1)*v.at(j).first + v.at(j).second;
        count += v.at(j).first;
      }
    }
    int index;
    for (int j=d-1;j>=0;j--) {
      if (!b.test(j)) {
        index = j;
        break;
      }
    }
    for (int j=0; j<=v.at(index).first; j++) {
      if (j!= v.at(index).first) {
        if (sum + 100*(index+1)*j >= g) {
          count += j;
          mincnt = min(mincnt, count);
          break;
        }
      } else {
        if (sum + 100*(index+1)*j + v.at(index).second >= g) {
          count += j;
          mincnt = min(mincnt, count);
          break;
        }
      }
    }
  }
  cout << mincnt << endl;
  
}


Measured memory_bytes: 256
/*
最小値,最大値,合計値
*/

#include<stdio.h>

int main(void){
  int n,i;/*n個の整数,i番目*/
  int a;/*i番目の整数*/
  int max,min;/*n個の最大値,最小値,合計*/
  long sum;

  scanf("%d",&n);
  
  i = 1;
  sum = 0;
  while(n>=i){
    scanf("%d",&a);
    switch (i){
      case 1:
	max = a;
	min = a;
	break;
      case 2:
	if(a > max){
	  min = max;
	  max = a;
	}
	else{
	  min = a;
	}
	break;
      default:
	if(a > max)
	  max = a;
	if(min > a)
	  min = a;
	break;
      }
    sum += a;
    i++;
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}


Measured memory_bytes: 2080
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>
using namespace std;
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
//const double PI = acos(-1) ;
db PI=3.1415926;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     pf("Case %d: %lld\n",z,x)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)


using namespace std;
ll n,m,y,x,h,e,l,o;


int main()
{
	CIN;
	//cin>>n;
	cin>>n;
	x=n+n*n+n*n*n;
	pf("%lld\n",x);


	
	
}

Measured memory_bytes: 3776
import itertools
A = [int(input()) for _ in range(5)]
tmin = 10**4
for x in itertools.permutations(range(5)):
    t = 0
    for i in range(5):
        a = t%10
        if a>0:
            t = (t//10+1)*10
        t += A[x[i]]
    tmin = min(tmin,t)
print(tmin)

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

int main(void){
	int n,k;

	while(cin>>n>>k && (n || k)){
		int count[n+1];
		fill(count,count+n+1,0);
		for(int i=0;i<k;i++){
			int x;
			cin>>x;
			count[x]++;
		}

		int maxLen = 0;
		for(int i=1;i<=n;i++){
			bool cardFlg = count[0];
			int j,index=-1;
			for(j=i;j<=n && (count[j]!=0 || cardFlg);j++){
				if(count[j] == 0 && cardFlg){
					index = j;
					cardFlg = false;
				}
			}
			maxLen = max(maxLen,j-i);
			if(index == -1) i = j;
			else i = index;
		}
		cout<<maxLen<<endl;
	}

	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
typedef pair<int,int> P;
string alph="abcdefghijklmnopqrstuvwxyz";
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
    int n;cin>>n;
    if(n/10==9||n%10==9)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, A[200020], B[200020];

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", A + i);
	for(int i=1;i<=N;i++) scanf("%d", B + i);
	ll ans = 0;
	for(int i=28;i>=0;i--) {
		vector <int> va, vb;
		for(int j=1;j<=N;j++) va.pb(A[j] & ((1<<(i+1))-1));
		for(int j=1;j<=N;j++) vb.pb(B[j] & ((1<<(i+1))-1));
		sort(all(va));
		sort(all(vb));
		ll cnt[3] = {}, L = 1<<i;
		for(int a=0, b=N-1;a<N;a++) {
			while(b >= 0 && va[a] + vb[b] >= L) --b;
			cnt[0] += b + 1;
		}
		for(int a=0, b=N-1;a<N;a++) {
			while(b >= 0 && va[a] + vb[b] >= 2*L) --b;
			cnt[1] += b + 1;
		}
		for(int a=0, b=N-1;a<N;a++) {
			while(b >= 0 && va[a] + vb[b] >= 3*L) --b;
			cnt[2] += b + 1;
		}
		ll c = (ll)N*N - cnt[2] + cnt[1] - cnt[0];
		if(c & 1) ans += L;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4460
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



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



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

#define ALL(c) c.begin(), c.end()
#define SZ(c) ((int)c.size())
#define REP(i, n) for (int i = 0, loop_num_##i = n; i < loop_num_##i; i++)

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

using ld = long double;

ld dp[21][200000];

signed main() {
	cout << setprecision(15) << fixed << endl;
	REP(i, 21) REP(j, 200000) dp[i][j] = 1e9;

	int N;
	cin >> N;
	vector<int> a(N);
	REP(i, N) cin >> a[i];

	dp[0][1] = 0;
	REP(i, N) {
		REP(j, 200000) {
			if (j == 0) continue;
			for (int k = 1; j * k < 200000; k++) {
				ld tmp = max(dp[i][j], (ld)abs(a[i] - j * k) / a[i]);
				dp[i + 1][j * k] = min(dp[i + 1][j * k], tmp);
			}
		}
	}

	ld ans = 1e9;
	REP(i, 200000) ans = min(ans, dp[N][i]);
	cout << ans << endl;
}



Measured memory_bytes: 68908
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d" ,&X,&Y,&Z);
  int T,W;
  T=X;
  W=Y;
  X=Z;
  Y=T;
  Z=W;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 1696
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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;}

#define P (1'000'000'007)

signed main() {
    capi(n);

    multiset<int> sa;

    rep(i, n) {
        capi(a);
        if (auto it = sa.lower_bound(a); it != sa.begin()) {
            --it;
            sa.erase(it);
        }
        sa.insert(a);
    }

    cout << sa.size();

    return 0;
}


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

c = N*2
import math
cl, cr = math.ceil(math.sqrt(c)), math.floor(math.sqrt(c))
if cl==cr+1 and cl*cr==c:
  k = cl
  print('Yes')
  ans = [[] for _ in range(k)]
  print(k)
  num = 1
  for i in range(k-1):
    for j in range(i+1, k):
      ans[i].append(num)
      ans[j].append(num)
      num += 1
  for arr in ans:
    print(len(arr), *arr, sep=' ')
else:
  print('No')



Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(void){
    int n, k; cin >> n >> k;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for(int i=0; i<k; i++) ans += l[i];

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int n,m;
    cin>>n>>m;
    if(m%2==0 && m>=2*n && m<=4*n)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

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

char map[105][105];
int n,m,x,y,ans=0,a[105][105],b[105][105];
short f[105][105][105][105];

int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",map[i]+1);
		for(int j=1;j<=m;j++){
			a[i][j]=a[i][j-1]+(map[i][j]=='o');
			b[i][j]=b[i-1][j]+(map[i][j]=='o');
			if(map[i][j]=='E')x=i,y=j;
		}
	}
	for(int i=x;i>=1;i--)
	for(int j=y;j>=1;j--){
		for(int k=x;k<=n;k++)
		for(int l=y;l<=m;l++){
			if(i>1&&i-1>k-x)ans=max(ans,f[i-1][j][k][l]=max(f[i-1][j][k][l],f[i][j][k][l]+a[i-1][min(l,m-y+j)]-a[i-1][max(j-1,l-y)]));
			if(k<n&&n-k>x-i)ans=max(ans,f[i][j][k+1][l]=max(f[i][j][k+1][l],f[i][j][k][l]+a[k+1][min(l,m-y+j)]-a[k+1][max(j-1,l-y)]));
			if(j>1&&j-1>l-y)ans=max(ans,f[i][j-1][k][l]=max(f[i][j-1][k][l],f[i][j][k][l]+b[min(k,n-x+i)][j-1]-b[max(i-1,k-x)][j-1]));
			if(l<m&&m-l>y-j)ans=max(ans,f[i][j][k][l+1]=max(f[i][j][k][l+1],f[i][j][k][l]+b[min(k,n-x+i)][l+1]-b[max(i-1,k-x)][l+1]));
		}
	}
	printf("%d",ans);
}

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

void fnInput(vector<int>& rvnBinHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnBinHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnBinHeap[i];
}

void fnBinaryHeap(const vector<int>& cnrvnBinHeap)
{
  for (int i = 1; i < cnrvnBinHeap.size(); ++i)
  {
    cout << "node " << i << ": key = " << cnrvnBinHeap[i] << ", ";
    int nParnt = i / 2;
    int nLeft = i * 2;
    int nRigt = nLeft + 1;
    if (nParnt >= 1)
      cout << "parent key = " << cnrvnBinHeap[nParnt] << ", ";
    if (nLeft < cnrvnBinHeap.size())
      cout << "left key = " << cnrvnBinHeap[nLeft] << ", ";
    if (nRigt < cnrvnBinHeap.size())
      cout << "right key = " << cnrvnBinHeap[nRigt] << ", ";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnBinHeap; 

  fnInput(vnBinHeap);
  fnBinaryHeap(vnBinHeap);
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(){
  int n,a,b,c,d;
  string s;
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  if(c > d){
    int flag = 0;
    int flag2 = 0;
    if(s[b] == '.' && s[b-2] == '.') flag = 1;
    else if(s[b] == '.' && s[b+1] == '.') flag = 1;
    else if(s[d-2] == '.' && s[d] == '.') flag = 1;
    else{
      int i = b-1;
      while(s[i] != '#' && i < n) i++;
      if(i == n){
        cout << "No";
        return 0;
      }
      int j = d-1;
      while(s[j] != '#' && d > 0) j--;
      if(d-1 - j >= 2) flag = 1;
      else{
        int cnt = 0;
        while(i < j){
          i++;
          if(s[i-1] == '#'){
            if(cnt >= 3){
              flag = 1;
              if(cnt >= 4){
                flag2 = 1;
                break;
              }
            }
            else
              cnt = 0;
          }
          else cnt++;
        }
      }
    }
    if(flag == 0){
      cout << "No";
      return 0;
    }
    if(flag){
      if(flag2 == 0)
        n--;
    }
  }
  for(int i = 0 ; i < n*100 ; i ++){
    if( b == d && a == c){
      cout << "Yes";
      return 0;
    }
    if(b < d){
      if(d - b == 1 || d - b == 2){
        b = d;
        continue;
      }
      else if(s[b+1] == '.'){
        b += 2;
        continue;
      }
      else if(s[b] == '.'){
        b ++;
        continue;
      }
      else break;
    }
    if(a < c){
      if(c - a == 1 || c - a == 2){
        a = c;
        continue;
      }
      else if(s[a+1] == '.'){
        a += 2;
        continue;
      }
      else if(s[a] == '.'){
        a ++;
        continue;
      }
      else break;
    }
  }
  if( b == d && a == c){
    while(1){;}
  }
  cout << "No";
  return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  vector<int> cnt;
  if (S.at(0) == '0') cnt.push_back(0);
  for (int i = 0; i < S.size(); i++) {
    char c = S.at(i);
    int tmp = 0;
    while (i < S.size() && S.at(i) == c) {
      tmp++;
      i++;
    }
    i--;
    cnt.push_back(tmp);
  }
  if (S.back() == '0') cnt.push_back(0);
  int ans = 0;
  int sum = 0;
  int right = 0;
  bool flag = false;
  for (int left = 0; left < cnt.size(); left += 2) {
    while (right < cnt.size() && right <= left + 2*K) {
      sum += cnt.at(right);
      right++;
    }
    ans = max(ans, sum);
    if (right >= cnt.size()) break;
    sum -= (cnt.at(left) + cnt.at(left+1));
  }
  cout << ans << endl;
}

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

int main() {
	int64_t a;
	cin >> a;

	int64_t count_zero=2;
	int64_t count_one =1;
	int64_t ans;
	
	if(a==0){
		ans = count_zero;
	}
	else if(a==1){
		ans = count_one;
	}
	else {
		for(int i=1; i<a; i++){
		    ans =count_zero+count_one;
			int64_t count_one2=count_one;
			int64_t count_zero2=count_zero;
			count_zero=count_one2;
			count_one=count_zero2+count_one2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(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 trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int n,a,b; cin>>n>>a>>b;
        int fans = 0;
        int temp; cin>>temp;
        rep(i,0,n-1){
            int curr; cin>>curr;
            curr = curr - temp;
            fans += min(curr*a, b);
            temp = curr+temp;
        }
        cout<<fans<<endl;

    }
}

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

int main(){
  int n,a,b,c,topp[101];
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++) cin >> topp[i];
  sort(topp,topp + n,greater<int>());
  int cal,dol,maxi;
  cal = c; dol = a;
  maxi = cal/dol;
  for(int i=0;i<n;i++){
    cal += topp[i];
    dol += b;
    maxi = (maxi < cal/dol)? cal/dol : maxi;
  }
  cout << maxi << endl;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    long double l;
    cin >> l;

    long double len = l/3;
    cout << fixed <<  setprecision(10) << len*len*len << endl;
}


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

using namespace std;

int main(){
  string S, T;
  string unk(T.size(), '?');
  cin >> S >> T;
  int p = -1;
  for (int i=S.size() - T.size(); i>=0; i--){
    string sub = S.substr(i, T.size());
    bool f = true;
    for (int j=0; j<T.size(); j++){
      if (sub[j] != '?' && sub[j] != T[j]){
        f = false;
        break;
      }
    }
    if (f){
      S = S.substr(0, i) + T + S.substr(i + T.size(), S.size() - (i + T.size()));
      p = i;
      break;
    }
  }
  if (p == -1){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    for (int i=0; i<S.size(); i++){
      cout << (S[i] == '?' ? 'a' : S[i]);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int main()
{
	owo
	 ll n;
	 cin>>n;
	 vector<ll>a(n);
	 vector<ll>chk(1e6+2);
	 int ans = 0;
	 for(int i=0;i<n;i++){cin>>a[i];chk[a[i]]++;}
     for(int i=0;i<n;i++)
     {
		 bool flag = 1;
		 if(chk[a[i]] > 1)continue;
		 for(int j=1;j*j<=a[i];j++)
		 {
			 if(j == a[i])continue;
			 if(a[i]%j == 0){
				 if(chk[j]){flag=0;break;}
				 if(j!=1 && chk[a[i]/j]){flag=0;break;}
			 }
		 }
		 if(flag)ans++;
	 }
	 cout<<ans;
}


Measured memory_bytes: 12688
WORM_EATEN_S = STDIN.gets.strip!
HINT = STDIN.gets.strip!
candidates = []

def apply_hint(given_str, start, hint)

  if start + hint.length > given_str.length
    return ''
  end

  applied = Marshal.load(Marshal.dump(given_str))

  (0..hint.length-1).each do |idx|
    target_char = given_str[start+idx]

    unless ( target_char == '?' || target_char == hint[idx] )
      return ''
    end

    applied[start+idx] = hint[idx]
  end

  return applied
end

# gather candidate strings
result = ''
(0..WORM_EATEN_S.length-1).each do |idx|
  result = apply_hint(Marshal.load(Marshal.dump(WORM_EATEN_S)), idx, HINT)
  candidates.push(result.gsub(/\?/, 'a')) if result != ''
end

# print the result
if candidates.length == 0
  puts 'UNRESTORABLE'
else
  puts candidates.min
end


Measured memory_bytes: 3836