akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
#define EPS (5e-7)
using namespace std;
int n,k;
typedef pair<pair<double,double>,double> ttt;
#define x_pos first.first
#define y_pos first.second
#define activity second
queue<ttt> q;
double x[62],y[62],c[62];
double xp,yp,ap,nx,ny,na;
double optimistic(double xx,double yy,double aa){
	//乐观估价函数
	vector<double> aux;
	for(int i=1;i<=n;i++)
		aux.push_back(c[i]*hypot(max(abs(x[i]-xx)-aa,0.000),max(abs(y[i]-yy)-aa,0.000)));
	nth_element(aux.begin(),aux.begin()+k-1,aux.end());
	return aux[k-1];
}
double realistic(double xx,double yy){
	//真实情况函数
	vector<double> aux;
	for(int i=1;i<=n;i++)
		aux.push_back(c[i]*hypot(x[i]-xx,y[i]-yy));
	nth_element(aux.begin(),aux.begin()+k-1,aux.end());
	return aux[k-1];
}
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i]>>c[i];
	q.push(make_pair(make_pair(0,0),1000));
	double res=1e9;
	cout<<fixed<<setprecision(15);
	double opti;
	while(q.size()){
		xp=q.front().x_pos;
		yp=q.front().y_pos;
		ap=q.front().activity;
		q.pop();
		//x坐标：xp
		//y坐标:yp
		//活动半径:ap
		opti=optimistic(xp,yp,ap);
		if(res-opti<=5e-7*max(1.0,opti))//乐观函数 
			continue;
		res=min(res,realistic(xp,yp));//现实情况 
		for(double mx:{-0.5,0.5}){
			for(double my:{-0.5,0.5}){
				q.push(make_pair(make_pair(xp+mx*ap,yp+my*ap),ap/2));
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
#define ll long long int
#define X first
#define Y second
const int MAXN = 1e5 + 5;
int n, dp[MAXN], arr[MAXN];


int main()
{
	int k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	dp[1] = 0;
	dp[2] = abs(arr[1] - arr[2]);
	for (int i = 3; i <= n; i++)
	{
		dp[i] = 1e9 + 100;
		for (int j = i - 1; j >= max(1, i - k); j--)
			dp[i] = min(abs(arr[i] - arr[j]) + dp[j], dp[i]);
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define MAX 100000
int A[MAX];int n;
int partition(int p,int r){
    int x=A[r];
    int i=p-1;
    rep(j,p,r){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}
int main(){
    int p;
    cin>>n;
    rep(i,0,n)cin>>A[i];
    p=partition(0,n-1);
    rep(i,0,n){
        if(i)cout<<" ";
        if(i==p)cout<<"[";
        cout<<A[i];
        if(i==p)cout<<"]";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3464
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
int cmp(const void *a, const void *b){return (*(ll*)a > *(ll*)b)?1:-1;}
int cmp1(const void *a, const void *b){return (*(ll*)b > *(ll*)a)?1:-1;}

ll n, k, a[200200], b[200200], c[200200], nb, nc;
int main(){
    scanf("%lld%lld", &n, &k);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
        if(a[i] > 0){
            b[nb++] = a[i];
        }else if(a[i] < 0){
            c[nc++] = a[i];
        }
    }
    ll nd = n - nb - nc;
    if(nb*nc < k && k <= nb*nc + (nb+nc)*nd + nd*(nd-1)/2){
        puts("0");
        return 0;
    }
    qsort(b, nb, 8, cmp); qsort(c, nc, 8, cmp);
    if(k <= nb*nc){
        ll lo = -1ll<<60, hi = 0;
        while(hi - lo > 1){
            ll mi = (hi + lo)/2;
            ll num = 0;
            for(int i=0; i<nb; i++){
                int l = -1, r = nc;
                while(r - l > 1){
                    int mid = (l + r)/2;
                    if(b[i] * c[mid] >= mi)r = mid;
                    else l = mid;
                }
                num += r;
            }
            if(num >= k) hi = mi;
            else lo = mi;
        }
        printf("%lld\n", lo);
        return 0;
    }
    qsort(c, nc, 8, cmp1);
    ll lo = -1, hi = 1ll<<60;
    while(hi - lo > 1){
        ll mi = (hi + lo)/2;
        ll num = nb*nc + (nb+nc)*nd + nd*(nd-1)/2;
        int j = nb - 1;
        for(int i=0; i<nb; i++){
            for(;b[i]*b[j] >= mi && i < j; j--);
            num += max(0,j-i);
        }
        j = nc - 1;
        for(int i=0; i<nc; i++){
            for(;c[i]*c[j] >= mi && i < j; j--);
            num += max(0,j-i);
        }
        if(num >= k)hi = mi;
        else lo = mi;
    }
    printf("%lld\n", lo);
    return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
int main()
{
    start;
    ll i,j,k,n,m,x,s;
    cin>>n>>m>>k;
    ll a[n+2]={0},b[m+2]={0};
   for(i=1;i<=n;i++)
   {
       cin>>s;
       a[i]=a[i-1]+s;
   }
   for(i=1;i<=m;i++)
   {
       cin>>s;
       b[i]=b[i-1]+s;
   }
    ll mx=0;
    for(i=0; i<=n && a[i]<=k;i++)
    {
        ll l=0,h=m,mid,ans=-1;
        while(l<=h)
        {
            mid=(l+h)/2;
            if(b[mid]<=(k-a[i]))
            {
                ans=mid;
                l=mid+1;
            }
            else h=mid-1;
        }
        mx=max(mx,i+ans);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 6752
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[150][150],ab[150][150];
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
double d[220000];
queue<int> que;
signed main(){
    cin>>s;
    rep(i,3){
        if(s[i]=='R'){
            cnt++;
        }
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans;
}

Measured memory_bytes: 10504
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
int h,w,kz,bc=0,ans=0;
string c[7];
scanf("%d %d %d",&h,&w,&kz);
for(int i=0;i<h;i++)
{
 cin >> c[i];
	for(int j=0;j<w;j++)
	{
	 if(c[i][j]=='#'){bc++;}
	}
}
for(int i=0;i<pow(2,h);i++)
{
	for(int j=0;j<pow(2,w);j++)
	{
	 int elm=0;
	 //iは行を、jは列を指す
	 int si=i,sj=j;
 	 int elmh[7]={},elmw[7]={};
	 for(int k=(h-1);k>=0;k--)
	 {
	  if(si>=pow(2,k)){elmh[k]=1; si-=pow(2,k);}
	 }
	 for(int k=(w-1);k>=0;k--)
	 {
	  if(sj>=pow(2,k)){elmw[k]=1; sj-=pow(2,k);}
	 }
	 //消す行と列を管理
	 for(int k=0;k<h;k++)
	 {
		for(int l=0;l<w;l++)
		{
		 if(elmh[k]==1||elmw[l]==1){if(c[k][l]=='#'){elm++;}}
		}
	 }
	 if((bc-elm)==kz){ans++;}
	}
}

printf("%d",ans);

}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a, b, x; cin >> a >> b >> x;
  if(b*a*a==x){
    cout << 0.0000000000 << endl;
    return 0;
  }
  double v=double(x);
  double l=double(a);
  double m=double(b);
  long double daikei=90.0-atanl(l*l*l*0.5/(l*l*m-v))*180.0/pi;
  long double issankaku=90.0-atanl(l*l*l*0.5/v)*180.0/pi;
  long double sankaku=90.0-atanl(2*v/l/m/m)*180.0/pi;
  if(daikei<=issankaku){
    cout << fixed << setprecision(15) << daikei << endl;
  }else{
    
    cout << fixed << setprecision(15) << sankaku << endl;
  }
  debug(daikei, issankaku, sankaku);
 
  


  

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ull gcd(ull a, ull b){
    if(a < b) swap(a, b);

    if(b == 0)
        return a;
    else 
        return gcd(b, a%b);
}

int solve(ull a, ull b, ull c, ull d){
    if(a < b) return -1;
    if(d < b) return -1;
    if(b <= c) return 1;

    ull g = gcd(b, d);
    ull M = b - g + (a % g);
    if(M > c)
        return -1;
    else
        return 1;
}

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

    REP(t,T){
        ull A, B, C, D;
        cin >> A >> B >> C >> D;
        int valid = solve(A, B, C, D);
        if(valid == 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;

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


    string s1,s2;
    cin >>s1 >>s2;

    s1.pb(s2.back());
    if(s1==s2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
 
using namespace std;
 
#define ll long long
const int N = (ll)(2e5) + 100;
 
int div_cel(int n, int k) {
    return (n + k - 1) / k;
}

void solve() {
    int n,k;cin >> n >> k;
    for (int x, i = 1;i <= n;i ++) cin >> x;
    cout << div_cel(n - 1,k - 1);
}
 
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define A	cout << 'A' << endl
#define B	cout << 'B' << endl
#define C	cout << 'C' << endl

using namespace std;

struct str
{
	int pm;
	int pe;
	int pj;
};

int main()
{
	while(true)
	{
		int n;
		str info[10001];

		cin >> n;

		if(n == 0)
		{
			return false;
		}

		for(int i = 0; i < n; i++)
		{
			cin >> info[i].pm >> info[i].pe >> info[i].pj;
		}

		for(int i = 0; i < n; i++)
		{
			if(info[i].pe == 100 || info[i].pm == 100 || info[i].pj == 100)
			{
				A;
			}

			else if((info[i].pm + info[i].pe) / 2 >= 90)
			{
				A;
			}

			else if((info[i].pe + info[i].pj + info[i].pm) / 3 >= 80)
			{
				A;
			}

			else if((info[i].pe + info[i].pj + info[i].pm) / 3 >= 70)
			{
				B;
			}

			else if((info[i].pe + info[i].pj + info[i].pm) / 3 >= 50 && info[i].pm >= 80 || info[i].pe >= 80)
			{
				B;
			}

			else
			{
				C;
			}
		}
	}
}

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

using ll = long long int;

const int MAX_N = (int)(1e3 + 5);

int n;

int a, b, c;

int l[MAX_N];

int base[MAX_N];

int ans = 11451419;

void rec(int cnt, map<int, int> mp) {
  if (cnt == n) {
    map<int, int> calc;

    calc[1] = 0;
    calc[2] = 0;
    calc[3] = 0;

    map<int, int> times;

    times[1] = -1;
    times[2] = -1;
    times[3] = -1;

    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
      if (itr->second == 0) continue;
      calc[itr->second] += l[itr->first];
      times[itr->second] += 1;
    }

    vector<int> tmpvec;

    for (auto itr = calc.begin(); itr != calc.end(); ++itr) {
      if (itr->second == 0) return;
      tmpvec.push_back(itr->second);
    }

    sort(tmpvec.begin(), tmpvec.end());

    int tmpmagic = (times[1] + times[2] + times[3]) * 10;

    for (int i = 0; i < 3; ++i) {
      tmpmagic += abs(tmpvec[i] - base[i]);
    }

    ans = min(ans, tmpmagic);

  }
  else {
    for (int i = 0; i < 4; ++i) {
      mp[cnt] = i;
      rec(cnt + 1, mp);
    }
  }
}

int main(void) {
  // Here your code !

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

  base[0] = c;
  base[1] = b;
  base[2] = a;

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(l[i]));
  }

  map<int, int> mp;

  rec(0, mp);

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

  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ll n;
    cin >> n;
    ll m = sqrt(2*n);
    if(m*(m+1) != 2 * n) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << '\n' << m+1 << endl;
        vector<stack<int> > x(m+1);
        queue<int> q;
        rep(i, n) {
            q.push(i+1);
        }
        rep(i, m+1) {
            cout << m << ' ';
            int k = 1;
            rep(j, m) {
                if(!x[i].empty()) {
                    cout << x[i].top();
                    x[i].pop();
                } else {
                    int now = q.front();
                    q.pop();
                    cout << now;
                    x[i+k].push(now);
                    k++;
                }
                if(j != m-1) {
                    cout << ' ';
                } else {
                    cout << '\n';
                }
            }
        }
    }
}




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

int main(){
        std::string s;
        std::cin >> s;

        int l = s.size();
        long long ans = 0;
        for(int i=0; i<pow(2,(l-1)); i++){
                long long summa = 0, kou = s[0] - '0';
                for(int j=0; j<l-1; j++){
                        if((i>>j)&1){
                                summa += kou;
                                kou = (s[j+1]-'0');
                        }else{
                                kou *= 10;
                                kou += s[j+1]-'0';
                        }
                }
                summa += kou;
                //printf("%lld\n", summa);
                ans += summa;
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> s(n);
  s[0]=a[0];
  rep(i,n-1){
    s[i+1]=s[i]+a[i+1];
    s[i+1]%=mod;
  }
  ll ans=0;
  rep(i,n){
    ans+=a[i]*(s[n-1]-s[i]+mod)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-9;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}
// 射影　直線に点pを投影　点pから直線に下ろした垂線の足
Point projection(Line l, Point p){
    Point a = l.first, b = l.second, c = p;
    double t = dot(p - a, b - a) / norm(b - a); 
    return a + t * (b - a);
}

int main(){
    double x, y;
    Point p1, p2;
    cin >> x >> y;
    p1 = {x, y};
    cin >> x >> y;
    p2 = {x, y};
    Line l = {p1, p2};
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> x >> y;
        Point c = {x, y};
        Point res = projection(l, c);
        res = c + 2.0 * (res - c);
        printf("%.10f %.10f\n", res.real(), res.imag());
    }
}


Measured memory_bytes: 3344
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
cnt = [0] * (200000)
for i in range(n):
    cnt[a[i] - 1] += 1
cnt.sort(reverse=True)
kinds = 200000 - cnt.count(0)
if kinds <= k:
    print(0)
else:
    for i in range(kinds - k):
        ans += cnt[kinds - 1 - i]
    print(ans)

Measured memory_bytes: 25644
#include<bits/stdc++.h>
using namespace std;
const long long sad=1e9+7;
int main()
{
    int n;
    cin>>n;
    long long cnt=1;
    for(int i=2;i<=n;i++)
    {
        cnt*=i;
        cnt%=sad;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  ll n, k;
  cin >> n >> k;
  multiset<pair<ll, ll>> st;
  ll cnt = 0;
  rep(i, n){
    ll a, b;
    cin >> a >> b;
    st.insert({a, b});
  }
  ll c = 0;
  for(auto p : st){
    c += p.second;
    if(c >= k){
      cout << p.first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 9832
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b;
  scanf("%lld %lld",&a,&b);
  if(a>=b)
  {
  	long long c=a%b;
    long long d=b-(a%b);
  	printf("%lld",min(c,d));
  }
  else if(a==b)printf("0\n");
  else if(a<=b)printf("%lld\n",min(a,b-a));
  return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n+2,0);
    rep(i,m){
        int l, r;
        cin >> l >> r;
        a[l]++; a[r+1]--;
    }
    rep(i,n+1) a[i+1] += a[i];
    int ans = 0;
    rep(i,n+1) if(a[i] == m) ans++;
    cout << ans << endl;    
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  int ben = 0;
  for (int i = 0; i < N; i++) {
    string o = blue.at(i);
    int ben_at_o = 0;
    for (int j = 0; j < N; j++) {
      if (blue.at(j) == o) {
        ben_at_o++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (red.at(j) == o) {
        ben_at_o--;
      }
    }
  ben = max(ben, ben_at_o);
  }
  cout << ben << endl;
}


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

using namespace std;

const int INF = 1e9;



int main() {
  ios::sync_with_stdio(false);
  int a,b,k;
  cin >> a >> b >> k;
  int j = 0;
  for (int i=100; i>0; i--) {
    if (a % i == 0 && b % i == 0) {
      j += 1;
      if (j == k) {
        cout << i << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin >> N;
    double x[N];
    std::string u[N];
    double sum=0;
    for(int i=0; i<N;i++){
        cin>>x[i];
        cin>>u[i];
        if(u[i]=="JPY"){sum=sum+x[i];}
        else {sum=sum+x[i]*380000;}
        }
        cout << sum << endl;
    
    
    
    

       return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t n, k;
  scanf("%zu %zu", &n, &k);

  std::vector<bool> v(n, true);

  for (size_t i = 0; i < k; ++i) {
    size_t d;
    scanf("%zu", &d);
    for (size_t j = 0; j < d; ++j) {
      size_t a;
      scanf("%zu", &a);
      --a;
      v[a] = false;
    }
  }

  int res = 0;
  for (size_t i = 0; i < n; ++i)
    if (v[i]) ++res;

  printf("%d\n", res);
}


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

    int A[N], B[N], C[N], ans = 0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    for(int i=0; i<N; i++) {
        cin >> B[i];
        ans += B[i];
    }
    for(int i=0; i<N-1; i++) {
        cin >> C[i];
    }

    for(int i=0; i<N-1; i++) {
        if(A[i] + 1 == A[i+1]) {
            ans += C[A[i]-1];
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	string s;
	cin >> s;
	sort(ALL(s));
	if (s == "abc")cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(ll i = 0; i < n; i++)
typedef long long ll;
const ll MOD=1e9+7;

int main() {
    ll n,m;
    std::cin >> n >> m;
    std::vector<int> h(n);
    rep(i,n){
        std::cin >> h[i];
    }
    std::vector<int> mx(n, 0);
    rep(i,m){
        ll a,b;
        std::cin >> a >> b;
        a--;
        b--;
        mx[a]=std::max(mx[a], h[b]);
        mx[b]=std::max(mx[b], h[a]);
    }
    int res=0;
    rep(i,n){
        if(h[i]>mx[i]){
            res++;
        }
    }
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 4068
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  long long x,y;
  cin >> x >> y;
  int i = 1;
  long long num = 1; 
  while(true) {
    if(num > y/x) {
      break;
    }
    num *= 2;
    i++; 
  }
  cout << i-1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int ans = 700;
        for(Character c:s)if(c=='o')ans+=100;
        System.out.println(ans);
    }
}


Measured memory_bytes: 24148
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int N,x,ans = 0;
  cin >> N >> x;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i] ;
  }
  sort(a,a+N);
  // for(int i = 0; i < N; i++){
  //   cout << a[i] << " , ";
  // }
  for(int i = 0; i < N; i++){
    if(i == N-1 && x-a[i] == 0) ans++;
    else if(i != N-1 && x-a[i] >= 0) {
      ans ++;
      x -= a[i];
    }
    else break;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 0ll * INF * INF;

const int MOD = 1e9 + 7;

int N, Nr[3];
map<vector<int>, ll> Cnt[2];
vector<int> valid(vector<int> &vc) {
	int n = SZ(vc);
	if(n > 0 && vc[0] == 99) return vector<int>(1, 99);
	vector<int> res;
	for(int i=0; i<n; i++) {
		int k=0, v=0; bool isCan = true;
		for(int j=i; j<n; j++) {
			v += vc[j];
			if(v == Nr[k]) {
				k++; v=0;
				if(k == 3) break;
			}else if(v > Nr[k]) {isCan = false; break;}
		}
		if(k == 3) return vector<int>(1, 99);
		if(!isCan) continue;
		for(int j=i; j<n; j++) res.push_back(vc[j]);
		break;
	}
	return res;
}
int main() {
	cin >> N; for(int k=0; k<3; k++) scanf("%d", &Nr[k]);
	Cnt[0][vector<int>(0)] = 1;
	for(int t=0; t<N; t++) {
		Cnt[1-t%2].clear();
		for(auto &val : Cnt[t%2]) {
			vector<int> now = val.one; 
			ll cnt = val.two % MOD;
			vector<int> temp = now; temp.push_back(-1);
			for(int k=1; k<=10; k++) {
				temp.back() = k;
				vector<int> next = valid(temp);
				Cnt[1-t%2][next] += cnt;
			}
		}
	}
	printf("%lld\n", Cnt[N%2][vector<int>(1, 99)] % MOD);
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P; //Point
typedef pair<P,P> L; //Line, Segment

const double EPS = 1e-9;
const double PI = 6.0 * asin(0.5);

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool isIntersect(L s1, L s2){
  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

vector<P> convex_hull(vector<P> v){
  vector<P> c; 
  sort(v.begin(),v.end());
  c.assign(v.begin(),v.begin()+2);
    
  for(int i=2;i<v.size();i++){
    P a = c[c.size()-1] - c[c.size()-2];
    P b = v[i] - c[c.size()-2];
        
    while(cross(a,b) > EPS){
      c.pop_back();
      if(c.size() < 2) break;
      a = c[c.size()-1] - c[c.size()-2];
      b = v[i] - c[c.size()-2];
    }
    c.push_back(v[i]);
  }
	
  int n = c.size();
  c.push_back(v[v.size()-2]);
	
  for(int i=v.size()-3;i>=0;i--){
    P a = c[c.size()-1] - c[c.size()-2];
    P b = v[i] - c[c.size()-2];
        
    while(cross(a,b) > EPS){
      c.pop_back();
      if(c.size() < n + 1) break;
      a = c[c.size()-1] - c[c.size()-2];
      b = v[i] - c[c.size()-2];
    }
    c.push_back(v[i]);
  }
  c.pop_back();
  return c;
}


vector<P> p1,p2;
int n,m;
int solve(){
  if(n+m<3) return 1;
  if(m==1&&n==2) return ccw(p1[0],p1[1],p2[0])!=0;
  if(n==2&&m==2) return !isIntersect(L(p1[0],p1[2]),L(p2[0],p2[1]));

  if(n<3) return 0;
  vector<P> t=convex_hull(p1);
  for(int i=0;i<=(int)t.size();i++){
    int flg=1;
    for(int j=0;j<m&&flg;j++)
      if(ccw(t[i],t[(i+1)%t.size()],p2[j])!=1)flg=0;
    if(flg) return 1;
    
  }
  return 0;  
}


int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)return 0;
    p1.resize(n),p2.resize(m);
    for(int i=0,a,b;i<n;i++)cin>>a>>b,p1[i]=P(a,b);
    for(int i=0,a,b;i<m;i++)cin>>a>>b,p2[i]=P(a,b);
    int ans=solve();
    swap(p1,p2);
    swap(n,m);
    ans|=solve();
    cout<<(ans?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3036
N = int(input())
for h in range(1, 3500 + 1):
    for n in range(h, 3500 + 1):
        if (4 * h * n - N * n - N * h) <= 0:
            continue
        if N * h * n % (4 * h * n - N * n - N * h) == 0:
            w = N * h * n // (4 * h * n - N * n - N * h)
            print("{} {} {}".format(h, n, w))
            exit()


Measured memory_bytes: 3064
/*
  -> RyU
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global
int n;
int dp[100005][3] = { 0 };
int recurse(vector<int> h[], int i, int idx)
{
    if (i == n)
        return h[i][idx];
    if (dp[i][idx])
        return dp[i][idx];
    vector<int> res;
    for (int j = 0; j < 3; j++) {
        if (idx != j) {
            res.eb(recurse(h, i + 1, j));
        }
    }
    return dp[i][idx] = (max(res[0], res[1]) + h[i][idx]);
}

void solve()
{
    cin >> n;
    vector<int> h[n + 1];
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        h[i].eb(a);
        h[i].eb(b);
        h[i].eb(c);
    }
    int res = 0;
    for (int i = 0; i < 3; i++) {
        res = max(res, recurse(h, 1, i));
    }
    cout << res << '\n';
}

signed main()
{
    Hiraishin
    // tests
    solve();
    return 0;
}

Measured memory_bytes: 23904
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	int n;
	cin>>n;
	map<string,int> m;
	REP(i,n){
		string s;
		cin>>s;
		m[s]++;
	}
	int ma=0;
	for(auto t:m){
		ma=max(ma,t.second);
	}
	for(auto t:m){
		if(t.second==ma){
			OUT(t.first);
		}
	}
	return 0;
}

Measured memory_bytes: 25216
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

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


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) cin >> c[i];

  int ans = 0;
  int count = 0;
  for(int i = 0; i < (1 << h); i++) {
    for(int j = 0; j < (1 << w); j++) {
      count = 0;
      rep(m, h) {
        rep(n, w) {
          if(i & (1 << m) || j & (1 << n)) continue;
          if(c[m][n] == '#') count++;
        }
      }
      if(count == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef long long int LL;
const LL INF = 9e18;

int w, h, n;

VP homes;
VI homes_x, homes_y;
int candidate_x[2], candidate_y[2];

PII ans_loc;
LL ans_dist = INF;

int main()
{
  scanf("%d%d%d", &w, &h, &n);
  for(int i = 0; i < n; i++){
    int x, y;
    scanf("%d%d", &x, &y);
    homes.push_back(make_pair(x, y));
    homes_x.push_back(x);
    homes_y.push_back(y);
  }

  sort(homes_x.begin(), homes_x.end());
  sort(homes_y.begin(), homes_y.end());

  candidate_x[0] = homes_x[(homes_x.size() - 1) / 2];
  candidate_x[1] = homes_x[homes_x.size() / 2];
  candidate_y[0] = homes_y[(homes_y.size() - 1) / 2];
  candidate_y[1] = homes_y[homes_y.size() / 2];

  for(int i = 0; i < 4; i++){
    LL mx = 0, sum = 0;
    for(int j = 0; j < homes.size(); j++){
      LL dist = abs(homes[j].first - candidate_x[(i & 2) / 2]) + abs(homes[j].second - candidate_y[i & 1]);
      sum += dist * 2;
      mx = max(mx, dist);
    }
    sum -= mx;

    if(sum < ans_dist){
      ans_dist = sum;
      ans_loc = make_pair(candidate_x[(i & 2) / 2], candidate_y[i & 1]);
    }
  }

  printf("%lld\n%d %d\n", ans_dist, ans_loc.first, ans_loc.second);
  return 0;
}

Measured memory_bytes: 2960
def gcd(m,n):  
    while m % n > 0:
        m, n = n, m % n
    else:
        return n
        
def gen_lcm_list(a):
    '''return a shorter list'''
    b = []
    for i in range(len(a)-1):
        b.append(a[i]*a[i+1]/gcd(a[i],a[i+1]))
    return b

n = int(raw_input())
a = map(int,raw_input().split())
while len(a) > 1:
    a = gen_lcm_list(a)
print a[0]

Measured memory_bytes: 4224
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = 0;
    String op = null;
    int b = 0;
    while (true) {
      a = sc.nextInt();
      op = sc.next();
      b = sc.nextInt();
      if (op.equals("?")) break;
      switch (op) {
        case "+" :
          System.out.println(a + b); break;
        case "-" :
          System.out.println(a - b); break;
        case "*" :
          System.out.println(a * b); break;
        case "/" :
          System.out.println(a / b); break;
      }
    }
  }
}


Measured memory_bytes: 26188
fun main(args: Array<String>) {
    val s = readLine()!!
    val n1 = s.mapIndexed { index, c ->
        if (index % 2 == 0 && c == '1') 1
        else if (index % 2 == 1 && c == '0') 1
        else 0
    }.sum()
    val n2 = s.mapIndexed { index, c ->
        if (index % 2 == 1 && c == '1') 1
        else if (index % 2 == 0 && c == '0') 1
        else 0
    }.sum()
    println(Math.min(n1, n2))
}


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

int main(){
    int n, Q;
    string s;
    cin >> n >> s >> Q;

    vector<set<int>> alphabet(26);
    for(int i=0; i<n; i++){
        alphabet[s[i]-'a'].insert(i+1);
    }

    for(int q=0; q<Q; q++){
        int type;
        cin >> type;

        if(type == 1){
            int i; char c;
            cin >> i >> c;

            for(int j=0; j<26; j++){
                if(alphabet[j].find(i) != alphabet[j].end()) alphabet[j].erase(i);
                if(c - 'a' == j)                             alphabet[j].insert(i);
            }
        }

        if(type == 2){
            int l, r;
            cin >> l >> r;

            int ans = 0;
            for(int j=0; j<26; j++){
                //cout << j<< " ";
                if(alphabet[j].empty() == false
                && alphabet[j].lower_bound(l) != alphabet[j].end()
                && *alphabet[j].lower_bound(l) <= r){
                    //cout << *alphabet[j].lower_bound(l) << " ";
                    ans += 1;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i,n+1) {
    if(i % 5 && i % 3) ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int r = sc.nextInt();
    int s = sc.nextInt();
    int p = sc.nextInt();
    String T = sc.next();

    char[] t = T.toCharArray();
    int sum = 0;

    for (int i = k; i < n; i++) {
      if (t[i-k] == t[i]) {
        t[i] = '/';
      }
    }

    for (int i = 0; i < n; i++) {
      if (t[i] == 'r') {
        sum += p;
      } else if (t[i] == 's') {
        sum += r;
      } else if (t[i] == 'p') {
        sum += s;
      }
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 26288
#include <iostream>
#include <cmath>


using namespace std;


int main()
{
	int n;
	int *x, *y;
	double sum;
	double tmp, max;

	// データ入力
	cin >> n;
	x = new int[n];
	y = new int[n];
	for(int i = 0; i < n; i++)
		cin >> x[i];
	for(int i = 0; i < n; i++)
		cin >> y[i];

	cout << fixed;
	// p = 1:マンハッタン距離
	sum = 0;
	for(int i = 0; i < n; i++)
		sum += fabs(x[i] - y[i]);
	cout << sum << endl;

	// p = 2:ユークリッド距離
	sum = 0;
	for(int i = 0; i < n; i++)
		sum += pow(x[i] - y[i], 2);
	cout << sqrt(sum) << endl;

	// p = 3
	sum = 0;
	for(int i = 0; i < n; i++)
		sum += pow(fabs(x[i] - y[i]), 3);
	cout << cbrt(sum) << endl;

	// p = ∞:チェビシェフ距離
	sum = max = 0;
	for(int i = 0; i < n; i++){
		tmp = fabs(x[i] - y[i]);
		if(max < tmp)
			max = tmp;
	}
	cout << max << endl;

	delete []x;
	delete []y;

	return 0;
}


Measured memory_bytes: 3468
def search(y,x,oy,ox,r):
    if y == h-1 and x == w-1:
        return r
    l = []
    for i,j in t:
        ny,nx = y+i,x+j
        if (0 <= ny < h and 0 <= nx < w) and not (ny == oy and nx == ox):
            if a[ny][nx] == "#":
                l.append((ny,nx))

    if 1 < len(l) or len(l) == 0:
        return r
    else:
        r.add((l[0][0],l[0][1]))
        return search(l[0][0],l[0][1],y,x,r)

h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
t = ((0,1),(1,0))

s = search(0,0,0,0,set([(0,0),(h-1,w-1)]))
f = True
for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and not (i,j) in s:
            print("Impossible")
            exit(0)
print("Possible")

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

ll saitankeiro(ll i,ll j,ll x, ll y){
  ll minimum = min(j-i,min(abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)));
  return minimum;
}


int main(){
  ll n,x,y;
  ll ans;
  cin >> n >> x >> y;
  map<ll, ll> mp;
  for(ll i=1; i<n; i++){
    mp[i]=0;
  }
  for(ll i=1; i<n; i++){
    for(ll j=i+1; j<=n; j++){
      ans = saitankeiro(i,j,x,y);
      mp[ans]++;
    }
  }
  rep(k,n){
    cout << mp.at(k) << endl;
  }
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type *) calloc ((size), sizeof (type)))

typedef struct union_find_depth {
  i32 *parent;
  i32 *depth;
  i32 size;
} union_find;

union_find* new_union_find (const i32 n) {
  union_find *u = ALLOC (1, union_find);
  u->parent = ALLOC (n, i32);
  u->depth = ALLOC (n, i32);
  u->size = n;
  for (i32 i = 0; i < n; ++i) {
    u->parent[i] = -1;
  }
  return u;
}

i32 root (union_find *u, i32 x) {
  if (u->parent[x] < 0) {
    return x;
  }
  i32 p = u->parent[x];
  i32 r = root (u, p);
  u->depth[x] += u->depth[p];
  u->parent[x] = r;
  return r;
}

i32 depth (union_find *u, i32 x) {
  root (u, x);
  return u->depth[x];
}

int unite (union_find *u, i32 x, i32 y, i32 w) {
  w += depth (u, x);
  w -= depth (u, y);
  x = root (u, x);
  y = root (u, y);
  if (x == y) {
    return w == 0;
  }
  if (u->parent[x] > u->parent[y]) {
    i32 swap = x;
    x = y;
    y = swap;
    w = -w;
  }
  u->depth[y] = w;
  u->parent[x] += u->parent[y];
  u->parent[y] = x;
  return 1;
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  union_find *u = new_union_find (n + 1);
  while (m--) {
    i32 l, r, d;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &l, &r, &d);
    if (!unite (u, l, r, d)) {
      puts ("No");
      return;
    }
  }
  puts ("Yes");
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
    #![allow(dead_code)]
    use std::io::prelude::*;
    use std::cmp::{max, min};
    use std::collections::{BinaryHeap, VecDeque};

    const MOD: i64 = 1e9 as i64 + 7; 

    fn main(){
        let n: usize = read();
        let k: usize = read();
        let p: Vec<usize> = (0..n).map(|_| read()).collect();
        let mut q1 = VecDeque::new();
        let mut q2 = VecDeque::new();
        let mut ans = 1;
        let mut cnt = 0;
        for i in 0..k{
            while !q1.is_empty() && *q1.back().unwrap() > p[i]{
                q1.pop_back();
            }
            while !q2.is_empty() && *q2.back().unwrap() < p[i]{
                q2.pop_back();
            }
            q1.push_back(p[i]);
            q2.push_back(p[i]);
        }
        if q1.len() == k{
            cnt += 1;        
        }
        
        for i in k..n{
            while !q1.is_empty() && *q1.back().unwrap() > p[i]{
                q1.pop_back();
            }
            while !q2.is_empty() && *q2.back().unwrap() < p[i]{
                q2.pop_back();
            }
            q1.push_back(p[i]);
            q2.push_back(p[i]);
            let &mi = q1.front().unwrap();
            let &ma = q2.front().unwrap();
            let mut f = false;
            if mi != p[i - k] || ma != p[i]{
                ans += 1;
                f = true;
            }
            if mi == p[i - k]{
                q1.pop_front();
            }else if ma == p[i - k]{
                q2.pop_front();
            }
            if f && q1.len() == k{
                cnt += 1;
            }
        }
        if cnt > 0{
            ans -= cnt - 1;
        }
        println!("{}", ans);
    }

    fn read<T>() -> T
    where
        T: std::str::FromStr,
    {
        let stdin = std::io::stdin();
        let token: String = stdin
            .lock()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().unwrap()
    }


Measured memory_bytes: 8444
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int A, B;
    std::cin >> A >> B;

    if (A <= 8 && B <= 8) {
        std::cout << "Yay!" << std::endl;
    } else {
        std::cout << ":("   << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;


int n=10000000;
int  p[10000001];
void  seive(){
    for (int i=1;i <= n; i++){
        for (int j=i;j<=n;j+= i)
                p[j]++;
    }
}


inline void solve(){
    int n,ans=1; cin>>n; 
    for (int i=2;i<=n;i++){
        ans += p[i]*i;
    }
    cout << ans << endl;
}

signed main()
{
    seive();
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 81748
<?php
$n = intval(fgets(STDIN));
$min = 10**18;
$c = 0;
for($i = 0; $i < $n; $i++){
  $A[] = 10**10-intval(fgets(STDIN));
}
echo lis($A);

function lis($A){
    $dp = array_fill(0, count($A)+1, PHP_INT_MAX);
    $dp[0] = 0;
    $longest = 0;
    foreach($A as $a){
        $b = lower_bound($dp, $a+1);
        $dp[$b] = $a;
        $longest = max($longest, $b);
    }
    return $longest;
}
function lower_bound($array, $key){
  $min = -1;
  $max = count($array);
  while($max - $min > 1){
    $c = intdiv($min + $max, 2);
    if($array[$c] >= $key){
      $max = $c;
    }else{
      $min = $c;
    }
  }
  return $max;
}

Measured memory_bytes: 13044
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,j,ans,x
    character(1000):: s,t

    read*, s,t

    ans = 100000000

    do i=1,len_trim(s)-len_trim(t)+1
        x=0
        do j=1,len_trim(t)
            if (s(j+i-1:j+i-1) /= t(j:j)) x=x+1
        end do
        ans = min(x,ans)
    end do
    print'(i0)', ans
end program main

Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
int a[maxn];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	int ans=0x7fffffff;
	for(int i=1;i+k-1<=n;i++){
		if(a[i]<0 && a[i+k-1]>=0){
			ans=min(ans,min(a[i+k-1]*2-a[i],a[i+k-1]-2*a[i]));
		}else{
			ans=min(ans,max(abs(a[i]),abs(a[i+k-1])));
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

void fnInput(int& rnAmtMoney)
{
  cin >> rnAmtMoney;
}

int fnAmtCheck(int nAmtMoney)
{
  const int cnnCake = 4;
  const int cnnDonut = 7;

  int nAmtCake = 0;
  while (true)
  {
    int nAmtMonCake = cnnCake * nAmtCake;
    if (nAmtMonCake > nAmtMoney)  return 0;

    int nRestMon = nAmtMoney - nAmtMonCake;
    if (nRestMon % cnnDonut == 0) return 1;
    nAmtCake++;
  }
}

int main()
{
  int nAmtMoney;

  fnInput(nAmtMoney);
  if (fnAmtCheck(nAmtMoney)) cout << "Yes" << endl;
  else                       cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
    cout << a[n-1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256