akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;
void mod_build(int n){  
  fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1; inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return fact[n]*invfact[n-k]%mod; } }
ll comb(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; }}
ll modpow(ll x,ll n){
  x%=mod; ll res=1;
  while(n>0){ if(n&1){res=res*x%mod;} x=x*x%mod; n>>=1; }
  return res;
}
ll modinv(ll a){ return modpow(a, mod-2); }

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

int main(){
  int n;
  cin >> n;
  map<pair<ll,ll>,int> mp;
  vector<ll> a(n),b(n);
  int az = 0;
  int bz = 0;
  int aaa=0;
  rep(i,n){
    cin >> a[i] >> b[i];
    if(a[i]==0&&b[i]==0) {aaa++;continue;}
    if(a[i]==0){
      az++;
      continue;
    }
    if(b[i]==0){
      bz++;
      continue;
    }
    ll g = gcd(a[i],b[i]);
    a[i] /= g;
    b[i] /= g;
    if(a[i]<0){ a[i]*=-1; b[i]*=-1; }
    mp[{a[i],b[i]}]++;
  }

  ll ori = 0;
  set<pair<ll,ll>> st;
  vector<pair<ll,ll>> k;
  bool flag = false;
  rep(i,n){
    if(a[i]==0&&b[i]==0) continue;
    if(b[i]==0||a[i]==0){
      if(bz!=0 && az!=0){
        if(!flag){
          k.emplace_back(bz, az);
          flag = true;
        } 
      } else {
        ori++;
      }
      continue;
    }
    ll x = b[i];
    ll y = a[i];
    if(x<0){ x *= -1; }else{ y *= -1; }
    if(mp.count({x,y})==0){
      ori++; 
    } else {
      if(st.find({x,y})==st.end()){
        k.emplace_back(mp[{x,y}], mp[{a[i],b[i]}]);
        st.insert({x,y});
        st.insert({a[i],b[i]});        
      }
    }
  }

  mint ans = modpow(2,ori);
  for(auto it:k){
    mint tmp = modpow(2,it.F) + modpow(2,it.S) -1;
    ans *= tmp;
  }
  ans-=1;
  ans += aaa;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 18712
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<mint> kai(m+1);
    kai[0] = mint(1);
    REP(i,m){
        kai[i+1] = kai[i] * mint(i+1);
    }
    mint ans(0);
    for(ll k = 0;k<=n;++k){
        mint t(1);
        t = kai[n];
        t /= kai[k];
        t /= kai[n-k];
        t *= kai[m];
        t /= kai[m-k];
        t *= kai[m-k];
        t /= kai[m-k-(n-k)];
        t *= kai[m-k];
        t /= kai[m-k-(n-k)];
        if(k%2==0){
          ans += t;
        }else{
          ans -= t;
        }
    }
    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 7088
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

bool prime[10001];
vector<int> vec;
int dp[10001];

int main(void){
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=10000;i++){
		if(prime[i]){
			vec.push_back(i);
			for(int j=i*2;j<=10000;j+=i){
				prime[j]=false;
			}
		}
	}
	for(int i=0;i<vec.size();i++){
		int sum=0;
		for(int j=i;j<vec.size();j++){
			sum+=vec[j];
			if(sum>=10001)break;
			dp[sum]++;
		}
	}
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",dp[n]);
	}
	return 0;
}

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

int fact(int n) {
  if ( n == 0 || n == 1 ) {
    return 1;
  }
  return n * fact(n-1);
}

int calc(vector<int>& S, int start, int end) {
  int diff = end - start;
  if ( diff == 1 ) {
    return 1;
  }
  priority_queue<int,vector<int>,greater<int>> pq;
  for(int i = start; i < end; i++) {
    pq.push(S.at(i));
  }
  int start_value = S.at(start);
  int rank = 0;
  while(!pq.empty()) {
    int v = pq.top();
    if ( start_value == v ) {
      break;
    }
    pq.pop();
    rank++;
  }
  int offset = rank > 0 ? rank * fact(diff-1) : 0;
  return offset + calc(S, start+1, end);
}

int calc_order(vector<int>& S) {
  return calc(S, 0, S.size());
}

int main() {
  //input
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  rep(i,N) {
    cin >> P.at(i);
  }
  rep(j,N) {
    cin >> Q.at(j);
  }
  //calc
  int a = calc_order(P);
  int b = calc_order(Q);
//  cout << "a = " << a << "," << "b = " << b << endl;
  int answer = a > b ? a - b : b - a;
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
input()
vals    = input()
vals    = vals.split()
vals    = list(map(lambda v:int(v), vals))


kisu    = 0
div4    = 0
div2    = 0

for e in (vals):
    if e % 4 == 0:
        div4    += 1
    elif e % 2 == 1:
        kisu    += 1
    else:
        div2    += 1

if div4 >= kisu:
    print("Yes")
elif div4 == kisu - 1 and len(vals) == div4 + kisu:
    print("Yes")
elif div2 == len(vals):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int bound = 2000100;
ll fact[bound], fact_inv[bound];

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

ll inv( ll x ){
	return power(x, mod-2);
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = inv(fact[b]);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r or r < 0 ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

int main(){
	init();
	ll k, s; string tmp;
	cin >> k >> tmp;
	s = tmp.size();
	ll n = s+k;
	ll ans = 0;
	for( ll i = 0; i < n; ++i ){
		ans += power(26, i) * comb(n-(i+1), s-1) % mod * power(25, n-(i+1)-(s-1)) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 36592
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

struct tree_diameter{
	const long long X = 1000000000000000000;
	pair<long long,vector<int>> get(vector<vector<pair<int,long long>>> &E){
		vector<long long> dis = bfs(E,0);
		long long maxi = -1;
		int ind = 0;
		for(int i=0;i<E.size();i++){
			if(dis[i]>maxi){
				maxi=dis[i];
				ind=i;
			}
		}

		dis = bfs(E,ind);
		maxi = -1;

		for(int i=0;i<E.size();i++){
			if(dis[i]>maxi){
				maxi=dis[i];
				ind=i;
			}
		}

		vector<int> ret;
		ret.push_back(ind);
		while(dis[ind]!=0LL){
			for(int i=0;i<E[ind].size();i++){
				if(dis[ind] == dis[E[ind][i].first] + E[ind][i].second){
					ind = E[ind][i].first;
					ret.push_back(ind);
					break;
				}
			}
		}
		
		return make_pair(maxi,ret);
		
	}
	
	pair<long long,vector<int>> get(vector<vector<int>> &E){
		vector<vector<pair<int,long long>>> e(E.size(),vector<pair<int,long long>>());
		for(int i=0;i<E.size();i++){
			for(int j=0;j<E[i].size();j++){
				e[i].emplace_back(E[i][j],1LL);
			}
		}
		return get(e);
	}
	
	vector<long long> bfs(vector<vector<pair<int,long long>>> &E,int start){
		vector<long long> dis(E.size(),X);
		dis[start] = 0LL;
		queue<int> Q;
		Q.push(start);
		
		while(Q.size()!=0){
			int u = Q.front();
			Q.pop();
			for(int i=0;i<E[u].size();i++){
				int v = E[u][i].first;
				if(dis[v]!=X)continue;
				dis[v] = dis[u] + E[u][i].second;
				Q.push(v);
			}
		}
		return dis;
	}
	
};

vector<int> d;

void dfs(vector<vector<int>> &E,int now,int p,int depth){
	if(depth==0){
		d[depth] = E[now].size();
	}
	else{
		d[depth] = max(d[depth],(int)E[now].size()-1);
	}
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==p)continue;
		dfs(E,to,now,depth+1);
	}
}

int main(){
	
	int N;
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	tree_diameter T;
	
	vector<int> t = T.get(E).second;
	
	pair<int,long long> ans(1000000000,10000000000);
	
	for(int i=0;i<N;i++){
		d.assign(N+3,0);
		dfs(E,i,-1,0);
		pair<int,long long> t(1,1LL);
		for(int j=0;j<d.size();j++){
			if(d[j]==0){
				t.first = j+1;
				break;
			}
			t.second *= d[j];
		}
		ans = min(ans,t);
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<E[i].size();j++){
			
			auto e = E;
			e.push_back(vector<int>());
			e.back().push_back(i);
			e.back().push_back(E[i][j]);
			e[i][j] = E.size();
			for(int k=0;k<e[E[i][j]].size();k++){
				if(e[E[i][j]][k]==i){
					e[E[i][j]][k]=E.size();
					break;
				}
			}
			
			d.assign(N+3,0);
			dfs(e,E.size(),-1,0);
			pair<int,long long> t(1,1LL);
			for(int k=0;k<d.size();k++){
				if(d[k]==0){
					t.first = k;
					break;
				}
				t.second *= d[k];
			}
			ans = min(ans,t);
			
		}
	}
			
	
	
	cout<<ans.first<<' '<<ans.second<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3720
N,K = map(int,input().split())
A = list(map(int,input().split()))

#(方針)
#1)1回の整数列Aにp箇所大きさの順番が逆になっているところがあれば, 
#p×(1+2+...+K)回の転倒数
#2)1以外で1回目の整数列Aと2回目の整数列にq箇所大きさの順番が逆になっているところがあれば,
#q×(1+2+...+(K-1))回の転倒数
p,q = 0,0
for i in range(N):
  for j in range(N):
    if(i<j):
      if(A[i]>A[j]): p += 1
    if(i>j):
      if(A[i]>A[j]): q += 1

tmp1 = (K*(K+1)//2)%(10**9 +7)
tmp2 = ((K-1)*K//2)%(10**9 +7)
ans = (p*tmp1 + q*tmp2)%(10**9 +7)
print(ans)  

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
	
	int n, AC = 0, WA = 0, TLE = 0, RE = 0;
	char str[10];
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++){
		scanf("%s", str);
		if(str[0] == 'A'){
			AC++;
		}
		else if(str[0] == 'W'){
			WA++;
		}
		else if(str[0] == 'T'){
			TLE++;
		}
		else if(str[0] == 'R'){
			RE++;
		}
	}
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
const int N=305;
int n,mo,k,c[N][N],f[N][N],w[N][N];
int main(){
    cin>>n>>k>>mo;
    for (int i=0; i<=n; ++i){
	c[i][0]=1;
	for (int j=1; j<=i; ++j)
	    c[i][j]=(c[i-1][j-1]+c[i-1][j])%mo;
    }
    for (int i=k; i>=0; --i){
	f[i][0]=1;
	for (int j=1; j<=n; ++j)
	    for (int t=0; t<j; ++t)
		(f[i][j]+=1ll*w[i+1][j-t-1]*f[i][t]%mo*c[j-1][t]%mo)%=mo;
	for (int j=0; j<=n; ++j)
	    w[i][j]=(w[i+1][j]+f[i][j])%mo;
    }
    cout<<f[0][n];
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], K = I[1];
		var a = G;
		var s = new MultiSet<long>();
		var sum = new long[N + 1];
		for (var i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
		for (var i = 0; i < N; i++) for (var j = i + 1; j <= N; j++) s.Add(sum[j] - sum[i]);
		var x = 0L;
		for (var i = 40; i >= 0; i--)
		{
			var y = x | (1L << i);
			var c = 0;
			var tmp = new List<long>();
			foreach (var p in s.Keys) if ((y & p) == y) c += s[p]; else tmp.Add(p);
			if (c >= K) { x = y; foreach (var p in tmp) s.RemoveAll(p); }
		}
		WriteLine(x);
	}
}
class MultiSet<T> : IEnumerable<T>, ICollection<T>
{
	readonly Dictionary<T, int> cnt = new Dictionary<T, int>();
	public IEnumerable<T> Keys => cnt.Keys;
	public int this[T x] => cnt[x];
	public int Count { get; private set; }
	public bool IsReadOnly => false;
	public MultiSet() { }
	public MultiSet(IEnumerable<T> s) { foreach (var x in s) Add(x); }
	public void Add(T x) { if (cnt.ContainsKey(x)) cnt[x]++; else cnt[x] = 1; Count++; }
	public bool Remove(T x) { if (!cnt.ContainsKey(x)) return false; if (--cnt[x] == 0) cnt.Remove(x); Count--; return true; }
	public int RemoveAll(T x) { var c = cnt.ContainsKey(x) ? cnt[x] : 0; Count -= c; cnt.Remove(x); return c; }
	public IEnumerator<T> GetEnumerator() { foreach (var x in cnt) for (var i = 0; i < x.Value; i++) yield return x.Key; }
	IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
	public void Clear() { Count = 0; cnt.Clear(); }
	public bool Contains(T item) => cnt.ContainsKey(item);
	public void CopyTo(T[] array, int arrayIndex) { foreach (var x in this) array[arrayIndex++] = x; }
}


Measured memory_bytes: 45028
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()

signed main() {
    int n, k;
    cin >> n >> k;

    int ca = n - (n / k - 1) * k;
    int cb = n - (n / k) * k;
    int cc = k - cb;
    cout << min({ca, cb, cc});
    
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
ll dp[100005];
int main()
{
    fio;
    ll n;
    cin>>n;
    pll a[n];
    rep(i,n)
    cin>>a[i].s>>a[i].f;
    sort(a,a+n);
    ll sum=0;
    rep(i,n)
    {
        if(a[i].f>=sum+a[i].s)
        {
            sum+=a[i].s;
            continue;
        }
        else
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 M, D;
  cin >> M >> D;
  i64 ans =0;
  for(int m = 1;m <= M;m++) {
    for(int d = 1;d <= D;d++) {
      if(d % 10 >= 2 && d / 10 >= 2 && (d % 10) * (d / 10) == m) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
    int a,b; cin>>a>>b;

    if (1<=a && a <=9 && 1<=b && b<=9) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
from math import pi
import numpy as np
a, b, x = map(int, input().split())

if x <= (b * a**2) / 2: 
    ans_rad = np.arctan((a * b**2) / (2 * x))
elif x > (b * a**2) / 2:
    ans_rad = np.arctan((2 * b * a ** 2 - 2 * x) / a**3)

ans = ans_rad * (180 / pi)
print("{}".format(np.round(ans, 7)))

Measured memory_bytes: 12500
#include<bits/stdc++.h>
#define mo 1000000007
#define add(a,b) (a+b>mo)?(a+=b-mo):(a+=b)
using namespace std;
int fac[200010],nifac[200010];
int getmi(int a,int x)
{
	long long ans=1;
	while (x)
	{
		if (x&1) ans=ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
long long work(int n,int m)
{
	//cout<<n<<' '<<m<<endl;
	return (long long)fac[n+m]*nifac[n]%mo*nifac[m]%mo;
}
int main()
{
	fac[0]=1;for (int i=1;i<=200000;i++) fac[i]=(long long)fac[i-1]*i%mo; 
	nifac[200000]=getmi(fac[200000],mo-2);
	for (int i=199999;i>=0;i--) nifac[i]=(long long)nifac[i+1]*(i+1)%mo;
	//cout<<(long long)fac[233]*nifac[233]%mo<<endl;
	int ans=0,h,w,a,b;
	cin>>h>>w>>a>>b;
	for (int i=1;i<=h-a;i++) ans=(ans+work(i-1,b-1)*work(w-b-1,h-i))%mo;
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
N=int(input())
L=list(map(int,input().strip().split()))
an=0
for i in range(N):
    kusi=[]
    kusi.append(min(L))
    L.remove(min(L))
    kusi.append(min(L))
    L.remove(min(L))
    an+=min(kusi)
print(an)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int min = 1001001001;
    rep(k, 100101) {
        int total = 2 * c * k + a * max(x - k, 0) + b * max(y - k, 0);
        min = (total < min) ? total : min;
    }
    cout << min << endl;
    return 0;
}



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

int main() {
  //unordered_map<string,long long int> dp;
  long long int x, ans = 0;
  cin >> x;
  for(int i=1; i <= x; i++)
    for(int j=1; j <= x; j++)
    	for(int k=1; k <= x; k++)
        {
          /*string temps = to_string(i) + to_string(j) + to_string(k);
          sort(temps.begin(), temps.end());
          if(dp[temps] != 0)
            ans = ans + dp[temps];
          else {*/
            long long int gcd = __gcd(__gcd(i,j), k);
            //dp[temps] = gcd;
            ans = ans + gcd;
          //}
        }
  cout << ans;
  return 0;
}
   

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

class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());

        var array = System.Linq.Enumerable.Repeat(0, 3).ToArray();

        array[a - 1] = -1;
        array[b - 1] = -1;


        for (int i = 0; i < array.Length; i++)
        {
            if(array[i] == 0)
            {
                Console.WriteLine(i + 1);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;


	while (1) {

		scanf("%d %c %d", &a, &op, &b);

		switch (op) {
		case '+':printf("%d\n", a + b); break;

		case '-':printf("%d\n", a - b); break;

		case '*':printf("%d\n", a*b); break;

		case '/':printf("%d\n", a / b); break;

		default:break;

		}

		if (op == '?') {
			break;
		}

	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int d[200000];
int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&d[i]);
	}
	sort(d,d+n);
	int mx=d[n/2],mn=d[n/2-1];
	cout<<mx-mn<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(void){
	long long n;
	cin >> n;
	long long sum=n-1;
	for(long long i=sqrt(n); i>1; i--){
		if(n%i==0){
			sum = min(sum, i + n/i -2);
		}
	}
	cout << sum << endl;
}

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

int bcd[3];
bool solve(int, int);

int main()
{
    int input, rest = 7;
    scanf("%d", &input);
    printf("%d", input / 1000);
    rest = 7 - input / 1000;
    input %= 1000;
    for (int i = 2; i >= 0; i--)
    {
        bcd[i] = input % 10;
        input /= 10;
    }
    solve(2, rest);
    printf("=7\n");

    return 0;
}

bool solve(int keta, int rest)
{
    if (keta == -1)
    {
        if (rest) return false;
        else return true;
    }

    if (solve(keta - 1, rest - bcd[keta]))
    {
        printf("+%d", bcd[keta]);
        return true;
    }
    else if (solve(keta - 1, rest + bcd[keta]))
    {
        printf("-%d", bcd[keta]);
        return true;
    }
    else
        return false;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
abc = [LIST() for _ in range(N-1)]
Q, K = MAP()
xy = [LIST() for _ in range(Q)]

connection = [[] for _ in range(N)]
for a, b, c in abc:
	connection[a-1].append((b-1, c))
	connection[b-1].append((a-1, c))

#print(connection)

step = [-1]*N

def DFS(N):
	for X, C in connection[N]:
		if step[X] == -1:
			step[X] = step[N] + C
			DFS(X)

step[K-1] = 0
DFS(K-1)

#print(step)

for x, y in xy:
	print(step[x-1] + step[y-1])


Measured memory_bytes: 177940
#include<iostream>
using namespace std;
long long int gcd(long long int a, long long int b);
int a[200000];
int main() {
	
	//D

	int n;
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int counter = 0;
	int seek = 1;
	for (i = 0; i < n; i++) {
		if (a[i] == seek) {
			counter++;
			seek++;
		}
	}
	if (counter == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << n - counter << endl;
	return 0;

	//C
	/*long long int A, B;
	cin >> A >> B;
	cout <<  A * B / gcd(A, B) << endl;
	return 0;*/

	//B
	/*int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int i;
	for (i = 0; i < n; i++) {
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
	return 0;*/
}
long long int gcd(long long int a,long long  int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

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

int main(){
    int a,b;
    cin >> a;
    cin >> b;
    int ans;
    ans=6-a-b;
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll a,b,k;cin>>a>>b>>k;
  FOR(i,a,min(a+k-1,b)){
  	cout<<i<<endl;
  }
  FOR(i,max(min(a+k-1,b)+1,b-k+1),b){
  	cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline())
s = [''.join(sorted(sys.stdin.readline().strip())) for _ in range(n)]

import collections
c = collections.Counter(s)

import math
def combination(v):
    return int(math.factorial(v) / (math.factorial(v - 2) * math.factorial(2)))
print(sum(combination(v) for v in c.values() if v != 1))


Measured memory_bytes: 19788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  map<string,int>mp;
  int n,m;
  string x;
  cin>>n;
  rep(i,n){
    cin>>x;
    mp[x]++;
  }
  cin>>m;
  rep(i,m){
    cin>>x;
    mp[x]--;
  }

  int maxi=0;
  for(auto itr : mp){
    maxi=max(maxi,(int)itr.second);
  }
  cout<<maxi<<endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut s: [Chars;n],
        m: usize,
        mut t: [Chars;m],
    }

    s.sort();
    s.push(['d'].to_vec());
    t.sort();
    t.push(['d'].to_vec());
    // debug!(s);
    // debug!(t);
    let mut cnt = 1;
    let mut ret_s: Vec<(String, usize)> = Vec::new();
    let mut ret_t: Vec<(String, usize)> = Vec::new();
    if n==1 {
        ret_s.push((s[0].iter().collect(), 1));
    } else {
        for i in 1..n+1 {
            let s1_tmp: String = s[i].iter().collect();
            let s0_tmp: String = s[i-1].iter().collect();
            if s0_tmp==s1_tmp {
                cnt += 1;
            } else {
                ret_s.push((s0_tmp, cnt));
                cnt = 1;
            }
        }
    }

    cnt = 1;
    if m==1 {
        ret_t.push((t[0].iter().collect(), 1));
    } else {
        for i in 1..m+1 {
            let t1_tmp: String = t[i].iter().collect();
            let t0_tmp: String = t[i-1].iter().collect();
            if t0_tmp==t1_tmp {
                cnt += 1;
            } else {
                ret_t.push((t0_tmp, cnt));
                cnt = 1;
            }
        }
    }
    debug!(ret_s.len());
    debug!(ret_t.len());
    let mut ans: Vec<i64> = Vec::new();
    // let mut init_ans = 0;
    // for i in 0..ret_s.len() {
        // init_ans = max(init_ans, ret_s[i].1);
    // }

    // ans.push(init_ans as i64);
    let mut ok = false;
    for i in 0..ret_s.len() {
        for j in 0..ret_t.len() {
            if ret_s[i].0==ret_t[j].0 {
                ans.push(max(0, (ret_s[i].1 as i64)-(ret_t[j].1 as i64)));
                ok = true;
            }
        }
        if ok==false {
            ans.push(ret_s[i].1 as i64);
        } else {
            ok = false;
        }
        
    }
    ans.sort();
    ans.reverse();
    println!("{}", ans[0]);
    // if ok {
    //     println!("{}", ans[1]);
    // } else {
    //     println!("{}", ans[0]);
    // }
}


Measured memory_bytes: 2204
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N; cin >>N;
  if(N == 2){
    int a, b; cin >>a >>b;
    FOR(i, 1, max(a, b) + 1) if(a % i == 0 && b % i == 0) cout <<i <<endl;
  } else{
    int a, b, c; cin >>a >>b >>c;
    FOR(i, 1, max(a, max(b, c)) + 1) if(a % i == 0 && b % i == 0 && c % i == 0) cout <<i <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)

#define shosu setprecision(10)

typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string s,t;
map<char,char> mp1,mp3;
map<char,int> mp2,mp4;

int main(){
cin>>s>>t;bool f=1;
rep1(i,s.size()){
if(mp2[s[i]]==0){
mp1[s[i]]=t[i];
mp2[s[i]]++;
}
if(mp4[t[i]]==0){
  mp3[t[i]]=s[i];
  mp4[t[i]]++;
}

if(mp1[s[i]]!=t[i]) f=0;
if(mp3[t[i]]!=s[i])f=0;

}
if(f)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long x, y, z, k, i, j;
	cin >> x >> y >> z >> k;
	vector<long long> a(x), b(y), c(z), v, w;
	for (i = 0; i < x; i++) cin >> a[i];
	for (i = 0; i < y; i++) cin >> b[i];
	for (i = 0; i < z; i++) cin >> c[i];

	priority_queue<long long> q;
	for (i = 0; i < x; i++) {
		for (j = 0; j < y; j++) {
			q.push(-a[i] - b[j]);
			if (q.size() > k) q.pop();
		}
	}

	while (!q.empty()) {
		v.push_back(-q.top());
		q.pop();
	}

	for (i = 0; i < z; i++) {
		for (auto p : v) {
			q.push(-c[i] - p);
			if (q.size() > k) q.pop();
		}
	}

	while (!q.empty()) {
		w.push_back(-q.top());
		q.pop();
	}

	sort(w.rbegin(), w.rend());
	for (auto p : w) cout << p << "\n";


	return 0;
}

Measured memory_bytes: 384
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array


void solve(){
    int d,t,s;
    cin >> d >> t >> s;
    double avg = (d*1.0)/s;
    if(avg<=t) cout << "Yes\n";
    else cout << "No\n";
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
 
vector <ll> factorials;
vector <ll> inv_factorials;
ll mod=1e9+7;
 
ll modExp(ll x, ll n)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}
 
ll modInv(ll a)
{
    return modExp(a, mod-2);
}
 
ll choose(ll n, ll k) 
{
    if (k==0) return 1;
    if (k<0 || k>n) return 0;
    ll ans = factorials[n] * inv_factorials[k] % mod;
    return (ans * inv_factorials[n - k]) % mod;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    const int kRange = 3e6;
    factorials.resize(kRange + 1, 1);
    inv_factorials.resize(kRange + 1, 1);
    loop(i,2, kRange+1)
    {
        factorials[i]=(factorials[i-1]*i)%mod;
    }
    inv_factorials[kRange] = modInv(factorials[kRange]);
    for (int i = kRange - 1; i >= 0; --i) {
        inv_factorials[i] = (inv_factorials[i + 1] * (i + 1)) % mod;
    }
 
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans=0;
    for (ll j=c1; j<=c2; ++j)
    {
        ll temp = (choose(r2+j+1, j+1)-choose(r1+j, j+1)+mod)%mod;
        ans = (ans+temp)%mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 47104
def dict_set(dict_A, dict_B):
    '''
    A, Bのどちらにも存在するkeyに対して、小さい方のvalueをもつような辞書を作る。
    
    Parameters
    -------------------------------------------
    dict_A, dict_B, dictionary
    
    Returns
    -------------------------------------------
    dict_AandB
    
    '''
    dict_AandB = {}
    
    for key in dict_A:
        if key in dict_B:
            dict_AandB[key] = min(dict_A[key], dict_B[key])
            
    return dict_AandB
  
import collections

n = int(input())

# initialize
input_str = input()
input_list = []
count_dict = {}
   
for char in input_str:
    input_list.append(char)
    
count_dict = collections.Counter(input_list)

for i in range(1, n):
    input_str = input()
    input_list = []
    
    for char in input_str:
        input_list.append(char)
    
    count_dict = dict_set(count_dict, collections.Counter(input_list))
    
# print(count_dict)

prepare_list = []
for i, v in count_dict.items():
    for _ in range(v):
        prepare_list.append(i)

answer_list = sorted(prepare_list)
print(''.join(answer_list))

Measured memory_bytes: 3316
//テンプレ
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)

using namespace std;
constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
//

class Solve {
public:
    int N;
    vector<int> primeNum;
    inline int pNum (const int & i){
        return  count_if(primeNum.begin(),primeNum.end(),[&i](const auto& x){return x >= i ;});
    }
    Solve(int _N);
    void exe();
}; 

Solve::Solve(int _N) :
    N(_N),primeNum(_N+1,0)
{
}

void Solve::exe(){
    FOR(i,2,N){
        int isPrime = 1;
        FOR(j,2,i-1){
            if(i % j == 0) isPrime = 0;
        }

        if(isPrime) {
            int p = i;
            int tmp = N/p;
            while(tmp > 0){
                
                tmp = N/p;
                primeNum[i] += tmp;
                p *= i;
            }
        } else {
            primeNum[i] = -1; //素数でない
        }
    }
    int ans = pNum(74) + pNum(24)*(pNum(2)-1/*同じものは使えない*/) + (pNum(4)-1) * pNum(14) + (pNum(2)-2)*pNum(4) * (pNum(4)-1)/2;//4,4の時、二つ選ぶ、つまりnC2をしなくちゃいけない
    cout << ans << endl;
 
}


signed main (){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int N;
    cin >> N;
    Solve solve(N);
    solve.exe();
}

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

int main() {

	ll x; cin >> x;
	ll ans = 0;
	for (ll b = 1; b <= x; b++) {
		for (ll p = 2; p <= 10; p++) {
			ll tmp = pow(b, p);
			if (tmp <= x) ans = max(ans, tmp);
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int n;
int c[55], v[55];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d", &v[i]);
	for(int i=0;i<n;i++) scanf("%d", &c[i]);
	
	int ans=0;
	for(int i=0;i<n;i++) {
		if(v[i]>c[i]) ans+=v[i]-c[i];
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c, d;
    cin >> a >> b;
    long long g;
    c = a;
    d = b;
    while(a != 0 && b != 0)
    {
        if (a >= b)
        {
            a %= b;
        }
        else{
            b %= a;
        }
    }
    g = a+b;
    cout << c/g*d << endl;
}


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

int main() {
  int N;
  vector<int> A(200);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int cnt = 0;

  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2 != 0) {
        exist_odd = true;
      }
    }

    if (exist_odd) break;

    for (int i = 0; i < N; i++) {
      A.at(i) /= 2;
    }

    cnt++;

  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[1010][1010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>H>>W;
    cin>>A>>B;
    cout<<(H-A)*(W-B)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long ans[20000] = {};
int main() {
#define int long long
	int n;
	cin >> n;
	vector<tuple<int,int, int>> wow;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		wow.push_back(make_tuple(a+b,a,b));
	}
	for (int i = 0;i < 20000;++i) {
		ans[i] = LONG_INF;
	}
	ans[0] = 0;
	sort(wow.begin(), wow.end());
	for (int i = 0;i < wow.size();++i) {
		for (int q = i+1;q > 0;--q) {
			if (ans[q - 1] <= get<1>(wow[i])) {
				ans[q] = min(ans[q], ans[q - 1] + get<2>(wow[i]));
			}
		}
	}
	for (int i = n;i >= 0;--i) {
		if (ans[i] != LONG_INF) {
			cout << i << endl;
			return 0;
		}
	}
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    vector<int> b(n+1);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        b.at(a.at(i))++;
    }
    sort(b.rbegin(),b.rend());
    
    int res=0;
    for(int i=k;i<n;i++){
        res+=b.at(i);
    }
    cout<<res<< endl;
    
    
}


Measured memory_bytes: 1792
n = int(input())
a = [(int(x), i) for i, x in enumerate(input().split())]
a.sort(reverse=True)
aval, ai = zip(*a)
dp = [[0] * (n+1) for _ in range(n+1)]

for l in range(n):
    for r in range(n):
        if l + r >= n: break
        dp[l+1][r] = max(dp[l+1][r], dp[l][r] + aval[l+r] * abs(ai[l+r]-l))
        dp[l][r+1] = max(dp[l][r+1], dp[l][r] + aval[l+r] * abs(ai[l+r]-(n-r-1)))

print(max([dp[i][n-i] for i in range(n+1)]))


Measured memory_bytes: 106120
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m;
string s;
vector<int> sum(100100, 0);

int main() {
    cin >> n >> m >> s;
    reverse(s.begin(), s.end());
    vector<int> ans;
    for(int i = 0; i <= n; ++i) {
        if(s.at(i) == '0') {
            sum.at(i+1) += sum.at(i) + 1;
        }else sum.at(i+1) += sum.at(i);
    }

    bool flg = true;
    for(int i = 0; i <= n; ) {
        // cout << "i " << i << endl;
        // 0にいることは保証される
        // 行けるところまで行くのが最適
        int smin = i+1; int smax = i+m;
        int exist = sum.at(min(smax+1, n+1)) - sum.at(smin);
        if(exist > 0) {
            // ここで探索をする
            for(int j = m; j >= 1; --j) {
                int snext = i+j;
                if(snext >= n) {
                    ans.emplace_back(n-i);
                    flg = false;
                    break;
                }else {
                    if(s.at(snext) == '0') {
                        i = snext;
                        ans.emplace_back(j);
                        break;
                    }
                }
            }
        }else {
            flg = false;
        }
        if(!flg) break;
    }

    int anslen = ans.size();
    int goal = 0;
    for(int i = 0; i < anslen; ++i) {
        // cout << ans.at(i) << endl;
        goal += ans.at(i);
    }

    if(goal == n) {
        for(int i = anslen-1; i >= 0; --i) {
            if(i == 0) cout << ans.at(i) << endl;
            else cout << ans.at(i) << " ";
        }
    }else cout << -1 << endl;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

typedef long long ll;

const int N = 1e5 + 5, Mod = 1e9 + 7;
int n, a[N], buk[N];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    buk[a[i]]++;
  }
  if (buk[0] > 1)
    cout << 0 << endl;
  else {
    int num = 0;
    for (int i = 0; i < n; ++i) {
      if (buk[i] == 0)
	continue;
      if (buk[i] == 2)
	++num;
      else if (buk[i] > 3) {
	cout << 0 << endl;
	return 0;
      }
    }
    ll ans = 1;
    for (int i = 1; i <= num; ++i)
      ans = (ans * 2LL) % Mod;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

ll gcd(ll a, ll b)
{return b?gcd(b,a%b):a;}


int main(){
    ll a, b; cin >> a >> b;
    ll n = gcd(a,b);
      
    ll ans = 1;
    if(n % 2 == 0){
        ans++;
        while(n % 2 == 0) n /= 2;
    }
  
    for (ll i = 3; i*i <= n; i+=2) {
        if(n % i == 0){
            ans++;
            while (n%i == 0) n /= i;
        }
          if(n == 1) break;
    }
      if(n != 1) ans++;
 
    cout << ans << endl;
}




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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

// B

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  int n;
  cin >> n;
  vector<ii> vec(n);
  vector<int> a;
  rep(i,n) {
    cin >> vec[i].fst >> vec[i].snd;
    a.pb( vec[i].fst == vec[i].snd );
  }
  rep(i,n) {
    if( i+2 < n && a[i] && a[i+1] && a[i+2] ) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 3620