akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main{

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

    void run(){
      Scanner sc=new Scanner(System.in);
      int N=sc.nextInt();
      int W=sc.nextInt();
      int[] w=new int[N];
      long[] v=new long[N];
      for(int i=0;i<N;++i){
          w[i]=sc.nextInt();
          v[i]=sc.nextLong();
      }
      long[] dp=new long[W+1];
      for(int i=0;i<N;++i){
          for(int j=W-w[i];j>=0;--j){
    	      dp[j+w[i]]=Math.max(dp[j+w[i]],dp[j]+v[i]);
          }
      }
      long ans=0;
      for(long val:dp)ans=Math.max(ans,val);
      System.out.println(ans);
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int ans=1;
  for (int i=0; i<N ; i++){
    cin >> S.at(i);
  }
  sort(S.begin(), S.end()); 
  for (int i=1; i<N ; i++){
    if (S.at(i) != S.at(i-1)) ans=ans+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

string S;


int main()
{
    cin >> S;

    for(int i = 0;i < S.size();i++)
    {
        if(i == 3)
        {
            cout << 8;
        }
        else 
            cout << S[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
///****In the name of ALLAH, most Gracious, most Compassionate****//

#include <bits/stdc++.h>
using namespace std;

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

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

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

const int N=1e3+5;
const int oo=1e9+7;
char s[N][N];

int32_t main()
{
    FastIO;
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            s[i][j] = '.';
    if(n%2)
    {
        for(int j=0; j<m-m%2; j+=2)
        {
            if(a>0)
                s[n-1][j] = '<', s[n-1][j+1] = '>', a--;
        }
    }
    if(m%2)
    {
        for(int i=0; i<n-n%2; i+=2)
        {
            if(b>0)
                s[i][m-1] = '^', s[i+1][m-1] = 'v', b--;
        }
    }
    for(int i=0; i<n-n%2; i+=2)
    {
        for(int j=0; j<m-m%2; j+=2)
        {
            if(a>1)
            {
                s[i][j] = '<',s[i][j+1] = '>',a--;
                s[i+1][j] = '<', s[i+1][j+1] = '>', a--;
            }
            else if(b>1)
            {
                s[i][j] = '^',s[i+1][j] ='v',b--;
                s[i][j+1] = '^', s[i+1][j+1]= 'v', b--;
            }
            else if(a>0)
                s[i][j] = '<',s[i][j+1] = '>',a--;
            else if(b>0)
                s[i][j] = '^',s[i+1][j] ='v',b--;
        }
    }
    if(a==1 and n>=3 and m>=3 and s[n-3][m-2]=='.' and s[n-2][m-2]=='.' and s[n-1][m-1] == '.')
    {
        s[n-1][m-1] = 'v',s[n-2][m-1] = '^';
        s[n-3][m-2] = '<' ,s[n-3][m-1] = '>';
        a--;
    }
    if(b==1 and n>=3 and m>=3 and s[n-2][m-3]=='.' and s[n-2][m-2]=='.' and s[n-1][m-1] == '.')
    {
        s[n-1][m-1] = '>',s[n-1][m-2] = '<';
        s[n-2][m-3] = '^' ,s[n-1][m-3] = 'v';
        b--;
    }

    if(a==0 and b==0)
    {
        cout<<"YES\n";
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<m; j++)
                cout<<s[i][j];
            cout<<"\n";
        }
    }
    else
        cout<<"NO\n";


}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int ans(string a, string b) {
  int n = a.size();
  int m = b.size();
  int memo[n+1][m+1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      memo[i][j] = 0;
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int res = max(memo[i-1][j], memo[i][j-1]);
      if (a[i-1] == b[j-1]) {
        res = max(res, memo[i-1][j-1] + 1);
      } else {
        res = max(res, memo[i-1][j-1]);
      }
      memo[i][j] = res;
    }
  }
  
  return memo[n][m];
}

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

  for (int i = 0; i < q; i++) {
    string a, b;
    cin >> a >> b;
    
    cout << ans(a, b) << endl;
  }

  return 0;
}

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

void swap(int &x, int &y);

void swap(int &x, int &y)
{
    if (x > y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
}
int main()
{
    for ( ; ; ) {
        int x, y;
        cin >> x >> y;
        if ((x == 0) && y == 0)
            break;
        swap(x, y);
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int main()
{
  ll r, D, x;
  cin >> r >> D >> x;
  REP(i,0,10) {
    x = r * x - D;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000+7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[100000], ans, dp[800][800],a[2000000], b[2000000];
string str,ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<string>vec[4];
vector<Pll>v;
map<pair<string, string>, LL>ma; 
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	cin >> str;
	rep(i, 1 << n) {
		string is[2];
		rep(j, n) {
			if (i >> j&1)
				is[0].push_back(str[j]);
			else is[1].push_back(str[j]);
		}
		ma[pair<string, string>(is[0], is[1])]++;
	}
	rep(i, 1 << n) {
		string is[2];
		rep(j, n) {
			if (i >> j&1)
				is[0].push_back(str[2 * n - j - 1]);
			else is[1].push_back(str[2 * n - j - 1]);
		}
	ans+=	ma[pair<string, string>(is[0], is[1])];
	}
	cout << ans << endl;
	return 0;
}


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

#define fr first
#define sc second
#define pb push_back
#define ll long long

using namespace std;

int a[55];

vector<int>p[55];
vector<int>vec;
pair<int, int>ans;
int s[30];
int cnt;
int u[30];
void make(int b, int n)
{
    int m = n;
    while (b)
    {
        s[n - 1] = b % 2;
        b /= 2;
        n--;
    }
}
main()
{
    int n, mn;
    cin >> n;
    mn = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        u[a[i]]++;
    }
    u[0]++;
    a[n] = 0;
    n ++;

    for (int i = 0; i <= 12; i++)
    {
        if (u[a[i]] > 2)
        {
            cout << 0;
            return 0;
        }
    }
    if (u[0] >= 2)
    {
        cout << 0;
        return 0;
    }
    if (n > 25)
    {
        cout << 0;
        return 0;
    }
    if (n >= 24)
    {
        cout << 1;
        return 0;
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++)
    {
            if (a[i]){
            p[i].pb(a[i]);
            p[i].pb(24 - a[i]);}
            else
                p[i].pb(a[i]),p[i].pb(0);
    }

    for (int i = 0; i < (1 << n); i++)
    {
        make(i, n);
        for (int j = 0; j < n - 1; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                mn = min(mn, min(abs(p[j][s[j]] - p[k][s[k]]),24 - abs(p[j][s[j]] - p[k][s[k]])));
            }
        }
        for (int j = 0; j < n; j++)
        {
            if (p[j][0] != 0){
            int mm = min(p[j][0], p[j][1]);
            mn = min(mn, mm);}
        }
        mn = min(mn, min(abs(p[0][s[0]] - p[n - 1][s[n - 1]]), 24 - abs(p[0][s[0]] - p[n - 1][s[n - 1]])));
            vec.pb(mn);
        mn = 1e9 + 1;
        memset(s, 0, sizeof(s));
    }

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

    cout << vec.back() << endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
	int n,x=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x=max(x,a[i]);
	}
	int t=0,l=0;
	for(int i=0;i<n;i++){
		if(t<min(a[i],x-a[i])){
			t=min(a[i],x-a[i]);
			l=a[i];
		}	
	}
	cout<<x<<' '<<l;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define F first
#define S second
#define pb push_back
#define f(a,j,b) for(int a=j;a<b;a++)
void solve()
{
    ll n,w;
	cin>>n>>w;
	ll wei[n+1],val[n+1];
	ll dp[100001][n+1];
	f(i,0,100001)
	{
		f(j,0,n+1)
		{
			dp[i][j]=INT_MAX;
		}
	}
    f(i,1,n+1)
	{
		cin>>wei[i]>>val[i];
		dp[0][i]=0;
	}
	dp[0][0]=0;
	ll fin;
	f(i,1,100001)
	{
		f(j,1,n+1)
		{
           if(i>=val[j])
		   {
			   dp[i][j]=min(dp[i][j-1],wei[j]+dp[i-val[j]][j-1]);
		   }
		   else
		   {
			   dp[i][j]=dp[i][j-1];
		   }
		//    cout<<dp[i][j]<<" ";
		}
		// cout<<endl;
	}
	f(i,1,100001)
	{
		if(dp[i][n]<=w)
		{
			fin=i;
		}
	}
	cout<<fin<<endl;
}
int main() {
	fast;
	fast_input;
	fast_output;
	// ll t;
	// cin>>t;
	// f(i,t)
	// {
    //   cout<<"Case #"<<i+1<<":"<<" ";
	     solve();
	// }
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long x, y, ans = 0;
    cin >> x >> y;
    while (x <= y) {
        ans++;
        x *= 2LL;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ( ((a == b) && (b == c) && (c == a)) || ((a != b) && (b != c) && (c != a)) ) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long t,i,j,n,m,l=10,r=0;
    cin>>n;
    while(l<=n){
        r+=(n/l);
        l*=5;
    }
    r=(n%2==1)? 0: r;
    cout<<r<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

bool check(int currH, int cx, int cy, vector<int> x, vector<int> y, vector<int> h){
	int n = (int)x.size();
	rep (i, n){
		if (h[i] != max(currH - abs(x[i] - cx) - abs(y[i] - cy), 0)){
			return false;
		} // end if
	} // end rep
	return true;
} 

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

	int N; cin >> N;
	vector<int> x(N, 0), y(N, 0), h(N, 0);
	rep (i, N){
		cin >> x[i] >> y[i] >> h[i];
	} // end rep

	vector<int> res(3, -1); // cx, cy, h order
	for (int cx = 0; cx <= 100; ++cx){
		for (int cy = 0; cy <= 100; ++cy){
			rep (i, N){
				if (h[i] != 0){
					int currH = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					if (check(currH, cx, cy, x, y, h)){
						res[0] = cx;
						res[1] = cy;
						res[2] = currH;
						break;
					} // end if
				} // end if
			} // end rep
		} // end for
		if (res[0] != -1) break;
	} // end for

	rep (i, 3){
		cout << res[i] << (i != 3 - 1 ? ' ' : '\n');
	} // end rep
	
	return 0;
}

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


int main(){
	
	int A,B,M;
	cin>>A>>B>>M;
	
	vector<int> a(A),b(B);
	
	for(int i=0;i<A;i++)cin>>a[i];
	for(int i=0;i<B;i++)cin>>b[i];
	
	int ans = 1000000;
	
	for(int i=0;i<M;i++){
		int x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		
		ans = min(ans,a[x]+b[y]-c);
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	ans = min(ans,a[0]+b[0]);
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mx 1000002
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {
	ll n,m;
	cin>>n>>m;
	cout<<min(abs(m-n%m),n%m)<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,A[20],B[20],C[20],sum=0;
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	for(int i=0;i<N-1;i++)cin>>C[i];
	for(int i=0;i<N-1;i++){
		sum+=B[A[i]-1];
		if(A[i+1]-A[i]==1)sum+=C[A[i]-1];
	}
	sum+=B[A[N-1]-1];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n - 1);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		
	}
	int t=0;
	sort(a.begin(), a.end());
	for (int i = 0;i < n-1;i++) {
		b[i] = a[i + 1] - a[i];
		if (b[i] == 0) { t = 1;break; }
	}


	if(t==0)cout << "YES" << endl;
	else cout << "NO" << endl;
	


	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
//const long long MAX = 1000000007;

int main(){
  int h,w;
  cin >> h >> w;
  char obj[h][w];
  int check[2][h][w];
  for(int i=0;i<2;i++){
    for(int j=0;j<h;j++){
      for(int k=0;k<w;k++){
        check[i][j][k] = 0;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> obj[i][j];
    }
  }
  int x=0;
  for(int i=0;i<h;i++){
    x=0;
    for(int j=0;j<w;j++){
      if(obj[i][j] == '.'){
        if(x != 0){
          check[0][i][j] = x;
        }else{
          x=1;
          for(int k=1;k+j < w;k++){
            if(obj[i][j+k] == '.'){
              x++;
            }else{
              break;
            }
          }
          check[0][i][j] = x;
        }
      }else{
        check[0][i][j] = 0;
        x=0;
      }
    }
  }
  for(int j=0;j<w;j++){
    x=0;
    for(int i=0;i<h;i++){
      if(obj[i][j] == '.'){
        if(x != 0){
          check[1][i][j] = x;
        }else{
          x=1;
          for(int k=1;k+i<h;k++){
            if(obj[i+k][j] == '.'){
              x++;
            }else{
              break;
            }
          }
          check[1][i][j] = x;
        }
      }else{
        check[1][i][j] = 0;
        x=0;
      }
    }
  }
  int max = 1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      //cout << check[1][i][j];
      if(check[0][i][j] + check[1][i][j] > max){
        max = check[0][i][j] + check[1][i][j];
      }
    }
    //cout << endl;
  }
  cout << max-1;
}


Measured memory_bytes: 35456
n=int(input())
town=[]
for i in range(n):
  xy=list(map(int,input().split()))
  town.append(xy)
way=0
import math
for i in range(n-1):
  for j in range(i+1,n):
    ij=(town[i][0]-town[j][0])**2+(town[i][1]-town[j][1])**2
    root=math.sqrt(ij)
    way=way+root
print(way*2/n)

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

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t=0,i;
	string a;
	cin>>a;
	for (i=0;i<a.size();i++){
		if (a[i]=='o'){
			t++;
		}
	}
	cout<<700+t*100;
	return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections
from heapq import *

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    n,m,s,t = LI()
    y_root = [[] for _ in range(n)]
    s_root = [[] for _ in range(n)]
    y_node = [INF] * n
    s_node = [INF] * n
    for _ in range(m):
        u,v,a,b = LI()
        y_root[u-1].append((v-1,a))
        y_root[v-1].append((u-1,a))
        s_root[u-1].append((v-1,b))
        s_root[v-1].append((u-1,b))

    def dist(node,root,r):
        q = [(0,r)]
        heapify(q)
        node[r] = 0
        while q:
            d,u = heappop(q)
            if node[u] < d: continue
            for v,e in root[u]:
                if d+e < node[v]:
                    node[v] = d+e
                    heappush(q,(d+e,v))

    dist(y_node,y_root,s-1)
    dist(s_node,s_root,t-1)

    t_node = [(y_node[i] + s_node[i],i) for i in range(n)]
    t_node.sort()

    p = 0
    for i in range(n):
        while t_node[p][1] < i:
            p += 1
        print(10**15 - t_node[p][0])


if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    long long H;
    long long W;
    cin>>H>>W;
    double res = (H*W)/2.0;
    if(H == 1 || W == 1) cout<<1<<endl;
    else cout<<(long long)ceil(res)<<endl;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s;
    cin >> s;
    if (s.substr(0, 4) == "YAKI") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

C = [0] * N
D = [0] * (N + 1)
for a in A:
    C[a - 1] += 1
    D[C[a - 1]] += 1

S = [0] * (N + 1)
for i in range(N):
    S[i + 1] = S[i] + D[i + 1]

ans = N
for K in range(1, N + 1):
    while ans > 0 and S[ans] < K * ans:
        ans -= 1
    print(ans)

Measured memory_bytes: 45824
N, A, B = map(int,input().split())
sum_element = []
for i in range(N+1):
    ketawa = 0
    i_temp = i
    for j in range(5):
        k = 4-j
        syou = i_temp//(10**k)
        ketawa += syou
        i_temp = i_temp - syou*(10**k)
    if A<=ketawa<=B:
        sum_element.append(i)
print(sum(sum_element))

Measured memory_bytes: 40176
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;
const int maxm=1e6+10;

int cnt[maxm],f[maxm],n;
vector <int> v;

int main(){
	memset(cnt,0,sizeof(cnt));
	memset(f,0,sizeof(f));
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		v.pb(x);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		for(int j=1;j*j<=v[i];j++){
			if(cnt[j]>=1&&v[i]%j==0) f[i]=1;
			if(cnt[v[i]/j]>=1&&v[i]%j==0) f[i]=1;
		}
		cnt[v[i]]++;
	}
	for(int i=0;i<v.size();i++) if(cnt[v[i]]>1) f[i]=1;
	int ans=0;
	for(int i=0;i<v.size();i++) if(!f[i]){
	//	cout<<v[i]<<" ";
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 12052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int main()
{
    int n,a[10][10];
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++){
        a[to_string(i)[0]-'0'][i%10]++;
    }
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

const int maxn = 15e4 + 5;

double dp[maxn], dp2[maxn];
int deg[maxn];
vector<int> G[maxn];

void dfs(int u, int fa) {
    dp[u] = 0;
    int p = deg[u];
    if (fa != -1) p --;
    for (int v : G[u]) if (v != fa) {
        dfs(v, u);
        dp[u] += (dp[v] + 1) * 1.0 / p;
    }
}

void dfs2(int u, int fa) {
    int p = deg[u];
    for (int v : G[u]) if (v != fa) {
        if (fa == -1) {
            if (p == 1)
                dp2[v] = 1;
            else
                dp2[v] = ((dp[u] + 1) * p - (dp[v] + 2)) / (p - 1);
        }
        else
            dp2[v] = ((dp2[u] + 1) + (dp[u] + 1) * (p - 1) - (dp[v] + 2)) / (p - 1);
        dfs2(v, u);
    }
}

int main(int argc, char const *argv[]) {
    int N; cin>>N;

    for (int i = 1; i < N; i ++) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
        deg[u] ++, deg[v] ++;
    }

    dp2[1] = 0;
    dfs(1, -1);
    dfs2(1, -1);

//    for (int i = 1; i <= N; i ++)
//        cout<<i<<" "<<dp[i]<<" "<<dp2[i]<<" "<<deg[i]<<endl;

    printf("%.8f\n", dp[1]);
    for (int i = 2; i <= N; i ++) {
        printf("%.8f\n", (dp[i] * (deg[i] - 1) + dp2[i]) * 1.0 / deg[i]);
    }
}

Measured memory_bytes: 18816
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

typedef struct {
	vector<int> edge;
	ll cost;
}node_t;
vector<node_t> node;

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

	node = vector<node_t>(N + 1);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		node[a].edge.push_back(b);
		node[b].edge.push_back(a);
	}

	ll total = 0;
	priority_queue<ll> C;
	for (int i = 0; i < N; i++) {
		ll c;
		cin >> c;
		total += c;
		C.emplace(c);
	}

	queue<int> q;
	vector<bool> visit(N + 1);
	q.push(1);
	visit[1] = true;
	node[1].cost = C.top();
	C.pop();

	while (!q.empty()) {
		int x = q.front();
		q.pop();

		for (auto to : node[x].edge) {
			if (visit[to]) continue;
			visit[to] = true;
			q.push(to);
			node[to].cost = C.top();
			C.pop();
		}
	}

	cout << total - node[1].cost << endl;
	for (int i = 1; i <= N; i++) {
		cout << node[i].cost << " ";
	}
	cout << endl;
}


Measured memory_bytes: 1152
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def half_divisor(x)
    ret=[]
    mx=(x**0.5).to_i
    1.upto(mx) do|i|
        if (x%i).zero?
          ret.push(i)
        end
    end
    return ret
end
N=gets.to_i
divs=half_divisor(N)
ans=0
divs.each do|x|
  val=(N/x)-1
  next if val.zero?
  ans+=val if N/val==N%val
end
puts ans

Measured memory_bytes: 14728
#include <stdio.h>
#include <stdbool.h>

int main(void){
	int N,x,i,j,tmp;

	//input
	scanf("%d %d",&N,&x);
	int a[N];
	for(i=0; i<N; i++){
		scanf("%d",&a[i]);
	}
	//sorting
	for(i=0; i<N; i++){
		for(j=i+1; j<N; j++){
			if(a[i]>a[j]){
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}
	//baramaki
	int ans=0;
	i=0;
	while(x>=a[i]){
		if(i==N-1){
			if(x==a[i]) {
				ans++;
			}
			break;
		}
		else{
			ans++;
			x= x-a[i];
			i++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

#define MAX 30000
pair<double,double> data[MAX];
double sY,sX;

int main(){
	int n;	cin>>n;
	for(int i=0;i<n;i++){
		double x,y;	cin>>x>>y;
		x+=(x/999900*100);
		y+=(y/999900*100);
		data[i]={x,y};
	}
	vector<double> angle(n);
	angle[0]=0;

	sX=data[0].first; sY=data[0].second;
	for(int i=1;i<n;i++){
		double y=(data[i].second - sY), x=(data[i].first - sX);

		angle[i]=atan2(y,x);
		while(angle[i-1]>=angle[i]){
			angle[i]+=2*M_PI;
		}
	}
	//angle[0]=1000;
	angle[0]=-1;

		pair<double,double> A,B,C,AB,BC,CA,BP,CP,AP;

	int q;	cin>>q;
	for(int i=0;i<q;i++){
		double x,y;	cin>>x>>y;

		double ang=atan2(y-sY,x-sX);
		while(ang<=angle[1])ang+=2*M_PI;
		// これで ang > angle[1] となったので、下の b>1 は確実？

		auto it=lower_bound(angle.begin(),angle.end(), ang);
		int a=it-angle.begin()-1, b=it-angle.begin();
		// b>1（すなわち a>=1）は確実（自信なし）

		// {{{ old
		// 		しかし a>=1 を保証するためにangを大きくしてしまったあまり、b>=n(範囲外！)をさす可能性
		// 		if(b>=n) b=1;
		// 		if(a>b)swap(a,b);
		// }}}

		// いや待てそもそもb>=nになった時点で三角の外なのでは？？？
		if(b>=n){
			cout<<"0"<<endl;
			continue;
		}

		//printf("A=[%d], B=[%d]\n",a,b);

		A={sX,sY};
		B={data[a].first, data[a].second};
		C={data[b].first, data[b].second};

		AB={B.first-A.first, B.second-A.second};
		BC={C.first-B.first, C.second-B.second};
		CA={A.first-C.first, A.second-C.second};

		BP={x-B.first, y-B.second};
		CP={x-C.first, y-C.second};
		AP={x-A.first, y-A.second};

		double c1=(AB.first*BP.second - AB.second*BP.first);
		double c2=(BC.first*CP.second - BC.second*CP.first);
		double c3=(CA.first*AP.second - CA.second*AP.first);

		if( (c1>=0 && c2>=0 && c3>=0)||(c1<0 && c2<0 && c3<0) ){
			cout<<"1"<<endl;
		}else cout<<"0"<<endl;
	}

	return 0;
}



Measured memory_bytes: 3880
import bisect 
s=int(input())
S=list(map(int,input().split()))
t=int(input())
T=sorted(list(map(int,input().split())))
ans=0
for x in T:
    ok = bisect.bisect(S,x)-1
    if S[max(ok,0)]==x:
        ans += 1
print(ans)



Measured memory_bytes: 16744
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct Mod {
    static constexpr auto kMod = 1000000007L;

    Mod() : n(0) {}
    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

int64_t dfs(const vector<vector<int64_t>>& adjs, vector<int64_t>& nums,
            int64_t v, int64_t p) {
    for (const auto& u : adjs[v]) {
        if (u == p) {
            continue;
        }

        nums[v] += dfs(adjs, nums, u, v);
    }

    return ++nums[v];
}

void solve(const vector<vector<int64_t>>& adjs, const vector<int64_t>& nums,
           vector<Mod>& ans, int64_t v, int64_t p) {
    int64_t n = adjs.size();
    for (const auto& u : adjs[v]) {
        if (u == p) {
            continue;
        }

        ans[u] = ans[v] * nums[u] / (n - nums[u]);
        solve(adjs, nums, ans, u, v);
    }
}

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

    vector<vector<int64_t>> adjs(n);
    for (auto i : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<int64_t> nums(n);
    dfs(adjs, nums, 0, -1);

    vector<Mod> ans(n);
    ans[0] = 1;
    for (auto i : irange(0L, n)) {
        ans[0] *= i + 1;
        ans[0] /= nums[i];
    }

    solve(adjs, nums, ans, 0, -1);

    for (auto a : ans) {
        cout << a.n << "\n";
    }
}

Measured memory_bytes: 17904
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}
long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  int N,K;
  int suki[40];
  cin>>N>>K;
  for(int i=0;i<40;i++){
    suki[i]=0;
  }
  for(int i=0;i<N;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int x;
      cin>>x;
      suki[x]++;
    }
  }
  int sum=0;
  for(int i=0;i<40;i++){
    if(suki[i]==N){
      sum++;
    }
  }
  cout<<sum<<endl;



}



  

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[20][20];

int main(void) {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	string ss = s;
	reverse(all(s));
	ll ans = 0;
	rep(i,0,1<<n){
		string s1;
		string s2;
		rep(j,0,n){
			if(((i>>j)&1)==1){
				s1+=s[j];
			}
			else{
				s2+=s[j];
			}
		}
		clr(dp,-1);
		dp[0][0] = 1;
		rep(j,0,n){
			rep(k,0,s1.sz){
				if(dp[j][k]==-1)continue;
				if(k<s1.sz&&ss[j]==s1[k]){
					if(dp[j+1][k+1]==-1){
						dp[j+1][k+1] = dp[j][k];
					}
					else{
						dp[j+1][k+1] += dp[j][k];
					}
				}
				if(j-k>=0&&j-k<s2.sz&&ss[j]==s2[j-k]){
					if(dp[j+1][k]==-1){
						dp[j+1][k] = dp[j][k];
					}
					else{
						dp[j+1][k] += dp[j][k];
					}
				}
			}
		}
		if(dp[n][s1.sz]!=-1){
			ans += dp[n][s1.sz];
		}
	}
	cout << ans*2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Graph II - Minimum Spanning Tree
 */
public class Main {

	static final int INF = 1 << 29;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int[][] a = new int[n][n];

		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int j = 0; j < n; j++) {
				a[i][j] = parseInt(st.nextToken());
			}
		}

		//solve
		int cost = 0;
		int size = 0;
		boolean[] S = new boolean[n];

		S[0] = true;
		size++;

		while (size < n) {
			int min = INF;
			int v = -1;
			for (int i = 0; i < n; i++) {
				if (S[i]) {
					for (int j = 0; j < n; j++) {
						if (!S[j] && a[i][j] != -1 && a[i][j] < min) {
							min = a[i][j];
							v = j;
						}
					}
				}
			}
			S[v] = true;
			size++;
			cost += min;
		}

		System.out.println(cost);
	}
}

Measured memory_bytes: 28196
#include<stdio.h>


int main(void){
  int n,m,h[100000],a[100000],b[100000];
  int i,j,c=0,x[100000];
  scanf("%d %d",&n,&m);
  for(i=1;i<=n;i++){
    scanf("%d",&h[i]);
    x[i]=1;
  }

  for(i=1;i<=m;i++){
    scanf("%d %d",&a[i],&b[i]);
    if(h[a[i]]==h[b[i]]){
      x[a[i]]=0;
      x[b[i]]=0;
    }

    if(h[a[i]]>h[b[i]]){
      x[b[i]]=0;
    }

    if(h[a[i]]<h[b[i]]){
      x[a[i]]=0;
    }
  }

  for(i=1;i<=n;i++){
    if(x[i]==1){
      c++;
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int sum[1000];
  sum[0]=1;
  for(int i=2;i<=999;++i) sum[i-1]=sum[i-2]+i;
  int i=1;
  while(1){
    if(sum[i-1]-a==sum[i]-b){
      cout<<sum[i]-b<<endl;
      break;
    }
    ++i;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int stack[110];
int top = 0;

void push(int v){ stack[top++] = v; }
int  pop(){ return stack[--top]; }


int main()
{
  char s[1000];
  while(scanf("%s",s)!=EOF)
    {
      if('0' <= s[0] && s[0] <= '9')//新しく読み込んだ要素が数字
		{
			int i,ret=0;
  			int size = strlen(s);
 			 for(i=0;i<size;i++)//何桁の整数か確認している
   	 		{
   		   		ret += (s[i]-'0')*pow(10,size-i-1);
   	 		}
		  push(ret);//新しい要素をプッシュする
		 continue;
		}
	  int a,b;//スタックの要素の上二つを演算にかける
	  b = pop();
	  a = pop();
	  if(s[0] == '+')
	      push(a+b);
	  else if(s[0] == '-')
	    push(a-b);
	  else if(s[0] == '*')
	    push(a*b);
	  else 
	    assert(0);
    }
  printf("%d\n",pop());//スタックにのっかてるやつ取りだす
  return 0;
}



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

struct Node {
	long long key;
	Node* left;
	Node* right;
};

void inseart(Node** root, Node* data) {
	if (*root == NULL) {
		*root = data;
		return;
	}
	Node* prev = NULL;
	Node* node = *root;
	while (node != NULL) {
		prev = node;
		if (node->key > data->key) {
			node = node->left;
		}
		else {
			node = node->right;
		}
	}
	if (prev->key > data->key) {
		prev->left = data;
	}
	else {
		prev->right = data;
	}
}

void visit(Node* root, vector<long long>& pre,vector<long long>& ino) {
	pre.push_back(root->key);
	if (root->left != NULL) {
		visit(root->left, pre, ino);
	}
	ino.push_back(root->key);
	if (root->right != NULL) {
		visit(root->right, pre, ino);
	}
}

void print(vector<long long>& v) {
	for (int i = 0; i < v.size(); i++) {
		cout << " " << v[i];
	}
}

void find(Node* root, long long key) {
	if (root == NULL) {
		cout << "no" << endl;
		return;
	}
	if (root->key == key) {
		cout << "yes" << endl;
		return;
	}
	else if (root->key > key) {
		find(root->left, key);
	}
	else {
		find(root->right, key);
	}
}

void del(Node** root, long long key) {
	if (root == NULL)return;

	if ((*root)->key == key) {

		if ((*root)->right != NULL && (*root)->left != NULL) {
			Node* node = (*root)->right;
			Node* prev = NULL;
			while (node != NULL) {
				prev = node;
				node = node->left;
			}
			(*root)->key = prev->key;
			del(&(*root)->right, prev->key);
		}
		else if ((*root)->right != NULL) {
			*root = (*root)->right;
		}
		else if ((*root)->left != NULL) {
			*root = (*root)->left;
		}
		else {
			*root = NULL;
		}
	}
	else if ((*root)->key > key) {
		del(&(*root)->left, key);
	}
	else {
		del(&(*root)->right, key);
	}
}


int main() {
	int n;
	int cnt = 0;
	Node node[500000];
	Node* root = NULL;

	cin >> n;
	for (int i = 0; i < n; i++) {
		string buf;
		vector<long long> pre;
		vector<long long> ino;
		long long k;
		cin >> buf;
		if (buf == "insert") {
			cin >> k;
			node[cnt].key = k;
			node[cnt].left = NULL;
			node[cnt].right = NULL;
			inseart(&root, &node[cnt]);
			cnt++;
		}
		else if (buf == "find") {
			cin >> k;
			find(root, k);
		}
		else if (buf == "delete") {
			cin >> k;
			del(&root, k);
		}
		else {
			visit(root, pre, ino);
			print(ino);
			cout << endl;
			print(pre);
			cout << endl;
		}
	}
	return 0;
}

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

int main(){
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < 5; i++) {
    if (i == 4)
    cout << a.at(i) << endl;
    else
    cout << a.at(i) << " ";
  }
}


Measured memory_bytes: 3112
def f(A, B):
    assert A <= B
    if A % 2 == 0 and B % 2 == 1:
        return ((B - A + 1) // 2) % 2
    if A % 2 == 0 and B % 2 == 0:
        return (((B - A) // 2) % 2) ^ B
    if A % 2 == 1 and B % 2 == 1:
        return A ^ (((B - A) // 2) % 2)
    if A % 2 == 1 and B % 2 == 0:
        return A ^ (((B - A - 1) // 2) % 2) ^ B


def main():
    A, B = list(map(int, input().split(' ')))
    print(f(A, B))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n =int(input())
p_100 = n // 100
tmp = n % 100
p_10 = tmp // 10
p_1 = tmp % 10
if p_100 == p_10:
    if p_10 == p_1:
        print(str(p_1) * 3)
    elif p_10 <= p_1:
        print(str(p_10+1) * 3)
    elif p_10 >= p_1:
        print(str(p_10) * 3)
elif p_100 <= p_10:
    print(str(p_100+1) * 3)
elif p_100 >= p_10:
    print(str(p_100) * 3)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<arr> matrix;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;
typedef map<int, arr> graph;
typedef vector<char> chararr;
typedef vector<chararr> charmat;
typedef pair<int, int> fraction;
ll MOD = 1000000007;
int n;
vector<int> gr[100000];
void  dfs(int src, int par, vector<vector<ll> > &dp) {
	if (gr[src].size() == 1 and gr[src][0] == par) {return;}
	for (auto it : gr[src]) {
		if (it != par)
		{	dfs(it, src, dp);
			dp[src][0] = (dp[src][0] * ((dp[it][0] + dp[it][1])%MOD))%MOD;
			dp[src][1] = (dp[src][1] * dp[it][0])%MOD;
		}
	}

}
int main() {
	cin >> n;
	ll x, y;
	for (int i = 0; i < (n - 1); ++i) {
		cin >> x >> y;
		x--; y--;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}

	if (n == 1) {cout << 2; return 0;}
	vector<vector<ll> > dp(n, vector<ll>(2, 1));
	dfs(0, -1, dp);
	cout << (dp[0][1] + dp[0][0]) % MOD;

}

Measured memory_bytes: 21120
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int s[100001];
	vpint hen;
	string S;
	scan(S);
	N=S.size();
	rep(i,N){
		s[i+1]=S[i]-'0';
	}
	int flag=1;
	if(s[N]==1) flag=0;
	if(s[1]==0) flag=0;
	rep1(i,N-1){
		if(s[i]!=s[N-i]) flag=0;
	}
	if(flag){
		int nownum=0;
		int ne=1;
		rep1(i,N){
			if(s[i]==1){
				rep1(j,i-nownum){
					hen.push_back(mp(ne,ne+j));
				}
				ne=ne+i-nownum;
				nownum=i;
			}
		}
		rep(i,hen.size()){
			printf("%d %d\n",hen[i].first,hen[i].second);
		}
	}
	else{
		prin(-1);
	}
	return 0;
}


Measured memory_bytes: 2804
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char s[100];
    cin>>s;
    if(s[0]=='S'&&s[1]=='A'&&s[2]=='T')
    {
        cout<<"1"<<endl;
    }
    if(s[0]=='S'&&s[1]=='U'&&s[2]=='N')
    {
        cout<<"7"<<endl;
    }
    if(s[0]=='M'&&s[1]=='O'&&s[2]=='N')
    {
        cout<<"6"<<endl;
    }
    if(s[0]=='T'&&s[1]=='U'&&s[2]=='E')
    {
        cout<<"5"<<endl;
    }
    if(s[0]=='W'&&s[1]=='E'&&s[2]=='D')
    {
        cout<<"4"<<endl;
    }
    if(s[0]=='T'&&s[1]=='H'&&s[2]=='U')
    {
        cout<<"3"<<endl;
    }
    if(s[0]=='F'&&s[1]=='R'&&s[2]=='I')
    {
        cout<<"2"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
int main(void)
{
char s[500];
double r;
scanf("%s",s);
r=atof(s);
printf("%f %f\n", r*r*3.14159265358979323, 3.14159265358979323*2*r);
return 0;
}

Measured memory_bytes: 1032
s = input()
n = len(s)
if (s == s[::-1] and s[: (n - 1) // 2] == s[: (n - 1) // 2][::-1] and s[(n + 3) // 2 - 1 :] == s[(n + 3) // 2 - 1 :][::-1]):
    print("Yes")
else:
    print("No")

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  float n, m = 0;
  cin >> n;
  rep(i, n) if((i+1) % 2 == 1) m++;
  cout << m / n << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int x=sc.nextInt();
		if(a<=x&&x<=a+b) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 22612
#include<stdio.h>
int main()
{
    int combi(int n);
    int n;
    int result;
    while (scanf("%d",&n) != EOF)
    {
        if(n>37)
        {
            result = 0;
        }
        else
        {
             result = combi(n);
        }

        printf("%d\n",result);
    }
	return 0;
}

int combi(n)
{
    int a,b,c,d;
    int count;
    count = 0;
    for (a=0;a<10;a++)
        for(b=0;b<10;b++)
            for(c=0;c<10;c++)
                for(d=0;d<10;d++)
        {
            if(a+b+c+d == n)
                count++;
        }
        return count;



}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>


using namespace std;
typedef long long ll;

int main(){
	ll n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	for(int i = 0; i < n; i++){
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
}




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

#define      sf           scanf
#define      pf           printf
#define      pb           push_back
#define      sz           200005
#define      read         freopen("in.txt", "r", stdin);
#define      write        freopen("out.txt", "w", stdout);
#define      optimize     ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef      long long int      ll;

int main()
{
	// read
	// write

	ll n, ans = 0;

	cin >> n;

	for(int i = 1; i <= n; i++)
	{
		if(i%3!=0 and i%5!=0) ans += i;
	}

	cout << ans << endl;
	



	return 0;
}

Measured memory_bytes: 3624
import sys
readline = sys.stdin.readline

import sys
from itertools import product
readline = sys.stdin.readline

def check1(A):
    K = max(A)
    table = [-1]*(K+1)
    for i in range(Q):
        table[A[i]] = i
    
    if -1 in table:
        return False
    if any(t1-t2 < 0 for t1, t2 in zip(table, table[1:])):
        return False
    return True

INF = 10**9+7
def check2(A):
    stack = []
    used = set()
    for a in A[::-1] + list(range(M)):
        if a not in used:
            used.add(a)
            stack.append(a)
    
    C = dict()
    for i in range(M):
        C[stack[i]] = i
    
    table = [0]*M + [INF]
    for a in A[::-1]:
        if table[C[a]] < table[C[a]-1]:
            table[C[a]] += 1
    
    used = set()
    ch = []
    for i in range(M):
        if table[i] < N:
            break
        ch.append(stack[i])
        used.add(stack[i])
    for i in range(M):
        if i not in used:
            used.add(i)
            ch.append(i)
    
    return stack == ch

N, M = map(int, readline().split())
Q = int(readline())
A = list(map(lambda x: int(x)-1, readline().split()))

ans = 'Yes'
if not check1(A):
    if not check2(A):
        ans = 'No'
print(ans)

Measured memory_bytes: 84052