akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap};
use std::io::{Write, BufWriter, stdout};
use std::iter::FromIterator;
fn main() {
    input! {
        N: usize,
        edges: [(usize1, usize1, usize); N-1],
        Q: usize,
        K: usize1,
        query: [(usize1, usize1); Q],
    }
    let mut edges_list = vec![Vec::<(usize, usize)>::new(); N];
    for &(a, b, c) in edges.iter() {
        edges_list[a].push((b, c));
        edges_list[b].push((a, c));
    }

    let mut d = vec![std::usize::MAX; N];
    d[K] = 0;
    let mut q = HashSet::<usize>::from_iter(0..N);
    let mut costs = BinaryHeap::<EdgeCost>::with_capacity(N);
    costs.push(EdgeCost(K, 0));
    while q.len() > 0 {
        let EdgeCost(prev, cc) = costs.pop().unwrap();
        if !q.remove(&prev) {
            continue;
        }
        for &(qq, cc) in edges_list[prev].iter() {
            if q.contains(&qq) {
                d[qq] = cmp::min(d[qq], d[prev] + cc);
                costs.push(EdgeCost(qq, d[qq]));
            }
        }
    }

    for &(qx, qy) in query.iter() {
        println!("{}", d[qx] + d[qy]);
    }
}

#[derive(Clone, Eq, PartialEq, PartialOrd)]
struct EdgeCost(usize, usize);

impl Ord for EdgeCost {
    fn cmp(&self, other: &Self) -> cmp::Ordering {
        self.1.cmp(&other.1)
    }
}


Measured memory_bytes: 27900
#include<iostream>
using namespace std;
int a,b,i;
int main()
{
    cin>>a>>b;
if(a>b)
{
    for(i=1;i<=a;i++)
    {
        cout<<b;
    }
}
else{
    for(i=1;i<=b;i++)
    {
        cout<<a;
    }
}
return 0;
}


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

void DebugPrint1(const string& s, int a, int b)
{
	for (int i = 0; i < s.length(); ++i) {
		if (a == i) {
			printf("A");
		}
		else if (b == i)
		{
			printf("B");
		}
		else
		{
			printf("%c", s[i]);
		}
	}

	printf("\n");
}

bool IsCanMove(const string& s, int e, int o, int &result)
{
	result = 0;

	if (o == 0)	return false;
	if (o >= 1)
	{
		if (s[o - 1] != '#' && e != (o - 1))
		{
			result = 1;
			return true;
		}
	}

	if (o >= 2)
	{
		if (s[o - 2] != '#' && e != (o - 2))
		{
			result = 2;
			return true;
		}
	}

	return false;

}
int main()
{
    int a, b, c, d, n;
	string s;
#if 1
	cin >> n >> a >> b >> c >> d;
	cin >> s;
#else
	a = 1;
	b = 3;
	c = 6;
	d = 7;
	s = ".#..#..";
	n = 7;
#endif

	a--;
	b--;
	c--;
	d--;

	int aPos = c;
	int bPos = d;

	bool isSuccess = false;
	while (1)
	{
		bool isFailed = false;
//		DebugPrint1(s, aPos, bPos);

		if (aPos != a)
		{
			// Aを動かす
			int result = 0;
			bool ret = IsCanMove(s, bPos, aPos, result);
			if (ret)
			{
				aPos -= result;
			}
			else
			{
				ret = IsCanMove(s, aPos, bPos, result);
				if (ret)
				{
					bPos -= result;
				}
				else
				{
					isFailed = true;
				}
			}
		}
		else if (bPos != b)
		{
			int result = 0;
			bool ret = IsCanMove(s, aPos, bPos, result);
			if (ret)
			{
				bPos -= result;
			}
			else
			{
				isFailed = true;
			}
		}


		if (aPos == a && bPos == b)
		{
			isSuccess = true;
			break;
		}

		if (isFailed)	break;
	};

	string ans = isSuccess ? "Yes" : "No";
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

void warshall_floyd(VVI &G)
{
  int V = G.size();
  REP(i, V) G[i][i] = 0;
  REP(k, V) REP(i, V) REP(j, V) G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  VVI c(10, VI(10)), A(H, VI(W));
  REP(i, 10) REP(j, 10) cin >> c[i][j];
  REP(i, H) REP(j, W) cin >> A[i][j];
  warshall_floyd(c);
  int ans = 0;
  REP(i, H) REP(j, W)
  {
    if (A[i][j] == -1 || A[i][j] == 1) continue;
    ans += c[A[i][j]][1];
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, H;
    cin >> N >> H;
    vector<int> A(N), B(N);
    priority_queue<int> Q;
    int ma = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        Q.push(B[i]);
        ma = max(ma, A[i]);
    }
    int cnt = 0;
    while(!Q.empty() && H > 0 && Q.top() > ma) {
        H -= Q.top(); Q.pop();
        cnt++;
    }
    if (H > 0) {
        cnt += (H + ma - 1) / ma;
    }
    cout << cnt << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;
typedef long long int ll;

class SegmentTree
{
public:
    vector<ll> t;
    ll n;

    SegmentTree(ll n)
    {
        this->t.resize(2*n);
        this->n = n;

        //this->print();
    }

    void print()
    {
        for (auto i: this->t)
        {
            cout<<i<<" ";
        }
        cout<<endl;
    }
    void add(ll pos,ll d)
    {
        ll node = pos + n;
        t[node]  = d;
        node /= 2;

        while (node >= 1)
        {
            t[node] = max(t[2*node],t[2*node + 1]);
            node /= 2;
        }

        //this->print();
    }

    ll get_max(ll a,ll b)
    {
        a += n;
        b += n;

        //cout<<a<<" "<<b<<endl;
        ll ans = 0;

        while (a <= b)
        {
            if (a%2) ans = max(ans,t[a++]);
            if (b%2 == 0) ans = max(ans,t[b--]);

            a /= 2;
            b /= 2;
        }

        return ans;
    }
};


ll solve(vector<ll>& H,vector<ll>& B)
{
    ll n = H.size();

    ll st_h = pow(2,ceil(log2(n+1)));
    SegmentTree* st = new SegmentTree(st_h);
    //dp[i] = max beauty with height == i

    for (ll i=0;i<n;++i)
    {
        ll my_h = H[i];
        ll best = st->get_max(0,my_h - 1);
        st->add(my_h,best + B[i]);

        //cout<<i<<"DOn"<<endl;
    }

    //return 9;
    return st->get_max(0,n);

}


int main()
{
    ll N;
    cin>>N;
    vector<ll> H(N);
    vector<ll> B(N);

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


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


    cout<<solve(H,B)<<endl;

    return 0;
}


Measured memory_bytes: 11056
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n;
    int m;
    int l;

    int i;
    int j;
    int k;
    unsigned int num;
    unsigned long int sum;
    
    unsigned int a[100][100];
    unsigned int b[100][100];
    
    for(i = 0; i < 100; i++)
    {
        for(j = 0; j < 100; j++)
        {
            a[i][j] = 0;
            b[i][j] = 0;
        }
    }
    
    scanf("%d %d %d", &n, &m, &l);
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
            scanf("%d", &num);
            a[i][j] = num;
            //printf("%d\n", a[i][j]);
        }
    }
    for(i = 0; i < m; i++)
    {
        for(j = 0; j < l; j++)
        {
            scanf("%d", &num);
            b[i][j] = num;
        }
    }
    
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < l; j++)
        {
            for(k = 0; k < m; k++)
            {
                sum += (int)(a[i][k]) * (int)(b[k][j]);
            }
            if(j > 0)
            {
                printf(" ");
            }
            printf("%ld", sum);
            sum = 0;
        }
        printf("\n");
        //sum = 0;
    }
    
    return 0;
}

Measured memory_bytes: 684
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, K = input_nums()
    S = input()
    now=''
    cnt=0
    for s in S:
        if s!=now:
            cnt+=1
        now=s
    """
    cnt => 不幸な人の数+1(最初のみ無条件でインクリメントしているため)
    N-1 => 最大の幸福数（端の人は前に人がいないため-1）
    N-cnt =>
        初期状態の幸福な人の数．
        正確には (N-1) - (cnt-1)である．
        これは最初のcntのインクリメントが無条件に行われるため．
    2*K =>
        1回の操作で幸福な人を2人増やせるので
        K回の操作では2*K人を幸福にできる
    """
    ans = min(N-1, N-cnt+2*K)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,k,ans=0;
  cin >> n >> m >> k;
  ans+=(k/1000)*(min(n,m*2));
  k%=1000;
  if(k==0){
    cout << ans << endl;
    return 0;
  }
  if(k>500){
    ans+=min(n,m*2);
  }else{
    ans+=min(n,m);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  long sum = 0;

  if ((C * 2) <= (A + B)) {
    if (X < Y) {
      sum += C * 2 * X;
      if (C * 2 < B) {
        sum += C * (Y - X) * 2;
      } else {
        sum += B * (Y - X);
      }
    } else {
      sum += C * 2 * Y;
      if (C * 2 < A) {
        sum += C * (X - Y) * 2;
      } else {
        sum += A * (X - Y);
      }
    }
  } else {
    sum += X * A;
    sum += Y * B;
  }

  cout << sum << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
using namespace std;

typedef long long int ll;

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  return a.second > b.second;
}

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> a(n);
  vector<pair<ll, ll> > pairs(m);

  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>() );

  for (ll i = 0; i < m; i++) {
    ll b, c; cin >> b >> c;
    pairs[i] = make_pair(b, c);
  }

  sort(pairs.begin(), pairs.end(), cmp);

  ll i = 0, j = 0, cnt = 0;
  ll ans = 0;

  while ( cnt < n ) {
    ll k = a[i];
    if (j < m) {
      ll f = pairs[j].first;
      ll s = pairs[j].second;
      if (s > a[i]) {
        ll t = min(f, n-cnt);
        ans += (s * t);
        j++;
        cnt += f;
      } else {
        ans += k;
        cnt++; i++;
      }
    } else {
      ans += k;
      cnt++; i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int s[MAX], t[MAX];
pair<int,int> temp[MAX], temp2[MAX],x[MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B, Q;
	
	cin>>A>>B>>Q;
	
	rep(i,A)cin>>s[i];
	rep(i,B)cin>>t[i];
	rep(i,Q){
		cin>>x[i].first;
		x[i].second = i;
	}
	
	sort(x,x+Q);
	
	for(int i = 0, j = 0, k = 0; i < Q; i++){
		for(;j < A;j++) if(x[i].first < s[j]) break;
		for(;k < B;k++) if(x[i].first < t[k]) break;
		
		if(j == 0) temp[x[i].second].first = INF;
		else temp[x[i].second].first = x[i].first-s[j-1];
		
		if(j == A) temp[x[i].second].second = INF;
		else temp[x[i].second].second = s[j]-x[i].first;
		
		if(k == 0) temp2[x[i].second].first = INF;
		else temp2[x[i].second].first = x[i].first-t[k-1];
		
		if(k == B) temp2[x[i].second].second = INF;
		else temp2[x[i].second].second = t[k]-x[i].first;
		
	}
	
	for(int i = 0; i < Q; i++) cout<<min(min(max(temp[i].first,temp2[i].first),max(temp[i].second,temp2[i].second)),min(min(temp[i].first,temp2[i].second)*2+max(temp[i].first,temp2[i].second),min(temp[i].second,temp2[i].first)*2 + max(temp[i].second,temp2[i].first)))<<endl;
	
	
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
        int n;
        cin >> n;
        vector<int> a(n);
        vector<bool> sum(2001,0);
        rep(i,n) cin >> a.at(i);
        
        rep(i,pow(2,n)){
                        int s = 0;
                        rep(j,n){
                                 if( i >> j & 1) s += a.at(j);
                }
                if(s <= 2000) sum.at(s) = 1;        
        }
        
        int q;
        cin >> q;
        rep(i,q){
                 int m;
                cin >> m;
                if(sum.at(m)) cout <<"yes"<< endl;
                else cout <<"no"<<endl;
        }
                         
        return 0;
}



Measured memory_bytes: 3276
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = 0
for i in range(n):
	if a[i] >= b[i]:
		c += b[i]
	else:
		b[i] -= a[i]
		c += a[i]
		if a[i+1] >= b[i]:
			c += b[i]
			a[i+1] -= b[i]
		else:
			c += a[i+1]
			a[i+1] = 0
print(c)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int l = d[N/2 - 1];
  int r = d[N/2];
  // cout << l << " " << r << "\n";
  // for (int i : d) {
  //   cout << i << " ";
  // }
  // cout << "\n";
  cout << (r - l) << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){
	
	int n;
	cin>>n;
	vector<int> a(n) , fre(n+1 , 0);

	for(int &x : a)
		cin>>x;

	for(int &x : a)
		fre[x]++;

	int ans = 0;

	for(int i = 1 ; i<= n ; ++i){

		ans += fre[i]*(fre[i]-1)/2;
	}

	for(int i = 0 ; i < n ; ++i){

		int x = a[i];

		cout<<ans - fre[x] + 1<<endl;
	}
}

signed main(){

    //fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}

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

#define endl '\n'

long long comb(const vector<int>& v, int n)
{
    long long result = 0;
    for (int i = 1; i <= n; i++)
        if (v[i] >= 2) result += v[i]*1ll*(v[i]-1)/2;
    return result;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> v(n), freq(n+1, 0);
    for (int& i : v) { cin >> i; freq[i]++; }
    long long all = comb(freq, n);

    for (int i = 0; i < n; i++)
    {
        int now = v[i];
        long long temp = all;
        if (freq[now] >= 2)
            temp = temp-freq[now]+1;
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 4224
void main() {
	auto N = ri;
	auto K = ri;
	ulong res = 1;
	foreach(i; 0..N) res = (res * 2 < res + K ? res * 2 : res + K);
	writeln(res);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 372
#include <stdio.h>
#include <string.h>
#define N 500000
int count;

struct node
{
  int key;
  int pare;
  int left;
  int right;
};

void insert(struct node bi[],int z)
{
  int x,y;
  int num=0;

  y=-1;
  x=bi[0].key;
//  printf("while start\n");
  while(1)
  {
    if(x==-1) break;
    y = num;
    if(z<x)
    {
      num = bi[num].left;
      if(num!=-1) x = bi[num].key;
      else
      {
        x=-1;
      }
    }
    else
    {
      num = bi[num].right;
      if(num!=-1) x = bi[num].key;
      else
      {
        x=-1;
      }
    }
  }
//  printf("while end\n");
  bi[count].pare=y;
  bi[count].key=z;

  if(y==-1)
  {
    bi[0].key=z;
  }
  else if(z<bi[y].key)
  {
    bi[y].left = count;
  }
  else
  {
    bi[y].right = count;
  }

  count++;
}

void pre(struct node bi[],int now)
{
  printf(" %d",bi[now].key);
  if(bi[now].left!=-1)  pre(bi,bi[now].left);
  if(bi[now].right!=-1)  pre(bi,bi[now].right);
}

void in(struct node bi[],int now)
{
  if(bi[now].left!=-1) in(bi,bi[now].left);
  printf(" %d",bi[now].key);
  if(bi[now].right!=-1) in(bi,bi[now].right);
}


void print(struct node bi[])
{
  in(bi,0);
  printf("\n");
  pre(bi,0);
  printf("\n");
}

int main(void)
{
  int n,i;
  int num;
  char comm[10];
  struct node bi[N];
  count=0;

  for(i=0;i<N;i++)
  {
    bi[i].key = -1;
    bi[i].pare = -1;
    bi[i].left = -1;
    bi[i].right = -1;
  }
//  printf("set ok\n");

  scanf("%d",&n);

  for(i=0;i<n;i++)
  {
//    printf("comm:");
    scanf("%s",comm);
//    printf("comm:%s\n",comm);
    if(strcmp(comm,"insert")==0)
    {
//      printf("scan:");
      scanf("%d",&num);
      insert(bi,num);
    }
    else
    {
//      printf("print\n");
      print(bi);
    }
  }
  return 0;
}

Measured memory_bytes: 8416
#include<bits/stdc++.h>
#include<math.h>
#include <string.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;





using namespace std;

int main()
{

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

  IOS;


  long n, m;
  cin >> n >> m;

  int arr[m];

  int sum = 0;

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

    sum += arr[i];
  }


  if (sum > n)
  {
    cout << -1 << endl;
    return 0;
  }

  else

    cout << n - sum;



  return 0;
}





Measured memory_bytes: 3652
using System;
class Code_01
{
    public static void Main()
    {
        string Datas1 = Console.ReadLine();
       
        if(Datas1=="hi"||
            Datas1=="hihi"||
            Datas1=="hihihi"||
            Datas1 =="hihihihi"||
            Datas1 =="hihihihihi"||
            Datas1 =="hihihihihihi"||
            Datas1 =="hihihihihihihi"||
            Datas1 =="hihihihihihihihi"||
            Datas1 =="hihihihihihihihihi"||
            Datas1 =="hihihihihihihihihihi")
        {
            Console.WriteLine("Yes");
        }else
        {
            Console.WriteLine("No");
        }

    }
}

Measured memory_bytes: 11092
import fractions

def factor(x):
  t = x
  p = [1]
  for i in range(2, -int(-x**0.5//1)+1):
    if x % i == 0:
      p.append(i)
      while x % i == 0:
        x /= i
  if x != 1:
    p.append(x)
  if len(p) == 1 and t != 1:
    p.append(t)
  return p

A, B = list(map(int, input().split()))
d = fractions.gcd(A, B)
p = factor(d)
print(len(p))
#p = factorization(d)
#print(p)
#print(len(p) + (0 if p[0][0] == 1 else 1))


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, K;
    cin >> N >> K;
    vector<int64_t> plus, minus;
    for(int i = 0; i < N; i++) {
        int64_t tmp;
        cin >> tmp;
        if(tmp > 0) {
            plus.push_back(tmp);
        } else if(tmp < 0) {
            minus.push_back(tmp);
        } else if(tmp == 0) {
            K--;
        }
    }
    sort(plus.begin(), plus.end());
    sort(minus.rbegin(), minus.rend());
    // 正のろうそくをi個点火する場合
    int64_t ans = -1;
    for(int i = 0; i <= plus.size(); i++) {
        int64_t a, b;
        if(i > 0) {
            a = plus[i - 1];
        } else {
            a = 0;
        }
        if(K - i > minus.size()) continue;
        if(K - i > 0) {
            b = abs(minus[K - i - 1]);
        } else {
            b = 0;
        }
        int64_t tmp = a + b + min(a, b);
        if(ans < 0 || tmp < ans) {
            ans = tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed
ll x;
cin>>x;
if(x>=30) cout<<"Yes\n";
else cout<<"No\n";
}



Measured memory_bytes: 8056
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = parseInt(input.trim().split(" ")[0]);
  let count = 0;
  let result = 1;

  while (input !== 1 || count === 10) {
    input = Math.floor(input / 2);
    count += 1;
  }

  console.log(Math.pow(2, count) + Math.pow(2, count) - 1);
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> cnt(3, 0);
    for (char c : s) {
        cnt[c - 'a']++;
    }
    sort(cnt.rbegin(), cnt.rend());
    cnt[0] -= cnt[2];
    cnt[1] -= cnt[2];
    if ((cnt[0] == 0 && cnt[1] == 0) || (cnt[0] == 1 && cnt[1] == 0) || (cnt[0] == 1 && cnt[1] == 1)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 764
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll gc(ll a, ll b){
    if(b == 0) return a;
    return gc(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for(auto &x : a){
        cin >> x;
    }
    a.PB(x);
    sort(ALL(a));
    int ans = 0;
    for(int i = 1; i < SZ(a); i++){
        ans = gc(ans, abs(a[i] - a[i - 1]));
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using namespace std;
int checkChar(char button, char dir);

int main(){
	string str;
	cin >> str;
	for(int i = 0; i <= str.length() -1; i += 2){
		checkChar(str[i], str[i+1]);
	}
	cout << endl;
	return 0;
}

int checkChar(char button, char dir){
	if(button == '0' && dir == 'U'){
		cout << "nn";
		return 0;
	}
	if(button != '1'){
		switch (button) {
			case '2': cout << "k";break;
			case '3': cout << "s";break;
			case '4': cout << "t";break;
			case '5': cout << "n";break;
			case '6': cout << "h";break;
			case '7': cout << "m";break;
			case '8': cout << "y";break;
			case '9': cout << "r";break;
			case '0': cout << "w";break;
		}
	}
	
	switch (dir) {
		case 'T': cout << "a";break;
		case 'L': cout << "i";break;
		case 'U': cout << "u";break;
		case 'R': cout << "e";break;
		case 'D': cout << "o";break;
	}
	
	return 0;
}


Measured memory_bytes: 3244
#include <stdio.h>

int main() {
  int first = 0, second = 0, third = 0;
  int i, a;
  for(i = 0; i < 10; i++) {
    scanf("%d", &a);
    if(a > first) {
      third = second;
      second = first;
      first = a;
    } else if(a > second) {
      third = second;
      second = a;
    } else if(a > third) {
      third = a;
    }
  }
  printf("%d\n%d\n%d\n", first, second, third);
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    int[] a = new int[n];
    int[] b = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }

    int[] c = new int[m];
    int[] d = new int[m];

    for (int i = 0; i < m; i++) {
      c[i] = sc.nextInt();
      d[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      long gap = 1000000000;
      int ans = m+1;
      for (int j = 0; j < m; j++) {
        int now = Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
        // System.out.println(i+" "+now);
        if (gap > now) {
          gap = Math.min(gap,now);
          ans = j+1;
          // System.out.println("gap "+gap+" ans "+ans);
        }
      }
      System.out.println(ans);
    }


  }

}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int a, b, k;
	cin >> a >> b >> k;


	int cnt = 0;
	for (int i = 100; i >= 1; i--) {
		if (a % i == 0 && b % i == 0) {
			cnt++;
		}

		if (cnt == k) {
			cout << i << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

ll lcm(ll x, ll y) {
	ll z=gcd(x,y);
	return x/z*y;
}

int main()
{
	ll n;
	cin >> n;
	ll t[n];
	rep(i,n) cin >> t[i];
	ll ans=t[0];
	REP(i,1,n) ans=lcm(ans,t[i]);
	cout << ans << endl;
	return 0;
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n)
  ll a=0;
  ll b=n;
  FOR(i,0,8){
    a+=n%10;
    n/=10;
  }
  if(b%a==0){
    co("Yes")
  }
  else{
    co("No")
  }
}

Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let x: i32 = scan.next::<i32>();
    if x >= 30 {
        writeln!(out, "Yes");
    }
    else {
        writeln!(out, "No");
    }
}

Measured memory_bytes: 2156
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>
#include <math.h>


using namespace std;
typedef long long ll;

#define rep(i,n) for (int i = 0; i < (n); i++)


int main() {
	int h, w, k,ans = 0;
	cin >> h >> w >> k;
	vector<string>s(h);
	vector<string>o(h);
	string a;
	rep(i, h) {
		cin >> s[i];
		o[i] = s[i];
	}

	rep(is, 1 << h)rep(js, 1 << w) {//二重ループはこう書ける//bit全探索 1<<h = 2^h
		//ビットが立っているじゃどうか(どの列が塗りつぶされているか)はこの段階のis,jsの値で決まっている
		int cnt = 0;
		rep(i,h)rep(j,w) {
			//bitが立っている場合はその行および列で下のcnt++をスルーするようにする、これを各行、列でチェック
			if (is >> i & 1)continue;//二進数のi桁目を取り出す作業、シフト演算子
			if (js >> j & 1)continue;
			if (s[i][j] == '#')cnt++;
		}
		if (cnt == k)ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;
import java.lang.Math;
class Main{

  public static int selectionSort(long a[], int x){
    int sw=0;
    long minv;
    int mini;
    for(int i=0;i<x-1;i++){
      minv=a[i]; mini=i;
      for(int j=i+1;j<x;j++){
        if(a[j]<minv){
          minv=a[j];
          mini=j;
        }
      }
      if(mini!=i){
      a[mini]=a[i];
      a[i]=minv;
      sw++;
    }
    }
    return sw;
  }
  public static void main(String args[]){
    Scanner stdIn=new Scanner(System.in);
    int x=stdIn.nextInt();
    long[] a=new long[x];
    //input
    for(int i=0;i<x;i++){
        a[i]=stdIn.nextLong();
    }

    int sw=selectionSort(a,x);

    for(int i=0;i<x;i++){
      System.out.print(a[i]);
      if(i<x-1){
        System.out.print(" ");
      }
    }
    System.out.println();
    System.out.println(sw);
  }
}



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

int main()
{
    std::string a, b;
    std::cin >> a >> b;
    if (a == b) { std::cout << "EQUAL" << std::endl; }
    else if (a.length() > b.length())
    {
        std::cout << "GREATER" << std::endl;
    }
    else if (a.length() < b.length())
    {
        std::cout << "LESS" << std::endl;
    }
    else
    {
        if ((a[0] - '0') > (b[0] - '0')) { std::cout << "GREATER" << std::endl; }
        else
        {
            std::cout << "LESS" << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main()
{
    long int a, b, W, c,d;
    scanf("%ld %ld %ld", &W, &a, &b);
    if(W>=1 && a>=1 && b >=1){
            if(a>b){
                d=a;
                a=b;
                b=d;
            }
            if((a+W) >= b){
                c=0;
            }
            else{
                c=b-(a+W);
            }
    }
    printf("%ld\n",c);
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C; cin >> A >> B >> C;

    if((A == B && A != C) || (A == C && A != B) || (B == C && A != B)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

int main(){
	long long L, R, ans = 2020;
	cin >> L >> R;
	for(long long i = L ; i <= R ; i++){
		if(i%2019 == 0){
			cout << "0" << endl;
			return 0;
		}
	}
	for(long long i = L ; i+1 <= L+2020 && i+1 <= R ; i++){
		for(long long j = i+1 ; j <= R ; j++){
			ans = (ans < ((i%2019)*(j%2019))%2019)? ans : ((i%2019)*(j%2019))%2019;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,K,i,total=0;
  int hei[100000];
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
    scanf("%d",&hei[i]);
  }
  for(i=0;i<N;i++){
    if(hei[i] >= K){
      total++;
    }
  }
  printf("%d\n",total);
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int a = sc.nextInt();	
      System.out.println( a + (int)Math.pow(a,2) + (int)Math.pow(a,3));
    
    }
}

Measured memory_bytes: 36000
main::IO()
main =do
  str<-getLine
  print (solver1 str)

solver1::String -> Int
solver1 [] = 0
solver1 (x:xs) = if x/='A' then solver1 xs else (solver2 xs 0) + 1

solver2::String -> Int -> Int
solver2 [] i = i
solver2 (x:xs) i = if x/='Z' then (solver2 xs (i+1)) else i + (solver3 (x:xs) 0 0)

solver3::String -> Int -> Int -> Int
solver3 [] m _ = m
solver3 (x:xs) m n = if x/='Z' then (solver3 xs m (n+1)) else (solver3 xs (n+1) (n+1))

Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define ll long long

using namespace std;

// input
ll s;

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

    cout << s/3600 << ":" << s/60%60 << ":" << s%60 << "\n";
}


Measured memory_bytes: 3204
#include<stdio.h>
int main(){
  int S;
  int h,m,s;
  int rS;
  int sh = 60 * 60;
  int sm = 60;
  scanf("%d",&S);
  h = (S/sh);
  rS = S - (h * sh);
  m = rS/sm;
  rS = rS - (m*sm);
  s = rS;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}



Measured memory_bytes: 2044
N = int(input())
A = list(map(int,input().split()))

li = [0] * (N + 1)
total = 0

for i in A:
  li[i] += 1
for i in li[1:]:
  total += i * (i - 1) // 2

for i in A:
  j = li[i]
  print(total - (j * (j - 1) // 2) + ((j - 1) * (j - 2) // 2))

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

using namespace std;

int main() {
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<a+1){
    cout<<k<<endl;
  }
  else if(k<a+b+1){
    cout<<a<<endl;
  }
  else{
    cout<<2*a+b-k<<endl;
  }
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pLL;
typedef long long ll;
int MOD = 1000000007;
int main(){
  int N;
  int ans=0;
  cin >> N;
  int V[N];
  int C[N];
  for(int i=0; i<N; i++){
    cin >> V[i];
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  for(int i=0; i<N; i++){
    if(V[i] > C[i]) ans += (V[i] - C[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int n, m;
bool used[500];
vector<int> e[500];

int main(){
	while(scanf("%d%d", &n, &m), n||m){
		rep(i,500) e[i].clear();
		rep(i,500) used[i] = false;
		rep(i,m){
			int x, y; scanf("%d%d", &x, &y);
			x--; y--;
			e[x].push_back(y);
			e[y].push_back(x);
		}
		used[0] = true;
		rep(i,e[0].size()){
			used[e[0][i]] = true;
			rep(j,e[e[0][i]].size()){
				used[e[e[0][i]][j]] = true;
			}
		}
		int ans = -1;
		rep(i,500) ans += used[i];
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,x,t;
	std::cin >> n >> x >> t;
	std::cout << ((n+x-1)/x)*t << std::endl;
	return 0;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  vector<int> swap1(26,-1),swap2(26,-1);
  
  for(int i=0;i<S.length();i++){
    if(swap1[S[i]-'a']==-1){
      swap1[S[i]-'a']=T[i]-'a';
      if(swap2[T[i]-'a']!=-1){
        cout<<"No"<<endl;
        return 0;
      }else{
        swap2[T[i]-'a']=S[i]-'a';
      }
    }else{
      if(swap1[S[i]-'a']!=T[i]-'a'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int i=0;i<S.length();i++){
    if(swap2[T[i]-'a']==-1){
      swap2[T[i]-'a']=S[i]-'a';
      if(swap1[S[i]-'a']!=-1){
        cout<<"No"<<endl;
        return 0;
      }else{
        swap1[S[i]-'a']=T[i]-'a';
      }
    }else{
      if(swap2[T[i]-'a']!=S[i]-'a'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 776
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S, T;

  std::cin >> S >> T;

  std::map<char, std::set<int>> map1, map2;

  for (int i = 0, size = S.size(); i < size; i ++) {
    map1[S[i]].insert(T[i]);
    map2[T[i]].insert(S[i]);
  }

  for (const auto& kv : map1)
    if (kv.second.size() > 1) {
      std::cout << "No" << std::endl;
      
      return 0;
    }

  for (const auto& kv : map2)
    if (kv.second.size() > 1) {
      std::cout << "No" << std::endl;
      
      return 0;
    }
  
  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
typedef long long ll;

#define MAX_N 100100
int V;
vector <pair <int,ll> >edge[MAX_N];
ll ans;
bool used[MAX_N];
ll kihaba(int now){
  if(used[now]){
    return 0;
  }
  used[now] = true;
  vector <ll> memo;
  rep(i,sz(edge[now])){
    if(!used[edge[now][i].fir]){
      memo.pb(kihaba(edge[now][i].fir)+edge[now][i].sec);
    }
  }
  sort(ALL(memo));
  reverse(ALL(memo));
  if(sz(memo) >= 2){
    ans = max(ans,memo[0]+memo[1]);
  }
  if(sz(memo) >= 1){
    ans = max(ans,memo[0]);
    return memo[0];
  }else{
    return 0;
  }
}


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> V;
  rep(i,V-1){
    int x,y;ll w;
    cin >> x >> y >> w;
    edge[x].pb(mp(y,w));
    edge[y].pb(mp(x,w));
  }
  rep(i,V){
    kihaba(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14588
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
   ll M;
  cin >>N>>M;
  
  vl X(M);
  rep(i,M) {
    cin >>X.at(i);
  }
  sort(all(X));
       
  
  if(N>=M) {
    cout<<0<<endl;
  }
  else if(N<M) {
    ll a=X.at(M-1)-X.at(0);
    ll sum=0;
    vl diff(M-1);
    rep(i,M-1) {
      diff.at(i)=X.at(i+1)-X.at(i);
    }
    sort(all(diff));
    
    repl(i,M-N,M-1) {
      sum +=diff.at(i);
    }
    cout<<a-sum<<endl;
  }
      
} 
    
 

Measured memory_bytes: 1792