akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

int main(){
	INIT;
	ll Q;
	cin>>Q;
	while(Q--){
		ll a, b;
		cin>>a>>b;
		if(a>b) swap(a, b);
		ll c = sqrt(a*b);
		ll res = c-1;
		ll d = c;
		if(d==a) d--;
		if(a>=2||b>=4){
		ll e = (a*b-1)/d-1;
		if(e>=b) e = b-1;
		if(e>0&&(a*b-1)/e<=a) e--;
		if(e<0) e = 0;
		res += e;
		} else {
			if(b==3) res++;
		}
		cout<<res<<endl;
	}
	return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

ll u1 = -1, u2 = -1;

void dfs(ll v, ll u, vi &vis, vi &g){

    if(vis[u]){

        u1 = u;
        u2 = v;
        return;
    }

    if(v != -1){
        vis[u] = vis[v] + 1;
    }

    dfs(u, g[u], vis, g);
}

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n >> k;
        vi g(n);
        for(i = 0; i < n; i++){
            cin >> a;
            a--;

            g[i] = a;
        }


        ll ans = 0;
        if(k <= n){
            ll ch = 0;

            while(k){
                ch = g[ch];
                k--;
            }

            ans = ch;
        }
        else{

            vi vis(n, 0);
            dfs(-1, 0, vis, g);

            ll rem = k - vis[u1];

            ll len = vis[u2] - vis[u1] + 1;
            k = rem%len;


            ll ch = u1;

            while(k){
                ch = g[ch];
                k--;
            }

            ans = ch;
        }

        cout << ans + 1 << nl;
    }   
    return 0;
}

Measured memory_bytes: 6276
N,M=map(int,input().split())
A=[]
B=[]
a=[]
a.append(0)
x=0
d=1
A.append(1)
A.append(2)
B.append(1)
B.append(1)
for j in range(2,N):
    A.append(A[j-1]+A[j-2])
    B.append(B[j-1]+B[j-2])
for i in range(1,M+1):
    a.append(int(input()))
    if a[i-1]==0:
        if a[i]==1:
            d=1
        else:
            x=A[a[i]-a[i-1]-2]
            d=d*x%(10**9+7)
    else:
        x=B[a[i]-a[i-1]-2]
        d=d*x%(10**9+7)
    if i>1:
        if a[i]-a[i-1]==1:
            d=0
c=N-a[M]
if c==1:
    print(d)
elif c==N:
    x=A[c-1]
    d=d*x%(10**9+7)
    print(d)
else:
    x=A[N-a[M]-2]
    d=d*x%(10**9+7)
    print(d)

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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      System.out.println(2*N*Math.PI);
    }catch(Exception e){
      System.out.println(e.toString());
    }
  }
}


Measured memory_bytes: 33064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long d, g, ans = 10000000000;
  cin>>d>>g;
  vector<long> p(d);
  vector<long> c(d);
  
  for(long i=0;i<d;i++) cin>>p[i]>>c[i];
  for(long bit=0;bit<(1<<d);bit++){
    long aaa=0;
    long bbb=0;
    for(long i=0;i<d;i++){
      if(bit&(1<<i)){
        aaa+=(i+1)*p[i]*100+c[i];
        bbb+=p[i];
      }
    }
    if(aaa>=g){
    	ans=min(ans,bbb);
    }else{
      for(long i=0;i<d;i++){
        if(!(bit&(1<<i))){
          if(aaa+(i+1)*(p[i]-1)*100>=g) ans=min(ans,bbb+((g-aaa)/100+i)/(i+1));
        }
      }
    }
  }
  
  cout<<ans<<endl;
}

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

signed main() {
  string S;
  cin >> S;
  
  if( S.size() == 2 ){
    cout << S << endl;
  }else{
    reverse(S.begin(), S.end());
    cout << S << endl;
  }
            
}


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

int main() {

    int h,w;
    cin >> h >> w ;

    char a[100][100];
    char b[102][102];

    //文字列の取得    
    for(int i=0; i<h; i++){
        cin >> a[i];
    } 

    for(int i=0; i<h+2; i++ ){
        for(int j=0; j<w+2; j++){
            b[i][j] = '#';
        }
    }

    for(int i=0; i<h; i++ ){
        for(int j=0; j<w; j++){
            b[i+1][j+1] = a[i][j];
            //cout << a[i][j] ; 
        }
//        cout << endl;
    }

    for(int i=0; i<h+2; i++){
        for(int j=0; j<w+2; j++){
            cout << b[i][j];
        }
        cout << endl;
    }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    //コイン投げて表の方が裏より多く出るDP
    int n;
    cin>>n;
    double p[n];
    rep(i,n){
        cin>>p[i];
    }
    double dp[n+1][n+1]={};
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0)    dp[i][j]=(1-p[i-1])*dp[i-1][j];
            else        dp[i][j]=(1-p[i-1])*dp[i-1][j]+p[i-1]*dp[i-1][j-1];
        }
    }
    double ans=0;
    for(int i=n;i>n/2;i--) {ans+=dp[n][i];}
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 70528
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007

n=ii1()
a=0
t=0
w=0
r=0
for i in range(n):
    s=is1()
    if s[0]=='A':
        a+=1
    if s[0]=='T':
        t+=1
    if s[0]=='W':
        w+=1
    if s[0]=='R':
        r+=1
if a>=0:
    print('AC x',a)
if w>=0:
    print('WA x',w)
if t>=0:
    print('TLE x',t)
if r>=0:
    print('RE x',r)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii(1LL, 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 2000000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}

i64 f( i64 n , i64 k )
{
    if( k < ( n-4 +2-1 )/2 || k>(n-3) || n<0 || k<0 ) return 0LL ;
    return C(k+1,n-3-k) ;
}

int main()
{
    preprocess() ;

    i64 i , j , k , l , m , n ;

    scanf("%lld",&n) ;

    if(n==2)
    {
        printf("1\n") ;
        return 0 ;
    }

    i64 ans = 0LL ;

    for( i64 k = (n-4 + 2-1)/2 ; k<=n-3 ; k++ )
    {
        i64 ret = ( fact[k+2]*f(n,k) - fact[k+1]*((f(n,k-1)*(n-k-2))%mod) )%mod ;
        ret = (ret*fact[ n-k-3 ])%mod ;
        ans = ( ans + ret*(k+2) )%mod ;
  //      printf("%lld-->%lld\n",k,ans) ;
    }

    printf("%lld\n", (ans%mod + mod)%mod ) ;

    return 0 ;

}


Measured memory_bytes: 31488
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n;
  int i,j;

  scanf("%d",&n);
  int v[n];
  int c[n];
  int rv[n];
  int tmp;
  int ans=0;
  for(i=0;i<n;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&c[i]);
  }
  for(i=0;i<n;i++){
    rv[i]=v[i]-c[i];
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(rv[i]<rv[j]){
        tmp=rv[j];
        rv[j]=rv[i];
        rv[i]=tmp;
      }
    }
  }
  for(i=0;i<n;i++){
    if(rv[i]>=0){
      ans=ans+rv[i];
    }
  }
  printf("%d",ans);

return 0;
}


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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN3(a,b,c)
    cout << a+b+c+9*max(max(a,b),c) << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int d = a+b+c;
    if(d >= 22) dunk("bust");
    else dunk("win");
    return 0;
}

Measured memory_bytes: 256
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      s: chars,
    }
    let mut cnts = vec![0; 3];
    for c in s {
        let idx = (c as u8 - 'a' as u8) as usize;
        cnts[idx] += 1;
    }
    let a = cnts[0];
    let b = cnts[1];
    let c = cnts[2];
    let max_n = max(a, max(b, c));
    let min_n = min(a, min(b, c));
    if max_n-min_n >= 2 {
        println!("{}", "NO");
    } else {
        println!("{}", "YES");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void)
{
    long long int A,B,N;
    scanf("%lld %lld %lld",&A,&B,&N);  
  if(A>=N){
        printf("%lld %lld",A-N,B);
    }else if(N<=A+B){
        printf("0 %lld",A+B-N);
    }else{
  		printf("0 0");
  }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int  A,B;

	cin >> A >> B;

	if(A <= 8 && B <= 8){

		cout << "Yay!" << "\n";
	}
	else{
		 
		cout << ":(" << "\n"; 
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int x = Integer.valueOf(arr01[0]);
        int y = Integer.valueOf(arr01[1]);
        int mysum = 0;
        Integer arr02[] = { 300000, 200000, 100000 };

        if (x == 1 && y == 1) {
            mysum = arr02[x - 1] + arr02[y - 1] + 400000;
        } else if (x <= 3 && y <= 3) {
            mysum = arr02[x - 1] + arr02[y - 1];
        } else if (x <= 3 && y > 3) {
            mysum = arr02[x - 1];
        } else if (x > 3 && y <= 3) {
            mysum = arr02[y - 1];
        }
        System.out.println(mysum);

    }

}

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

void rec(int d,ll val,vector<ll> &all){
    all.push_back(val);
    if(d == 10)return;
    for(int i = -1;i < 2;i++){
        int add = val%10+i;
        if(add<0||add>9)continue;
        rec(d+1,val*10+add,all);
    }
    return;
}
    
int main(){
    cin >> k;
    vector<ll>all;
    for(int i = 1;i<10;i++)rec(1,i,all);
    sort(all.begin(),all.end());
    cout << all[k-1] << endl;

    return 0;
}

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

bool all_same(string s){
	char x=s[0];
	for(auto c:s){
		if(c != x) return false;
	}
	return true;
}
int main()
{
	string s; cin>>s;
	ll k; cin>>k;
  	ll n=s.length();
	if(all_same(s)) {
		cout<<(n*k)/2; return 0;
	}
	
	ll c=0;
	
	if(s[0]!=s[n-1]){
		
		for(ll i=1;i<n;i++){
			if(s[i]==s[i-1]){
				s[i]='0'; c++;
			}
		}

		cout<<k*c; return 0;
	}
	
	ll a=0,b=0;
	ll i=0;
	while(s[i]==s[0]) {a++; i++;}

	i=n-1;
	while(s[i]==s[n-1]){i--; b++;}

	for(i=a+1;i<=n-1-b;i++){
		if(s[i]==s[i-1]){
			s[i]='0'; c++;
		}
	}

	cout<<(k-1)*((a+b)/2) + k*c + a/2 + b/2;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N;
vector<ll> li;
vector<ll> bs;

const int MAX = 300000;
struct segtree {
    int N, dat[2*MAX];
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = INF;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return INF;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

struct segtree seg;

int input(){
  cin >> N;
  REP(i,N) li.push_back(inp<ll>());
}

ll div(ll n,ll l,ll r){
  //cout << n << "," << l << "," << r << "," << bs[n] << endl;
  
  ll su = 0;
  su += (bs[n]-l+1)*(r-bs[n]+1)*n;
  if ( l < bs[n] ) su += div( seg.query(l,bs[n]-1+1) ,l,bs[n]-1);
  if ( bs[n] < r ) su += div( seg.query(bs[n]+1,r+1) ,bs[n]+1,r);
  return su;
}

int main()
{
  
  input();
  seg = segtree(N);
  REP(i,N) seg.update(i,li[i]);
  
  REP(i,N+1) bs.push_back(-1);
  REP(i,N) bs[li[i]] = i;
  ll ret = div(1,0,N-1);
  
  cout << ret << endl;
}

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

const int N = 100005;
using LL = long long;

int head[N], d[N], tot;
struct edge {
	int v, next, w;
} e[N<<1];
void add (int u, int v, int w) {
	e[tot].v = v, e[tot].w = w % 2, e[tot].next = head[u], head[u] = tot++;
}
void dfs (int u, int fa, int dis) {
	d[u] = dis;
	for (int i = head[u]; ~i; i = e[i].next) {
		int v = e[i].v, w = e[i].w;
		if (v == fa) continue;
		dfs (v, u, (dis+w)%2);
	}
}
int main () {
	tot = 0;
	memset (head, -1, sizeof(head));
	int n; cin >> n;
	for (int i = 0; i < n-1; ++i) {
		int u, v, w; cin >> u >> v >> w;
		add (u, v, w); add (v, u, w);
	}
	dfs (1, -1, 0);
	for (int i = 1; i <= n; ++i) printf ("%d\n",d[i]);
	return 0;
}

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

int main(int argc, char *argv[]){

    char x, y;

    scanf("%c %c", &x, &y);

    if(x < y){
        printf("<");
    }else if(x > y){
        printf(">");
    }else{
        printf("=");
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N; cin >> N;
	int count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				count++;
			}
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a;
int main()
{
	int n;
	scanf("%d",&n);
	int t=0,l=-1,ans=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a);	
		if (a==l)
			t++;	
		else
		{
			ans+=t/2;
			l=a;
			t=1;
		}
	}
	ans+=t/2;
	cout<<ans;
	return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n, 0);
  for (int i = 0; i < 2; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == 'R') {
        cnt++;
      } else {
        ans[j] += cnt / 2;
        ans[j - 1] += (cnt + 1) / 2;
        cnt = 0;
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    for (int j = 0; j < n; j++) {
      if (s[j] == 'L') s[j] = 'R';
      else s[j] = 'L';
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int toint(char a){
	switch(a){
		case '0':return 0;
		case '1':return 1;
		case '2':return 2;
		case '3':return 3;
		case '4':return 4;
		case '5':return 5;
		case '6':return 6;
		case '7':return 7;
		case '8':return 8;
		case '9':return 9;
	}
}

int main() {
	char a,b;
	cin>>a>>b;
   string A,B;
   for(int i=0;i<toint(b);i++){
   	A+=a;
   }
   for(int i=0;i<toint(a);i++){
   	B+=b;
   }
   int numA=stoi(A);
   int numB=stoi(B);
   
	if(numA>numB){
	cout<<numA<<endl;
	}
	else{
		cout<<numB<<endl;
	}
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
std::vector<int> G[100100];
int parent[100100];

void computeParent(int v, int prev){
    for(int u : G[v]){
        if(u == prev){continue;}

        parent[u] = v;
        computeParent(u, v);
    }
}

int lengthToRoot(int v){
    int l = 0;
    until(v == 1){
        v = parent[v];
        ++l;
    }

    return l;
}

int countVertices(int v){
    int res = 1;
    for(int u : G[v]){
        if(u == parent[v]){continue;}

        res += countVertices(u);
    }

    return res;
}

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

    std::cin >> N;

    for(int i=0;i<N-1;++i){
        int a, b;
        std::cin >> a >> b;

        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    computeParent(1, -1);
    
    int l = (lengthToRoot(N) - 1) / 2, v = N;
    while(l > 0){
        v = parent[v];
        --l;
    }

    int cnt = countVertices(v);
    std::cout << (N - cnt > cnt ? "Fennec" : "Snuke") << std::endl;
}


Measured memory_bytes: 10752
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
int upcmpii(const void *a, const void *b){
    return (*(int*)a == *(int*)b ? 0 : (*(int*)a > *(int*)b ? 1 : -1));
}
void sort_ui(int *a, int n){ qsort(a, n, sizeof(int), upcmpii);}

int main(){
    //input
    int n, m;
    scanf("%d%d", &n, &m);

    bool ch[101010] = {0};
    int cnt[101010];
    ch[0] = true;
    rep(i, n) cnt[i] = 1;
    rep(i, m){
        int x, y;
        scanf("%d%d", &x, &y);
        x--; y--;
        if(ch[x]){
            ch[y] = true;
            if(cnt[x] <= 1){
                ch[x] = false;
            }
        }
        cnt[x]--;
        cnt[y]++;
    }    

    //output
    ll ans = 0;;
    rep(i, n){
        if(ch[i]) ans++;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 2224
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>


using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

int main(){
    int n, m;
    cin >> n >> m;
    char x[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> x[i][j];
    
    int dp[n][m];
    
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        dp[i][j] = 100000000;
    dp[0][0] = 0;
    if (x[0][0] == '#')
        dp[0][0]++;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char boja = x[i][j];
            int val = dp[i][j];
            if (i + 1 < n){
                char boja2 = x[i + 1][j];
                if (boja2 != '#' || boja == '#')
                    dp[i + 1][j] = min(dp[i + 1][j], val);
                else
                    dp[i + 1][j] = min(dp[i + 1][j], val + 1);
            }
            if (j + 1 < m){
                char boja2 = x[i][j + 1];
                if (boja2 != '#' || boja == '#')
                    dp[i][j + 1] = min(dp[i][j + 1], val);
                else
                    dp[i][j + 1] = min(dp[i][j + 1], val + 1);
            }
        }

    }
    
    cout << dp[n - 1][m - 1];
    return 0;
}


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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  
  if ( n % findSumOfDigits(n) == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> e(n+1,vector<int>(0));
    vector<int> a(n+1,0),d(n+1,0);
    queue<pp> q;
    rep(i,n-1){
        int f,g;
        cin >> f >> g;
        e.at(f).push_back(g);
        e.at(g).push_back(f);
        a.at(f)++;
        a.at(g)++;
    }
    rep(i,n+1){
        if (a.at(i)==1){
            q.push(make_pair(i,1));
            a.at(i)=-1;
            d.at(i)=1;
        }
    }
    int ans;
    while (!q.empty()){
        int r=q.front().first,t=q.front().second;
        a.at(r)=-1;
        //cout << r << " " << t << endl;
        q.pop();
        rep(i,e.at(r).size()){
            a.at(e.at(r).at(i))--;
            if (a.at(e.at(r).at(i))==1){
                d.at(e.at(r).at(i))=t+1;
                q.push(make_pair(e.at(r).at(i),t+1));
            }
            if (a.at(e.at(r).at(i))==0){
                ans=d.at(r)+d.at(e.at(r).at(i));
                //cout << ans << endl;
            }
        }
    }
    if (ans%3==2) cout << "Second" << endl;
    else cout << "First" << endl;
    //cout << ans << endl;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int q;
  cin >> q;

  rep(_,q){
    string s, t;
    cin >> s >> t;
    int ns = s.size();
    int nt = t.size();

    vec2(dp, ns+1, nt+1);

    rep(i,ns){
      rep(j,nt){
        if(s[i]==t[j]){
          chmax(dp[i+1][j+1], dp[i][j]+1);
        }
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
      }
    }

    prt(dp[ns][nt]);
  }
}



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

int main(void){
	string name[9];
	int a[9]={0},b[9]={0};

	for(int i=0;i<9;++i) cin >> name[i] >> a[i] >> b[i];
	for(int i=0;i<9;++i){
		int man=a[i]+b[i], price=(a[i]*200)+(b[i]*300);
		a[i] = man;
		b[i] = price;
	}

	for(int i=0;i<9;++i) cout << name[i] << " " << a[i] << " " << b[i] << endl;
}


Measured memory_bytes: 3204
D,N = map(int,input().split())
if D == 0 :
    if N != 100 :
        print(N)
    else :
        print(101)
elif D == 1 :
    if N != 100 :
        print(N*100)
    else :
        print(10100)
else :
    if N != 100 :
        print(N*10000)
    else :
        print(1010000)
        
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int n;
    cin>>n;
    ll a,mi=INF*2,ma=0;
    rep(i,n){
        cin>>a;
        ma=max(ma,a);
        mi=min(mi,a);
    }
    cout<<ma-mi<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 16:37:16 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]
  pre = 'R'
  r_cnt = 1
  l_cnt = 0
  l_pre = -1
  C = [0]*(len(S))
  for i in range(1, len(S)):
    now = S[i]
    if pre == 'R' and now == 'R':
      r_cnt += 1
    elif pre == 'R' and now == 'L':
      C[i-1] = r_cnt
      r_cnt = 0
      l_pre = i
      l_cnt = 1
    elif pre == 'L' and now == 'L':
      l_cnt += 1

    if (pre == 'L' and now == 'R') or (i == len(S)-1):
      C[l_pre] = l_cnt
      l_cnt = 0
      r_cnt = 1
      ave = int((C[l_pre] + C[l_pre-1]) / 2)
      if (C[l_pre] + C[l_pre-1]) % 2 == 0:
        C[l_pre-1], C[l_pre] = ave, ave
      else:
        n_move = max(C[l_pre-1], C[l_pre]) - 1
        if n_move % 2 == 0:
          if C[l_pre-1] > C[l_pre]:
            C[l_pre-1], C[l_pre] = ave+1, ave
          else:
            C[l_pre-1], C[l_pre] = ave, ave+1
        else:
          if C[l_pre-1] > C[l_pre]:
            C[l_pre-1], C[l_pre] = ave, ave+1
          else:
            C[l_pre-1], C[l_pre] = ave+1, ave

    pre = now

  print(*C, sep=' ')


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 79228
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

tot = 0
while len(A) > 1:
    a = A.pop()
    tot += B[a - 1]
    if a - 1 == A[-1]:
        tot += C[a - 1 - 1]
tot += B[A.pop() - 1]
print(tot)

Measured memory_bytes: 3064
using System;
class Program
 {
        static void Main(string[] args)
        { 
            var a = Console.ReadLine();
            var b = Console.ReadLine();

            string[] n_m = a.Split(' ');
            string[] day = b.Split(' ');
            
            var n = int.Parse(n_m[0]);
            var m = int.Parse(n_m[1]);

            var sum = 0;
            for(int i = 0;i < m;i++){
                sum += int.Parse(day[i]);
            }

            var ans = n - sum;

            if(ans < 0) Console.WriteLine(-1);
            else Console.WriteLine(ans);


        }
 }

Measured memory_bytes: 28456
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    n=int(input())
    arr=list(str(n))
    ans=0
    for i in range(len(arr)):
        ans+=int(arr[i])
        ans%=9
    ans%=9
    if ans==0:
        print("Yes")
    else:
        print("No")

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


Measured memory_bytes: 82756
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    foreach (i, ref x; a)
    {
        x -= i + 1;
    }
    a.sort!"a < b";

    long total;
    foreach (x; a)
    {
        total += abs(x - a[n/2]);
    }

    total.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 10972
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")
 
int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    if(n == m){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n){
    if(n==1||n==1){
        return false;
    }
    for(int i=2;i<n;++i){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
int fact(int n){
    int ans = 1;
    for(int i = 1; i<= n; ++i){
        ans *= i;
    }
    return ans;
}


int main()
{
    int t,n, s;
    cin>>t;
    cin>>n>>s;
    if(n + s%t <= s){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

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

    sort(a,a+N);

    ll candy = x;
    int Happy_counter = 0;
    for(int i = 0; i < N; i++){
        if(i == N-1){
            if(candy == a[i]){
                Happy_counter++;
            }
        }else{
            candy -= a[i];
            if(candy < 0){
                break;
            }else{
                Happy_counter++;
            }
        }
    }

    cout << Happy_counter << endl;

    return 0;
}


Measured memory_bytes: 256
import Foundation

let imput_num:String = readLine()!

let ab:[String] = imput_num.componentsSeparatedByString(" ")
let a = Int(ab[0])!
let b = Int(ab[1])!

if a < 10 {
  if b < 10 {
    print(a*b)
  } else {
  	print(-1)
  }
} else {
  print(-1)
}

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

using namespace std;

int n, m, w, ans = 0, sum = 0;
int g[10][10] = {0};

int getsum(int k) {
    int res = 0;
    bool vis[10][10] = {false};
    for (int i = 0; i < n; i++) {
        if ((k >> i) & 1) {
            for (int j = 0; j < m; j++) {
                vis[i][j] = true;
            }
        }
    }
    for (int i = n; i < n + m; i++) {
        if ((k >> i) & 1) {
            for (int j = 0; j < n; j++) {
                vis[j][i - n] = true;
            }
        }
    }
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < m; j++) {
    //         printf("%d ", vis[i][j]);
    //     }
    //     puts("");
    // }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (vis[i][j]) {
                res += g[i][j];
            }
        }
    }
    // if (k == 5)
    //     printf("%d", res);
    // printf("(%d)\n", sum - res);
    return sum - res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &w);
    for (int i = 0; i < n; i++) {
        char a[10];
        scanf("%s", a);
        for (int j = 0; j < m; j++) {
            if (a[j] == '#') {
                g[i][j] = 1;
                sum++;
            }
        }
    }
    // printf("(%d)", sum);
    for (int i = 0; i < 1 << (n + m); i++) {
        if (getsum(i) == w) {
            // printf("(%d)\n", i);
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3784
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    priority_queue<double, vector<double>, greater<double>> v;
    double res = 0;
    rep(i, n){
        double a; cin >> a;
        v.push(a);
    }
    for(ll i = 1; i < n; i++){
        double v1 = v.top();
        v.pop();
        double v2 = v.top();
        v.pop();
        double new_v = (v1 + v2) / 2;
        res = new_v;
        v.push(new_v);
    }
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[2][100];
    int dp[2][100];
    cin >> n;
    imfor(i, 2) {
        imfor(j, n) {
            cin >> a[i][j];
        }
    }
    imfor(i, n) {
        if (i == 0) {
            dp[0][i] = a[0][i];
        }
        else {
            dp[0][i] = dp[0][i - 1] + a[0][i];
        }
    }
    imfor(i, n) {
        if (i == 0) {
            dp[1][i] = dp[0][i] + a[1][i];
        }
        else {
            dp[1][i] = max(dp[0][i] + a[1][i], dp[1][i - 1] + a[1][i]);
        }
    }
    cout << dp[1][n - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define mod 2019
#define ll long long
int main(){

	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    string s;
    cin>>s;
    int n = s.length();
    std::vector<int> cnt_suf(mod);
    int ans = 0;
    int suf = 0;
    int power_of_ten = 1;
    cnt_suf[0]++;
    for (int i = n-1; i >=0; --i)
    {
    	int digit = s[i] - '0';
    	suf = (suf + (digit * power_of_ten)) % mod;
    	power_of_ten = (power_of_ten * 10) % mod;
        cnt_suf[suf]++;
    }

    for (int i = 0; i < mod; ++i)
    {
    	if(cnt_suf[i] >= 2){
    		ans += (cnt_suf[i] * (cnt_suf[i] - 1))/2;
    	}
    }
    cout<<ans;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nn 504
#define lf double
char buf[nn][nn];
int n,m;
int tag[nn][nn];int vis[nn][nn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%s",buf[i]);
	for(int i=0;i<n;i++)
	{
		putchar('#');
		for(int j=1;j<m-1;j++) if((i%2==1) or buf[i][j]=='#') putchar('#');else putchar('.');
		putchar('.');
		puts("");
	}
	puts("");
	for(int i=0;i<n;i++)
	{
		putchar('.');
		for(int j=1;j<m-1;j++) if((i%2==0) or buf[i][j]=='#') putchar('#');else putchar('.');
		putchar('#');
		puts("");
	}
	return 0;
} 

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int a,b,c;
	int min;
	
	scanf("%d %d %d",&a,&b,&c);
	
	min = a + b;
	if(min > a + c){
		min = a + c;
	}
	if(min > b + c){
		min = b + c;
	}
	
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    
    long divisor = 1000000007;
    
    // combination
    long long comb(long n , long r){
        //cout << "comb_n:" << n << " comb_r:" << r << endl;
        if(n < 0 || r < 0 || r > n){
            cout << "comb-error" << endl;
        }
        if(n - r < r) r = n - r;
        if(r == 0) return 1;
        if(r == 1) return n;
        vector<long> num, deno;
        for(long k = 0 ; k < r; k++){
            num.push_back(n-r+k+1);
            deno.push_back(k+1);
        }
        long pivot , offset;
        for(long p = 2; p <= r ; p++){
            pivot = deno[p-1];
            if(pivot > 1){
                offset = (n - r) % p;
                for(long k = p - 1 ; k < r; k+= p){
                    num[k - offset] /= pivot;
                    deno[k] /= pivot; 
                }
            }
            
        }
        long long result = 1;
        for(long k = 0;  k < r ; k++){
            if(num[k] > 1) result *= num[k];
            result = result % divisor;
        }
        //cout << "comb:" << result << endl;
        return result;
    }
    
    
    int main(){
      long  n , k;
      cin >> n >> k;
      // prime Factoring
      vector<long> v;
      long t;
      t = k;
      for(long i = 2 ; i * i <= k ; i++){
          if(t == 1) break;
          while(t % i == 0){
              //cout << "prime:" << i << endl;
              v.push_back(i);
              t = t / i;
          }
      }
      if(t > 1) v.push_back(t);
      map<long, long> m;
      for(long i = 0 ; i < v.size() ; i++){
          auto itr = m.find(v[i]);
          if(itr != m.end()){
              m[v[i]] = m[v[i]] + 1;
          }else{
              m[v[i]] = 1;
          }
      }
      long long ans = 1;
      long s;
      for(auto itr = m.begin() ; itr != m.end() ; ++itr){
          s = itr->second;
          //cout << itr->first << endl;
          ans *= comb(s + n - 1 , s);
          ans = ans % divisor;
      }
      
      cout << ans << endl;
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int ans=k*k;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        int p=x*x+y*y;
        if(p<=ans)
            cnt++;

    }
    cout<<cnt<<endl;


}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <strings.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int ab, bc, ca;
    int ans;

    scanf("%d %d %d", &ab, &bc, &ca);

    ans = ab * bc / 2;

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

    return 0;
}


Measured memory_bytes: 128
def is_acgt_char(c):
  return c == "A" or c == "C" or c == "G" or c == "T"

def main():
  S = input()
  ans = 0

  for i in range(len(S)):
    count = 0
    
    for j in range(i, len(S)):
      if(not is_acgt_char(S[j])):
        break

      count += 1

    ans = max(ans, count)

  print(ans)

if __name__ == "__main__":
  main()

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 10000000000000
#define L 10000
int main()
{
    int n,k;
    cin >> n >> k;
    vector<ll> x(n);
    vector<ll> dist(n-k+1,0);
    rep(i,n)cin >> x[i];
    rep(i,n-k+1){
        dist[i]=x[i+k-1]-x[i];
        
        dist[i]+=min(abs(x[i+k-1]),abs(x[i]));
        
    }
    
    ssort(dist);
    cout << dist[0] << endl;
}

Measured memory_bytes: 4516