akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int n;
    cin >> n;
    V<int> cnt(30, 11000);
    rep(i, n) {
        V<int> pc(30);
        string s;
        cin >> s;
        for (auto c : s) {
            pc[c - 'a']++;
        }
        rep(j, 30) chmin(cnt[j], pc[j]);
    }
    string ans;
    rep(i, 30) rep(j, cnt[i]) ans.pb('a' + i);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int par[200000];
int fnd(int k)
{
    return par[k]==k?k:par[k]=fnd(par[k]);
}
int w[200000];
bool cmp(const pair<pair<int,int>,int> &a,const pair<pair<int,int>,int> &b)
{
    return a.second<b.second;
}
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    vector<pair<pair<int,int>,int> > cross;
    for (int i=0;i<n;++i)
        w[i]=2000000000;
    for (int i=0;i<q;++i)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        cross.push_back(make_pair(make_pair(a,b),c));
        if (c+1<w[a])
            w[a]=c+1;
        if (c+2<w[b])
            w[b]=c+2;
    }
    for (int i=0;i<n;++i)
        w[(i+1)%n]=min(w[(i+1)%n],w[i]+2);
    for (int i=0;i<n;++i)
        w[(i+1)%n]=min(w[(i+1)%n],w[i]+2);
    for (int i=0;i<n;++i)
        cross.push_back(make_pair(make_pair(i,(i+1)%n),w[i]));
    sort(cross.begin(),cross.end(),cmp);
    for (int i=0;i<n;++i)
        par[i]=i;
    long long ans=0;
    for (auto &c:cross)
    {
        int u=c.first.first,v=c.first.second;
        if (fnd(u)!=fnd(v))
        {
            par[fnd(u)]=fnd(v);
            ans+=c.second;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 10732
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<P> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    Graph M(N);
    rep(i, N){
        int u, k;
        cin >> u >> k;
        rep(j, k){
            int v, c;
            cin >> v >> c;
            M[u].push_back(P(v, c));
        }
    }

    vector<int> d(N, INF), p(N, -1);
    vector<bool> seen(N, false);
    d[0] = 0;

    while(1){
        int mincost = INF;
        int u;

        rep(i, N){
            if(!seen[i] && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(mincost == INF) break;
        seen[u] = true;

        rep(i, M[u].size()){
            int v = M[u][i].first, c = M[u][i].second;
            if(!seen[v] && d[u] + c < d[v]){
                d[v] = d[u] + c;
                p[v] = u;
            }
        }
    }

    rep(i, N){
        cout << i << ' ' << d[i] << endl;
    }

}


Measured memory_bytes: 7464
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int W=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int z=Math.abs(a-b);
		if(z<=W) {
			z=0;
		}else{
			z=z-W;
		}
		System.out.println(z);


	}

}

Measured memory_bytes: 21712
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const int LIM=1000010;
bool sosu[LIM];

int main() {
	int i;
	for(i=0;i<LIM;i++)sosu[i]=true;
	sosu[0]=sosu[1]=false;
	int j;
	for(i=0;i<LIM;i++){
		if(!sosu[i])continue;
		for(j=i+i;j<LIM;j+=i){
			sosu[j]=false;
		}
	}
	int a,d,n;
	while(a=in(),d=in(),n=in()){
		while(true){
			if(sosu[a]){
				n--;
				if(n==0)break;
			}
			a+=d;
		}
		cout<<a<<endl;
	}
	return 0;
}

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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c =='o' || c== 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

ans = ""
ans += "R"*(tx-sx)
ans += "U"*(ty-sy)
ans += "L"*(tx-sx)
ans += "D"*(ty-sy)
ans += "D"
ans += "R"*(tx-sx+1)
ans += "U"*(ty-sy+1)
ans += "L"
ans += "U"
ans += "L"*(tx-sx+1)
ans += "D"*(ty-sy+1)
ans += "R"

print(ans)


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

int H, A;

int main() {
    cin >> H >> A;
    if (A >= H) { cout << 1 << endl; return 0; }
    int cnt = 0;
    while (H > 0) {
        H -= A;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main()
{
    int n, m;
    string str1, str2;
    while (true)
    {
        cin >> str1;
        if (str1 == "-")
        {
            break;
        }
        cin >> n;
        for (int i = 0; i != n; ++i)
        {
            cin >> m;
            str2 = str1.substr(0, m);
            str1 = str1.substr(m, str1.size() - m);
            str1 += str2;
        }
        cout << str1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MOD 1000000007
int key,dp[10005][2][102];
vector<int> res;
int digit_dp(int idx,int tight,int ds)
{
	if(idx==-1&&ds==0)
	return 1;
	if(idx==-1)
	return 0;
	if(dp[idx][tight][ds]!=-1&&tight!=1)
	return dp[idx][tight][ds];
	int total=0,k=(tight==1)?res[idx]:9;
	for(int i=0;i<=k;i++)
	{
		int nt=(res[idx]==i)?tight:0;
		total=(total+digit_dp(idx-1,nt,(ds+i)%key))%MOD;
	}
	if(!tight)
	dp[idx][tight][ds]=total%MOD;
	return total%MOD;
}
signed main()
{
	string s;
	cin>>s;
	cin>>key;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		int v=(int)(s[i]-'0');
		res.push_back(v);
	}
	reverse(res.begin(),res.end());
	memset(dp,-1,sizeof(dp));
	int x=digit_dp(len-1,1,0)-1;
	if(x<0)
	x=x+MOD;
	cout<<x<<"\n";
}

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

const int MOD=1e9+7;

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

Measured memory_bytes: 6388
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;


int main() {

	string s;
	cin >> s;
	if (s == "SUN")cout << 7 << endl;
	if (s == "MON")cout << 6 << endl;
	if (s == "TUE")cout << 5 << endl;
	if (s == "WED")cout << 4 << endl;
	if (s == "THU")cout << 3 << endl;
	if (s == "FRI")cout << 2 << endl;
	if (s == "SAT")cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll A, B;
  cin >> A >> B;
  if (A + B >= 10) {
    COUT("error");
  } else {
    COUT(A + B);
  }
  return 0;
}

Measured memory_bytes: 3612
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

if aL%2 and aJ%2 and aI > 0:
    print(int((aI-1)/2)*2+aO+int(aJ/2)*2+int(aL/2)*2+3)
elif aI%2 and (aL%2 or aJ%2) and aL > 0 and aJ > 0:
    print(int(aI/2)*2+aO+int((aJ-1)/2)*2+int((aL-1)/2)*2+3)
else:
    print(int(aI/2)*2+aO+int(aJ/2)*2+int(aL/2)*2)


Measured memory_bytes: 3064
uses crt;
var
  w: array [0..100] of int64;
        v: array [0..100] of longint;
        c: array [0..100000] of int64;
        m,n,i,j,sum,k: longint;


begin
        clrscr;
        readln ( n, m);
        for i:=1 to n do
        begin
                readln ( w[i], v[i]);
                sum:= sum + v[i];
        end;

        c[0]:= 0;
        for i:=1 to sum do c[i]:= 100000000000;

        for i:=1 to n do
        begin
                j:= sum;
                while j >= v[i]  do
                begin
                        if c[j- v[i]] + w[i] <= c[j] then
                        c[j]:= c[j- v[i]] + w[i];
                        dec (j);
                end;
        end;

        for i:= sum downto 1 do
        if c[i] <= m then
        begin
                write ( i);
                break;
        end;
        readln;
end.


Measured memory_bytes: 896
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,k=map(int,input().split())
mod=10**9+7

red=n-k
sep=red+1


for i in range(1,1+k):
    if i>sep:
        print(0)
        continue
    blue=k-i
    ans=cmb(i+blue-1,blue)*cmb(sep,i)%mod
    print(ans)


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

const int MOD = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> a;
    a.resize(H);

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

    int dp[H][W];

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                continue;
            }

            // left
            if (j - 1 >= 0 && a[i][j - 1] == '.') {
                dp[i][j] += dp[i][j - 1];
            }
            // up
            if (i - 1 >= 0 && a[i - 1][j] == '.') {
                dp[i][j] += dp[i - 1][j];
            }

            dp[i][j] %= MOD;
        }
    }

    /*
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
     */

    cout << dp[H - 1][W - 1] % MOD << endl;
    return 0;
}

Measured memory_bytes: 5248
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

import math

a,b = input().split()
a = a+b
a = int(a)

if math.sqrt(a)==(math.sqrt(a))//1:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> sushi(n);
  vector<ll> f(n + 1);
  unordered_map<int, int> um;
  rep(i, n) { cin >> sushi.at(i).second >> sushi.at(i).first; }
  sort(sushi.begin(), sushi.end(), greater<pair<int, int>>());
  // priority_queue<pair<int, int>, vector<pair<int, int>>,
  //                greater<pair<int, int>>>
  //     pq;

  ll sum = 0;
  rep(i, k) {
    int type = sushi.at(i).second;
    if (um.count(type)) {
      um.at(type) += 1;
    } else {
      um.emplace(type, 1);
    }
    sum += sushi.at(i).first;
    // pq.push(sushi.at(i));
  }
  f.at(um.size()) = sum + um.size() * um.size();

  int from = k - 1;
  int to = k;

  ll maxval = f.at(um.size());
  if (n == k) {
    cout << maxval << endl;
    return 0;
  }
  while (true) {
    int ftype = sushi.at(from).second;
    int fpt = sushi.at(from).first;
    int ttype = sushi.at(to).second;
    int tpt = sushi.at(to).first;
    bool fstop = true;
    bool tstop = true;
    if (um.at(ftype) == 1) {
      from--;
      fstop = false;
    }
    if (um.count(ttype) != 0) {
      to++;
      tstop = false;
    }
    if (fstop && tstop) {
      int usize = um.size();
      f.at(usize + 1) =
          f.at(usize) - fpt + tpt - usize * usize + (usize + 1) * (usize + 1);
      um.emplace(ttype, 1);
      maxval = max(f.at(usize + 1), maxval);
      um.at(ftype) -= 1;
      from--;
      to++;
    }
    if (from == -1 || to == n) {
      break;
    }
  }
  cout << maxval << endl;
  return 0;
}


Measured memory_bytes: 5260
#include <iostream>

using namespace std;

int main(){
    int N,T;
    cin >> N;
    cin >> T;
    int c[N],t[N];
    for(int i = 0; i < N; i++){
        cin >> c[i];
        cin >> t[i];
    }
    int min = 1000;
    int tle = 0;
    for(int j = 0; j < N; j++){
        if(t[j] <= T){
            if(c[j] <= min){
                min = c[j];
                tle = 1;
            }
        }
    }
    if(tle){
        cout << min << endl;
    }else{
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 764
/*input
Sunny
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll sub(ll x,ll y){
    return (x % MOD - y % MOD + MOD) % MOD;
}
ll mult(ll a,ll b) 
{ 
    return ((a%MOD)*(b%MOD))%MOD;
} 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string arr[3]={"Sunny", "Cloudy", "Rainy"};
    string a;
    cin>>a;
    REP(i,3){
        if(arr[i]==a){
            cout<<arr[(i+1)%3];
            return 0;
        }
    }
}

Measured memory_bytes: 256
#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 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	i_os;
	ll n;
	cin>>n;
	vector<ll> arr(n+1);
	vector<bool> prime(n+1);
	REP(i,1,n+1){
		arr[i] = i;
		prime[i] = 1;
	}
	REP(i,2,sqrt(n) + 1){
		if(prime[i])
		{
			for(ll j = i;j <= n/i; j++){
				prime[i*j] = 0;
				if(arr[i*j] == i*j){
					arr[i*j] = i;
				}
			}
		}
	}

	vector<ll> ans(n+1);
	REP(i,1,n+1) ans[i] = 1;
	REP(i,2,n+1){
		ll val2 = i;
		ll ct = 0;
		while(val2 % arr[i] == 0){
			val2 /= arr[i];
			ct++;
		} 
		ans[i] = (ct+1)*ans[val2];
	}
	ll p = 0;
	REP(i,1,n+1){
		p += i*ans[i];
	}
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 160820
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans=0;
int arr[200005];
int absx(int p)
{
	return p>0?p:-p;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    {
	       scanf("%d",&arr[i]);
	       arr[i]-=i;
	    }
	sort(arr+1,arr+1+n);
	int b=arr[(n+1)/2];
	for(int i=1;i<=n;i++)
	    ans+=(long long)absx(arr[i]-b);
	printf("%lld",ans);	    
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner
import kotlin.system.exitProcess

val arr = BooleanArray(10){true}
fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val k = scanner.nextInt()
	repeat(k){ arr[scanner.nextInt()]=false }
	rec(n)
}

fun rec(n: Int) {
	val cs = n.toString().toCharArray()
	val strBld = StringBuilder()
	cs.forEachIndexed { i, c ->
		val d = c.toString().toInt()
		if (!arr[d]) {
			for (a in d + 1..9) {
				if (arr[a]) {
					strBld.append(a)
					repeat(cs.size - i - 1) { strBld.append(arr.indexOf(true)) }
					ans(strBld)
				}
			}
			var add=1
			repeat(cs.size-i){
				strBld.append(arr.indexOf(true))
				add*=10
			}
			rec(strBld.toString().toInt()+add)
		} else strBld.append(d)
	}
	ans(strBld)
}


fun ans(ans: StringBuilder){
	println(ans)
	exitProcess(0)
}

Measured memory_bytes: 33988
#include <algorithm>
#include <cstdio>

using namespace std;

int main(void){
  int a[3];

  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  sort(a,a+3);
  printf("%d %d %d\n",a[0],a[1],a[2]);
}

Measured memory_bytes: 1040
# 解説を参考に作成
# さらに 提出 #12403542 を参考


def solve():
    S = input()
    lenS = len(S)
    mod_list = [0] * 2019
    x = 0
    for i in range(lenS):
        x = (int(S[lenS - 1 - i]) * pow(10, i, 2019) + x) % 2019
        mod_list[x] += 1

    result = 0
    for i, ml in enumerate(mod_list):
        if i == 0:
            result += ml
        result += int(ml * (ml - 1) / 2)
    print(result)


if __name__ == '__main__':
    solve()


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int X = std::max(A, C);
    int Y = std::min(B, D);
    cout << std::max(0, Y - X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(a + b > c + d) cout << "Left" << endl;
  else if(a + b == c + d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

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

	if (A + B > C + D) {
		cout << "Left";
	}
	else if (A + B == C + D){
		cout << "Balanced";
	}
	else {
		cout << "Right";

	}
}

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

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

class NyaGadgetVector
{
public:
	template<typename T> static void Add(vector<T>& collection, T add_value)
	{
		for (auto& e : collection)
			e += add_value;
	}
	/**
	@brief 標準入力関数
	@note
	 標準入力から入力されたsize個の値をcollectionに格納する
	**/
	template<typename T> static void InputStream(vector<T>& collection, int size)
	{
		for (int i = 0; i < size; i++)
			cin >> collection[i];
	}
	template<typename T> static T Max(const vector<T>& collection)
	{
		T max = collection[0];
		for (const auto& e : collection)
		{
			if (max < e)
				max = e;
		}
		return max;
	}
	/**
	@brief 合計関数
	@note
	 collectionのstart_indexからend_indexまでの要素を合計して返す
	**/
	template<typename T> static T Sum(const vector<T>& collection, int start_index, int end_index)
	{
		int sum = 0;
		for (int i = start_index; i < end_index; i++)
			sum += collection[i];
		return sum;
	}
};

int main()
{
	int n;  cin >> n;	// 本数

	vector<int> flower_max_collection(n, 0);
	NyaGadgetVector::InputStream(flower_max_collection, n);

	int water_times = 0;
	int max = NyaGadgetVector::Max<int>(flower_max_collection);

	loop(i, max)
	{
		if (1 <= flower_max_collection[0])
			water_times++;
		for (int i = 0; i < n-1; i++)
		{
			if (flower_max_collection[i] <= 0 && 1 <= flower_max_collection[i+1])
				water_times++;
		}
		NyaGadgetVector::Add(flower_max_collection, -1);
	}

    cout << water_times; 
	return 0;
}


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

int n, m, x, book[13][13], c[13], ans=-1;

int main(){
	cin >> n >> m >> x;
	for (int i=0;i<n;i++){
		cin >> c[i];
		for (int j=0;j<m;j++) cin >> book[i][j];
	}
	for (int mask=0;mask<(1<<n);mask++){
		vector<int>tmp(m,0);
		int cost=0;
		for (int i=0;i<n;i++){
			if (mask&(1<<i)){
				cost+=c[i];
				for (int j=0;j<m;j++) tmp[j]+=book[i][j];
			}
		}
		bool ok=1;
		for (int i=0;i<m;i++){
			if (tmp[i]<x) ok=0;
		}
		if (ok) ans=(ans==-1 ? cost : min(ans,cost));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	int N; cin >> N;
	if (N <= 999) {
		printf("ABC\n");
	}
	else {
		printf("ABD\n");
	}
	return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int t = 0;
  ll ans = 0;
  rep(i,n) {
    if (p[i] < t) {
      ans += t-p[i];
    }
    t = max(t, p[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define LL long long

const LL inf = 100000000007;
int n, m, r;
int aa[10];
LL d[205][205];

int main()
{
    while(~scanf("%d %d %d", &n, &m, &r))
    {
        for(int i = 0; i < r; ++i)
            scanf("%d", &aa[i]);
        for(int i = 0; i <= n; ++i)
            for(int j = 0; j <= n; ++j)
                d[i][j] = inf;
        int a, b, c;
        for(int i = 0; i < m; ++i)
        {
            scanf("%d %d %d", &a, &b, &c);
            d[a][b] = d[b][a] = c;
        }
        for(int k = 0; k <= n; ++k)
        {
            for(int i = 0; i <= n; ++i)
            {
                for(int j = 0; j <= n; ++j)
                {
                    if(k == i || k == j) continue;
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        LL ans = inf;
        sort(aa, aa + r);
        do
        {
            LL sum = 0;
            for(int i = 0; i < r - 1; ++i)
                sum += d[aa[i]][aa[i + 1]];
            ans = min(ans, sum);
        }while(next_permutation(aa, aa + r));
        printf("%lld\n", ans);
    }
}


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

void swap(int a[],int o,int t){
	int w;
	//cout<<"aa"<<o<<t<<endl;
	w=a[o];a[o]=a[t];a[t]=w;
}

int main(){
	char p,c,q;
	int m[3]={1,0,0};
	while(cin>>p){
			cin>>c>>q;
		swap(m,(int)(p-'A'),(int)(q-'A'));
		//cout<<m[0]<<m[1]<<m[2]<<endl;
	}
	for(int i=0;i<3;i++){
		if(m[i]==1)cout<<(char)('A'+i)<<endl;
	}

}

Measured memory_bytes: 1132
import sys

K = int(input())
A = [int(x) for x in input().split()]

if A[-1] != 2:
    print(-1)
    sys.exit()

minn = 2
maxn = 3

for i in range(len(A) - 2, -1, -1):
    m = A[i]
    a = (minn + m - 1) // m * m
    b = maxn // m * m
    if b < a:
        print(-1)
        sys.exit()
    minn = a
    maxn = b + m - 1

print(minn, maxn)



Measured memory_bytes: 14252
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int t;
        int x;
        int y;
        int nt = 0;
        int nx = 0;
        int ny = 0;
        int dist;
        int time;
        boolean successFlg = true;
        PrintWriter out = new PrintWriter(System.out);

        for (int i = 0; i < N; i++) {

            t = Integer.parseInt(sc.next());
            x = Integer.parseInt(sc.next());
            y = Integer.parseInt(sc.next());
            time = t - nt;
            dist = Math.abs(x - nx) + Math.abs(y - ny);

            if (dist > time || (time - dist) % 2 != 0) {
                successFlg = false;
            }

            nt = t;
            nx = x;
            ny = y;
        }

        if (successFlg) {
            out.println("Yes");
        } else {
            out.println("No");
        }

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 57660
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N;
  ci(N);
  ve<dl> H(N);
  rep(i, N){
    ci(H.at(i));
  }
  rev(H);
  rep(i, N- 1){
    if(H.at(i) - H.at(i + 1) == -1){
      H.at(i + 1)--;
    }
    else if(H.at(i) - H.at(i + 1) < -1){
      co("No");
      rt;
    }
  }
  co("Yes");
}

Measured memory_bytes: 1024
h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])

Measured memory_bytes: 24764
$n = gets.to_i
colors = gets.chomp.split("")
color_array = Array.new(3) { Array.new }
colors.each.with_index(1) do |color, index|
  case color
  when "R"
    color_array[0] << index
  when "G"
    color_array[1] << index
  when "B"
    color_array[2] << index
  end
end

$ngs = Array.new($n + 1, 0)

def count_ngs(a, b)
  gap = b - a
  $ngs[((a + b) / 2)] += 1 if gap.even?
  $ngs[a - gap] += 1 if (a - gap) > 0
  $ngs[b + gap] += 1 if (b + gap) <= $n
end

color_array[0].each do |i1|
  color_array[1].each do |i2|
    if i1 > i2
      count_ngs(i2, i1)
    else
      count_ngs(i1, i2)
    end
  end
end

ans = color_array[0].size * color_array[1].size * color_array[2].size

color_array[2].each do |i|
  ans -= $ngs[i]
end

puts ans


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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define re return
#define vi vector <int> 
#define pii pair <int,int>
#define pll pair <long long , long long>
typedef long long ll;

ll n,ans,a[100000];

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n-1;i++)
	{
		if(a[i]%2==1&&a[i+1]>0)
		{
			a[i]--;
			a[i+1]--;
			ans++;
		}
	}
	for(int i=0;i<n;i++)
		ans+=a[i]/2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, A;
  cin >> H >> A;
  if (H % A == 0) {
    int x = H / A;
    cin >> x;
    cout << x << endl;
  }
  else {
    int y = H / A + 1;
    cin >> y;
    cout << y << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	ll cnt = 1;
	ll n,k;
	cin >> n >> k;
	ll m = k;
	while (n>=m){
		cnt++;
		m *= k;
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template <class T, class T2>
void group(T &xs, vector<pair<T2, int> > &result) {
  int i=0, j;
  while (i<xs.size()) {
    j=i;
    while (j < xs.size() and xs[j] == xs[i]) j++;
    result.push_back({ xs[i], j-i });
    if (j==i) i++;
    i=j;
  }
}

int main() {
  string s; in(s);
  vector<pair<char, int> > G;
  group(s, G);
  int ans = 0;
  for (auto g: G) {
    if (g.first == 'R') ans = max(ans, g.second);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>

int main()
{
	double x[100], y[100], sum = 0, metric = 0;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lf", x + i);
	for (int i = 0; i < n; i++)
		scanf("%lf", y + i);
	for (int i = 0; i < n; i++)
		metric += fabs(x[i] - y[i]);
	printf("%lf\n", metric);
	for (int i = 0; i < n; i++)
		sum += pow(x[i] - y[i], 2);
	printf("%lf\n", sqrt(sum));
	metric = sum = 0;
	for (int i = 0; i < n; i++)
		sum += pow(fabs(x[i] - y[i]), 3);
	printf("%lf\n", cbrt(sum));
	for (int i = 0; i < n; i++)
		if (metric < fabs(x[i] - y[i]))
			metric = fabs(x[i] - y[i]);
	printf("%lf\n", metric);

	return 0;
}


Measured memory_bytes: 2104
import sys
from collections import deque
from bisect import bisect_left, bisect_right

N=input()
A=[ int(sys.stdin.readline().strip())  for _ in range(N) ]

LIS=[]
for i,x in enumerate(A[::-1]):
	if i==0:
		LIS.append(x)
	elif LIS[-1]<=x:
		LIS.append(x)
	else:
		p=bisect_right(LIS,x)
		LIS[p]=x

print len(LIS)

Measured memory_bytes: 40604
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	vector<int>B(N - 1);
	for (int i = 0; i < N - 1; i++) {
		cin >> B[i];
	}
	A[0] = B[0];
	for (int i = 0; i < N - 1; i++) {
		A[i + 1] = B[i];
		if (A[i] > B[i]) {
			A[i] = B[i];
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += A[i];
	}
	cout << ans << endl;
}


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


void solve(long long N, std::vector<long long> a){
    map<long long, long long> mp;
    for(long long i=0; i<N; i++)
    {
        if(mp.count(a.at(i)) == 0)
        {
            mp[a.at(i)] = 1;
        }
        else
        {
            mp.at(a.at(i))++;
        }
    }

    long long total = 0;
    for(auto p : mp)
    {
        total += p.second * (p.second - 1) / 2;
    }
    // cout << "total : " << total << endl;

    for(long long i=0; i<N; i++)
    {
        long long dif = -1 * mp.at(a.at(i)) + 1;
        cout << total + dif << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int A, B, C, X, Y;

int main() {
    cin >> A >> B >> C >> X >> Y;
    if (C * 2 > A + B) {
        cout << A * X + B * Y << endl;
        return 0;
    }
    if (Y > X) {
        cout << (C * 2 > B? C * 2 * X + B * (Y - X): C * 2 * Y) << endl;
        return 0;
    } else {
        cout << (C * 2 > A? C * 2 * Y + A * (X - Y): C * 2 * X) << endl;
        return 0;
    }
}



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

using namespace std;

struct Node{
	Node(){
		brother = parent = -1;
		height = depth = num_of_children = 0;
	}
	int parent,brother,depth,num_of_children,height;
	vector<int> children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

void calcHeight(Node nodes[],int height,int parent){
	nodes[parent].height = max(nodes[parent].height,height+1);
	if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}

int main(){
	int n,id,left_id,right_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left_id,&right_id);
		if(left_id != -1){
			nodes[id].children.push_back(left_id);
			nodes[id].num_of_children++;
			nodes[left_id].parent = id;
		}
		if(right_id != -1){
			nodes[id].children.push_back(right_id);
			nodes[id].num_of_children++;
			nodes[right_id].parent = id;
		}
		if(left_id != -1 && right_id != -1){
			nodes[left_id].brother = right_id;
			nodes[right_id].brother = left_id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	if(n > 1){
		calcDepth(nodes,root_id);

		for(int i = 0; i < n; i++){
			if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
		}
	}

	for(int i = 0; i < n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
				,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
		if(nodes[i].parent == -1){
			printf(" root\n");
		}else if(nodes[i].num_of_children == 0){
			printf(" leaf\n");
		}else{
			printf(" internal node\n");
		}

	}
}


Measured memory_bytes: 2796
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
 int main() {
 	int a,b,c;
 	cin >> a >> b >> c;
 
	 if(a == b){
		 cout << c;
	 }else if(a == c){
 		cout << b;
	}else{
 		cout << a;
 	}
 }

Measured memory_bytes: 3584
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main() {
     
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
     int a,b;
     scanf("%d%d",&a,&b);
  if(b>=a)
     printf("%d",a);
  
  else
     printf("%d",a-1);
     
    
	return 0;
}

Measured memory_bytes: 256
N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a, b=[0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
ans, j=0, M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans=max(ans, i+j)
print(ans)

Measured memory_bytes: 47548
#include<stdio.h>

int A[20000000];
int H;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}
 
void maxHeapify(int A[], int i){
  int l, r, largest;
  int tmp;

  l = left(i);
  r = right(i);

  if(l <= H && A[l] > A[i]){
    largest = l;
  }else {largest = i;}

  if(r <= H && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int A[]){
  int i;
  for(i = H/2; i>=1; i--){
    maxHeapify(A, i);
  }
}


int main(){
  int i;

  scanf("%d", &H);

  for ( i = 1; i <= H; i++ ){ 
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);

  for ( i = 1; i <= H; i++ ){ 
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

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

using namespace std;
using ll    = long long;


void solve(ll N, ll D, vector<ll> X, vector<ll> Y) {
  int ans = 0;
  rep(i, N) {
    ans += (X[i]*X[i] + Y[i]*Y[i]) <= D*D;
  }
  cout << ans << '\n';
}

int main() {
  ll N;
  scanf("%lld",&N);
  ll D;
  scanf("%lld",&D);
  vector<ll> X(N);
  vector<ll> Y(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
    scanf("%lld",&Y[i]);
  }
  solve(N, D, move(X), move(Y));
  return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
ll dp[100005][103];
ll w[103],v[103];
int main()
{
	ll n,W;
	cin>>n>>W;
	ll sum=0;
	fr(i,1,n)
	{
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	fr(i,1,100000)
	{
		fr(j,0,100)
		dp[i][j]=INT_MAX;
	}
	ll ans=0;
	fr(i,1,sum)
	{
		fr(j,1,n)
		{
			dp[i][j]=dp[i][j-1];
			if(v[j]<=i)
			{
				dp[i][j]=min(dp[i-v[j]][j-1]+w[j],dp[i][j]);
			}
			//cout<<dp[i][j]<<" ";
			if(dp[i][j]<=W)
			ans=i;
		}
		//cout<<"\n";
	}
	cout<<ans;
    return 0;
}





Measured memory_bytes: 84132
class SEGTree:
    def __init__(self,n,fanction,unit):
        self.Unit=unit
        i=1<<(n.bit_length()-1)
        if i!=n:
            i*=2
        self.Fanction=fanction
        self.SEG=[self.Unit]*(2*i-1)
        self.d=i
    def update(self,i,x):
        i+=self.d-1
        self.SEG[i]+=x
        while i>0:
            i=(i-1)//2
            self.SEG[i]=self.Fanction(self.SEG[i*2+1],self.SEG[i*2+2])
    def find(self,a,b,k,l,r):
        if r<=a or b<=l:
            return self.Unit
        if a<=l and r<=b:
            return self.SEG[k]
        else:
            c1=self.find(a,b,2*k+1,l,(l+r)//2)
            c2=self.find(a,b,2*k+2,(l+r)//2,r)
            return self.Fanction(c1,c2)
    def get(self,a,b):
        return self.find(a,b,0,0,self.d)

def sumint(a,b):return a+b

n,q=map(int,input().split())
SEG=SEGTree(n,sumint,0)
for _ in range(q):
    com,x,y=map(int,input().split())
    x-=1
    if com==0:
        SEG.update(x,y)
    else:
        print(SEG.get(x,y))


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	int h, n;
	cin >> h >> n;
	
	int sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum >= h)cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = sorted([A[i]-B[i] for i in range(N)])
tot = sum(C)
cnt = 0
if tot<0:
    cnt = -1
else:
    a = 0
    for i in range(N):
        if C[i]<0:
            a += C[i]
            cnt += 1
        else:
            break
    for i in range(N-1,-1,-1):
        if a>=0:break
        a += C[i]
        cnt += 1
print(cnt)

Measured memory_bytes: 85424
main = do
  (n:m:x:xs) <- map read . words <$> getLine
  ms <- map read . words <$> getLine
  putStrLn . show $ solve x ms

solve :: Int -> [Int] -> Int
solve x ms = 
  let (l,r) = foldl (\(a,b) k -> if k < x then (a+1,b) else (a,b+1)) (0,0) ms
  in min l r


Measured memory_bytes: 1020
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

    int N,W,ans = 0,sum = 0;
    scanf("%d %d",&N,&W);

    int* dp = new int[W+1];
    int* friends = new int[N+1];

    friends[0] = 0;
    for(int i = 1; i <= N; i++){
        scanf("%d",&friends[i]);
        sum += friends[i];
    }

    sort(friends,friends+(N+1));

    if(sum <= W || W < friends[1]){
        printf("1\n");
        return 0;
    }

    sum = 0;
    for(int i = 1; i <= N; i++){
        sum += friends[i-1];
        if(sum > W)break;

        if(i == N){
            ans = (ans + 1)%MOD;
            break;
        }

        for(int a = 0; a <= W-sum; a++)dp[a] = 0;

        dp[0] = 1;

        for(int a = i+1; a <= N; a++){
            for(int b = W-sum; b >= friends[a]; b--){
                dp[b] = (dp[b] + dp[b-friends[a]])%MOD;
            }
        }

        for(int a = 0; a <= W-sum; a++){
            if(W-sum-a < friends[i]){
                ans = (ans + dp[a])%MOD;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 2764