akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct edge{int to,cap,rev;};

const int MAX_V = 222;
const int F_INF = 19191919;
vector<edge> G[MAX_V];
int lv[MAX_V],it[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,0,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    memset(lv,-1,sizeof(lv));
    queue<int> que;
    lv[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && lv[e.to]<0){
                lv[e.to] = lv[v]+1;
                que.push(e.to);
            }
        }
    }
}

int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=it[v]; i<G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap>0 && lv[v]<lv[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(lv[t]<0) return flow;
        memset(it,0,sizeof(it));
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}

struct Point{ int x,y,v; };

inline double dist(const Point &p, const Point &q)
{
    return sqrt((p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y));
}

using pi = pair<int,int>;
using pd = pair<double,pi>;

int main()
{
    int n,m;
    while(scanf(" %d %d", &n, &m),n)
    {
        rep(i,MAX_V) G[i].clear();
        int S = n+m, T = S+1;

        vector<Point> t(n),b(m);
        rep(i,n) scanf(" %d %d %d", &t[i].x, &t[i].y, &t[i].v);
        rep(i,m) scanf(" %d %d", &b[i].x, &b[i].y);

        vector<pd> e;
        rep(i,n)rep(j,m) e.pb({dist(t[i],b[j])/t[i].v,pi(i,j)});
        sort(all(e));

        rep(i,n) add_edge(S,i,1);
        rep(i,m) add_edge(n+i,T,1);

        int idx = 0;
        int f = 0;
        int E = e.size();
        while(idx<E)
        {
            int u = e[idx].se.fi, v = n+e[idx].se.se;
            add_edge(u,v,1);
            f += max_flow(S,T);
            if(f==m) break;
            ++idx;
        }

        assert(idx<E);
        printf("%.10f\n", e[idx].fi);
    }
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	bool ok=0;
	for(int i=0; 4*i<=n&&!ok; i++){
		if((n-4*i)%7==0)ok=1;
	}
	if(ok)cout << "Yes";
	else cout << "No";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a=read();
    printf("%lld\n",48-a);
    return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define int ll

void solve()
{
    int n;
    cin>>n;
    vector<multiset<int>> v(4);
    for(int i=0;i<4;i++)v[i]=multiset<int>();
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v[0].insert(x+y);
        v[1].insert(x-y);
        v[2].insert(-x+y);
        v[3].insert(-x-y);
    }
    if(n==1){
        cout<<"0\n";
        return;
    }
    int ans=*(v[0].rbegin());
    v[0].erase(prev(v[0].end()));
    ans-=*(v[0].begin());
    ans=max(ans,(*(v[1].rbegin()))-(*(v[1].begin())));
    ans=max(ans,(*(v[3].rbegin()))-(*(v[3].begin())));
    ans=max(ans,(*(v[2].rbegin()))-(*(v[2].begin())));
    cout<<ans<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 41156
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
static const int INF = 1000010000;
//static const int NIL = -1;
//static const int MOD = 1000000007;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
//#define int ll

int k[214514] = {};

signed main(){
    int n;
    int a;
    scanf("%d%d",&n,&a);
    for(int i=0;i<n;i++){
        int tmp;
        scanf("%d",&tmp);
        k[tmp]++;
    }
    VI p;
    for(int i=0;i<214514;i++){
        if(k[i]) p.pb(k[i]);
    }
    int s = p.size();
    sort(all(p));
    int ans = 0;
    if(a>=s){
        printf("0\n");
        return 0;
    }
    for(int i=0;i<s-a;i++) ans += p[i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll                  long long
#define pb                  push_back
#define mp                  make_pair
#define in                  insert
#define sz(a)               (int)(a).size()
#define all(x)              (x).begin(), (x).end()
#define fore(i,a,b)         for(ll i=a; i<b; i+=1)
#define forr(i,a)           for(ll i=a; i>=0; i-=1)
#define forg(i,b,e,c)       for (ll i=(ll)b; i<(ll)e; i+=c)
#define ford(i,a)           for(auto i=a.begin(); i!=a.end(); i++) 
#define F first
#define S second
#define min3(a, b, c)       min(min(a, b), c)
#define min4(a, b, c, d)    min(min(a, b), min(c, d))
#define max3(a, b, c)       max(max(a, b), c)
#define max4(a, b, c, d)    max(max(a, b), max(c, d))
#define endl "\n"
#define printV(arr)         fore(x,0,sz(arr)) cout << arr[x] <<" "; cout<<endl;
#define setp(x)             fixed<<setprecision(x)
 
 
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll,ll> lll;
typedef vector<ii> vii;
typedef vector<lll> vlll;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<string> vs;
const int MAX=1e5+10;
const int MOD=1000000009;
const double pi=acos(-1);
const int dx[]={0,1,-1,0};
const int dy[]={-1,0,0,1};
const int dxc[]={0,1,-1,0,1,1,-1,-1};
const int dyc[]={-1,0,0,1,-1,1,-1,1};
 
ll min(ll a, ll b){
    if(a>b) return b;
    return a;
}
ll max(ll a, ll b){
    if(a>b) return a;
    return b;
}
 
ll gcd(ll a, ll b){
    while(b!=0){
        a%=b;
        swap(a,b);
    }
    return a;
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
bool isPrime(ll n){
    if(n<=1) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3; i*i<=n; i+=2){
        if(n%i==0) return false;
    }
    return true;
}
 
set<ll> gen(ll n){
    set<ll> divs;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            divs.insert(i);
            divs.insert(n/i);
        }
    }
    return divs;
}
 
map<ll, int> fact(ll n){
    map<ll, int> F;
    for(ll p = 2; p*p <= n; p++){
        while(n%p == 0){
            F[p]++;
            n /= p;
        }
    }   
    if(n > 1) F[n]++;
    return F;
}
 
ll sum(ll n){
    return (n*(n+1))/2;
}
 
ll binaryExp(ll a, ll b, ll c){
    if(b==0) return 1;
    if(b%2==0){
        ll temp=binaryExp(a,b/2,c);
        return (temp*temp)%c;
    }
    else{
        ll temp=binaryExp(a,b-1,c);
        return (temp*a)%c;
    }
}
 
bool isPal(string& cad){
    int p1=sz(cad)-1;
    fore(i,0,sz(cad)/2){
        if(cad[i]!=cad[p1]) return false;
        p1--;
    }
    return true;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n; cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  ll H,W; cin >> H >> W;
  
  ll S1,S2,S3,l;
  ll ans = 1e18;
  for (ll i = 1; i < H; i++) {
    S1 = i * W;
    l = (H-i) / 2;
    S2 = l * W;
    S3 = (H-i-l) * W;
    if (S1 <= S2) ans = min(ans, S3 - S1);
    else if (S1 >= S3) ans = min(ans,S1 - S2);
    else ans = min(ans,S3-S2);
    
    l = W / 2;
    S2 = (H-i) * l;
    S3 = (H-i) * (W-l);
    if (S1 <= S2) ans = min(ans, S3 - S1);
    else if (S1 >= S3) ans = min(ans,S1 - S2);
    else ans = min(ans,S3-S2);
  }
  
  swap(H,W);
  
  for (ll i = 1; i < H; i++) {
    S1 = i * W;
    l = (H-i) / 2;
    S2 = l * W;
    S3 = (H-i-l) * W;
    if (S1 <= S2) ans = min(ans, S3 - S1);
    else if (S1 >= S3) ans = min(ans,S1 - S2);
    else ans = min(ans,S3-S2);
    
    l = W / 2;
    S2 = (H-i) * l;
    S3 = (H-i) * (W-l);
    if (S1 <= S2) ans = min(ans, S3 - S1);
    else if (S1 >= S3) ans = min(ans,S1 - S2);
    else ans = min(ans,S3-S2);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
let inp_list = fun () ->
  List.map int_of_string (Str.split (Str.regexp "") (input_line stdin))
    
type op =
  | Plus
  | Cons

let rec list_all : int -> 'a list -> 'a list list  = fun n ol ->
  if n > 0 then
    List.fold_right (fun l ans ->
        List.fold_right
          (fun o xs ->
             (o :: l) :: xs)
          ol ans)
      (list_all (n - 1) ol) []
  else
    [[]]

let removeCons l ops =
  let rec loop =
    (function
      | (x1 :: x2 :: xs, o :: os) ->
        (match o with
           Plus ->
           let (ans_xxs, ans_os) = (loop (x2 :: xs, os)) in
           (x1 :: ans_xxs, o :: ans_os)
         | Cons -> loop (10 * x1 + x2 :: xs, os))
      | ([x], _) -> ([x],[])
      | _ -> failwith "Something happend in removeCons")
  in
  loop (l, ops)  

let sum = List.fold_left (fun s x -> s + x) 0

let ic c = int_of_char c - int_of_char '0' 

let () =
  let l = inp_list () in
  let n = List.length l in
  let ops_lists = list_all (n - 1) [Plus; Cons] in
  let rec solve = function
      [] -> 0
    | ops :: opss ->
      let (l' , _) = removeCons l ops in
      sum l' + solve opss
  in
  let ans = solve ops_lists
  in
  print_int ans;
  print_newline ()


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  char* m=(char*)malloc(8);
  if(! scanf("%d%d", (int*)m, (int*)(m+4)) ) exit(0);
  *(double*)m= (double) *(int*)m / *(int*)(m+4);
  printf("%f\n", *(double*)m);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    unsigned long : "%lu",\
                                    long int : "%ld",\
                                    char :"%c",char*:"%s")

int main(void){
    int n;
    char str[n];
    scanf("%d",&n);
    scanf("%s",str);
    int count  = 0;
    for(int i = 2;i < n;i++){
        if(str[i] == 'C' && str[i - 1] == 'B' && str[i - 2] == 'A')count++;
    }
    mprint(count);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<long>p(n);
  int i;
  for(i=0;i<n;i++){
    cin >> p[i];
  }
  vector<double>e(n);
  for(i=0;i<n;i++){
    e[i] = (double)(p[i]*(p[i]+1))/(2*p[i]);
  }
  vector<double>s(n);
  s[0] = e[0];
  for(i=1;i<n;i++){
    s[i] = s[i-1] + e[i];
  }
  double maxx = 0.0;
  for(i=k-1;i<n;i++){
    if(maxx<s[i]-s[i-k])maxx=s[i]-s[i-k];
  }
  printf("%.10lf",maxx);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
	ll n,t,i,j,x=-1e18,k=1e18;
    cin>>n;
    
    ll a,b,y=-1e18,m=1e18;
    for(i=0;i<n;i++){
        cin>>a>>b;
        x=max(x,a+b);
        k=min(k,a+b);
        y=max(y,a-b);
        m=min(m,a-b);
    }
    
    cout<<max(x-k,y-m);
    
	return 0;
}

Measured memory_bytes: 3616
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<map>
using namespace std;

int main() {
	int h,w,k;cin>>h>>w>>k;
	vector<vector<long long>> dp(h+1,vector<long long>(w,0));
	dp[0][0]=1;
	map<int,int> c;
	c[-1]=1;
	c[-2]=1;
	c[0]=1;
	c[1]=2;
	c[2]=3;
	for(int i=3;i<w;i++){
		c[i]=c[i-1]+c[i-2];
	}
	int def=1;
	for(int i=0;i<9;i++){
		def*=10;
	}
	def+=7;
	for(int i=1;i<h+1;i++){
		for(int j=0;j<w;j++){
			dp[i][j]=dp[i-1][j]*c[w-2-j]*c[j-1];
			if(j>0){
				dp[i][j]+=dp[i-1][j-1]*c[j-2]*c[w-2-j];
			}
			if(j<w-1){
				dp[i][j]+=dp[i-1][j+1]*c[j-1]*c[w-3-j];
			}
			dp[i][j]%=def;
		}
	}
//	for(int i=0;i<h+1;i++){
//		for(int j=0;j<w;j++){
//			cout<<dp[i][j]<<' ';
//		}
//		cout<<endl;
//	}
	cout<<dp[h][k-1]<<endl;
	return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N+1);
  for(int i=1; i<=N; i++){
    cin >> A[i];
  }
  for(int i=K+1; i<=N; i++){
    if(A[i] > A[i-K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4044
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	x %= b;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let w: f64 = read(&mut stdin_lock, &mut buf, b' ');
    let h: f64 = read(&mut stdin_lock, &mut buf, b' ');
    let x: f64 = read(&mut stdin_lock, &mut buf, b' ');
    let y: f64 = read(&mut stdin_lock, &mut buf, b'\n');
    let a = (w * h) / 2f64;
    let b = if (w / 2f64) == x && (h / 2f64) == y { 1 } else { 0 };
    print!("{:.6} {}", a, b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




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

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

int n,a,b,c,d;
signed main(){
  cin>>n>>a>>b>>c>>d;
  if(a > b)swap(a,b);
  a = b-a;
  rep(i,n){
    int upmax = d*i, upmin = c*i, dnmax = (-d)*(n-i-1), dnmin = (-c)*(n-i-1);
    if(upmin + dnmax <= a && a <= upmax + dnmin){
      cout << "YES" << endl;return 0;
    }
  }
  cout << "NO" << endl;
}


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

using namespace std;

int main(void) {
    int n;
    long long sum = 0, min, max, a;
    
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        cin >> a;
        if(i == 0){
            max = a;
            min = a;
        }
        if(max < a){
            max = a;
        } else if(min > a){
            min = a;
        }
        sum = sum + a;
    }
    cout << min << " " << max << " " << sum << "\n";
    
    return 0;
}

Measured memory_bytes: 1244
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	if a%2 == b%2 {
		fmt.Println(abs(a-b) / 2)
		return
	}
	v1 := min(max(a-1, b-1), max(n-a, n-b))

	d1 := a - 1 + 1
	b2 := b - d1
	a2 := 1

	d2 := n - b + 1
	a3 := a + d2
	b3 := n
	v2 := min((b2-a2)/2+d1, (b3-a3)/2+d2)
	fmt.Println(min(v1, v2))
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
num=int(input())
s=[int(i) for i in input().split()]
s.sort(reverse=True)
array=[]
for i in range(num-1):
    if i==0:
        array.append(s[i])
    else:
        array.append(s[i])
        array.append(s[i])
point=0
for i in range(num-1):
    if i==0:
        point+=array[i]
    else:
        point+=array[i]
print(point)

Measured memory_bytes: 31592
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;

vector<vector<int>> v(100010);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    int used[n]={};
    used[0] = 1;
    while(q.size()){
        int p = q.front();
        q.pop();
        for(auto i:v[p]){
            if(!used[i]){
                q.push(i);
                used[i] = p+1;
            }
        }
    }
    cout << "Yes\n";
    for(int i=1;i<n;i++){
        cout << used[i] <<"\n";
    }

}

Measured memory_bytes: 10116
#include <stdio.h>
#include <string.h>
int main(void){
        int i,j,m,n;
        char s[201],c[201];

        while(1){
                scanf("%s",s);
                if(s[0] == '-')
                        break;

                scanf("%d",&m);
                for(i=0;i<m;i++){
                        strcpy(c,s);
                        scanf("%d",&n);
                        for(j=0;j<n;j++)
                                s[strlen(c)-n+j] = c[j];
                        for(j=0;j<strlen(c)-n;j++)
                                s[j] = c[j+n];
                }
                puts(s);
        }
        return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL t;
    cin >> n >> t;
    vector<LL> a(n);
    vector<LL> max_a(n);
    vector<LL> min_a(n);
    for(LL i=0; i<n; i++){
        cin >> a[i];
        if(i==0){
            min_a[i]=a[i];
        }else{
            min_a[i]=min(min_a[i-1], a[i]);
        }
    }
    max_a[n-1]=a[n-1];
    for(LL i=n-2; i>=0; i--){
        max_a[i]=max(max_a[i+1], a[i]);
    }

    LL max_diff=0;
    for(LL i=0; i<n-1; i++){
        max_diff=max(max_diff, max_a[i+1]-min_a[i]);
    }

    //for( LL i=0; i<n; i++){
    //    cout << min_a[i] << " " << max_a[i] << endl;
    //}

    map<LL, LL> value_list;
    LL ans=0;
    for(LL i=0; i<n; i++){
        LL tmp=a[i]-max_diff;
        if(value_list.find(tmp)!=value_list.end()){
            value_list[tmp]--;
            ans++;
        }else{
            value_list[a[i]]++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11924
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Diagnostics;
using System.Threading;


namespace AtcoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            if (A == B)
            {
                Console.WriteLine("EQUAL");
            }
            else if (A.Length == B.Length)
            {
                for(int i = 0; i < A.Length; i++)
                {
                    if (int.Parse(A.Substring(i,1)) > int.Parse(B.Substring(i,1)))
                    {
                        Console.WriteLine("GREATER");
                        break;
                    }
                    if (int.Parse(A.Substring(i,1)) < int.Parse(B.Substring(i,1)))
                    {
                        Console.WriteLine("LESS");
                        break;
                    }
                }
            }
            else if (A.Length > B.Length)
            {
                Console.WriteLine("GREATER");
            }
            else
            {
                Console.WriteLine("LESS");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
typedef pair< int , int> P;
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const P& firstElof, const P& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=0;
std::cin >> x>>y>>z>>w;
for(int i=0;i<=x;i++){
  for(int j=0;j<=y;j++){
    for(int k=0;k<=z;k++){
      if(i*500+j*100+k*50==w)n++;
    }
  }
}
std::cout << n << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n;
  cin >> n;
  unordered_map< ll, ll > cnt;
  for (ll i=0; i<n; ++i) {
    ll a;
    cin >> a;
    if (cnt.count(a)==0) cnt[a] = 1;
    else cnt[a]++;
  }
  ll ans = 0;
  for (auto c : cnt) {
    if (c.first <= c.second) ans += c.second-c.first;
    else ans += c.second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4260
a=int(input())
b=[]
ans=0
for _ in range(a):
    b.append(tuple(map(str,input().split())))
for i in range(a):
    if b[i][1]=="JPY":
        ans+=int(b[i][0])
    else:
        ans+=float(b[i][0])*380000
print(ans)

Measured memory_bytes: 3060
cards = []
patterns = ['S', 'H', 'C', 'D']

for i in patterns:
    for j in range(1, 14):
        cards.append('{} {}'.format(i, j))

n = int(input())

for _ in range(n):
    card = input()
    cards.remove(card)

for c in cards:
    print(c)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

string n; int k;
set<int> d;
ll mod = 1e9+7;

ll fpow(ll a, ll b, ll md){
	ll res = 1;
	a = (a%md);
	while(b>0){
		if(b%2==1){
			res = (res*a)%md;
		}
		b = b/2;
		a = (a*a)%md;
	}
	return res%md;
}

int f(int i, int num){
	if(i >= n.size()+1){
		// if(num==9999) cout<<"here"<<endl;
		if(num >= stoi(n)){
			return num-stoi(n);
		}
		else{
			return INT_MAX;
		}
	}

	int ans = INT_MAX;
	for(int j=0;j<10;j++){
		if(d.count(j)) continue;
		ans = min(ans, f(i+1,num+ j*fpow(10,i,mod)));
	}
	if(i==n.size()){
		ans = min(ans, f(i+1,num));
	}
	return ans;
}

int main(){
	fastread;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int u;
		cin>>u;
		d.insert(u);
	}
	int dif = f(0,0);
	// cout<<dif<<endl;
	cout<<stoi(n)+dif<<endl;




	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1e9+7 ;

int main(){
  ll h,w;
  cin >> w >> h;
  ll p[w],q[h];
  rep(i,w)cin >> p[i];
  rep(i,h)cin >> q[i];
  sort(p,p+w);
  sort(q,q+h);
  ll sump[w]={},sumq[h]={};
  rep(i,w){
    sump[i]+=p[i];
    sump[i+1]=sump[i];
  }
  rep(i,h){
    sumq[i]+=q[i];
    sumq[i+1]=sumq[i];
  }
  ll ans=longinf;
  ll temp=sump[w-1]+sumq[h-1];
  rep(i,w){
    int x=upper_bound(q,q+h,p[i])-q;
    if(x>=1)temp+=sumq[x-1];
    temp+=(h-x)*p[i];
  }
  ans=min(ans,temp);
  cout << ans << endl;
return 0;}

Measured memory_bytes: 3328
k = int(input())
s = input()
MOD = 10**9+7

class Facts():
    # O(max_num)
    def __init__(self, max_num=10**5, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        # nCk mod p with memo
        # O(log(p))
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[k]
        c = self.fact[n-k]
        return (a*self.power_func(b, self.p-2) *
                self.power_func(c, self.p-2)) % self.p

    def power_func(self, a, b):
        # a^b mod p
        # O(log(b))
        ans = 1
        while b > 0:
            if b & 1:
                ans = ans * a % self.p
            a = a * a % self.p
            b >>= 1
        return ans

r26 = [1 for _ in range(k + 1)]
r25 = [1 for _ in range(k + 1)]
for i in range(1, k+1):
   r26[i] = (r26[i-1] * 26) % MOD
   r25[i] = (r25[i-1] * 25) % MOD
facts = Facts(max_num=len(s)+k+1, p=MOD)

total = len(s) + k
ans = 0
for s_n in range(len(s), total+1):
   d = total - s_n
   ans += facts.comb(total - d - 1, len(s) - 1) * r25[k-d] * r26[d]
   ans %= MOD

print(ans)


Measured memory_bytes: 166584
let g=print_newline;;let rec f()=Scanf.scanf"%d %d
"(fun h w->if h>0&&w>0then(for i=1to h do for j=1to w do print_char(if i>1&&i<h&&j<w&&j>1then '.'else '#')done;g()done;f(g())));;f()

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.size()) {
        mp[s[i]]++;
    }

    vi cnt(3, 0);
    int seq = 0;
    for(auto &p : mp) {
        cnt[seq] = p.se;
        seq++;
    }

    SORT(cnt);
    if(abs(cnt[0]-cnt[2])>1) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int i = 1;
    do {
      int x = i;
      if (x % 3 == 0){
        System.out.print(" " + i);
        continue;
      }
      while(true){
        if(x % 10 == 3){
          System.out.print(" " + i);
          break;
        }
        x /=10;
        if (x != 0) continue;
        else break;
      }
    }while (++i <= n);
    System.out.println();
  }
}

Measured memory_bytes: 28796
#include <stdio.h>
#define N 100
int main(){

  int i,j,num;
  int minj,count=0;
  int A[N],tmp;

  scanf("%d",&num);
  
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }

 
  for(i=0;i<num;i++){
    minj=i;
    for(j=i;j<num;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(A[i]!=A[minj]){
      count++;
    }
    tmp=A[minj];
    A[minj]=A[i];
    A[i]=tmp;
     
  }


for(i=0;i<num-1;i++){
  printf("%d ",A[i]);
 }
printf("%d\n",A[num-1]);
printf("%d\n",count);



return 0;
}



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

int main() {
  int n, m = 0;
  cin >> n;
  vector<vector<pair<int, bool>>> v(n, vector<pair<int, bool>>());
  rep(i, n){
    int a;
    cin >> a;
    rep(j, a){
      int b;
      bool c;
      cin >> b >> c;
      v[i].push_back(make_pair(b, c));
    }
  }
  rep(i, (1 << n)){
    int d = 0;
    bool e = 1;
    rep(j, n){
      if(i & (1 << j)){
        ++d;
        for(auto p: v[j]){
          if((p.second && (i & (1 << p.first - 1))) || (!p.second && !(i & (1 << p.first - 1)))) continue;
          else{
            e = 0;
            break;
          }
        }
        if(!e) break;
      }
    }
    if(e) m = max(m, d);
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[N-1])


Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long  A, B;
	int K;
	scanf("%lld%lld%d", &A, &B, &K);
	for (long long i = A; i <= min(B, A + K - 1); i++) {
		printf("%lld\n", i);
	}
	for (long long i = max(B - K + 1, A + K); i <= B; i++) {
		printf("%lld\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect＿left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int main (){

  int num, nums, i, j, cnt=0;

  scanf("%d", &num);

  int n[num];

  for(i=0; i<num; i++){

    scanf("%d", &n[i]);
    
  }

  for(i=0; i<num; i++){

    for(j=num-1; j>i; j--)
      if(n[j] < n[j-1]){
	nums = n[j];
	n[j]=n[j-1];
	n[j-1]=nums;
	cnt++;
      }

  }

  for(i=0;i<num;i++){
    if(i>0)printf(" ");
    printf("%d", n[i]);
    if(i==num-1)printf("\n");
  }
  printf("%d\n",cnt);

  return 0;
  
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std;

int main()
{
FASTIO
//input_from_file

int n;
cin >> n;

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

int dp[n];
dp[0] = 0;
if(n == 1){
  cout << 0;
  return 0;
}

dp[1] = abs(a[1] - a[0]);

for(int i = 2; i < n; i++){
  int x = abs(a[i] - a[i-1]) + dp[i-1], y = abs(a[i] - a[i-2]) + dp[i-2];
  dp[i] = min(x, y);
}

cout << dp[n-1];
}


Measured memory_bytes: 1024
from math import *
PI = 3.1415926535898
pool = []
pool.append("1100000011")
pool.append("1000000010000000100000001")
pool.append("1111")
pool.append("1000000110000001")
pool.append("11000000011")
pool.append("100000001100000001")
pool.append("110000011")
while True:
	try:
		pat = ""
		for i in range(8):
			s = str(raw_input())
			while len(s) == 0:
				s = str(raw_input())
			pat += s
		flag = False
		tp = ""
		for x in pat:
			if x != '0':
				flag = True
			if flag:
				tp += x
		pat = reversed(tp)
		flag = False
		tp = ""
		for x in pat:
			if x != '0':
				flag = True
			if flag:
				tp += x
		pat = tp
		print chr(pool.index(pat) + ord('A'))
	except EOFError:
		break

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong A, B;

	cin >> A >> B;
	if ((A-B)%2 == 0) {
		cout << min(A,B) + abs(A-B)/2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string s;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> s;
  int c = s.length() - 2;
  if (s[0] == s[s.length()-1]) c--;
  if (c % 2 == 0) cout << "Second\n";
  else cout << "First\n";
  return 0;
}


Measured memory_bytes: 512
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec2<ll> tree;

Vec ans, a, x;

void dfs(ll node, ll par){
	if(par != -1) ans[node] = ans[par];
	ll p = lower_bound(all(x), a[node]) - x.begin();
	ll t = x[p];
	x[p] = a[node];
	chmax(ans[node], p + 1);
	for(ll i : tree[node]) if(i != par) dfs(i, node);
	x[p] = t;
}

int main(void){
	ll n;
	cin >> n;
	tree.resize(n);
	ans.resize(n);
	a.resize(n);
	x.assign(n, LINF);
	rep(i, n) cin >> a[i];

	rep(i, n - 1){
		ll u, v;
		cin >> u >> v;
		u--, v--;
		tree[u].pb(v);
		tree[v].pb(u);
	}

	dfs(0, -1);
	rep(i, n) co(ans[i]);

	return 0;
}


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

int main()
{
	char InpS[11];
	string S;
	int ans = 999;

	for (int i = 0; i < 11; i++)
	{
		InpS[i] = NULL;
	}
	cin >> InpS;
	S = InpS;

	for (uint16_t i = 0; i <= S.length() - 3; i++)
	{
		int c;

		c = abs(atoi(S.substr(i, 3).c_str()) - 753);
		if (ans > c) ans = c;
	}

	cout << ans << endl;

	return(0);
}


Measured memory_bytes: 256
#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; cin>>n;
    vector<int> ans;
    int a[200020];
    for(int i=1; i<=n; i++) cin>>a[i];
    int b[200020]={};
    for(int i=n; i>=1; i--){
        b[i]=a[i];
        for(int j=2*i; j<=n; j+=i){
            b[i]^=b[j];
        }
        if(b[i]) ans.push_back(i);
    }
    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); i++){
        cout<<ans[i];
        if(i<(int)ans.size()-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

int main(){
  int r, d, x; cin >> r >> d >> x;
  int mo[10];
  mo[0] = x*r-d;
  for(int i=1;i<=10;i++){
    mo[i] = mo[i-1] * r - d;
  }
  for(auto m:mo){
    cout << m << endl;
  }
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;
int main()
{
	int a,b,x;
	cin>>x>>a>>b;
	if(abs(a-x)>abs(b-x))
	{
		cout<<"B"<<endl;
	}
	else
	{
		cout<<"A"<<endl;
	}
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

class BIT {
   public:
    explicit BIT(int64_t nn) : n(pow(2, ceil(log2(nn)))), b(n + 1) {}

    void init() { b.assign(n + 1, 0); }

    // [0, i)の和
    int64_t sum(int64_t i) const {
        int64_t s = 0;

        while (i > 0) {
            s += b[i];
            i -= (i & -i);
        }

        return s;
    }

    void add(int64_t i, int64_t a) {
        // 1-indexedに直す
        ++i;

        while (i <= n) {
            b[i] += a;
            i += (i & -i);
        }
    }

   private:
    int64_t n;
    vector<int64_t> b;
};

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> r = a;
    sort(r.begin(), r.end());

    BIT bit(2 * n);
    auto ans = *partition_point(r.begin(), r.end(), [&](int64_t m) {
        vector<int64_t> b(n + 1);
        b[0] = n;
        for (auto i : irange(1L, n + 1)) {
            b[i] = b[i - 1] - 1;
            if (a[i - 1] <= m) {
                b[i] += 2;
            }
        }

        bit.init();
        bit.add(b[0], 1);
        int64_t k = 0;
        for (auto i : irange(1L, n + 1)) {
            k += bit.sum(b[i]);
            bit.add(b[i], 1);
        }

        return k <= n * (n + 1) / 2 / 2;
    });

    cout << ans << endl;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m;i < n;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define fi first
#define se second
const int inf = 1e9;

vector<PP> vs;
multiset<int> s{inf};
int main(){
	int n;
	scanf("%d", &n);
	rep(i,n){
		int x, y;
		scanf("%d%d",&x, &y);
		vs.push_back(PP(x, P(y, 0)));
	}
	rep(i,n){
		int x, y;
		scanf("%d%d", &x, &y);
		vs.push_back(PP(x, P(y, 1)));
	}
	sort(vs.begin(), vs.end());
	
	int ans = 0;
	rep(i,2*n){
		PP pp = vs[i];
		int x = pp.fi, y = pp.se.fi;
		int f = pp.se.se;
		if(f){
			auto it = s.upper_bound(-y);
			if(*it == inf)continue;
			s.erase(it);ans++;
		}else{
			s.insert(-y);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string n;
  cin >> n;
  if(n[0]==n[1]||n[1]==n[2]||n[2]==n[3])cout << "Bad" << endl;
  else cout << "Good" << endl;
}  


Measured memory_bytes: 768
#include <stdio.h>
#include <algorithm>
using namespace std;

int a[10010],b[10010],c[10010],flag[10010],in[10010],num[10010];


int main()
{
    int n;scanf("%d",&n);int ans=0;
    for (int i=1;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        in[a[i]]++;in[b[i]]++;
    }
    for (int i=1;i<=n;i++)
        scanf("%d",&c[i]);
    sort(c+1,c+n+1);
    for (int i=1;i<=n;i++) flag[i]=1;
    int now=1;
    while(1)
    {
        int tmp=n+1;
        for (int j=1;j<=n;j++)
            if (flag[j])
                if (in[j]<tmp) tmp=in[j];
        if (tmp==n+1) break;
        for (int j=1;j<=n;j++)
        if (flag[j] && (in[j]==tmp) )
        {
            num[j]=c[now];
            flag[j]=0;
            if (now<n) ans+=c[now];
            now++;
        }
        for (int i=1;i<=n;i++) in[i]=0;
        for(int j=1;j<n;j++)
            if(flag[a[j]] && flag[b[j]]) in[a[j]]++,in[b[j]]++;
    }

    printf("%d\n",ans);
    for (int i=1;i<n;i++)
        printf("%d ",num[i]);
    printf("%d",num[n]);

}


Measured memory_bytes: 512
n = gets.chomp.to_i
t, a = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)
idx = 0
abs_min = 1_000_000_000
(0..(n - 1)).each do |i|
  tmp = (a - (t - h[i] * 0.006)).abs
  if tmp < abs_min
    abs_min = tmp
    idx = i
  end
end
puts (idx + 1)

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
)

var Err error = errors.New("cannot read from stdin")
var m = map[string]string{
	"A": "T",
	"T": "A",
	"C": "G",
	"G": "C",
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	if !sc.Scan() {
		panic(Err)
	}
	fmt.Println(m[sc.Text()])
}

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

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

    int minnum = 1001001001;
    int maxnum = -1;
    for(int i = 0; i < n; i++){
        if(a[i] > maxnum) maxnum = a[i];
        if(a[i] < minnum) minnum = a[i];
    }

    cout << maxnum-minnum << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
import copy
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
sa, sb = ns().split()

tb = ''.join(sb.split("."))

a = int(sa)
b = int(tb)

print(a*b//100)

Measured memory_bytes: 68232
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int K, R, L;
Double P, E, T;

Double rec(int i, Double pp, Double lb, Double ub) {
	if (i == K) {
		Double med = (lb + ub) / 2.;
		if (abs(med - T) < E) return pp;
		return 0.0;
	}
	
	if (T + E < lb || ub < T - E) return 0.0;
	if (T - E < lb && ub < T + E) return pp;
	
	Double med = (lb + ub) / 2.;
	
	Double res = 0.0;
	if (T < med) {
		res += rec(i + 1, pp * (1 - P), lb, med);
		res += rec(i + 1, pp * P, med, ub);
	} else {
		res += rec(i + 1, pp * P, lb, med);
		res += rec(i + 1, pp * (1 - P), med, ub);
	}
	
	return res;
}

void solve() {
	printf("%lf\n", rec(0, 1.0, (Double)R, (Double)L));
}

int main() {
	cin >> K >> R >> L;
	cin >> P;
	cin >> E;
	cin >> T;
	solve();
	return 0;
}

Measured memory_bytes: 1244
N,T = gets.split.map(&:to_i)
t = gets.strip.split.map(&:to_i)
answer = 0

if N == 1

    answer += T 

else

    for i in 0..N-2
 
        if t[i+1]-t[i] < T 

            answer += t[i+1]-t[i]

        else 

            answer += T 

        end

    end

    answer += T 

end

puts answer 




Measured memory_bytes: 17924