akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define Komachi is retarded
#define pb push_back
#define mp make_pair
#define bcnt __builtin_popcount
#define clz __builtin_clz
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define LB lower_bound
#define UB upper_bound
#define IN insert
#define lp (p<<1)
#define rp (p<<1|1)
#define lson l,mid,lp
#define rson mid+1,r,rp
#define LL long long
#define uLL unsigned long long
#define DB double 
#define INF 1000000000
#define EPS 1e-6
#define debug(a,p) cerr<<a<<p;
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;i++)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;i--)
 
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0;}
 
#define Mod 1000000007
#define M 100004

int X,Y,Tmp;

void Exgcd(int a,int b){
    if(!b){X=1;Y=0;return;}
    Exgcd(b,a%b);
    Tmp=X;X=(1-1ll*a*X)/b;Y=Tmp;
}

int n,A[M],C[M],P[M],Lastl,Lastr,T[M];

void Init(int C[M],int n){
	C[0]=1;
	REP(i,1,n+1){
		Exgcd(Mod,i);X=(X%Mod+Mod)%Mod;
		C[i]=1ll*C[i-1]*X % Mod*(n-i+1)%Mod;
	}
}
int main(){
	scanf("%d",&n);n++;
	REP(i,1,n+1){
		scanf("%d",&A[i]);
		if(P[A[i]])Lastl=P[A[i]],Lastr=i;
		else P[A[i]]=i;
	}
	Init(C,n);Init(T,Lastl-1+n-Lastr);
	
	printf("%d\n",n-1);
	REP(i,2,n+1){
		int Ans=(0ll+C[i]-T[i-1]+Mod)%Mod;
		printf("%d\n",Ans);
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		int[] t = sc.nextIntArray(n);
		
		int m = sc.nextInt();
		
		int[] p = new int[m];
		int[] x = new int[m];
		
		for(int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			x[i] = sc.nextInt();
		}
		
		int sum = Arrays.stream(t).sum();
		
		for(int i = 0; i < m; i++) {
			out.println(sum - t[p[i] - 1] + x[i]);
		}
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

        return tokenizer.nextToken("\n");
    }

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

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

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

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

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

Measured memory_bytes: 26580
// https://atcoder.jp/contests/agc041/tasks/agc041_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M, V, P;
  cin >> N >> M >> V >> P;

  VL as(N);
  map<ll, ll> act;

  rep(i, N) {
    ll a;
    cin >> a;
    as[i] = a;
    act[a]++;
  }

  sort(all(as));

  auto is_ok = [&](ll index) -> bool {
    ll a = as[index];
    ll rest = M * V;

    auto over_it = upper_bound(all(as), a + M);
    ll over_index = over_it - as.begin();
    ll over_a_ct = N - over_index;
    if (over_a_ct >= P) return false;
    rest -= over_a_ct * M;
    ll rr = P - over_a_ct - 1;

    if (rest <= 0) return true;

    ll smaller_a_ct = upper_bound(all(as), a) - as.begin();
    rest -= smaller_a_ct * M;

    if (rest <= 0) return true;

    over_index -= rr;
    rest -= rr * M;

    if (rest <= 0) return true;

    ll b_i = upper_bound(all(as), a) - as.begin();

    for (ll ii = b_i; ii < over_index; ii++) {
      rest -= a + M - as[ii];
    }

    return rest <= 0;
  };

  if (is_ok(0)) drop(N);

  ll ng = 0;
  ll ok = N - 1;

  while (ok - ng > 1) {
    ll mid = (ng + ok) / 2;
    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  ll res = N - ok;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <cstdio>
#define maxn 1000006
#define mp make_pair
#define fi first
#define se second
using namespace std;
vector <int> G[maxn];
vector < pair <int, int> > V[maxn];
pair <int, int> edges[maxn];
bool del[maxn];
int to[maxn], turn[maxn], f[maxn];
void addpath(int u, int v, int i){
	V[u].push_back(mp(v, i));
	V[v].push_back(mp(u, i));
	edges[i] = mp(u, v);
}
int dfn[maxn], dfn_cnt = 0, fa[maxn], ans;
void dfs(int u, int f){
	fa[u] = f;
	for (int i = 0; i < G[u].size(); ++ i){
		int v = G[u][i];
		if (v != f)
			dfs(v, u);
	}
	dfn[++ dfn_cnt] = u;
}
bool vis[2003][2003];
bool cover(int u, int e, int f){
	if (u == e)
		return true;
	for (int i = 0; i < G[u].size(); ++ i){
		int v = G[u][i];
		if (v != f && cover(v, e, u)){
			if (! vis[u][v]){
				++ ans;
				vis[u][v] = true;
			}
			return true;
		}
	}
	return false;
}
int read(){
	int cnt = 0;
	char ch = getchar();
	while (ch < '0' || '9' < ch)
		ch = getchar();
	while ('0' <= ch && ch <= '9'){
		cnt = cnt * 10 + ch - '0';
		ch = getchar();
	}
	return cnt;
}
int main(){
	int n = read(), m = read();
	int tmp = m;
	for (int i = 1; i < n; ++ i){
		int u = read(), v = read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1; i <= m; ++ i){
		int u = read(), v = read();
		addpath(u, v, i);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; ++ i){
		int u = dfn[i], last = -1;
		del[u] = true;
		for (int j = 0; j < V[u].size(); ++ j){
			int v = V[u][j].fi;
			if (del[v])
				continue;
			if (last == -1){
				last = j;
				continue;
			}
			addpath(V[u][last].fi, V[u][j].fi, ++ m);
			to[V[u][j].se] = m;
			turn[V[u][j].se] = mp(u, v) != edges[V[u][j].se];
			to[V[u][last].se] = m;
			turn[V[u][last].se] = (mp(u, V[u][last].fi) != edges[V[u][last].se]) ^ 1;
			last = -1;
		}
		if (last != -1){
			addpath(fa[u], V[u][last].fi, ++ m);
			to[V[u][last].se] = m;
			turn[V[u][last].se]= mp(u, V[u][last].fi) != edges[V[u][last].se];
		}
	}
	for (int i = m; i; -- i){
		if (to[i])
			f[i] = f[to[i]] ^ turn[i];
		if (f[i])
			swap(edges[i].fi, edges[i].se);
	}
	for (int i = 1; i <= tmp; ++ i)
		cover(edges[i].fi, edges[i].se, 0);
	cout << ans << endl;
	for (int i = 1; i <= tmp; ++ i)
		printf("%d %d\n", edges[i].fi, edges[i].se);
}


Measured memory_bytes: 63360
#include <iostream>
using namespace std;
  
int main() {
    int n, r, max = -1e9, min;

    cin >> n;
    cin >> min;
    for (int i = 1; i < n; i++) {
        cin >> r;
        if (max < r - min) max = r - min;
        if (min > r)       min = r;
    }
    cout << max << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define eps 1.0E-14
using namespace std;
const int N =1e6;
char s[N];
int main()
{
    int l =200099,r =200100;
    char x;
    for(;;r++){
        scanf("%c",&x);
        if(x=='\n') break;
        s[r] =x;
    }
    int f1,f2,q,q1 =0,q2 =0;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d",&f1);
        if(f1==1)
        {
            int t =l;
            l =r;
            r =t;
            q1++;
            q2++;
            q1 %=2;
            q2 %=2;
        }
        else
        {
            char c;
            scanf("%d",&f2);
            //cout<<f2<<endl;
            getchar();
            scanf("%c",&c);
            if(f2==1)
            {
                s[l] =c;
                if(q1==0)
                    l--;
                else if(q1==1)
                    l++;
            }
            else
            {
                s[r] =c;
                if(q2==0)
                    r++;
                else if(q2==1)
                    r--;
            }
        }
    }

    if(l<r)
    {
        for(int i=l+1; i<r; i++)
        {
            printf("%c",s[i]);
        }
    }
    else
    {
        for(int i=l-1; i>r; i--)
        {
            printf("%c",s[i]);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#define Max 100
#define Inf 2147483647
#define w 0
#define x 1
#define z 2
 
int n, m[Max][Max];
 
void d(){
  int min;
  int d[Max],alpha[Max];
  int i;
  for(i = 0 ;i< n;i++){
    d[i] = Inf;
    alpha[i] = Inf;
  }
  d[0]=0;
  alpha[0]=x;
  int u;
  while(1){
    min = Inf;
    u = -1;
    for(i = 0;i<n;i++){
      if(min > d[i] && alpha[i] != z){
        u = i;
        min = d[i];
      }
    }
    if(u == -1)break;
    alpha[u] = z;
    for(i = 0;i<n;i++){
      if(alpha[i]!= z &&m[u][i] != Inf){
        if(d[i] > d[u] + m[u][i]){
          d[i] = d[u] + m[u][i];
        }
      }
    }
  }
  int v;
  for(i = 0 ;i< n;i++){
    v = d[i];
    if(d[i] == Inf) v = -1;
    printf("%d %d\n",i,v);
  }
}
 
int main(){
  scanf("%d",&n);
  int i,j;
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      m[i][j] = Inf;
    }
  }
  int k,c,u,v;
  for(i = 0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j = 0;j<k;j++){
      scanf("%d %d",&v,&c);
      m[u][v] = c;
    }
  }
  d();
  return 0;
}


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

int S(long long n) {
    int ret = 0;
    while(n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

double f(long long n) {
    return (double)(n) / S(n);
}

int main() {
    vector<long long> res;

    long long base = 1;
    for(int i=0; i<15; ++i) {
        for(int j=1; j<150; ++j) {
            res.push_back(base * (j + 1) - 1);
        }
        base *= 10;
    }
    sort(begin(res), end(res));
    res.erase(unique(begin(res), end(res)), end(res));

    for(int i=0; i<res.size(); ++i) {
        for(int j=i+1; j<res.size(); ++j) {
            if(f(res[i]) > f(res[j])) {
                res.erase(begin(res) + i--);
                break;
            }
        }
    }

    int K;
    cin >> K;
    for(int i=0; i<K; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 256
# 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>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

struct SegmentTree {
private:
	int n;
	vector<int> node;
public:
	//初期化
	SegmentTree(vector<int> v) {
		int sz = v.size();
		//2冪
		n = 1; while (n < sz) n *= 2;
		//ノード数は2n-1個
		node.resize(2 * n - 1, 0);
		//最小段の値を入れる
		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		//登る
		for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
	}

	//更新クエリ
	void add(int k, int val) {
		//最小段にアクセス
		k += (n - 1);
		//足す処理
		node[k] += val;
		//登りながら更新
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}

	//取得クエリ
	int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
		//最初に見る区間
		if (r < 0) r = n;
		//目的の区間と被らないとき
		if (b <= l || r <= a) return 0;
		//完全に被ってるとき
		if (a <= l && r <= b) return node[k];
		//一部被ってるとき
		int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

int main() {
	int n, q; cin >> n >> q;
	SegmentTree seg(vector<int>(n, 0));
	for (int i = 0; i<q; i++) {
		int c, x, y; cin >> c >> x >> y;
		if (c == 0) seg.add(x - 1, y);
		else cout << seg.getsum(x - 1, y) << endl;
	}
	return 0;
}


Measured memory_bytes: 4128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<stack>
#include<queue>
#include<map>
#include<cmath>
const int maxn = 5e5 + 5;
using namespace std;

long long a,b,x;

int main(){
	scanf("%lld %lld %lld",&a, &b, &x);
	if(a % x == 0 && b % x == 0 && a == b) printf("1\n");
	else if(a == 0 && b != 0) printf("%lld\n", b / x + 1);
	else printf("%lld\n", b / x - (a - 1) / x);
	return 0;
}

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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n, d) for (int i = (s); i < (int)(n); i += (d))
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()

const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(const vector<T> &v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(const vector<vector<T>> &v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

template <typename T, typename S>
void show1dpair(const vector<pair<T, S>> &v)
{
    int n = v.size();
    rep(i, n) cout << v[i].first << wsp << v[i].second << rt;
    return;
}

template <typename T, typename S>
void pairzip(const vector<pair<T, S>> &v, vector<T> &t, vector<T> &s)
{
    int n = v.size();
    rep(i, n)
    {
        t.push_back(v[i].first);
        s.push_back(v[i].second);
    }
    return;
}

template <typename T>
void maxvec(vector<T> &v)
{
    T s = v[0];
    int n = v.size();
    rep(i, n - 1)
    {
        if (s > v[i + 1])
        {
            v[i + 1] = s;
        }
        s = v[i + 1];
    }
}

template <typename T, typename S>
bool myfind(T t, S s)
{
    return find(t.cbegin(), t.cend(), s) != t.cend();
}

bool check(int y, int x, int h, int w)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}



int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << rt;

    return 0;
}


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

int main(){
    int s;
    cin >> s;
    int x=s / 3600;
    int y=(s-(x*3600));    
    int z=y%60;
    
    y=y/60;
    cout << x << ":" << y << ":" << z<<endl;
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    string ans = "";
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  var inputNum = Number(input[0]);
  var tmpAll = [];
  for(var i=1; i <= inputNum; i++){
    var tmp = input[i].split(" ");
    tmpAll.push(tmp);
  }
  var array = tmpAll;

  // ソート
  array.sort(function(a, b){
    return a[1]- b[1];
  });

  var result = 'Yes';
  var sumA = 0;

  for(var j=0; j < inputNum; j++){
    sumA = sumA + Number(array[j][0]);
    if(sumA > Number(array[j][1])){
      result = 'No';
      break;
    }
  }
  console.log(result);
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int n;
  cin >> n;
  vector<vi> t(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  int root = 0;
  vi d(n, -1);
  rep(k, 2) {
    queue<int> q;
    q.push(root);
    d[root] = 0;
    while(!q.empty()) {
      int i = q.front();
      q.pop();
      for(int ni : t[i]) {
        if(d[ni] != -1) continue;
        d[ni] = d[i] + 1;
        q.push(ni);
      }
    }
    if(k == 1) continue;
    root = max_element(all(d)) - d.begin();
    d = vi(n, -1);
  }
  int l = *max_element(all(d));
  cout << (l % 3 == 1 ? "Second" : "First") << endl;
}

Measured memory_bytes: 14324
#include <stdio.h>

 int main(void){
 int a[3][10][4] = {0};
 int i, j, k;
 int n, p;
 int b, f, r, v; 


scanf("%d", &n);
 


for(i=0; i<n; i++)
{
	 scanf("%d %d %d %d", &b, &f, &r, &v);

 	a[f-1][r-1][b-1] += v;
 
}

 for(k=0; k<4; k++)
{
 
	for(i=0; i<3; i++)
	{
 		for(j=0; j<10; j++)
		{
 			if(a[i][j][k] == 0)
			{
 				printf(" 0");
 			}
			else	
			{
 				printf(" %d", a[i][j][k]);
 			}
 		}
 
		printf("\n");
 	}
 
	if(k != 3)
	{
 		printf("####################\n");
 	}
 }

 	return 0;
 
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S;
    cin >> S;
    if(S=="Sunny") cout << "Cloudy" << endl;
    else if(S=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  long double h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1;
  } else {
    long double prod = ceil((h * w) / 2);
    cout << std::setprecision(18) << prod;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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 INF = 1000100100;

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

    ll cnt0 = 0, cnt1 = 0;
    REP(i, S.length()) {
        if(i % 2 == 0) {
            if(S[i] != '0') {
                ++cnt0;
            }

            if(S[i] != '1') {
                ++cnt1;
            }
        } else {
            if(S[i] != '1') {
                ++cnt0;
            }

            if(S[i] != '0') {
                ++cnt1;
            }
        }
    }

    cout << min(cnt0, cnt1) << endl;

    return 0;
}

Measured memory_bytes: 3736
using System;

namespace teeeeeeeeeeeeeeest
{
    class Program
    {
        static void Main(string[] args)
        {
            string n,m;
            string[] N,M;
            double a, b, p, q, r,aa;
            n = Console.ReadLine();
            m = Console.ReadLine();
            N = n.Split();
            M = m.Split();
            a = double.Parse(N[0]);
            b = double.Parse(N[1]);
            p = double.Parse(M[0]);
            q = double.Parse(M[1]);
            r = double.Parse(M[2]);
            aa = (a * p + (b-a) * (p-q)) / (q + r) +b;
            Console.WriteLine(aa);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 17908
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()

n, m = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(m):
    x, y = [int(i) - 1 for i in input().split()]
    e[x].append(y)

used = [False] * n
top = []


def dfs(i):
    if not used[i]:
        used[i] = True
        for j in e[i]:
            dfs(j)
        top.append(i)


for i in range(n):
    dfs(i)

ans = [0] * n
for i in reversed(top):
    for j in e[i]:
        ans[j] = max(ans[j], ans[i] + 1)
print(max(ans))


Measured memory_bytes: 158812
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
memory = [[-1 for i in range(max(m)+1)]for j in range(n)]

def f(i, m):
    if m == 0:
        return 1
    elif i >= n:
        return 0
    elif memory[i][m] != -1:
        return memory[i][m]
    elif m - a[i] >= 0:
        res0 = f(i+1, m)
        res1 = f(i+1, m-a[i])
        if res0 or res1:
            memory[i][m] = 1
            return 1
        else:
            memory[i][m] = 0
            return 0
    else:
        res = f(i+1, m)
        memory[i][m] = res
        return res

for k in m:
    print('yes' if f(0, k) else 'no')


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x,y,z, k;
	cin >> x >> y >> z >> k;
	vector<long long> a(x), b(y), c(z);
	for (int i = 0;i < x;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < y;i++) {
		cin >> b[i];
	}
	for (int i = 0;i < z;i++) {
		cin >> c[i];
	}
	vector<long long> da(x * y);
	for (int i = 0;i < x;i++) {
		for (int j = 0;j < y;j++) {
			da[x*i + j] = a[i]+b[j];
		}
	}
	sort(da.begin(), da.end());
	reverse(da.begin(), da.end());
	int g = min(k, x*y);
	vector<long long> ans(k * 2);
	for (int i = 0;i < z;i++) {
		for(int j = 0;j < g;j++) {
			ans[j] = c[i] + da[j];
		}
		sort(ans.begin(), ans.end());
	}
	for (int i = k * 2 - 1;i > k-1;i--)
		cout << ans[i] << endl;
//	for (int i = 0;i < x + y;i++)
	//	cout << da[i] << endl;
}

Measured memory_bytes: 8192
def c(n, a, cnt):
    for i in range(n):
        num = a.count(i+1)
        if num != 0:
            cnt[i] += 1

    return cnt

def solve():
    
    n, k = map(int, input().split())
    cnt = [0]*n
    for _ in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        c(n, a, cnt)

    return cnt.count(0)




print(solve())


Measured memory_bytes: 9196
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 1000

int table[NUM];


int main(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i < N; i++)scanf("%d",&table[i]);

	int num_query;
	scanf("%d",&num_query);

	int b,m,e;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d %d",&b,&m,&e);
		rotate(table+b,table+m,table+e);
	}

	printf("%d",table[0]);
	for(int i = 1; i < N; i++){
		printf(" %d",table[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 3256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		a[i]=i+1;

	vector<int> p(n),q(n);
	for(int i=0;i<n;i++)
		cin >> p[i];
	for(int i=0;i<n;i++)
		cin >> q[i];

	int pp,qq;

	int it=0;
	do
	{
		if(a==p)pp=it;
		if(a==q)qq=it;
		it++;
	}while(next_permutation(a.begin(),a.end()));

	cout << abs(pp-qq) << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10;
double a[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n-1;++i){
        a[i+1]=(a[i]+a[i+1])/2;
    }
    cout<<a[n]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define INF 1000000
#define N 9
using namespace std;

int d[N][N];
int ans[N];
//初期化
void init(){
  for(int i=0;i<N;i++){
      ans[i]=0;
    for(int j=0;j<N;j++){
      if(i==j) d[i][i]=0;
      else d[i][j]=INF;
    }
  }
}
void solve(int n){
  init();
  int a,b,t;
  //値代入
  for(int i=0;i<n;i++){
    cin>>a>>b>>t;
    d[a][b]=d[b][a]=t; //無向辺
  }
  //ワーシャルフロイド
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(d[i][j]==INF) continue;
      ans[i]+=d[i][j]; //距離の累積和
    }
  }
  int answer=INF,town;
  for(int i=0;i<N;i++){
    if(ans[i]!=0&&answer>ans[i]){
      answer=ans[i]; town=i;
    }
  }
  cout<<town<<" "<<answer<<"\n";

}
int main(){
  int n;
  cin>>n;
  while(n!=0){solve(n);cin>>n;}

}



Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int x_num;
    int x_ans = 1;
    int i = 0;

    scanf("%d",&x_num);

    for(i=0;i<3;i++){
        x_ans = x_ans * x_num;
    }
    printf("%d\n",x_ans);
    return (0);
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll a, b , k;
    cin >> a>> b >> k;
    ll g = __gcd(a, b) ;
    ll cnt =0 ;
    for (int i = g; i; i--) {
    	if (g % i ==0 ) {
    		cnt ++ ;
    		if (cnt ==k) return cout << i, 0;
		}
	}
    
    return (0) ;
}

Measured memory_bytes: 256
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (70)
#define P (1000000007)
int l,r,f[N][2][2][2];
int dfs(int p,bool ul,bool ll,bool h);
signed main(){Mst(f,-1),Rd(l),Rd(r),wr(dfs(log2(r),1,1,0)),exit(0);}
int dfs(int p,bool ul,bool ll,bool h){
	if(p==-1)return 1;
	int dl((l>>p)&1),dr((r>>p)&1),re(0);
	if(~f[p][ul][ll][h])return f[p][ul][ll][h];
	if(!ll||!dl)re=dfs(p-1,ul&&!dr,ll,h);
	if(h&&(!ll||!dl)&&(!ul||dr))re+=dfs(p-1,ul,ll,1);
	if(!ul||dr)re+=dfs(p-1,ul,ll&&dl,1);
	return f[p][ul][ll][h]=re%P;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;
Node treeMinimum(Node);
Node treeSearch(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

Node treeMinimum(Node x){
  while( x->left > NIL ) x = x->left;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ) {
    y = x;

    if( x->key > z->key ) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }

  z->parent = y;

  if( y == NIL ){
    root = z;
  }
  else {
    if(z->key < y->key ) {
      y->left = z;
	}
    else {
      y->right = z;
    }
  }
}


void inorder(Node u){
  if( u == NIL ) return ;
  inorder( u->left );
  printf(" %d",u->key);
 
  inorder( u->right );

}

void preorder(Node u){

  if( u == NIL ) return ;
  printf(" %d",u->key);
  
  preorder( u->left );
  preorder( u->right );
 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d",&x);

      Node t = treeSearch(root, x);

      if ( t != NIL ) printf("yes\n");

      else printf("no\n");
    } 

    else if ( com[0] == 'i' ){
      scanf("%d",&x);
      insert(x);
    } 

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    } 
    else if ( com[0] == 'd' ){
      scanf("%d",&x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};
const ll mod = 1000000007;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 1;
    rep(i,1,n+1){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    v = list(map(int, input().split()))
    n = v[0]
    x = v[1]
    a = list(map(int, input().split()))

    # aの値が小さい順にぴったり配っていく
    count = 0
    a = sorted(a)

    for i in range(len(a)):
        if i == len(a) - 1:
            if x == a[i]:
                count += 1
        elif x >= a[i]:
            x -= a[i]
            count += 1
        else:
            break

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61956
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A[3];
    ll K;
    cin >> A[0] >> A[1] >> A[2];
    cin >> K;
    sort(A, A + 3);

    cout << A[0] + A[1] + A[2] * pow(2, K) << endl;

    return 0;
}

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

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if(s*t>=d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
n = int(input())
h = list(map(int,input().split()))
c = 0
t = 0
for i in range(len(h)-2):
    if h[i+2]<h[i+1]<h[i] or h[i+1]-h[i] <= -2:
        print("No")
        c += 1
        break
    if h[i+1]<h[i]:
        t += 1
        if t == 2:
            print("No")
            c += 1
            break
    elif h[i+1]>h[i]:
        t = 0
    
            
if c == 0:
    if len(h)>=2:
        if h[-1]-h[-2] <= -2:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")

Measured memory_bytes: 14976
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	int[] sosuu = new int[100001];
	public void run() {
		sosuuCalc();
		while(sc.hasNext()){
			int m = sc.nextInt();
			double a = sc.nextInt();
			double b = sc.nextInt();
			double c = a/b;
			if(m == 0 && a  == 0 && b == 0)break;
			else calc(m,c);
			
		}
	}
	public void sosuuCalc(){
		sosuu[0] = -1;
		sosuu[1] = -1;
		for(int i = 2; i < 100001; i++){
			if(sosuu[i] == 0){
				sosuu[i] = 1;
				for(int j = i * 2; j < 100001; j = j + i){
					sosuu[j] = -1;
				}
			}
		}
	}
	public void calc(int m, double c){
		int t = 0;
		for(int pq = m; pq > 0; pq--){
			for(int p = 2; p*p <= pq; p++){
				if(sosuu[p] == 1 && pq % p == 0){
					int q = pq / p;
					if(sosuu[q] == 1 && c <= ((double) p) / ((double)q)){
						System.out.println(p + " " + q);
						t++;
						break;
					}
				}
			}
			if(t != 0) break;
		}
	}

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

Measured memory_bytes: 29108
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  cout << max(max(A+B, 2*A-1), 2*B-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL a[2000222],dp[4],n,sum[2000222];
#define P(x) (x%3+3)%3
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		sum[i]=sum[i-1];
		if(i&1)sum[i]+=a[i];
	}
	dp[1]=0;dp[2]=max(a[1],a[2]);
	for(int i=3;i<=n;++i)
	{
		LL now,pre1,pre2;
		now=P(i);pre1=P(i-1);pre2=P(i-2);
		dp[now]=0;
		if(i&1)
		{
			dp[now]=max(dp[pre1],dp[pre2]+a[i]);
		}
		else
		{
			dp[now]=max(sum[i],dp[pre2]+a[i]);
		}
	}
	printf("%lld\n",dp[P(n)]);
}

Measured memory_bytes: 6908
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    const digit = (x) => String(x).split("").length
    let cnt = 0
    for(let i = 1; i<= n; i++){
        let tmp = digit(i)
        if(tmp % 2 !== 0) cnt++
    }
    console.log(cnt)
}
Main()


Measured memory_bytes: 37092
#include <bits/stdc++.h>
using namespace std;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
typedef long long LL;
const int N = 4e5 + 10;
const int inf = 0x3f3f3f3f;
struct E {
	int u, v, w;
	E(int _u = 0, int _v = 0, int _w = 0) {u = _u, v = _v, w = _w;}
	inline bool operator < (const E &e) const {return w < e.w;}
} e[N << 1];
int n, m, a[N], uni[N];

inline int Find(int x) {return x == uni[x] ? x : uni[x] = Find(uni[x]);}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

int main() {
	int u, v; in(n), in(m);
	for (int i = 0; i < n; ++i)
		uni[i] = i, a[i] = a[i + n] = inf;
	for (int i = 1; i <= m; ++i) {
		in(e[i].u), in(e[i].v), in(e[i].w);
		a[e[i].u] = min(a[e[i].u], e[i].w + 1);
		a[e[i].v] = min(a[e[i].v], e[i].w + 2);
	}
	for (int i = 1; i < (n << 1); ++i) a[i] = min(a[i], a[i - 1] + 2);
	for (int i = 0; i < n; ++i) e[++m] = E(i, (i + 1) % n, min(a[i], a[i + n]));
	sort(e + 1, e + m + 1);

	LL ans = 0; int cnt = 0;
	for (int i = 1; i <= m; ++i) {
		u = Find(e[i].u), v = Find(e[i].v);
		if (u != v) uni[u] = v, ans += (LL)e[i].w, ++cnt;
		if (cnt == n - 1) break;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 13312
n,m=map(int,input().split())
hoge=list(map(int,input().split()))
ans=0
for i in range(len(hoge)):
  huga1=[hoge[j] for j in range(len(hoge)) if hoge[j]<hoge[i]]
  huga2=[hoge[j] for j in range(len(hoge)) if hoge[j]<hoge[i] and j>i]
  ans+=(len(huga1)*int(m*(m+1)//2))%(10**9+7)
  ans-=(len(huga1)-len(huga2))*m
  ans=ans%(10**9+7)
print(ans)

Measured memory_bytes: 3188
h,w,k = map(int,input().split())
c = [input() for _ in range(h)]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ii in range(h):
            if((i >> ii)& 1):
                for jj in range(w):
                    if((j >> jj)& 1):
                        cnt += (c[ii][jj]=='#')
        ans += (cnt==k)

print(ans)

Measured memory_bytes: 68236
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 2019;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    ll X;
    cin >> X;
    int i = 1;
    ll depo = 100;
    while (true) {
        depo += (ll)depo*0.01;
        if (depo >= X) break;
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 N, M, a, b;
    cin >> N >> M;
    map<int, int> AB1, ABN;
    string ans = "IMPOSSIBLE";
    rep(i,M) {
        cin >> a >> b;
        if (a == 1) ++AB1[b];
        if (a == N) ++ABN[b];
        if (b == 1) ++AB1[a];
        if (b == N) ++ABN[a];
    }
    if (AB1.size() != 0 && ABN.size() != 0) {
        for (auto x : AB1) {
            if (ABN[x.first] > 0) {
                ans = "POSSIBLE";
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 17668
import sys
def q(a,h):
 d[a]=h
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
input()
for e in sys.stdin:
 e=e.split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t)))))


Measured memory_bytes: 60056
n = int(input())
A = list(map(int,input().split()))
A.sort()

l = [0]*(10**6+1)

for i in A:
    if l[i] <= 1:
        for j in range(0,10**6+1,i):
            l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)

Measured memory_bytes: 132828
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int m;
  cin >> m;
  cout << 24+(24-m) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,q,l[200000],r[200000],t[200000],c=0;
  string s;
  cin >> n >> q >> s;
  rep(i,q)cin >> l[i] >> r[i];
  rep(i,s.length())t[i]=0;
  rep(i,s.length()-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      c++;
      t[i]=c;
      c++;
      t[i+1]=c;
    }
    else if(t[i]==0)t[i]=c;
  }
  t[s.length()-1]=c;
  rep(i,q){
    printf("%lld\n",t[r[i]-1]/2-t[l[i]-1]/2);
  }
}

Measured memory_bytes: 5760