akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

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

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

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

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

fn main() {
    input!{
        s: chars
    }    
    let MOD = 1_000_000_007;
    // println!("{:?}", s);
    let mut dp:Vec<Vec<i64>> = vec![vec![0;13];s.len()+1];
    // println!("{:?}", dp); // ans = dp[s.len()][5]
    dp[0][0]=1;
    for i in 0..s.len() {
        let n = if s[i] == '?' {-1}else{s[i] as i32 - 48};
        // println!("{}", n);
        for j in 0..10 {
            if n!=-1 && n!=j {
                continue;
            }
            for k in 0..13 {
                dp[i+1][((10*k+j)%13) as usize]+=dp[i][k as usize];
            }
        }
        for j in 0..13 {
            dp[i+1][j]%=MOD;
        }
    }
    let ans = dp[s.len()][5];

    println!("{}", ans);
    
}

Measured memory_bytes: 18684
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/scc>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << da[i].size() << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

int main() {
    int n,m; cin >> n >> m;
    ac::scc_graph g(n);
    rip(i,m,0) {
        int a,b; cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ans = g.scc();
    cout << ans.size() << '\n';
    vdeb(ans);
}

Measured memory_bytes: 40100
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
    int N,i;
    scanf("%d",&N);
    int A[51],B[51],C[51];   
    int S;
    S=0;
    for(i=0;i<N;i++){
    	scanf("%d",&A[i]);
    }
    for(i=0;i<N;i++){
    	scanf("%d",&B[i]);
    }
    for(i=0;i<N-1;i++){
    	scanf("%d",&C[i]);
    }
    for(i=0;i<N;i++){
    	S=S+B[A[i]-1];
    }
     for(i=1;i<N;i++){
    	if((A[i]-A[i-1]==1)){
    		S=S+C[A[i-1]-1];
    	}
    }
    printf("%d\n",S);
    return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

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

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

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

fn main() {
    input!{
        n: usize,
        abs: [(i64, i64); n],
    }

    let mut ab_with_sums: Vec<_> = abs.into_iter().map(|(a, b)| (a, b, a+b)).collect();
    ab_with_sums.sort_by_key(|&(_, _, sum)| sum);
    ab_with_sums.reverse();

    let mut answer = 0;

    for i in 0..n {
        if i % 2 == 0 {
            let (a, _, _) = ab_with_sums[i];
            answer += a;
        } else {
            let (_, b, _) = ab_with_sums[i];
            answer -= b;
        }
    }

    println!("{}", answer);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int n;
	cin>>n;
	
	map<string,int>mp;
	
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll maxi = 0;
    rep(i, N) {
        cin >> A[i];
        maxi = max(maxi, A[i]);
    }
    ll l = 1, r = maxi;
    do {
        ll key = (l + r) / 2;
        ll temp = 0;
        iter(i, A) temp += i / key + !!(i % key) - 1;
        if(temp <= K) r = key - 1;
        else l = key + 1;
    } while(l <= r);
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){double N, T, A;
cin >> N >> T >> A;
vector<double> H(N+1);
erep(i, N) cin >> H[i];
erep(i, N){
    H[i] = abs((T-H[i]*0.006)-A);
}
long ans; double tmp = 1e6;
erep(i, N){
    if(H[i] < tmp){
       ans = i;
      tmp = H[i];
    }
}
 show(ans);
//erep(i, N) show(H[i]);
return 0;
}

Measured memory_bytes: 256
use proconio::input;
 
fn main() {
  input! {
    n: usize,
    hs: [i64; n],
  }
  let mut dp = vec![0i64;n];
  dp[0] = 0;
  dp[1] = (hs[1] - hs[0]).abs();
  
  for i in 2..n {
    dp[i] = std::cmp::min(
      (hs[i] - hs[i-1]).abs() + dp[i-1],
      (hs[i] - hs[i-2]).abs() + dp[i-2],
    );
  }
  println!("{}", dp[n-1]);
}

Measured memory_bytes: 4048
#include <iostream>
#include <cstdio>
#include <cstdlib>

int main(int argc, char *argv[]) {
	char grid[2][3];
	for(int i=0;i<2;i++){
		for(int j=0;j<3;j++){
			scanf("%c",&grid[i][j]);
		}
		getchar();
	}
	int flag=0;
	for(int i=0;i<3;i++){
		
		if(grid[0][i]!=grid[1][2-i]){
			flag=1;
		}
	}
	if(flag) printf("NO");
	else printf("YES");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false);cerr << "compiled" << endl

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

INTV dist;
vector<INTV> Graph;

void dfs(int ps){
	for(auto nx : Graph[ps]){
		if(dist[nx] == -1){
			dist[nx] = dist[ps] + 1;
			dfs(nx);
		}
	}
}

signed main(void){
  Accepted_MAGIC;
  
  int N; cin >> N;
  Graph.resize(N);
  REP(i, N-1){
  	int a, b; cin >> a >> b; a--; b--;
  	Graph[a].eb(b); Graph[b].eb(a);
  }
  INTV odd, even;
  dist.resize(N, -1);
  dist[0] = 0;
  dfs(0);

  REP(i, N){
  	if(dist[i] & 1) odd.eb(i);
  	else even.eb(i);
  }

  INTV ans(N, -1); vector<bool> used(N+1, 0);
  if(odd.size() <= N/3){
  	REP(i, odd.size()){
  		ans[odd[i]] = 3*(i+1);
  		used[3*(i+1)] = 1;
  	}
  	int idx = 0;
  	for(int i = 1; i <= N; i++){
  		if(!used[i]){
  			ans[even[idx]] = i;
  			++idx;
  		}
  	}
  } else if(even.size() <= N/3){
  	REP(i, even.size()){
  		ans[even[i]] = 3*(i+1);
  		used[3*(i+1)] = 1;
  	}
  	int idx = 0;
  	for(int i = 1; i <= N; i++){
  		if(!used[i]){
  			ans[odd[idx]] = i;
  			++idx;
  		}
  	}
  } else {
  	int mul = 1;
  	REP(i, odd.size()){
  		if(i < (N+2)/3) ans[odd[i]] = 3*i + 1;
  		else {
  			ans[odd[i]] = 3*mul;
  			++mul;
  		}
  	}
  	REP(i, even.size()){
  		if(i < (N+1)/3) ans[even[i]] = 3*i + 2;
  		else {
  			ans[even[i]] = 3*mul;
  			++mul;
  		}
  	}
  }
  for(auto num : ans){
  	cout << num << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 19176
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <bitset>
#include <climits>

using namespace std;

#define ll long long

int main(void){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0;i < n;++i)    cin >> a[i];

    int bits_max = (int)pow(2.0, (double)n);
    ll ans = LLONG_MAX;
    for(int bits = 0;bits < bits_max;++bits){
        if(bitset<16>(bits).count() >= k){
            ll hight_max = 0;
            ll cost = 0;

            for(int i = 0;i < n;++i){
                if(bits >> i & 1 && hight_max >= a[i]){
                    cost += hight_max + 1LL - a[i];
                    hight_max = hight_max + 1LL;
                }
                hight_max = max(hight_max, a[i]);
                // cout << i << " " << hight_max << endl;
                // cout << cost << endl;
            }

            ans = min(ans, (ll)cost);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
B << 0

total = 0
A.zip(B).inject(0) do |rest,(a,b)|
  x = min(a, rest)
  y = min(b, a - x)
  total += (x + y)
  b - y
end

puts total


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

int main(){
  int n,k,l[100],sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  sort(l,l+n,greater<int>());
  for(int i=0;i<k;i++){
    sum+=l[i];
  }
  cout<<sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  reverse(all(a));
  ll ans=0;
  rep(i,n){
    if(i==0) continue;
    ans+=a[i/2];
  }
  out(ans);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

const int N = 5e5 + 7;

int f[N], lst[N], c[N], fin[N];
ti q[N];

void add(int pos, int val) {
    for (; pos < N; pos |= pos + 1)
        f[pos] += val;
}

int ask(int l, int r) {
    int ans = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1)
        ans += f[r];
    --l;
    for (; l >= 0; l = (l & (l + 1)) - 1)
        ans -= f[l];
    return ans;
}

void solve() {
    loop(i, N)
        lst[i] = -1;
    int n, Q;
    cin >> n >> Q;
    loop(i, n)
        cin >> c[i];
    loop(i, Q) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        q[i] = mkt(l, r, i);
    }
    sort(q, q + Q, [](ti t1, ti t2) { return get<1>(t1) < get<1>(t2); });
    int R = 0;
    loop(i, Q) {
        int l, r, num;
        tie(l, r, num) = q[i];
        while (R <= r) {
            if (lst[c[R]] != -1)
                add(lst[c[R]], -1);
            add(R, 1);
            lst[c[R]] = R;
            ++R;
        }
        fin[num] = ask(l, r);
    }
    loop(i, Q)
        cout << fin[i] << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 17380
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l1,l2,c=0,flag=0;
    string a;
    string b;
    cin>>a;
    cin>>b;
    if(a.size()>b.size())
    {
        cout<<"GREATER"<<endl;
        
    }
    else if(a.size()<b.size())
    {
        
        cout<<"LESS"<<endl;
    }
    else if(a.size()==b.size())
    {
        for(i=0;i<a.size();i++)
        {
            if(a[i]>b[i])
            {
//                cout<<a[i]<<endl;
//                cout<<b[i]<<endl;
                flag=1;
                c=1;
                break;
            }
            else if(a[i]<b[i])
            {
//                cout<<a[i]<<endl;
//                cout<<b[i]<<endl;
                flag=1;
                c=0;
                break;
            }
        }
        if(flag==1 && c==1)
            cout<<"GREATER"<<endl;
        else if(flag==1 && c==0)
            cout<<"LESS"<<endl;
        else if(flag==0 && c==0)
            cout<<"EQUAL"<<endl;

    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;




//ここから編集する


int main() {
    vector<ll> v(100005,0);
    vector<ll> imos(100005,0);
    int N;
    ll K;
    cin >> N >> K;
    REP(i,0,N){
        ll a,b;
        cin >> a >> b;
        v[a] += b;
    }
    imos[0] = 0;
    REP(i,0,100001){
        imos[i+1] = imos[i] + v[i];
    }
    int ans;
    REP(i,0,100001){
        if(imos[i] < K && K <= imos[i+1]){
            ans = i;
            break;
        }
//        if(imos[i] >= K){
//            ans = i;
//            break;
//        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
ev=[]
for i in range(n):
  if i%2==1:ev.append(a[i])
x=[0]*n
x[0]=sum(a)-2*sum(ev)
for i in range(1,n):
  x[i]=2*a[i-1]-x[i-1]
print(*x)



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

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;     //How many towns are there?

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

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		int d[10][10];
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				d[i][j]=T[i][j];
			}
		}
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(d[i][j]>d[i][k]+d[k][j]){
						d[i][j]=d[i][k]+d[k][j];
					}
				}
			}
		} 

		int dis=INF,name=-1,tmp;
		for(int i=0;i<m;i++){
			tmp = 0;
			for(int j=0;j<m;j++){
				tmp += d[i][j];
			}
			if(dis>tmp){
				dis=tmp;
				name=i;
			}
		}
		cout << name << " " << dis << endl;


	}

	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));

//関数：
int gcd(int mx, int mn) {
	if(mn == 0) return(mx);
	else gcd(mn, mx%mn);
}

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

	int n; cin >> n;
	vec a(n); vec b(n);
	vector<pair<int,int>> aa(n); vector<pair<int,int>> bb(n);
	rep(i, n) {
		cin >> a[i]; aa[i] = {a[i],i};
	}
	rep(i, n) {
		cin >> b[i]; bb[i] = {b[i],i};
	}
	
	sort(all(aa));
	sort(all(bb));
	rep(i, n) {
		if(aa[i].first > bb[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	//SWAPの回数はn - #cycleで求まる。1サイクルの場合Noになる。
	//bool frag = true;
	rep(i, n-1) {
		if(aa[i+1].first <= bb[i].first) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	vector<int> p(n);
	rep(i, n) p[aa[i].second] = bb[i].second;
	int ct = 1;
	int x = p[0];
	while(x != 0) {
		ct++;
		x = p[x];
	}
	if(ct == n) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	//if(frag && frag2) {
	//	cout << "No" << endl;
	//	return 0;
	//} else {
	//	cout << "Yes" << endl;
	//	return 0;
	//}
	
	return 0;
}
//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';

Measured memory_bytes: 5760
if __name__ == '__main__':

    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    root = [] # 訪れた頂点をメモ
    already = [-1] * (n+1) # rootのindexのメモ　と　すでに訪れたか

    c = 1# 周期
    l = 0# 例外部分のながさ
    """
    周期は　書き換えようとした時の　書き換えたかった数 - すでに書いてある数
    """

    v = 1#頂点は1 ここから遷移
    while(already[v] == -1): # すでに書いてあれば訪れている。かつ周期の起点となる場所
        already[v] = len(root) #訪れたら何回目かを記述
        root.append(v)
        v = a[v-1]

    c = len(root) - already[v]
    l = already[v]

    if k < l:#例外部分のながさ
        ans = root[k]
    else:# 周期にいるなら
        k -= l
        ans = root[k%c+l]

    print(ans)


Measured memory_bytes: 94908
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N, R;
	cin >> N >> R;
	cout << R + (N >= 10 ? 0 : 100*(10-N)) << endl;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s.at(0)==s.at(2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto XL = new long[][](N);
	foreach (i; 0..N)
	{
		XL[i] = [RD, RD];
	}
	XL.sort!"a[0]-a[1] < b[0]-b[1]"();

	auto dp = new long[](N+1);
	dp[] = long.max;
	dp[0] = long.min;
	long pos;

	foreach (i; 0..N)
	{
		foreach_reverse (j; 0..pos+1)
		{
			auto l = XL[i][0]-XL[i][1];
			auto r = dp[j];
			if (r <= l)
			{
				auto r2 = XL[i][0]+XL[i][1];
				dp[j+1].chmin(r2);
				pos.chmax(j+1);
				break;
			}
		}
	}

	long ans;
	foreach_reverse (i; 0..dp.length)
	{
		if (dp[i] != long.max)
		{
			ans = i;
			break;
		}
	}
	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 12796
#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> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
int a[21];
int b[21];
int c[21];

int main() { // 골드 1, 플레 1
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i > 1 && a[i - 1] + 1 == a[i]) {
			ans += c[a[i - 1]];
		}
		ans += b[a[i]];
	}
	cout << ans << '\n';



}


Measured memory_bytes: 256
from collections import deque

k = int(input())
q = deque(range(1,10))
for i in range(k):
    x = q.popleft()
    if x % 10 != 0:
        q.append(10 * x + (x % 10 - 1))
    q.append(10 * x + (x % 10))
    if x % 10 != 9:
        q.append(10 * x + (x % 10 + 1))
print(x)


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

using namespace std;

const int MAX_N = 202;

using vint = vector<int>;

vint G[MAX_N];
bool H[MAX_N][MAX_N];

int col[MAX_N];
bool dfs(int u, int c) {
 col[u] = c;
  for(int v : G[u]) {
    if(col[v] == c) assert(false);//return false;
    if(col[v] == 0) dfs(v, -c);
  }
  return true;
}

int main() {
  int n;
  while(cin >> n, n) {
    for(int i = 0; i < MAX_N; ++i) G[i].clear();
    memset(H, false, sizeof(H));
    memset(col, 0, sizeof(col));
    map<string, int> mp;
    int sz = 0;
    for(int i = 0; i < n; ++i) {
      string cross;
      cin >> cross;
      int idx = cross.find('-');
      string s = cross.substr(0, idx);
      string t = cross.substr(idx+1);
      if(!mp.count(s)) mp[s] = sz++;
      if(!mp.count(t)) mp[t] = sz++;
      int u = mp[s], v = mp[t];
      G[u].push_back(v);
      G[v].push_back(u);
      H[u][v] = true;
    }
    cout << sz << endl;
    for(int i = 0; i < sz; ++i) {
      if(!col[i]) dfs(i, 1);
    }
    for(int i = 0; i < sz; ++i) {
      for(int j = i+1; j < sz; ++j) {
	bool c = false;
	bool d = true;
	bool e = true;
	for(int k = 0; k < sz; ++k) {
	  if(i == k || j == k) continue;
	  if(H[i][k] && H[j][k]) c = true;
	  if(H[k][i] && H[k][j]) c = true;
	  if(H[k][i] && H[j][k]) d = false;
	  if(H[i][k] && H[k][j]) e = false;
	}
	H[i][j] |= (c&&d&&e);
	H[j][i] |= (c&&d&&e);
      }
    }
    for(int i = 0; i < sz; ++i) {
      for(int j = 0; j < sz; ++j) {
	for(int k = 0; k < sz; ++k) {
	  H[j][k] |= H[j][i]&H[i][k];
	}
      }
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; ++i) {
      string cross;
      cin >> cross;
      int idx = cross.find('-');
      string s = cross.substr(0, idx);
      string t = cross.substr(idx+1);
      if(!mp.count(s)) {
	cout << "NO" << endl;
	continue;
      }
      if(!mp.count(t)) {
	cout << "NO" << endl;
	continue;      
      }
      int u = mp[s], v = mp[t];
      //cout<<col[u]<<" "<<col[v]<<endl;      
      if(col[u] == col[v]) {
	cout << "NO" << endl;
	continue;
      }
      if(H[u][v]) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    long long a[n+1][2];
    for(int i=1;i<=k-1;i++){
        cin>>a[i][0];
        a[i][1]=a[i][0];
    }
    for(int i=k;i<=n;i++){
        cin>>a[i][1];
        if(k==1){
            a[i][0]=a[i][1];
        }
        else{
            a[i][0]=a[i-k+1][1];
        }
    }
    for(int i=k+1;i<=n;i++){
        if(a[i][1]>a[i-1][0]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6744
#ABC179B

n = int(input())
a = [0]*n
b = [0]*n

ans = 'No'

for i in range(n):
    a[i],b[i] = map(int,input().split())


for i in range(n-2):
    if a[i] == b[i]:
        if a[i+1]==b[i+1] and a[i+2]==b[i+2]:
            ans = 'Yes'
            exit

print(ans)

Measured memory_bytes: 9220
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int H, N;
	cin >> H >> N;
	vector<int>dp(H + 1, INF);
	dp[0] = 0;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		rep(j, H) {
			int nj = min(j + a, H);
			dp[nj] = min(dp[nj], dp[j] + b);
		}
	}
	cout << dp[H];
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

template<int64 N>
struct BIT {
    int64 arr[N+1];

    BIT(int sz) {
        fill(arr, arr+N+1, 0);
    }

    void add(int x, int64 v) {
        for (int i = x; i <= N; i += i & -i) {
            arr[i] += v;
        }
    }

    int64 sum(int x) {
        int64 ans = 0;
        for (int i = x; i > 0; i -= i & -i) {
            ans += arr[i];
        }
        return ans;
    }
};

int N, K;
int64 a[200001];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K;
    for (int j = 1; j <= N; ++j) {
        cin >> a[j];
        a[j] -= K;
    }

    vector<int64> rv;

    a[0] = 0;
    for (int j = 1; j <= N; ++j) {
        a[j] += a[j-1];
        rv.push_back(a[j]);
    }
    sort(begin(rv), end(rv));

    int64 ans = 0;
    BIT<200000> bit(N);
    for (int j = N; j >= 1; --j) {
        if (a[j] >= 0) ++ans;
        int idx = lower_bound(begin(rv), end(rv), a[j]) - begin(rv) + 1;
        ans += bit.sum(N) - bit.sum(idx-1);
        bit.add(idx, 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int main(){
    unsigned int N;
    bool flag = false;
    cin >> N;
    string S,T,T2;
    cin >> S;
    if(N % 2 == 0){
        T = S.substr( 0,N / 2);
        T2 = S.substr(N / 2 , N);
        if(T == T2)
            flag = true;
    }
    if(flag){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC118D
{
    class Program
    {
        private static readonly int[] requiredMatch = { 2, 5, 5, 4, 5, 6, 3, 7, 6 };
        private int[] availableNumbers;
        private Dictionary<int, string> cache = new Dictionary<int, string>() { [0] = "" };

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Calc();
        }

        void Calc()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = temp[0]; // マッチ棒の本数
            var m = temp[1]; // 使用可能な数字の種類数(使わない)
            availableNumbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Console.WriteLine(Match(n));
        }

        string Match(int remainingMatch)
        {
            // 与えられたマッチ棒で作れる最大の整数を返す
            // - マッチ棒が0本の場合は空文字列を返す
            // - マッチ棒を余らせてしまう場合はnullを返す

            if (cache.ContainsKey(remainingMatch))
            {
                return cache[remainingMatch];
            }

            var max = "0";

            foreach (int number in availableNumbers)
            {
                if (requiredMatch[number - 1] <= remainingMatch)
                {
                    var next = Match(remainingMatch - requiredMatch[number - 1]);

                    if (next != null)
                    {
                        max = GetMax(number.ToString() + next, max);
                    }
                }
            }

            if (max != "0")
            {
                // Console.Error.WriteLine(remainingMatch + " : " + max);
                cache.Add(remainingMatch, max);
                return max;
            }
            else
            {
                cache.Add(remainingMatch, null);
                return null;
            }
        }

        string GetMax(string a, string b)
        {
            if (a.Length > b.Length)
            {
                return a;
            }
            else if (a.Length < b.Length)
            {
                return b;
            }
            else
            {
                return a.CompareTo(b) > 0 ? a : b;
            }
        }
    }
}


Measured memory_bytes: 95872
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  Scanner scanner=new Scanner(System.in);
  int n =scanner.nextInt();
  
  if(n<105){
  n=0;
  }else if (n<135){
  n=1;
  }else if (n<165){
  n=2;
  }else if (n<189){
  n=3;
  }else if (n<195){
  n=4;
  }else{
  n=5;
  }

  System.out.println(n);
  }
}

Measured memory_bytes: 22996
#include<stdio.h>
void swap(int *,int*);
int main (){
  int N,kar,i,j;
  int b[100];
  int flag = 1;
  int count = 0;
  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&b[i]);
  }
  while(flag != 0){
    flag = 0;
    for(j = N-1;j >= 1;j--){
      if(b[j] < b[j-1]){
	swap(&b[j],&b[j-1]);
	flag = 1;
	count++;
      }
    }
  }
  for(i=0;i<N-1;i++){ /*iは1過ぎている*/
    printf("%d ",b[i]);
  }
  printf("%d\n",b[N-1]);
  printf("%d\n",count);

    
  return 0;
}
void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}



Measured memory_bytes: 2124
#include <stdio.h>
int main(void)
{
  int i;
  char str[32];
  fgets(str,sizeof(str),stdin);
  for(i=0;i<5;i++)
  {
    printf("%c",str[i]);
  }
  printf(" ");
  for(i=6;i<13;i++)
  {
    printf("%c",str[i]);
  }
  printf(" ");
  for(i=14;i<19;i++)
  {
    printf("%c",str[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

vector<pair<long long, long long>> soinsu;

int main(){
	long long n;
	cin >> n;
	
	long long nuse = n;
	for(long long i=2; i*i<=n; i++){
		if(nuse % i != 0) continue;
		long long sisu= 0;
		
		while(nuse%i==0){
			++sisu;
			nuse /= i;
		}
		soinsu.push_back({i,sisu});
	}
	if(nuse != 1) soinsu.push_back({nuse,1});
	
	long long ans = 0;
	
	REP(i,soinsu.size()){
		long long count=1;
		while(soinsu[i].second >= count){
			ans++;
			soinsu[i].second -= count;
			count++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    sort(a.begin(), a.end());

    REP(i, N-1){
        if (a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

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

using namespace std;

long long h;

int main() {
	scanf("%lld", &h);
	long long k = 1, s = 0;
	while (k <= h) k *= 2, s++;
	long long ans = 0, g = 1;
	for (int i = 1; i <= s; ++i) {
		ans += g;
		g *= 2;
	} 
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 1e5 * 3 + 10;

int n, a[MAXN];
ll ans;

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i <= 3 * n; ++i)
        cin >> a[i];
    sort (a + 1, a + (3 * n) + 1);
    reverse (a + 1, a + (3 * n) + 1);
    for (int i = 2; i <= n * 2; i += 2)
        ans += a[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

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

}

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

int main() {
  int64_t H,W,M;
  cin>>H>>W>>M;
  set<int64_t> s;
  vector<pair<int,int64_t>> qw(H);
  vector<pair<int,int64_t>> as(W);
  for(int i=0;i<H;i++){
    qw[i].second=i;
  }
  for(int i=0;i<W;i++){
    as[i].second=i;
  }
  for(int i=0;i<M;i++){
    int64_t a,b;
    cin>>a>>b;
    a--,b--;
    s.insert(a*W+b);
    qw[a].first++;
    as[b].first++;
  }
  sort(qw.begin(), qw.end());
reverse(qw.begin(), qw.end());
  sort(as.begin(), as.end());
reverse(as.begin(), as.end());
  vector<int> er;
  vector<int> df;
  int Z=qw[0].first+as[0].first;
  int A=qw[0].first,B=as[0].first;
  for(int i=0;i<H;i++){
    if(A==qw[i].first){
      er.push_back(qw[i].second);
    }
    else{
      break;
    }
  }
  for(int i=0;i<W;i++){
    if(B==as[i].first){
      df.push_back(as[i].second);
    }
    else{
      break;
    }
  }
  int64_t X=er.size(),Y=df.size();
  int64_t L=X*Y;
  if(X*Y<=M){
    for(int i=0;i<X;i++){
      for(int j=0;j<Y;j++){
        int64_t K=er[i]*W+df[j];
        if(s.count(K)){
          L--;
        }
      }
    }
  }
  if(L==0){
    Z--;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 30804
//package atcoder;

import java.util.*;

public class Main {

    private static final int MAX = 1000000; // Wa want a solution with time O(Sqrt(N)) = O(Sqrt(10^12)) = 10^6.

    private static final int[] lp = new int[MAX + 1];
    private static final List<Integer> pr = new ArrayList<>();

    static {    // fast Eratosthenes sieve
        for (int i = 2; i <= MAX; ++i) {
            if (lp[i] == 0) {
                lp[i] = i;
                pr.add(i);
            }
            for (int j = 0; j < pr.size() && pr.get(j) <= lp[i] && i*pr.get(j) <= MAX; ++j) {
                lp[(i * pr.get(j))] = pr.get(j);
            }
        }
    }

    public static void main (String[] args) {

        final Scanner in = new Scanner(System.in);
        long N = in.nextLong();

        final long B = (long)Math.sqrt(N) + 1;
        long count = 0;

        final Set<Integer> usedPrimes = new HashSet<>();

        for (int prime = 2; prime <= Math.min(B, MAX); ++prime) {
            if (lp[prime] == prime && (N > 0) && (N % prime == 0)) {
                long z = prime;
                usedPrimes.add(prime);  // record prime
                while ((N > 0) && (N % z == 0)) { // try all z = prime, prime^2, prime^3, ...
                    count++;
                    N = N/z;
                    z = z*prime;
                }

                while ( (N > 0) && (N % prime == 0) ) {  // exhaust prime as a factor of N
                    N = N/prime;
                }
            }
        }

        if (N > 1 && test(N, usedPrimes)) { // N > 1 ==> some part of the initial value of N is still left;
            count++;                        // test == true ==> the remaining part N is having a prime factor P
            // (possibly being a prime itself, that is P = N) that is not among the recorded primes
            // This means that this P contributes with 1 more case: z = P^1.
        }

        System.out.println(count);
    }

    // checks if N is not divided evenly by any prime number in usedPrimes
    private static boolean test(final long N, final Set<Integer> usedPrimes) {
        for (int usedPrime : usedPrimes) {
            if (N % usedPrime == 0) {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 44036
#include<stdio.h>

int main(void){
	long int a;
	long int b;
	long int k;
	scanf("%ld %ld %ld",&a,&b,&k);
	if(k<a){
		a=a-k;
	}else{
		k=k-a;
		a=0;
		if(k<b){
			b=b-k;
		}else{
			b=0;
		}
	}
	printf("%ld %ld",a,b);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   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; }
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
        int n;
        cin>>n;
       char s[n];
       for(int i=0;i<n;i++)cin>>s[i];
       for(int i=0;i<n;i++){
           if(s[i]=='Y'){
               cout<<"Four"<<endl;
               return 0;
           }
       }
       cout<<"Three"<<endl;


   }
     


 


 






    





      

        


Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
#include <queue>
using namespace std;

#define rep(i, n) for(int i = 0 ; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main(){

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]++;
    int s = 0;
    int mx = 0;
    queue<int> q;

    rep(i, n){
        s += p[i];
        q.push(p[i]);
        if( q.size() > k ){
            s -= q.front();
            q.pop();
        }
        if( q.size() == k ){
            mx = max(mx, s);
        }
    }

    double ans = mx;
    ans /= 2;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    int N; cin >> N;
    string S; cin >> S;
    
    ll r=0, g=0, b=0;
    for (auto c : S){
        if (c=='R') r++;
        if (c=='G') g++;
        if (c=='B') b++;
    }
    
    ll ans = r * g * b;
    for (int d = 1; d <= N; d++){
        for (int m = 1; m < N-1; m++){
            if (m-d<0||m+d>N-1) continue;
            if (S[m-d]!=S[m+d] && S[m-d]!=S[m] && S[m]!=S[m+d]) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624