akhauriyash/Code-Regression huggingface dataset:
// Original: https://github.com/tanakh/competitive-rs
#[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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

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

fn main() {
    input!(n: usize, mut ab: [(usize, usize); n]);

    ab.sort_by(|x, y| x.1.cmp(&y.1));
    let mut ok = true;
    let mut left = 0;
    let mut cnt = 0;
    for i in 0..n {
        left += ab[i].0;

        if left > ab[i].1 {
            ok = false;
        }
    }

    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define N 1000000
using namespace std;
int H;
vector<int> data(N);

int par(int i){
	return i/2;
}
int lef(int i){
	return i*2;
}
int right(int i){
	return i*2 + 1;
}

void maxheap(int i){
	int le,ri,max;
	le = lef(i);
	ri = right(i);
	
	if(le <= H && data.at(le) > data.at(i)) max = le;
	else max = i;

	if(ri <= H && data.at(ri) > data.at(max)){
		max = ri;
	}
	if(max != i){
		swap(data.at(i),data.at(max));
		maxheap(max);
	}
}

int main(){
	cin >> H;
	for(int i=1;i<=H;i++) cin >> data.at(i);
	
	for(int i=H/2;i>=1;i--) maxheap(i);
	
	for(int i=1;i<=H;i++){
		cout << " " << data.at(i);
	}
	cout << endl;
}


Measured memory_bytes: 6628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    ll N, K;
    cin >> N >> K;
    pair<ll, ll> p[100000];
    for(int i=0; i<N; i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p+N);
    ll num=0;
    for(int i=0; i<N; i++){
        if(num+p[i].second>=K){
            cout << p[i].first;
            return 0;
        }
        num+=p[i].second;
    }
}

Measured memory_bytes: 1792
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    A=[tuple(map(int, input().split())) for _ in range(N)]
    ans=0
    for i in range(N):
        for j in range(N):
            if i==j: continue
            ans+=((A[i][0]-A[j][0])**2 + (A[i][1]-A[j][1])**2) ** 0.5
    print(ans/N)

if __name__ == '__main__':
    main()

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    set<ll> c;
    for(int i = 1; i*i <= sum; i++){
        if(sum % i == 0){
            c.insert(i);
            c.insert(sum/i);
        }
    }
    ll ans = 1;
    for(ll x : c){
        ll need;
        vector<ll> r(n);
        rep(i,n) r[i] = a[i] % x;
        sort(r.begin(), r.end());
        ll B = 0;
        rep(i,n) B += x-r[i];
        need = 1e18;
        ll A = 0;
        rep(i,n){
            A += r[i];
            B -= x-r[i];
            need = min(need, max(A,B));
        }
        if(need <= k) ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

void rsortr_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int n;
int w, x;
int a[4][101];
int b[4]={1,1,1,1};

int main(void){
	n=nextint();
	x=nextint();
	w=nextint();
	a[0][b[0]++]=nextint();
	for(int i=1; i<n; i++){
		int W=nextint()-w;
		int v=nextint();
		a[W][b[W]++]=v;
	}
	for(int k=0; k<4; k++){
		rsortr_u32(&a[k][1], b[k]);
		for(int i=1; i<=b[k]; i++){
			a[k][i]+=a[k][i-1];
		}
	}
	int ans=0;
	for(int i0=0; i0<=b[0]; i0++){
		for(int i1=0; i1<=b[1]; i1++){
			for(int i2=0; i2<=b[2]; i2++){
				for(int i3=0; i3<=b[3]; i3++){
					long W=(long)w*i0+(long)(w+1)*i1+(long)(w+2)*i2+(long)(w+3)*i3;
					if(W<=x){
						int now=a[0][i0]+a[1][i1]+a[2][i2]+a[3][i3];
						if(now>ans) ans=now;
					}
				}
			}
		}
	}
	printf("%d\n", ans);
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int h, n;
    cin >> h >> n;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        s += x;
    }
    
    cout << (s >= h ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if(len(even) == 1 and len(odd) == 1):
        print(all_length // 2)
    elif(len(even)==1):
        print(all_length // 2 - odd[1][1])
    elif(len(odd)==1):
        print(all_length // 2 - even[1][1])    
    else:
        print(min(all_length - even[0][1] - odd[1][1], all_length - even[1][1] - odd[0][1]))


Measured memory_bytes: 15972
N,A,B=map(int,input().split())
## print(N,A,B)
value_size = A + B

number_blue = A * (N // value_size)
## print(number_blue)

resid = N % value_size
## print(resid)

if resid > A:
    resid = A
print(number_blue + resid)


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int cnt = 1;

    int A;
    int prev = -1;

    bool anyFlg = true;
    bool evnFlg = false;
    bool incFlg = true;

    int tmp = 0;

    for (int i = 0; i < N; i++)
    {
        if (scanf("%d", &A) < 1) return 0;

        if (prev == -1) evnFlg = true;
        else if (prev < A)
        {
            if ((tmp >= 2) && !incFlg & !evnFlg)
            {
                anyFlg = true;
                tmp = 0;
                cnt++;
            }
            else
            {
                anyFlg = false;
            }
            incFlg = true;
            evnFlg = false;
        }
        else if (A < prev)
        {
            if ((tmp >= 2) && incFlg & !evnFlg)
            {
                anyFlg = true;
                tmp = 0;
                cnt++;
            }
            else
            {
                anyFlg = false;
            }
            incFlg = false;
            evnFlg = false;
        }
        else
        {
            if (anyFlg) evnFlg = true;
        }

        prev = A;
        tmp++;
    }

    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

struct UnionFind{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int N) : par(N), sizes(N, 1){
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x){
  if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    if(sizes[rx] < sizes[ry]) swap(rx, ry);
    par[ry] = rx;
    sizes[rx] += sizes[ry];
  }

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

  int size(int x){
    return sizes[root(x)];
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M; cin >> N >> M;
  ll NN = N*(N-1)/2;
  vector<ll> ans;
  ans.push_back(NN);
  UnionFind tree(N);
  vector<ll> A(M, 0);
  vector<ll> B(M, 0);
  REP(i, M){
    int tmpA, tmpB; cin >> tmpA >> tmpB; tmpA--; tmpB--;
    A[i] = tmpA; B[i] = tmpB;
  }
  for(int i = M-1; i >= 0; i--){
    if(tree.root(A[i]) == tree.root(B[i])){
      ans.push_back(NN);
    }else{
      NN -= tree.size(A[i])*tree.size(B[i]);
      ans.push_back(NN);
    }
    tree.unite(A[i], B[i]);
  }
  for(int i = M-1; i >= 0; i--) cout << ans[i] << endl;
}


Measured memory_bytes: 4596
while 1:	
	n = int(raw_input())
	if n == 0:
		break
	search_map = [[0 for i in range(21)] for i in range(21)]

	for i in range(n):
		x, y = map(int,raw_input().split(" "))
		search_map[y][x] = 1

	here = [10,10]
	m = int(raw_input())
	for i in range(m):
		d, l = raw_input().split(" ")
		l = int(l)
		l_sign = 1 if d == "N" or d == "E" else -1 
		if d == "N" or d == "S":
			next = [here[0], here[1]+l_sign*l]
			for j in range(1,l+1):
				search_map[here[1] + l_sign*j][here[0]] = 0
		else :
			next = [here[0]+l_sign*l, here[1]]
			for j in range(1,l+1):
				search_map[here[1]][here[0] + l_sign * j] = 0
		here = next
	rest_gem = sum([sum(line) for line in search_map])
	print "Yes" if rest_gem == 0 else "No"

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

struct team{
  int id,ac,sec;
  vector<ll> v;
  bool operator<(const team& a){
    if(ac == a.ac){
      if(sec == a.sec) return id < a.id;
      return sec > a.sec;
    }
    return ac < a.ac;
  }
  bool operator>(const team& a){
    if(ac == a.ac){
      return sec > a.sec;
    }
    return ac < a.ac;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll M,T,P,R;
  while(cin >> M >> T >> P >> R && M+T+P+R){
    vector<team> v(T);
    rep(i,T){
      v[i].id = i+1;
      v[i].v.resize(P);
    }
    ll m,t,p,j;
    rep(i,R){
      cin >> m >> t >> p >> j;
      if(j == 0){
        v[t-1].ac++;
        v[t-1].sec += m + 20 * v[t-1].v[p-1];
      }
      else{
        v[t-1].v[p-1]++;
      }
    }
    sort(all(v));
    reverse(all(v));
    cout << v[0].id;
    REP(i,1,T){
      if(v[i] > v[i-1]){
        cout << ',' << v[i].id ;
      }
      else{
        cout << '=' << v[i].id ;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3248
class WeightedUnionFindTree:

    def __init__(self, n_nodes):
        super().__init__()
        self.par = [i for i in range(n_nodes)]
        self.rank = [0] * n_nodes
        self.weights = [0] * n_nodes

    def find(self, x):
        if self.par[x] == x:
            return x
        root = self.find(self.par[x])
        self.weights[x] += self.weights[self.par[x]]
        self.par[x] = root
        return root

    def unite(self, x, y, weight=0):
        root_x, root_y = self.find(x), self.find(y)
        if root_x == root_y:
            return
        if self.rank[root_x] < self.rank[root_y]:
            self.par[root_x] = root_y
            self.weights[root_x] = weight - self.weights[x] + self.weights[y]
        else:
            self.par[root_y] = root_x
            self.weights[root_y] = - \
                (weight - self.weights[x] + self.weights[y])
            if self.rank[root_x] == self.rank[root_y]:
                self.rank[root_x] += 1

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

    def diff(self, x, y):
        return self.weights[x] - self.weights[y]


if __name__ == "__main__":
    N, Q = map(int, input().split())
    uft = WeightedUnionFindTree(N)
    ans = []
    for _ in range(Q):
        type_, u, v, *weight = map(int, input().split())
        if type_ == 0:
            uft.unite(u, v, weight[0])
        else:
            ans.append(uft.diff(u, v) if uft.is_same(u, v) else '?')
    for a in ans:
        print(a)



Measured memory_bytes: 15264
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin>>n;
	rep(i,0,n){
		ll p1,p2; cin>>p1>>p2;
		if(p1>p2) swap(p1,p2);
		ll p3=p1*p2; ll root=sqrt(p3);
		if(root*(root+1)<p3) cout<<2*root-1<<endl;
		else if(root*root==p3){
			if(p1==p2) cout<<2*root-2<<endl;
			else cout<<2*root-3<<endl;
		}
		else cout<<2*root-2<<endl;
 	}
	return 0;
}


Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
map<string, int> mp;
string s;
signed main()
{
	cin >> n;
	REP(i, n){
		cin >> s;
        mp[s]++;
	}

	int res = 0;
    for (auto m : mp){
		res++;
    }

	cout << res << endl;
	return 0;
}


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

typedef long long ll;

typedef pair<int, int> xy;
typedef pair<int, xy> vp;

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

    int H, W;

    cin >> H >> W;

    vector<vector<char> > S(H + 2, vector<char>(W + 2));

    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            cin >> S[i][j];
        }
    }

    int max = 0;

    vector<xy> p;
    p.push_back(make_pair(-1,  0));
    p.push_back(make_pair( 1,  0));
    p.push_back(make_pair( 0, -1));
    p.push_back(make_pair( 0,  1));

    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            if(S[i][j] == '.') {
                vector<vector<bool> > C(H + 2, vector<bool>(W + 2, false));
                C[i][j] = true;
                queue<vp> q;
                q.push(make_pair(0, make_pair(i, j)));
                int count;
                while(!q.empty()) {
                    vp vxy = q.front();
                    q.pop();
                    count = vxy.first;
                    //cerr << count << endl;
                    for(int k = 0; k < 4; k++) {
                        xy x = vxy.second;
                        x.first += p[k].first;
                        x.second += p[k].second;
                        if(S[x.first][x.second] == '.' && !C[x.first][x.second]) {
                            //cerr << x.first << " " << x.second << endl;
                            C[x.first][x.second] = true;
                            q.push(make_pair(count + 1, make_pair(x.first, x.second)));
                        }
                    }
                }
                if(count > max) {
                    max = count;
                }
            }
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))


int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N;
    cin >>N;

    //-----------------------------------
    ll ans=0,t;
    repd(i,1,N+1){
        t=N/i;
        ans+= t * (t+1)*i / 2;
    }
    cout << ans <<'\n';


    return (0);
}

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

int main(){
  int i,j;
  long n;
  cin>>n;
  int mi=1000;
  int prod;
  for(i=0;i<9;i++){
	prod=1;
    for(j=0;j<i;j++){
      prod*=10;
    }
    if((n/prod)%1000>99){
      mi=min(mi,(int)abs(753-(n/prod)%1000));
    }
  }
  cout<<mi;
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val ll = listOfInt()
    val max = ll.max()!!

    println(if (max < ll.sum() - max) "Yes" else "No")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37924
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		int a;
		cin >> a;
		ans += (a-1);
	}
	print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
  	int n;
  	cin >> n;
    int a[n];
  	char bs[n+1];
    bs[0]='-';
  	bs[n]='-';
  	//up 1 down 2 - 0
  	for(int i=0;i<n;i++) cin >> a[i];
  
  	for(int i=1;i<n;i++) {
    	if(a[i-1] <  a[i]) {
          bs[i] = '/';
        }
      	if(a[i-1] == a[i]) {
          bs[i] = '-';
        }
        if(a[i-1] >  a[i]) {
          bs[i] = '\\';
        }
    }
    //bool first = true;
  	long long money = 1000;
  	long long kabu = 0;
  	int mins,maxs,t;
    for(int i=1;i<n;i++) {
    	if(bs[i]=='/') {
          mins=a[i-1];
          //ut << "b4 " << money << " " << kabu << endl;
          if(mins <= money) {
          	kabu += money/mins;
          	money -= kabu*mins;
          }
          //ut << "af " << money << " " << kabu << endl;
        }
      	
      	if(bs[i]=='\\') {
          maxs=a[i-1];
          
          money += kabu*maxs;
          kabu = 0;
        }
        t = a[i];
    }
  	cout << money+kabu*t << endl;
}


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

int cnt;
void selection_sort(int n,int array[100]){
    for(int i = 0 ; i < n ; i++){
        int mini = i, A = 0;
        for(int j = i ; j < n ; j++){
            if(array[j] < array[mini]){
                mini = j;
                A = 1;
            }
        }
        if(!A) continue;
        swap(array[i],array[mini]);
        cnt++;
    }
}

int main(){
    int n,array[100];
    
    cin >> n;
    for(int i = 0 ; i < n ; i++) cin >> array[i];
    
    cnt = 0;
    selection_sort(n,array);
    
    for(int i = 0 ; i < n ; i++){
        if(!i) cout << array[i];
        else cout << ' ' << array[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int d, t, s;

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

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

    cin >> d >> t >> s;
    if (t * s >= d) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

//bool comp(
//
//	st pll &a, const pll &b) {
//	return a.first < b.first;
//}
//std::vector<int> enum_div(int n)//nの約数を列挙
//{
//	std::vector<int> ret;
//	for (int i = 1; i*i <= n; ++i)
//	{
//		if (n%i == 0)
//		{
//			ret.push_back(i);
//			if (i != 1 && i*i != n)
//			{
//				ret.push_back(n / i);
//			}
//		}
//	}
//	return ret;
//}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	priority_queue<int> q;
	string s = {};
	string s1 = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	ll x[300005] = {};
	ll y[620] = {};
	ll y2[302][302] = {};
	cin >> a;

	vector<int> v = {};
	vector<int> v1 = {};
	vector<int> v2 = {};
	ans = 1;
	int tmp;
	for (int i = 1; i <= a; i++)
	{
		v.push_back(i);
	}
	for (int i = 1; i <= a; i++)
	{
		cin >> tmp;
		v1.push_back(tmp);
	}
	//for (int i = 0; i < a; i++)
	//{
	//	//cout << int(s[i] - '0') << endl;
	//	v1.push_back(int(s[i] - '0'));
	//}
	//for (int i = 0; i < a; i++)
	for (int i = 0; i < a; i++)
	{
		cin >> tmp;
		v2.push_back(tmp);
	}
	//for (int i = 0; i < v.size(); i++) {
	//	cout << " " << v2[i];
	//}


	do {
		//cout << ":";
		//for (int i = 0; i < v.size(); i++) {
		//	cout << " " << v[i];
		//}
		//cout << "\n";
		//string s2(v.begin(), v.end());
		//cout << s2<<endl;
		if (v == v1)
		{
			b = ans;
		}
		if (v == v2)
		{
			c = ans;
		}


		ans++;
	} while (next_permutation(v.begin(), v.end()));
	//return 0;

	cout << abs(b - c) << endl;
	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 256
import copy
S = input()
mod = 10 ** 9 + 7
N = 13
dp = [0] * N
dp[0] = 1

for i in range(len(S)):
	next_dp = [0] * N
	
	if S[i] == '?':
		for j in range(10):
			for k in range(N):
				next_dp[(10 * k + j) % N] += dp[k]
				next_dp[(10 * k + j) % N] %= mod
			
	else:
		j = int(S[i])
		
		for k in range(N):
			next_dp[(10 * k + j) % N] += dp[k]
			next_dp[(10 * k + j) % N] %= mod
			
	dp = copy.copy(next_dp)
	
print(dp[5])


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

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

    vector<char> c(n);
    rep(i,n) cin >> c[i];

    int Rcnt = 0;
    rep(i,n) if (c[i] == 'R') Rcnt++;

    int ans = min(Rcnt, n-Rcnt);
    {
        int cnt = 0;
        int i = 0, j = n-1;
        while (1) {
            while (i < n-1 && c[i] != 'W') i++;
            while (j > 0 && c[j] != 'R') j--;
            if (i < j) {
                c[i] = 'R';
                c[j] = 'W';
                cnt++;
            } else {
                break;
            }
        }
        ans = min(ans, cnt);
    }

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


Measured memory_bytes: 3588
#include <stdio.h>

int N[50];

int fib(int n){
  if(n==0)return N[n]=1;
  if(n==1)return N[n]=1;
  if(N[n]!=-1)return N[n]; 
  return N[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;

  for(i=0;i<50;i++)N[i]=-1;

  scanf("%d",&n);

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

  return 0;
  

}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<vector<pair<int,ll>>> g(100005);
//偶奇性をそのまま持ってくる
vector<ll> v(100005, -1);

void dfs(int a, ll w) {//a:今のいる位置 w:そこまでの重み
	for (auto& c : g[a]) {
		//一度通ったらもう来なくてよい
		if (v[c.first] != -1) continue;
		v[c.first] = w + c.second;
		dfs(c.first, v[c.first]);
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		g[u].emplace_back(pair<int, ll>(v, w));
		g[v].emplace_back(pair<int, ll>(u, w));
	}
	v[0] = 0;
	dfs(0, 0);
	vector<ll> ans;
	rep(i, n) ans.emplace_back(v[i] % 2);
	rep(i, n) dunk(ans[i]);
	return 0;
}

Measured memory_bytes: 10488
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

sorted = a.sort
while m > 0
  max = sorted[n-1]
  sorted[n-1] /= 2
  m -= 1
  break if m == 0
  (n-2).downto(0) do |i|
    if (max / 2) < sorted[i]
      sorted[i] /= 2
      m -= 1
    else
      break
    end
    break if m == 0
  end
  sorted = sorted.sort unless m == 0
end

p sorted.inject(:+)





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

using namespace std;

const int INF = 1 << 29;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  
  vector<int> accW(N + 1, 0);
  vector<int> accE(N + 1, 0);
  for(int i = 0; i < N; i++) {
    accW[i + 1] = accW[i] + (s[i] == 'W');
  }
  for(int i = 0; i < N; i++) {
    accE[i + 1] = accE[i] + (s[i] == 'E');
  }
  
  int ret = INF;
  for(int i = 0; i < N; i++) {
    int l = i == 0 ? 0 : accW[i];
    int r = i == N - 1 ? 0 : accE[N] - accE[i + 1];
    ret = min(ret, l + r);
  }
  cout << ret << endl;
}

Measured memory_bytes: 3076
class UF:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
ab=ab[::-1]
u=UF(n)
size = [1 for _ in range(n+1)]
ben = n*(n-1)//2
ans = [ben]
for i in range(m):
    ai = ab[i][0]
    bi = ab[i][1]
    if u.same_check(ai,bi):
        ans.append(ben)
        u.union(ai,bi)
    else:
        x = u.find(ai)
        y = u.find(bi)
        ben -= size[x]*size[y]
        ans.append(ben)
        if u.rank[x] < u.rank[y]:
            size[y] = size[x]+ size[y]
        else:
            size[x] = size[x]+size[y]
        u.union(ai,bi)

for j in range(m):
    print(ans[m-1-j])

Measured memory_bytes: 120408
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
  string s;
  cin>>s;
  ll a = INF,z = -1;
  rep(i,s.size()){
    if(s[i] == 'A')
      a = min(a,i);
    if(s[i] == 'Z')
      z = max(z,i);
  }
  int ans = z - a +1;
  print(ans)
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>
#include <map>
#include <set>
#include <bitset>

#define forin(i, f, t) for(ll i = f; i < t; i++)

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using Pair = pair<ll, ll>;

int divisor[201];

int main() {
    for (auto i = 1; i <= 200; i++) {
        int t = i;
        while (t <= 200) {
            divisor[t]++;
            t += i;
        }
    }
    
    int n;
    cin >> n;
    
    int count = 0;
    for (auto i = 1; i <= n; i+=2) {
        if (divisor[i] == 8)
            count++;
    }
    cout << count << endl;
    
}



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

int main() {
    int n,a,b; cin >> n >> a >> b;
    if (a > b) cout << 0;
    else if (n == 1) cout << (a==b);
    else {
        long long first = a+b+(long long)(n-2)*a;
        long long last = a +b+(long long)(n-2)*b;
        long long len = last-first+1;
        cout << len << endl;
    }


    return 0;
}

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

using namespace std;

const int N = 1000;

int w, n;
int weight[N];
int value[N];
int dp[N+1][N+1];

void solve(){
   fill(dp[0], dp[N+1], -1);
   for(int i=0;i<N+1;i++){
      dp[0][i] = 0;
   }
   for(int i=0;i<n;++i){
      for(int j=0;j<=w;++j){
         if(j < weight[i]){
            dp[i+1][j] = dp[i][j];
         }else{
            dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]] + value[i]);
         }
      }
   }
   for(int i=w-1;i>=0;--i){
      if(dp[n][i] != dp[n][w]){
         cout << dp[n][w] << endl << i+1 << endl;
         return;
      }
   }
}

main(){
   for(int t=1;cin >> w && w;++t){
      cin >> n;
      for(int i=0;i<n;++i){
         char c;
         cin >> value[i] >> c >> weight[i];
      }
      cout << "Case " << t << ":" << endl;
      solve();
   }
   return 0;
}

Measured memory_bytes: 0
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(string s) {
    int[char] d;
    foreach (c; s) {
        d[c]++;
    }
    return d.values.all!(e => e % 2 == 0);
}

void main() {
    auto s = read!string;
    writeln(calc(s) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;

ll N, M;
vector<vector<ll>> edge;
vector<ll> dp;

ll rec(const ll vert)
{
	if (dp[vert] != -1) return dp[vert];

	ll ans = 0;
	for (ll i = 0; i < (ll)edge[vert].size(); ++i)
	{
		chmax(ans, rec(edge[vert][i]) + 1);
	}

	dp[vert] = ans;
	return ans;
}

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

	cin >> N >> M;

	edge.resize(N);
	dp = vector<ll>(N, -1);

	for (ll i = 0; i < M; ++i)
	{
		ll x, y;
		cin >> x >> y;

		edge[x - 1].push_back(y - 1);
	}

	ll ans = 0;
	for (ll i = 0; i < N; ++i)
	{
		chmax(ans, rec(i));
	}

	cout << ans << endl;
	//system("pause");
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;

lli a, b, v, w, t;

int main(void){
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    if((v-w)*t >= abs(b-a)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C; cin>>A>>B>>C;
    if(A==B){
        cout<<C;
        return 0;
    }
    else if(C==B){
        cout<<A;
        return 0;
    }
    else{
        cout<<B;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a=0,b=0,c=0;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a<b&&b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

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

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int32_t MAX = 1e5+1;

template<int32_t MAX> struct cominit{
    int64_t Fac[MAX], Finv[MAX], Inv[MAX];
    constexpr cominit(): Fac(), Finv(), Inv(){
        Fac[0] = Fac[1] = 1;
        Finv[0] = Finv[1] = 1;
        Inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            Fac[i] = Fac[i - 1] * i % MOD;
            Inv[i] = MOD - Inv[MOD%i] * (MOD / i) % MOD;
            Finv[i] = Finv[i - 1] * Inv[i] % MOD;
        }        
    }
    
};

//#define int int64_t
signed main()
{
    constexpr auto com = cominit<MAX>();
	int n, m; cin >> n >> m;
    if(abs(n-m)>=2){
        cout << 0 << endl;
    }
    else{
        if(n>m || m > n){
            cout << com.Fac[n]*com.Fac[m]%MOD << endl;
        }
        else
        {
            cout << (com.Fac[n]*com.Fac[m]%MOD)*2%MOD << endl;
        }
        
    }
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n;
int p[200001];
int main()
{
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		int x;
		cin>>x;
		p[x]++;
	}
	for(int i=1;i<=n;i++)cout<<p[i]<<endl;
}


Measured memory_bytes: 4348
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public void solve() {
        int n = in.nextInt();
        BigInteger a = new BigInteger(in.next());
        BigInteger b = new BigInteger(in.next());
        BigInteger g = a.gcd(b);
        a = a.divide(g);
        b = b.divide(g);
        //out.println(a + " " + b);
        for (int i = 1; i < n; i++) {
            BigInteger x = new BigInteger(in.next());
            BigInteger y = new BigInteger(in.next());
            g = x.gcd(y);
            x = x.divide(g);
            y = y.divide(g);
            BigInteger k1 = a.divide(x);
            if (k1.multiply(x).compareTo(a) < 0)
                k1 = k1.add(BigInteger.ONE);
            BigInteger k2 = b.divide(y);
            if (k2.multiply(y).compareTo(b) < 0)
                k2 = k2.add(BigInteger.ONE);
            BigInteger k = k1.compareTo(k2) >= 0 ? k1 : k2;
            a = x.multiply(k);
            b = y.multiply(k);
            //out.println(a + " " + b);
        }
        out.println(a.add(b));
    }

    public static void main(String[] args)throws IOException {
        FastScanner in;
        boolean isLocalRun = args.length >= 1 && "local_run".equals(args[0]);
        if (isLocalRun)
            in = new FastScanner(new FileInputStream("input"));
        else
            in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int testsCount = 1;
        for (int testNum = 0; testNum < testsCount; testNum++)
            new Main(in, out).solve();
        in.close();
        out.close();
    }

    final PrintWriter out;
    final FastScanner in;

    public Main(FastScanner in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }
}

class FastScanner {
    private StringTokenizer tokenizer;
    private BufferedReader reader;

    public FastScanner(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            if (line == null)
                return null;
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public String nextLine() {
        String line;
        try {
            line = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        tokenizer = null;
        return line;
    }

    public void close() {
        try {
            reader.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}



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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  for(int i;i<k;i++){
    if(i%2==0){
      if(a%2!=0)
        a -= 1;
      a /= 2; b += a;
    }
    else{
      if(b%2!=0)
        b -= 1;
      b /= 2; a += b;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c;
	int hasil;
	scanf("%d %d %d", &a, &b, &c);
	if(a<=b && b<=c){
		hasil=a+b;
	} else if(a<=b && c<=b){
		hasil=a+c;
	} else if(a>=b && a>=c){
		hasil=b+c;
	} else if(b<=c && a<=c){
		hasil=a+b;
	}
	printf("%d\n", hasil);
}

Measured memory_bytes: 128
n = [str(input()) for _ in range(2)]

if int(n[0]) == 1 or int(n[0]) % 2 == 1:
	print("No")
	exit()

s = n[1][:int(int(n[0])/2)]
if n[1].count(s) == 2:
	print("Yes")
else:
	print("No")

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

int main() {
    int n,m;cin>>n>>m;
    vector<int> a[100001];
    for (int i=0;i<n;i++) {
        int b,c;cin>>b>>c;
        a[b].push_back(c);
    }
    int ans=0;
    priority_queue<int> q;
    for (int i=1;i<=m;i++) {
        for (int x:a[i])
            q.push(x);
        if (q.size()) {
            ans+=q.top();q.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5632
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int x,y;
    cin >> x >> y;
    y = abs(y);
    int l = (int)s.size();
    vint xi;
    vint yi;
    int xsum=0;
    int ysum=0;
    int mode = 0;
    int now=0;
    int xf = -1;
    REP(i,l){
        if(s[i]=='F'){
            now++;
        }else{
            if(xf==-1){
                xf=now;
            }else if(mode==0){
                xsum+=now;
                xi.pb(now);
            }else{
                ysum+=now;
                yi.pb(now);
            }
            now=0;
            mode = 1-mode;
        }
    }
    if(xf==-1){
        xf=now;
    }else if(mode==0){
        xsum+=now;
        xi.pb(now);
    }else{
        ysum+=now;
        yi.pb(now);
    }
    x-=xf;
    x = abs(x);
    if(x>xsum||(xsum-x)%2==1){
        cout << "No\n";
        return 0;
    }
    int xr = (xsum+x)/2;
    vint rx(xsum+1);
    rx[0]=1;
    for(int i : xi){
        for(int j=xsum;j>=0;--j){
            if(rx[j]==1){
                rx[j+i]=1;
            }
        }
    }
    if(rx[xr]==0){
        cout << "No\n";
        return 0;
    }


    if(y>ysum||(ysum-y)%2==1){
        cout << "No\n";
        return 0;
    }
    int yr = (ysum+y)/2;
    vint ry(ysum+1);
    ry[0]=1;
    for(int i : yi){
        for(int j=ysum;j>=0;--j){
            if(ry[j]==1){
                ry[j+i]=1;
            }
        }
    }
    if(ry[yr]==0){
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

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

    int x;
    cin>>x;
    if(x==3||x==5||x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3636
sub p{($b=pop)?($b%2?"@_":1)*p("@_"**2%$%,$b>>1)%$%:1}$c=<>=~$";($\+=($_[$_-1]-$_[-$_])*$c)%=$%=1e9+7,$c=$c*$_%$%*p(++$j,$%-2)%$%for$'..(@_=sort{$a-$b}glob<>);print

Measured memory_bytes: 30192
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;
const ll mod=1e9+7;

int main(){
    ll h,w;
    cin >> h >> w;
    ll dx[4]={-1,1,0,0};
    ll dy[4]={0,0,-1,1};
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }
    vector<vector<ll>> used(h,vector<ll>(w));
    ll ans=0;
    rep(i,h){
        rep(j,w){
            if(used[i][j]) continue;
            queue<pll> que;
            que.push({i,j});
            ll white=0,black=0;
            used[i][j]=1;
            while(!que.empty()){
                pll x=que.front();
                que.pop();
                if(s[x.fi][x.se]=='#') black++;
                else white++;
                rep(k,4){
                    ll nx=x.fi+dx[k];
                    ll ny=x.se+dy[k];
                    if(0<=nx && nx<=h-1 && 0<=ny && ny<=w-1 && s[x.fi][x.se]!=s[nx][ny] && used[nx][ny]==0){
                        que.push({nx,ny});
                        used[nx][ny]=1;
                    }
                }
            }
            ans+=white*black;
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main() {
    int n;
   // vector<double> s;
    double x,m;
    priority_queue<double, vector<double>, greater<double> >q;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
       // s.push_back(x);
        q.push(x);
    }
    m=q.top();
    q.pop();
    while(!q.empty()){
        m=(m+q.top())/2;
        q.pop();
    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 256