akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, a, b;
    cin >> n >> a >> b;
    
    if (n < a + b -1) {
        cout << "-1" << endl;
        return 0;
    }
    if (n > a * b) {
        cout << "-1" << endl;
        return 0;
    }
    
    auto getnum = [&](lint i, lint j) -> lint {
        return a * (b - 1 - i) + 1 + j;
    };
    
    vector<lint> s;
    lint c = n - b;
    
    repeat (i, b) {
        lint t = getnum(i, 0);
        s.emplace_back(t);
        if (c <= 0) continue;
        if (c > 0) {
            if (c <= a - 1) {
                repeat (j, c) {
                    t = getnum(i, j+1);
                    s.emplace_back(t);
                }
                c = 0;
            }
            else {
                repeat (j, a - 1) {
                    t = getnum(i, j+1);
                    s.emplace_back(t);
                }
                c -= (a - 1);
            }
        }
    }
    
    // 座標圧縮(配列sの値を破壊的に変更する)
    // ソート → 一意要素を前に → 後半に残る重複要素を削除 → 二分探索で元の数字のindexを調べる
    auto t = s;
    sort(t.begin(), t.end());
    auto it = unique(t.begin(), t.end());
    t.erase(it, t.end());
    for(auto &e: s) {
        e = lower_bound(t.begin(), t.end(), e) - t.begin();
    }
    
    repeat (i, s.size()) {
        cout << s[i]+1 << " ";
    }
}

Measured memory_bytes: 8684
# クラスカル法
class Kruskal_UnionFind():
    # 無向グラフであるという前提に注意
    def __init__(self, N):
        self.edges = []
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def add(self, u, v, d):
        """
        u = from, v = to, d = cost
        """
        self.edges.append([u, v, d])

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def Kruskal(self):
        """
        return: 最小全域木のコストの和
        """
        edges = sorted(self.edges, key=lambda x: x[2])  # costでself.edgesをソートする
        res = 0
        for e in edges:
            if not self.same(e[0], e[1]):
                self.unite(e[0], e[1])
                res += e[2]
        return res

N = int(input())
xy = [list(map(int, input().split())) + [i] for i in range(N)]

Krus = Kruskal_UnionFind(N)

xy.sort(key=lambda x: x[0])
x_cost = [[xy[i-1][2], xy[i][2], abs(xy[i-1][0] - xy[i][0])] for i in range(1, N)]
xy.sort(key=lambda x: x[1])
y_cost = [[xy[i-1][2], xy[i][2], abs(xy[i-1][1] - xy[i][1])] for i in range(1, N)]

for i in range(N-1):
    a, b, w = x_cost[i]
    Krus.add(a, b, w)
    a, b, w = y_cost[i]
    Krus.add(a, b, w)

ans = Krus.Kruskal()

print(ans)


Measured memory_bytes: 81428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  int x;
  cin >> x;
  int a, b;
  if (x == 0) {
    cout << 0 << " " << 0 << endl;
    return;
  }
  FOR(i, -118, 119) {
    FOR(j, -119, 118) {
      int now = pow(i, 5) - pow(j, 5);
      if (now == x) {
        a = i;
        b = j;
        break;
      }
    }
  }
  cout << a << " " << b << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

long long N, X, Y;
long long dp[2005][2005];

int main(){
	cin >> N >> X >> Y;
	for(long long i = 0; i < 2005; i++) {
		for(long long j = 0; j < 2005; j++) {
			dp[i][j] = abs(i-j);
		}
	}

	X--;
	Y--;
	dp[X][Y] = 1;
	for(long long i = 0; i < 2005; i++) {
		for(long long j = 0; j < 2005; j++) {
			dp[i][j] = min(dp[i][j], dp[i][X] + dp[X][Y] + dp[Y][j]);
		}
	}
	map<long long, long long> memo;

	for(long long i = 0; i < N; i++) {
		for(long long j = i + 1; j < N; j++) {
			memo[dp[i][j]]++;
			//cout << "d[" << i << "][" << j << "] = " << dp[i][j] << endl;
		}
	}

	for(long long i = 1; i< N; i++){
		cout << memo[i] << endl;
	}


}


Measured memory_bytes: 35036
import numpy as np

N, A, B, C = map(int,input().split())
goals = [A,B,C]
ls = []
for i in range(N):
    ls.append(int(input()))

# goals = [1000,800,100]
# ls = [300,333,400,444,500,555,600,666]
# goals = [100, 90, 80]
# ls = [98, 40,30,21,80]

def count(x,ls):
    try:
        x.index(0)
        x.index(1)
        x.index(2)        
    except:
        return False
    A = np.zeros(len(goals))
    for i,l in enumerate(ls):
        add_ind = x[i]
        if add_ind==3:
            pass
        else:
            A[add_ind] += l
    combine_MP = 0
    for i in range(3):
        combine_MP += 10*(x.count(i)-1)
    return A, combine_MP
    
    
score_min = 100000
for N in range(4**8):
    x = []
    for j in range(len(ls)):
        x.append(N % 4)
        N = N // 4 
    try:
        A, combine_MP = count(x,ls)
        score = np.abs(A-np.array(goals)).sum() + combine_MP
        if score_min >= score:
            score_min = score
    except:
        pass
print(int(score_min))

Measured memory_bytes: 14512
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n,cwalk,ctel;

ll dp[MAXN];
int x[MAXN];

void run() {
	scanf("%d%d%d",&n,&cwalk,&ctel);
	REP(i,n) scanf("%d",&x[i]);
	REP(i,n) dp[i]=LLONG_MAX; dp[0]=0;
	REP(i,n-1) {
		{ ll ncost=dp[i]+(ll)(x[i+1]-x[i])*cwalk; if(ncost<dp[i+1]) dp[i+1]=ncost; }
		{ ll ncost=dp[i]+ctel; if(ncost<dp[i+1]) dp[i+1]=ncost; }
	}
	printf("%lld\n",dp[n-1]);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 1408
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
S = 0

for i in range(N)[::-1]:
  if A[i] + A[i+1] >= B[i]:
    S += B[i]
    A[i] = min(A[i] + A[i+1] - B[i], A[i])
    
  else:
    S += A[i] + A[i+1]
    A[i] = 0
    
print(S)

Measured memory_bytes: 81892
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;


int main(){
	int n;
	while(cin>>n && n)
	{
		multimap< double,int,greater<double> > rieki;
		int y;
		cin>>y;
		for(int i=0; i<n; i++)
		{
			int b,r,t;
			cin>>b>>r>>t;
			double v;
			if(t==1) {
				v = 1.0 * (1.0 + y * (r / 100.0));
				rieki.insert( make_pair( v,b) ) ;
			}

			else {
				v = 1.0 * pow(1.0 + r / 100.0, y);
				rieki.insert( make_pair( v,b) ) ;
			}
		}
		multimap< double,int,greater<double> > :: iterator it=rieki.begin();
		cout<< (*it).second <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100005],flag=0;
int main(int argc, char *argv[])
{
	int s1=0,s2=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0)s1++;
		if(a[i]%4!=0&&a[i]%2==0)s2++;
	}
	if(n/2<=s1||(s1*2+s2)>=n)cout <<"Yes"<<endl;
	else cout <<"No"<<endl;
	
}

Measured memory_bytes: 640
#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() {
    int Th,Ta,Ah,Aa;
    cin >> Th >> Ta >> Ah >> Aa;
    int Td,Ad;
    Td = ceil((double)Th / (double)Aa);
    Ad = ceil((double)Ah / (double)Ta);
    //cout << Td  << " " << Ad << endl;
    if(Td>=Ad){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

struct Edge {
  int from;
  int to;
  int d;
  Edge (int from, int to, int d)
    : from(from), to(to), d(d)
  {}
};

class People {
  vector<vector<Edge>> graph;
  vector<int> visited;
  vector<int> total;
  int n;
public:
  People () {
    int m;
    cin >> n >> m;
    graph.resize(n);
    visited.resize(n, 0);
    total.resize(n);
    int l, r, d;
    for (int i=0; i<m; ++i) {
      cin >> l >> r >> d;
      graph[l-1].emplace_back(l-1, r-1, d);
      graph[r-1].emplace_back(r-1, l-1, -d);
    }
  }

  bool visit (int v, int t) {
    if (0 < visited[v]) {
      return t == total[v];
    } else {
      total[v] = t;
      visited[v] = 1;
      for (Edge &e : graph[v]) {
        if (!visit(e.to, t + e.d)) {
          return false;
        }
      }
      visited[v] = 2;
      return true;
    }
  }
  bool solve () {
    for (int i=0; i<n; ++i) {
      if (0 == visited[i] && !visit(i, 0)) return false;
    }
    return true;
  }
};

int main () {
  People p;
  cout << (p.solve() ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 13312
import java.util.*;
public class Main {
	void doIt() {
		Scanner in = new Scanner(System.in);
		Player[][] playerArray = new Player [3][8];
		Player[] semiArray = new Player [18];
		for(int i = 0; i < 3; i++){
			for(int k = 0; k < 8; k++){
				playerArray[i][k] = new Player(in.nextInt(), in.nextDouble());
			}
			Arrays.sort(playerArray[i]);
		}
		int cnt = 0;
		for(int i = 0; i < 3; i++){
			for(int k = 2; k < 8; k++){
				semiArray[cnt] = playerArray[i][k];
				cnt++;
			}
		}
		Arrays.sort(semiArray);
		for(int i = 0; i < 3; i++){
			for(int k = 0; k < 2; k++){
				System.out.printf("%d %.2f\n",playerArray[i][k].num, playerArray[i][k].time);
			}
		}
		for(int i = 0; i < 2; i++){
			System.out.printf("%d %.2f\n",semiArray[i].num, semiArray[i].time);
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
	class Player implements Comparable<Player>{
		int num;
		double time;
		Player(int num, double time){
			this.num = num;
			this.time = time;
		}
		@Override
		public int compareTo(Player o) {
			if(this.time > o.time) return 1;
			else if(this.time < o.time) return -1;
			return 0;
		}
	}
}

Measured memory_bytes: 20280
#include<iostream>
using namespace std;
int main()
{
  int n;
  long long p = 1, mod = 1000000007ll;
  cin >> n;
  for(int i = 1; i <= n; i++)
  {
    p = p * i;
    p = p % mod;
  }
  cout << p;
  return 0;
}

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

using namespace std;
long long int a,b,c,d;
long long int judge(long long int);
long long int lcd(long long int,long long int);
long long int gcd(long long int ,long long int);

long long int judge(long long int x)
{
    if(x > b)
    {
        return 0;
    }
    if(a % x == 0)
    {
        return b / x - a / x + 1;
    }
    return b / x - a / x ;
}

long long int lcd(long long int x,long long int y)
{
   return x*y / gcd(x,y); 
}

long long int gcd(long long int x,long long int y)
{
    if(x < y)
    {
        long long int tmp = x;
        x = y;
        y = tmp;
    }
    long long int r = x % y;
    while(r > 0)
    {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main()
{
  cin >> a >> b >> c >> d;
  long long int result = b - a + 1 - judge(c) - judge(d) + judge(lcd(c,d));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int a, b;
    cin >> a >> b;
    int ans =0;
    FOR(i, a, b+1){
        if(i%10 == i/10000 && (i/1000)%10 == (i/10)%10) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
N=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  N[a]+=b
for i in range(10**5+1):
  k-=N[i]
  if k<=0:
    print(i)
    exit()

Measured memory_bytes: 11480
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll dp[10050][2][100]; //pos, less, mod d

int main () {
  string k;
  int d;
  cin >> k >> d;

  int n = sz(k);
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,d) {
      rep(dig,10) (dp[i+1][1][(j+dig)%d] += dp[i][1][j]) %= mod;
      rep(dig,k[i]-'0') (dp[i+1][1][(j+dig)%d] += dp[i][0][j]) %= mod;
      (dp[i+1][0][(j+k[i]-'0')%d] += dp[i][0][j]) %= mod;
    }
  }
  ll ans = (dp[n][0][0]+dp[n][1][0]-1+mod)%mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val v = in.readLine.split(" ").map(_.toInt)
  val c = in.readLine.split(" ").map(_.toInt)

  val ans = (0 until n)./:(0)((acc, i) => {
    val res = v(i) - c(i)
    if(res > 0) acc + res else acc
  })
  println(ans)
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    if (S[A] != '-')
    {
        cout << "No";
        return 0;
    }
    else
    {
        S.erase(A, 1);
        for (int i = 0; i < S.size(); ++i)
        {
            if (!isdigit(S[i]))
            {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import sys,collections,itertools
input = sys.stdin.readline
N=int(input())
a=list(map(int,input().split()))
A =[0]+list(itertools.accumulate(a))
Ac = collections.Counter(A)
cnt = 0
for val in Ac.values():
    cnt += val*(val-1)//2
print(cnt)

Measured memory_bytes: 44332
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int x, k, d;
    cin>>x>>k>>d;
    x = abs(x);

    int div = abs(x / d);
    int rem = abs(x) % d;

    if(div <= k){
        k -= div;

        if(k & 1) cout<<abs(x - div*d - d);
        else cout<<abs(x - div*d);
    }
    else{
        cout<<abs(x - k*d);
    }
} 

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
    int l=0, r=0, d = 0;
    int co = 0;
    int i = 0;
    scanf("%d %d %d", &l, &r, &d);

    for(i = l; i <= r; i++){
        if(i % d == 0)
            co++;
    }
    printf("%d \n", co);
    return 0;
}

Measured memory_bytes: 1736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int m,d,a,b,ans=0;cin>>m>>d;
    string s;
    for(int i=4;i<=m;i++){
        for(int j=22;j<=d;j++){
            s=str(j);
            a=s[0]-'0';
            b=s[1]-'0';
            if(a>1&&b>1&&a*b==i)ans++;
        }
    }
    cout<<ans<<endl;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
    string S = "abcdefghijklmnopqrstuvwxyz";

    char a;
    cin>>a;

    for(int i=0;i<S.size();i++){
        if(a==S.at(i)){
            cout<<S.at(i+1);
        }
    }
}



Measured memory_bytes: 256
import sys
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        sum=i*10000+j*5000+(n-i-j)*1000
        if sum==y and (n-i-j)>=0:
            print(i,j,n-i-j)
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 200005
#include <bits/stdc++.h>
using namespace std;

ll cal(ll x){
    if(x <= 1) return 0;
    ll res = x * (x-1);
    res /= 2;
    return res;
}

int main() {
    ll n, m, res;
    cin >> n >> m;
    res = cal(n) + cal(m);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
  size_t n;
  cin >> n;
  vector<pii> v[2];
  {
    std::map<int, int> tmp[2];  // (要素, 出現数)
    for (size_t i=0; i<n; i+=2)
      for (size_t j=0; j<2; ++j) {
        int v_i;
        std::cin >> v_i;
        ++tmp[j][v_i];
      }
    for (size_t j=0; j<2; ++j) {
      for (const auto& p: tmp[j])
        v[j].emplace_back(p.second, p.first);
      sort(v[j].begin(), v[j].end(), std::greater<>());
    }
  }
  auto f0=v[0].begin();
  auto f1=v[1].begin();

  if (v[0].size() == 1 && v[1].size() == 1) {
    if (f0->second == f1->second) {
      cout << n/2 << endl;
    } else {
      cout << "0\n";
    }
    return 0;
  }

  if (f0->second != f1->second) {
    cout << n-(f0->first+f1->first) << endl;
    return 0;
  }

  
  auto g0=next(f0);  
  auto g1=next(f1);  
  if (f0->first != f1->first) {
    if (f0->first > f1->first) {
      cout << n-(f0->first+g1->first) << endl;
    } else {
      cout << n-(g0->first+f1->first) << endl;
    }
    return 0;
  }

  cout << n-(f0->first+max(g0->first, g1->first)) << endl;
  return 0;
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
using namespace std;
 
int main(){
    
    int r,D,x[20];

    cin >> r>>D>>x[0];

    for(int i=1;i<=10;i++){
        x[i]=r*x[i-1] - D;
    }

    for(int i=1;i<=10;i++){
        cout << x[i] <<endl;
    }
    
    return 0;

}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc150/tasks/abc150_c

import itertools

if __name__ == "__main__":
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))

    A = [i for i in range(1, N+1)]
    S = set()
    a = 0
    b = 0
    for i, permutated in enumerate(itertools.permutations(A)):
        if permutated == P:
            a = i
        if permutated == Q:
            b = i

    print(abs(a-b))


Measured memory_bytes: 39024
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 14 20:27:59 2019

@author: ctiuser
"""
import sys

N = int(input())
A = list(map(int,input().split()))

A.sort()

if A[-1] == 0:
    print('Yes')
    sys.exit()

if N % 2 == 0:
    if A[0] == 0:
        flg = True
        if A[0] != A[N//2-1]:
            flg = False
        if A[N//2] != A[-1]:
            flg = False
        if flg:
            print('Yes')
            sys.exit()

flg = True
if N % 3 != 0:
    flg = False

if A[0] != A[N//3-1]:
    flg = False
if A[N//3] != A[(2*N)//3-1]:
    flg = False
if A[(2*N)//3] != A[(3*N)//3-1]:
    flg = False

if A[0] ^ A[N//3] != A[(2*N)//3]:
    flg = False

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14116
loop do
  h, w = gets.split(" ").map{|x| x.to_i}
  if h != 0 && w != 0
    puts "#" * w
    (h-2).times {puts "#" + "." * (w - 2) + "#"}
    puts "#" * w
    puts ""

  else
    break
  end
end

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


typedef struct{
	double value;
	double weight;
} DATA_T;

/*
int Median(DATA_T *data, int left, int right)
{
	int mid;

	mid = (left + right) / 2;

	if(data[left].value / data[left].weight < data[mid].value / data[mid].weight &&  data[mid].value / data[mid].weight < data[right].value / data[right].weight
	|| data[right].value / data[right].weight < data[mid].value / data[mid].weight && data[mid].value / data[mid].weight < data[left].value / data[left].weight)
		return mid;
	else if(data[mid].value / data[mid].weight < data[left].value / data[left].weight && data[left].value / data[left].weight <  data[right].value / data[right].weight
	|| data[right].value / data[right].weight < data[left].value / data[left].weight && data[left].value / data[left].weight <  data[mid].value / data[mid].weight)
		return left;
	else
		return right;
}
*/

int Partition(DATA_T *data, int left, int right)
{
	DATA_T tmp, x;
	int soeji;
	int i, j;

	i = left - 1;
	j = right;
//	soeji = right;//Median(data, left, right);
	x = data[right];

	while(1){
		while(data[++i].value / data[i].weight < x.value / x.weight);
//while(data[++i].value < x.value);
		while(i < --j && x.value / x.weight < data[j].value / data[j].weight);
//while(i < --j && x.value < data[j].value);
		if(j <= i)
			break;

		tmp = data[i];
		data[i] = data[j];
		data[j] = tmp;
	}

	tmp = data[i];
	data[i] = data[right];
	data[right] = tmp;

	return i;
}


void Quick_sort(DATA_T *data, int left, int right)
{
	int pivot;

	if(right <= left)
		return;

	pivot = Partition(data, left, right);

	Quick_sort(data, left, pivot - 1);

	Quick_sort(data, pivot + 1, right);
}


int main()
{
	int N, W;
	DATA_T *data;
	double max;
	int i, j;

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

	data = (DATA_T *)malloc(sizeof(DATA_T) * N);

	for(i = 0; i < N; i++)
		scanf("%lf %lf", &data[i].value, &data[i].weight);

	Quick_sort(data, 0, N - 1);


	max = 0;
	for(i = N - 1; i >= 0; i--){
		if(W - data[i].weight > 0){
			W -= data[i].weight;
			max += data[i].value;
		}else{
			max += data[i].value * W / data[i].weight;
			break;
		}
	}

	printf("%.8lf\n", max);

	return 0;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<((a+b+c-max({a,b,c}))%2==0?(max({a,b,c})*3-a-b-c)/2:(max({a,b,c})*3+3-a-b-c)/2)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

long long n, k, m, x[100010], d[100010], result, l = 0;
int main(){
	int t;
	cin >> t;
	for (int i = 0; i < t; i++){
		result = 0;
		cin >> n >> k;
		for (int j = 0; j < n; j++){ cin >> x[j]; }
		for (int j = 0; j + 1 < n; j++){ d[j] = x[j + 1] - x[j]; }
		sort(d, d + n - 1);
		m = max(l, n - k);

		for (int j = 0; j < m; j++)
			result += d[j];
		cout << result << endl;

	}
}

Measured memory_bytes: 2744
#include <iostream>
using namespace std;
#include <cmath>
#include <math.h> 

int main() {
  int n;
  cin >> n;
  int n2 =int (n/1.08);
  if( floor(n2 * 1.08) == n){
    cout << n2;
  } 
  else if (floor((n2+1) * 1.08) == n){
    cout << n2+1;
  }
  else{
    cout << ":(";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#define SWAP(type, x, y){type tmp = x; x = y; y = tmp;}
using namespace std;

using lint = boost::multiprecision::cpp_int;

lint gcd(lint x, lint y){
    if(x < y) SWAP(lint, x, y);
    while(y != 0){
        lint tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

lint lcm(lint x, lint y){
    // if(x == y) return x;
    return x*y / gcd(x, y);
}

int main(){
    int N;
    lint T, ans;
    cin >> N >> T;
    ans = T;
    for(int i=0;i<N-1;i++){
        cin >> T;
        // cout << "ans: " << ans << endl;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import math
N = int(input())
D,X = list(map(int, input().split()))
A = [int(input()) for _ in range(N)]

ans = 0
for d in range(1,D+1):
  for i in range(N):
    if((d - 1) % A[i] == 0):
      ans += 1
print(ans+X)

Measured memory_bytes: 3064
#include <stdio.h>

void swap(int *i, int *j)
{
	*i += *j;
	*j = *i - *j;
	*i -= *j;
}

int main(void)
{
	int a[5];
	int i, j;

	for (i = 0; i < 5; i++){
		scanf("%d", &a[i]);
	}

	for (i = 0; i < 4; i++){
		for (j = 0; j < 4 - i; j++){
			if (a[j] < a[j + 1]){
				swap(&a[j], &a[j + 1]);
			}
		}
	}

	for (i = 0; i < 5; i++){
		printf("%d", a[i]);

		if (i < 4){
			printf(" ");
		}
		else {
			printf("\n");
		}
	}

	return (0);
}

Measured memory_bytes: 600
while True:
    y = 0
    n,x = map(int, input().split(' '))
    if n == 0 and x == 0:
        break
    for i in range(1,n + 1):
        for j in range(1,n + 1):
            for m in range(1,n + 1):
                if i + j + m == x:
                    if i < j < m :
                        y = y + 1
    print(y)


Measured memory_bytes: 5596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int n;
	cin >> n;
	cout << 800 * n - 200 * (n / 15) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int y=*max_element(A.begin(),A.end());

  vector<bool>ok(10000000,true);

  for(int i=0;i<N;i++){
   int x=A[i];
   for(int j=2;j<=y/x;j++){
     ok[x*j]=false;
   }
   if(i<N-1&&A[i]==A[i+1]){ok[A[i]]=false;}
  }

  int cnt=0;
  for(int i=0;i<N;i++){
    if(ok[A[i]]){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 5288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a =new long[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextLong();
		}

		System.out.println(binarySearch(a));


	}

	static long binarySearch(long[] input) {
		int n=input.length;
		long max = Long.MAX_VALUE;
		long min =0;
		while (max>min) {
			long mid=min+(max-min)/2;
			if(done(input,mid)) {
				max=mid;
			} else if (nearDone(input,mid)) {
				for(long i = Math.max(0,mid-n); i<=mid; i++) {
					if(done(input,i)) {
						max=i;
						break;
					}
					if(i==mid) {
						min=mid+1;
					}
				}


			} else {
				min=mid+1;
			}
		}
		return min;
	}

	static boolean done(long[]input, long m) {
		int n=input.length;
		long count=0;
		for(int i=0;i<n;i++) {
			count+=(input[i]+m-(n-1)+n)/(n+1);
		}
		return count <= m;
	}

	static boolean nearDone(long[] input, long m) {
		int n=input.length;
		long count=0;
		for(int i=0;i<n;i++) {
			count+=(input[i]+m-(n+n-1)+n)/(n+1);
		}
		return count <= m;
	}
}


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

const int MAX = 200010;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int main(){
    ll n,k;cin>>n>>k;
    init();
    ll an=n*(n-1)%MOD+1;
    for(ll i=2;i<=min(n-1,k);i++){
        ll tmp=fac[n]*finv[i]%MOD*finv[n-i]%MOD*fac[n-1]%MOD*finv[n-i-1]%MOD*finv[i]%MOD;
        an+=tmp;
        an%=MOD;
    }
    cout<<an<<endl;
}

    









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

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

    int cnt = 0;
    rep(i, s.size()) {
        if (s[i] == 'o')
            ++cnt;
    }

    cnt += 15 - s.size();

    if (cnt >= 8)
        cout << "YES";
    else
        cout << "NO";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
v = [1, 5, 10, 50, 100, 500 ]

acm [] [] = 0
acm (a:as) (b:bs) = (a*b) + acm as bs

ans i v =
  let a = acm i v
  in
    if a >= 1000
    then 1
    else 0

main = do
  l <- getLine
  let i = map read $ words l :: [Int]
      o = ans i v
  print o
      

Measured memory_bytes: 3652
import java.awt.List;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	private static final boolean TEST = false;

	public static void main(String[] args) {

		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, k;
		if (TEST) {
			n = 10;
			k = 3;
		} else {
			n = in.nextInt();
			k = in.nextInt();
		}
		int[] p = new int[n];
		if (TEST) {
			for (int i = 0; i < n; i++)
				p[i] = i + 1;
			int c = (int) (Math.random() * 5);
			for (int i = 0; i < c; i++) {
				int a = (int) (Math.random() * n);
				int b = (int) (Math.random() * n);
				int t = p[a];
				p[a] = p[b];
				p[b] = t;
			}
			for (int i = 0; i < n; i++)
				System.out.print(p[i] + " ");
			System.out.println();
		} else {
			for (int i = 0; i < n; i++)
				p[i] = in.nextInt();
		}
		int r = 0;
		if (TEST) {
			r = testSolve(n, k, p);
			System.out.println(r);
			r = solve(n, k, p);
		} else
			r = solve(n, k, p);
		System.out.println(r);
		in.close();
	}

	private static int testSolve(int n, int k, int[] p) {
		int[][] t = new int[n - k + 1][n];
		for (int i = 0; i < t.length; i++) {
			t[i] = p.clone();
			Arrays.sort(t[i], i, i + k);
		}
		int r = 0;
		boolean[] f = new boolean[n];
		for (int i = 0; i < t.length; i++)
			if (f[i])
				continue;
			else {
				r++;
				for (int j = i + 1; j < t.length; j++) {
					f[j] = true;
					for (int x = 0; x < n; x++)
						if (t[i][x] != t[j][x]) {
							f[j] = false;
							break;
						}
				}
			}
		return r;
	}

	private static int solve(int n, int k, int[] p) {
		Deque<Integer> min = new ArrayDeque<>();
		Deque<Integer> max = new ArrayDeque<>();
		for (int i = 0; i < k; i++) {
			addMin(i, p, min);
			addMax(i, p, max);
		}
		boolean seq = false;
		if (min.size() == k)
			seq = true;
		int r = 1;
		for (int i = 0, j = k; j < n; i++, j++) {
			if (min.peekFirst() == i)
				min.pollFirst();
			if (max.peekFirst() == i)
				max.pollFirst();
			addMin(j, p, min);
			addMax(j, p, max);
			if (p[i] < p[min.peekFirst()] && j == max.peekFirst())
				continue;
			if (min.size() == k && seq)
				continue;
			r++;
			if (min.size() == k)
				seq = true;
//			System.out.println("-- " + i + " " + r);
		}
		return r;
	}

	private static void addMax(int e, int[] p, Deque<Integer> max) {
		while (!max.isEmpty()) {
			int r = max.peekLast();
			if (p[r] < p[e])
				max.pollLast();
			else
				break;
		}
		max.add(e);
	}

	private static void addMin(int e, int[] p, Deque<Integer> min) {
		while (!min.isEmpty()) {
			int r = min.peekLast();
			if (p[r] > p[e])
				min.pollLast();
			else
				break;
		}
		min.add(e);
	}
}

Measured memory_bytes: 91192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll a,b,c; cin>>a>>b>>c;
    ll k; cin>>k;
    rep(i,k){
        if(b<=a){
            b*=2;
            continue;
        }
        else if(c<=b){
            c*=2;
            continue;
        }
    }
    if(c>b&&b>a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


























































































Measured memory_bytes: 3628
class Node
  attr_accessor :left, :right, :parent, :height, :depth, :type, :sibling, :degree
  def initialize(ary)
    @left, @right = ary
    @parent = -1
    @height = 0
    @depth = 0
    @type = ""
    @sibling = -1
    @degree = 0
  end
end


#入力
n = gets.to_i
inputs = Array.new(n){gets.split.map(&:to_i)}

# nodesをidをキーとしたハッシュで持つ。
$nodes = inputs.inject({}){|memo, input| memo[input.shift] = Node.new(input);memo}

#parent, sibling, degreeをセット
def set_parent_and_sibling_and_degree
  $nodes.each_key do |key|
    if $nodes[key].left != -1
      $nodes[$nodes[key].left].parent = key.to_i
      $nodes[key].degree += 1
    end

    if $nodes[key].right != -1
      $nodes[$nodes[key].right].parent = key.to_i
      $nodes[key].degree += 1
    end

    if $nodes[key].left!=-1 && $nodes[key].right != -1
      $nodes[$nodes[key].left].sibling = $nodes[key].right
      $nodes[$nodes[key].right].sibling = $nodes[key].left
    end
  end
end

#rootをゲット
def root
  $nodes.each_key do |key|
    if $nodes[key].parent == -1
      return $nodes[key]
    end
  end
end

#heightをセット
def set_height(node)
  h1, h2 = 0, 0

  if node.left!=-1
    h1 = set_height($nodes[node.left]) + 1
  end

  if node.right!=-1
    h2 = set_height($nodes[node.right]) + 1
  end

  return node.height = [h1, h2].max
end

#depthをセット
def set_depth(node, cnt)
  node.depth = cnt
  if node.left!=-1
    set_depth($nodes[node.left], cnt+1)
  end
  if node.right!=-1
   set_depth($nodes[node.right], cnt+1)
  end
end

#typeをセット
def set_type
  $nodes.each_key do |key|
    if $nodes[key].parent == -1
      $nodes[key].type = "root"
    elsif $nodes[key].left == -1 && $nodes[key].right == -1
      $nodes[key].type = "leaf"
    else
      $nodes[key].type = "internal node"
    end
  end
end

set_parent_and_sibling_and_degree
set_height(root)
set_depth(root, 0)
set_type

$nodes.sort.each do |key, val|
  puts "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" % [key, val.parent, val.sibling, val.degree, val.depth, val.height, val.type]
end


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

int main () {
  int a, b; cin >> a >> b;
 int ans=0;
  
  int c,d,e,f,g;
  for (int i=a; i<= b; i++) {
    c = i % 10;
    d = i/10 % 10;
    e = i/100 % 10;	//chỉ cần so sánh đầu cuối nên số này ko cần
    f = i/1000 % 10;
    g = i/10000 % 10;

    if ( c==g && d==f) ans++;
  }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

vector<pair<int, int>> cord;

double calc(vector<pair<int, int>>& v){
    
    double dis = 0.0;    
    for(int i = 0; i < (v.size() - 1); i++){
        
        double x = (v[i].first - v[i+1].first) * (v[i].first - v[i+1].first);        
        double y = (v[i].second - v[i+1].second) * (v[i].second - v[i+1].second);  
        dis += sqrt((x + y));
    }

    return dis;
}

int main(){

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

    for(int i = 0; i < n; i++){
        int a, b;
        scanf("%d %d", &a, &b);

        cord.push_back(make_pair(a, b));        
    }    
    
    sort(cord.begin(), cord.end());
   
    double dist = 0.0, qtd = 0.0;
    do{

        qtd++;
        dist += calc(cord);

    }while(next_permutation(cord.begin(), cord.end()));

    printf("%.10lf\n", dist/qtd);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e5+5;
int prime[N],sum[N];
bool is_pr[N];
int cnt;
inline int Scan()
{
    int r = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        r = (r << 3) + (r << 1) + ch - '0';
        ch = getchar();
    }
    return r * f;
}
inline void Print(int x)
{
    if(x < 0)
    {
        x = -x;
        putchar('-');
    }
    if(x > 9)Print(x/10);
    putchar(x % 10 + '0');
}
void sieve()
{
    mem(is_pr,0);
    for(int i=2; i<N-4; i++)
    {
        if(!is_pr[i])
        {
            for(int j=i+i; j<N-4; j+=i)
                is_pr[j]=1;
        }
    }
}
int main()
{
    sieve();
    for(int i=3;i<N-4;i+=2) if(!is_pr[i] && !is_pr[(i+1)/2]) sum[i]++;
    rep(i,2,N-4) sum[i] += sum[i-1];
    int q;
    while(~scanf("%d",&q))
    {
        while(q--)
        {
            int l,r;
            l = Scan();
            r = Scan();
            Print(sum[r] - sum[l-1]);
            puts("");
        }
    }
    return 0;
}


Measured memory_bytes: 1152
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 100006
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll head[MAXN],b[MAXN],dis[MAXN],len1[MAXN],len2[MAXN],ans[MAXN];
queue<ll> q;
struct  po
{
	ll nxt,to,dis1,dis2;
}edge[MAXN<<2];
struct pp{
	ll ans,id;
}d[MAXN];
ll n,m,s,t,num,sum=1000000000000000ll;
inline void add_edge(ll from,ll to,ll dis1,ll dis2)
{
	edge[++num].nxt=head[from];
	edge[num].to=to;
	edge[num].dis1=dis1;
	edge[num].dis2=dis2;
	head[from]=num;
}
inline void spfa1(int s)
{
	memset(b,0,sizeof(b));
	memset(dis,126,sizeof(dis));
	q.push(s);
	b[s]=1;
	dis[s]=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		b[u]=0;
		for(re int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(dis[v]>dis[u]+edge[i].dis1){
				dis[v]=dis[u]+edge[i].dis1;
				if(!b[v]){
					b[v]=1;
					q.push(v);
				}
			}
		}
	}
}
inline void spfa2(int s)
{
	memset(b,0,sizeof(b));
	memset(dis,126,sizeof(dis));
	q.push(s);
	b[s]=1;
	dis[s]=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		b[u]=0;
		for(re int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(dis[v]>dis[u]+edge[i].dis2){
				dis[v]=dis[u]+edge[i].dis2;
				if(!b[v]){
					b[v]=1;
					q.push(v);
				}
			}
		}
	}
}
inline bool cmp(pp a,pp b)
{
	return a.ans<b.ans;
}
int main() 
{
	cin>>n>>m>>s>>t;
	for(re int i=1;i<=m;i++){
		ll x,y,a,b;
		cin>>x>>y>>a>>b;
		add_edge(x,y,a,b);
		add_edge(y,x,a,b);
	}
	
	spfa1(s);
	for(re int i=1;i<=n;i++)
		len1[i]=dis[i];
	spfa2(t);
	for(re int i=1;i<=n;i++)
		len2[i]=dis[i];
	for(re int i=1;i<=n;i++){
		d[i].ans=len1[i]+len2[i];
		d[i].id=i;
	}
	sort(d+1,d+1+n,cmp);
	int x=1;num=1;
	while(num<=n){
		while(d[x].id>=num){
			cout<<sum-d[x].ans<<endl;
			num++;
		}
		x++;
	}	
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  int x=7%k;
  set<int>s;
  int i=1;
  while(s.count(x)==0){
    if(x==0){
      cout<<i<<endl;
      return 0;
    }
    s.insert(x);
    x=(x*10+7)%k;
    ++i;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 50444
// Author - Sumit

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define int ll
#define ps push
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repd(i,a,b) for (int i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pair<int,int>>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

void solve(){
    int n,w;
    cin>>n>>w;
    int wt[n],v[n];
    rep(i,0,n){
        cin>>wt[i]>>v[i];
    }
    int dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    rep(i,1,n+1){
        rep(j,1,w+1){
            if(j<wt[i-1]){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-wt[i-1]]+v[i-1]);
            }
        }
    }
    // rep(i,0,n+1){
    //     rep(j,1,w+1){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    debug(dp[n][w]);
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t=1;
    // cin>>t;
    WL(t){
        solve();
    }    
}

Measured memory_bytes: 79104
N, Y = map(int,input().split())
l0 = ""
for i in range(N+1):
  for j in range(N+1):
    z = Y - (10000*i) - (5000*j)
    k = z // 1000
    if z % 1000 == 0 and i+j+k == N and 0 <= k <= N:
      l0 = str(i) + " " + str(j) + " " + str(k)
    else:
      l1 = "-1 -1 -1"
if l0 != "":
  print(l0)
else:
  print(l1)

Measured memory_bytes: 3188