akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int N,K;
vector<int> V;
bool mem[20] = {0};

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 0; i < K; i++)
    {
        int d;
        scanf("%d",&d);
        mem[d]=true;
    }
    sort(V.begin(),V.end());
    for(int i = 0; i < 10; i++)
    {
        if(mem[i] && !(i == 0))continue;
        for(int j = 0; j < 10; j++)
        {
            if(mem[j] && !(i == 0 && j == 0))continue;
            for(int k = 0; k < 10; k++)
            {
                if(mem[k] && !(i == 0 && j == 0 && k == 0))continue;
                for(int l = 0; l < 10; l++)
                {
                    if(mem[l] && !(i == 0 && j == 0 && k == 0 && l == 0))continue;
                    for(int m = 0; m < 10; m++)
                    {
                        if(mem[m])continue;
                        if(i * 10000 + j * 1000 + k * 100 + l * 10 + m >= N)
                        {
                            printf("%d\n",i * 10000 + j * 1000 + k * 100 + l * 10 + m);
                            return 0;
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys



def solve(N: int):
    from itertools import product, count, takewhile
    ans = 0
    for i in range(10):
        for s in product('357', repeat=i):
            if any(c not in s for c in '357'):
                continue
            if int(''.join(s)) <= N:
                ans += 1
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

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

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

vector<pair<ll, ll>> move_L;
vector<pair<ll, ll>> move_R;

int d[2][111][55];
char mp[111][55];

void make_move(){
	for(int i = -2;i <= 2;i++){
		for(int j = 1;j <= 3;j++){
			if(abs(i) + abs(j) <= 3)move_R.EB(i, j);
		}
	}

	for(int i = -2;i <= 2;i++){
		for(int j = -3;j <= -1;j++){
			if(abs(i) + abs(j) <= 3)move_L.EB(i, j);
		}
	}
}

void init() {
	REP(i, 2)REP(j, 111)REP(k, 55){
		d[i][j][k] = INF;
		mp[j][k] = 'X';
	}
}

void solve(int h, int w){
	init();
	vector<pair<ll, ll>> goal;
	priority_queue<P, vector<P>, greater<P>> pq;

	REP(i, h){
		REP(j, w){
			cin >> mp[i + 5][j + 5];
			if(mp[i + 5][j + 5] == 'S'){
				d[0][i + 5][j + 5] = 0;
				d[1][i + 5][j + 5] = 0;

				pq.push(MP(MP(0, 0), MP(i + 5, j + 5)));
				pq.push(MP(MP(0, 1), MP(i + 5, j + 5)));

				mp[i + 5][j + 5] = '0';
			}

			if(mp[i + 5][j + 5] == 'T'){
				goal.EB(i + 5, j + 5);

				mp[i + 5][j + 5] = '0';
			}
		}
	}

	//cout << "end inpit " << endl;

	while(!pq.empty()){
		int now_d = pq.top().FI.FI;
		int now_type = pq.top().FI.SE;
		int now_y = pq.top().SE.FI;
		int now_x = pq.top().SE.SE;

		//cout << now_d << " " << now_type << " " << now_y << " " << now_x << endl;

		pq.pop();

		if(now_d > d[now_type][now_y][now_x])continue;
		if(now_type){
			REP(i, move_L.size()){
				int nxt_y = now_y + move_L[i].FI;
				int nxt_x = now_x + move_L[i].SE;

				if(mp[nxt_y][nxt_x] == 'X')continue;

				int nxt_d = d[now_type][now_y][now_x] + (mp[nxt_y][nxt_x] - '0');
				if(d[1 - now_type][nxt_y][nxt_x] > nxt_d) {
					d[1 - now_type][nxt_y][nxt_x] = nxt_d;
					pq.push(MP(MP(nxt_d, 1 - now_type), MP(nxt_y, nxt_x)));
				}
			}
		}
		else {
			REP(i, move_R.size()){
				int nxt_y = now_y + move_R[i].FI;
				int nxt_x = now_x + move_R[i].SE;

				if(mp[nxt_y][nxt_x] == 'X')continue;

				int nxt_d = d[now_type][now_y][now_x] + (mp[nxt_y][nxt_x] - '0');
				if(d[1 - now_type][nxt_y][nxt_x] > nxt_d) {
					d[1 - now_type][nxt_y][nxt_x] = nxt_d;
					pq.push(MP(MP(nxt_d, 1 - now_type), MP(nxt_y, nxt_x)));
				}
			}
		}
	}

	//cout << "end daikusutora" << endl;

	int ans = INF;
	REP(i, goal.size()){
		ans = min(ans, d[0][goal[i].FI][goal[i].SE]);
		ans = min(ans, d[1][goal[i].FI][goal[i].SE]);
	}

	cout << (ans < INF ? ans:-1) << endl;

	return;
}

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

	make_move();
	int h, w;
	while(cin >> w >> h,h | w){
		solve(h, w);
	}

	return 0;
}



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

using namespace std;

using ll = long long;

ll MOD = 1e9+7;

class Edge{
public:
    int from,to,value;
    Edge(ll a,ll b,ll c){
        from = a;
        to = b;
        value = c;
    }
    Edge(ll a,ll b){
        from = a;
        to = b;
    }
};

   ll calc(vector<ll> v){
        sort(v.begin(), v.end());
        vector<ll> ruiseki;
        ruiseki.push_back(0);
        for(int i = 0;i < v.size();i++){
            ruiseki.push_back(ruiseki.back() + v[i]);
        }
        ll ans = 0;
        for(int i = 0;i < (int)v.size()-1;i++){
            ll sum = ruiseki.back() - ruiseki[i+1];
          //  cout<<sum<<endl;
            ans += sum - v[i] * (int(v.size())-i-1);
        }
        return ans%MOD;
    }

int main(){
    int n,m;cin >> n >> m;
    vector<ll> X;
    vector<ll> Y;
    for(int i = 0;i < n;i++){
        ll x;cin >> x;
        X.push_back(x+(1e9));
    }
    for(int j = 0;j < m;j++){
        ll y;cin >> y;
        Y.push_back(y+(1e9));
    }
 
   // cout<<calc(X)<<" "<<calc(Y)<<endl;
    cout<<(calc(X) * calc(Y))%MOD<<endl;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n; 
  cin >> n;
  vector<long long> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  for (int i = 0; i < n; i++) cin >> c.at(i);
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  long long ans = 0, p, q;
  for (int i = 0; i < n; i++) {
    long long x = b.at(i);
    p = lower_bound(a.begin(), a.end(), x) - a.begin();
    q = c.begin() + n - upper_bound(c.begin(), c.end(), x);
    ans += p*q;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2688
#include<iostream>
#include<cctype>
#include<stdio.h>
using namespace std;
int main() {
    char ch;
    
    while(1) {
        
        scanf("%c", &ch);
        
       
        if (isalpha(ch)) {
            
            if (islower(ch)) {
                
                printf("%c", toupper(ch));
                
            } else {
                
                printf("%c", tolower(ch));
                
            }
            
       /* } else if (ch == ' ') {
            
            cout << ' ';
            
        } else if (ch == ',') {
            
            cout << ',';
            
        } else if (ch == '.') {
            
            cout << '.';
            */
        } else {
            
            cout << ch;
           
        }
        
         if (ch == '\n') {
            
            //cout << endl;
            break;
            
        }
        
        
    }
    
    return 0;
    
}



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


using namespace std;
const int N = 2e5 + 10;

int n , mod , a[N];

int calcmin(int l,int r) {
	int Min = mod << 1;
	for(int _l = l , _r = r; _l <= _r; _l++ , _r--) {
//		printf("__ %d %d %d [%d\n",_l,_r,a[_l]+a[_r],Min);
		Min = min(Min , a[_l] + a[_r]);
	}
	return Min;
}
int main() {
	scanf("%d%d",&n,&mod);
	n <<= 1;

	for (int i = 1; i <= n; i++) {
		scanf("%d",a + i);
	}
	sort(a + 1 , a + 1 + n);

	int l = 0 , r = (n >> 1) - 1 , pos = n | 1;//pos - n

	while (l <= r) {
		int mid = l + r >> 1;
//		printf("[] %d %d\n",mid<<1|1,calcmin(mid<<1|1,n));
		if (calcmin(mid << 1 | 1 , n) >= mod) {
			pos = mid << 1 | 1;
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
//	printf("__ %d\n",pos);
	
	
	int res = 0;
	for (int i = 1; i <= pos - 1; i++) {
		res = max(res , a[i] + a[pos - i]);
	}

	for (int i = pos; i <= n; i++) {
//		printf("%d %d %d\n",n+pos,i,n+pos-i);
		res = max(res , (a[i] + a[n + pos - i]) % mod);
	}

	cout<<res;
	return 0;
}

/*

3 10
0 2 3 4 5 9

*/

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

int main(){
	int a[4];
	memset(a, 0, sizeof(a));
	string s;
	cin >> s;
	//cout << s.length() << endl;
	int x = 0, y = 0;
	for(int i = 0; i < s.length(); i++){
		if(s.at(i) == 'N') y++, a[0]++;	
		else if(s.at(i) == 'S') y--,a[1]++;
		else if((s.at(i) == 'E')) x++, a[2]++;
		else x--, a[3]++;
	}
	if(a[0] && a[1] && a[2] && a[3]) cout << "Yes";
	else if(a[0] && a[1] && !a[2] && !a[3]) cout << "Yes";
	else if(!a[0] && !a[1] && a[2] && a[3]) cout << "Yes";
	else cout << "No";
	return 0;
}

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

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if(A+B>=X && X >=A){
        cout <<"YES"<<"\n";
    }else {
        cout << "NO" << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[105];
int main(){
	cin >> N;
	double ave = 0.0;
	for(int i=0;i<N;i++){
		cin >> a[i];
		ave += a[i];
	}
	ave /= (double)N;
	int ans = 0;
	double diff = 100000.0;
	for(int i=0;i<N;i++){
		if(diff-eps>abs(ave-(double)a[i])){
			ans = i;
			diff = abs(ave-(double)a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int ss(int a[], int n) {
	int sw = 0;
	for (int i = 0; i < n-1; i++) {
		int minj = i;
		for (int j = i; j < n ; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
		if (i != minj) {
			sw++;
		}
	}
	return sw;
}

int main() {
	int a[100];
	int sw = 0;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sw = ss(a, n);
	for (int i = 0; i < n; i++) {
		if (i) {
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e6+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ii d[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    REP (i,n) {
        string s;
        cin >> s;
        int stk = 0;
        REP (j,SZ(s)) {
            if (s[j] == '(') stk++;
            else {
                if (stk) stk--;
                else d[i].Y++;
            }
        }
        d[i].X = stk;
    }

    vector<int> fr,bck,v;
    REP (i,n) {
        if (d[i].Y == 0) fr.eb(i);
        else if (d[i].X == 0) bck.eb(i);
        else v.eb(i);
    }
    sort(ALL(v),[&](const int a,const int b){
        return d[a].X-d[a].Y > d[b].X-d[b].Y;
    });


    int cnt = 0;
    REP (i,SZ(fr)) cnt += d[fr[i]].X;
    REP (i,SZ(v)) {
        cnt -= d[v[i]].Y;
        if (cnt < 0) return cout << "No" << endl,0;
        cnt += d[v[i]].X;
    }
    REP (i,SZ(bck)) cnt -= d[bck[i]].Y;
    if (cnt != 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int N;
    map<int, int> pos;

    cin >> N;
    rep(i, N) {
        int A; cin >> A;
        pos[A] = i;
    }

    ll ans = 0LL;
    set<int> s;
    s.insert(-1);
    s.insert(N);

    for (int i=1; i<=N; i++) {
        auto ite = s.insert(pos[i]).first;
        int l = *prev(ite);
        int r = *next(ite);

        ans += ((ll)pos[i] - l) * (r - pos[i]) * i;
    }
    cout << ans << endl;
}



Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(z) (z).begin(),(z).end() 
#define MOD 1000000007
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll isprime(ll n)
{
	for(int i=2;i<n;i++)
		if(n%i==0)
		return 0;
		
	return 1;	
}
int main()
{ 
    FAST;
	ll x;
	cin>>x;
	ll ans=0;
	while(x>=500)
	{
		ans+=1000;
		x-=500;
	}
	while(x>=5)
	{
		ans+=5;
		x-=5;
	}
	cout<<ans;
}


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

using namespace std;

#define llong long long 
#define len(v) ((int)v.size())
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++i < n; )
#define rep1(i,n) for (int i = 0; ++i <= n;)

#define maxn 333
int n, m;
int a[maxn][maxn];

int fre[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> m;
  rep(i, n) rep(f, m) cin >> a[i][f];

  int ans = maxn;
  rep(i, m) {
    ii t;
    rep(f, n)
      t = max(t, {++fre[a[f][0]], a[f][0]});
    ans = min(ans, t.xx);
    rep(f, n)
      remove(a[f], a[f] + m - i, t.yy);
    memset(fre, 0, sizeof(fre));
  }

  cout << ans;

  return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n-1];
		int sum =0;
		for(int i=0; i<n; i++) {
			 a[i] = sc.nextInt();
		}
		for(int i=0; i<n; i++) {
			 b[i] = sc.nextInt();
		}
		for(int i=0; i<n-1; i++) {
			 c[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			sum +=b[i];
		}
		for(int i=0; i<n-1; i++) {
			if((a[i]+1)==a[i+1]) {
				sum +=c[a[i]-1];
			}
		}
		System.out.println(sum);
	}

}

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

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

    long long a, b;
    cin >> a >> b;

    int ans = -1;
    if(a < 0 and b < 0){
        a = -1 * a;
        b = -1 * b;
        long long diff = a - b;
        if(diff % 2 == 0) ans = 2;
        else ans = 1;
    }else if(a <= 0 and 0 <= b){
        ans = 0;
    }else{
        ans = 1;
    }

    vector<string> Ans = {"Zero", "Positive", "Negative"};
    cout << Ans[ans] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args) {
		//Lê as entradas do teclado
		Scanner sc = new Scanner(System.in);
		
	    int n = Integer.parseInt(sc.next());
	    int w = Integer.parseInt(sc.next());
	    
	    //Inicializa os parametros 
	    long[][] matriz = new long[n+1][w+1];
	    int[] p = new int[n];
	    int[] v = new int[n];
	    
	    //Inicializa a matriz com 0
	    for(int i = 0; i <= n; i++) {
	      for(int j = 0; j <= w; j++) {
	        matriz[i][j] = 0;
	      }
	    }
	    
	    //Lê as entradas de peso e valor
	    for(int i = 0; i < n; i++) {
	      p[i] = Integer.parseInt(sc.next());
	      v[i] = Integer.parseInt(sc.next());
	    }
	    
	    //Percorre a matriz buscando o valor que caiba na mochila
	    for(int i = 0; i < n; i++) {
	      for(int j = 0; j <= w; j++) {
	        matriz[i + 1][j] = matriz[i][j];
	        if(j >= p[i]) {
	          matriz[i+1][j] = Math.max(matriz[i + 1][j], matriz[i][j - p[i]] + v[i]);
	        }
	      }
	    }
	    
	    //Imprime a soma máxima possível dos valores dos itens que Taro leva para casa.
	    System.out.println(matriz[n][w]);

	}

}


Measured memory_bytes: 126676
#include<stdio.h>
int main(void){
	int a,b,c;
	int x=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a<1||b<1||c>10000){
		printf("error\n");
		return 0;
	}else {
		for(int i=a;i<=b;i++){
			if(c%i==0) x++;
		}
		printf("%d\n",x);
		return 0;
	}
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int a = scanner.nextInt();

			int temp = n % 500;
			if (temp <= a) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 22356
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    int sumx = 0;
    for(int i=0;i<n;i++){
        if(v[i] > c[i]){
            sumx += v[i]-c[i];
        }
    }
    cout << sumx << endl;
    return 0;
}

Measured memory_bytes: 256
# Problem A - Biscuits

# input
N, P = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
even_count = 0
odd_count = 0
for a in a_nums:
    if a%2==0:
        even_count += 1
    else:
        odd_count += 1

# check
if even_count==N:
    if P==0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))


Measured memory_bytes: 2940
x, y = map(int, input().split())
ans = 0
if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000

if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

if x == 1 and y == 1:
    ans += 400000

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
const double pi=acos(-1);
int n,L,a[3005];
double ansx,ansy;
int main(){
	scanf("%d%d",&n,&L);
	For(i,1,n) scanf("%d",&a[i]);
	long long v=1ll*n*(n-1)*(n-2)/6;
	For(i,1,n) For(j,i+1,n){
		int dif=(n-j+i-1)-(j-i-1);
		ansx+=cos(pi*(a[i]+a[j])/L)*dif;
		ansy+=sin(pi*(a[i]+a[j])/L)*dif;
	}
	ansx/=v; ansy/=v;
	printf("%.15lf %.15lf\n",ansx,ansy);
}

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

int main() {
  int N,A,B,C;
  cin >> N;
  A = 0;
  C = N;
  
  for (int i = 0; i < 9; i++) {
    B = 1;
      for (int j = 8 - i; j > 0; j--) {
        B *= 10;   
      }
    
    A += C / B;
    C %= B;
  }
  
  if (N % A == 0) {
    cout << "Yes" << endl;
  }  
  
  else { cout << "No" << endl; }
  
}

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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define all(n) n.begin(),n.end()


signed main(){
	int m,d;
	cin>>m>>d;
	int ans=0;
	lp(i,m){
		int mo=i+1;
		lp(j,d){
			int x=(j+1)/10;
			int y=(j+1)%10;
			if(x>=2&&y>=2&&x*y==mo)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

d = defaultdict(int)
n = int(input())
a = list(map(int, input().split()))

for i in a:
    d[i] += 1
    d[i + 1] += 1
    d[i - 1] += 1

mx = 0
for dd in d:
    mx = max(d[dd], mx)
print(mx)


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int MOD = 1e9 + 7; 
const int N = 1e4+10; 
const int INF = 1e9 + 5; 



int d[N];
int a[N], b[N];
int main(void) 
{
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif
	
	int h, n; 
	scanf("%d %d", &h, &n); 
	for (int i=0; i<=h; i++) d[i] = INF; 
	d[0]=0; 
	for (int i=1; i<=n; i++) scanf("%d %d", &a[i], &b[i]); 
	for (int ii=1; ii<=n; ii++)
	{
		int value=a[ii], cost=b[ii]; 
		
		for (int i=0; i<=h; ++i) 
		{
			int j = min(h, i+value); 
			d[j] = min(d[j], d[i] + cost); 
		}
	}
	printf("%d\n", d[h]); 



	return false;   


}


Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i

#        a, b
CAKEs = [4, 7]
#        0, 1
ans   = []
sum   = 0

def sum_cake(b=0,a=0)
  a*4 + b*7
end

for b in 0..N/CAKEs[1]
  next if sum_cake(b) > N
  for a in 0..N/CAKEs[0]
    sum = sum_cake(b,a)
    next if sum > N
    if sum == N
      #puts "#{a},#{b}"
      #ans << "a = #{a},b = #{b}"
      puts "Yes"
      exit 0
    end
  end
end

puts "No"

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int a, b, c, d;
	scanf("%d%d%d", &a, &b, &c);
	if (a > b) {
		d = a;
		a = b;
		b = d;
	}

	if (b > c) {
		d = b;
		b = c;
		c = d;
	}

	if (a > b) {
		d = a;
		a = b;
		b = d;
	}

	printf("%d %d %d\n", a, b, c);
	return 0;

}


Measured memory_bytes: 2736
N = int(input())
S = list(input())

w = 0
e = S[1:].count('E')

leader = S[0]
min_mem=e
cnt_mem=0

for i in range(1, N):
    if leader ==  'W':
        w += 1
    leader = S[i]

    if leader == 'E':
        e -= 1

    cnt_mem = w + e
    if cnt_mem < min_mem:
        min_mem = cnt_mem

print(min_mem)

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

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

int main(void){
    int N;
    cin >> N;
    if((N % 10) == 3){
        cout << "bon";
    } else if((N % 10) == 0 || (N % 10) == 1 || (N % 10) == 6 || (N % 10) == 8 ){
        cout << "pon";
    } else {
        cout << "hon";
    }
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int a[1<<20], NMAX = 1000022;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 for(int i = 1;i <= NMAX;i++) {
   int j = i;
   while(j <= NMAX) {
     a[j]++;
     j+=i;
   }
 }

 int N;
 cin>>N;
 ll ans = 0;
 for(int c = 1;c < N;c++) {
   ans += a[N-c];
 }
 cout<<ans;




 return 0;
}


Measured memory_bytes: 7592
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int n, m;
vector<vector<int>> r;
vector<int> p;
int main()
{
    cin >> n >> m;
    r = vector<vector<int>>(m, vector<int>());
    REP(i, m) {
        int k;
        cin >> k;
        REP(j, k) {
            int ki;
            cin >> ki;
            ki--;
            r[i].push_back(ki);
        }
    }
    REP(i, m) {
        int pi;
        cin >> pi;
        p.push_back(pi);
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); ++bit) {
        bool ok = true;
        // D(bit);
        REP(i, m) {
            int cnt = 0;
            for (auto rij : r[i]) {
                if ((bit >> rij) & 1) {
                    cnt++;
                }
            }
            // DD(i, cnt);
            // D(p[i]);

            if (cnt % 2 != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N;
        List<Integer> numbers = new ArrayList<>();
        try {
            N  = Integer.parseInt(br.readLine());
            for (int i=0; i<N; i++) {
                numbers.add(i, Integer.parseInt(br.readLine()));
            }
            int max = 0;
            int index = -1;
            for (int i=0; i<N; i++) {
                if (numbers.get(i) > max) {
                    max = numbers.get(i);
                    index = numbers.indexOf(max);
                }
            }
            int second = 0;
            int index2 = -1;
            for (int i=0; i<N; i++) {
                if (i != index && numbers.get(i) > second) {
                    second = numbers.get(i);
                    index2 = numbers.indexOf(second);
                }
            }
            if (max == second) {
                for (int i=0; i<N; i++) {
                    System.out.println(max);
                }
            }
            else {
                for (int i=0; i<N; i++) {
                    if (i == index) {
                        System.out.println(second);
                    }
                    else {
                        System.out.println(max);
                    }
                }
            }
        }
        catch(Exception e) {
        }
    }
}

Measured memory_bytes: 68960
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll A[3]; cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    if(A[0] % 2 == 0 || A[1] % 2 == 0 || A[2] % 2 == 0) {
        cout << 0 << endl;
    }else {
        cout << A[0] * A[1] << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String S = in.nextLine();
    String T = in.nextLine();
    int N = S.length(), ans = 0;
    for(int i = 0; i < N; ++i){
    if(S.charAt(i) != T.charAt(i)) ++ans;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 42572
/* Swapping Two Numbers */
#include <stdio.h>

int main()
{
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0){ break; }
        if(x < y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
}


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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n + 1);
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector <int> pref(n + 2, 0), suf(n + 2, 0);
  for(int i = 1; i <= n; i++) {
    pref[i] = __gcd(pref[i - 1], a[i]);
    //cout << pref[i] << '\n';
  }
  for(int i = n; i >= 1; i--) {
    suf[i] = __gcd(suf[i + 1], a[i]);
    //cout << suf[i] << '\n';
  }
  int best = pref[n];
  for(int i = 1; i <= n; i++) {
    //cout << best << '\n';
    //cout << a[i] << ' ' << pref[i - 1] << ' ' << suf[i + 1] << '\n';
    best = max(best, __gcd(pref[i - 1], suf[i + 1]));
  }
  cout << best << '\n';
}


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

int gcm(int x,int y)
{
  if(x%y==0)
    return y;
  return gcm(y,x%y);
}

int main()
{
  int n,ans;
  ans=0;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
    {
      for(int k=1;k<=n;k++)
      {
        ans+=gcm(gcm(i,j),k);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
N,Q = [ int(it) for it in input().split() ]
S = input()

ds = 0
li = [0]*N
for i in range(1,N):
  if S[i-1]=='A' and S[i]=='C':
    ds+=1
  li[i]=ds
#print ( li ) 

for i in range(Q):
  l,r = [ int(it) for it in input().split() ]
  print ( li[r-1]-li[l-1] )

Measured memory_bytes: 52052
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 100010;
vector<int> prime;
bool is_prime[MAX_N + 1];
void sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime. push_back(i);
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
}

signed main(){
    int m, a, b;
    sieve(100000);
    while(1){
        cin >> m >> a >> b;
        if(m + a + b == 0) break;
        int MAX = -1, ap = -1, aq = -1;
        rep(i, 0, prime.size()){
            rep(j, i, prime.size()){
                int p = prime[i];
                int q = prime[j];
                if(prime[i] * prime[j] > m) break;
                if(a * q <= p * b && p * q > MAX){
                    MAX = p * q;
                    ap = p;
                    aq = q;
                }
            }
        }
        cout << ap << " " << aq << endl;
    }
}

Measured memory_bytes: 3368
#K, N = map(int, input().split())
#As = list(map(int, input().split()))
#dmax = 0
#for i in range(N-1):
#    dmax = max(dmax, As[i+1]-As[i])
#dmax = max(dmax, As[0] + K - As[N-1])
#print(K - dmax)
K, N = map(int, input().split())
A = [int(x) for x in input().split()]
l = 0
A.append(A[0] + K)
for i in range(N):
    l = max(l, A[i+1] - A[i])
print(K-l)


Measured memory_bytes: 24948
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break

Measured memory_bytes: 95576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;

LL fun(LL n, LL m)//写个自定义函数配配对
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}

int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);//输出与换行
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

int main(){
  ll N, M;
  cin >> N >> M;
  vll A(M);
  vi num = {INT_INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  vector<pair<char, int>> box(0);
  vi dp(10100, -1*INT_INF);
  vector<string> str(10100, "");
  for(int i = 0; i < M; i++){
    int A;
    cin >> A;
    box.push_back(pair<char, int>(A + '0', num.at(A)));
    dp.at(num.at(A)) = 1;
    str.at(num.at(A)) = (char)(A + '0');
  }
  for(int i = 1; i <= N; i++){ //合計の本数
    for(int j = 0; j < box.size(); j++){
      //末尾にbox.at(i).firstを付け加える
      int n = box.at(j).second; //増える本数
      if(i-n < 0) continue;
      if(dp.at(i-n)+1 > dp.at(i)){ //桁を増やせる
        dp.at(i) = dp.at(i-n) + 1;
        str.at(i) = str.at(i-n) + box.at(j).first;
      }
      else if(dp.at(i-n)+1 == dp.at(i)){
        string s1 = str.at(i);
        string s2 = str.at(i-n) + box.at(j).first;
        sort(ALL(s1), greater<char>()); sort(ALL(s2), greater<char>());
        if(s1 > s2) str.at(i) = s1;
        else str.at(i) = s2;

      }
    }
  }
  sort(ALL(str.at(N)), greater<char>());
  cout << str.at(N) << endl;
}

Measured memory_bytes: 37248
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
using namespace std;



int main() {
	int N, T;
	cin >> N >> T;
	int v[2 * N];
	for (int i = 0; i < 2*N; i++) {
		cin >> v[i];
	}


	int min_cost = 1001;

	for (int i = 0; i < N; i++) {
		if (v[2 * i + 1] <= T) {
			min_cost = min(min_cost,v[2 * i]);
		}
	}

	if (min_cost == 1001) {
		cout << "TLE" << endl;
	}
	else {
		cout << min_cost << endl;
	}


	return 0;
}

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

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

const int Maxh = 18;
const int mod = 1000000007;

int H, n;
int L;
int P[1 << Maxh];
int sum[1 << Maxh][2];
vector <ii> has[1 << Maxh];
int res;

void Add(int ind, int val)
{
    int v = L + P[ind];
    val = ll(val) * v % mod;
    while (v > 1) {
        int u = v / 2;
        val = ll(val) * u % mod;
        sum[u][v % 2] = (sum[u][v % 2] + val) % mod;
        v = u;
    }
}

void Rem(int ind, int val)
{
    int v = L + P[ind];
    val = ll(val) * v % mod;
    while (v > 1) {
        int u = v / 2;
        val = ll(val) * u % mod;
        sum[u][v % 2] = 0;
        v = u;
    }
}

void Get(int ind, int val)
{
    int v = L + P[ind];
    val = ll(val) * v % mod;
    while (v > 1) {
        int u = v / 2;
        res = (res + ll(val) * sum[u][1 - v % 2]) % mod;
        val = ll(val) * u % mod;
        v = u;
    }
}

int main()
{
    scanf("%d", &H); n = (1 << H) - 1;
    L = 1 << (H - 1);
    for (int i = 0; i < L; i++) {
        scanf("%d", &P[i]); P[i]--;
        has[L + i].push_back(ii(L + i, i));
    }
    for (int i = L - 1; i >= 1; i--) {
        int rig = 2 * i + 1, lef = 2 * i;
        has[i].resize(has[rig].size() + has[lef].size());
        int pnt = 0;
        for (int j = 0; j < has[rig].size(); j++) {
            has[i][pnt] = ii(ll(has[rig][j].first) * i % mod, has[rig][j].second);
            Add(has[i][pnt].second, has[i][pnt].first);
            pnt++;
        }
        int lim = pnt;
        for (int j = 0; j < has[lef].size(); j++) {
            Get(has[lef][j].second, has[lef][j].first);
            has[i][pnt] = ii(ll(has[lef][j].first) * i % mod, has[lef][j].second);
            pnt++;
        }
        for (int j = 0; j < lim; j++)
            Rem(has[i][j].second, has[i][j].first);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 34728
#include <stdio.h>
#define N_MAX 2000
int main(int argc, char **argv) {
	int n;
	scanf("%i", &n);
	int l[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		scanf("%i", &l[i]);
	}
	int t[N_MAX + 1];
	for(int k = 1; k < n; k *= 2) {
		int a = 1, b = 1 + k;
		while(b <= n) {
			int ao = a + k, bo = b + k <= n + 1 ? b + k : n + 1;
			for(int i = a; i < bo; ++i) {
				if(l[a] <= l[b]) {
					t[i] = l[a++];
					if(a == ao) {
						for(int j = i + 1; j < bo; ++j) {
							t[j] = l[b++];
						}
						break;
					}
				} else {
					t[i] = l[b++];
					if(b == bo) {
						for(int j = i + 1; j < bo; ++j) {
							t[j] = l[a++];
						}
						break;
					}
				}
			}
			a = b;
			b = a + k;
		}
		for(int i = 1; i < a; ++i) {
			l[i] = t[i];
		}
	}
	int ans = 0;
	for(int i = 1; i <= n - 2; ++i) {
		for(int j = i + 1; j <= n - 1; ++j) {
			int w = l[i] + l[j];
			int a = j + 1, b = n;
			while(a <= b) {
				int m = (a + b) / 2;
				if(l[m] < w) {
					a = m + 1;
				} else {
					b = m - 1;
				}
			}
			ans += b - j;
		}
	}
	printf("%i\n", ans);
	return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    double n,k; cin >> n >> k;
    long double ans = 0;
    FOR(i,1,n) {
        double cnt = 0;
        while(i*pow(2,cnt) < k) {
            cnt++;
        }
        ans += pow(0.5,cnt);
    }
    cout <<setprecision(10) <<  ans/n << endl;
}


Measured memory_bytes: 4100
#include <stdio.h>

int x( int a ) {
  return a * a;
}

int HEXtoINT( char h[ ] ) {
  int i;
  int ans = 0;

  for( i = 0; i < 2; i++ ) {
    ans *= 16;

    if( '0' <= h[ i ] && h[ i ] <= '9' )      ans += h[ i ] - '0';
    else if( h[ i ] == 'A' || h[ i ] == 'a' ) ans += 10;
    else if( h[ i ] == 'B' || h[ i ] == 'b' ) ans += 11;
    else if( h[ i ] == 'C' || h[ i ] == 'c' ) ans += 12;
    else if( h[ i ] == 'D' || h[ i ] == 'd' ) ans += 13;
    else if( h[ i ] == 'E' || h[ i ] == 'e' ) ans += 14;
    else if( h[ i ] == 'F' || h[ i ] == 'f' ) ans += 15;
  }

  return( ans );
}

int main( void ) {
  int col[ 8 ][ 3 ];
  col[ 0 ][ 0 ] = HEXtoINT( "00" ); col[ 0 ][ 1 ] = HEXtoINT( "00" ); col[ 0 ][ 2 ] = HEXtoINT( "00" );
  col[ 1 ][ 0 ] = HEXtoINT( "00" ); col[ 1 ][ 1 ] = HEXtoINT( "00" ); col[ 1 ][ 2 ] = HEXtoINT( "ff" );
  col[ 2 ][ 0 ] = HEXtoINT( "00" ); col[ 2 ][ 1 ] = HEXtoINT( "ff" ); col[ 2 ][ 2 ] = HEXtoINT( "00" );
  col[ 3 ][ 0 ] = HEXtoINT( "00" ); col[ 3 ][ 1 ] = HEXtoINT( "ff" ); col[ 3 ][ 2 ] = HEXtoINT( "ff" );
  col[ 4 ][ 0 ] = HEXtoINT( "ff" ); col[ 4 ][ 1 ] = HEXtoINT( "00" ); col[ 4 ][ 2 ] = HEXtoINT( "00" );
  col[ 5 ][ 0 ] = HEXtoINT( "ff" ); col[ 5 ][ 1 ] = HEXtoINT( "00" ); col[ 5 ][ 2 ] = HEXtoINT( "ff" );
  col[ 6 ][ 0 ] = HEXtoINT( "ff" ); col[ 6 ][ 1 ] = HEXtoINT( "ff" ); col[ 6 ][ 2 ] = HEXtoINT( "00" );
  col[ 7 ][ 0 ] = HEXtoINT( "ff" ); col[ 7 ][ 1 ] = HEXtoINT( "ff" ); col[ 7 ][ 2 ] = HEXtoINT( "ff" );

  while( 1 ) {
    int i, j;
    char ch[ 10 ];
    int cur, min, minI;

    scanf( "%s", ch );
    if( ch[ 0 ] == '0' ) break;

    cur = 0;
    for( i = 0; i < 3; i++ ) cur += x( HEXtoINT( ch + ( i*2+1 ) ) - col[ 0 ][ i ] );
    min = cur;
    minI = 0;

    for( j = 1; j < 8; j++ ) {
      cur = 0;
      for( i = 0; i < 3; i++ )
        cur += x( HEXtoINT( ch + ( i*2+1 ) ) - col[ j ][ i ] );
      if( min > cur ) {
        min = cur;
        minI = j;
      }
    }

    switch( minI ) {
      case 0 : printf( "black\n" );   break;
      case 1 : printf( "blue\n" );    break;
      case 2 : printf( "lime\n" );    break;
      case 3 : printf( "aqua\n" );    break;
      case 4 : printf( "red\n" );     break;
      case 5 : printf( "fuchsia\n" ); break;
      case 6 : printf( "yellow\n" );  break;
      case 7 : printf( "white\n" );   break;
    }
  }

  return( 0 );
}

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

int main(){
    long long x;
    cin >> x;
    long long num = 100;
    long long cnt=0;
    while(1){
        num += num/100;
        cnt++;
        if(num>=x){
            cout << cnt << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long n,m,dp[53][2503],s;
vector<pair<long long,pair<long long,long long> > >v[53];
int main(){
	scanf("%lld%lld%lld",&n,&m,&s);
	s=min(s,n*50);
	while(m--){
		long long x,y,a,b;scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
		v[x-1].push_back(make_pair(y-1,make_pair(-a,b)));
		v[y-1].push_back(make_pair(x-1,make_pair(-a,b)));
	}
	memset(dp,31,sizeof(dp));
	for(long long i=0;i<n;i++)
	{
		long long c,d;cin>>c>>d;
		v[i].push_back(make_pair(i,make_pair(c,d)));
	}
	priority_queue<pair<long long,pair<long long,long long> > >Q;
	Q.push(make_pair(0,make_pair(0,s)));
	dp[0][s]=0;
	while(Q.size()){
		long long tm=Q.top().first,ct=Q.top().second.first,cn=Q.top().second.second;Q.pop();
		for(long long i=0;i<v[ct].size();i++){
			long long nct=v[ct][i].first,ntm=tm-v[ct][i].second.second,ncoi=v[ct][i].second.first+cn;
			if(ncoi<0)continue;
			if(ncoi>n*50)continue;
			ncoi=min(ncoi,n*50);
			if(dp[nct][ncoi]>-ntm){
				dp[nct][ncoi]=-ntm; 
				Q.push(make_pair(ntm,make_pair(nct,ncoi)));
			}
		}
	}
	for(long long i=1;i<n;i++){
		long long ans=LONG_LONG_MAX;
		for(long long j=0;j<=n*50;j++)ans=min(ans,dp[i][j]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7532
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c;
    if(a==b+c||a+b==c||a+c==b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

int main(void){
  int buf, res;
  vector<int> list;
  for(int i = 0;i<3;i++){
    cin >> buf;
    list.push_back(buf);
  }
  sort(list.begin(),list.end(), greater<int>());
  // for(int a : list) cout << a << ' ';

  cout << list.at(0) * 10 + list.at(1) + list.at(2) << endl;
}

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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define Ld long double

using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main(){
    optimize();
    ll n;
    cin>>n;
    vector<ll> arr(n);
    FOR(i,0,n-1) cin>>arr[i];

    ll sum = 0;
    ll prefixSumArray[n];

    prefixSumArray[0] = 0;
    prefixSumArray[1] = arr[0];
    FOR(i,2,n-1) prefixSumArray[i] = (prefixSumArray[i-1]+arr[i-1])%mod;

    FOR(i,0,n-1)
    {
        sum += prefixSumArray[i]*arr[i];
        sum %= mod;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
char a[100],b[1001][1001];
int e,k,coo;
int main(){
    scanf("%s",a);
    while(1){ if(a[k]==0)break; k++; }
    cin>>e;
    for(int i=0;i<e;i++){
        scanf("%s",b[i]);
        for(int r=0;r<10;r++){ b[i][10+r]=b[i][r]; }
    }
    for(int i=0;i<e;i++){
            int flg=0;
        for(int g=0;g<20;g++){
            if(b[i][g]==a[0]){
                int co=0;
                for(int x=0;x<k;x++){ if(b[i][g+x]==a[x]){co++;} }
                if(co==k&&flg==0){coo++;flg++;}
            }
        }
    }
    cout<<coo<<endl;
}

Measured memory_bytes: 3244