akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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 <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

ll d(ll n,ll m){
	string s=to_string(n);
	string t=to_string(m);
	return max((ll)s.size(),(ll)t.size());
}

int main(){
	ll N;cin>>N;
	vector<pair<ll,ll>>v;
	rep(i,N){
		ll x,l;cin>>x>>l;
		v.emplace_back(x+l,x-l);
	}
	
	ll nowF=-1*INF;
	ll ans=0;
	sort(v.begin(),v.end());
	rep(i,N){
		if(nowF<=v[i].second){
			nowF=v[i].first;
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2420
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    dict = {}
    for i in range(N):
        if A[i] not in dict:
            dict[A[i]] = 1
        else:
            dict[A[i]] += 1
    ans = 0
    for i, j  in dict.items():
        ans += (j - 1) * j // 2
    for i in range(N):
        print(ans - dict[A[i]] + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 25768
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),
			b = sc.nextInt();
		if(a <= b) {
			System.out.println(a);
		} else {
			System.out.println(a-1);
		}
	}
}

Measured memory_bytes: 21716
#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 n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(a + b - n, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
  	cin >> n;
  	string s;
  	cin >> s;
	if (n%2==1)
		cout << "No";
  	else if (s.substr(0, n/2).compare(s.substr((n+1)/2, n/2))==0)
      cout << "Yes";
  	else cout << "No";
}

Measured memory_bytes: 256
import sys
import math
from itertools import accumulate as acc

N,C=map(int,input().split())


a=[[0 for i in range(10**5+1)] for i in range(C+1)]

rec=[0 for i in range(10**5+1)]

for i in range(N):
    s,t,c=map(int,input().split())
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

    a[c][s],a[c][t]=1,1

tmp=0
ans=0
for i in range(10**5):
    tmp+=rec[i]
    ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 28360
a,b = map(int,input().split())
N = int(input())
n = 1009
reserve = [0]*n

#新しい予約
b = b-1
reserve[a] += 1
reserve[b+1] -= 1

#既存の予約
for i in range(N):
    s,f = map(int,input().split())
    f = f-1
    reserve[s] += 1
    reserve[f+1] -= 1

judge = 0
for i in range(n):
 if(i != 0): reserve[i] += reserve[i-1]
 if(reserve[i] >= 2): judge = 1

#print(reserve)
print(judge)


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, k, a, ans;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a;
	ans = (n - 1) / (k - 1) + ((n - 1) % (k - 1) != 0);
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

int main(){
  ll n, count=0;
  cin >> n;
  rep(i, 1, n+1){
    if (i < 10) count++;
    if (i >=100 && i < 1000) count++;
    if (i >=10000 && i < 100000) count++;
  }
  print(count);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;



void solve()
{
	int x;;
	cin>>x;
	
	vector<pair<int,int>>v;
	
	for(int i=0;i*i*i*i<=1e18/i;i++)
	{
		v.pb({i*i*i*i*i,i});
		v.pb({-i*i*i*i*i,-i});
	}	
	
	sort(v.begin(),v.end());
	
	int q=sz(v);
	
	for(int i=1;i<q;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(v[i].ff-v[j].ff==x)
			{
				cout<<v[i].ss<<" "<<v[j].ss<<endl;
				return ;
			}
		}
	}
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr.txt","r",stdin);
    int k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}

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

int sx, sy, tx, ty;
string f, b;
string ans;

set<pair<int, int>> vis;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> sx >> sy >> tx >> ty;
    int curx = sx, cury = sy;
    while (curx != tx || cury != ty) {
		if (cury < ty) {
			cury++;
			f += 'U';
			vis.insert({curx, cury});
		}
		
		if (curx < tx - 1 || cury == ty) {
			curx++;
			f += 'R';
			vis.insert({curx, cury});
		}
	}
	
	ans += f;
	
    while (curx != sx || cury != sy) {
		if (cury > sy && vis.find({curx, cury - 1}) == vis.end()) {
			cury--;
			b += 'D';
		}
		
		if (curx > sx && vis.find({curx - 1, cury}) == vis.end()) {
			curx--;
			b += 'L';
		}

	}
    ans += b;
    ans += "LU" + f + "RD";
    ans += "RD" + b + "LU";
    
	cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

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

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

    int colors[9];
    for(int i = 0; i < 9; ++i) {
        colors[i] = 0;
    }

    for(auto ai : a) {
        if (ai >= 3200) {
            ai = 3200;
        }
        colors[ai/400]++;
    }

    int ans_min = 0, ans_max = 0;

    for(int i = 0; i < 9; ++i) {
        if (i==8) {
            ans_max = ans_min + colors[i];
        } else {
            if (colors[i]) {
                ans_min++;
            }
        }
    }

    cout << ((ans_min == 0) ? 1 : ans_min) << " " << ans_max << endl;

    return 0;

}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class UnionFind {
public:
    vector<int> par, rank;
    int cnt;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

struct edge {
    int u;
    int v;
    int cost;
};

bool comp_edge(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int kruskal(int V, vector<edge>& es) {
    sort(es.begin(), es.end(), comp_edge);
    UnionFind uf(V);
    int ret = 0;

    for (edge e : es) {
        if (uf.same(e.u, e.v)) continue;
        uf.unite(e.u, e.v);
        ret += e.cost;
    }

    return ret;
}

signed main() {
    int N;
    cin >> N;

    int xbase[N];
    int ybase[N];

    vector<P> xs(N);
    vector<P> ys(N);

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        xs[i] = P(x, i);
        ys[i] = P(y, i);

        xbase[i] = x;
        ybase[i] = y;
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    vector<edge> es;

    for (int i = 0; i < N - 1; i++) {
        P p0 = xs[i];
        P p1 = xs[i+1];
        int cost = min(abs(p0.first - p1.first), abs(ybase[p0.second] - ybase[p1.second]));
        es.push_back({p0.second, p1.second, cost});
    }

    for (int i = 0; i < N - 1; i++) {
        P p0 = ys[i];
        P p1 = ys[i+1];
        int cost = min(abs(p0.first - p1.first), abs(ybase[p0.second] - ybase[p1.second]));
        es.push_back({p0.second, p1.second, cost});
    }

    cout << kruskal(N, es) << endl;

    return 0;
}

Measured memory_bytes: 13296
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n, m; n = in(), m = in(), n || m;) {
		vector<int> map(n--);
		for (int &x: map)
			x = in();
		for (int i = 1, c = 0; i <= m; i++) {
			c += in();
			if (c < n)
				c += map[c];
			if (c >= n) {
				outl(i++);
				for (;i <= m; i++)
					in();
			}
		}
	}
}


Measured memory_bytes: 2488
/**
ABC164A - Sheep and Wolves
*/
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
	unsigned int s, w;
	string ans;

	// input
	cin >> s >> w;

	// calc
	if (s <= w) {
		ans = "unsafe";
	}
	else {
		ans = "safe";
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll s = 0;
    rep(i, n) s ^= a[i];
    ll ans = s;
    rep(i, n)a[i] &= ~s;

    int r = 0;
    vector<int> top(n);
    for (int i = 60; i >= 0; --i) {
        int j = r;
        for (; j < n; ++j) {
            if (a[j] >> i & 1) {
                swap(a[r], a[j]);
                break;
            }
        }
        if (j == n) continue;
        top[r] = i;
        rep(k, n) {
            if (r == k) continue;
            if (a[k] >> i & 1) a[k] ^= a[r];
        }
        ++r;
    }

    ll x = 0;
    rep(i, r) x ^= a[i];
//    for (int i = 60; i >= 0; --i) {
//        ll nx = x | (1ll << i);
//        {
//            ll b = nx;
//            rep(j, r) {
//                if (b >> top[j] & 1) b ^= a[j];
//            }
//            if ((b & nx) == 0) {
//                x = nx;
//            }
//        }
//    }

    ans += x * 2;
    cout << ans << endl;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    string s, t;
    cin >> s >> t;
    vector<char> transformation(26);
    rep(i, 26) transformation[i] = 'a' + i;

    rep(i, s.size()) {
        char from = s[i];
        from = transformation[from - 'a'];
        char to = t[i];

//        transformation[from - 'a'] = to;
//        transformation[to - 'a'] = from;

        auto it_f = find(transformation.begin(), transformation.end(), from);
        auto it_t = find(transformation.begin(), transformation.end(), to);
        *it_f = to;
        *it_t = from;
    }

    rep(i, s.size()) {
        char from = s[i];
        char to = transformation[from - 'a'];
        if (t[i] == to) continue;
        cout << "No" << endl;
        ret();
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 776
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
if A * B < N:
    print(-1)
    exit()
if N < A + B - 1:
    print(-1)
    exit()

groups = [[] for _ in range(A)]
nums = deque(list(range(1, N + 1)))
for i in reversed(range(len(groups))):
    groups[i].append(nums.pop())
for i in range(len(groups)):
    nums.append(groups[i].pop())
    for _ in range(B):
        if not nums:
            break
        groups[i].append(nums.popleft())

ans = []
for g in groups:
    ans += g[::-1]
print(*ans)


Measured memory_bytes: 61316
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku
		
int main(void){
	long long n=llin(),m=llin(),ans=0;
	if(m>=2*n){
		ans=n;
		m-=2*n;
		ans+=m/4;
	}
	else ans=m/2;
	llprint(ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>

int main() {
    long A, B;
    int C, D;
    std::cin >> A >> B >> C >> D;

    long cnum = B / C;
    if (A % C == 0) {
        cnum = cnum - (A / C) + 1;
    } else {
        cnum = cnum - (A / C);
    }

    long dnum = B / D;
    if (A % D == 0) {
        dnum = dnum - (A / D) + 1;
    } else {
        dnum = dnum - (A / D);
    }

    int a = C;
    int b = D;
    if (a < b) {
        int tmp = a;
        a = D;
        b = tmp;
    }
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    long x = (long)C * D / b;
    long xnum = B / x;
    if (A % x == 0) {
        xnum = xnum - (A / x) + 1;
    } else {
        xnum = xnum - (A  / x);
    }

    std::cout << B - A + 1 - cnum - dnum + xnum << std::endl;

    return 0;
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n,q;string s;
	cin>>n>>q>>s;
	int rui[n+1]={};
	for(int i=1;i<n;i++){
		if(s[i]=='C'&&s[i-1]=='A')rui[i+1]++;
	}
	rep(i,n)rui[i+1]+=rui[i];
	rep(i,q){
		int l,r;cin>>l>>r;
		dump(rui[r]-rui[l]);
	}
}





Measured memory_bytes: 1792
#include<cstdio>
int n,m,k;
int calc(int i,int j){
  return i*(m-j)+(n-i)*j;
}
int main(){

  scanf("%d%d%d",&n,&m,&k);
  bool flag=false;
  for(int i=0;i<=n;++i){
    for(int j=0;j<=m;++j){
      if(calc(i,j)==k)flag=true;
    }
  }
  if(flag)printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)
#define MOD 1000000007
#define N 1003

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int n, m;
char a[N][N];
int f[N][N];

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    fore(i, 0, n) fore(j, 0, m) cin >> a[i][j];
    f[0][0] = 1;
    fore(i, 0, n) fore(j, 0, m) {
        if (i + 1 < n && j < m && a[i + 1][j] == '.') {
            f[i + 1][j] += f[i][j];
            f[i + 1][j] %= MOD;
        }
        if (i < n && j + 1 < m && a[i][j + 1] == '.') {
            f[i][j + 1] += f[i][j];
            f[i][j + 1] %= MOD;
        }
    }
    cout << f[n - 1][m - 1] << '\n';
    return 0;
}


Measured memory_bytes: 5120
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let rec f1 xs =
    let flag = Array.create 10 false
    let a = Array.init (Array.length xs) (fun _ -> null)
    for (i, j) in Seq.zip xs [0 .. 30000] do
        flag.[i] <- true
        a.[j] <- Array.copy flag
    a

[<EntryPoint>]
let main _ =
    let N = read int
    let S = (read string).ToCharArray() |> Array.map (string >> int)

    let r1 = f1 S
    let r2 = f1 (Array.rev S) |> Array.rev

    let ans = Array.create 1000 false
    for i in [1 .. N - 2] do
        let mid = S.[i]
        let ls = r1.[i - 1]
        let rs = r2.[i + 1]
        for l in [0 .. 9] do
            for r in [0 .. 9] do
                if ls.[l] && rs.[r] then
                    let k = l * 100 + mid * 10 + r
                    ans.[k] <- true

    Array.filter ((=) true) ans
    |> Array.length
    |> printfn "%i"

    0

Measured memory_bytes: 26436
using System;

namespace ABC124
{
    class C
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int wCount = 0;
            int bCount = 0;

            // 先頭が白のパターン
            for (int i = 0; i < S.Length; i++)
            {
                if ((i % 2) == 0)
                {
                    if (S[i] != '1') { wCount++; }
                }
                if ((i % 2) == 1)
                {
                    if (S[i] != '0') { wCount++; }
                }
            }

            for (int i = 0; i < S.Length; i++)
            {
                if ((i % 2) == 0)
                {
                    if (S[i] != '0') { bCount++; }
                }
                if ((i % 2) == 1)
                {
                    if (S[i] != '1') { bCount++; }
                }
            }
            Console.WriteLine(Math.Min(wCount, bCount));
        }
    }
}

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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	char a[3],b[3],c[3];
	cin>>a;
	cin>>b;
	cin>>c;
	cout<<a[0]<<b[1]<<c[2];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,M;
	cin >> N >> M;
	ll s[N];
    ll i;
    ll a,b;
    for(i=0;i<N;i++){
    	s[i]=N+1;
    }
    for (i=0;i<M;i++){
    	cin >> a >> b;
    	if(s[a-1]>b-1){
    		s[a-1]=b-1;
    	}
    }
    ll fin=N+1;
    ll ans =0;
    for (i=0;i<N;i++){
    	if(fin==i){
    		fin=N+1;
    		ans++;
    	}
    	if(s[i]<fin){
    		fin=s[i];
    	}
    }
    cout << ans;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned char ubyte;

const ld EPS = 1e-9;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

bool eq(double a, double b) {
	return fabs(a - b) < EPS;
}

template<class T>
T sqr(const T & x) { return x * x; }

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T>
ll myround(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

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

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
		os << *it;
		if ((it + 1) != v.end()) os << ", ";
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

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

#define all(a) (a).begin(), (a).end()

const int N = 100100;

int a[N];
int n, res, k;
vector<int> g[N];

int dfs(int v) {
	int cur = 0;
	for (int to : g[v]) {
		cur = max(cur, dfs(to) + 1);
	}
	if (cur + 1 >= k && v != 1 && a[v] != 1) {
		res++;
		return -1;
	}
	else {
		return cur;
	}
}

int main() {
	srand(time(0));
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	scanf("%d%d", &n, &k);

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

	if (a[1] != 1) {
		a[1] = 1;
		res++;
	}

	for (int i = 2; i <= n; i++) {
		g[a[i]].push_back(i);
	}

	dfs(1);

	cout << res << endl;
}

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

int main(){
  
  string s, t;
  cin >> s >> t;
  
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == t.at(i)){
      count++;
    }
  }
  
  if(count++ == s.size()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
      
  
  

Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_StudyScheduling solver = new A_StudyScheduling();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_StudyScheduling {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int h1 = in.nextInt();
            int m1 = in.nextInt();
            int h2 = in.nextInt();
            int m2 = in.nextInt();
            int k = in.nextInt();
            int l = h1 * 60 + m1;
            int r = h2 * 60 + m2 - k;
            out.println(Math.max(r - l, 0));
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 32820
N = int(input())
tm_pos = [list(map(int, input().split())) for i in range(N)]
for i in tm_pos:
    if i[0] < i[1] + i[2] or i[0] % 2 != (i[1] + i[2]) % 2:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 27300
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int x;
		for(int i=1; true; i++){
			x = sc.nextInt();
			if(x == 0) break;
			System.out.println("Case " + i + ":" + " " + x);
		}
	}
}


Measured memory_bytes: 41120
import math

def length(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

while True:
    p = list(map(int, input().split()))
    if not list(filter(lambda x: x, p)):
        break

    a, b, c = length(p[0], p[1], p[2], p[3]), length(p[0], p[1], p[4], p[5]), length(p[2], p[3], p[4], p[5])
    S = 0.5 * a * b * (1 - ((a ** 2 + b ** 2 - c ** 2) / (a * b * 2)) ** 2) ** 0.5
    R = (2 * S) / (a + b + c)

    s = (a + b + c) / 2
    d = (((- a + b + c) / 2) ** 2 + R ** 2) ** 0.5
    e = (((a - b + c) / 2) ** 2 + R ** 2) ** 0.5
    f = (((a + b - c) / 2) ** 2 + R ** 2) ** 0.5

    print(R / (2 * (s - c)) * (s + f - R - e - d), end=" ")
    print(R / (2 * (s - b)) * (s + e - R - d - f), end=" ")
    print(R / (2 * (s - a)) * (s + d - R - e - f))



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

int main() {
  int N, K;
  int xi;
  int i;
  int sum = 0;

  cin >> N >> K;

  for (i=0;i<N;i++) {
    cin >> xi;
    if (xi <= K/2) {
      sum += 2*xi;
    } else {
      sum += 2*(K-xi);
    }
  }

  cout << sum << endl;
}

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

int main(){

  typedef struct{
    double x, y, r;
  }_CirclePara;
  
  int n;
  double d;
  _CirclePara a, b;
  
  cin >> n;
  for(int i=0; i<n; i++){
		cin >> a.x >> a.y >> a.r >> b.x >> b.y >> b.r;
  	
  	d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
	  if(a.r + b.r < d) cout << 0 << endl;
	  else if(a.r - b.r > d) cout << 2 << endl;
	  else if(b.r - a.r > d) cout << -2 << endl;
	  else cout << 1 << endl;
  }

  return 0;

}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7;
const long long OO = 1e18+25;

int n, w[125], v[125],W;
long long mem[100][N];

long long dp(int idx=0, int wi=W)
{
    if(idx == n) return 0;
    long long &ret = mem[idx][wi];
    if(ret != -1) return ret;
    return ret = max(dp(idx+1, wi), (wi>=w[idx]?dp(idx+1, wi-w[idx])+v[idx]:0));
}

int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d%d",&n,&W);
    for(int i=0; i<n; i++) scanf("%d%d",w+i,v+i);
    printf("%lld",dp());
    return 0;
}
	     		 					   	 	 								 	

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(x,a) for(auto& (x) : (a) )
int main(){
  std::cout<<std::fixed<<std::setprecision(10);
  int n;
  cin >> n;
  vector<int> x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  double len = 0;
  int cou=0;
  vi num(n);
  rep(i,n)num[i]=i;
  auto get_di =[&](int i,int j){
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
  };
  do{
    rep(i,n-1){
      len+=get_di(num[i],num[i+1]);
    }
    cou++;
  }while(next_permutation(num.begin(),num.end()));
  
  double ans = len/cou;
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        List<Integer>[] lists = new List[n];

        for (int i = 0; i < n; i++) {
            lists[i] = new ArrayList<>();
        }

        for (int i = 0; i < m; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            lists[s].add(t);
        }

        double[] baseDP = new double[n];
        int[] maxCostNodes = new int[n];

        for (int i = n - 2; i >= 0; i--) {
            double max = -1;
            int maxCostNode = -1;
            List<Integer> list = lists[i];
            for (int node : list) {
                if (max < baseDP[node]) {
                    max = baseDP[node];
                    maxCostNode = node;
                }
                baseDP[i] += baseDP[node];
            }
            baseDP[i] = baseDP[i] / list.size() + 1;
            maxCostNodes[i] = maxCostNode;
        }

//        debug(baseDP);
//        debug(maxCostNodes);

        double ans = m;

        for (int i = 0; i < n; i++) {
            double[] dp = new double[n];
            final int maxCostNode = maxCostNodes[i];

            for (int j = n - 2; j >= 0; j--) {
                List<Integer> list = i == j && lists[j].size() > 1
                        ? lists[j].stream().filter(x -> x != maxCostNode).collect(Collectors.toList())
                        : lists[j];
                for (int node : list) {
                    dp[j] += dp[node];
                }
                dp[j] = dp[j] / list.size() + 1;
            }
//            debug(dp);

            ans = Math.min(dp[0], ans);
        }

        System.out.println(ans);

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 97248
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 a[MAXN],b[MAXN],pre[MAXN],ans[MAXN];
map<int,int64> zz,num;
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {read(a[i]);b[i] = a[i];ans[1] += a[i];}
    sort(b + 1,b + N + 1);
    for(int i = N ; i >= 1 ; --i) {

        if(b[i] != b[i + 1]) {
            num[b[i]] += N - i;
            zz[b[i]] += zz[b[i + 1]];
        }
        num[b[i]]++;
        zz[b[i]] += b[i];
    }
    int pos = 1;
    for(int i = 1 ; i <= N ; ++i) {
        if(a[i] > pre[i - 1] && i != 1) {
            ans[i] += zz[pre[i - 1]] - pre[i - 1] * num[pre[i - 1]];
            ans[pos] -= ans[i];
            pos = i;
        }
        pre[i] = max(pre[i - 1],a[i]);
    }
    for(int i = 1 ; i <= N ; ++i) {
        out(ans[i]);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 16640
def main():
    while True:
        h, w = map(int, input().split())
        if h == 0 and w == 0: break
        
        print('#'*w)
        for item in range(h-2):
            print('#' + '.'*(w-2) + '#')
        print('#'*w)
        print('')
        

main()

Measured memory_bytes: 7752
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    cout<<(in<char>()<='Z'?'A':'a')<<endl;
}



Measured memory_bytes: 3584
def calc(H, W, ans):
    w0 = W // 2
    w1 = W - w0
    for h0 in range(1, H):
        Sa = h0 * W
        h1 = H - h0
        h2 = h1 // 2
        h3 = h1 - h2
        Sb1, Sc1 = h1 * w0, h1 * w1
        Sb2, Sc2 = h2 * W, h3 * W
        m1, _, M1 = sorted([Sa, Sb1, Sc1])
        m2, _, M2 = sorted([Sa, Sb2, Sc2])
        ans = min(ans, M1 - m1, M2 - m2)
    return ans

H, W = map(int, input().split())
print(calc(W, H, calc(H, W, H * W)))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    if (a > b) {
       a ^= b;
       b ^= a;
       a ^= b;
    }
    if (b > c) {
       b ^= c;
       c ^= b;
       b ^= c;
    }
    if (a > b) {
       a ^= b;
       b ^= a;
       a ^= b;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int st = 26, len = 1;
    while (st < n) {
         n -= st;
         ++len;
         st *= 26;
    }
    for (int i = 1; i <= len; i++) {
        int v = 1;
        for (int j = 0; j < len - i; j++) v *= 26;
        for (char c = 'a'; c <= 'z'; c++) {
            if (v < n) {
                n -= v;
            }
            else {
                cout << c;
                break;
            }
        }
    }
    cout << '\n';
}


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

int main() {
  long long int n,m,ans,y;
  cin>>n>>m;
  ans=0;
  vector<long long int> a(n);
  vector<long double> b(n);
  vector<long double> c(n);
  for(long long int i=0;i<n;i++){
    cin>>a.at(i);
    cin>>b.at(i);
    c.at(i)=a.at(i)+0.000001*b.at(i);
  }
  sort(c.begin(),c.end());
  for(long long int i=0;i<n;i++){
    a.at(i)=c.at(i);
    b.at(i)=(c.at(i)-a.at(i))*1000000;
    y=static_cast <long long int> (b.at(i));
    if(abs(b.at(i)-y)>abs(b.at(i)-y-1)) y++;
    if(y<=m){
      ans+=a.at(i)*y;
      m-=y;
    }
    else{
      ans+=a.at(i)*m;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii; 
typedef vector<string> vs;
typedef vector<vi> vvi;
int a[111];
int n;
int ans;
int num;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0)num++;
	}
	for(int i=0;;){
		int be=-1;
		int en=-1;
		int hi=1000000;
		for(int j=0;j<n+1;j++){
			if(a[j]!=0 && be==-1)be=j;
			if(a[j]!=0 && be!=-1)hi=min(hi,a[j]);
			if(a[j]==0 && be!=-1){
				en=j;
				for(int k=be;k<en;k++){
					a[k]-=hi;
					if(a[k]==0)num++;
				}
				ans+=hi;
				break;
			}
		}
		if(num==n){
			cout<<ans<<endl;
			return 0;
		}
	}
    return 0;
}

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

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *NodePointer;

NodePointer r,NIL;

NodePointer getMinimum(NodePointer x){
  while(x->l != NIL){
    x = x->l;
  }
  return x;
}


NodePointer find(NodePointer x,int k){
  while(x != NIL && k != x->key){
    if(k < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  return x;
}

NodePointer getSuccessor(NodePointer x){
  NodePointer y;
  if(x->r != NIL){
    return getMinimum(x->r);
  }

  y = x->p;
  while(y != NIL && x ==y->r){
    x = y;
    y = y->p;
  }

  return y;
}

void delete(NodePointer z){
  NodePointer x;
  NodePointer y;

  if(z->l == NIL || z->r == NIL){
    y = z;
  }else{
    y = getSuccessor(z);
  }

  if(y->l != NIL){
    x = y->l;
  }else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    r = x;
  }else{
    if(y == y->p->l){
      y->p->l = x;
    }else{
      y->p->r = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }
}

void insert(int k){
  NodePointer y = NIL;
  NodePointer x = r;

  NodePointer z = (NodePointer)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  z->p = y;

  if(y == NIL){
    r = z;
  }else if(z->key < y->key){
    y->l = z;
  }else{
    y->r = z;
  }
}

void inorder(NodePointer u){
  if(u == NIL){
    return;
  }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(NodePointer u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print(){
  inorder(r);
  puts("");
  preorder(r);
  puts("");
}

int main(){
  int n,i,j,z,x;
  char s[10];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0] == 'f'){
      scanf("%d",&x);
      NodePointer t = find(r,x);
      if(t == NIL)printf("no\n");
      else printf("yes\n");

    }else if(s[0] == 'i'){
      scanf("%d",&z);
      insert(z);
    }else if(s[0] == 'd'){
      scanf("%d",&z);
      delete(find(r,z));
    }else{
      print();
    }
  }

  return 0;
}

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

const int N=5010;
int n,A,B;
stack<int>stk;
char ans[N];
int chk(int x,int y){
	cout<<"? "<<x<<' '<<y<<endl;
	string s;cin>>s;
	return s[0]=='Y';
}
int main(){
	cin>>A>>B;n=A+B;
	if(A<=B){
		cout<<"Impossible\n";
		return 0;
	}
	for(int i=0;i<n;++i)
		if(stk.empty()||chk(stk.top(),i))stk.push(i);
		else stk.pop();
	for(int i=0;i<n;++i)ans[i]='0'+chk(stk.top(),i);
	cout<<"! "<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,T;
  cin>>N>>T;
  VI A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  vector<PII> P(N);
  rep(i,N) P[i]=mp(A[i],B[i]);
  sort(all(P));
  rep(i,N){
    A[i]=P[i].first;
    B[i]=P[i].second;
  }
  VVI dp(N+1,VI(T+1));
  rep(i,N) rep(j,T) dp[i][j]=-1;
  dp[0][0]=0;
  int ans=0;
  VI X(N+1);
  rep(i,N) X[N-1-i]=max(X[N-i],B[N-1-i]);
  rep(i,N){
    rep(j,T){
      if(dp[i][j]!=-1){
        if(j+A[i]<=T-1) dp[i+1][j+A[i]]=max(dp[i+1][j+A[i]],dp[i][j]+B[i]);
        dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      }
    }
    int M=0;
    rep(j,T) M=max(M,dp[i+1][j]);
    ans=max(ans,M+X[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 10000000007

int main() {
	ll n;
	cin>>n;
	ll ans=0;
	ll ch[52];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			ans+=ch[i]*ch[j];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3608