akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {
int a,b;
int k;
cin>>k>>a>>b;
for(int i=a;i<=b;i++){
	if(i%k==0){
		cout<<"OK"<<endl;
		return 0;
	}
}
cout<<"NG"<<endl;
return 0;

}



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

using namespace std;

using ll = long long;

const ll INF = 1e18;

struct Dinic {
    using T = ll;

    struct Edge {
        int to;
        T cap;
        int rev;  //行き先、容量、逆辺
        Edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector< vector<Edge> > G;
    vector<int> level, iter;

private:
    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (const Edge& e : G[v]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    T dfs(int v, int t, T 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]) {
                T 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;
    }

public:
    Dinic(int V) : G(V), level(V, -1), iter(V, 0) {}

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

    T max_flow(int s, int t) {
        T flow = 0;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            T f;
            while ((f = dfs(s, t, INF)) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    Dinic dinic(n + 2);

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if (a >= 0) {
            ans += a;
            dinic.add_edge(0, i + 1, a);
        } else {
            dinic.add_edge(i + 1, n + 1, -a);
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = i * 2; j <= n; j += i) {
            dinic.add_edge(j, i, INF);
        }
    }
    
    ans -= dinic.max_flow(0, n + 1);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=220,P=1e9+7;
int n,m,ans,a[N],b[N],f[N][N];
void chk(int&x){x-=P;x+=(x>>31)&P;}
int qpw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%P)if(y&1) z=1ll*z*x%P;return z;}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);a[0]=1;b[n+1]=1;
	FOR(i,1,n) scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+2);m=unique(b+1,b+n+2)-b;
	FOR(i,0,n) a[i]=lower_bound(b+1,b+m,a[i])-b;
	f[0][1]=1;
	FOR(i,1,n)FOR(j,1,a[i-1])if(f[i-1][j]){
		int x=a[i-1],y=a[i];
		if(x>y){
			chk(f[i][min(j,y)]+=f[i-1][j]);
			if(j>=y) chk(f[i][y]+=f[i-1][j]);
		}
		else{
			if(j<x) chk(f[i][j]+=1ll*qpw(2,b[y]-b[x])*f[i-1][j]%P);
			else FOR(k,x,y)
			chk(f[i][k]+=2ll*(qpw(2,b[y]-b[k])-(k==y?0:qpw(2,b[y]-b[k+1]))+P)%P*f[i-1][j]%P);
		}
	}
	FOR(j,1,m) chk(ans+=f[n][j]);
	cout<<ans<<'\n'; 
}

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

#define ll long long

int const N = 111, W = 1e5 + 11;

ll n, w;
ll arr[N][2], dp[N][W], vis[N][W];

ll pound(ll index, ll weight)
{
		if (index > n)
				return 0;
				
		if (weight > w)
				return -1e9;
				
		if (vis[index][weight])
				return dp[index][weight];
				
		vis[index][weight] = 1;
		
		return dp[index][weight] = max(arr[index][1] + pound(index + 1, weight + arr[index][0]), pound(index + 1, weight));
}

int main()
{
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);

    cin >> n >> w;
    
    for (int i = 0; i < n; ++i)
        cin >> arr[i][0] >> arr[i][1];
        
    cout << pound(0, 0);
    
    return 0;
}


Measured memory_bytes: 158080
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n),sum(n+1);
    cins(all(a));
    SORT(a);
    rep(i,n) sum[i+1] = a[i];
    rep(i,n) sum[i+1] += sum[i];
    ll l = -1,r = 400000;
    while(r-l > 1){
        ll mid = (r+l)/2;
        ll cnt = 0,same = 0;
        rep(i,n){
            if (a[n-1]+a[i] < mid) continue;
            cnt += n-(upper_bound(all(a),mid-a[i])-a.begin());
            same += upper_bound(all(a),mid-a[i])-lower_bound(all(a),mid-a[i]);
        }
        if (cnt <= m && same+cnt >= m){
            l = mid;
            break;
        }
        cnt += same;
        if (cnt >= m) l = mid;
        else r = mid;
    }
    ll ans = 0;
    ll cnt = 0;
    rep(i,n){
        if (a[n-1]+a[i] < l) continue;
        //PRINT(l-a[i]);
        ll index = upper_bound(all(a),l-a[i])-a.begin();
        cnt += n-(upper_bound(all(a),l-a[i])-a.begin());
        ans += sum[n]-sum[index]+a[i]*(n-index);
    }
    ans += l*(m-cnt);
    PRINT(ans);
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i : a)
        cin >> i;
    sort(all(a));
    a.resize(unique(all(a)) - a.begin());
    if (a.size() == n)
        cout << "YES";
    else
        cout << "NO";
} 

void run() {

}

void write() {

}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    read();
    run();
    write();
    return 0;
}

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

using namespace std;

#define fr(i,a,b) for(register long long i=a;i<=b;i++)
#define fv(i,a,b) for(register long long i=a;i>=b;i--)
#define fmax(a,b) ((a)>(b)?(a):(b))
#define fmin(a,b) ((a)<(b)?(a):(b))

long long n,amn,ans;
bool flag;

inline long long v_in(){
	char ch=getchar();long long sum=0,f=1;
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) sum=(sum<<3)+(sum<<1)+(ch^48),ch=getchar();
	return sum*f;
}

int main(){
	n=v_in(),amn=1e16,flag=false;
	fr(i,1,n){
		long long x=v_in(),y=v_in();
		if(x!=y) flag=true;
		ans+=x;
		if(x>y) amn=fmin(amn,y);
	}
	if(!flag) printf("0\n");
	else printf("%lld\n",ans-amn);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double 
#define MOD 1000000007ll 
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std;
#define pi (long double)3.14159265358979323846 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
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);
}
ll power(ll a,ll p,ll m)
{
    ll re=1;
    re%=m;
    for(;p;p>>=1){
        if(p&1) re=re*a%m;
        a=a*a%m;
    }
    return re;
}
int main()
{
    ll n;
    cin>>n;
    if(n==1)
    {
        cout<<0<<endl;
        return 0;   
    }
    ll p1=1,ans;
    for(ll i=0;i<n;i++)
    {
        p1 *= 10;
        p1 %= MOD;
    }
    ans = p1;
    p1 = 1;
    for(ll i=0;i<n;i++)
    {
        p1 *= 9;
        p1 %= MOD;
    }
    ans -= p1;
    ans = (ans+MOD)%MOD;
    ans -= p1;
    ans = (ans+MOD)%MOD;
    p1 = 1;
    for(ll i=0;i<n;i++)
    {
        p1 *= 8;
        p1 %= MOD;
    }
    ans += p1;
    ans = (ans+MOD)%MOD;
    cout<<ans<<endl;

}   

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

int main(){
  ll n;
  cin >> n;
  
  vector<ll> a(n+1), b(n);
  
  for (ll i = 0; i < n+1; i++ )
    cin >> a[i];
    
  for ( ll i = 0; i < n; i++ )
    cin >> b[i];
  
  ll ans = 0;
  ll m;
  
  for (ll i = 0; i < n; i++ ){
    m = min( b[i], a[i] );
    
    ans += m;
    b[i] -= m;
    
    m = min( b[i], a[i+1] );
    ans += m;
    a[i+1] -= m;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1792
dp = [0, 1]

s = input()
s = s[::-1]
s += "0"

for i in range(len(s)):
    dp0, dp1 = dp
    dp[0] = min(dp0, dp1 + 1) + int(s[i])
    dp[1] = min(dp0, dp1 - 1) + 10 - int(s[i])

print(min(dp))

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

typedef long long int llint;

int main()
{
  int n, x;
  vector<int> a;

  cin>> n;
  
  for(int i = 0; i < n; i++) {
    cin>> x;
    a.push_back(x);
  }

  int l = 0, r = 0;
  int now = 0;
  llint sum = 0;

  while(l < n) {

    while(r < n && (now ^ a[r]) == now + a[r]) {
      now ^= a[r++];
      sum++;
    }

    now ^= a[l++];
    sum += r - l;
    
  }

  cout<< sum <<endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = ll(1e18) + 1;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    ll N,K; cin >> N >> K;
    ll tmp=N;
    int ans=1;
    while(1){
        if (tmp<K)break;
        tmp=tmp/K;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

string S;

int main(void){
	cin>>S;
	rep(i,S.length()-8){
		printf("%c",S[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { cout << -1 << '\n'; exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll r, c, k; cin >> r >> c >> k;

  VVll itm(r, Vll(c));
  rep(i, k) {
    int x, y, v; cin >> x >> y >> v;
    --x, --y;
    itm[x][y] = v;
  }

  VVll dp(4, Vll(c));

  rep(i, r) {
    VVll tmp(4, Vll(c));
    tmp[0] = dp[3];
    rep(j, c) {
      chmax(tmp[1][j], dp[3][j] + itm[i][j]);
      if (j) rep(l, 4) chmax(tmp[l][j], tmp[l][j-1]);
      if (j) rep2(l, 1, 4) chmax(tmp[l][j], tmp[l-1][j-1] + itm[i][j]);
      rep2(l, 1, 4) chmax(tmp[l][j], tmp[l-1][j]);
    }
    swap(dp, tmp);
  }

  ll ans = dp[3][c-1];
  cout << ans << '\n';
  return 0;
}


// 2 4 5
// 1 1 3
// 1 2 3
// 1 3 3
// 1 4 100
// 2 4 4

Measured memory_bytes: 74256
#include <iostream>
typedef long long int ll;

using namespace std;

int main(void){
  ll a,b,c,K;
  cin >> a >> b >> c >> K;
  ll ans = 0;
  ll num = 0;
  if(a >= K){
    cout << K << endl;
    return 0;
  }
  ans += a;
  num += a;
  //////////////
  num += b;
  if(num >= K){
    cout << ans << endl;
    return 0;
  }
  ans = ans - (K-num);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = b; i >= (a); --i)
#define repdl(i, a, b) for(ll i = b; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool ihmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
#endif
using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  string s; read(s);
  int st = 0, a = sz(s);
  for (char c : s) {
    if (c == 'S') ++st;
    else if (c == 'T' && st > 0) st--, a -= 2;
  }
  write(a);
}



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

# 偶数、奇数の個数を数える
odds = 0
even = 0
for a in A:
  if a%2 == 0:
    even += 1
  else:
    odds += 1

ans = 0
# 操作1をするため個数が多いものを少ないものに偶奇を合わせる
if even == 2: # 偶数を奇数にする
  ans += 1
  for i in range(3):
    if A[i]%2==0:
      A[i] += 1
      
elif odds == 2:
  ans += 1
  for i in range(3):# 奇数を偶数にする
    if A[i]%2==1:
      A[i] += 1
      

# 最大値に合わせるよう+2を加えて数を合わせる
ma = max(A)
for i in range(3):
  ans += (ma-A[i])//2
print(ans)  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;

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

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

    // cumulative sum
    for(int i=1; i<n; i++){
        a[i] += a[i-1];
    }

    long long int diff = INF;
    for(int i=0; i<n-1; i++){
        if(diff > abs(a[n-1] - 2 * a[i])) diff = abs(a[n-1] - 2 * a[i]);
    }
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <map>
using namespace std;
#define REP(i, a, n) for (int i = ((int)a); i < ((int)n); i++)
#define lli long long int

#define MAX_N 100000
//#define DEBUG

int n;
int ar1[MAX_N];
int ar2[MAX_N];
int ans = 0;

void read()
{
    cin >> n;
    ans = n;
    int tmp1;
    int tmp2;
    REP(i, 0, n/2)
    {
        cin >> tmp1 >> tmp2;
        ar1[tmp1]++;
        ar2[tmp2]++;
    }
}
void solve()
{
    pair<int, int> max1 = make_pair(0, 0);
    int max2 = 0;
    pair<int, int> max3 = make_pair(0, 0);
    int max4 = 0;
    REP(i, 0, MAX_N)
    {
        if (ar1[i] > max1.second)
        {
            if (max1.second > max2)
            {
                max2 = max1.second;
            }
            max1.first = i;
            max1.second = ar1[i];
        }
        else if (ar1[i] > max2)
        {
            max2 = ar1[i];
        }
        if (ar2[i] > max3.second)
        {
            if (max3.second > max4)
            {
                max4 = max3.second;
            }
            max3.first = i;
            max3.second = ar2[i];
        }
        else if (ar2[i] > max4)
        {
            max4 = ar2[i];
        }
    }
#ifdef DEBUG
    cout << "候補" << endl;
    cout << max1.first << " : " << max1.second << endl;
    cout << max2 << endl;
    cout << "候補" << endl;
    cout << max3.first << " : " << max3.second << endl;
    cout << max4 << endl;
#endif
    if (max1.first == max3.first)
    {
        if (max1.second > max3.second)
        {
            ans -= max1.second;
            ans -= max4;
        }
        else if (max1.second < max3.second)
        {
            ans -= max3.second;
            ans -= max2;
        }
        else
        {
            if (max2 > max4)
            {
                ans -= max2;
                ans -= max3.second;
            }
            else
            {
                ans -= max1.second;
                ans -= max4;
            }
        }
    }
    else
    {
        ans -= max1.second;
        ans -= max3.second;
    }
}
void print()
{
    cout << ans << endl;
}
int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
#else
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
#endif
    read();
    solve();
    print();
    return 0;
}
/* 注意すべき点
グローバル以外の配列は初期化すべし
*/

Measured memory_bytes: 1024
//////////////////////////////////////
////       ABHINASH GIRI          ////
/////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define pr 4294967296   // 2^32
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define high 1000000001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             -1e18
#define pinf              1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define e               1000000000
#define w(x)            int t; cin>>t; while(t--)
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define co(x) cout<<(x)<<"\n"
#define endl "\n"
typedef unsigned long int  ul;
typedef unsigned long long int ull;
typedef unsigned long long  int  li;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<long int> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long int,long int>> vpl;
typedef vector<pair<long long int,long long int>> vpll;
typedef long long ll;
bool cmp(pair<char,int>a,pair<char,int>b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first>b.first;
}
int main() {
    std::chrono::time_point<std::chrono::high_resolution_clock> start_timer, end_timer;
    start_timer = std::chrono::high_resolution_clock::now();
    bool show_time = false;  //  change it to true when needed;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    /* Cook your Code  */
    fast;
    string s;
    cin>>s;
    if(s[1]=='B')
    {
        s[1]='R';
    }
    else {s[1]='B';}
    cout<<s<<endl;



    end_timer = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer-start_timer).count();
    if(show_time)
    {cout << "\\nElapsed Time: " << elapsed_time << "ms\\n";}

    return 0;
}

Measured memory_bytes: 3636
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ins(s);
    ll n= s.size();

    if(s.substr(0,n/2)==s.substr(n-n/2,n/2)){
        REP(i,n/2){
            if(s[i]!=s[n-1-i]){
                out("No");
                return 0;
            }
        }
        out("Yes");
        return 0;
    }
    out("No");
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 999999
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
//typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 300005
//#define MO 
int h[N][20],vi[N][20],O,n,a[20],b[20],Ans;
int dfs(int p, int op, int la)
{
	
	if(op==3)
	int lxy=1;
	
	if(vi[op][la])return h[op][la];
	vi[op][la]=1;
	if(!p)return h[op][la]=0;
	h[op][la]=INF;
	int w,pp,ss,_ss=0,_w;
	if(abs(la-p)&1)w=b[la];else w=a[la];
	pp=op^(1<<la);
	F2(i,la+1,n)if(pp&(1<<i))++_ss;
	F2(i,0,n)if(pp&(1<<i)){
		if(abs(i-p)&1)_w=a[i];else _w=b[i];
		if(_w>w)continue;
		ss=dfs(p-1,pp,i)+_ss;
		chmin(h[op][la],ss);
	}
	return h[op][la];
}

inline void _Sol_()
{
	read(n);F2(i,0,n)read(a[i]);F2(i,0,n)read(b[i]);
	O=(1<<n)-1;
//	F(o,1,O)_[o]=_[o>>1]+(o&1);
//	F(o,0,O)G[_[o]].push_back(o);
	Ans=INF;
	F2(i,0,n)
	dfs(n-1,O,i),
	chmin(Ans,h[O][i]);
	if(Ans>10000)prin(-1);else prin(Ans); //01 020  scanf 020
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}
/*
3
3 4 3
3 2 3
*/


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

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>

#define all(a) (a).begin(),(a).end()
using namespace std;

bool check(vs &ngo, string s){
	for (string t : ngo) if (t == s) return 0;
	return 1;
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, M, C;
	scanf("%d%d%d", &N, &M, &C);

	int B[M], A[N][M];
	int i, j;
	for (i = 0; i < M; i++)
		scanf("%d", &B[i]);
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			scanf("%d", &A[i][j]);
		}
	}

	int tmp = 0, result = 0;
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			tmp += A[i][j] * B[j];
		}
		tmp += C;
		if (tmp > 0)
			result += 1;
		tmp = 0;
	}

	printf("%d\n", result);

	return 0;
}


Measured memory_bytes: 128
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for i in range(N)]

ans = 0
for i in range(N):
    sum = C
    for (a, b) in zip(A[i], B):
        sum += a * b
    if sum > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
S = list(str(input()))
bit_flag = []
result_s = []
for i in range(1 << len(S)-1):
    tmp = []
    for j in range(len(S)-1):
        tmp.append((i >> j) & 1)
    bit_flag.append(tmp)

for bit in bit_flag:
    tmp = S[0]
    # [0, 0]などが入っている
    for i in range(len(S)-1):  # 2回
        if bit[i] == 1:
            tmp += "+"
        tmp += S[i+1]
    result_s.append(tmp)
ans = 0
for s in result_s:
    ans += eval(s)
print(ans)


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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

int k;
void input() { cin >> k; }

void exit_end(int ans) {
  cout << ans << endl;
  exit(0);
}

void solve() {
  vector<int> v(k + 1, -1);
  if (k % 2 == 0) exit_end(-1);
  v[1] = 7 % k;
  rep(i, 2, k + 1) v[i] = (v[i - 1] * 10 + 7) % k;
  rep(i, 1, k + 1) {
    if (v[i] == 0) { exit_end(i); }
  }
  exit_end(-1);
}

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

Measured memory_bytes: 7520
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int x,y,z,k;
vector<ll> v,w;
ll a[1100],b[1100],c[1100];

int main(){
  cin>>x>>y>>z>>k;

  rep(i,x){
    cin>>a[i];
  }
  rep(i,y){
    cin>>b[i];
  }
  rep(i,z){
    cin>>c[i];
  }

  rep(i,x){
    rep(j,y){
      v.PB(a[i]+b[j]);
    }
  }

  sort(all(v));
  reverse(all(v));
  sort(c,c+z);
  reverse(c,c+z);

  for(int i=0;i<v.size()&&i<3000;i++){
    rep(j,z){
      w.PB(v[i]+c[j]);
    }
  }

  sort(all(w));
  reverse(all(w));

  rep(i,k){
    cout<<w[i]<<endl;
  }

}



Measured memory_bytes: 43364
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int n, k[105];
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	for (int i = n - 1; i >= 0; --i) {
		cout << k[i];
		if (i != 0) { cout << " "; }
	}
	cout << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL N; cin >> N;
    VI u(N-1),v(N-1);
    REP(i,N-1){
        cin >> u[i] >> v[i];
    }
    LL ans = 0;
    REP(i,N){
        ans += (N - i) * (N-i+1) / 2;
    }
    dump(ans)
    REP(i,N-1){
        LL l = u[i], r = v[i];
        if(l > r) swap(l,r);
        ans -= l * (N-r+1);
    }
    cout << ans << endl;

}

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

int main(void){
    ll n;
    scanf(" %lld",&n);
    
    vector<char> p;
    while(n>0){
        p.push_back('a'+(char)(--n%26));
        //printf("pppp %c \n",'a'+(char)((n-1)%26));
        n/=26;
        //printf("aaaa %I64d\n",n);
    }

    reverse(p.begin(),p.end());
    
    for(int i=0;i<(int)p.size();i++){
        printf("%c",p[i]);
    }
}


Measured memory_bytes: 3648
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

main = do

   [c11,c12,c13] <- map bsreadInt . BC.words <$> BC.getLine
   [c21,c22,c23] <- map bsreadInt . BC.words <$> BC.getLine
   [c31,c32,c33] <- map bsreadInt . BC.words <$> BC.getLine
   let cn = [c11,c12,c13,c21,c22,c23,c31,c32,c33]
   if (crit1 cn) && (crit2 cn) == True then putStrLn "Yes"
                                       else putStrLn "No"

crit1 :: [Int] -> Bool
crit1 [c11,c12,c13,c21,c22,c23,c31,c32,c33] = if ((c21-c11) == (c22-c12)) && ((c23-c13) == (c22-c12))
                                              then True
                                              else False

crit2 :: [Int] -> Bool
crit2 [c11,c12,c13,c21,c22,c23,c31,c32,c33] = if ((c31-c11) == (c32-c12)) && ((c32-c12) == (c33-c13))
                                              then True
                                              else False

Measured memory_bytes: 380
open Scanf
open Printf

let multiplication lst =
  let rec loop total l = match l with
      [] -> total
    | first :: rest -> if total > 1_000_000_000_000_000_000 / first then
                          (if List.mem 0 lst  then 0 else -1)
                       else loop (first * total) rest
  in loop 1 lst

let n = sscanf (read_line ()) "%d" (fun n -> n)
let a_list = List.map (fun n -> int_of_string n) (String.split_on_char ' ' (read_line ()))
let () = printf "%d\n" (multiplication a_list)


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

bool isGumoji(string s){
    int l, d;
    string str=s;
    string s1, s2;
    l = s.length()%2;
    if(l==0) {
        d=s.length()/2;

        s1 = s.substr(0, d);
        s2 = s.substr(d, s.length());
        /*
        cout << "length:" << s.length() << endl;
        cout << "s1:" << s1 << endl;
        cout << "s2:" << s2 << endl;
        */
        if(s1==s2){
            return true;
        }else{
            return false;
        }
    }else{
        return false;
    }
}
int main(){
    string str;
    cin >> str;
    // cout << isGumoji(str) << endl;
    for(int i=str.length(); i>=2; --i){
        str.pop_back();

        // cout << str << endl;
        //cout << isGumoji(str) << endl;
        if(isGumoji(str)) break;
    }
    cout << str.length() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

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

int main(void){
  int num;
  int s[200000];
  
	for(int i = 0; i <200000; i++){
		s[i] = -1;
	}
	int flag = 0;
	scanf("%d",&num);
	for(int i = 0;i < num; i++){
  		scanf("%d", &s[i]);
	}
	qsort(s,num,sizeof(int),compare_int);
	for(int j = 0; j < num - 1; j++){
		if(s[j] == s[j + 1]){
			printf("NO");
			flag = 1;
			break;
		}
	}
	if(flag == 0){
		printf("YES");
	}
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;


int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int k, s;
    cin>>k>>s;
    int ans = 0;
    for(int x=0; x<=k; x++) {
        for(int y=0; y<=k; y++) {
            int z = s-x-y;
            if(z>=0 && z<=k)
                ans++;
        }
    }

    cout<<ans;

return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

long long gcd(long long x, long long y)
{
	if (x < y) return gcd(y, x);
	long long r;
	while(r = x%y){
		x = y;
		y = r;
	}
	return y;
}

long long lcm(long long x, long long y)
{
	return x*y/gcd(x, y);
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b; cin>>a>>b;
	cout << gcd(a, b) << "\n";
	return 0;
}


Measured memory_bytes: 3224
import java.util.*

fun main(args: Array<String>) = p28()

fun p28() {
    data class Vertex(val neighbor: MutableSet<Int> = mutableSetOf())

    val n = readLine()!!.toInt()
    val vertexes = Array(n) {
        val line = readLine()!!.split(' ').map { it.toInt() }
        Vertex(line.drop(2).map { it - 1 }.toMutableSet())
    }

    val queue = ArrayDeque(listOf(0 to 0))
    val distances = IntArray(n) { -1 }
    val visited = mutableSetOf(0)

    while (queue.isNotEmpty()) {
        val (index, dist) = queue.poll()
        distances[index] = dist
        vertexes[index].neighbor.filter { visited.add(it) }
            .map { it to dist + 1 }.let { queue.addAll(it) }
    }

    val answer = distances.mapIndexed { index, dist -> "${index + 1} $dist" }
        .joinToString(System.lineSeparator())

    println(answer)
}



Measured memory_bytes: 33940
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		String []s = new String [n];
		int []t = new int [n];
		int sum[] = new int [n+1];
		
		sum[0] = 0;
		
		for(int i = 0 ;i < n ;i++) {
			s[i] = sc.next();
			t[i] = Integer.parseInt(sc.next());
			sum[i+1] += t[i] + sum[i];
		}
		
		String x = sc.next();
		int ans = 0;
		
		for(int i = 0 ;i < n ;i++) {
			if(s[i].equals(x)) {
				ans = sum[n] - sum[i+1];
				break;
			}
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n,m,u,v,w;
    scanf("%d%d",&n,&m);
    vector<pair<int,int>> list[100005];
    REP(i,m){
        scanf("%d%d%d",&u,&v,&w);
        list[u-1].push_back(make_pair(v-1,w));
        list[v-1].push_back(make_pair(u-1,w));
    }
    int checked[100005]={};
    int cost=0;
    REP(i,n){
        if(!checked[i]){
            queue<int> que;
            que.push(i);
            cost++;
            while(!que.empty()){
                int now=que.front();
                que.pop();
                checked[now]=1;
                //printf("check : %d\n",now);
                for(pair<int,int> next : list[now]){
                    if(!checked[next.first]){
                        que.push(next.first);
                    }
                }
            }
        }
    }
    printf("%d\n",cost);
    return 0;
}

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

N = int(input())
xy = []
for i in range(N) :
    x, y = map(int, input().split())
    xy.append((i, x, y))

v = []

xy.sort(key=lambda x: x[1])
pi, px, py = xy[0]
for i in range(1, N) :
    ci, cx, cy = xy[i]
    v.append((min(cx-px, abs(cy-py)), pi, ci))
    pi, px, py = ci, cx, cy
    
xy.sort(key=lambda x: x[2])
pi, px, py = xy[0]
for i in range(1, N) :
    ci, cx, cy = xy[i]
    v.append((min(cy-py, abs(cx-px)), pi, ci))
    pi, px, py = ci, cx, cy

class UnionFind() :
    def __init__(self, N) :
        self.par = [-1] * N
        
    def root(self, x) :
        while self.par[x] >= 0:
            x = self.par[x]
        return x

    def unite(self, x,y) :
        rx = self.root(x)
        ry = self.root(y)

        if rx != ry :
            if self.par[rx] > self.par[ry] :
                self.par[rx] = ry
            else :
                if self.par[rx] == self.par[ry] :
                    self.par[rx] -= 1
                self.par[ry] = rx
    
    def same(self, x, y) :
        return self.root(x) == self.root(y)

uf = UnionFind(N)
counter = 0
s = 0

v.sort()
for v_ in v :
    c, a, b = v_
    if not uf.same(a, b) :
        uf.unite(a, b)
        counter += 1
        s += c
        if counter == N - 1 :
            break
            
print(s)

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

using namespace std;

int N, M;
int a[50], b[50];

void solve() {
    int res[51] = {0};
    for (int i = 0; i < M; ++i) {
        res[a[i]]++;
        res[b[i]]++;
    }
    for (int i = 1; i <= N; ++i) {
        printf("%d\n", res[i]);
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    int N;
    cin>>N;
    double ans=((double)(N/2+N%2))/N;
    cout<<ans<<endl;
    return 0;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N, K;
int dp[2001][2001];
int T[2001][2001];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  K--;
  for (int i=1; i<=N; i++) dp[K][i] = 1;
  rep(x, N+1) T[K][x] = dp[K][x];
  rep(x, N) add(T[K][x+1], T[K][x]);

  for (int i=K-1; i>=0; i--) {
    rep(x, N+1) {
      if (x > 0) add(dp[i][x], T[i+1][x-1]);
      if (x < N-i) add(dp[i][x], dp[i+1][x]);
    }
    rep(x, N+1) T[i][x] = dp[i][x];
    rep(x, N) add(T[i][x+1], T[i][x]);
  }
  int s = dp[0][N];
  rep(i, N-K-2) s = (2LL*s) % MOD;
  cout << s << "\n";
  return 0;
}


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

ll n,d[100005],otac[100005],broj[100005];
vector<ll> adj[100005];

void dfs1(ll tr,ll pr)
{
    for(auto u: adj[tr])
    {
        if(u!=pr)
        {
            otac[u]=tr;
            d[u]+=d[tr]+1;
            dfs1(u,tr);
        }
    }

}

void brojac(ll tr,ll pr)
{
    broj[tr]++;
    for(auto u:adj[tr])
    {
        if((u!=pr))
        {
            brojac(u,tr);
            broj[tr]+=broj[u];
        }
    }
}

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

    cin>>n;
    for(ll i=1;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    otac[1]=-1;
    dfs1(1,0);

    ll x=d[n]/2-(d[n]%2==0);
    ll ind=n;
    while(x)
    {
        ind=otac[ind];
        x--;
    }

    brojac(1,0);

    //cout<<broj[ind]<<endl;

    if((n-2)-(broj[ind]-1)<=(broj[ind]-1))
        cout<<"Snuke"<<endl;
    else
        cout<<"Fennec"<<endl;

    return 0;
}


Measured memory_bytes: 17648