akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  ll N;
  cin >> N;
  vector<mint> A(N);
  for(int i=0; i<N; i++) cin >> A[i];

  
  vector<mint> wa(N+1);
  wa[0] = 0;
  for(int i=0; i<N; i++) wa[i+1] = wa[i] + A[i];

  mint ans = 0;
  for(int i=0; i<N; i++){
    ans += A[i] * (wa.back()- wa[i+1]);
  }

  cout << ans << endl;


  return 0;


}


Measured memory_bytes: 6428
# include <stdio.h>
int main()
{
    double a,b,c,d;
    scanf("%lf",&a);
    b=3.1415926535897932384626433*a*a;
    c=2*3.1415926535897932384626433*a;
    printf("%.6lf %.6lf\n",b,c);
    return 0;
}



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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

int n, L;
int a[100010];

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

    cin >> n >> L;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] >= L) {
            cout << "Possible" << endl;
            for (int j = 0; j < i; j++) {
                cout << j + 1 << endl;
            }
            for (int j = n - 1; j >= i + 1; j--) {
                cout << j << endl;
            }
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}

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

struct pint{
    int a;
    int b;
};

bool operator<(const pint& x, const pint& y) {
    return x.b < y.b;
}

int main(void){
    int n, m;
    cin >> n >> m;
    vector<pint> v(m);
    for(int i=0; i<m; i++) cin >> v[i].a >> v[i].b;
    sort(v.begin(), v.end());
    int res = 0;
    int front = 1;
    for(auto p : v) {
        if(p.a >= front) {
            res++;
            front = p.b;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int dp[400];

int main() {
	int n;
	cin >> n;
	vector<int> s(n), l(n), p(n);
	rep(i, n) {
		cin >> s[i] >> l[i] >> p[i];
	}
	int m;
	cin >> m;
	vector<int> w(m);
	rep(i, m) {
		cin >> w[i];
	}
	for(int i=1; i<=393; i++) {
		rep(j, n) {
			for(int k=i-l[j]; k<=i-s[j]; k++) {
				if(k<0) continue;
				dp[i] = max(dp[i], dp[k] + p[j]);
			}
		}
	}
	bool fail = false;
	rep(i, m) {
		if( dp[w[i]] == 0 ) {
			fail = true;
		}
	}
	if(fail) cout << "-1" << endl;
	else {
		rep(i, m) {
			cout << dp[w[i]] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int b = 0, w = 0, count = 0;
    char c;
    while (cin >> c) {
        if (count%2 == 0) {
            if (c == '0') b++;
            else w++;
        } else {
            if (c == '1') b++;
            else w++;
        }
        count++;
    }
    ct(min(b, w));
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,i,j,a[1001],b[1001],s;
	scanf("%d %d",&n,&m);
	while(!(n==0 && m==0)){
		s=1;
		for(j=1;j<=n;j++){
			scanf("%d",&a[j]);
		}
		for(i=1;i<=m;i++){
			scanf("%d",&b[i]);
		}
		for(i=1;i<=m;i++){
			s+=b[i];
			if(s>=n){
				break;
			}
			s+=a[s];
			if(s>=n){
				break;
			}
		}
		printf("%d\n",i);
		scanf("%d %d",&n,&m);
	}
	return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string s;
int k;
vector<string>a;
main()
{
	cin>>s>>k;
	for(int i=0;i<s.size();i++)for(int j=1;j+i<=s.size()&&j<=5;j++)a.push_back(s.substr(i,j));
	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());
	cout<<a[k-1]<<endl;
}


Measured memory_bytes: 1660
#include<iostream>
#include<map>
#include<queue>
using namespace std;

struct Worm{
  int body[10];
  bool operator < ( const Worm &p ) const{
    for(int i=0;i<10;i++){
      if(body[i]==p.body[i])continue;
      return body[i] < p.body[i];
    }
  }
};

int size,nowcnt;
Worm now,next,X;
string str;
map < Worm , bool > vd;
queue <Worm> Q;
queue < int > cnt;
void input();
void init();
void solve();

int main(){
  while(cin>>str&&str!="0"){
    input();
    init();
    solve();
  }
  return 0;
}

void init(){
  vd.clear();
  while(!Q.empty()){
    Q.pop();
    cnt.pop();
  }
}

void input(){
  size=str.size();
  for(int i=0;i<size;i++){
    if(str[i]=='r')X.body[i]=1;
    if(str[i]=='g')X.body[i]=2;
    if(str[i]=='b')X.body[i]=3;
  }
  for(int i=size;i<10;i++){
    X.body[i]=0;
  }
}

void solve(){
  int count;
  Q.push(X);
  cnt.push(0);
  vd[X]=true;

  while(!Q.empty()){
    now=Q.front();Q.pop();
    nowcnt=cnt.front();cnt.pop();
    
    count=0;
    for(int i=1;i<size;i++)
      if(now.body[i]==now.body[i-1])count++;
    if(count==size-1){
      cout<<nowcnt<<endl;
      return;
    }
    
    for(int i=0;i<size-1;i++){
      if(now.body[i]==now.body[i+1])continue;
      next=now;
      next.body[i]=next.body[i+1]=(6-now.body[i]-now.body[i+1]);
      if(vd[next]==true)continue;
      vd[next]=true;
      Q.push(next);
      cnt.push(nowcnt+1);

    }

  }
  cout<<"NA"<<endl;
}

Measured memory_bytes: 2656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 200000;
int cnt[300];
int n;
char s[MaxN + 5];

int main()
{
	while (~scanf("%s", s)) {
		n = strlen(s);
		LL ans = 0 ;
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < n; i++) {
			ans = ans + (i - cnt[s[i]]);
			cnt[s[i]]++;
		}
		printf("%lld\n", ans + 1);
	}
	return 0;
}

Measured memory_bytes: 384
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

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

bool correct[100005];
int ans;

void solve(){
    int n,m;
    cin >> n >> m;

    int pnts = 0, pnl[100005] = {0};

    for(int i = 1;i<=m;i++){
        int p;
        string res;
        cin >> p >> res;

        if(correct[p])continue;

        if(res == "WA"){
            pnl[p]++;
        }
        else {
            correct[p] = true;
            pnts++;
        }
    }

    for(int i = 1;i<=n;i++){
        if(correct[i])ans+=pnl[i];
    }
    cout << pnts << " " << ans << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 1152
abcd = int(input())
d = int(abcd % 10)
c = int(((abcd - d) % 100)/10)
b = int((abcd - c*10 - d)%1000/100)
a = int(abcd / 1000)

if(a == b):
  print("Bad")
elif(b == c):
  print("Bad")
elif(c == d):
  print("Bad")
else:
  print("Good")

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

int main() {
  int n, k;
  cin >> n >> k;
  int res = 0;
  rep(i, n) {
    int x;
    cin >> x;

    if (x < k - x) {
      res += x * 2;
    } else {
      res += (k - x) * 2;
    }
  }
  cout << res << endl;
}


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

int main() {
  int n;
  string l;
  vector<int> res(4);
  cin >> n;
  for(int i = 0;i<n; i++) {
	cin >> l;
    if(l=="AC") {
      res.at(0) += 1;
    }else if(l=="WA") {
      res.at(1) += 1;
    }else if(l=="TLE") {
      res.at(2) += 1;
    }else{
      res.at(3) += 1;
    }
  }
  cout << "AC x " << res.at(0) << endl;
  cout << "WA x " << res.at(1) << endl;
  cout << "TLE x " << res.at(2) << endl;
  cout << "RE x " << res.at(3) << endl;
  return 0;
}

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

int main(){
 int x,y,z;
 cin >> x >> y >> z;

 int num[3] = {x,y,z};
 int tmp;
 for( int i=0; i<3; i++ ){
  for( int j=i+1; j<3; j++ ){
   if( num[i]>num[j] ){
    tmp = num[i];
    num[i] = num[j];
    num[j] = tmp;
   }
  }
 }

 cout << num[0] << " " << num[1] << " " << num[2] << endl;

 return 0;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int R[2];
int L[2];
int U[2];
int D[2];
int X[2];
int Y[2];
char in[2];
int main(){
	int a;scanf("%d",&a);
	R[0]=L[0]=U[0]=D[0]=X[0]=Y[0]=mod;
	R[1]=L[1]=U[1]=D[1]=X[1]=Y[1]=-mod;
	vector<double>v;
	vector<int>tx;
	vector<int>ty;
	
	v.push_back(0);
	for(int i=0;i<a;i++){
		int x,y;
		scanf("%d%d%s",&x,&y,in);
		if(in[0]=='R'){
			Y[0]=min(Y[0],y);
			Y[1]=max(Y[1],y);
			R[0]=min(R[0],x);
			R[1]=max(R[1],x);
		}
		if(in[0]=='L'){
			Y[0]=min(Y[0],y);
			Y[1]=max(Y[1],y);
			L[0]=min(L[0],x);
			L[1]=max(L[1],x);
		}
		if(in[0]=='U'){
			X[0]=min(X[0],x);
			X[1]=max(X[1],x);
			U[0]=min(U[0],y);
			U[1]=max(U[1],y);
		}
		if(in[0]=='D'){
			X[0]=min(X[0],x);
			X[1]=max(X[1],x);
			D[0]=min(D[0],y);
			D[1]=max(D[1],y);
		}
	}
	for(int i=0;i<2;i++){
		tx.push_back(X[i]);
		tx.push_back(L[i]);
		tx.push_back(R[i]);
		ty.push_back(Y[i]);
		ty.push_back(U[i]);
		ty.push_back(D[i]);
	}
	for(int i=0;i<tx.size();i++){
		for(int j=i+1;j<tx.size();j++){
			v.push_back(ABS(tx[i]-tx[j])*0.5);
			v.push_back(ABS(tx[i]-tx[j]));
			
		}
	}
	for(int i=0;i<ty.size();i++){
		for(int j=i+1;j<ty.size();j++){
			v.push_back(ABS(ty[i]-ty[j])*0.5);
			v.push_back(ABS(ty[i]-ty[j]));
		}
	}
	
	double ret=inf;
	for(int i=0;i<v.size();i++){
		double lm=min((double)X[0],min(R[0]+v[i],L[0]-v[i]));
		double rm=max((double)X[1],max(R[1]+v[i],L[1]-v[i]));
		double dm=min((double)Y[0],min(U[0]+v[i],D[0]-v[i]));
		double um=max((double)Y[1],max(U[1]+v[i],D[1]-v[i]));
		ret=min(ret,(rm-lm)*(um-dm));
		//printf("%f: %f %f %f %f %f\n",v[i],lm,rm,dm,um,(rm-lm)*(um-dm));
	}
	printf("%.12f\n",ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int dp[50][1000 + 100][1000 + 100];
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<int> a(N), b(N), c(N);
  REP(i, N) cin >> a[i] >> b[i] >> c[i];
  REP(i, 50) REP(j, 1000) REP(k, 1000) {
    dp[i][j][k] = INF;
    if (j == 0 && k == 0) dp[i][j][k] = 0;
  }
  REP(i, N) {
    REP(j, 1000) REP(k, 1000) {
      chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
      chmin(dp[i + 1][j][k], dp[i][j][k]);
    }
    int A = 10;
  }
  int ans = INF;
  for (int i = 1; i * Ma <= 800 && i * Mb <= 800; i++) {
    chmin(ans, dp[N][i * Ma][i * Mb]);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 218656
a,b,c,d=map(int,input().split())
ans=0
if a>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=b*d
    else:
        ans=a*d
elif b>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=max(b*d,a*c)
    else:
        ans=a*c
else:
    if c>=0:
        ans=b*c
    elif d>=0:
        ans=a*c
    else:
        ans=a*c
print(ans)

Measured memory_bytes: 9168
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, 100000) {
		if (i*i > n) {
			cout << (i - 1)*(i - 1) << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int a,b; cin >> a >> b;
    if(a < 6){
        cout << 0 << endl;
    }else if(a <= 12){
        cout << b/2 << endl;
    }else{
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 100002;
long long ans[MAXN]={0};
int num[13]={0};
int maxlen;
long long getnum(){
    long long ret=0;
    for(int i=maxlen;i>=0;i--)
        ret=ret*10+num[i];
    return ret;
}
void op(){
    for(int i=0;i<=maxlen;++i){
        if(i==maxlen||num[i]<=num[i+1]){
            int check = 0 ;
            num[i]++;
            while(num[i]>9){
                num[i+1]++;
                num[i]=0;
                i++;
            }
            maxlen = max(maxlen,i);
            int j;
            while(i<maxlen&&abs(num[i]-num[i+1])>1){
                i++;
                num[i]++;
            }
            for(int j=i-1;j>=0;j--)
                num[j]=max(num[j+1]-1,0);
            return ;
        }
    }
}

void solve(){
    maxlen=0;
    num[0]=1;
    for(int i=1;i<MAXN;i++){
        ans[i]=getnum();
        op();
    }
}
int main()
{
    solve();
    int k;
    cin >> k;
    cout << ans[k] << endl;
    return 0;
}


Measured memory_bytes: 4348
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#define INF 0x3f3f3f3f

using namespace std;
typedef long long ll;
ll x,k,d;
int main() {
	ios::sync_with_stdio(false);
	scanf("%lld%lld%lld",&x,&k,&d);
	x=abs(x);
	ll t=x/d;
	if(k<=t) {
		printf("%lld",x-d*k);
	}
	else {
		if((k-t)%2==1) {
			printf("%lld",abs(x%d-d));
		}
		else {
			printf("%lld",abs(x%d));
		}
	}
	return 0;
}


Measured memory_bytes: 3856
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC160D();

int main()
{
	ABC160D();
	fflush(stdout);
	return 0;
}

static void ABC160D()
{
	int N, X, Y;
	getint(N, X, Y);
	
	std::vector<int> dist(N + 1, 0);
	for (int start = 1; start < N; start++) {
		for (int end = start + 1; end <= N; end++) {
			int diff = end - start;
			int passed = abs(X - start) + 1 + abs(Y - end);
			dist[std::min(diff, passed)]++;
		}
	}
	
	for (int d = 1; d < N; d++) {
		printf("%d\n", dist[d]);
	}
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
    input! {
        t:usize
    }

    let mut table = vec![(0, 0); 128];
    for i in 0..128 {
        for j in 0..128 {
            let buf = i ^ j + j;
            if buf > table[i].0 {
                table[i] = (buf, j);
            }
        }
    }
    for _ in 0..t {
        input! {
            n:usize,d:usize,
        }
        let r = 127 * (n - 1) + if n % 2 == 0 { 127 - d } else { d };
        println!("{}", r);
    }
}


Measured memory_bytes: 2184
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    S = input()

    N = len(S) + 1
    a = [0] * N 
    for i in range(N-1):
        if S[i] == "<":
            a[i+1] = max(a[i+1], a[i]+1)
    for i in reversed(range(N-1)):
        if S[i] == ">":
            a[i] = max(a[i], a[i+1]+1)
    
    print(sum(a))


if __name__ == '__main__':
    main()

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt(), s = fs.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++) {
			if(i<k)sb.append(s + " ");
			else {
				if(s>=(int)1e9) sb.append(1 + " ");
				else sb.append(s+1 + " ");
			}
		}
		System.out.println(sb.toString());
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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

Measured memory_bytes: 43988
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  map<int,vector<int>>G;
  int a,b;
  for(int i=0;i<m;i++){
    cin>>a;cin>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if(!G.count(1)){
    cout <<"IMPOSSIBLE"<<endl;
    return 0;
  }
  int size=G[1].size();
  for(int i=0;i<size;i++){
    int size2=G[G[1].at(i)].size();
    for(int j=0;j<size2;j++){
      if(G[G[1].at(i)].at(j)==n){
        cout <<"POSSIBLE"<<endl;
        return 0;
      }
    }
  }
  cout <<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 25884
use v5.18;
use warnings;
use Data::Dumper;
use List::Util qw( sum );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my @chars = split //, read_line;
say solve(\@chars);

sub solve {
  my $chars = shift;
  my $first_cost =
    sum map { $_->[0] }
      grep { $_->[1] eq 'B' }
      map { [$_, $chars->[$_] ] } 0 .. $#$chars;
  my @moved_chars = sort { $b cmp $a } @$chars;
  my $last_cost =
    sum map { $_->[0] }
      grep { $_->[1] eq 'B' }
      map { [$_, $moved_chars[$_] ] } 0 .. $#moved_chars;
  $last_cost - $first_cost;
}


Measured memory_bytes: 91704
#include "iostream"
#include "string"
using namespace std;

int main(){
  int n;int k;string s;
  cin>>n>>k;
  cin>>s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else{
    s[k-1]='c';
  }
  cout<<s<<endl;


}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,mx=0,ans=0,tmp;
    cin>>n;
    for(int i=0;i<n&&cin>>tmp;i++)
        ans+=max(0LL,mx-tmp),mx=max(mx,tmp);
    cout<<ans;
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[15][1005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w,k; cin>>h>>w>>k;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  ll ans=INF;
  rep(bit,(1<<h-1)){
    ll g=0;
    vll id(h);
    rep(i,h){
      id[i]=g;
      if(bit>>i&1) g++;
    }
    g++;
    
    vvll c(g,vll(w)); // グループ数/列 ごとのホワイトチョコレート
    rep(i,h) rep(j,w) c[id[i]][j]+=(G[i][j]-'0');
    ll tmp=g-1;
    vll now(g);
    auto add=[&](ll j){
      rep(i,g) now[i]+=c[i][j];
      rep(i,g) if(now[i]>k) return false;
      return true;
    };
    rep(j,w){
      if(!add(j)){
        tmp++;
        now=vll(g);
        if(!add(j)){
          tmp=INF;
          break;
        }
      }
    }
    chmin(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ans = "APPROVED";
    for (int i=0;i<N;i++){
      int A = sc.nextInt();
      if (A%2==0){
        if (A%3==0 || A%5==0){
          continue;
        }else{
          ans = "DENIED";
          break;
        }
      }
    }
    System.out.println(ans);
  }
}

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

int main()
{
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; ++i) {
		int Ah = i % 100;
		int At = i / 1000;
		if (Ah % 10 == At / 10 && Ah / 10 == At % 10) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,m;
  cin>> a>> b>> c;
  m=max({a,b,c});
  if(m==a) cout<<m*10+b+c<<endl;
  else if(m==b) cout<<m*10+a+c<<endl;
  else cout<<m*10+b+a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{
    long long x,ans;
    scanf("%lld",&x);
    ans=x/11*2;
    x%=11;
    if(x>0&&x<=6)
        ans++;
    else if(x>=7)
        ans+=2;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int N,K;
vector<vector<int>> v(5010);
int C[5010] = {},R[5010],ans[5010] = {},used[5010] = {},inf = 1e9;
int cost[5010][5010] = {};
int main(){
    cin >> N >> K;
    for(int i=1;i<=N;i++){
        cin >> C[i] >> R[i];
    }
    int a,b;
    for(int i=0;i<K;i++){
        cin >> a >> b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    for(int i=1;i<=N;i++){
        ans[i] = inf;
        for(int j=1;j<=N;j++){
            cost[i][j] = inf;
            cost[j][i] = inf;
        }
    }
    queue<P> Q;
    for(int i=1;i<=N;i++){
        Q.push(P(i,R[i]));
        cost[i][i] = 0;
        while(!Q.empty()){
            P p = Q.front(); Q.pop();
            int n = p.first;
            if(p.second==0) continue;
            for(auto x:v[n]){
                if(cost[i][x]==inf){
                    cost[i][x] = C[i];
                    Q.push(P(x,p.second-1));
                }
            }
        }
    }
    ans[1] = 0;
    while(true){
        int a = -1;
        for(int i=1;i<=N;i++){
            if(!used[i] && (a==-1 || ans[i]<ans[a])) a = i;
        }
        if(a==-1) break;
        used[a] = 1;
        for(int i=1;i<=N;i++){
            ans[i] = min(ans[i],ans[a]+cost[a][i]);
        }
    }
    cout << ans[N] << endl;
}


Measured memory_bytes: 101156
H, W = map(int, input().split())

ans = 0
if H == 1 or W == 1:
  ans = 1
else:
  if (H % 2 == 0) and (W % 2 == 0):
    ans = (H * W) // 2
  if (H % 2 == 0) and (W % 2 == 1):
    ans = (H // 2) * W
  if (H % 2 == 1) and (W % 2 == 0):
    ans = H * (W // 2)
  if (H % 2 == 1) and (W % 2 == 1):
    ans = (H * W) // 2 + 1

print(ans)


Measured memory_bytes: 61904
#include <bits/stdc++.h>
using namespace std;
int main(){
for(int i=0;;i++){
int a,z;
cin>>a>>z;

if(a==0) break;
for(int i=0;i<a;i++){
for(int i=0;i<z;i++){
cout<<"#";
}
cout<<endl;
}
cout<<endl;
}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	cin>>n;
	if(n==1)puts("Hello World");
	else{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
const double eps=1e-5;

bool check(double x,double y)
{
       if(abs(x)<=eps&&abs(y)<=eps)
        return 1;
      return 0;
}
int main()
{
  double x;
  cin>>x;
  x=x/360*2*pi;
  double t=x;
  double xx,yy;
  xx=0;
  yy=1;
  int k=0;
  int s;
  while(!check(xx,yy))
  { 
    xx+=sin(x);
    yy+=cos(x);
    x+=t;
    if(x>=2*pi) x-=2*pi;
    
    k++;
  
  }
  cout<<k+1<<endl;
}


Measured memory_bytes: 4080
#include <cstdio>
#define ll long long int

int main(void){
		int a, b, c, x, y;
		ll price = 0;
		scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
		if(a + b < c * 2){
				printf("%lld\n", (ll)(a * x + b * y));
		}else{
				int upper = x > y ? a : b;
				int max = x > y ? x : y;
				int max2 = x > y ? y : x;
				if(upper > c * 2){
						price = c * 2 * max;
						
				}else{
						price = max2 * c * 2 + upper * (max - max2);
				}
				printf("%lld\n", price);
		}
		return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  vi a(5);
  rep(i, 5) cin >> a[i];
  int ans = 0;
  rep(i, 5) ans += (a[i] + 9) / 10 * 10;
  int mn = 10;
  rep(i, 5) if(a[i] % 10 >= 1) mn = min(mn, a[i] % 10);
  ans -= 10 - mn;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
#define oo 1000000
#define zyy 1000000007
#define M 3005
using namespace std;
inline ll read(){ll x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,ans=1,a[M];
int main(){
	n=read();
	For(i,1,n){
		int x=i;
		for(int j=2;j*j<=x;j++) while(x%j==0) a[j]++,x/=j;
		if(x) a[x]++;
	}
	For(i,2,n) ans=1ll*ans*(a[i]+1)%zyy;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
x, n = map(int,input().split())
p = [int(a) for a in input().split()]
p.sort()

ans = 0
j = 0 
for i in range(-1, 102):
    if j != n and p[j] == i:
        j += 1
        continue
    if abs(i - x) < abs(ans - x):
        ans = i
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    long long sum = 0;
    if(a < k){
        sum += a;
        k -= a;
        if(b < k){
            k -= b;
            sum -= k;
        }
    }else{
        sum =k;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>

double solve(int k, int n, const std::vector<int>& pips)
{
  std::vector<double> averages(n);
  std::transform(
      pips.begin(),
      pips.end(),
      averages.begin(),
      [](int p) { return (p + 1) / 2.0; });
  double sum = std::accumulate(averages.begin(), averages.begin() + k, 0.0);
  double max = sum;
  for (int i = k; i < n; ++i) {
    sum = sum - averages[i - k] + averages[i];
    max = std::max(max, sum);
  }
  return max;
}

int main()
{
  int k, n;
  std::cin >> n >> k;
  std::vector<int> pips(n);
  for (auto& p : pips) {
    std::cin >> p;
  }

  std::cout << std::fixed << std::setprecision(12) << solve(k, n, pips) << std::endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define NOTF -1
#define FREE 1

int A[N][N];
int x,row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void printboard(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(A[i][j]){
	if(row[i]!=j) return;
      }
    }
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if (row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  if(i==N){
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]==NOTF || dpos[i+j]==NOTF || dneg[i-j+N-1] == NOTF) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOTF;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  
  int i,j,t,w;
  
  scanf("%d",&x);

  for(i=0;i<2*N-1;i++) dpos[i]=dneg[i]=FREE;

  for(i=0;i<N;i++) col[i]=row[i]=FREE;
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      A[i][j]==false;
    }
  }

  for(i=0;i<x;i++){
    scanf("%d%d",&t,&w);
      A[t][w]=true;
  }
  putQueen(0);
  
  return 0;

}



Measured memory_bytes: 2112
l = []
gets.to_i.times do
  com, n = gets.split
  case com
  when 'insert'
    l.unshift(n)
  when 'delete'
    i = l.index(n)
    l.delete_at(i) unless i.nil?
  when 'deleteFirst'
    l.shift
  when 'deleteLast'
    l.pop
  end
end
puts l * ' '

Measured memory_bytes: 170028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename T>
vector<vector<T>> pascal(int val) {
  vector<vector<T>> c(val + 1, vector<T>(val + 1, 0));
  REP(i, val + 1) {
    c[i][0] = 1;
    FOR(j, 1, i + 1) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  return c;
}

int main() {
  int n, k, s, t; cin >> n >> k >> s >> t;
  vector<int> a;
  while (n--) {
    int ai; cin >> ai;
    if ((ai & s) != s || (ai | t) != t) continue;
    int bit = 0, b = 0;
    REP(i, 18) {
      if (!(s >> i & 1) && (t >> i & 1)) b |= (ai >> i & 1) << (bit++);
    }
    a.emplace_back(b);
  }
  n = a.size();
  int l = 0;
  REP(i, 18) {
    if (!(s >> i & 1) && (t >> i & 1)) ++l;
  }
  vector<vector<ll>> c = pascal<ll>(n);
  ll ans = 0;
  REP(bit, 1 << l) {
    map<int, int> mp;
    REP(i, n) ++mp[a[i] & bit];
    for (auto [ignore, cnt] : mp) {
      // cout << bit << ' ' << cnt << '\n';
      for (int i = 1; i <= k && i <= cnt; ++i) ans += c[cnt][i] * (__builtin_popcount(bit) & 1 ? -1 : 1);
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3692
#!/usr/bin/env python3

import sys
import pprint
import math

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)

def prime_fact(n):
	p = {}
	for i in range(2, int(-(-n**0.5//1))+1):
		if n % i == 0:
			while n % i == 0:
				n //= i
				p[i] = p.get(i, 0) + 1
	if n != 1:
		p[n] = p.get(n, 0) + 1
	return p
# s = n(n+1)/2 

def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	if n == 1:
		print(0)
		exit()
	p = prime_fact(n)
	ans = 0
	if len(p.keys()) == 0:
		print(1)
		exit(0)
	keys = list(p.keys())
	key = keys[0]
	i = 1
	j = 0
	while 1:
		if p[key] < i:
			j += 1
			if len(keys) == j:
				break
			key = keys[j]
			i = 1
			continue
		log.print(p, n, key)
		z = key ** i
		n /= z
		p[key] -= i
		ans += 1
		i += 1
	print(ans)


main()

Measured memory_bytes: 68996
n, k, l = map(int, raw_input().split())

def rr(x, gr):
    if x != gr[x]: gr[x] = x = rr(gr[x], gr)
    return x

def g(x, y, gr):
    px = rr(x, gr)
    py = rr(y, gr)
    if px < py:
        gr[py] = px
    else:
        gr[px] = py

roads = range(n)
for _ in range(k):
    p, q = map(int, raw_input().split())
    g(p - 1, q - 1, roads)
for i in range(n): rr(i, roads)

rails = range(n)
for _ in range(l):
    r, s = map(int, raw_input().split())
    g(r - 1, s - 1, rails)
for i in range(n): rr(i, rails)

c = {}
for p1, p2 in zip(roads, rails):
    try:
        c[p1, p2] += 1
    except KeyError:
        c[p1, p2] = 1

ans = [c[p1, p2] for p1, p2 in zip(roads, rails)]
print ' '.join(map(str, ans))


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

using namespace std;
typedef long long ll;

int main(void){
   int n, k;
   cin >> n >> k;
   vector<double> p(n);
   vector<double> score(n+1,0);
   for (int i = 0; i < n; i++){
      double sum = 0;
      cin >> p.at(i);
      sum = (1.0 + p.at(i)) / 2.0;
      score.at(i+1) = score.at(i)+sum;
   }
   double ans = 0,temp =0;
   for (int i = 0; i <n-k+1;i++){
      temp = score.at(i+k)-score.at(i);
      ans = max(ans, temp);
   }
   printf("%.12lf\n", ans);
   return 0;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  ll a, b;
  cin >> n;
  rep(i, n) {
    cin >> a >> b;
    ll tmp = a % b;
    if(tmp == 0) tmp = b;
    cout << tmp << endl;
  }
	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=1000005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

bitset<MAXN+1> isPrime;
vector<int> primeList;
void sieve(){
    isPrime.reset();
    isPrime.flip();
    isPrime[0] = isPrime[1] = 0;
    primeList.push_back(2);
    for (int i = 4; i < MAXN; i+=2) isPrime[i] = 0;
    for (int i = 3; i < MAXN; i+=2) {
        if (!isPrime[i]) continue;
        primeList.push_back(i);
        for (int j = i; j <= MAXN/i; ++j) isPrime[i*j] = 0;
    }
}

vector<pi> primeFactorize(int X) {
    vector<pi> result;
    for (auto i:primeList) {
        if (i > X/i) break;
        int cnt = 0;
        while (X % i == 0) {
            X /= i;
            cnt++;
        }
        if (cnt > 0) result.emplace_back(i, cnt);
    }
    if (X != 1) result.emplace_back(X, 1);
    return result;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	sieve();
	
	int N; cin>>N;
	
	vector<pi> vec = primeFactorize(N);
	int ans = 0;
	for (auto i:vec){
		int lim = i.second;
		int s = 0, e = 1e9;
		while (e-s>1){
			int m = (s+e)/2;
			int tmp = m*(m+1)/2;
			if (tmp > lim) e = m;
			else s = m;
		}
		ans += s;
	}
	cout<<ans;
}


Measured memory_bytes: 4332
import math
N, M = [int(i) for i in input().split()]

ans = 1
sosu = True if M % 2 == 1 else False

if M % 2 == 1:
    sqrt = int(math.ceil(math.sqrt(M)))
    for i in range(3, sqrt, 2):
        if M % i == 0:
            sosu = False
            break

if sosu == False:
    for i in range(N, M):
        if M % i == 0:
            ans = M / i
            break


print(int(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const int INF = 1001001001;

void dfs(vector<vector<int>> &tree, vector<int> &dt, int now, int bf){
  for(auto i : tree.at(now)){
    if(i == bf) continue;
    dt.at(i) = dt.at(now) + 1;
    dfs(tree, dt, i, now);
  }
}

int main(){
  int n, ta, ao;
  cin >> n >> ta >> ao;
  ta--; ao--;
  vector<vector<int>> tree(n, vector<int>());
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree.at(a).push_back(b);
    tree.at(b).push_back(a);
  }
  vector<int> dt(n, INF), da(n, INF);
  dt.at(ta) = 0; da.at(ao) = 0;

  dfs(tree, dt, ta, -1);
  dfs(tree, da, ao, -1);

  int ans = 0;
  rep(i, n){
    int nt = dt.at(i), na = da.at(i);
    // cerr << nt << " " << na << endl;
    if(nt > na) continue;
    ans = max(ans, na-1);
  }
  cout << ans << endl;
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end());

    int cnt = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int c = l[i]+l[j];
            auto itr = lower_bound(l.begin(),l.end(),c);
            cnt += (int)(itr-(l.begin()+j)-1);
        }
    }

    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
const int dx[4] = {1, 0, -1, 0} , dy[4] = {0, 1, 0, -1};
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,k,s; cin >> n >> k >> s;
    REP(i,k) cout << s << endl;
    REP(i,n-k) cout << 114514810 << endl;

    return 0;
}

Measured memory_bytes: 1280
#N = int(input())
N,K= map(int,input().split())
H =list(map(int,input().split()))
#L = [list(map(str,input().split())) for i in range(N)]

H = sorted(H)

ans = 0
for i in range(N-K):
    ans += H[i]
print(ans)


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

using namespace std;

using ll = long long;

// from ACL
long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

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

    int T;
    cin >> T;
    while (T--) {
        int N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 3628