akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h1,m1,h2,m2,K;cin>>h1>>m1>>h2>>m2>>K;
    int a=h1*60+m1,b=h2*60+m2;
    cout<<max(0,b-a-K)<<endl;
}



Measured memory_bytes: 3624
import math

A, B, H, M = map(int, input().split())
degree = abs(6 * M - 30 * (H+M/60))
if degree > 180:
    degree = 360 - degree
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(degree))))


Measured memory_bytes: 9472
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, q: usize,
        tuv: [(usize, usize, usize); q]
    }

    let mut dsu = DSU::new(n);
    
    for (t, u, v) in tuv {
        match t {
            0 => {
                dsu.merge(u, v);
            }
            1 => {
                let res = dsu.same(u, v) as u8;
                println!("{}", res);
            }
            _ => unreachable!()
        }
    }
}
#[allow(dead_code)]
pub struct DSU {
    parent_or_size: Vec<isize>,
}

#[allow(dead_code)]
impl DSU {
    pub fn new(n: usize) -> Self {
        assert!(n <= std::isize::MAX as usize);
        Self {
            parent_or_size: vec![-1; n],
        }
    }

    pub fn merge(&mut self, a: usize, b: usize) -> usize {
        let mut x = self.leader(a);
        let mut y = self.leader(b);
        if x == y {
            return x;
        }
        if -self.parent_or_size[x] < -self.parent_or_size[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent_or_size[x] += self.parent_or_size[y];
        self.parent_or_size[y] = x as isize;
        x
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.leader(a) == self.leader(b)
    }

    pub fn leader(&mut self, a: usize) -> usize {
        if self.parent_or_size[a] < 0 {
            a
        } else {
            self.parent_or_size[a] = self.leader(self.parent_or_size[a] as usize) as isize;
            self.parent_or_size[a] as usize
        }
    }

    pub fn size(&mut self, a: usize) -> usize {
        let leader = self.leader(a);
        -self.parent_or_size[leader] as usize
    }

    pub fn groups(&mut self) -> Vec<Vec<usize>> {
        let mut leader_buf = vec![0usize; self.parent_or_size.len()];
        let mut group_size = vec![0usize; self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            leader_buf[i] = self.leader(i);
            group_size[leader_buf[i]] += 1;
        }
        let mut result = vec![Vec::new(); self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            result[i].reserve(group_size[i]);
        }
        for i in 0..self.parent_or_size.len() {
            result[leader_buf[i]].push(i);
        }
        result.retain(|v| !v.is_empty());
        result
    }
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int X = 1001000;
signed main() {
	vector<bool>prime(X, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i <= sqrt(X); i++) {
		if (prime[i]) {
			for (int j = i * 2; j < X; j += i) {
				prime[j] = false;
			}
		}
	}
	int n, x;
	while (cin >> n >> x,n||x) {
		vector<bool>money(x+100, false); money[0] = true;
		vector<int>v(n); rep(i, 0, n)cin >> v[i];
		rep(i, 0, n) {
			rep(j, 0, x+100 - v[i]) {
				if (money[j]) {
					money[j + v[i]] = true;
				}
			}
		}
		int ans(-1);
		for (int i = x ; i >= 1; i--) {
			if (prime[i] && money[i]) {
				ans = i;
				break;
			}
		}
		if (ans == -1)cout << "NA" << endl;
		else cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>
#include <stdlib.h>
#define QSIZE 100005

typedef struct pp{
  char name[100];
  int time;
} P;

P queue[QSIZE];
int head=0,tail=0;

void enqueue(P y)
{
int next=(tail+1)%QSIZE;
if(next==head){
  printf("Queue overflow\n");
  exit(2);
}
queue[tail]=y;
tail=next;
}

P dequeue(void)
{
  P x;
  if(head ==tail){
    printf("Queue is empty\n");
    exit(3);
  }
  x=queue[head];
  head=(head+1)%QSIZE;
  return x;
}

int min(int a,int b) { return a<b?a:b; }


int main(){
  int i,n,q,time,min,sum=0;
  P a;

  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s %d",queue[i].name,&queue[i].time);
    enqueue(queue[i]);
  }
  while(head!=tail){
  a=dequeue();
  if(q<a.time) {
    a.time-=q;
    enqueue(a);
    sum+=q;
  }else{
    sum+=a.time;
    printf("%s %d\n",a.name,sum);
  }
  }
  return 0;
}



Measured memory_bytes: 11876
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<deque>
#include<functional>
#include<numeric>
#include<bitset>
#include<cassert>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
/////////////////////

int const N = 2e3 + 41;
int const M = 4e6 + 41;

int n, a[N];
int ans;

bool bit(int m, int i){
	return (m & (1 << i));
}

bitset<M> d;

void print(vi v){
	printf("{ ");
	fi(0, sz(v)) printf("%d,",v[i] + 1);
	printf("}\n");
}

int brute(){
	vector<int> b;
	fi(0, n) b.pb(a[i]);
	vector<pair<int, vi>> v;
	fi(1, (1<<n)){
		vector<int> vv;
		int x = 0;
		fj(0, n){
			if(bit(i, j)){
				x += a[j];
				vv.pb(j);
			}
		}
		v.pb(mp(x, vv));
	}
	sort(v.begin(), v.end());
	
#ifdef _DEBUG
	fi(0, sz(v)){
		printf("%d %d ",i+1,v[i].first);
		print(v[i].second);
	}

#endif
	return  v[sz(v)/2].first;
}

void solve(){
#ifdef _DEBUG
	printf("brute = %d\n",brute());
#endif
	if(n == 1){
		ans = a[0];
		return;
	}
	sort(a, a+n);
	int s = 0;
	fi(0, n) s += a[i];
	d.set(0);
	fi(0, n){
		d |= (d << a[i]);
	}
	//fi(0, 1000) printf("%d\n",d.test(i));
	fi(1, M){
		if(d.test(i)){
			if(i * 2 >= s){
				ans = i;
				return;
			}
		}
	}
	assert(false);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d",&n);
	fi(0, n) scanf("%d",&a[i]);

	solve();

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> values;
int n;
vector<int> operations;
ll memo[2010];
bool done[2010];
ll dp(int a)
{
	if (done[a]) return memo[a];
	done[a] = 1;
	ll ans = 0;
	for (int i = a + 2; i < n; i+=2)
	{
		ans = max(ans, dp(i) + values[i]);
	}
	return memo[a] = ans;
}
void findoptimal(int a, int alreadygone)
{
	pair<ll, int> best = {0, 0};
	for (int i = a + 2; i < n; i+=2)
	{
		best = max(best, { dp(i) + values[i], i });
	}
	if (best.first)
	{
		int s = a-alreadygone;
		int e = best.second-alreadygone;
		while (s != e)
		{
			int mid = (s+e)/2;
			operations.push_back(mid+1);
			alreadygone+=2;
			e-=2;
		}
		findoptimal(best.second, alreadygone);
	}
	else
	{
		int sz = n-a;
		while (sz != 1)
		{
			operations.push_back(sz);
			sz--;
		}
	}
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		ll a;
		scanf("%lld", &a);
		values.push_back(a);
	}
	pair<ll, ll> best = { -2e15, 0 };
	for (int i = 0; i < n; i++)
	{
		best = max(best, { dp(i) + values[i], i });
	}
	//printf("%lld %d\n", best.first, best.second);
	for (int i = 0; i < best.second; i++)
	{
		operations.push_back(1);
	}
	findoptimal(best.second, best.second);
	printf("%lld\n%d\n", best.first, operations.size());
	for (auto a : operations) printf("%d\n", a);
}

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

int main(){
	int i,j,k,n,m,l,z; string s;
	cin >> n;
	vi a(n), b(n);

	rep(i, n) cin >> a[i];
	rep(i, n){
		b[i] = a[i] - i - 1;
	}

	sort(ALL(b));

	m = b[n/2];

	ll x = 0LL;

	rep(i, n){
		x += abs(b[i] - m);
	}

	cout << x << endl;

}

Measured memory_bytes: 1792
n = int(input())
if n%2:
    print(0)
else:
    #2と5があれば10ができる→5の方が少ない→素因数5の数を数える
    ans = (n//5)//2
    tmp = 5
    while True:
        tmp *= 5
        if tmp > n:
            break
        ans += (n//tmp)//2
    print(ans)

Measured memory_bytes: 61576
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+7;
int main()
{
	long long n;
	cin>>n;
	vector<long long> h(n);
	for(long long i=0;i<n;i++){
		cin>>h[i];
	}
	// Initialise the vector elements with INF
	vector<long long> dp(n, INF);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(long long i=2;i<n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4816
#include <stdio.h>

int main()
{
int a[4][13]={0};
int i, j, k, x, n;
char m;

scanf("%d",&n);

for(k = 0; k < n; k++)
{
scanf(" %c %d",&m,&x);
if(m == 'S')
{
	a[0][x - 1] = 1;
}
	
else{
	if(m == 'H')
	{
	a[1][x - 1] = 1;
	}
else{ 
		if(m == 'C')
		{
		a[2][x - 1] = 1;
		}
	else
	{
	if(m == 'D')
	{
		a[3][x - 1] = 1;
	}
		}
}
}
}


for(i = 0; i < 4; i++)
{
	for(j = 0; j < 13; j++)
	{
		if(a[i][j] == 0)
		{
			if(i == 0)
				printf("S %d\n", j + 1);
		else if(i == 1)
				printf("H %d\n", j + 1);
					else if(i == 2)
				printf("C %d\n", j + 1);
		else if(i == 3)
	printf("D %d\n", j + 1);
	}
	}
}

return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    long long N;
    map<ll, ll> A;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        A[a]++;
    }
    if (A.size() == 3)
    {
        vector<pair<ll, ll>> pairs;
        for (auto p : A)
        {

            pairs.push_back(p);
        }
        if ((pairs[0].first ^ pairs[1].first ^ pairs[2].first) == 0 &&
            pairs[0].second == N / 3 && pairs[1].second == N / 3 && pairs[2].second == N / 3)
        {
            cout << "Yes" << endl;

        }else{
            cout << "No" << endl;
        }
    }
    else if (A.size() == 2)
    {
        ll zero_count = A[0];
        ll nonzero_count;
        for (auto p : A)
        {
            if (p.first != 0)
            {
                nonzero_count = p.second;
            }
        }
        if (zero_count == N / 3 && nonzero_count == 2 * N / 3)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else if (A.size() == 1)
    {
        if (A[0] == N)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);

long long v[3100][3100], dp[3100][3100][5];


void solve4ts()
{
    
    int R, C, K;
    cin >> R >> C >> K;
    memset(v, 0, sizeof(v));
    for (int i = 0; i < K; ++i) {
        long long r, c, t;
        cin >> r >> c >> t;
        v[r][c] = t;
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= R; ++i) {
        for (int j = 0; j <= C; ++j) {
            for (int k = 0; k <= 3; ++k) {
                // 上へ行く
                if (i-1 >= 0) {
                    chmax(dp[i][j][0], dp[i-1][j][k]);
                    chmax(dp[i][j][1], dp[i-1][j][k] + v[i][j]);
                }
 
                // 右へ行く
                if (j-1 >= 0) {
                    chmax(dp[i][j][k], dp[i][j-1][k]);
                    if (k-1 >= 0)
                        chmax(dp[i][j][k], dp[i][j-1][k-1] + v[i][j]);
                }
            }
        }
    }
    long long res = 0;
    for (int k = 0; k <= 3; ++k) chmax(res, dp[R][C][k]);
    cout << res << endl;
    
    
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/

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

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

  if(b==0){cout<<a<<endl;}
  else{
    
    vector<int> vec(b);
    
  for(int i=0;i<b;i++){
  cin>>vec.at(i);
  }
   
  for(int i=a;i<=a+100;i++){
    c=0;
    for(int j=0;j<b;j++)
    {if(vec.at(j)==i){c=1;}}
    if(c==0){max=i;
           break;}
  }
    
    for(int i=a;i>=a-100;i--){
    d=0;
    for(int j=0;j<b;j++)
    {if(vec.at(j)==i){d=1;}}
    if(d==0){min=i;
            break;}
  }
   
    if((max-a)<(a-min)){cout<<max<<endl;}
  if((max-a)>=(a-min)){cout<<min<<endl;}
 
  }
  
 
}


Measured memory_bytes: 3592
while True:
    num = list(map(int,input().split()))
    if(num[0] == 0 and num[1] == 0):
        break
    else:
        if(num[0] > num[1]):
            print("%d %d" %(num[1],num[0]))
        else:
            print("%d %d" %(num[0],num[1]))
            


Measured memory_bytes: 5620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

// comb_table
ll C[51][51];

/* add your algorithm here */

void comb_table (int N) {
  rep(i,N+1) {
    rep(j,i+1) {
      if (j == 0 || j == i)
      C[i][j] = 1;
      else
      C[i][j] = (C[i-1][j-1] + C[i-1][j]); // 二項定理
    }
  }
}

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

  const int NMAX = 50;
  ll v[NMAX];

  rep(i,N) cin >> v[i];

  comb_table(N);
  sort(v,v+N);
  reverse(v,v+N);

  double max_average = 0.0;
  rep(i,A) max_average += v[i];
  max_average /= A;

  int a_th_val_num = 0, a_th_val_pos = 0;
  rep(i,N) {
    if (v[i] == v[A-1]) {
      a_th_val_num++;
      if (i < A) {
        a_th_val_pos++;
      }
    }
  }

  ll cnt = 0LL;
  if (a_th_val_pos == A) {
    for (a_th_val_pos = A; a_th_val_pos <= B; ++a_th_val_pos) {
      cnt += C[a_th_val_num][a_th_val_pos];
    }
  } else {
    cnt += C[a_th_val_num][a_th_val_pos];
  }

  cout.precision(20);
  cout << fixed << max_average << endl;
  cout << cnt << endl;
}


Measured memory_bytes: 256
import bisect as bi

def ref(n):
  if n < 6:
    return n
  else:
    s6 = l6[bi.bisect(l6, n)-1]
    s9 = l9[bi.bisect(l9, n)-1]
    return min(n//s6 + ref(n%s6), 1+ref(n-s9))

l6 = [6**i for i in range(7)]
l9 = [9**i for i in range(6)]
print (ref(int(input())))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>

int main() {
	char S[100100];
	int len;
	char v = 'a';
	int flag = 0;
	scanf("%s",S);
	len = strlen(S);
	for(int i = 0; i <= 25; i++) {
		v = 'a' + i;
		for(int j = 0; j < len; j++) {
			if(S[j] == v)
				break;
			if(j == len-1)
				flag = 1;
		}
		if(flag == 1)
			break;
	}
	if(flag != 0)
		printf("%c\n",v);
	else
		printf("None\n");
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	//char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	int c[502],s[502],f[502];

	f(i,0,n-2) cin>>c[i]>>s[i]>>f[i];

	vi v;

	int sum;
	f(i,0,n-2){
	    sum=0;
        f(j,i,n-2){
            if(sum<s[j]) sum=s[j];
            else if(sum%f[j]==0);
            else sum+=(f[j]-(sum%f[j]));
            sum+=c[j];
        }
        v.pb(sum);
	}

    f(i,0,v.size()-1) cout<<v[i]<<endl;

	cout<<0<<endl;
}


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

int main(){
	int H,W;
	cin >> H>>W;
	string A;
	vector<string> vec(W+2,"#");
	for (int i = 0; i < vec.size(); i++) {
		cout << vec.at(i);
	}	
	cout << endl;
	for(int i=0;i<H;i++){
		cout << "#";
		cin >> A;
		cout << A;
		cout << "#";
		cout << endl;
	}
	for (int i = 0; i < vec.size(); i++) {
		cout << vec.at(i);
	}	
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<climits>
#include<math.h>
using namespace std;

int min(const int& a, const int& b){
    return a < b? a : b;
}
int updateUtil(vector<int>& tree, vector<int>& lazy, const int& L, const int& R, const int& v, const int& k, const int& l, const int& r){
    if(k > tree.size() || l > r) return INT_MAX;
    if(lazy[k] >= 0){
        tree[k] = lazy[k];
        if(l < r){
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        lazy[k] = -1;
    }
    if(l > R || r < L) return tree[k];
    if(l >= L && r <= R){
        tree[k] = v;
        if(l < r){
            lazy[2*k+1] = v;
            lazy[2*k+2] = v;
        }
    }
    else{
        int mid = l+(r-l)/2;
        tree[k] = min(updateUtil(tree, lazy, L, R, v, 2*k+1, l, mid), updateUtil(tree, lazy, L, R, v, 2*k+2, mid+1, r)); 
    }
    return tree[k];
}

void update(vector<int>& tree, vector<int>& lazy, const int& n, const int& L, const int& R, const int& v){
    updateUtil(tree, lazy, L, R, v, 0, 0, n-1);
}

int findUtil(vector<int>& tree, vector<int>& lazy, const int& L, const int& R, const int& k, const int& l, const int& r){
    if(k > tree.size() || l > r) return INT_MAX;
    if(lazy[k] >= 0){
        tree[k] = lazy[k];
        if(l < r){
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        lazy[k] = -1;
    }
    if(l > R || r < L) return INT_MAX;
    if(l >= L && r <= R) return tree[k];
    int mid = l+(r-l)/2;
    return min(findUtil(tree, lazy, L, R, 2*k+1, l, mid), findUtil(tree, lazy, L, R, 2*k+2, mid+1, r));
}

int find(vector<int>& tree, vector<int>& lazy, const int& n, const int& L, const int& R){
    return findUtil(tree, lazy, L, R, 0, 0, n-1);
}
int main(){
    int n, q, com, s, t, x;
    scanf("%d %d", &n, &q);
    int h = (int)ceil(log2(n));
    int max_size = 2*(int)pow(2, h)-1;
    vector<int> tree(max_size, INT_MAX);
    vector<int> lazy(max_size, -1);
    for(int i = 0; i < q; i++){
        scanf("%d", &com);
        if(com == 0){
            scanf("%d %d %d", &s, &t, &x);
            update(tree, lazy, n, s, t, x);
        }
        else if(com == 1){
            scanf("%d", &s);
            printf("%d\n", find(tree, lazy, n, s, s));
        }
        else printf("undefined com\n");
    }    
}



Measured memory_bytes: 4780
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    // auto B = A.map!(x => BigInt(x)).array;
    auto l = lcm(A);
    long ans;
    foreach (a; A)
    {
        long x = (l * powmod(a, MOD - 2, MOD)) % MOD;
        ans = (ans + x) % MOD;
    }
    writeln(ans);
}

long lcm(long[] A)
{
    long[long] f;
    foreach (a; A)
    {
        auto d = factorize(a);
        foreach (key, value; d)
        {
            f[key] = max(f.get(key, 0), value);
        }
    }
    // writeln(f);
    long ans = 1;
    foreach (key, value; f)
    {
        ans = powmod(key, value, MOD) * ans % MOD;
    }
    return ans;
}

/// x^^n % m
T powmod(T = long)(T x, T n, T m)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}

/// 素因数分解
long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n + 1);
  REP(i, n) { cin >> a[i + 1]; }

  FOR(i, k + 1, n + 1) {
    if (a[i] > a[i - k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll l, r, d; cin >> l >> r >> d;
    ll ans = 0;
    frep(i, l, r) {
        if((i%d) == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextInt() - 1;
        }

        bool[] exist = new bool[100000];
        int now = 0;
        int answer = 0;
        while (true)
        {
            if (exist[now])
            {
                break;
            }
            exist[now] = true;

            answer++;
            int next = a[now];
            if (next == 1)
            {
                Console.WriteLine(answer);
                return;
            }

            now = next;
        }

        Console.WriteLine(-1);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 17488
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=100003;
int N, M, k;
int arr[MX];
int can[MX];
int main()
{
    scanf("%d", &N);
    scanf("%d", &M);
    for(int i=1;i<=N;i++) arr[i]=1;
    can[1]=1;
    for(int i=0;i<M;i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        arr[a]--;
        arr[b]++;
        can[b]|=can[a];
        if(!arr[a]) can[a]=0;

    }
    int an=0;
    for(int i=1;i<=N;i++) an+=(can[i] ? 1:0);
    cout<<an;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
    int flag=0;
    if(a==5&&b==5&&c==7)
        flag=1;
    if(a==7&&b==5&&c==5)
        flag=1;
    if(a==5&&b==7&&c==5)
        flag=1;
    if(flag)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int a[N];
  int flag=0;
  
  for (int i=1; i<N+1; i++){
    cin >> a[i];
  }
  
  int i=1;
  for (int j=0; j<N; j++){
      if(a[i]!=2){
        i=a[i];
      } else {
        cout << j+1 <<endl;
        flag=1;
        break;
      }
  }
  if (flag==0){
    cout << -1 <<endl;
  }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
ll n;
int cnt,tot,ans;
int main(){
	n=read();
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			cnt=0;
			tot=1;
			while(n%i==0){
				n/=i;
				++cnt;
				if(cnt==tot){
					cnt=0;
					++ans;
					++tot;
				}
			}
		}
	}
	if(n>1) ++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> lx,rx;
    ll cnt = 0;
    lx.push_back(0);
    rx.push_back(0);
    rep(i,n){
        ll x;
        cin >> x;
        if(x<0){
            lx.push_back(-x);
        }
        if(x==0)
            cnt++;
        if(x>0)
        {
            rx.push_back(x);
        }
    }
    sort(lx.begin(), lx.end());
    ll ans = 10000000000;
    for(auto& u:lx){
        ll tmp = cnt;
        for(auto& v:rx){
            ll dis = min(2*u+v,2*v+u);
            if(v!=0){
                tmp++;
            }
            if(tmp==k){
                ans = min(ans, dis);
            }
        }
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1656
#include<stdio.h>

int main(){

  int a, b, c, ch;

  scanf("%d %d %d", &a, &b, &c);
  
  if ( a > b ) { 
    ch = a; 
    a = b; 
    b = ch; 
  }
  if ( b > c ) {
    ch = b;
    b = c;
    c = ch;
  }
  if ( a > b ) {
    ch = a;
    a = b;
    b = ch;
  }



  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 1848
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int n,T;
     cin>>n>>T;
     int c[n],t[n];
     for(int i=0;i<n;i++)
        cin>>c[i]>>t[i];
     int maxcost=1000000;
     for(int i=0;i<n;i++)
     {
         if(t[i]<=T)
           maxcost=min(maxcost,c[i]);
     }
     if(maxcost==1000000)
     {
        cout<<"TLE";
        return 0;
     }
     cout<<maxcost;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007;
#define INF 1000000000000000001;
#define ll long long
vector<int>g[200005];
vector<pair<int,int>>wg[123456];
int level[200005];
void dfs(int s,int pre){
      for(auto i:g[s])
      {
        if(i != pre)
          {
            level[i]+=level[s];
            dfs(i,s);
          }
      }

}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  for (size_t i = 1; i < n; i++) {
      int x,y;
      cin>>x>>y;
      g[x].push_back(y);
      g[y].push_back(x);

  }
  for(int i=0;i<m;++i){
    int p,q;
    cin>>p>>q;
    level[p]+=q;

  }
  dfs(1,0);
  for(int i=1;i<=n;i++)
    cout<<level[i]<<" ";

    cout<<endl;
  return 0;
}


Measured memory_bytes: 26368
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
int dp[1 << 16][40];
int n, X, Y, Z, m;

bool valid(const vector<int>& a) {
  int sum = 0, i;
  for (i = 0; i < a.size(); ++i) {
    sum += a[i];
    if (sum >= X) break;
  }
  if (sum != X) return false;
  sum = 0;
  for (++i; i < a.size(); ++i) {
    sum += a[i];
    if (sum >= Y) break;
  }
  if (sum != Y) return false;
  sum = 0;
  for (++i; i < a.size(); ++i) {
    sum += a[i];
    if (sum >= Z) break;
  }
  return sum == Z;
}

int solve(int mask, int pos) {
  if (pos == n) return 1;
  int& ret = dp[mask][pos];
  if (ret >= 0) return ret;
  ret = 0;
  int pre = -1;
  vector<int> a;
  a.push_back(-1);
  for (int k = 0; k < m; ++k) {
    if (mask & (1 << k)) {
      a.push_back(k - pre);
      pre = k;
    }
  }
  for (int k = 1; k <= 10; ++k) {
    a[0] = k;
    if (!valid(a)) {
      int sum = a[0] - 1, nxt_mask = 1 << sum;
      for (int i = 1; i < a.size(); ++i) {
        sum += a[i];
        if (sum >= m) break;
        nxt_mask |= 1 << sum;
      }
      ret = (ret + solve(nxt_mask, pos + 1)) % MOD;
    }
  }
  return ret;
}

int main() {
  scanf("%d%d%d%d", &n, &Z, &Y, &X);
  m = X + Y + Z - 1;
  memset(dp, 255, sizeof(dp));
  int ret = 1;
  for (int i = 0; i < n; ++i) ret = ret * 10LL % MOD;
  printf("%d\n", (ret + MOD - solve(0, 0)) % MOD);
  return 0;
}


Measured memory_bytes: 10624
def main12():
    n = int(input())
    nlist = []
    for i in range(n):
        nlist.append(int(input()))
    maxnum = max(nlist)
    c = nlist.count(maxnum)
    if c > 1:
        for i in range(n):
            print(maxnum)
    else:
        l = nlist.index(maxnum)
        nlist[l] = 0
        maxnum2 = max(nlist)
        for i in range(n):
            if i != l:
                print(maxnum)
            else:
                print(maxnum2)

if __name__ == "__main__":
    main12()

Measured memory_bytes: 12520
import java.util.Scanner;

/**
 * Created by labuser on 2016/04/15.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int s;
        int h;
        int m;
        int sl;

        Scanner sc = new Scanner(System.in);
        s = Integer.parseInt(sc.nextLine());

        h = s / 3600;
        m = s % 3600 / 60;
        sl = s % 3600 % 60;
        System.out.println(h+":"+m+":"+sl);

    }
}

Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline ll lcm(T& a, T& b) {
    auto z = a * b;
    auto x = max(a, b);
    auto y = min(a, b);
    return z / __gcd(x, y);
}


int main() {
        /* input */
    int N;  cin >> N;
    vector<ll> a(N); rep(i, N) cin >> a[i];

    // 方針：少なくとも m = LCM-1 の時，f の各項が最大値 a[i]-1 を取るので，f は最大となる．

    ll ans = 0;
    rep(i, N) {
        ans += a[i] - 1;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

out = 0
A.sort(reverse=True)
for i in range(n):
    if (i + 1) * 2 <= n:
        out += A[i] * 2
    elif (i + 1) * 2 - 1 <= n:
        out += A[i]

print(out - A[0])

Measured memory_bytes: 31372
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int v[N];
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    int c[N];
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    int a[N];
    for(int i=0;i<N;i++){
        a[i]=v[i]-c[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        if(a[i]>0){ans+=a[i];}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#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++)
using namespace std;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> v(m * 2);
	rep(i, m * 2) cin >> v.at(i);
	rep2(i, 1, n + 1) {
		cout << count(v.begin(), v.end(), i) << "\n";
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N = ii()
    class Edge:
        def __init__(self, a, b):
            self.a = a
            self.b = b
            self.color = None
        def get_con(self, i):
            return self.b if self.a==i else self.a
    edges = []
    tree = tuple([] for _ in range(N))
    for _ in range(N-1):
        a, b = mis()
        a -= 1
        b -= 1
        edge = Edge(a, b)
        edges.append(edge)
        tree[a].append(edge)
        tree[b].append(edge)
    tasks = [(0, 0)]
    max_color = 1
    for used, node in tasks:
        color = 1
        for edge in tree[node]:
            if color == used:
                color += 1
            if edge.color is not None:
                continue
            edge.color = color
            tasks.append((color, edge.get_con(node)))
            max_color = max(max_color, color)
            color += 1
    print(max_color)
    for edge in edges:
        print(edge.color)



main()


Measured memory_bytes: 46760
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
			b[i]=a[i];
		}
		Arrays.sort(a);
		int r=a[n/2];
		int l=a[n/2-1];

		for(int i=0; i<n; i++) {
			int ans;
			if(b[i]<r) {
				ans = r;
			} else {
				ans = l;
			}
			System.out.println(ans);
		}
		sc.close();
	}
}


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

using namespace std;

int main ()
{
  int nb[3][3], n, i, j, k;
  i = 0;
  while(i < 3)
  {   
	  cin >> nb[i][0] >> nb[i][1] >> nb[i][2]; 
    i++;
  }
  
  cin >> n;
  int bingo[n];
  k = n;
  j = 0;
  while(0 < k)
  {   
	cin >> bingo[j];
	k--;
    j++;
  }
  i = 0;
  j = 0;
  k = n;
  while(i < 3)
  {
  	while(j < 3)
    {
      while(0 <= k - 1)
      {
        if(nb[i][j] == bingo[k - 1])
        {
          nb[i][j] = 0;
        }
		k--;
      }
      k = n;
      j++;
    }
    j = 0;
    i++;
  }
  i = 0;
  j = 0;
 

  while(i < 3)
  {
    if(nb[i][0] == 0 && nb[i][1] == 0 && nb[i][2] == 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    if(nb[0][i] == 0 && nb[1][i] == 0 && nb[2][i] == 0)
    {
      cout << "Yes" << endl;
      return 0;
    }    
    i++;
  }
  if(nb[0][0] == 0 && nb[1][1] == 0 && nb[2][2] == 0)
  {
    cout << "Yes" << endl;
    return 0;
  }
  if(nb[0][2] == 0 && nb[1][1] == 0 && nb[2][0] == 0)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;

}


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

int main()
{
    string s; cin>>s;
    int n=s.size();
    for(int i=0; i<n; ++i) {
        for(int j=0; j<n; ++j) {
            string t=s;
            t.erase(j, i);
            if (t=="keyence") { cout<<"YES"<<endl; return 0; }
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		long count = 0;
		int c;
		for(int a = 1; a < n; a++){
			for(int b = 1; a*b < n; b++){
				c = n - a*b;
				if((a*b)+c==n && c > 0) count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35884
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N];
        int count = 0;
        int max = 0;
        for (int i = 0 ; i < N ; i++) {
            H[i] = sc.nextInt();
            if (max < H[i]) {
                max = H[i];
            }
        }
        int[][] HN = new int[max][N];
        for (int i = 0; i < max; i++) {
            for (int j = 0; j < N ; j++) {
                if (0 < H[j]) {
                    HN[i][j] = 1;
                    H[j]--;
                } else {
                    HN[i][j] = 0;
                }
            }
        }
        for (int[] line : HN) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < line.length; i++) {
                if (i == 0 && line[0] != 0) {
                    sb.append(line[i]);
                } else if (0 < i && line[i] != line[i-1]) {
                    sb.append(line[i]);
                } else {
                    continue;
                }
            }
            count += sb.toString().split("0").length;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23504
import sys
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

N, K = map(int, input().split())
or_result = [K]
for i in range(K.bit_length()):
    if (1 << i) & K:
        or_result.append((K & ~((1 << i) - 1)) - 1)

values = {r:0 for r in or_result}
for _ in range(N):
    A, B = map(int, input().split())
    for key in values:
        if key & A == A:
            values[key] += B

print(max(values.values()))

Measured memory_bytes: 73992
#include<iostream>
#include <bits/stdc++.h>
//1000000000000223
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, m ;
char x,  ans1[509][509], ans2[509][509];
int main()
{
    IO
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        ans1[i][1]=ans2[i][m]='#';
    for(int i=1; i<=n; i++)
    {
        if(i%2)
            for(int j=1; j<m; j++)
                ans1[i][j]='#';
        else
            for(int j=2; j<=m; j++)
                ans2[i][j]='#';
    }
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
        {
            if(ans1[i][j]!='#')
                ans1[i][j]='.';
            if(ans2[i][j]!='#')
                ans2[i][j]='.';
            cin>>x;
            if(x=='.')
                continue;
            if(i%2)
                ans2[i][j]='#';
            else
                ans1[i][j]='#';
        }
    for(int i=1; i<=n; i++)
        cout<<ans1[i]+1<<"\n";
    cout<<"\n";
    for(int i=1; i<=n; i++)
        cout<<ans2[i]+1<<"\n";
    return 0;
}


Measured memory_bytes: 1280
import static java.lang.System.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		
		char[] str = sc.next().toCharArray();
		int c0 = 0;
		int c1 = 0;
		for(char c: str) {
			if(c == '0') c0++;
			else c1++;
		}
		
		out.println(Math.min(c0, c1)*2);
	}

}


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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N) ;
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int sum = 0; 
  
  for(int i = 0; i < N; i++){
    sum = sum + A.at(i);
  }
  
  if( H > sum ){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include<set>
#include<cmath>
using namespace std;
int a[15][100005];
int count( int S[], int m, int n )
{
	if(a[m][n]!=-1)return a[m][n];
	
	if (n == 0)
		a[m][n]= 0;
    
	else if (n < 0)
		a[m][n]= 99999;

	else if (m <=0 && n >= 1)
		a[m][n]= 99999;
    else
	a[m][n]=min(count( S, m - 1, n ),1+count( S, m, n-S[m-1] ));
	return a[m][n];
}

int main() {
	memset(a,-1,sizeof(a));
	set<int> s;int k,n;
	cin>>n;
	s.insert(1);
	k=1;
	while(pow(6,k)<=n){
		s.insert(pow(6,k));k++;
	}
	k=1;
	while(pow(9,k)<=n){
		s.insert(pow(9,k));k++;
	}
	k=0;int arr[15];
	for(auto x:s){arr[k++]=x;}
	cout<<count(arr,k,n);
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,t;
    cin>>a>>b>>t;
    cout<<b*(t/a);
    return 0;
}

Measured memory_bytes: 3608
/*
 * @author : ashish1610
 */
#include <bits/stdc++.h>
using namespace std;
#define ll	long long int
#define MOD	1000000007
int main() {
	string str;
	cin >> str;
	int ar[26];
	memset(ar, 0, sizeof(ar));
	for(int i = 0; i < (int)(str.length()); ++i) {
		ar[str[i] - 'a'] += 1;
	}
	for(int i = 0; i < 26; ++i) {
		if(ar[i] & 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;


int main() {
	int N;
	cin >> N;
	auto a = double(N / 2);
	auto ans = 1 - double(a/N);
	cout << ans << endl;
}

Measured memory_bytes: 256