akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll a, b; cin >> a >> b;
  char c[100][100];
  for (ll i = 0; i < 50; i++) {
    for (ll j = 0; j < 100; j++) {
      c[i][j] = '#';
      c[i+50][j] = '.';
    }
  }
  ll island = 1;
  for (ll i = 0; i < 50; i++) {
    for (ll j = 0; j < 100; j++) {
      if (island <= a-1 && i%2 == 0 && j%2 == 0) {
        c[i][j] = '.';
        island++;
      }
    }
  }
  island = 1;
  for (ll i = 99; i >= 50; i--) {
    for (ll j = 0; j < 100; j++) {
      if (island <= b-1 && i%2 == 1 && j%2 == 0) {
        c[i][j] = '#';
        island++;
      }
    }
  }
  cout << 100 << " " << 100 << endl;
  for (ll i = 0; i < 100; i++) {
    for (ll j = 0; j < 100; j++) {
      cout << c[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct cnt{
	struct cnt* next;
	int* ary;
} cntnr;

int min(int x,int y)
{
	if(x > y)
	{
		return y;
	}
	else
	{
		return x;
	}
}

cntnr* countsquare(int n,int h)
{
	cntnr* data = (cntnr*)malloc(sizeof(cntnr));
	cntnr* tmp;
	int i,j;
	if(h >= n)
	{
		data->ary = (int*)malloc(sizeof(int)*101);
		data->ary[0] = n;
		data->ary[1] = 0;
		tmp = data;
		for(i = 1;i < n;i++)
		{
			tmp->next = countsquare(i,n-i);
			while(tmp->next != NULL)
			{
				tmp = tmp->next;
				for(j = 100;j > 0;j--)
				{
					tmp->ary[j] = tmp->ary[j-1];
				}
				tmp->ary[0] = n-i;
			}
		}
		tmp->next = NULL;
	}
	else
	{
		tmp = data;
		for(i = (n-h);i < n;i++)
		{
			tmp->next = countsquare(i,min(h,n-i));
			while(tmp->next != NULL)
			{
				tmp = tmp->next;
				for(j = 100;j > 0;j--)
				{
					tmp->ary[j] = tmp->ary[j-1];
				}
				tmp->ary[0] = n-i;
			}
		}
		tmp->next = NULL;
		data = data->next;
	}
	return data;
}

int main()
{
	int n;
	int i,j;
	while(scanf("%d",&n),n)
	{
		cntnr* data = countsquare(n,n);
		do
		{
			printf("%d",data->ary[0]);
			i = 0;
			while(data->ary[++i])
			{
				printf(" %d",data->ary[i]);
			}
			printf("\n");
			data = data->next;
		}while(data->next != NULL);
		printf("%d",data->ary[0]);
		i = 0;
		while(data->ary[++i])
		{
			printf(" %d",data->ary[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
package main
 
import (
	"bufio"
    "time"
    "fmt"
    "os"
 )

var sc = bufio.NewScanner(os.Stdin)

func main() {
    var str string
    if sc.Scan() {
        str = sc.Text()
    }
  
  layout := "2006/01/02"
  s, _ := time.Parse(layout, str)
  
  tbd := "2019/05/01"
  t, _ := time.Parse(layout, tbd)
  
  if s.Unix() < t.Unix() {
    fmt.Println("Heisei")
  } else {
    fmt.Println("TBD")
  }
}

Measured memory_bytes: 640
#include<stdio.h>
int main() {
  int cnt, num, repeat, i = 0, ans = 1 << 29;
  scanf("%d",&repeat);
  for(;i < repeat; i++) {
    scanf("%d",&num);
    cnt = 0;
    while(1) {
      if(num % 2 > 0) break;
      cnt++;
      num /= 2;
    }
    ans = ans > cnt ? cnt : ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
// inputに入力データ全体が入る     
function Main(input) {             //   
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")
 
 T = Number(tmp0[0])
  X = Number(tmp0[1])

  var ans = T/X;
ans = ans*10000000000;
ans = Math.round(ans)/10000000000

var ans = ans.toFixed(10);   // "15.7840"

  console.log(ans)
 
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("3 4\n2 1 3\n3 1 2 3\n2 3 2")

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main ()
{
    long long int n,a,b,i,r;
    while (scanf ("%lld %lld",&a,&b)!=EOF)
    {
        i=a+b;
        r=log10(i)+1;
        printf ("%lld\n",r);
    }
    return 0;
}


Measured memory_bytes: 3448
# coding: utf-8

n, q = map(int,raw_input().split())
A = [(1<<31) - 1 for i in xrange(100000)]
B = [(1<<31) - 1 for i in xrange(101)]
 
def update(i,x):
    if A[i] == (1<<31) - 1:
        A[i] = x
        B[i/1000] = min(x, B[i/1000])
    else:
        A[i] = x
        MIN = (1<<31) - 1
        for j in xrange(i/1000 * 1000, (i/1000 + 1) * 1000):
            if A[j] < MIN:
                MIN = A[j]
        B[i/1000] = MIN
 
def find(s,t):
    MIN = (1<<31) - 1
    if s/1000 == t/1000 or s/1000 + 1 == t/1000:
        for i in xrange(s, t+1):
            if A[i] < MIN:
                MIN = A[i]
    else:
        #left range
        for i in xrange(s, (s/1000 + 1) * 1000):
            if A[i] < MIN:
                MIN = A[i]
        #middle range
        for j in xrange(s/1000 + 1, t/1000):
            if B[j] < MIN:
                MIN = B[j]
         
        #right range
        for i in xrange(t/1000 * 1000, t+1):
            if A[i] < MIN:
                MIN = A[i]
    print MIN   
     
for i in xrange(q):
    com, s, t = map(int,raw_input().split())
    if com: #find
        find(s,t)
    else: #update
        update(s,t)

Measured memory_bytes: 6112
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 }
}

Measured memory_bytes: 28652
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    double L;
    cin >> L;
    fixed(cout);
    cout.precision(6);
    cout << (L/3)*(L/3)*(L/3);
}


Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  a[i] = -a[i]
heapq.heapify(a)
for i in range(m):
  l = -heapq.heappop(a)
  heapq.heappush(a,-(l//2))
print(-sum(a))

Measured memory_bytes: 14180
//In the name of God

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

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

const int N = 1e5+10 , mod = 1e9+7;

string t = "keyence";

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   string s;
   cin >> s;
   if(s == t)
      return cout << "YES" , 0;
   int n = s.length();
   for(int i = 0 ; i < n ; i++){
      for(int j = i ; j < n ; j++){
         string ret = "";
         for(int k = 0 ; k < n ; k++)
            if(k < i || k > j)
               ret += s[k];
         if(ret == t)
            return cout << "YES" , 0;
      }
   }
   cout << "NO";
   return 0;
}


Measured memory_bytes: 256
x, y=map(int, input().split())

s=0

if (x==3):  s+=100000

if (x==2): s+=200000

if (x==1): s+=300000

if (y==3): s+=100000

if (y==2): s+=200000

if (y==1): s+=300000

if (s==600000): s+=400000

print(s) 

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

vii li;

void perm(int cur, vi cur_v, int n, int m){
    if(n==0){
        li.pb(cur_v);
        return;
    }
    for(int num = cur; num <= m; num++){
        vi v2;
        rep(i, 0, cur_v.size()){
            v2.pb(cur_v[i]);
        }
        v2.pb(num);
        perm(num, v2, n-1, m);
    }
}

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vii query(q, vi());
    rep(i, 0, q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        query[i].pb(a);
        query[i].pb(b);
        query[i].pb(c);
        query[i].pb(d);
    }
    vi ini;
    int a, b, c, d;
    perm(1, ini, n, m); 
    ll ans = 0;
    rep(i, 0, li.size()){
        ll sc = 0;
        rep(j, 0, q){
            a = query[j][0];
            b = query[j][1];
            c = query[j][2];
            d = query[j][3];
            a--;
            b--;
            if(li[i][b]-li[i][a] == c) sc += d;
        }
        ans = max(ans, sc);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 9868
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{x:i32,y:i32,z:i32};

    let mut mx = 0;
    for i in 1..x+1 {
        let w = x - 2*z - (i-1)*z;
        if w/y >= i {
            //debug!(w,w/y,i);
            mx = max(mx, i);
        }
    }
    println!("{}",mx);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    int ans = 0;
    rep(i, s.size()) if(s[i]=='1') ans++;
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;typedef vector<int> vi;typedef vector<ll> vll;
typedef pair<int,int> ii;typedef map<int,int> mii;
inline void rvi(vi &v, int n){int temp; rep(i,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll &v, int n){ll temp;rep(i,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline vll prefixsum(vi &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-2;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-2;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
void solve();int main(){ios;solve();return 0;}
//--------SOLVE--------------------------------------------------------------------
void solve()
{
	vi a(3);
	rep(i,3) 
	{
		cin>>a[i];
	}
	isort(a);
	cout<<(a[0]*a[1])/2<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long double a, b, h, m;
  cin>>a>>b>>h>>m;
  long double theta = M_PI * 2 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0);
  long double res=(a*a + b*b - 2*a*b*cos(theta));
  printf("%20.20Lf\n", sqrtl(res));
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1000000000 + 7;
const int N = 310;

typedef long long ll;

ll n;
deque <ll> a;
vector <ll> d;

inline void solve()
{
    scanf("%lld", &n);

    while(n)
    {
        if(n % 2 == 1)
        {
            d.pb(1);
            n /= 2;
        }
        else
        {
            d.pb(0);
            n --;
        }
    }

    int c = 1;

    for(int i = d.size() - 1; i >= 0; i --)
    {
        if(d[i] == 1)
            a.pb(c);
        else
            a.push_front(c);
        c ++;
    }
    cout << a.size() * 2 << endl;
    for(int i = 0; i < a.size(); i ++)
        cout << a[i] << " ";
    for(int i = 1; i < c; i ++)
        cout << i << " ";
}

int tests = 1;

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

    while(tests --)
        solve();
}


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

using namespace std;

int main() {
	int N, maxv = -1,count,num,memo;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		count = 0;
		num = i;
		while(num>=2){
			if (num % 2 == 0) {
				num /= 2;
				count++;
			} else {
				break;
			}
		}
		if (max(maxv, count) == count) {
			maxv=count ;
			memo = i;
		}
	}
	cout << memo << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
bool sortinrev(const pair<int, int>& a, const pair<int, int>& b) {
    return a.first + a.second > b.first + b.second;
}
 
int main()
{
    fast();
    long long  n  , i , g , l , cnt =0 , ans ;
    double d ; 
    cin>>n;
    long long int a[n] ;
    for(i=0;i<n;i++)
    	cin>>a[i] ;
    ans = a[0] ; 
    for(i=1;i<n;i++)
    	 ans = ( ( (a[i] * ans) ) /  (__gcd(a[i], ans) ) ); 
	for(i=0;i<n;i++)
		cnt+= ans/ a[i] ; 
	d = (double)ans/(double)cnt ; 
	printf("%0.10f",d);
	
	
	return 0 ;
}

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

int main(void)
{
  int n,x,y,i,j,k=0,l=0,m=0;
  int a[101],b[101];


  m=1;
  do{
    cin >> n >> x;
    a[m] = n;  b[m] = x;
    m = m+1;
  }while(n != 0 || x != 0);

  for(k = 1; k < m-1; k++){
    n = a[k];  x = b[k];
    l = 0;
    for(i = 1; i <= n-2; i++){
      for(j = i+1; j <= n-1; j++){
        y = x-j-i;
        if(y > j && y <= n) {
          l = l+1;
        }
      }
    }
    cout << l << endl;
  }

  return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 40010
using namespace std;
int p[maxn],dp[maxn][15];
int c[15][15];
int n,m;
void init(){//printf("&\n");
		for(int i=0;i<(1<<n);i++)for(int j=0;j<n;j++)dp[i][j]=-1;
		for(int i=0;i<(1<<n);i++){
				for(int j=0;j<n;j++){
						if((i>>j)&1){
								for(int k=j+1;k<n;k++){
										if((i>>k)&1){
												p[i]+=c[j][k];
										}
								}
						}
				}
		}
		//	printf("&&\n");
}
int main(){
		while(~scanf("%d%d",&n,&m)){
				//scanf("%d%d",&n,&m);
				int sum=0;
				memset(c,0,sizeof c);
				while(m--){
						int u,v,w;scanf("%d%d%d",&u,&v,&w);
						u--;v--;sum+=w;
						c[u][v]=c[v][u]=w;
				}
				memset(p,0,sizeof p);init();
				dp[1][0]=0;
				for(int i=0;i<(1<<n);i++){
						for(int j=0;j<n;j++){
								if(dp[i][j]==-1)continue;
								int x=(((1<<n)-1)^i)|(1<<j);
								for(int y=x;y>=0;y--){
										y&=x;
										dp[i|y][j]=max(dp[i|y][j],dp[i][j]+p[y]);
								}
								for(int k=0;k<n;k++){
										if(!c[j][k])continue;
										if((i>>k)&1)continue;
										dp[i|(1<<k)][k]=max(dp[i|(1<<k)][k],dp[i][j]+c[j][k]);
								}//printf("&\n");
						}
				}//printf("*");
				int ans=1e9+7;
				for(int i=0;i<(1<<n);i++){
						ans=min(ans,sum-dp[i][n-1]);
				}
				printf("%d\n",ans);
		}
		return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
 
int main(){
  char S[1001];
  
  scanf("%s",&S);
  
  int i=0;
  i=strlen(S);
  
  if(S[i-1]=='s'){
    printf("%ses",S);
  }
  else{
    printf("%ss",S);
  }
  
  
  return 0;
  
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int n,h[100000],f[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
    f[h[i]-1]=i+1;
  }
  for(int i=0;i<n;i++){
    cout<<f[i]<<" ";
  }
  cout<<endl;
  return 0;
  }


Measured memory_bytes: 1536
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  int h[100005];
  int flag = 0;
  for(int i=1; i<=n; i++)  scanf("%d", h+i);
  for(int i=n; i>1; i--){
    if(h[i-1] > h[i]){
      h[i-1] -= 1;
      if(h[i-1] > h[i]){
	flag = 1;
	break;
      }
    }
  }
  if(flag)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}


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

int main() {
  
  int N; cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  if (N == 1) { cout << vec[0] << endl; return 0; }
  
  int tmp = __gcd(vec[0], vec[1]);
  
  for (int i = 2; i < N; i++) tmp = __gcd(tmp, vec[i]);
  
  cout << tmp << endl;
  
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int ans = 0;
    bool isOK = true;
    while(true){
        for(int i = 0; i < N; i++){
            if(a.at(i) % 2 != 0){
                isOK = false;
                break;
            }
        }
        if(isOK == false) break;

        
        for(int i = 0; i < N; i++){
                a.at(i) /= 2;
        }
        ans++;

    }    
    cout << ans << endl;
}

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


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

ll n,k;
cin>>n>>k;

ll arr[n+1];

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

sort(arr,arr+n);
ll sum=0;
for(int i=0;i<k;i++)
{
    sum+=arr[i];

}
cout<<sum;
}

Measured memory_bytes: 3652
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main(void){
    int n, m;
    std::cin >> n >> m;
    std::vector<int> h(n);
    for(int i = 0; i < n; ++i){
        int tmp;
        std::cin >> tmp;
        h[i] = tmp;
    }
    std::vector<bool> v(n, true);
    for(int i = 0; i < m; ++i){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        if(h[tmp1 - 1] <= h[tmp2 - 1]) v[tmp1 - 1] = false; 
        if(h[tmp2 - 1] <= h[tmp1 - 1]) v[tmp2 - 1] = false;
    }
    n = 0;
    for(int i = 0; i < v.size(); ++i) if(v[i]) ++n;
    std::cout << n << std::endl;

    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
const int MOD = 1000000007;
const ll INF = 1e18 + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
string s; ll k;
vector<vector<pii>> dp;

pii solve(int l, int r)
{
	if (dp[l][r].first >= 0) return dp[l][r];
	pii res(INF, INF);
	if (l == r) return pii(1, 1);
	else if (r - l == 1)
	{
		if (s[l] == s[r]) res = pii(2, 1);
		else res = pii(3, 2);
	}
	else
	{
		if (s[l] == s[r]) res = pii(solve(l + 1, r - 1).first + 2, solve(l + 1, r - 1).second);
		else
		{
			pii tmp1 = solve(l + 1, r), tmp2 = solve(l, r - 1);
			if (tmp1.first == tmp2.first) res = pii(tmp1.first + 2, tmp1.second + tmp2.second);
			else res = pii(min(tmp1, tmp2).first + 2, min(tmp1, tmp2).second);
		}
	}
	return dp[l][r] = pii(res.first, min(res.second, INF));
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> s >> k;
	dp.resize(2222, vector<pii>(2222, pii(-1, -1)));
	int n = s.size();
	ll len = solve(0, n - 1).first, c = solve(0, n - 1).second;
	if (c < k)
	{
		cout << "NONE" << endl;
		return 0;
	}
	k--;
	string ans(len, '#');
	int ansl = 0, ansr = len - 1, tmp = 0, l = 0, r = n - 1;
	while(1)
	{
		if (l == r)
		{
			ans[ansl] = s[l];
			break;
		}
		if (l > r) break;
		if (s[l] == s[r])
		{
			ans[ansl] = ans[ansr] = s[l];
			ansl++; ansr--;
			l++; r--;
		}
		else
		{
			bool f;
			if (solve(l + 1, r).first < solve(l, r - 1).first) f = true;
			else if (solve(l, r - 1).first < solve(l + 1, r).first) f = false;
			else
			{
				if (s[l] < s[r])
				{
					if (solve(l + 1, r).second <= k)
					{
						k -= solve(l + 1, r).second;
						f = false;
					}
					else f = true;
				}
				else if(s[l] > s[r])
				{
					if (solve(l, r - 1).second <= k)
					{
						k -= solve(l, r - 1).second;
						f = true;
					}
					else f = false;
				}
			}
			if (f)
			{
				ans[ansl] = ans[ansr] = s[l];
				ansl++; ansr--;
				l++;
			}
			else
			{
				ans[ansl] = ans[ansr] = s[r];
				ansl++; ansr--;
				r--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80296
#include <iostream>
using namespace std;
int main(void){
    int h, w, i, j;
    
    while(1){
    
        cin >> h >> w;
        if(h == 0 && w == 0){
           break;
        }
        else{
            for(i = 0; i < h; i++){
                for(j = 0; j < w; j++){
                    if(j != 0 && j != (w-1) && i != 0 && i != (h-1)){
                        cout << ".";
                    }
                    else{
                        cout << "#";
                    }
                }cout << endl;
            }
        cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll s[100001];
ll parents[100001];
ll p[100001];
ll root(ll x){
  if(parents[x] == x){
    return x;
  }else{
    return parents[x] = root(parents[x]);
  }
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(ll x, ll y){
  x = root(x);
  y = root(y);
  if(x == y) return;
  parents[x] = y;
}

int A[100000];
int B[100000];
ll diff;
ll ans[100000];

int main(){
  ll N, M;
  cin >> N >> M;
  rep(i, 1, N + 1){
    parents[i] = i;
    s[i] = 1;
  }
  rep(i, M){
    cin >> A[i];
    cin >> B[i];
  }

  rrep(i, M){
    if(i == M - 1){
      ans[i] = N * (N - 1) / 2;
    }else{
      ans[i] = ans[i + 1] - diff;
    }
    int a = A[i];
    int b = B[i];
    if(same(a, b)){
      diff = 0;
    }else{
      int sizeA = s[root(a)];
      int sizeB = s[root(b)];
      unite(a, b);
      s[root(a)] = sizeA + sizeB;
      diff = sizeA * sizeB;
    }
  }
  rep(i, M){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std ;
using ll = long long ;

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


int main(){
	ll a,b,c,d ;
	cin >> a >> b >> c >> d ;
	cout << (b-(b/c+b/d-b/(c/gcd(c,d)*d)))-(a-1-((a-1)/c+(a-1)/d-(a-1)/(c/gcd(c,d)*d))) << endl ;
}

Measured memory_bytes: 256
n = int(input())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int,input().split())
 
a = sorted(a)
b = sorted(b)
 
if n%2!=0:
    ans = b[(n-1)//2] - a[(n-1)//2] + 1
else:
    ans = (b[n//2-1] + b[n//2]) - (a[n//2-1] + a[n//2]) + 1
 
print(ans)

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

unsigned long long c=0;
int A[100000000];

void marge(int A[], int left, int mid, int right){
  int n1=0,n2=0;
  int L[500100];
  int R[500100];
  n1=mid-left;
  n2=right-mid;
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INT_MAX;
  R[n2]=INT_MAX;
  int j=0;
  int i=0;
  for(int k=left;k<right;k++){
    
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      
    }
    else {
      A[k]=R[j];
      j++;
      c=c+n1-i;
    }
  }
}

void margesort(int A[], int left, int right){
  int mid=0;
  if(left+1<right){
    mid=(left+right)/2;
    margesort(A,left,mid);
    margesort(A,mid,right);
    marge(A,left,mid,right);
  }
}

int main(){
  int n=0;
  int left=0,right=0;
  //int S[100000000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  left=0;
  right=n;
  margesort(A,left,right);
  /*for(int i=0;i<n;i++){
    if(i!=0)cout<<" ";
    cout<<A[i];
    }*/
  printf("%llu\n",c);
  
  return 0;
}




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

using namespace std;

typedef long long int64;

const int mod = 1e9 + 7;

int main()
{
  int N, X[100001];

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

  int64 ret = 1;
  int lastidx = 0;
  for(int i = 1; i < N; i++) {
    ret *= (i - lastidx + 1);
    ret %= mod;
    while((i - lastidx) * 2 + 1 > X[i]) ++lastidx;
  }
  cout << ret << endl;
}

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

int main() {
  
  int men = 700;
  
  string s;
  cin >> s;
  int count = 0;
  
  if ( s[0] == 'o' ) count++;
  if ( s[1] == 'o' ) count++;
  if ( s[2] == 'o' ) count++;
  
  cout << men + 100 * count << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  double sum;
  vector<double> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (A.at(i) != 0) {
      sum += (1 / A.at(i));
    }
  }
  cout << fixed << setprecision(8) << (1 / sum) << endl;
  
}

Measured memory_bytes: 256
def c_daydream(S):
    # Sを逆にしたものから文字列を除いていき、空文字にできるか？
    s = S[::-1]
    n = len(s)
    while True:
        if n == 0:
            return 'YES'
        elif n >= 5 and s[:5] == 'maerd':
            s = s[5:]
        elif n >= 7 and s[:7] == 'remaerd':
            s = s[7:]
        elif n >= 5 and s[:5] == 'esare':
            s = s[5:]
        elif n >= 6 and s[:6] == 'resare':
            s = s[6:]
        else:
            return 'NO'
        n = len(s)
    return None

S = input().strip()
print(c_daydream(S))

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	int a[105];
	rep(i, n) cin >> a[i];

	f = 0;
	rep(i, n){
		rep(j, n){
			if(i == j) continue;
			f = max(f, a[i] - a[j]);
		}
	}

	cout << f <<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
assert 2*M+1 <= N

if M % 2 == 1:
    step_m1 = M
    step_m2 = M - 1
else:
    step_m1 = M - 1
    step_m2 = M
assert step_m1 + 1 + step_m2 + 1 <= N
ans = []
a = 0
for step in range(step_m1, -1, -2):
#     print(step)
#     print(a, a+step)
    ans.append([a+1, a+step+1])
    a += 1
a = step_m1 + 1
for step in range(step_m2, 0, -2):
#     print(step)
#     print(a, a+step)
    ans.append([a+1, a+step+1])
    a += 1
print('\n'.join(map(lambda L: ' '.join(map(str, L)), ans)))

Measured memory_bytes: 30020
N = list(map(int,input().split()))
N.sort()
A = N[0]
B = N[1]
C = N[2]
ans = 0
if max(N) == min(N):
  print(ans)
  exit()
if (B-A)%2 == 0:
  ans += (B-A)//2 + C - B
else:
  ans += 1
  B += 1
  C += 1
  ans += (B-A)//2 + C - B
  
print(ans)
  

Measured memory_bytes: 38384
def numSort(a, b, c)
	arr = [a, b, c]
	result = arr.sort
	return sprintf('%d %d %d', result[0], result[1], result[2])
end

input = gets.chomp
a, b, c = input.split(' ').map(&:to_i)
puts numSort(a, b, c)

Measured memory_bytes: 8628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  if (X == 1 || X == 2 * N - 1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;

    vector <int> ans(2 * N - 1);
    vector <bool> checked(2 * N);

    ans[N - 1] = X; checked[X] = true;
    ans[N - 2] = 2 * N - 1; ans[N] = 1;
    checked[2 * N - 1] = true; checked[1] = true;

    if (checked[2 * N - 2] == false && N > 2){
      checked[2 * N - 2] = true;
      ans[N - 3] = 2 * N - 2;
    }
    if (checked[2] == false && N > 2){
      checked[2] = true;
      ans[N + 1] = 2;
    }
    
    int now = 1;
    for (int i = 0; i < 2 * N - 1; i++){
      if (ans[i] == 0){
        while (checked[now] != false){
          now++;
        }
        ans[i] = now;
        checked[now] = true;
      }
    }
    
    for (int i = 0; i < 2 * N - 1; i++){
      cout << ans[i] << endl;
    }
    

  }
  
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 3;

int main() {
    
    
    int a[N], n;
  
        n = 3;
        for(int i = 0 ; i <n ; ++ i)
            
            cin>>a[i];
    
        int ans = abs(a[1] - a[0]) + abs(a[2] - a[1]);
        do {
            ans = min(ans, abs(a[1] - a[0]) + abs(a[2] - a[1]));
        } while(next_permutation(a , a +  3));
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 764
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
index = 0
f = 0
ans = [0,0]
for i in range(N+1):
    if (i == A[index]):
        ans[f] += 1
        index = min(index+1,M-1)
    if (i == X):
        f += 1

print(min(ans))




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

int main() {
	int N;
	double v[50];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> v[i];

	//vを低い順（昇順）にソートして、値が低い方から合成をする
	sort(v, v + N);
	double value;
	for (int i = 1; i < N; i++) {
		if (i == 1)
			value = (v[0] + v[1]) / 2.0;
		else
			value = (value + v[i]) / 2.0;
	}
	cout << setprecision(6) << value << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	cout << "ABC" << N;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

ABCとNを合成して出力すればおｋ
*/

Measured memory_bytes: 256
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let mut v:Vec<u32> = (0..3).map(|_|sc.read()).collect::<Vec<u32>>();
    v.sort();
    println!("{} {} {}",v[0], v[1], v[2]);
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 5024
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int main()
{
    std::ios::sync_with_stdio(false);
    int K,S;
    cin >> K >> S; 
    int ans = 0; 
    for(int i=0;i<=K;i++)
    {
        for(int j=0;j<=K;j++)
        {
            int cnt = S-i-j;
            if(cnt>=0 && cnt<=K) ans++;
        }
    }
    cout << ans << endl;
    //system("pause");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	int r=101,l=0,i;
	cin>>a;
	for(i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			r=i;
			break;
		}
	}
	for(i=a.size()-1;i>=0;i--)
	{
		if(a[i]=='F')
		{
			l=i;
			break;
		}
	}
	if(r<l)
	cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(long x, long y) {
  if(y > x) {
    int tmp = x;
    x = y;
    y = tmp;
  }

  int mod = x % y;
  if(mod == 0) {
    return y;
  }

  return gcd(y, mod);
}


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

  cout << A * B / gcd(A, B);

  return 0;
}


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

int main(){
    int n; string s; cin >> n >> s;
    int ans=0;
    rep(i,n-2){
        if((s[i]=='A') &&(s[i+1]=='B') &&(s[i+2]=='C')) ans++;
    }
    cout << ans << endl;
return 0;
}


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

/**
 *
 * Let dp[mask] be the number of ways to find graph matchings between 1,..,x to mask
 * Where x is # of bits in mask
 * For all x,v connected and v in mask
 * We get dp[mask^(1<<v)] ways 
 */
public class Main {

    static int MOD=1000000007;
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int N=Integer.parseInt(br.readLine());
        boolean[][] arr=new boolean[N][N];
        for (int i = 0; i < N; i++) {
            StringTokenizer st=new StringTokenizer(br.readLine());
            for (int j = 0; j < N; j++) {
                if(Integer.parseInt(st.nextToken())==1){
                    arr[i][j]=true;
                }
            }
        }
        int[] dp=new int[1<<N];  dp[0]=1;int x=0;
        for (int mask = 1; mask < (1<<N); mask++) {
            x=-1;
            for (int j = 0; j < N; j++) {
                if((mask&(1<<j))>0){
                    x++;
                }
            }
            //Go from x to x-1
            for (int i = 0; i < N; i++) {
                if((mask&(1<<i))>0 && arr[i][x]){
                    dp[mask]+=dp[mask^(1<<i)];
                    dp[mask]%=MOD;
                }
            }
        }
        System.out.println(dp[(1<<N)-1]);
    }
    
}


Measured memory_bytes: 41224
def gcd(x, y): 
      
    while(y): 
        x, y = y, x % y 
      
    return x 
 
n=int(input())
a=list(map(int,input().split()))
x=1
ans=0
for i in a:
    x=(x*i)//gcd(x,i)
for i in a:
    ans+=(x//i)
ans=ans%(1000000007)
print(ans)

Measured memory_bytes: 4084
#include<vector>
#include<iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
ll m=1e9+7;
ll ans;
int node=1;
int n;
ll an[1000005];

ll inv(ll a)
{
	ll b=m-2;
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		a=(a*a)%m;
		b=b>>1;
	}
	return ans;
}

void dfs(int i, vector<int> *v, vector<bool> &vis, vector<ll> &dp, vector<int> &sz, vector<ll> &f)
{
	vis[i]=1;
	dp[i]=1;
	sz[i]=1;
	ll l=v[i].size();
	lp(j,0,l)
	{
		if(!vis[v[i][j]])
		{
			dfs(v[i][j],v,vis,dp,sz,f);
			sz[i]=sz[i]+sz[v[i][j]];
			dp[i]=(dp[i]*dp[v[i][j]])%m;
			dp[i]=(dp[i]*inv(f[sz[v[i][j]]]))%m;
		}
	}
	dp[i]=(dp[i]*f[sz[i]-1])%m;
}

void solve(int i, vector<int> *v, vector<bool> &vis, vector<int> &sz, vector<ll> &f)
{
	ll temp;
	vis[i]=1;
	ll l=v[i].size();
	lp(j,0,l)
	{
		if(!vis[v[i][j]])
		{
			temp=(an[i]*((sz[v[i][j]]*inv(n-sz[v[i][j]]))%m))%m;
	//		if(v[i][j]==4)
	//			cout<<temp<<endl;
			if(temp>=ans)
			{
				if(ans==temp)
				{
					if(node<v[i][j])
						node=v[i][j];
				}
				else
					node=v[i][j];
				ans=temp;
			}
			an[v[i][j]]=temp;
			solve(v[i][j],v,vis,sz,f);
		}
	}
}

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int t=1;
//	cin>>t;
	while(t--)
	{
		node=1;
		cin>>n;
	//	cout<<"#";
		vector<int> v[n+1];
		vector<bool> vis(n+1, 0);
		vector<ll> dp(n+1,1);
		vector<int> sz(n+1,0);
		vector<ll> f(n+1,1);
		f[0]=1;
		lp(i,1,n+1)
			f[i]=(i*f[i-1])%m;
		lp(i,0,n-1)
		{
			int a,b;
			cin>>a>>b;
			v[a].pb(b);
			v[b].pb(a);
		}
		dfs(1,v,vis,dp,sz,f);
		ans=dp[1];
		an[1]=dp[1];
		fill(vis.begin(),vis.end(),0);
		solve(1,v,vis,sz,f);
	//	cout<<node<<" "<<ans<<"\n";
		lp(i,1,n+1)
			cout<<an[i]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 19444
#include<stdio.h>
#include<algorithm>
using namespace std;
struct node{
	long long size;
	int val;
	int num;
	bool operator<(node b) const
	{
		return val*b.size>b.val*size;
	}
};
node nn[64];
int p[64];
long long dp[131072];
int x[131072];
long long y[131072];
void add(long long size,int val,int num)
{
	for(int i=0;i<val;i++)
	{
		int l=0,r=-1;
		for(int j=0;j*val+i<=125000;j++)
		{
			while(l<=r)
			{
				if(dp[j*val+i]-size*j>y[r])
				{
					break;
				}
				r--;
			}
			while(l<=r)
			{
				if(x[l]>=j-num)
				{
					break;
				}
				l++;
			}
			r++;
			x[r]=j;
			y[r]=dp[j*val+i]-size*j;
			dp[j*val+i]=y[l]+size*j;
		}
	}
}
int main()
{
	int n,x,d;
	scanf("%d%d%d",&n,&x,&d);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&nn[i].size);
		if(i)
		{
			scanf("%d",&p[i]);
			p[i]--;
			nn[i].num=d;
		}
		else
		{
			nn[i].num=x;
		}
		nn[i].val=1;
	}
	for(int i=n-1;i>0;i--)
	{
		nn[p[i]].size+=nn[i].size;
		nn[p[i]].val+=nn[i].val;
	}
	sort(nn,nn+n);
	for(int i=1;i<=125000;i++)
	{
		dp[i]=1000000000000000000LL;
	}
	for(int i=0;i<n;i++)
	{
		if(nn[i].num<50)
		{
			add(nn[i].size,nn[i].val,nn[i].num);
			nn[i].num=0;
		}
		else
		{
			add(nn[i].size,nn[i].val,50);
			nn[i].num-=50;
		}
	}
	int ans=0;
	for(int i=0;i<=125000;i++)
	{
		if(dp[i]>x)
		{
			continue;
		}
		int rm=x-dp[i];
		int answer=i;
		for(int j=0;j<n;j++)
		{
			int num=rm/nn[j].size;
			if(num>nn[j].num)
			{
				num=nn[j].num;
			}
			answer+=num*nn[j].val;
			rm-=num*nn[j].size;
		}
		if(answer>ans)
		{
			ans=answer;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(snip_i, m) cin >> a.at(snip_i);
  vector<mint> dp(n+3, 0);
  int im = 0;
  dp.at(0) = 1;
  rep(i, n){
    if(im < a.size() && i == a.at(im)){
      im++;
      continue;
    }
    dp.at(i+1) += dp.at(i);
    dp.at(i+2) += dp.at(i);
  }
  cout << dp.at(n).x << endl;
  return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  ll ans;
  ans = 1000 * (x / 500);
  ans += 5 * ((x % 500) / 5);
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n; cin >> n;
  vi t(n); re(i, n) cin >> t[i];
  int m; cin >> m;
  vi p(m), x(m); re(j, m) cin >> p[j] >> x[j];

  int sum = 0;
  re(i, n) sum += t[i];
  re(j, m) {
    cout << sum - t[p[j]-1] + x[j] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#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字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }



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

	int a, b; cin >> a >> b;
	int n = b-a;
	int len = n*(n+1)/2;
	cout << len-b << endl;

	return 0;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    xxyy = [list(map(str, input().split())) for _ in range(n)]
    xxyy = sorted(xxyy, key=lambda x: (int(x[0]), int(x[1]), x[2], int(x[3]), x[4]))
    for xy in xxyy:
        print(*xy)


resolve()



Measured memory_bytes: 64868
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int a,b;
    cin >> a >> b;
    if(a<=b)
      cout<<a;
    else
      cout<<a-1;

	return 0;
	// BYE BYE
}


Measured memory_bytes: 256
#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    inf          1e9
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
///typedef pair<int,vi> pp;

int dr[8]= {0,0,-1,1,-1,-1,+1,+1};
int dc[8]= {-1,1,0,0,-1,+1,-1,+1};

const int N=1000005;

int main()
{
    int n;
    cin>>n;
    int cnt=0,res=0;
    fr(i,1,n)
    {
        int x,y;
        cin>>x>>y;
        if(x==y)cnt++;
        else if(x!=y)cnt=0;
        if(cnt==3)
        {
            res=1;
        }
    }
    if(res)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n;
    string s;
    cin >> n;
    cin >> s;
    ll _max = 0;
    for(ll i = 1; i <= n - 1; i++)
    {
        vector<ll> a(26, 0), b(26, 0);
        ll temp = 0;
        for(ll k = 0; k < i; k++)
        {
            a[(ll)(s[k] - 'a')]++;
        }
        for(ll k = i; k < n; k++)
        {
            b[(ll)(s[k] - 'a')]++;
        }

        for(ll k = 0; k < 26; k++)
        {
            if(a[k] != 0 && b[k] != 0)
                temp++;
        }
        _max = max(temp, _max);
    }

    cout << _max << endl;    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=20010,M=80010;
int n,va[N],op[N];
pair<int,int> lh[N];

const int xb=N-5;
int id[N<<1],size;
vector<int> g[M];
int sta[M],top,dfn[M],low[M],col[M],colnum,dfsclock;
inline void add(int x,int y){
	g[x].push_back(y);
}
inline void seg_add(int fr,int x,int y){
	for (int l=xb+x-1,r=xb+y+1;l^r^1;l>>=1,r>>=1){
		if (~l&1) add(fr,id[l^1]);
		if (r&1) add(fr,id[r^1]);
	}
}
inline void tarjan(int x){
	dfn[x]=low[x]=++dfsclock;sta[++top]=x;
	for (vector<int>::iterator to=g[x].begin();to!=g[x].end();++to)
		if (!dfn[*to]) tarjan(*to),low[x]=min(low[x],low[*to]);
		else if (!col[*to]) low[x]=min(low[x],dfn[*to]);
	if (low[x]==dfn[x]){
		col[x]=++colnum;
		while (sta[top]!=x) col[sta[top--]]=colnum;
		--top;
	}
}
inline bool check(int d){
	for (int i=1;i<=size;++i) g[i].clear(),dfn[i]=col[i]=0;
	colnum=dfsclock=0;
	size=2*n;
	for (int i=xb+1;i<=xb+2*n;++i) id[i]=++size,add(id[i],lh[i-xb].second);
	for (int i=xb;i;--i)if (id[i<<1]||id[i<<1|1]){
		id[i]=++size;
		if (id[i<<1]) add(id[i],id[i<<1]);
		if (id[i<<1|1]) add(id[i],id[i<<1|1]);
	}
	for (int i=1;i<=2*n;++i){
		int ip=lower_bound(lh+1,lh+2*n+1,make_pair(va[i],op[i]))-lh;
		int lp=upper_bound(lh+1,lh+2*n+1,make_pair(va[i]-d,int(2e9)))-lh;
		int rp=lower_bound(lh+1,lh+2*n+1,make_pair(va[i]+d,0))-lh-1;
		seg_add(i,lp,ip-1);
		seg_add(i,ip+1,rp);
	}
	for (int i=1;i<=size;++i) if (!dfn[i]) tarjan(i);
	for (int i=1;i<=n;++i) if (col[i]==col[i+n]) return 0;
	return 1;
}
int main(){
//	freopen("A.in","r",stdin);freopen("A.out","w",stdout);
	scanf("%d",&n);
	int cnt=0;
	for (int i=1;i<=n;++i) 
		scanf("%d%d",&va[i],&va[i+n]),
		lh[++cnt]=make_pair(va[i],i+n),
		lh[++cnt]=make_pair(va[i+n],i),
		op[i]=i+n,op[i+n]=i;
	sort(lh+1,lh+cnt+1);
	
	int ans=0;
	for (int l=1,r=lh[2*n].first,mid;l<=r;mid=(l+r)>>1,check(mid)?ans=mid,l=mid+1:r=mid-1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 9088