akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

struct LowestCommonAncestor {
  int n, h;
  vector<vector<int>> par;
  vector<vector<pair<int,int>>> g;
  vector<int> dep;
  vector<ll> weight;

  LowestCommonAncestor(int sz) {
    n = sz; h = 1;
    g.resize(n), dep.resize(n), weight.resize(n);
    while ((1 << h) <= n) h++;
    par.assign(h, vector<int>(n, -1));
  }

  void add_edge(int u, int v, int w = 0) {
    g[u].emplace_back(make_pair(v, w));
    g[v].emplace_back(make_pair(u, w));
  }

  void dfs(int u, int p, int depth) {
    par[0][u] = p;
    dep[u] = depth;
    if (p == -1) weight[u] = 0;
    for (auto v : g[u]) {
      if (v.first == p) continue;
      weight[v.first] = weight[u] + (1LL << v.second);
      dfs(v.first, u, depth + 1);
    }
  }

  void build(int root = 0) {
    dfs(root, -1, 0);
    for (int i = 0; i + 1 < h; i++) {
      for (int j = 0; j < n; j++) {
        if (par[i][j] != -1) par[i+1][j] = par[i][par[i][j]];
        else par[i+1][j] = -1;
      }
    }
  }

  int query(int u, int v) {
    if (dep[u] > dep[v]) swap(u, v);
    for (int i = h-1; i >= 0; i--) {
      if ( ((dep[v] - dep[u]) >> i) & 1) v = par[i][v];
    }
    if (u == v) return u;
    for (int i = h-1; i >= 0; i--) {
      if (par[i][u] != par[i][v]) {
        u = par[i][u];
        v = par[i][v];
      }
    }
    return par[0][u];
  }

  int dist(int u, int v) {
    return dep[u] + dep[v] - 2 * dep[query(u, v)];
  }

  ll weightedsum(int u, int v) {
    return (weight[u] + weight[v]) - 2 * weight[query(u, v)];
  }
};

int main(){
  int n, m;
  cin >> n;
  LowestCommonAncestor lca(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    lca.add_edge(a, b, i);
  }
  lca.build();
  vector<P> d;
  cin >> m;
  rep(i,m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    d.emplace_back(make_pair(u, v));
  }

  ll res = 0;

  for (int bit = 0; bit < (1 << m); bit++) {
    ll sum = 0;
    for (int i = 0; i < m; i++) { 
      if (bit & (1 << i)) {
        sum |= lca.weightedsum(d[i].first, d[i].second);
      }
    }
    int rev = n - 1 - __builtin_popcountll(sum);
    if (__builtin_popcountll(bit) % 2 == 0) res += (1LL << rev);
    else res -= (1LL << rev);
  }

  cout << res << endl;

  return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 51;
int n;
map<ttgl, int> mp;
ttgl arr[mxN];
int main() {
    //freopen("greedy.in", "r", stdin);
    //freopen("greedy.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    owo(i, 0, n) {
        cin>>arr[i].first>>arr[i].second;
    }
    owo(i, 0, n) {
        owo(j, 0, n) {
            if(i==j)continue;
            mp[{arr[i].first-arr[j].first, arr[i].second-arr[j].second}]++;
        }
    }
    int mx = 0;
    for(auto p: mp) {
        mx = max(mx, p.second);
    }
    cout<<(n-mx)<<"\n";
    return 0;
}

Measured memory_bytes: 3780
function main()
  n, m = map(s -> parse(Int, s), split(readline()))
  mod = 10^9 + 7
  ans = 1
  i = 2

  while i * i <= m
    if m % i == 0
      count = 0
      while m % i == 0
        count += 1
        m /= i
      end
      ans *= comb(n + count - 1, count, mod)
      ans %= mod
    end
    i += 1
  end

  if m > 1
    ans *= n
    ans %= mod
  end

  println(ans)
end

function comb(n, k, m)
  if (n - k < k) return comb(n, n - k, m) end
  nume = 1
  deno = 1
  for i = 0:k - 1
    nume *= n - i
    deno *= i + 1
    nume %= m
    deno %= m
  end
  return (nume * modpow(deno, m - 2, m)) % m
end

function modpow(a, p, m)
  if p == 0
    return 1
  elseif p % 2 == 0
    h = modpow(a, p / 2, m)
    return (h * h) % m
  else
    return (a * modpow(a, p - 1, m)) % m
  end
end

main()


Measured memory_bytes: 113516
S = str(input())
f = []
l = []
ans = 'Yes'
for i in range(int((len(S)-1)/2)):
    f.append(S[i])
    l.append(S[-i-1])
for i in range(len(f)):
    if f[i] != l[-i-1]:
        ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
int main(){
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
  bool check=true;
  bool ok=true;
for(int i=0;i<n-1;i++){
    if((!ok&&a[i]>a[i+1])||a.at(i)-a.at(i+1)>1)check=false;
    else if(a[i]>a[i+1])ok=false;
    else if(a[i]<a[i+1])ok=true;
  
}
if(check)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (ll i=0;i<(n);i++)
using namespace std;
#define vecout(v) for(int i=0;i<v.size();i++) {cout<<v[i]<<endl;}
typedef long long ll;

vector<ll> p;
vector<ll> a;
ll n;
ll x;

ll f(ll N, ll X){
    if(N==0) {
        if(X<=0) return 0;
        else return 1;
    }
    else if(X<=p[N-1]+1) return f(N-1, X-1);
    else if(x==p[N-1]+2) return a[N-1]+1;
    else return a[N-1]+f(N-1, X-2-p[N-1])+1;
}
int main(void){
    cin>>n>>x;
    p.resize(n+1);
    a.resize(n+1);
    p[0]=1;
    a[0]=1;
    for(ll i=1;i<=n;i++){
        p[i]=2*p[i-1]+3;
    }
    for(ll i=1;i<=n;i++){
        a[i]=2*a[i-1]+1;
    }
    ll ans=f(n, x);
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#define ll long long int 

using namespace std;

int A,B,Q;


int main(){
    cin >> A >> B >> Q;
    vector<ll> s(A),t(B),X(Q);
    for(int i = 0;i < A;i++){
        cin >> s[i];
    }
    for(int i = 0;i < B;i++){
        cin >> t[i];
    }
    for(int i = 0;i < Q;i++){
        cin >> X[i];
    }
    for(int i = 0;i< Q;i++){
        ll x = X[i];
        ll east_s,east_t,west_s,west_t;
        auto Iter_s = lower_bound(s.begin(),s.end(), x);
        auto Iter_t = lower_bound(t.begin(),t.end(), x);
        if (Iter_s - s.begin() == 0){
            west_s = 20000000000;
        }
        else{
            west_s = x - s[Iter_s - s.begin()-1];
        }
        if (Iter_t - t.begin() == 0){
            west_t = 20000000000;
        }
        else{
            west_t = x - t[Iter_t - t.begin()-1];
        }
        if (Iter_s - s.begin() == s.size()){
            east_s = 20000000000;
        }
        else{
            east_s = s[Iter_s - s.begin()] - x;
        }        
        if (Iter_t - t.begin() == t.size()){
            east_t = 20000000000;
        }
        else{
            east_t = t[Iter_t - t.begin()] - x;
        }
        ll ww,ws,sw,ss;
        ww = max(west_t,west_s);
        if(west_t < east_s){
            ws = 2*west_t + east_s;
        }
        else ws = west_t + 2*east_s;
        if(east_t < west_s){
            sw = 2*east_t + west_s;
        }
        else sw = east_t + 2*west_s;
        ss = max(east_t,east_s);
        cout << min({ww,ws,sw,ss}) << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#define ll long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main(){
	IOS;
	int n,d;
	cin>>n>>d;
	if(n%(2*d+1)==0){
		cout<<n/(2*d+1);
	}	
	else {
		cout<<n/(2*d+1)+1;
	}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
inline int in() { int x; cin>>x; return x;}
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
//----------------------------------------------------------------
int main(int argc,char* argv[]){
    fileio
    int px = in();
    int py = in();
    int qx = in();
    int qy = in();
    rep(i,qy-py) cout<<'U';
    rep(i,qx-px) cout<<'R';
    rep(i,qy-py) cout<<'D';
    rep(i,qx-px) cout<<'L';
    cout<<'L';
    rep(i,qy-py+1) cout<<'U';
    rep(i,qx-px+1) cout<<'R';
    cout<<'D';
    cout<<'R';
    rep(i,qy-py+1) cout<<'D';
    rep(i,qx-px+1) cout<<'L';
    cout<<'U';
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%i %i %i", &a, &b, &c);
	if (a > b && a > c) {
		if (b > c) {
			printf("%i %i %i\n", c, b, a);
		} else if (b < c) {
			printf("%i %i %i\n", b, c, a);
		} else {
			printf("%i %i %i\n", b, c, a);
		}
	} else if(b > a && b > c) {
		if (a > c) {
			printf("%i %i %i\n", c, a, b);
		} else if (c > a) {
			printf("%i %i %i\n", a, c, b);
		} else {
			printf("%i %i %i\n", c, a, b);
		}
	} else if (c > a && c > b) {
		if (a > b) {
			printf("%i %i %i\n", b, a, c);
		} else if (b > a) {
			printf("%i %i %i\n", a, b, c);
		} else {
			printf("%i %i %i\n", b, a, c);
		}
	} else {
		printf("%i %i %i\n", a, b, c);
	}
	return 0;
}


Measured memory_bytes: 2148
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	ll flag = 0;
	if(a==b && a==c)
	{
		flag=1;
	}
	else if(a!=b && b!=c && c!=a)
	{
		flag=1;
	}
	cout<<(flag == 1? "No" : "Yes")<<endl;
	//cout<<a<<" "<<b<<" "<<c<<endl;
}

int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif*/

    //main code starts here//
    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }


    //code ends///
    /*#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif*/
	return 0;

		
}

Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 04.21.2020 10:38:16
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

ll my_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

ll my_inv(ll a) { return my_pow(a, MOD - 2); }

namespace Comb {
const int MAXK = 2e5 + 5;
int fac[MAXK], inv_fac[MAXK];

void init() {
  fac[0] = inv_fac[0] = 1;
  for (int i = 1; i < MAXK; ++i) {
    fac[i] = mul(fac[i - 1], i);
    inv_fac[i] = my_inv(fac[i]);
  }
}

int C(int a, int b) {
  if (a < 0 || b < 0 || b > a) {
    return 0;
  }
  return mul(fac[a], mul(inv_fac[b], inv_fac[a - b]));
}

}  // namespace Comb

int N;
vector<vector<int>> G;
vector<int> sum, dp, ans;

int calcSum(int x, int par) {
  int c = 1;
  for (int v : G[x]) {
    if (v != par) {
      c += calcSum(v, x);
    }
  }
  return sum[x] = c;
}

int calcDp(int x, int par) {
  ll rlt = Comb::fac[sum[x] - 1];
  for (int v : G[x]) {
    if (v != par) {
      rlt = mul(mul(rlt, calcDp(v, x)), Comb::inv_fac[sum[v]]);
    }
  }
  return dp[x] = (int)rlt;
}

void calcAns(int x, int par) {
  if (x == 0) {
    ans[x] = dp[x];
  } else {
    ans[x] = mul(mul(ans[par], sum[x]), my_inv(N - sum[x]));
  }
  for (int v : G[x]) {
    if (v != par) {
      calcAns(v, x);
    }
  }
}

int main() {
  Comb::init();
  cin >> N;
  G.resize(N);
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  sum.resize(N);
  dp.resize(N);
  ans.resize(N);

  calcSum(0, -1);
  dbg(sum);
  calcDp(0, -1);
  dbg(dp);
  calcAns(0, -1);

  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}


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

const int N = 15;
typedef long long LL;

int n, m, s, a[N], b[N][N], ans = 1e9, q[N];

bool check() {
	for(int i = 1; i <= m; i++)
		if(q[i] < s) return false;
	return true;
}

int main() {
	cin>>n>>m>>s;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		for(int j = 1; j <= m; j++) 
			cin>>b[i][j];
	}
	for(int s = 0; s < (1<<n); s++) {
		int res = 0;
		memset(q, 0, sizeof(q));
		for(int i = 1; i <= n; i++)
			if(s&(1<<(i - 1))) {
				res += a[i];
				for(int j = 1; j <= m; j++)
					q[j] += b[i][j];
			}
		if(check()) ans = min(ans, res);
	}
	if(ans == 1e9) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    if(N % 2 == 0) cout << N << endl;
    else cout << 2 * N << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		cout << "0";
		return 0;
	}
	n /= 2;
	ll ans = 0;
	while (n > 0) {
		ans += n / 5;
		n /= 5;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x, y;
        while(true){
            x = scan.nextInt();
            y = scan.nextInt();
            if(x == 0 && y == 0) break;
            if(x > y){ System.out.println(y + " " + x); }
            else{ System.out.println(x + " " + y); }
        }
    }
}


Measured memory_bytes: 35844
#define _USE_MATH_DEFINES
#include<iostream>


using ll = long long;

using namespace std;


int main() {
	int n,y;
	cin>>n>>y;
	bool ok=false;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int k=n-i-j;
			if(10000*i+5000*j+1000*k==y){
				cout<<i<<" "<<j<<" "<<k<<endl;
				ok=true;
				break;
			}
			if(ok)break;
		}
		if(ok)break;
	}
	if(!ok)cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 3588
# A,B,C,Xを取得
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1
print(count)      

Measured memory_bytes: 3060
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int A = int.Parse(input1[0]);
        int B = int.Parse(input1[1]);
        int K = int.Parse(input1[2]);

        int v = 0;
        int c = 0;
        for(int i = A; i >= 0; i--)
        {
            if(A % i == 0 && B % i == 0)
            {
                c++;
                if(c == K)
                {
                    v = i;
                    break;
                }
            }
        }
        Console.WriteLine(v);
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    char x, y;
    cin >> x >> y;
    if(x < y){
        cout << '<' << endl;
    }else if(y < x){
        cout << '>' << endl;
    }else{
        cout << '=' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    #print(i)
    cnt=0
    for j in range(2*i,N+1,i):
        #print(i,j)
        if B[j]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)

Measured memory_bytes: 14084
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include<string>
#include<algorithm>
using namespace std;
int a[114];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; }
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
 
using namespace std;
 
class Process
{
public:
    string name;
    int time;
};
 
void kai()
{
    int n, q;
    cin >> n >> q;
    queue<Process> a;
    for (int i = 0; i < n; ++i)
    {
        Process p;
        cin >> p.name >> p.time;
        a.push(p);
    }
    int sum = 0;
    while (!a.empty())
    {
        Process p = a.front();
        a.pop();
        if (p.time <= q)
        {
            sum += p.time;
            cout << p.name << " " << sum << endl;
        }
        else
        {
            sum += q;
            p.time -= q;
            a.push(p);
        }
    }
}
 
int main()
{
    kai();
    return(0);
}


Measured memory_bytes: 6228
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,a[101],b[101],_min,_max;
int main()
{
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=m;i++)	cin>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	if(a[n]>=y||b[1]<=x)
	{
		puts("War");
		return 0;
	}
	if(a[n]<b[1])
	{
		puts("No War");
		return 0;
	}
	puts("War");
	return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


int main() {
    int K;
    cin >> K;
    deque<pii> D;
    D.push_front({1, 1});
    int now = 1;
    const int INF = 1 << 29;
    vector<int> ans(K, INF);
    while(!D.empty()) {
        pii p = D.back(); D.pop_back();
        if (ans[p.second] == INF) ans[p.second] = p.first; else continue;
        now = p.first;

        D.push_back({now, p.second * 10 % K});
        D.push_front({now + 1, (p.second + 1) % K});
    }
    cout << ans[0] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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


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

	int N, D;
	cin >> N >> D;


	if (N % (D * 2 + 1) != 0) {
		cout << (N / (D * 2 + 1)) + 1 << endl;
	}
	else {
		cout << N / (D * 2 + 1) << endl;
	}
}


Measured memory_bytes: 256
while True:
    x,y,s=map(int, input().split())
    if x==0 and y==0 and s==0:
        break
        
    b=0
    for i in range(1,s):
        for j in range(1,i+1):
             if i*(100+x)//100 + j*(100+x)//100 ==s:
                k=i*(100+y)//100 + j*(100+y)//100
                b=max(b,k)
    print(b)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m,c,ans;
int b[111];
int a[111];
int main(){
	cin>>n>>m>>c;
	for(int i=0;i<m;i++)cin>>b[i];
	while(n--){
		for(int i=0;i<m;i++)cin>>a[i];
		int res=c;
		for(int i=0;i<m;i++)res+=a[i]*b[i];
		if(res>0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int BEAM = 870;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
    if(i % 73 == 0)BEAM -= 90;
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 21924
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = 0;
    if(a+2 < b){
        k -= a-1;
        ans = a;
        ans += (b-a) * (k/2);
        k %= 2;
        ans += k;
    }
    else{
        ans = 1 + k;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	if(str[0] == str[1] && str[2] == str[3] && str[0] != str[3]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long int n, k;
	cin >> n >> k;
	vector<long long int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	if (n <= k) {
		cout << 0 << endl;
		return 0;
	}
	long long int ans=0;
	sort(h.rbegin(), h.rend());
	for (int i = k; i < n; i++) {
		ans = ans + h[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4788
import java.io.*;
import java.math.BigInteger;
import java.util.*;



public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, k;
	static long mod = 1000000007;
	static int[][] memo;
	static String s;
	static HashSet<Integer> nodes;
	static ArrayList<Integer>[] ad, tree;
	static boolean[] vis, taken;
	static int[] a;
	static TreeSet<Long> al;
	static long[] val;
	static ArrayList<String> aa;
	static char[] b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		long k=0;
		int m=sc.nextInt();
		while(m-->0)
			k+=sc.nextInt();
		System.out.println(Math.max(n-k, -1));
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 34184
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
vi adj[N];
vi no[N];
bool used[N];
int comp[N];
int c = 0;
int dfs(int v) {
    used[v] = true;
    comp[v] = c;
    int cnt = 0;
    for (auto to : adj[v]) {
        if (used[to]) continue;
        cnt += dfs(to);
    }
    return cnt + 1;
}
void solve(){
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    } 
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y;
        no[x].pb(y);
        no[y].pb(x);
    }
    vi a;
    for (int i = 1; i <= n; ++i) {
        if (used[i]) continue;
        a.pb(dfs(i));
        c++;        
    }
    for (int i = 1; i <= n; ++i) {
        int cnt = 0;
        for (auto to : no[i]) {
            if (comp[to] == comp[i]) cnt++;
        }
        cout << a[comp[i]] - cnt - adj[i].size() - 1 << ' ';
    }
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 12416
n,*s=map(int,open(0).read().split())
s=sorted(s)
sum_s=sum(s)
if sum_s%10:
  print(sum_s)
else:
  for i in range(n):
    if s[i]%10:
      print(sum_s-s[i])
      break
  else:
    print(0)

Measured memory_bytes: 3060
A, B, C, X, Y = map(int, input().split())
Z = min(X, Y)
p = 0
if A + B >= C * 2:
  p += C * 2 * Z
else:
  p += (A + B) * Z
X, Y = X-Z, Y-Z
if X > 0:
  if A > 2 * C:
    p += 2 * C * X
  else:
    p += A * X
if Y > 0:
  if B > 2 * C:
    p += 2 * C * Y
  else:
    p += B * Y
print(p)


Measured memory_bytes: 3060
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
from operator import itemgetter
import sys
input = sys.stdin.readline
n=int(input())
lx=[]
ly=[]
XY = [[i] + [int(x) for x in input().split()] for i in range(n)]
edge = set()
for key in [itemgetter(1),itemgetter(2)]:
    XY.sort(key = key)
    for i in range(n-1):
        i1,x1,y1 = XY[i]
        i2,x2,y2 = XY[i+1]
        d = min(abs(x1-x2),abs(y1-y2))
        edge.add((i1,i2,d))

row,col,value = zip(*edge)
value = np.array(value,dtype=int)
graph = csr_matrix((value,(row,col)),shape=(n,n))

tree = minimum_spanning_tree(graph,overwrite = True).astype(int)
print(tree.sum())


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

using namespace std;
const int maxn = 100000;
int n,a[maxn+2],t,res;

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	for (int i=1; i<=n; i++)
	cin >> a[i];
	res=0;
	for (int i=1; i<=n; i++)
	if (i==a[i])
	{
		res++;
		t=a[i];
		a[i]=a[i+1];
		a[i+1]=t;
	}
	cout << res;
	return 0;
}
		

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(void) {
	
	int h, w;
	vector<string> a(100);

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

	for (int i = 0; i < w+2; i++)
	{
		cout << "#";
	}
	cout << "\n";
	for (int i = 0; i < h; i++)
	{
		cout << "#" << a[i] << "#\n";
	}
	for (int i = 0; i < w+2; i++)
	{
		cout << "#";
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y):x(x),y(y){}
  Point operator+(Point a){return Point(x+a.x,y+a.y);}
  Point operator-(Point a){return Point(x-a.x,y-a.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}
};
typedef Point Vector;
typedef vector<Point> Polygon;
double norm(Point a){
  return a.x*a.x+a.y*a.y;
}
double abs(Point a){
  return sqrt(norm(a));
}
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
const double PI=3.141592653589793238;
Point trans(double k){
  return Point(cos(k*2*PI),sin(k*2*PI));
}
int n,m;
Polygon p;
double dp[50][50][50];
double dfs(int b,int c,int d){
  if(d==m) return 0;
  if(dp[b][c][d]>=0) return dp[b][c][d];
  double res=0;
  for(int a=c;a!=b;a=(a+1)%n){
    res=max(res,dfs(b,a,d+1)+abs(cross(p[a]-p[b],p[c]-p[b])));
  }
  return dp[b][c][d]=res;
}
signed main(){
  while(cin>>n>>m,n||m){
    p.clear();
    p.resize(n);
    for(int i=0;i<n;i++){
      double k;
      cin>>k;
      p[i]=trans(k);
      //cout<<p[i].x<<" "<<p[i].y<<endl;
    }
    for(int i=0;i<50;i++)
      for(int j=0;j<50;j++)
	for(int k=0;k<50;k++)
	  dp[i][j][k]=-1;
    double ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j) continue;
	ans=max(ans,dfs(i,j,2));
      }
    }
    printf("%.6f\n",ans/2.0);
  }
  return 0;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<int> a(n+1,0),b(n+1,0);
  for(int i=0;i<n;i++){
    if(s[i]=='W'){
      a[i+1]+=a[i]+1;
    }else{
      a[i+1]=a[i];
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='E'){
      b[max(i-1,0)]+=b[i]+1;
    }else{
      b[max(i-1,0)]=b[i];
    }
  }
  int ans=1e9;
  for(int i=0;i<n;i++){
    ans=min(a[i]+b[i],ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6128
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = 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; }

int main()
{
    string S; cin >> S;

    lint sum = 0;
    for (int bit = 0; bit < (1 << (S.length() - 1)); ++bit)
    {
        lint num = S[0] - '0';
        for (int i = 0; i < S.length() - 1; ++i)
        {
            if (bit & (1 << i))
            {
                sum += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        sum += num;
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int cou,n,x,b;
  cin >> n >> x;
  cou=1;
  b=0;
  vector <int> a(n);
  for (int i=0;i<n;i++)
    cin >> a.at(i);
  for (int i=0;i<n;i++){
  b+=a.at(i);
    if(b<=x)
      cou++;
  }
  cout << cou << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, d;

int main() {
	cin >> n >> d;
	
	cout << ce(n, 2 * d + 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	cin>>n;
	vector<ll>ans(n+1,-1);
	ans[1]=0;
	vector<vector<pair<ll,ll>>>road(n+1);
	for(int i=0;i<n-1;i++){
		ll u,v,w;
		cin>>u>>v>>w;
		road[u].push_back({v,w%2});
		road[v].push_back({u,w%2});
	}
	queue<ll>que;
	que.push(1);
	while(!que.empty()){
		ll x=que.front();
		que.pop();
		for(pair<ll,ll>p:road[x]){
			if(ans[p.first]!=-1)continue;
			ans[p.first]=(ans[x]+p.second)%2;
			que.push(p.first);
		}
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 11384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;

int main(){
  int n,r;
  cin >> n >> r;
  
  if(n>=10) cout << r;
  else cout << r+100*(10-n);
  
  return 0;
}

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

#ifdef LOCAL
#define dbg(x) (cerr << "ln " << __LINE__ << ": " << #x << " = " << (x) << '\n')
#else
#define dbg(x) {}
#endif

typedef long long ll;

int n;
ll a[10005], b[10005];
ll ops, dif, ao, bo, eqz;

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

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

	for (int i=1; i<=n; i++) {
		dif += b[i] - a[i];

		if (a[i] > b[i]) {
			bo += a[i] - b[i];
		} else {
			ll d = b[i] - a[i];
			if (d % 2) {
				ao += d / 2 + 1;
				bo += 1;
			} else {
				ao += d / 2;
			}
		}
	}

	eqz = abs(ao - bo);

	dbg(ao);
	dbg(bo);
	dbg(eqz);
	dbg(dif);

	// bar ao puta moram da biram a
	// bar bo puta moram da biram b

	// smem da biram najvise dif puta

	cout << (max(ao, bo) + eqz <= dif ? "Yes\n" : "No\n");
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = 0;
            var B = 0;
            var BA = 0;
            var AB = 0;
            for (int i = 0; i < N; i++)
            {
                var s = Read();
                var first = s[0];
                var last = s[s.Length - 1];
                if (first == 'B' && last == 'A') BA++;
                else if (first == 'B') B++;
                else if (last == 'A') A++;
                for (int j = 0; j < s.Length - 2; j++)
                {
                    if (s.Substring(j, 2) == "AB") AB++;
                }
            }
            if (N == 1)
            {
                Console.WriteLine(AB);
                return;
            }
            var ans = AB;
            var tmp = Math.Min(A, B);
            ans += tmp;
            A -= tmp;
            B -= tmp;
            N -= tmp * 2;
            var rem = Math.Max(A, B);            
            if (rem > BA)
            {
                if (BA * 2 <= N)
                {
                    ans += BA;
                    N -= BA * 2;
                    BA = 0;
                }
                else
                {
                    tmp = Math.Min(rem, N / 2);
                    ans += tmp;
                    N -= tmp * 2;
                    BA -= tmp;
                }
            }
            else
            {
                if (rem * 2 <= N)
                {
                    ans += rem;
                    BA -= rem;
                    N -= rem * 2;
                }
                else
                {
                    tmp = Math.Min(BA, N / 2);
                    ans += tmp;
                    BA -= tmp;
                    N -= tmp * 2;
                }
            }
            if (ans - AB > 0) ans += Math.Min(BA, N);
            else if (BA >= 2) ans += BA - 1;

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h> 
using namespace std;
long long f[2005][2005],n,k;
const int Mod=1e9+7;
int main()
{
	scanf("%lld%lld",&n,&k);
	f[0][0]=1;
	for(int i=1; i<=n; i++)
	{
		f[i][0]=1;
		for(int j=1; j<=i; j++) f[i][j]=(f[i-1][j-1]+f[i-1][j])%Mod;
	}
	for(int i=1; i<=k; i++) printf("%lld\n",f[n-k+1][i]*f[k-1][i-1]%Mod);
	return 0;
}

Measured memory_bytes: 30080
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,n,x;
long long int sum;

int main(){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x);
		sum+=x;
	}
	printf("%d\n",sum/n);
	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;
import java.util.Stack;

//Strange Mathematical Expression
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String[] s = sc.nextLine().split(" ");
			Stack<Double> u = new Stack<Double>();
			for(String v:s){
				if(v.equals("+")){
					double b = u.pop();
					double a = u.pop();
					u.push(a+b);
				}
				else if(v.equals("-")){
					double b = u.pop();
					double a = u.pop();
					u.push(a-b);
				}
				else if(v.equals("*")){
					double b = u.pop();
					double a = u.pop();
					u.push(a*b);
				}
				else if(v.equals("/")){
					double b = u.pop();
					double a = u.pop();
					u.push(a/b);
				}
				else u.push(Double.parseDouble(v));
			}
			System.out.println(u.pop());
		}
	}
}

Measured memory_bytes: 12000
import numpy as np
mod = 1000000007

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

bit = 1
ans = 0
for i in range(60):
    a_and = a & 1
    cnt_one = np.count_nonzero(a_and)
    ans += (cnt_one * (n - cnt_one) * bit) % mod
    ans %= mod
    a >>= 1
    bit *= 2
    bit % mod

print(ans)

Measured memory_bytes: 48828
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    vector<ll> a(n),f(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>f[i];
    sort(begin(a),end(a));
    sort(begin(f),end(f));
    ll from = 0,to=1e+12;
    function<bool(ll)> check = [&](ll x) {
        ll cnt = 0;
        rep(i,n) {
            cnt += max(0LL,a[i]-x/f[n-1-i]);
        }
        return cnt <= k;
    };
    while(true) {
        ll mid = (from + to) / 2;
        if (check(mid)) {
            to = mid;
        }
        else {
            from = mid;
        }
        if (to-from<=1) {
            if(check(from)) {
                cout << from << endl; 
            }else {
                cout << to << endl;
            }
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);


  
int main(){
  int n;
  cin >> n;
  vector<ll>vec(n);
  ll sum=0;
  rep(i,n){
    ll a;
    cin >> a;
    vec[i]=a-i-1;
  }
  sort(vec.begin(),vec.end());
  
  ll b;
  if(n%2==0){
    b=(vec[n/2-1]+vec[n/2])/2;
    rep(i,n){
      sum+=abs(vec[i]-b);
    }
  }
  else{
    b=vec[n/2];
    rep(i,n){
      sum+=abs(vec[i]-b);
    }
  }
  cout << sum << endl;
  return 0;
}


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


int main()
{
	string S;
	cin >> S;
	if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
S = [input() for i in range(H)]
C = sum(i.count('.') for i in S)

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
que = deque([(0, 0, 0)])
used = {(0, 0)}

res = []
while que:
    s, t, cost = que.popleft()
    if s == H-1 and t == W-1:
        res = cost
        break
    for di, dj in dd:
        xi = s + di; yj = t + dj
        if (not 0 <= xi < H) or (not 0 <= yj < W) or S[xi][yj] == '#' or (xi, yj) in used:
            continue
        used.add((xi, yj))
        que.append((xi, yj, cost + 1))
if res:
    print(C - 1 - res)
else:
    print(-1)


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if (a == b && a == c && b == c) {
        cout << "1" << endl;
    }else if(a == b || a == c || b == c){
        cout << "2" << endl;
    }else{
        cout << "3" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	long long a[100];
	f(i, 100)a[i] = 0;
	int k, s;
	int n, m;
	int x, y, z;
	int ans = 0;
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i < 87; i++){
		a[i] = a[i - 2] + a[i - 1];
	}
	scanf("%d", &n);

	printf("%lld\n", a[n]);

	return 0;
}



Measured memory_bytes: 128