akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const int N = 1<<18|3, B = 11;
struct node{int id,u,l;};
int n,v[N],w[N],q,ans[N],sz,len,a[N];vector<node>que[N];Pii b[N];

void dfs2(int id, int dep, int x, int y){
	if(x<0)return;
	if(dep>sz){
		umax(ans[id],y);
		return;
	}
	dfs2(id,dep+1,x,y);
	dfs2(id,dep+1,x-w[a[dep]],y+v[a[dep]]);
}
void dfs1(int id, int dep, int x, int y){
	if(x<b[1].fi)return;
	if(dep>sz){
		umax(ans[id],y+b[upper_bound(b+1,b+len+1,mp(x,0x3f3f3f3f))-b-1].se);
		return;
	}
	dfs1(id,dep+1,x,y);
	dfs1(id,dep+1,x-w[a[dep]],y+v[a[dep]]);
}
void dfs(int dep, int x, int y){
	if(dep>sz){
		b[++len]=mp(x,y);
		return;
	}
	dfs(dep+1,x,y);
	dfs(dep+1,x+w[a[dep]],y+v[a[dep]]);
}
int main() {
	read(n);
	rep(i,1,n)read(v[i]),read(w[i]);
	read(q);
	rep(i,1,q){
		int u,l;read(u);read(l);
		if(u<1<<B){
			sz=0;for(;u;u>>=1)a[++sz]=u;
			dfs2(i,1,l,0);
		}
		else{
			int x=u;while(x>=1<<B)x>>=1;
			que[x].pb((node){i,u,l});
		}
	}
	rep(i,1,n)if(SZ(que[i])){
		sz=len=0;for(int u=i;u;u>>=1)a[++sz]=u;
		dfs(1,0,0);sort(b+1,b+len+1);
		rep(j,2,len)umax(b[j].se,b[j-1].se);
		for(auto q:que[i]){
			sz=0;for(int u=q.u;u>i;u>>=1)a[++sz]=u;
			dfs1(q.id,1,q.l,0);
		//	umax(ans[q.id],);
		}
	}
	rep(i,1,q)printf("%d\n",ans[i]);
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  if(s[0]==s[1]&&s[1]==s[2]){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(s[1]==s[2]&&s[2]==s[3]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<pair<ll,ll> > shop(N);
	for (int i = 0; i < N; i++)cin >> shop[i].first >> shop[i].second;
	sort(shop.begin(), shop.end());
	ll ans = 0; ll drk = 0;

	for (int i = 0; i < N; i++) {
		if (shop[i].second <= M - drk) {
			ans += shop[i].first * shop[i].second;
			drk += shop[i].second;
		}
		else {
			ans += shop[i].first * (M - drk);
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    string s;
    cin >> s;
    int n = s.back() - '0';
    if(n == 3)cout << "bon\n";
    else if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon\n";
    else cout << "pon\n";
    return 0;
}

Measured memory_bytes: 3632
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
a=inp
ans = 0
h={}
f = 0
a.each do |d|
  f = 1 if(!(d.even?))
end
ans+=1 if(f == 0)
while(true)
  na = (a[1]+a[2])/2
  nb = (a[0]+a[2])/2
  nc = (a[0]+a[1])/2
  a = [na,nb,nc]
  f = 2 if(h[a] == true)
  h[a] = true 
  a.each do |d|
    f = 1 if(!(d.even?))
  end
  break if(f>0)
  ans += 1
end
p (f==1)? ans : -1
=begin
=end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;

ll c[51][51];

void combination(int n){

    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= i;j++){
            if(j == 0 || i == j){
                /*nC0 = 1、nCn = 1*/
                c[i][j] = 1LL;
            }else{
                c[i][j] = c[i-1][j-1] + c[i-1][j];
            }
        }
    }
}


int main(){


    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    REP(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end(),greater<ll>());
    combination(n);

    double ave = 0.0;
    REP(i,a){
        ave += v[i];
    }
    ave /= a;/*平均が求められた*/

    ll N = 0,R = 0;
    for(int i = 0;i < n;i++){
        if(v[i] == v[a-1]){
            N++;
            if(i < a){
                R++;
            }
        }
    }

    ll ans = 0;
    if(R == a){

        for(ll i = a;i <= b;i++){
            ans += c[N][i];
        }

    }else{
        ans += c[N][R];
    }
    printf("%.12f\n",ave);
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

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

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> dist(n-1);
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int> ());
    for(int i=0; i<n-1; i++){
        dist[i]=A[i]-A[i+1];
    }
    sort(dist.begin(), dist.end());
    
    if(dist.size()<=1){
        cout << A[0];
    }else{
        int M=max(dist[1], A[n-2]);
        int ans=1;
        for(int sub=M; sub>=2; sub--){
            int flag=0;
            for(int i=0; i<n; i++){
                if(A[i]%sub!=0){
                    flag++;
                }
                if(flag==2) break;
            }
            if(flag<=1){
                ans=sub;
                break;
            }
        }
        cout << ans;
    }

    
    return 0;
}

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

int main(){
  int a, b, c, k;
  cin >> a >> b>> c>> k;
  int sum=a;

  if(a>k) sum=k;
  if(a+b<k) sum-=k-(a+b);
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 3764
import numpy as np
 
data = int(input())
array = np.fromiter(map(int, input().split()), np.int64)
 
result = 0
for bit in range(60):
    array01 = int((array & 1).sum())
    result = (result + array01 * (data - array01) * (1 << bit)) % 1000000007
    array >>= 1
print(result)


Measured memory_bytes: 44524
#include <bits/stdc++.h>
using namespace std;
int main(){
//	freopen("loan.in","r",stdin);
//	freopen("loan.out","w",stdout);
	int a,b;
	cin>>a>>b;
	int c=a;
	a=max(a,b);
	b=min(b,c);
	for(int i=1;i<=a;i++) cout<<b;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong n,m;
llong y[100010],p[100010];
V yp[100010];

int main(){ _;
  cin>>n>>m;
  REP(i,m){
    llong yy,pp;
    cin>>pp>>yy;
    y[i] = yy; p[i] = pp;
    yp[pp-1].push_back(yy);
  }

  REP(i,n) VSORT(yp[i]);  
  REP(i,m){
    int index = lower_bound(yp[p[i]-1].begin(),yp[p[i]-1].end(),y[i])-yp[p[i]-1].begin()+1;
    printf("%06lld%06d\n",p[i],index);
  }
		 

  return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
//const int mx=1e5+7;
//int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
//vector<int> adj[mx];
//vector<int> ans;
//---dfs--
// bool visited[mx];
// vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---
const int N=203;
ll a[N],b[N],c[N];
ll dp[N][N][N];
int n,m,k;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		string s;
		cin>>s;
		int ans=0;
		if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') ans=3;
		else if((s[0]=='R'&& s[1]=='R')||(s[1]=='R'&&s[2]=='R')) ans=2;
		else if(s[0]=='R'||s[1]=='R'||s[2]=='R') ans=1;
		cout<<ans<<"\n";
 	}
}

Measured memory_bytes: 3644
n = int(input())
a = list(map(int, input().split()))
ans = 0
r = [0] * (n + 1)
for i, v in enumerate(a, start=1):
    r[i] = v + r[i - 1]

for i in range(n - 1):
    ans += a[i + 1] * r[i + 1]

print(ans % (10 ** 9 + 7))


Measured memory_bytes: 94180
#include<stdio.h>

int main(void){
  int n,m,i,c,d;
  int a[1000];

  for(;;){
    scanf("%d%d",&n,&m);
    if(n==0&&m==0)
      break;
    
    // init
    for(i=0;i<1000;i++)
      a[i]=0;
    
    i=0;
    d=0;
    while(1){     // Loop
      if(d==n-1)  // Finish
	break;    // ---> A
      else{
	c=0;
	while(1){   // Next Out Search
	  i++;
	  if(i>n)
	    i=1;
	  if(a[i]==0)
	    c++;
	  if(c==m){  // Out Person Match
	    a[i]++;
	    d++;
	    break;
	  }
	}
      }
    }
    // A ---> 
    for(i=1;i<=n;i++){
      if(a[i]==0){
	printf("%d\n",i);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int A, N;
	cin >> N >> A;
	if (N % 500 <= A)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A = input()
B = input()

if int(A) - int(B) == 0:
  	print('EQUAL')
else:
    if len(A) > len(B):
        print('GREATER')
    elif len(A) < len(B):
        print('LESS')
    else:
        i = 0
        while i < len(A):
            if A[i] > B[i]:
                print('GREATER')
                break
            elif A[i] < B[i]:
                print('LESS')
                break
            else:
                i += 0

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=3e3+10;
const int MOD=1e9+7;

int N;
double p[MAX];
void input(){
    cin>>N;
    rep1(i,N)cin>>p[i];
}

double dp[MAX][MAX];
void solve(){
    dp[0][0]=1;
    rep1(i,N)rep(up, i+1){
        if(up==0) dp[i][up]=dp[i-1][up]*(1-p[i]);
        else dp[i][up]=dp[i-1][up]*(1-p[i])+dp[i-1][up-1]*p[i];
    }
}

double ans;
void output(){
  	rep(up,N+1)if(up>N-up){
        ans+=dp[N][up];
    }
    cout<<fixed;
    cout<<setprecision(12)<<ans<<endl;
}

int main(){
    input();
    solve();
    output();
}

Measured memory_bytes: 69120
#include <stdio.h>
int main(){
	int a,b,t,i,ans=0;
	scanf("%d %d %d",&a,&b,&t);
	
	for(i=1;i<=(t/a);i++){
		if((i*a)<=t) ans=ans+b;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n, m, p;
	while (cin >> n >> m >> p&&n) {
		int x[1001] = {};
		int sum = 0;
		int t;
		for (int i = 1; i <= n; i++) {
			cin >> x[i];
			sum += x[i];
			if (i == m)t = x[i];
		}
		if (t == 0) {
			cout << 0 << endl;
		}
		else {
			cout << sum * (100 - p) / t << endl;
		}
	}
}

Measured memory_bytes: 3076
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long

int main()
{
    fastt;

    ll n, m, k, i, j, x, l, r, md, y, s=0, h, f=0, an = 0;
    cin>>n>>k;
    ll a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
        if(s<a[i])s=a[i];
    }
    l = 1;
    r = s;
    while(l<=r){
        f=0;
        md = (l+r)/2;
        s=0;
        for(i=0; i<n; i++){
            if(a[i]>md){
                x=a[i]/md;
                if(md*x==a[i])s+=x-1;
                else s+=x;
            }
            if(s>k){
                f=1;
                break;
            }
        }
        if(f==0){
            an = md;
            r=md-1;
        }
        else{
            l=md+1;
        }
    }
    cout<<an<<endl;
    return 0;
}






Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  //input_from_file;
  ll n,k,m,u,v;cin>>n>>m;
  vector<vector<char>> vec(n,vector<char>(m,'a'));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++) cin>>vec[i][j];
  }
  vector<vector<ll>> dp(n,vector<ll>(m,0));
  for(ll i=0;i<n;i++){
    if(vec[i][0]=='.')  dp[i][0]=1;
    else break;
  }
  for(ll i=0;i<m;i++){
    if(vec[0][i]=='.')  dp[0][i]=1;
    else break;
  }
  for(ll i=1;i<n;i++){
    for(ll j=1;j<m;j++){
      if(vec[i][j]=='.')  dp[i][j]=( dp[i-1][j]%mod + dp[i][j-1]%mod ) %mod;
    }
  }
  // for(ll i=0;i<n;i++){
  //   for(ll j=0;j<m;j++){
  //     cout<<dp[i][j]<<" ";
  //   }cout<<endl;
  // }
  cout<<dp[n-1][m-1]%mod;
  return 0;

}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define tci int t;scanf("%d",&t);while(t--)
#define tcl ll t;sl(t);while(t--) 
int main() 
{
    ll n;
    sl(n);
    ll c2=0,c4=0,prime=0;
    rep(i,n)
    {
        ll p;
        sl(p);
        if(p%2==0)
        {
            if(p%4==0)
                c4++;
            else
                c2++;
        }
        else
            prime++;
    }
    //cout<<c2<<c4<<prime;nl;
    c4-=prime;
    if(c2==0)
        c4++;
    if(c4>=0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}   

Measured memory_bytes: 384
import sys
inp=sys.stdin.readline()
sx,sy,tx,ty=map(lambda x: int(x), inp.split(' '))
ret=''
for i in range(ty-sy):
    ret=ret+'U'
for i in range(tx-sx):
    ret=ret+'R'
for i in range(ty-sy):
    ret=ret+'D'
for i in range(tx-sx+1):
    ret=ret+'L'
for i in range(ty-sy+1):
    ret=ret+'U'
for i in range(tx-sx+1):
    ret=ret+'R'
ret=ret+'DR'
for i in range(ty-sy+1):
    ret=ret+'D'
for i in range(tx-sx+1):
    ret=ret+'L'
ret=ret+'U'
print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}
 
//#define DEBUG

ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;

int main()
{
    cin >> N >> W;
    vector< pair<ll, ll> > data(N*4);
    ll base;
    int nums[4] = {0, 0, 0, 0};
    for (int i = 0; i < N; ++i) {
        pair<ll, ll> d;
        cin >> d.first >> d.second;
        if (i == 0)
            base = d.first;
        int num = d.first - base;
        data[num*N + nums[num]] = d;
        nums[num]++;
    }

    for (int i = 0; i < 4; ++i) {
        cerr << nums[i] << endl;
        sort(&data[i*N], &data[i*N + nums[i]], greater< pair<ll, ll> >());
        for (int j = 0; j < nums[i]; ++j) {
            cerr << j << " : " << data[i*N + j].first
            << ", " << data[i*N + j].second << endl;
        }
    }

    int max0 = min(nums[0], (int)(W / base));
    int max1 = min(nums[1], (int)(W / (base+1)));
    int max2 = min(nums[2], (int)(W / (base+2)));
    int max3 = min(nums[3], (int)(W / (base+3)));
    ll maxValue = 0;
    for (int i = 0; i <= max0; ++i) {
        ll weight = 0, value = 0;
        for (int j = 0; j < i; ++j) {
            pair<ll, ll> d = data[j];
            if (weight + d.first > W) break;
            weight += d.first;
            value += d.second;
        }

        for (int j = 0; j <= max1; ++j) {
            ll weight0 = weight, value0 = value;
            for (int k = 0; k < j; ++k) {
                pair<ll, ll> d = data[N + k];
                if (weight0 + d.first > W) break;
                weight0 += d.first;
                value0 += d.second; 
            }

            for (int k = 0; k <= max2; ++k) {
                ll weight1 = weight0, value1 = value0;
                for (int l = 0; l < k; ++l) {
                    pair<ll, ll> d = data[2*N + l];
                    if (weight1 + d.first > W) break;
                    weight1 += d.first;
                    value1 += d.second;
                }

                for (int l = 0; l <= max3; ++l) {
                    ll weight2 = weight1, value2 = value1;
                    for (int p = 0; p < l; ++p) {
                        pair<ll, ll> d = data[3*N + p];
                        if (weight2 + d.first > W) break;
                        weight2 += d.first;
                        value2 += d.second;
                    }
                    maxValue = max(maxValue, value2);
                }
            }
        }
    }

    cout << maxValue << endl;

    return 0;
}

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

using namespace std;

const int MAX_N = 100, MAX_M = 1000, MAX_C = 1000, INF = MAX_N * MAX_C;

int n, m, ans = 0;
int a[MAX_M + 1], b[MAX_M + 1], c[MAX_M + 1];
int d[MAX_N + 1][MAX_N + 1];

bool isGood[MAX_M + 1];

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

    cin >> n >> m;

    for (int e = 1; e <= m; e++) {
        cin >> a[e] >> b[e] >> c[e];
    }

    for (int e = 1; e <= m; e++) {
        isGood[e] = true;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            d[i][j] = INF;
        }
    }

    for (int i = 1; i <= n; i++) {
        d[i][i] = 0;
    }

    for (int e = 1; e <= m; e++) {
        d[a[e]][b[e]] = min(d[a[e]][b[e]], c[e]);
        d[b[e]][a[e]] = min(d[b[e]][a[e]], c[e]);
    }

    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    for (int e = 1; e <= m; e++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (d[i][j] == d[i][a[e]] + d[b[e]][j] + c[e]) {
                    isGood[e] = false;
                }

                if (d[i][j] == d[i][b[e]] + d[a[e]][j] + c[e]) {
                    isGood[e] = false;
                }
            }
        }
    }

//    for (int i = 1; i <= n; i++) {
//        for (int j = 1; j <= n; j++) {
//            cout << d[i][j];
//
//            if (j < n) {
//                cout << ' ';
//            } else {
//                cout << '\n';
//            }
//        }
//    }

    int ans = 0;
    for (int e = 1; e <= m; e++) {
        if (isGood[e]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
/*
Author : N_o_o_B
Created : January 12 2020 12:06:41 
*/
#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 TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vi a(n);
    fori(i,n) cin >> a[i];
    int num = -1;
    bool ok = 1;
    ll cur_lcm = 1;
    fori(i,n){
        a[i] /= 2;
        int tmp = a[i];
        int cnt = 0;
        while(tmp%2 == 0){
            tmp /= 2;
            cnt++;
        }
        ok &= (num == -1 or num == cnt);
        num = cnt;
        cur_lcm = cur_lcm*a[i]/__gcd((ll)a[i],cur_lcm);
    }
    num = m/cur_lcm;
    int ans = ok * (num+1)/2;
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 640
import sys

n = int(input())

s = input()

count_w = s.count('W')
count_r = n - count_w

if count_w == 0 or count_r == 0:
    print(0)
    sys.exit()

sa = s[:count_r]
sb = s[count_r:]
num_sa = sa.count('W')
num_sb = sb.count('R')
if num_sa <= num_sb:
    print(num_sa)
else:
    print(num_sb)

Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define db double
#define ll long long
const int INF = 1e9;
vector<int> solve(int x, int y){
    vector<int> res(x);
    for (int i=0;i<x;i++){
        if ((i%y) == y-1){
            res[i] = -INF;
        }
        if ((i%y) == ((x%y)-1)){
            res[i] = INF-1;
        }
    }
    return res;
}
main(){  
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a%c==0 && b%d==0){
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    if (b%d != 0){
        vector<int> res = solve(b, d);
        for (int i=0;i<a;i++){
            for (int j=0;j<b;j++) cout << res[j] << " ";
            cout << endl;
        }
        return 0;
    }
    vector<int> res = solve(a, c);
    for (int i=0; i < a; i++){
        for (int j=0;j<b;j++) cout << res[i] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main (){
    char a[10][10];
    for(int i=0;i<3;i++)
        scanf("%s",&a[i]);
    printf("%c%c%c\n",a[0][0],a[1][1],a[2][2]);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

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

    int D, N;
    cin >> D >> N;
    if (N == 100) N = 101;
    ll ans = N * pow(100, D);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string s;
    int n;
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        int temp=s[i]-'A';
        temp+=n;
        temp%=26;
        s[i]=temp+'A';
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
	int N;
	int i = 1;
	cin >> N;
	while (pow(2,i) <= N)i++;
	cout << pow(2, i - 1) << endl;
	return 0;
}

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


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, input().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    h, a = MI()

    ans = h // a
    if h % a != 0:
        ans += 1
    print(ans)


main()


Measured memory_bytes: 64836
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<vector<int> > E(n, vector<int>());
  REP(i, n){
    int u, k; cin >> u >> k; u--;
    REP(j, k){
      int v; cin >> v; v--;
      E[u].push_back(v);
    }
  }
  vector<int> d(n, -1);
  vector<bool> dd(n, false);
  d[0] = 0;
  dd[0] = true;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int cur = q.front(); q.pop();
    for(auto &i : E[cur]){
      if(dd[i]) continue;
      d[i] = d[cur] + 1;
      q.push(i);
      dd[i] = true;
    }
  }
  REP(i, n){
    cout << i+1 << " " << d[i] << endl;
  }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
string s,t;
int n;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	cin >> s >> t;
	for(int i = 0;i < n;i++){
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int n, k;
vector<char> used;
vector<int> dist;
vector<vector<int>> g;

void DFS(int u) {
    used[u] = true;
    for (int v : g[u]) {
        if (!used[v]) {
            dist[v] = dist[u] + 1;
            DFS(v);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> k;

    g.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int answer = n + 1;

    if (k % 2 == 0) {
        for (int u = 0; u < n; ++u) {
            used.assign(n, false);
            dist.assign(n, 0);
            DFS(u);

            int currentAnswer = 0;
            for (int v = 0; v < n; ++v)
                if (2 * dist[v] > k)
                    ++currentAnswer;

            answer = min(answer, currentAnswer);
        }
    } else {
        for (int u = 0; u < n; ++u) {
            for (int v : g[u]) {
                used.assign(n, false);
                dist.assign(n, 0);

                used[u] = used[v] = true;

                DFS(u);
                DFS(v);

                int currentAnswer = 0;
                for (int i = 0; i < n; ++i)
                    if (dist[i] * 2 + 1 > k)
                        ++currentAnswer;

                answer = min(answer, currentAnswer);
            }
        }
    }

    cout << answer << endl;

    return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  uint64_t a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}




Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
bool flag=false;
using pii = pair<int, int>;
int hoge=0;
int h,w;
bool inrange(int y,int x){return (0<=x&&x<w&&0<=y&&y<h);}
void dfs(int cnt,pii now,vector<vector<char>>graph){
    if(cnt==hoge&&now==pii(h-1,w-1))flag=true;
    if(inrange(now.first+1,now.second)&&graph[now.first+1][now.second]=='#'){
        dfs(cnt+1,pii(now.first+1,now.second),graph);
    }
    if(inrange(now.first,now.second+1)&&graph[now.first][now.second+1]=='#'){
        dfs(cnt+1,pii(now.first,now.second+1),graph);
    }
    return;
}
int main(){
    cin>>h>>w;
    vector<vector<char>>graph(h,vector<char>(w));
    rep(i,h)rep(j,w){
        cin>>graph[i][j];
        if(graph[i][j]=='#')hoge++;
    }
    dfs(1,pii(0,0),graph);
    if(flag)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


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

typedef long long ll;

int n;
ll a, b;
vector<ll> h;

bool can(ll& x) {
    ll m = 0;
    for (auto&& i : h) {
        ll hi = i - x*b;
        if (hi <= 0) continue;
        m += ceil(1.0 * hi / (a - b));
    }
    return m <= x;
}


int main() {
    cin >> n >> a >> b;
    h.resize(n);
    for (auto&& i : h) scanf("%lld", &i);

    ll lb = -1, ub = 1145141919;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if (can(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int g = A[0];
  for (int i = 0; i < N; i++) {
    g = gcd(g, A[i]);
  }
  for (int i = 0; i < N; i++) {
    if (A[i] >= K && (A[i] - K) % g == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int count(int b);
int n,k;

int main(){
 scanf("%d%d",&n,&k);
 long res = 0;
 for(int b=k+1;b<=n;b++){
        res +=count(b);
 }
 printf("%ld\n",res);
}

int count(int b){
 int sum = 0;
 int x = n/b;
 int y = n%b;

 sum += x*(b-k);
 sum += max(y-k+1,0);
 if(k==0) sum--;
 return sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll l = 0;
    ll r = 1000000000;

    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        ll now = 0;
        rep(i, n)
        {
            now += (a[i] - 1) / mid;
        }
        if (k >= now)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 4592
import sys

list = list(map(int, input().split()))
length_list = map(int, input().split())

N = list[0]
X = list[1]

i = 1
total = 0

for len in length_list:
  total = total + len
  if total <= X:
    i = i + 1
    if i == N + 1:
      print(i)
  else:
    print(i)
    sys.exit()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<fstream>
#include<cstring>
#define Maxn 100000
using namespace std;
int N;
int dian[Maxn+5]={0};
int cnt[20]={0};
int ans=0;
int f[1<<20];
int Xor[1<<20]={0};
int main()
{
	//memset(f,0x3f,sizeof(f));
	scanf("%d",&N);
	for(int i=1,x,y,c;i<N;i++){
		scanf("%d%d%d",&x,&y,&c);
		x+=1,y+=1;
		dian[x]^=c;
		dian[y]^=c;
	}
	for(int i=1;i<=N;i++)cnt[dian[i]]++;
	int tot=0;
	for(int i=1;i<=15;i++)ans+=(cnt[i]/2),tot|=((1&cnt[i])<<(i-1));
	//for(int i=1;i<=N;i++)cout<<dian[i]<<endl;
	for(int i=1;i<(1<<15);i++)f[i]=f[i>>1]+(i&1);
	for(int i=1;i<(1<<15);i++)f[i]-=1;
	for(int s=1;s<(1<<15);s++){
		for(int i=1;i<=15;i++){
			if((s>>(i-1))&1)
			Xor[s]^=i;
		}
	}
	for(int s=1;s<(1<<15);s++){
		if(Xor[s])continue;
		for(int k=(s-1)&s;k;k=(k-1)&s){
			if(Xor[k])continue;
			f[s]=min(f[s],f[k]+f[s^k]);
		}
	}
	cout<<ans+f[tot];
	return 0;
} 

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

typedef long long LL;

#define int LL

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        int A, B, C, D; scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        int len = (max(A, B) + min(A, B)) / (min(A, B) + 1);
        int l = 0, r = 1e9, mid, pos = -1;
        while (l <= r) {
            mid = (l + r) >> 1;
            int t1 = A - mid / (len + 1) * len - mid % (len + 1);
            int t2 = B - mid / (len + 1);
            int h1 = t1 * len + (mid % (len + 1) || !mid ? len : 0);
            if (t1 >= 0 && t2 >= 0 && h1 >= t2) pos = mid, l = mid + 1;
            else r = mid - 1;
        } 
        assert(pos >= 0);
        for (int i = C; i <= min(D, pos); i++) 
            putchar(i % (len + 1) ? 'A' : 'B');
        for (int i = min(D, max(pos, C - 1)) + 1; i <= D; i++) 
            putchar((A + B - i + 1) % (len + 1) ? 'B' : 'A');
        puts("");
    }
    return 0;
}

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

const int limit = 100010;
using edge = struct {int to; int color; int id;};
vector<edge> tree[limit];
int col[limit];
int k;

void dfs(int v, int p, int no){
    int id = 1;
    for(auto &e : tree[v]) {
        if(e.to == p) continue;
        if(id == no) id++;
        dfs(e.to, v, id);
        col[e.id] = id;
        k = max(id, k);
        id++;
    }
}

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

    int n;
    cin >> n;

    int id = 0;
    k = 0;

    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        tree[a].push_back({b, 0, id});
        tree[b].push_back({a, 0, id});
        id++;
    }

    dfs(0, -1, -1);

    cout << k << endl;
    for(int i = 0; i < n-1; i++){
        cout << col[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  int ans = 0;
  rep(i, 0, 4) ans += (s[i] == '2');
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func Amin(nums ...int) int {
	min := -1
	for _, num := range nums {
		if min == -1 {
			min = num
		}
		if min > num {
			min = num
		}
	}
	return min
}

func main() {
	var a, b, c, x, y int
	var high, low, highCost int
	fmt.Scan(&a, &b, &c, &x, &y)
	if x >= y {
		high, low = x, y
		highCost = a
	} else {
		high, low = y, x
		highCost = b
	}
	p1 := a*x + b*y
	p2 := low*2*c + (high-low)*highCost
	p3 := high * 2 * c
	fmt.Println(Amin(p1, p2, p3))
}


Measured memory_bytes: 512
#include<iostream>

int main(){

	double min_v;
	while (std::cin >> min_v){

		double t = min_v / 9.8;
		double sum = 4.9*t*t;

		std::cout << (int)(sum + 5) / 5 + 1 << std::endl;
	}

	return 0;
}

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

void call(int n){
	int i = 1;
	do{
		int x = i;
		if ( x % 3 == 0 ){
			cout << " " << i;
			continue;
		}
		do{
			if ( x % 10 == 3 ){
				cout << " " << i;
				break;
			}
			x /= 10;
		}while(x);
	}while(++i<=n);
	cout << endl;
}


int main() {
	int n;cin>>n;
	call(n);
}

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

struct StronglyConnectedComponents{
    vector<vector<int>> G,rG,C,T;
    vector<int> vs,cmp,used;
    StronglyConnectedComponents(int n):G(n),rG(n),cmp(n),used(n){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        rG[v].emplace_back(u);
    }
    void dfs(int v){
        used[v]=1;
        for (int u:G[v]) if(!used[u]) dfs(u);
        vs.emplace_back(v);
    }
    void rdfs(int v,int k){
        used[v]=1;
        cmp[v]=k;
        C[k].emplace_back(v);
        for (int u:rG[v]) if (!used[u]) rdfs(u,k);
    }
    int build(){
        int n=G.size();
        for (int i=0;i<n;++i) if (!used[i]) dfs(i);
        fill(used.begin(),used.end(),0);
        int k=0;
        for (int i=n-1;i>=0;--i){
            if (!used[vs[i]]){
                C.emplace_back(),T.emplace_back();
                rdfs(vs[i],k++);
            }
        }
        for (int v=0;v<n;++v) for (int u:G[v]){
            if (cmp[v]!=cmp[u]) T[cmp[v]].emplace_back(cmp[u]);
        }
        for (int i=0;i<k;++i){
            sort(T[i].begin(),T[i].end());
            T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
        }
        return k;
    }
    int operator[](int i) const{
        return cmp[i];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    StronglyConnectedComponents SCC(N);
    for (int i=0;i<M;++i){
        int a,b; cin >> a >> b;
        SCC.add_edge(a,b);
    }
    cout << SCC.build() << '\n';
    for (int i=0;i<SCC.C.size();++i){
        cout << SCC.C[i].size();
        for (int v:SCC.C[i]) cout << ' ' << v;
        cout << '\n';
    }
}

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

#define ff first
#define ss second
#define ll long long
#define W(x) cerr << "\033[31m"<< #x << " = " << x << "\033[0m" << endl;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;
ll oo2 = 1ll*oo*oo; 


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

    string m = s.substr(5, 2);
    string y = s.substr(0, 4);
    W(stoi(m)); W(stoi(y));
    if(stoi(m) > 4 or stoi(y) > 2019) {
        puts("TBD");
    } else {
        puts("Heisei");
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<complex>
double PI=acos(-1);

template<typename T>
class FFT{
  private:
    using Complex = std::complex<double>;
    std::vector<Complex> C;
    void DFT(std::vector<Complex> &F,int n,int sig=1){
        if(n==1) return;
        std::vector<Complex> f0(n/2),f1(n/2);
        for(int i=0;i<n/2;++i){
            f0[i]=F[2*i];
            f1[i]=F[2*i+1];
        }
        DFT(f0,n/2,sig);
        DFT(f1,n/2,sig);
        Complex z(cos(2.0*PI/n),sin(2.0*PI/n)*sig),zi=1;
        for(int i=0;i<n;++i){
            if(i<n/2) F[i]=f0[i]+zi*f1[i];
            else F[i]=f0[i-n/2]+zi*f1[i-n/2];
            zi*=z;
        }
        return;
    }
    void invDFT(std::vector<Complex> &f,int n){
        DFT(f,n,-1);
        for(int i=0;i<n;++i){
            f[i]/=n;
        }
        return;
    }
  public:
    FFT(const std::vector<T> &A,const std::vector<T> &B){
        int n=1;
        while(n<=A.size()+B.size()){
            n*=2;
        }
        std::vector<Complex> h(n,Complex(0)),g(n,Complex(0));
        for(int i=0;i<n;++i){
            if(i<A.size()) h[i]=Complex(A[i]);
            if(i<B.size()) g[i]=Complex(B[i]);
        }
        DFT(h,n);
        DFT(g,n);
        C.resize(n);
        for(int i=0;i<n;++i) C[i]=h[i]*g[i];
        invDFT(C,n);
        for(int i=0;i<n;++i) if(T(C[i].real())!=C[i].real()){
            C[i]=Complex(C[i].real()+0.5);
        }
    }
    T operator[](int k)const{return C[k].real();}
};

int main(){
    int N;
    long long M;
    std::cin>>N>>M;
    std::vector<int> A(N);
    int MAX_A=0;
    for(int i=0;i<N;++i){
        std::cin>>A[i];
        MAX_A=std::max(MAX_A,A[i]);
    }
    std::vector<long long> cnt(MAX_A+1);
    for(int i=0;i<N;++i){
        cnt[A[i]]++;
    }
    FFT<long long> C(cnt,cnt);
    long long ans=0;
    for(int i=2*MAX_A;i>=0;--i){
        if(M>=C[i]){
            ans+=i*C[i];
            M-=C[i];
        }else{
            ans+=i*M;
            break;
        }
    }
    std::cout<<ans<<std::endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<long int> a(n+1);
  rep(i,n) cin >> a[i];
  for(int i = 1;i <= n-k;i++) {
    string ans = "No";
    if(a[i] < a[i+k]) ans = "Yes";
    cout << ans << endl;
  }
}

Measured memory_bytes: 4824