akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[200200];

int main() {
	ll n;
	cin>>n;
	vector<pair<ll,ll> > v;
	ll sum = 0;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(mp(a,i));
	}
	sort(all(v));
	ll a1 = v[v.sz/2-1].fi;
	ll a2 = v[v.sz/2].fi;
	rep(i,0,v.sz){
		if(i<v.sz/2){
			d[v[i].se]=a2;
		}
		else{
			d[v[i].se]=a1;
		}
	}
	rep(i,0,n){
		cout << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 7020
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <iomanip>

using namespace std;
typedef long long ll;
const int maxn=1e6+1111;

int arr[maxn];
int dp[maxn];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    memset(dp,0x3f3f3f,sizeof(dp));
    arr[0]=0x3f3f3f;
    dp[0]=dp[1]=0;
    for(int i=1;i<=n;++i){
        scanf("%d",arr+i);
        for(int j=1;j<=k&&i-j>0;++j){
            dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 6400
if __name__ == '__main__':
    [n,m] = [int(i) for i in input().split()]
    h = [int(i) for i in input().split()]
    d = dict()
    for i in range(n):
        d[i+1] = dict()
    for i in range(m):
        [a,b] = [int(i) for i in input().split()]
        if b in d[a].keys():
            d[a][b] = d[a][b] + 1
            d[b][a] = d[b][a] + 1
        else:
            d[a][b] = 1
            d[b][a] = 1
    count = 0
    for i in range(1,n+1,1):
        good = True
        for j in d[i].keys():
            if h[i-1] <= h[j-1]:
                good = False
                break
        
        if good:
            # print(i)
            count+=1
    

    # print(d)
    print(count)



Measured memory_bytes: 54540
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int main () {
    int d, l, r;
    cin >> l >> r >> d;
    printf("%d\n", r / d - (l - 1) / d);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<i64> q;
    for(int i = 0; i < N; i++) {
        i64 a;
        cin >> a;
        q.push(a);
    }
    for(int i = 0; i < M; i++) {
        i64 a = q.top();
        q.pop();
        q.push(a / 2);
    }
    i64 ans = 0;
    for(int i = 0; i < N; i++) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn dfs(target: usize, color: i32, edges: &Vec<Vec<usize>>, draw_result: &mut Vec<i32>) -> bool {
    if draw_result[target] != 0 {
        return color == draw_result[target];
    }
    draw_result[target] = color;
    for &to in edges[target].iter() {
        if !dfs(to, -color, edges, draw_result) {
            return false;
        }
    }
    true
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, m) = (v[0], v[1]);
    let mut a = vec![0; m];
    let mut b = vec![0; m];

    let mut edges = vec![std::collections::HashSet::new(); n];

    for i in 0..m {
        let v: Vec<usize> = read_vec();
        let (a, b) = (v[0] - 1, v[1] - 1);
        edges[a].insert(b);
        edges[b].insert(a);
    }

    // make complement graph
    let mut complement_edges = vec![Vec::new(); n];
    for i in 0..n {
        for j in 0..n {
            if !edges[i].contains(&j) && i != j {
                complement_edges[i].push(j);
            }
        }
    }

    // draw
    let mut draw_result = vec![0; n]; //0: undrawn, -1 or 1

    let mut plus_group = Vec::new();
    let mut minus_group = Vec::new();

    for i in 0..n {
        if draw_result[i] == 0 {
            if !dfs(i, 1, &complement_edges, &mut draw_result) {
                println!("-1");
                return;
            }
        }
        let mut plus_count = 0;
        let mut minus_count = 0;
        for j in 0..n {
            if draw_result[j] == 1 {
                plus_count += 1;
            } else if draw_result[j] == -1 {
                minus_count += 1;
            }
        }
        let plus_group_new = plus_count - plus_group.iter().sum::<usize>();
        plus_group.push(plus_group_new);
        let minus_group_new = minus_count - minus_group.iter().sum::<usize>();
        minus_group.push(minus_group_new);
    }

    let mut dp = vec![false; n + 1];
    dp[plus_group.iter().sum::<usize>()] = true;

    for gi in 0..plus_group.len() {
        let diff = minus_group[gi] as i32 - plus_group[gi] as i32;
        if diff >= 0 {
            for i in (0..n + 1).rev() {
                let index = (diff + i as i32);
                if 0 <= index && index as usize <= n && dp[i] {
                    dp[index as usize] = true;
                }
            }
        } else {
            for i in 0..n + 1 {
                let index = (diff + i as i32);
                if 0 <= index && index as usize <= n && dp[i] {
                    dp[index as usize] = true;
                }
            }
        }
    }

    let mut ans = std::usize::MAX;
    if dp[0] || dp[n] {
        ans = n * (n - 1) / 2;
    }
    for i in 1..n {
        if dp[i] {
            ans = std::cmp::min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 20732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  ll n,a,b,ans;
  cin >> n >> a >> b;
  ans = a*(n/(a+b));
  if(n%(a+b)>=a) ans+=a;
  else ans+=n%(a+b);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import ceil

def solve(N: int, p: "List[float]"):

    dp = [[0.0] * (N+1) for i in range(N+1)]

    dp[0][0] = 1
    for i in range(N):
         for j in range(N):
             dp[i+1][j] += dp[i][j] * (1-p[i])
             dp[i+1][j+1] += dp[i][j] * p[i]

    print(sum(dp[N][ceil(N/2):]))


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ float(next(tokens)) for _ in range(N) ]  # type: "List[float]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 112476
<?php
    $array = explode(" ",trim(fgets(STDIN)));
    $a = (int)$array[0];
    $b = (int)$array[1];

    $ret = (double)0;

    for( $i=1; $i<=$a; $i++){
        $tmp = (double)(1.0/$a);
        $now = $i;
        while($now<$b) {
            (int)$now *= 2;
            (double)$tmp /= 2;
        }
        
        (double)$ret+=$tmp;
    }

    printf("%.12f\n",$ret);

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


Int dp[2][81+10][160 * 80 * 4 + 100];
signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int H, W;
  cin>>H>>W;

  vector<vector<Int> > A(H, vector<Int>(W));
  vector<vector<Int> > B(H, vector<Int>(W));
  cin>>A;
  cin>>B;

  Int ofset = (H + W) * 80 + 10;
  Int M = ofset * 4 + 10;
  dp[0][0][ofset] = 1;

  Int I = 0;
  Int ans = INF;
  for(Int i=0;i<H;i++){

    for(Int j=0;j<W;j++)
      for(Int k=0;k<M;k++)dp[!I][j][k] = 0;

    for(Int j=0;j<W;j++){
      for(Int k=0;k<M;k++){
        if(dp[I][j][k] == 0) continue;
        Int v1 = k + (A[i][j] - B[i][j]);
        Int v2 = k + (-A[i][j] + B[i][j]);
        if(0 <= v1 && v1 < M){
          dp[!I][j][v1] = 1;
          dp[I][j+1][v1] = 1;
        }
        if(0 <= v2 && v2 < M){
          dp[!I][j][v2] = 1;
          dp[I][j+1][v2] = 1;
        }

        if(i == H - 1 && j == W - 1){
          Min(ans, abs(v1 - ofset));
          Min(ans, abs(v2 - ofset));
        }
      }
    }
    I = !I;
  }

  cout<<ans<<endl;

  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> a(m);
  vector<int> b(m);
  rep(i,n) cin >> h[i];
  rep(i,m) cin >> a[i] >> b[i];
  vector<bool> c(n,true);
  rep(i,m){
    if(h[a[i]-1] < h[b[i]-1]) c[a[i]-1] = false;
    else if(h[a[i]-1] > h[b[i]-1]) c[b[i]-1] = false;
    else if(h[a[i]-1] == h[b[i]-1]) {
      c[a[i]-1] = false;
      c[b[i]-1] = false;
    }
  }
  int cnt = 0;
  rep(i,n) {
    if(c[i]==true) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4548
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    ld p=3.14159265;
    ld r,m=2;
    cin >> r;
    cout << fixed << setprecision(10) << r*m*p << endl;
}

Measured memory_bytes: 3736
a, b, c, n = map(int, input().split())
ans = 0
for i in range(n//a + 1):
    rem = n - i*a
    for j in range(rem//b + 1):

        rem1 = rem - j*b
        if rem1 % c == 0:

            ans += 1


print(ans)


Measured memory_bytes: 40556
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<bitset>
using namespace std;
typedef bitset<60000>bi;
bool get(vector<int>v, int t)
{
	bi x;
	x[30000] = 1;
	for (int i = 0; i < v.size(); i++)x = (x << v[i]) | (x >> v[i]);
	return x[30000 + t];
}
int main()
{
	string s;
	cin >> s;
	s.push_back('T');
	int x, y;
	scanf("%d%d", &x, &y);
	vector<int>v1, v2;
	int mode = -1;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'T')
		{
			if (mode == -1)mode = 1;
			else if (mode == 0)v1.push_back(cnt), mode = 1;
			else v2.push_back(cnt), mode = 0;
			cnt = 0;
		}
		else
		{
			if (mode == -1)x--;
			else cnt++;
		}
	}
	if (get(v1, x) && get(v2, y))printf("Yes\n");
	else printf("No\n");
}

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

struct BIT {
    vector<ll> bit;
    int N;

    BIT(int N) : bit(vector<ll>(N + 1, 0)), N(N) {}

    // return sum in [0, `i`] in log(n)
    ll sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i - (i & -i));
    }

    // add `x` at `i`
    void add(int i, ll x) {
        if (i > N) return;
        bit[i] += x;
        add(i + (i & -i), x);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    rep(i, n) {
        cin >> c[i];
        c[i]--;
    }
    vector<vector<int>> rli(q, vector<int>(3, 0));
    rep(i, q) {
        cin >> rli[i][1] >> rli[i][0];
        rli[i][0]--;
        rli[i][1]--;
        rli[i][2] = i;
    }
    sort(rli.begin(), rli.end());

    vector<int> ans(q, 0);
    BIT fwt(n);
    vector<int> lastApp(n, -1);
    int r = -1;

    rep(i, q) {
        for (int nr = r + 1; nr <= rli[i][0]; nr++) {
            if (lastApp[c[nr]] >= 0) {
                fwt.add(lastApp[c[nr]] + 1, -1);
            }
            lastApp[c[nr]] = nr;
            fwt.add(nr + 1, 1);
        }
        r = rli[i][0];
        ans[rli[i][2]] = fwt.sum(r + 1) - fwt.sum(rli[i][1]);
    }
    rep(i, q) {
        cout << ans[i] << endl;
    }
}


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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){

  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin  >> n;
  int a[100000]; int b[100000]; int c[100000];

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

  sort(a, a+n);
  sort(b, b+n);
  sort(c, c+n);

  ll o = 0;

  ll cb[100000];
  for(int i = n-1;i>= 0;--i){
    int k = lower_bound(a, a+n, b[i])-a;
    cb[i] = k;
  }

  for (int i = 1; i < n; ++i) { cb[i] += cb[i-1]; }
  for (int i = n-1; i >= 0; --i) {
    int j = lower_bound(b, b+n, c[i])-b-1;
    if (j >= 0) o += cb[j];
  }
  std::cout << o << std::endl;

  return 0;
}



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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;

int main()
{
  ll k; cin >> k;
  if (k%2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  ll d = 7;
  for (int i=1; i<=1000000; i++) {
    if (d%k == 0) {
      cout << i << endl;
      return 0;
    }
    d = (d*10+7)%k;
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
// int facctorialMethod(int k){
//     int sum = 1;
//     for (int i = 1; i <= k; ++i)
//     {
//         sum *= i;
//     }
//     return sum;
// }
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    // for(int i=0;i<n;i++){
    //     cout << s.at(i) << endl;
    // }
    string tmp;
    tmp = s.at(0);
    int count = 1;
    for(int i=1;i<n;i++){
        if(tmp!=s.at(i)){
            count++;
            tmp = s.at(i);
        }
    }
    cout<<count<<endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

ll N, K;
ll fac[int(2e6+5)], rev[int(2e6+5)], nCr[int(2e6+5)];
string S;

int main(){
  cin >> K >> S;
  N = S.length();
  fac[0] = 1; rev[0] = 1;
  for (ll i = 1; i <= N + K; i++){
    fac[i] = fac[i-1] * i % MOD;
    rev[i] = Pow(fac[i], MOD - 2);
  }
  for (ll i = 0; i <= K; i++){
    nCr[i] = fac[i + N - 1] * rev[i] % MOD;
    nCr[i] *= rev[N - 1]; nCr[i] %= MOD;
  }

  ll ans = 0;
  for (ll i = 0; i <= K; i++){
    ll now = Pow(25, i) * Pow(26, K - i) % MOD;
    now *= nCr[i]; now %= MOD;
    ans += now; ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 43556
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


typedef pair<ll,ll> pll;

bool comp(pll a, pll b){
    return a.second<b.second;
}

int main(){
    ll ans,n;
    cin >>n;
    vector< pair<ll,ll> > ab;
    bool flag=true;
    for(int i=0;i<n;i++){
        ll a,b;
        cin >>a>>b;
        ab.push_back(make_pair(a,b));
    }

    sort(ab.begin(),ab.end(),comp);
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=ab[i].first;
        if(ab[i].second<sum){
            flag=false;
            break;
        }
    }


    if(flag)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;

    return 0;

}

Measured memory_bytes: 6256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int r, g;
	cin >> r >> g;
	// r + p = 2 * g 

	cout << 2 * g - r << endl;

	return 0;
}


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

int main(){
    int A[3][3];
    int B[3][3];
    rep(i,3){
        cin >> A[i][0] >> A[i][1] >> A[i][2];
        B[i][0]=B[i][1]=B[i][2]=0;
    }
    int N;
    cin >> N;
    rep(i,N){
        int b;
        cin >> b;
        for(int x=0;x<3;x++){
            for(int y=0;y<3;y++){
                if(A[x][y]==b){
                    B[x][y]=1;
                }
            }
        }
    }

    bool flag = false;
    rep(i,3){
        if(B[i][0]&B[i][1]&B[i][2]==1) flag=true;
        if(B[0][i]&B[1][i]&B[2][i]==1) flag=true;
    }
    if(B[0][0]&B[1][1]&B[2][2]==1) flag=true;
    if(B[0][2]&B[1][1]&B[2][0]==1) flag=true;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int a, b, t; cin >> a >> b >> t;
    cout << t/a*b << endl;
    return 0;
}


Measured memory_bytes: 256
N = input()
S = input()
count = 0
for i in range(1000):
    n = "{:03d}".format(i)
    n1, n2, n3 = n[0], n[1], n[2]
    i1 = S.find(n1)
    if -1 < i1 < len(S) - 2:
        i2 = S.find(n2, i1 + 1)
        if -1 < i2 < len(S) - 1:
            i3 = S.find(n3, i2 + 1)
            if -1 < i3:
                count += 1
                continue
print(count)


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  string S, T;
  cin >> S >> T;
  int best = inf;
  for(int i = 0; i <= S.size() - T.size(); i++) {
    int add = 0;
    for(int j = 0; j < T.size(); j++) {
      add += S[i + j] != T[j];
    }
    chmin(best, add);
  }
  cout << best << "\n";
}


Measured memory_bytes: 3648
#include <iostream>
#include <cassert>
#include <algorithm>
#define N int(1e5+10)

using namespace std;

int dp[N],h[N];
int main(int argc,char ** argv)
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>h[i+1];
    }
    for(int i=2;i<=n;++i){
        int mn=0x3f3f3f3f;
        for(int j=max(1,i-k);j<i;++j){
            mn=min(mn,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=mn;
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 4412
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, A, B;

int main(void)
{
  cin >> N >> A >> B;
  int ans = min(N * A, B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll a,b;
	cin>>a>>b;
	if(a>=10||b>=10)cout<<-1<<endl;
	else cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
W=list(map(int,input().split()))
ans=10**10
for i in range(N):
    S1=sum(W[:i+1])
    S2=sum(W[i+1:])
    if abs(S1-S2)<=ans:
        ans=abs(S1-S2)
print(ans)

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

public class Main {
	private static String[] TENKI = { "Sunny", "Cloudy", "Rainy" };

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ansewr;

		ansewr = (Arrays.asList(TENKI).indexOf(S) + 1 )% 3;

		System.out.println(TENKI[ansewr]);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[105],b[105];
int main(){
	scanf("%d",&n);
	int ans = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		ans += max(0,a[i]-b[i]);
	}
	cout<<ans<<endl;
}

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

nec = [0 for i in range(n)]
fi = max(-x+(a[0]+a[1]),0)
nec[1] = max(0,a[1]-fi)
for i in range(2,n):
    sec = max(-x+(a[i]+nec[i-1]),0)
    nec[i]=a[i]-sec
    fi += sec

print(fi)


Measured memory_bytes: 64356
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  int N;
  int t = 1, a = 1;

  cin >> N;

  Rep(i, N) {
    //cout << t << " " << a << endl;
    int T, A;
    cin >> T >> A;

    int mn = max( (t + T-1) / T, (a + A-1) / A );
    t = T * mn; a = A * mn;
  }

  cout << t + a << endl;
}


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

class Main
{

	static Scanner sc;

	public static void main( String[] args ) throws IOException
	{
		sc = new Scanner( new BufferedReader( new InputStreamReader( System.in ) ) );
	    int a = sc.nextInt(), b = sc.nextInt();
	    if(a == b) System.out.println("a == b");
	    if(a < b) System.out.println("a < b");
	    if(a > b) System.out.println("a > b");
	}
}


Measured memory_bytes: 26128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)

int main() {
	int n,in;
	cin >> n;
	vi a;
	rep(i, n) {
		cin >> in;
		a.push_back(in);
	}
	vector<bool> ans(2001,false);
	rep(i, pow(2,n)) {
		int b = i;
		int tmp = 0;
		rep(j, n) {
			if (b & 1)tmp += a[j];
			b = b >> 1;
		}
		ans[tmp] = true;
	}
	cin >> n;
	rep(i, n) {
		cin >> in;
		cout << (ans[in] ? "yes" : "no") << endl;
	}
}



Measured memory_bytes: 3268
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        String str = sc.next();

        

        if(n % 2 == 1) {
            System.out.println("No");
            return;
        }
        else {
            String s_1 = str.substring(0, n/2);
            String s_2 = str.substring(n/2, n);

            //System.out.println(s_1);
            //System.out.println(s_2);
            if(s_1.equals(s_2)) System.out.println("Yes");
            else System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import sys
input = sys.stdin.readline

def main():
    s = input()[:-1]
    n = len(s)
    dp = [[0, 0] for _ in range(n+1)]
    
    for i in range(n):
        key = int(s[n-1-i])
        dp[i+1][0] = dp[i][0] + key
        
        if key > 0:
            dp[i+1][0] = max(dp[i+1][0], dp[i][1] + key - 1)
        
        dp[i+1][1] = max(dp[i][0], dp[i][1]) + 9
    
    print(dp[n][0])
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9212
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Sarray();
            var Fi = Sarray();
            Array.Sort(Ai);
            Array.Sort(Fi); Array.Reverse(Fi);
            costs = new Tuple<long, long, long>[N];
            for (var i = 0; i < N; ++i)
                costs[i] = Tuple.Create(Ai[i], Fi[i], Ai[i] * Fi[i]);//A,F,cost
            Array.Sort(costs, (l, r) => (int)(l.Item3 - r.Item3));
            var min = -1L;
            var max = costs.Max(c => c.Item3);
            while (1 < max - min)
            {
                var mid = (min + max) / 2;
                if (check(mid, K))
                    max = mid;
                else
                    min = mid;
            }
            WriteLine(max);
        }
        static Tuple<long, long, long>[] costs;
        static bool check(long x, long k)//k回以下の操作でcostをx以下にできる？
        {
            var N = costs.Length;
            var num = 0L;
            for (var i = N - 1; 0 <= i; --i)
            {
                var c = costs[i].Item3;
                var f = costs[i].Item2;
                num += Max(0, (c - x + f - 1) / f);
                if (k < num) return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 54472
N, = map(int, input().split())

def s(x):
    x = x & 0xFFFF0000 if x & 0xFFFF0000 else x
    x = x & 0xFF00FF00 if x & 0xFF00FF00 else x
    x = x & 0xF0F0F0F0 if x & 0xF0F0F0F0 else x
    x = x & 0xCCCCCCCC if x & 0xCCCCCCCC else x
    x = x & 0xAAAAAAAA if x & 0xAAAAAAAA else x
    return x


xs = []
for _ in range(N):
    xs.append(list(map(int, input().split())))

d = [0]*(2**N)
d2 = [0]*(2**N)

for i in range(1, 2**N):
    x = bin(i)[2:][::-1]
    l = len(x)-1
    d[i] = d[i-s(i)]
    for j, b in enumerate(x):
        if b == '1':
            d[i] += xs[l][j]

for i in range(1, 2**N):
    k = i
    d2[i] = d[i]
    while k:
        k = (k-1)&i
        nk = i^k
        d2[i] = max(d2[i], d2[k]+d2[nk])
print(d2[2**N-1])


Measured memory_bytes: 44508
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
const ll INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;

// Bedone harf !

const int N = 40,
	  		M = 10;

int a[N + 10], b[N + 10], c[N + 10];
int n, ma, mb, dp[N + 10][N * M + 30][N * M + 30];


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

	for(int z = 0; z <= N; z++)
		for(int i = 0; i <= N * M; i++)
			for(int j = 0; j <= N * M; j++)
				dp[z][i][j] = inf;
	dp[0][0][0] = 0;

	int n, ma, mb;
	cin >> n >> ma >> mb;
	for(int i = 0; i < n; i++)
		cin >> a[i] >> b[i] >> c[i];

	for(int i = 0; i < n; i++)
		for(int x = 0; x <= N * M; x++)
			for(int y = 0; y <= N * M; y++)
				if(dp[i][x][y] != inf){
					dp[i + 1][x][y] = min(dp[i + 1][x][y], dp[i][x][y]);
					dp[i + 1][x + a[i]][y + b[i]] = min(dp[i + 1][x + a[i]][y + b[i]], dp[i][x][y] + c[i]);
				}

	// ghalat nist ? :-?
	int ans = inf;
	for(int i = 1; i <= N * M; i++)
		for(int j = 1; j <= N * M; j++)
			if(ma * j == mb * i)
				ans = min(ans, dp[n][i][j]);
	if(ans == inf)
		cout << -1 << '\n';
	else
		cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 55680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, q; cin>>n>>q;
    int ind[200020];
    int l[200020], r[200020], x[200020];
    for(int i=0; i<n; i++){
        int s, t; cin>>s>>t>>x[i];
        ind[i]=i;
        l[i]=s-x[i], r[i]=t-x[i];
    }
    int d[200020];
    for(int i=0; i<q; i++) cin>>d[i];
    vector<int> ps[200020], pp[200020];
    for(int i=0; i<n; i++){
        int k=lower_bound(d, d+q, l[i])-d;
        ps[k].push_back(x[i]);
        k=lower_bound(d, d+q, r[i])-d;
        pp[k].push_back(x[i]);
    }
    multiset<int> st;
    for(int i=0; i<q; i++){
        for(auto y:ps[i]){
            st.insert(y);
        }
        for(auto y:pp[i]){
            st.erase(st.lower_bound(y));
        }
        if(st.empty()) cout<<-1<<endl;
        else cout<<(*st.begin())<<endl;
    }
    return 0;
}

Measured memory_bytes: 30196
import numpy as np

n,k=map(int,input().split())
a=np.array(input().split(),dtype=int)
f=np.array(input().split(),dtype=int)

a=np.sort(a)[::-1]
f=np.sort(f)

ok=10**18
ng=-1

import math
def isOK(val,arr,farr,k):
  return arr.sum()-np.minimum(arr,val//farr).sum()<=k
  
while abs(ok-ng)>1:
  mid=abs(ok+ng)//2
  if isOK(mid,a,f,k):
    ok=mid
  else:
    ng=mid
    
print(ok)


Measured memory_bytes: 37220
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
for i in range(int(N**.5),0,-1):
    if N % i == 0:
        print(i+(N//i)-2)
        exit()


Measured memory_bytes: 63632
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int l = sc.nextInt();
        int s = 0;
        int mx = Integer.MAX_VALUE;
        int e=0;
        for (int i = 0; i < n; i++) {
			s+=l+i;
			if(abs(l+i)<mx) {
				mx=abs(l+i);
				e=l+i;
			}
		}
		
        out.println(s-e);
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    double c;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    	this.c=(double)b/a;
//    }
//
//    public int compareTo(P p){
//        return Double.compare(p.c,c);
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 20820
n = int(input())
nodes = []
ref = [0] * n
for i in range(n):
    l = [int(i) for i in input().split()]
    if l[1] != -1:
        ref[l[1]] += 1
    if l[2] != -1:
        ref[l[2]] += 1
    nodes.append(l)

nodes = sorted(nodes, key=lambda x: x[0])

preorder_ans = []
inorder_ans = []
postorder_ans = []


# u: node(list)
def preorder(u):
    preorder_ans.append(u[0])
    if u[1] != -1:
        preorder(nodes[u[1]])

    if u[2] != -1:
        preorder(nodes[u[2]])


def inorder(u):
    if u[1] != -1:
        inorder(nodes[u[1]])

    inorder_ans.append(u[0])

    if u[2] != -1:
        inorder(nodes[u[2]])


def postorder(u):
    if u[1] != -1:
        postorder(nodes[u[1]])

    if u[2] != -1:
        postorder(nodes[u[2]])

    postorder_ans.append(u[0])


def format_print(l):
    print("", " ".join([str(i) for i in l]))


# print(nodes)

preorder(nodes[ref.index(0)])
inorder(nodes[ref.index(0)])
postorder(nodes[ref.index(0)])

print("Preorder")
format_print(preorder_ans)
print("Inorder")
format_print(inorder_ans)
print("Postorder")
format_print(postorder_ans)



Measured memory_bytes: 5620
#include <stdio.h>

int main(void) {
   
    int n,i;
    scanf("%d",&n);
    int a[n];
    for (i=0; i<n; i++) {
        scanf("%d",&a[i]);
        }
    for(i=n-1;i>=0;i--){
        if(i==0){
           printf("%d",a[i]);
    }else{
        printf("%d ",a[i]);
    }}
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int N, K, Q;
  int A; //仮置き
  cin >> N >> K >> Q;
  vector<int> count(N);
  for(int i = 0; i < Q; i++){
    cin >> A;
    count.at(A - 1) = count.at(A - 1) + 1;
    A = 0;
  }
  for(int i = 0; i < N; i++){
    if(Q - count.at(i) >= K){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		String in;
		HashSet<String> ht = new HashSet<String>();
		for (int i = 0; i < n; i++) {
			in = br.readLine();
			if (in.charAt(0) == 'i') {
				ht.add(in.substring(7));
			} else {
				out.append(ht.contains(in.substring(5))?"yes\n":"no\n");
			}
		}
		System.out.print(out);
	}
}

Measured memory_bytes: 131396
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray().sortedArray()
    val B = readLine()!!.split(" ").map { it.toInt() }.toIntArray().sortedArray()
    val C = readLine()!!.split(" ").map { it.toInt() }.toIntArray().sortedArray()

    var ans = 0L
    for(b in B){
        //Aに対してbより真に小さいものを探す
        var l = -1
        var r = N
        while (r - l > 1) {
            val m = l + (r - l) / 2
            if (A[m] >= b) {
                r = m
            } else {
                l = m
            }
        }
        val a = r

        //Cに対してbより真に大きいものを探す
        l = -1
        r = N
        while (r - l > 1) {
            val m = l + (r - l) / 2
            if (C[m] > b) {
                r = m
            } else {
                l = m
            }
        }
        val c = N - r

        ans += a.toLong() * c.toLong()
    }
    println(ans)
}

Measured memory_bytes: 110488
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,K=mint()
X=lint()
minus=[]
plus=[0]
for x in X:
    if x<0:
        minus.append(-x)
    else:
        plus.append(x)
minus.append(0)
P=len(plus)-1
M=len(minus)-1
ans=INF
for i in range(K+1):
    p = INF if K-i>P else plus[K-i]
    m = INF if i>M else minus[M-i]
    ans=min(ans,p+m+min(p,m))
print(ans)

Measured memory_bytes: 85988
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    ll n, ans;
    cin >> n;
    rep(i, n) {
        ll a;
        cin >> a;
        if (i == 0) ans = a;
        else ans = gcd(a, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    map<int64_t, int64_t>d;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        int64_t n;
        cin >> n;
        vec[i] = n;
        if (d.count(n) > 0) {
            d[n] = d[n] + 1;
        } else {
            d[n] = 1;
        }
    }

    int64_t default_comb_count = 0;
    for (auto n : d) {
        if (n.second >= 2) {
            int64_t num = n.second;
            default_comb_count += num * (num - 1) / 2;
        }
    }

    for (int64_t i=0; i<N; i++) {
        int64_t num = vec[i];
        int64_t comb_cunt = default_comb_count;
        if (d[num] >= 2) {
            comb_cunt -= (d[num] * (d[num] - 1) / 2);
        }

        if (d[num] > 2) {
            comb_cunt += ((d[num] -1) * (d[num] - 2) / 2);
        }

        cout << comb_cunt << endl;
    }
    return 0;
}

Measured memory_bytes: 12656