akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    int d; cin >> d;
    ll g; cin >> g;
    vector<ll> p(d);
    vector<ll> c(d);
    rep(i, d) cin >> p[d - 1 - i] >> c[d - 1 - i];

    int min_count = 100000000;
    int count, sum;
    bool flag;
    for(int bit = 0; bit < (1 << d); bit++){
        flag = false;
        count = 0; 
        sum = 0;
        for(int i = 0; i < d; i++){
            if(bit & (1 << i)){
                int num;
                if((g - sum) > (d - i) * 100 * p[i] + c[i]){
                    sum += (d - i) * 100 * p[i] + c[i];
                    count += p[i];
                }else{
                    num = min(((g - sum) + ((d - i) * 100) - 1) / ((d - i) * 100), p[i]);
                    count += num;
                    flag = true;
                }
            }
            if(flag) break;
        }
        //cout << count << endl;
        if(flag) min_count = min(count, min_count);
    }
    cout << min_count << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> h(n), dp(n + 2, INF);
  for (int i = 0; i < n; i++) cin >> h[i];
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = min(dp[i] + abs(h[i] - h[i + 1]), dp[i + 1]);
    dp[i + 2] = min(dp[i] + abs(h[i] - h[i + 2]), dp[i + 2]);
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAXN 100005
#define reg register
#define inl inline
using namespace std;
int n,a[MAXN],f[MAXN],sum[MAXN],ans,_[25];
int Dfs(reg int x)
{
    if(!x) return 0;
    if(f[x]!=-1) return f[x];
    f[x]=2e9;
    for(reg int i=0;i<16;i++)
    {
        if(x&_[i])
        {
            for(reg int j=0;j<16;j++)
            {
                if((x&_[j]) && i!=j)
                {
                    reg int y=i^j,nxt=x^_[i]^_[j]^_[y];
                    if(x&_[y]) f[x]=min(f[x],Dfs(nxt)+2);
                    else f[x]=min(f[x],Dfs(nxt)+1);
                }
            }
        }
    }
    return f[x];
}
int main()
{
    memset(f,-1,sizeof(f));
    scanf("%d",&n);
    for(reg int i=1;i<n;i++)
    {
        reg int x,y,z;
        scanf("%d %d %d",&x,&y,&z);
        x++;
        y++;
        a[x]^=z;
        a[y]^=z;
    }
    for(reg int i=1;i<=n;i++) sum[a[i]]++;
    _[0]=1;
    reg int t=0;
    for(reg int i=1;i<=16;i++) _[i]=_[i-1]<<1;
    for(reg int i=1;i<16;i++)
    {
        ans+=sum[i]>>1;
        t+=_[i]*(sum[i]&1);
    }
    ans+=Dfs(t);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
 
const int N=1e6+5,MOD=1000000007;
 
int n,idx[N],q,m,u,tc,k,l,x,y;
 
ll ans;
 
char s[N];
struct cmp
{
    bool operator()(const pair<int,int> &a,const pair<int,int> &b){
        if (a.second>b.second)
            return true;
    	if(b.second>a.second)
    	   return false;

        return a.first<b.first;
    }
};
 
 
vector<string> v;
 
pair<int,int> a[N];
 
int main(){ 
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
  
    scanf("%d %d",&n,&m);
    priority_queue<pair<int,int>,vector<pair<int,int> >,cmp > curr;
    priority_queue<pair<int,int>,vector<pair<int,int> > > pq;
    for(int i=0;i<n;i++){
        scanf("%d %d",&a[i].first,&a[i].second);
        if (a[i].first<=m)
            pq.push(a[i]);
    }
    int last=m+1;
    while(!pq.empty()){
        pair<int,int> x=pq.top();
        pq.pop();
        if (x.first<last){
            curr.push(x);
            last--;
        }
        else{
            int y=curr.top().second;
            //printf("%d %d\n",curr.top().first,curr.top().second);
            if (x.second>y){
                curr.pop(),curr.push(x);
            }
        }
    }
    while(!curr.empty()){
        ans+=curr.top().second;
        curr.pop();
    }
    printf("%lld\n",ans);
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int dp[5050][5050];

void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s;
  t = s;
  dump(s, t);
  // dp[s.size() + 2][t.size() + 2]のテーブルが必要
  rep(i, s.size() + 1) rep(j, t.size() + 1) {
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
    if (i < s.size() && j < t.size() && s[i] == t[j]) {
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
    }
  }
  // dumpv(dp, (int)(s.size()+1), (int)(t.size()+1));
  rep(i, s.size() + 1) rep(j, t.size() + 1) dp[i][j] = 0;
  for (int i = s.size() - 1; 0 <= i; i--) {
    for (int j = t.size() - 1; 0 <= j; j--) {
      if (s[i] == t[j]) {
        dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
      }
    }
  }
  // dumpv(dp, (int)(s.size()+1), (int)(t.size()+1));
  int ans = 0;
  // rep(i, n) rep(j, n) {
  //   if (j <= i) continue;
  //   int len = min(dp[i][j], j - i);
  //   ans = max(ans, len);
  // }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int len = min(dp[i][j], j - i);
      ans = max(ans, len);
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 98944
#include<bits/stdc++.h>
using namespace std;
#define dscan(a,b) scanf("%d %d",&a,&b);
#define scan(a) scanf("%d",&a);
#define pin(a) printf("%d\n",a)
#define pll(a) printf("%I64d\n",a);
#define inf 1000000009
#define infmx 1e18
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define all(x) x.begin(),x.end()
typedef pair<int,int>pi;
typedef pair<long long,long long>pll;
typedef vector<int>vi;
const int N=2100000;
ll mod=1e9+7;
int power(int a,int p){int r=1,y=a;while(p){if(p&1)r=(1LL*r*y)%mod;p>>=1;y=(1LL*y*y)%mod;}return r;}
int ara[N];
int main()
{
    IOS;
    int n;cin>>n;
    vector<int>v;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        sum+=a;
        if(a%10!=0)v.pb(a);
    }
    if(sum%10==0){
        sort(all(v));
        if(v.size()==0)sum=0;
        else{
            sum-=v[0];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3628
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let n:usize = read();
    let mut x:i32 = read();
    let mut a:Vec<i32> =(0..n).map(|_| read()).collect();

    a.sort();
    let mut ans:i32 = 0;
    for &el in a.iter() {
        //debug!(x,el,ans);
        if x - el > 0 {
            ans += 1;
            x -= el;
        } else if x - el == 0 {
            x -= el;
            ans += 1;
            break;
        } else {
            x -= el;
            break;
        }
    }
    //debug!(ans,x);

    println!("{}", if x > 0 {ans-1} else {ans});

}


Measured memory_bytes: 4352
#[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")
    };
}

use std::collections::BinaryHeap;
fn main() {
    input!{
        n:usize,
        k:usize,
        v:[i64;n],
    }
    let u = std::cmp::min(n,k as usize);
    let mut ans:i64 = 0;
    for i in 0..u+1 {
        for j in 0..u-i+1 {
            let mut heap = BinaryHeap::new();
            for kk in 0..i {
                heap.push(-v[kk]);

            } // A
            for l in 0..j {
                heap.push(-v[n-1-l]);
            } // B
            // println!("{:?}", heap);
            let mut sum = 0;
            let mut counter = 1;
            while heap.peek() != None {
                if heap.peek() <= Some(&0) {
                    break;
                }
                if counter +i +j > k {
                    break;
                }
                heap.pop();
                counter+=1;
                // println!("{}", counter);
            }
            // println!("{:?}", heap);
            while let Some(m) = heap.pop() {
                sum -= m;
            }
            ans = std::cmp::max(ans, sum);
        }
    }
    println!("{}", ans);

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e3+7;
inline int read(){
	int x=0,f=1;char C=getchar();
	while(!isdigit(C)){if(C=='-') f=-1;C=getchar();}
	while(isdigit(C)) x=(x<<1)+(x<<3)+C-'0',C=getchar();
	return x*f;
}
int n,m,q,a[maxn][maxn],sumn[maxn][maxn],sume1[maxn][maxn],sume2[maxn][maxn];
int main(){
//	freopen("wang.in","r",stdin);
//	freopen("wang.out","w",stdout);
	n=read(),m=read(),q=read();
	char C=getchar();
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++){
	  	while(!isdigit(C)) C=getchar();
	  	a[i][j]=C-'0',C=getchar();
	  }
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	    sumn[i][j]=sumn[i][j-1]+sumn[i-1][j]-sumn[i-1][j-1]+a[i][j],
	    sume1[i][j]=sume1[i][j-1]+sume1[i-1][j]-sume1[i-1][j-1]+(a[i][j]==a[i][j+1]&&a[i][j]==1),//-
	    sume2[i][j]=sume2[i][j-1]+sume2[i-1][j]-sume2[i-1][j-1]+(a[i][j]==a[i+1][j]&&a[i][j]==1);//|
	while(q--){
		int xx=read()-1,yy=read()-1,x1=read(),y1=read();
		int N=sumn[x1][y1]-sumn[xx][y1]-sumn[x1][yy]+sumn[xx][yy];
		int M=sume1[x1][y1-1]-sume1[xx][y1-1]-sume1[x1][yy]+sume1[xx][yy];
		M+=sume2[x1-1][y1]-sume2[xx][y1]-sume2[x1-1][yy]+sume2[xx][yy];
//		cout<<N<<" "<<M<<endl;
		printf("%d\n",N-M);
	}
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    vector<int> v;
    for (int i = 0; i < 10; i++) {
      if (1 << i & n) {
        v.push_back(1 << i);
      }
    }
    cout << v[0];
    for (size_t i = 1; i < v.size(); i++) {
      cout << " " << v[i];
    }
    cout << "\n";
  }
}


Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n; cin >> n;
	string s = "";
	string t;
	for (int i = 0; i < n; i++) {
		cin >> t; s += t;
	}
	set<int> st;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 9&&j<=n-i; j++) {
			string u = s.substr(i, j);
			int x = stoi(u);
			st.insert(x);
		}
	}
	int out = 0;
	while (st.count(out))out++;
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll a;
  cin >> a;
  
  char c; cin >> c;
  ll b;
  cin >> b;
  
  if (c == '+')
    cout << a + b << endl;
  else
    cout << a - b << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <vector>
#include <queue>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define MAX_V 100005
#define INF (1 << 30)

class Dinic {
    public:

    struct edge {int to, cap, rev;};
    
    vector<edge> G[MAX_V];
    int level[MAX_V];
    int iter[MAX_V];
    
    void add_edge(int from, int to, int cap) {
        G[from].push_back((edge){to, cap, (int)G[to].size()});
        G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
    }
    
    void bfs(int s) {
        memset(level, -1, sizeof(level));
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (int i = 0; i < G[v].size(); i++) {
                edge &e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }
    
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = 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;
        for (;;) {
            bfs(s);
            if (level[t] < 0) return flow;
            memset(iter, 0, sizeof(iter));
            int f;
            while ((f = dfs(s, t, INF)) > 0) {
                flow += f;
            }
        }
    }

};

int main() {
    
    int N; cin >> N;
    vi a(N), b(N), c(N), d(N);
    REP(i, N) cin >> a[i] >> b[i];
    REP(i, N) cin >> c[i] >> d[i];

    Dinic dinic;
    
    REP(i, N) REP(j, N) {
        if (a[i] < c[j] && b[i] < d[j]) dinic.add_edge(i, j + N, 1);
    }

    // s -> 2N, t -> 2N + 1
    int s = 2 * N;
    int t = s + 1;
    REP(i, N) {
        dinic.add_edge(s, i, 1);
        dinic.add_edge(i + N, t, 1);
    }

    cout << dinic.max_flow(s, t) << endl;


    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,w[100],sum,now,ans=INF;

signed main() {
    cin >> n;
    rep(i,n) cin >> w[i],sum+=w[i];
    rep(i,n) {
        now += w[i];
        ans = min(ans,abs(sum-now-now));
    }
    cout << ans << endl;
}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int ans = 0;
	int n, h, w;cin >> n >> h >> w;
	REP(i, n){
		int a, b;cin >> a >> b;
		if(a >= h && b >= w)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int min(int x,int y){
	if(x > y)
		return y;
	else 
		return x; 
}

int abss(int x){
	if(x < 0)
		return (-1)*x;
	else
		return x;
}
int main(){
	int n,x,y;
	scanf("%d %d %d",&n,&x,&y);
	
	int a[n+1][n+1];
	int b[n];
	
	int i,j;
	for(i = 0;i < n;i++)
		b[i] = 0;
		
	
	for(i = 1;i <= n;i++){
		for(j = i;j <= n;j++){
			if(i == j)
				a[i][j] = 0;
			else{
				a[i][j] = min(abss(i - x) + abss(y - j) + 1,j - i);
				b[a[i][j]]++;
			}
			//printf("%d ",a[i][j]);
			
		}
		//printf("\n");
	} 
	
	
	for(i = 1;i < n;i++){
		printf("%d\n",b[i]);
	}
	
	return 0;
	
	// 
}

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

int main() {
	// your code goes here
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if (b<=c){
		cout << 0 << endl;
	}
	else if (d<=a){
		cout << 0 << endl;
	}
	else if (a>=c){
		if (b>d){
			cout << d-a << endl;
		}
		else cout << b-a << endl;
	} 
	else if (a<=c){
		if (b>d){
			cout << d-c << endl;
		}
		else cout << b-c << endl;
	}

	
	
	return 0;
}	

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    sort(all(s));
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

#define MAXN 100000

vector<ll> connected[MAXN];
ll path_length[MAXN];

ll dfs(ll i){
  if(path_length[i]!=-1) return path_length[i];
  if(connected[i].size()==0){
    path_length[i] = 0;
    return path_length[i];
  }
  ll max_length = 0;
  for(ll node : connected[i]){
    max_length = max(max_length,dfs(node));
  }
  path_length[i] = max_length + 1;
  return path_length[i];
}

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

  REP(i,m){
    ll x,y;
    cin >> x >> y;
    x--, y--;
    connected[x].push_back(y);
  }

  fill(path_length,path_length+n,-1);
  ll ans = 0;
  REP(i,n) ans=max(ans,dfs(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8576
n=int(input())
d=sorted(list(map(int,input().split())))
#print(d)
res=0
if n % 2 == 0:
    m=int(n/2)
    #print(d[m],d[m+1])
    if d[m-1] == d[m]:
        pass
    else:
        res = d[m] - d[m-1] 

else:
    pass
    
    
print(res)
        

Measured memory_bytes: 14396
N, u, v = map(int, input().split())
tree = [[] for i in range(N + 1)]
for _ in range(N - 1):
	a, b = map(int, input().split())
	tree[a].append(b)
	tree[b].append(a)

def dfs(node):
	sta = [node]
	dis = [-1] * (N + 1)
	dis[node] = 0
	while sta:
		no = sta.pop()
		tempD = dis[no] + 1
		for tempN in tree[no]:
			if dis[tempN] < 0:
				dis[tempN] = tempD
				sta.append(tempN)
	else:
		return dis

disU = dfs(u)
disV = dfs(v)
ans = 0

for u_, v_ in zip(disU[1:], disV[1:]):
	if u_ < v_:
			ans = max(ans, v_)
else:
	print(ans - 1)

Measured memory_bytes: 30004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.FileStore;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] order;
      StringBuilder result = new StringBuilder(n*4);
      Dictionary dict = new Dictionary(10_000_000);

      for(int i=0; i<n; i++) {
        order = br.readLine().split(" ");
        switch( order[0] ) {
          case "insert" :
            dict.insert(order[1]);
            break;
          case "find" :
            result.append( dict.find(order[1]) ).append("\n");
            break;
        }
      }

      System.out.print(result);
    }
  }
}

class Dictionary {
  boolean[] dict;

  public Dictionary(int size) {
    dict = new boolean[size];
  }

  public void insert(String str) {
    int key   = getKey(str);
    dict[key] = true;
  }
  public String find(String ref) {
    int key = getKey(ref);

    return isExist(key) ? "yes" : "no";
  }
  private int getKey(String str) {
    int len = str.length();
    int ret = 0;
    StringBuilder buf = new StringBuilder(12);
    for(int i=0,d=10; i<len; i++ ) {
      buf.append( str1ToInt(str.substring(i,i+1)) );
    }
    ret = Integer.parseInt(buf.toString(), 5);

    return ret;
  }
  private boolean isExist(int key) {

    return dict[key];
  }
  private int str1ToInt(String s1) {

    switch( s1 ) {
      case "A" :
        return 1;
      case "C" :
        return 2;
      case "G" :
        return 3;
      case "T" :
        return 4;
      default :
        return -1;
    }

  }
}


Measured memory_bytes: 237764
#include <stdio.h>
int main(void){
	int a,b,c, i = 0;
	scanf("%d %d %d", &a,&b,&c);
	for (i = 0; a <= b; b = b - a){
		i++;
		if (i == c)
			break;
	}
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
#define PI 3.14159265358979323846264338327950L
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

int GCD(int a,int b){
	return b?GCD(b,a%b):a;
}

int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a >= k){
		cout<<k<<endl;
	}
	else if(a+b >= k){
		cout<<a<<endl;
	}
	else{
		cout<<a-(k-(a+b))<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int n = scanner.nextInt();
    int l = scanner.nextInt();
    
    ArrayList<String> word = new ArrayList<>();
    
    // n回データを取得し格納する
    for(int i = 0; i < n; i++) {
      word.add(scanner.next());
    }
    
    // データをソートする
    // abw
    // eop
    // cpo
    // xxb
    // bqq
    boolean changed = true; // 交換が発生したかどうかのフラグ（初期値はtrue）
    while(changed) {
      changed = false; // まだこのループで交換は行われてない
      for(int i = 1; i < n; i++) {
        // 自分とその前を比較して、自分が相手より小さかったら
        if(compare(word.get(i), word.get(i - 1))) {
	      // 自分と相手の場所を入れ替える
          String tmp; // *退避しておくところ
          tmp = word.get(i); // *自分を退避
          word.set(i, word.get(i - 1)); // *自分のいたところに相手を入れる
          word.set(i - 1, tmp); // *相手のいたところに退避しておいた自分を入れる
          changed = true; // 交換が発生した
        }
      }
  	}
    
    // listの中の要素を区切らずに連続して出力
    for(String w: word) {
      System.out.print(w);
    }
  }
  
  /**
   * 二つの文字列を比較し、一つ目の方が辞書順で小さければtrue
   * そうでなければfalseを返す
   */
  public static boolean compare(String str1, String str2) {
    return str1.compareTo(str2) < 0;
  }
}


Measured memory_bytes: 37364
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop()
#define ppb         pop_back()
#define ppf         pop_front()
#define OK          cout<<"Ok"<<"\n";
#define TESTS       ll test;cin>>test;for(ll   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(1e6)
    string s;
bool is_ok(int ss,int e)
{
    int cnt=(e-ss+1)/2;
    for(int i=ss,j=e;cnt--;i++,j--)
    {
        if(s[i]!=s[j]) return 0;
    }
    return 1;
}
int main()
{
    FAST
    cin>>s;
    s="*"+s;
    int len=s.size()-1;
    if(is_ok(1,s.size()-1) and is_ok(1,(len-1)/2) and is_ok((len+3)/2,len) ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;
NodePointer nil;
NodePointer listSearch(int key);
void init(void);
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  //  free(t);
}
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}
void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  printList();
  return 0;
}
NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}


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

int main(){
	string s;
	cin >> s;
	
	string ans;
	for(int i = 0; i < s.length(); i++){
		if(ans.length() != 0 && s[i] == 'B'){
			int tmp = ans.length() - 1;
			ans.erase(tmp);
		}else if(ans.length() == 0 && s[i] == 'B'){
			continue;
		}else{
			ans.push_back(s[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;
 
 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
 
    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(a[i]));
    }
    sort(a.begin(), a.end());
 
    long ans=0;
    for(i=0; i<n; i++) {
        long curr=a[i];
        long k=i;
        long count=0;
        while(k<n && a[k]==curr) {
            count++;
            k++;
        }
        if(count>=curr) {
            ans += curr;
        }
        i+=(count-1);
    }
    printf("%ld\n", n-ans);
 
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
using namespace std;
 
void outPut(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",mark,i);
    }
}
 
int main(){
    char mark[2];
    int n,S[14],H[14],C[14],D[14],tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",mark,&tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}


Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans=1;
  rep(i,S.size()){
    if(i){
      if(S[i]!=S[i-1]) ans++;
    }
  }
  cout<<ans<<endl;
}



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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


int main(){
  string s;
  cin>>s;
  ll ct=0;
  for(ll i=0;i<3;i++){
    if(s[i]=='o')ct++;
  }
  cout<<700+ct*100<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

bool compare_by_b(pair<long, long> a, pair<long, long> b){
    return a.second < b.second;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    vector<ll>a2(n);
    rep(i, n)a2[i] = a[i]*2;

    ll sa = a2[0];
    for(int i = 1; i < n; i++){
        if(i%2 == 1)sa -= a2[i];
        else sa += a2[i];
    }
    ll x = sa /2;
    cout << x << " ";
    for(int i = 0; i < n-1; i++){
        x = (a[i] - x/2)*2;
        cout << x << " ";
    }

}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll x, a;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> x >> a;
	if (x < a)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 256
s = input()
ym = [s[i*2:i*2+2] for i in range(2)]

if 0 < int(ym[0]) and 0 < int(ym[1]) and int(ym[0]) < 13 and int(ym[1]) < 13:
  print("AMBIGUOUS")
elif 0 < int(ym[1]) and int(ym[1]) < 13:
  print("YYMM")
elif 0 < int(ym[0]) and int(ym[0]) < 13:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim max As Int64
    Dim n, k, x, t As Int64
    Sub Main()
        Dim s() As String = ReadLine.Split
        n = s(0)
        s = ReadLine.Split
        Dim a(s.Length - 1) As Integer
        For i = 0 To s.Length - 1
            a(i) = s(i)
        Next
        max = a(0)
        For i = 1 To n - 1
            If a(i) <= max Then
                ans += (max - a(i))
            Else
                max = a(i)
            End If
        Next
        WriteLine(ans)
    End Sub
End Module


Measured memory_bytes: 46848
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int n,m;
int wa_cnt,ac_cnt;
bool flag[1000010];
int wa[1000010];

int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x; string s;
		cin>>x>>s;
		if(s=="AC" && !flag[x])
		{
			ac_cnt++;
			wa_cnt+=wa[x];
			flag[x]=true;
		}
		else if(s=="WA" && !flag[x])
		{
			wa[x]++;
		}
	}
	cout<<ac_cnt<<" "<<wa_cnt;
	return 0;
}


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, k;
	cin >> n >> k;
	int max = (n - 1) * (n - 2) / 2;
	if (k > max)
		cout << -1;
	else
	{
		vector<pair<int, int>> Adj;
		for (int i = 1; i < n; ++i)
			Adj.pb({i, n});
		int m = n - 1;
		int curr = 1;
		int i = 2;
		while (k < max)
		{
			db(k,max);
			Adj.pb({curr, i});
			++i;
			if (i == n)
			{
				curr++;
				i = curr + 1;
			}
			max--;
		}
		cout << Adj.size() << '\n';
		for (auto x : Adj)
			cout << x.f << ' ' << x.s << '\n';
	}
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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


int main(){
    int k,a,b; cin>>k>>a>>b;
    bool ans=false;
    for(int i=1;i<=a;i++){
        if(i*k>=a && i*k<=b){
            ans=true;
            break;
        }
    }
    if(ans) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3600
// Iroha loves Strings
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  vector <string> s;
  string s1;
  int N,L;
  cin>>N>>L;
  
  for(int i=0;i<N;i++)
  {
    cin>>s1;
    s.push_back(s1);
  }
  sort(begin(s),end(s));
  for(string s1:s)
    cout<<s1;

  return 0;
}

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

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

    long long l0 = 2, l1 = 1, tmp;
    for (int i = 1; i < n; i++) {
        tmp = l1;
        l1 = l0 + tmp;
        l0 = tmp;
    }

    cout << l1 << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    ll a[n][k+1], b[n][k+1];
    fill(a[0], a[n], 0), fill(b[0], b[n], 0);
    int x = s[0]-'0';
    a[0][1] = 1;
    b[0][0] = 1;
    b[0][1] = x-1;
    rep2(i, 1, n-1){
        x = s[i]-'0';
        rep(j, k+1) b[i][j] += b[i-1][j];
        rep(j, k) b[i][j+1] += b[i-1][j]*9;
        if(x == 0){
            rep(j, k+1) a[i][j] += a[i-1][j];
            continue;
        }
        rep(j, k+1) b[i][j] += a[i-1][j];
        rep(j, k){
            b[i][j+1] += a[i-1][j]*(x-1);
        }
        rep(j, k){
            a[i][j+1] += a[i-1][j];
        }
    }
    cout << a[n-1][k]+b[n-1][k] << endl;
}

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

int main() {
  ll h,w;cin>>h>>w;
  ll ans=(h*w+1)/2;
  if(h==1||w==1)cout<<1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 3580
# include <bits/stdc++.h>
using namespace std;
# define FOR(i, a, b) for (int i = a; i <= b; ++i)
# define FDR(i, a, b) for (int i = a; i >= b; --i)
# define mp make_pair
# define pb push_back
typedef long long i64;
const int N = 20005;

int main ()
{
    int n;
    cin >> n;
    if (n < 1200) puts("ABC");
    else if (n < 2800) puts("ARC");
    else puts("AGC");
    return 0;
}


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

// I DON'T KNOW WHO YOU ARE BUT I WILL FIND YOU AND SEE YOUR CODE _/\_

# define MOD         1000000007
# define gc          getchar
# define LL          long long
# define pb          push_back
# define mp          make_pair
# define vi          vector<int>
# define MAXN        1000005
# define INF         1e9
# define all(v)      v.begin(),v.end()

template<class T> void in(T &x) { register T c=gc();x=0;T neg=0;for(;((c<48||c>57)&&c!='-');c=gc());if(c=='-'){neg=1;c=gc();}for(;c>47&&c<58;c=gc()){x=(x<<1)+(x<<3)+c-48;}if(neg)x=-x;}
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
LL power(LL a,LL b,LL m){ if(b==0) return 1; if(b==1) return a%m; LL t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
LL lcm(LL a, LL b) { LL ret = a*b; ret /= __gcd(a,b); return ret;}
LL nC2(LL n) {LL ret = n*(n-1)/2; return ret;}

int main()
{
	int k,s;
	cin>>k>>s;
	int ans=0;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			int rem=s-i-j;
			if(rem>=0 && rem<=k)
				ans++;
		}
	}
	cout<<ans;
    return 0;
}


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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int n;
	cin >> n;
	char ope;
	int opec;
	while (true)
	{
		cin >> ope;
		if (ope == '=')
		{
			break;
		}
		cin >> opec;
		switch (ope)
		{
		case '+':
			n += opec;
			break;
		case '-':
			n -= opec;
			break;
		case '*':
			n *= opec;
			break;
		case '/':
			n /= opec;
			break;
		}
	}

	cout << n << endl;
	return 0;
}


Measured memory_bytes: 3112
<?php
fscanf(STDIN, "%d %d", $num1, $num2);

$div = 0;
$max_num = max($num1, $num2);
$min_num = min($num1, $num2);
while ($min_num != 0) {
    $tmp = $min_num;
    $min_num = $max_num % $min_num;
    $max_num = $tmp;
}

echo $max_num."\n";
?>


Measured memory_bytes: 9196
#include <stdio.h>

int main(){

  int i,j,n;
  int data[]={1,2,4,8,16,32,64,128,256,512};
  int result[10];

  while (scanf("%d",&n)!=EOF){
    int j=0;
    for (i=9;i>=0;i--){
      if (n==0){
        break;
      }
      if (n>=data[i]){
        n-=data[i];
        result[j++]=data[i];
      }
    }
    for (i=j-1;i>0;i--){
      printf("%d ",result[i]);
    }
      printf("%d\n",result[0]);
  }

  return 0;
}

Measured memory_bytes: 596
'use strict'

const dfs = (num, N) => {
    if(parseInt(num) > N){
        return 0
    }

    let ret = 1
    if(num.indexOf('7') === -1 || num.indexOf('5') === -1 || num.indexOf('3') === -1){
        ret = 0
    }else{
        for(let n of num.split('')){
            if(n !== '7' && n !== '5' && n !== '3'){
                ret = 0
                break
            }
        }
    }
    const tar = ['7', '5', '3']
    for(let i of tar ){
        if(num === ''){
            ret += dfs(i, N)
        }else{
            ret += dfs(num + i, N)
        }
    }
    return ret

}

const main = (input) => {
    const N = parseInt(input)
    console.log(dfs('', N))
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 11016
#include <iostream>

using namespace  std;

int a[100010];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[a[i]] == i) {
            ++ans;
        }
    }
    cout << ans / 2;
    return 0;
}


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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    int v[n];

    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v, v + n);
    long double r = v[0];
    for (int i = 1; i < n; i++) {
        r = (r + v[i]) / 2;
    }
    cout << r << endl;

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


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	var tot int
	var cnt int = 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				tot = 500*i + 100*j + 50*k
				if tot == x {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=18;

int n;
int a[MAXN];

ll go(int l,int r,int L,int R) {
	if(r==l+1) return 0;
	ll ret=LLONG_MAX;
	FORE(m,l+1,r-1) {
		ll x=go(l,m,L,L+R);
		ll y=go(m,r,L+R,R);
		ll cur=(ll)(L+R)*a[m]+x+y;
		ret=min(ret,cur);
	}
	return ret;
}

ll solve() {
	return a[0]+a[n-1]+go(0,n-1,1,1);
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%d",&a[i]);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];

  vector<Int> us,vs;
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(st[i][j]!='B') continue;
      us.emplace_back(i+j);
      vs.emplace_back(i-j);
    }
  }
  sort(us.begin(),us.end());
  sort(vs.begin(),vs.end());

  cout<<max(us.back()-us.front(),vs.back()-vs.front())<<endl;
  return 0;
}



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

int main()
{
  int n;
  cin>>n;
  multiset<int> s;
  vector<int> v(n);
  int m=n;
  for(auto &i:v) 
  {
    cin>>i;
    s.insert(i);
  }
  for(auto i:v)
  {
    s.erase(s.find(i));
    cout<<*s.rbegin()<<"\n";
    s.insert(i);
  }
  
  return 0;
}


Measured memory_bytes: 11776