akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <tuple>
#include <vector>
#include <unordered_map>
#include <iostream>
using namespace std;

long long encode(long long p, long long q, long long r, long long s) {
    return (((p << 10) + q) << 20) + (((r << 10) + s));
}

tuple<int, int, int, int> decode(long long x) {
    int p = x >> 30, q = (x >> 20) & 1023, r = (x >> 10) & 1023, s = x & 1023;
    return {p, q, r, s};
}

long long rotate(long long x) {
    return (x >> 30) | ((x & ((1 << 30) - 1)) << 10);
}

int multiplicity(long long x) {
    auto [p, q, r, s] = decode(x);
    if (p == r && q == s)
        return p == q ? 4 : 2;
    else
        return 1;
}

int main() {
    int n; cin >> n;
    unordered_map<long long, int> cnt;
    vector<long long> tiles;
    for (int i = 0; i < n; i++) {
        int p, q, r, s; cin >> p >> q >> r >> s;
        long long x = encode(p, q, r, s);
        for (int j = 0; j < 4; j++, x = rotate(x)) {
            cnt[x]++;
            tiles.push_back(x);
        }
    }
    long long ans = 0;
    unordered_map<long long, int> want;
    for (int i = 0; i < tiles.size(); i += 4) {
        const long long x = tiles[i];
        for (long long x1 = x, a = 0; a < 4; a++, x1 = rotate(x1)) cnt[x1]--;
        for (int j = i / 4 * 4 + 4; j < tiles.size(); j++) {
            const long long y = tiles[j];
            assert (cnt[y] > 0);
            for (long long y1 = y, a = 0; a < 4; a++, y1 = rotate(y1)) cnt[y1]--;
            auto [p, q, r, s] = decode(x);
            auto [t, u, v, w] = decode(y);
            want.clear();
            want[encode(u, t, q, p)]++;
            want[encode(q, t, w, r)]++;
            want[encode(u, p, s, v)]++;
            want[encode(w, v, s, r)]++;
            long long prod = 1;
            bool ok = true;
            for (auto [z, k] : want) if (cnt[z] == 0)  { ok = false; break; }
            if (ok) {
                for (auto [z, k] : want) {
                    const int m = multiplicity(z);
                    assert (cnt[z] % m == 0);
                    for (int i = 0; i < k; i++) prod *= cnt[z] - m * i;
                    for (long long z1 = z, a = 0; a < 4; a++, z1 = rotate(z1)) cnt[z1] -= k;
                }
                for (auto [z, k] : want) {
                    for (long long z1 = z, a = 0; a < 4; a++, z1 = rotate(z1)) cnt[z1] += k;
                }
                ans += prod;
            }
            for (long long y1 = y, a = 0; a < 4; a++, y1 = rotate(y1)) cnt[y1]++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 21056
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3) {
        rep(j,3) cin >> a[i][j];
    }
    rep(i,3) {
        rep(j,3) {
            a[i][j]-=a[2][j];
        }
    }
    bool flag=1;
    rep(i,3) {
        rep(j,2) {
            if (a[i][j]!=a[i][2]) flag=0;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

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

    bool flag = true;
    for(int i=0; i<S.size(); i++){
        if(i%2==0 && S[i]=='L') flag = false;
        if(i%2==1 && S[i]=='R') flag = false;
    }

    if(flag) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
let rec power x n =
  if n <= 0 then 1
  else if n mod 2 = 0 then
    power (x*x) (n/2)
  else
    x * power x (n - 1)
let () =
  let d, n = Scanf.scanf "%d %d" (fun d n -> d, n) in
  let s = Array.init 101 (fun i -> if d = 0 then
                                     (if i = 100 then 101
                                      else i)
                                   else (if i = 100 then
                                           (i+1) * (power 100 d)
                                         else
                                           i * (power 100 d))) in 
  Printf.printf "%d\n" (s.(n))


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



int main() {
	ll N, M;
	cin >> N >> M;

	if (N % 2 == 1) {
		repn(i, M) {
			cout << i << " " << N+1 - i << endl;
		}
	}

	else {
		ll L = N / 4;
		repn(i, min(M, L)) {
			cout << i << " " << N+1 - i << endl;
		}
		for (ll i = L + 1; i <= M; i++) {
			cout << i << " " << N - i << endl;
		}
	}
	
	system("PAUSE");
}


Measured memory_bytes: 3704
using System;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    int m = 0, a = 1;
    for (int i = 1; i <= n; i++) {
      int t = Cnt(i);
      if (m < t) {
        m = t;
        a = i;
      }
    }
    Console.WriteLine(a);
  }

  static int Cnt(int n) {
    int cnt = 0;
    while (n % 2 == 0) {
      cnt++;
      n /= 2;
    }
    return cnt;
  }
}

Measured memory_bytes: 11092
n=int(input())
if n%10==3:
    print('bon')
elif n%10==0:
    print('pon')
elif n%10==1:
    print('pon')
elif n%10==6:
    print('pon')
elif n%10==8:
    print('pon')
else:
    print('hon')
    

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long l;
void solve(int k,int a,int b)
{
    int rem;
    rem = b%k;
    if(b - rem >= a)
        cout<<"OK";
    else
        cout<<"NG";
}
int main()
{
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    solve(k,a,b);
    return 0;
}

Measured memory_bytes: 3592
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
p = LI()
a = [i * 30000 for i in range(1, n + 1)]
b = [i * 30000 for i in range(n, 0, -1)]
for i in range(n):
    a[p[i] - 1] += i


print(*a)
print(*b)


Measured memory_bytes: 46044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n;
	cin >> n;
	vector<ld> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<vector<ld>> dp(n+1, vector<ld>(n+1, 0));
	dp[1][0] = 1 - p[0];
	dp[1][1] = p[0];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i+1][j] += dp[i][j] * (1 - p[i]);
			dp[i+1][j+1] += dp[i][j] * p[i];
		}
	}
	ld ans = 0;
	for (int j = n/2 + 1; j <= n; j++) {
		ans += dp[n][j];
	}
	cout << fixed << setprecision(10) << ans << endl;
}




Measured memory_bytes: 141056
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    vector<int>v(3);rep(i,3)cin>>v[i];
    sort(all(v));
    int a=v[0];
    int b=v[1];
    int c=v[2];
    if((c-a)%2==0&&(c-b)%2==0){
        cout<<(c-a)/2+(c-b)/2<<endl;
    }else if((c-a)%2&&(c-b)%2){
        cout<<(c-a)/2+(c-b)/2+1<<endl;
    }else{
        if((c-a)%2)swap(a, b);
        cout<<(c+1-a-1)/2+(c+1-b-2)/2+2<<endl;
    }
}


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

//iteration
#define rep(i,m) for(int i=0;i<(m);++i)
#define rev(i,m) for(int i=(int)(m) - 1;i>=0;--i)
#define repn(i) for(int i = 0; i < n; ++i)
#define revn(i) for(int i=(int)(n) - 1;i>=0;--i)

//IO
#define newline() cout<<'\n'
#define line(s) cout<<(s)<<'\n'
#define spaced(s) cout<<(s)<<' '
#define rint(n) int n;cin>>n

#define all(x) (x).begin(),(x).end()
#define sqr(x) ((x)*(x))
#define present(c,x) ((c).find(x) != (c).end()) 

#define long long long

using namespace std;

//constants
const int inf = 1234567890;
const long infl = 8876543210123456789ll;
const int MOD = 1000000007;

void init() {
	ios::sync_with_stdio(false);
	cin.tie(0);
}

template <class RandomAccessIterator>
void print(RandomAccessIterator a, RandomAccessIterator b) {
	for (; a < b; ++a) {
		line(*a);
	}
}

template <class RandomAccessIterator>
void println(RandomAccessIterator a, RandomAccessIterator b) {
	for (; a < b; ++a) {
		spaced(*a);
	}
	newline();
}

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
#pragma endregion

int a[100];

int main() {
	init();
	rint(n);
	repn(i) cin >> a[i];
	int best = inf;
	for (int i = -100; i <= 100; i++) {
		int sum = 0;
		repn(j) sum += sqr(i - a[j]);
		best = min(best, sum);
	}
	line(best);
}

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

int main() {

  string S, T;
  cin >> S >> T;

  ll max = 0;
  ll tmp;
  for(int i = 0; i < S.length() - T.length() + 1; i++){
    tmp = 0;
    for(int j = 0; j < T.length(); j++){
      if(S[i + j] == T[j]){
        tmp++;
      }
    }
    if(tmp > max){
      max = tmp;
    }
  }
  cout << T.length() - max << endl;
}


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

struct S { int bg, ed, ar; };

int main()
{
	string s;
	cin >> s;
	
	stack<int> st;
	vector<S> v;
	
	bool f = false;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == '\\'){
			st.push(i);
		}
		if (s[i] == '/'){
			if (st.empty()) continue;
			int ar = i - st.top();
			while (!v.empty() && st.top() < v.back().bg){
				ar += v.back().ar;
				v.pop_back();
			}
			v.push_back({st.top(), i, ar});
			st.pop();
		}
	}
	
	int area = 0;
	for (S &a : v) area += a.ar;
	cout << area << endl;
	
	cout << v.size();
	for (S &a : v) cout << " " << a.ar;
	cout << endl;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower)
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper)
//#define min(a) *min_element(a.begin(),a.end())
//#define max(a) *max_element(a.begin(),a.end())
#define pdd pair<long double,long double>
#define prnt(a) for(auto x:a) cout<<x<<" ";
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'
#define PI 3.1415926535897932385
#define INF 1000000000000000
#define M 1000000007
#define ve  vector<ll>;
ll n;
ll w;
vector<ll>a(1e5);
vector<vector<ll>>dp(1e5+1,vector<ll>(100+1,-1));

 
 
int main()
{

string s;
cin>>s;

ll sum=0;
for(auto x:s)
{
	sum+=x-'0';
	

}
if(sum%9==0)
{
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}


  
return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, R, r[8], d[200][200], INF = 1e8;

int main() {
	cin >> n >> m >> R;
	inc(i, R) { cin >> r[i]; r[i]--; }
	
	inc(i, n) {
	inc(j, n) {
		d[i][j] = INF;
	}
	}
	inc(i, n) { d[i][i] = 0; }
	
	inc(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	
	inc(k, n) {
	inc(i, n) {
	inc(j, n) {
		setmin(d[i][j], d[i][k] + d[k][j]);
	}
	}
	}
	
	int p[8];
	inc(i, R) { p[i] = i; }
	
	int ans = INF;
	do {
		int sum = 0;
		inc(i, R - 1) { sum += d[r[p[i]]][r[p[i + 1]]]; }
		setmin(ans, sum);
	} while(next_permutation(p, p + R));
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include<cmath>
#include<ctime>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include <cstdio>
#include <string>
using namespace std;
int n;
vector<pair<int, int> >ans;
int main(){
    scanf("%d", &n);
    if (n & 1) {
        for (int i = 1; i <= n; i++)
            for (int j = i + 1; j <= n; j++)
                if (j + i != n)
                    ans.push_back(make_pair(i, j));
        printf("%d\n", ans.size());
        for (auto u: ans)
            printf("%d %d\n", u.first, u.second);
    } else{
        for (int i = 1; i <= n; i++)
            for (int j = i + 1; j <= n; j++)
                if (j + i != n + 1)
                    ans.push_back(make_pair(i, j));
        printf("%d\n", ans.size());
        for (auto u: ans)
            printf("%d %d\n", u.first, u.second);

    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll fact[MAX];
ll rfact[MAX];

ll comb(ll n, ll k) {
    return fact[n]*rfact[k]%MOD*rfact[n-k]%MOD;
}

ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}


int main(void) {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    ll i, j;
    fact[0]=rfact[0]=1;
    for(i=1; i<MAX; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modPow(fact[i], MOD-2);
    }
    
    ll ans=0;
    for(j=B; j<W; j++) {
        ans+=comb(H-1-A+j, j)*comb(A+W-j-2, W-1-j)%MOD;
        ans%=MOD;
    }
    prin(ans);
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxN=1000100<<1;
const int Mod=1e9+7;

int n;
int F[maxN],G[maxN];

int main(){
    scanf("%d",&n);
    F[0]=G[0]=1;
    for (int i=1;i<=n+n;i++){
        int l=max(0,i-n-1),r=min(n-1,i-3);
        if (l<=r) F[i]=(((F[i]+G[r]-(l?G[l-1]:0))%Mod)+Mod)%Mod;
        if (i<=n) F[i]=(F[i]+F[i-1])%Mod;
        G[i]=(G[i-1]+F[i])%Mod;
    }
    int Ans=(G[n+n]-G[n-1]+Mod)%Mod;
    for (int i=0;i+2<=n;i++){
        if (i+2<=n) Ans=(Ans+1ll*F[i]*(n-1)%Mod*(n-1)%Mod)%Mod;
        //else if (i+1<=n) Ans=(Ans+1ll*F[i]*(n-1)%Mod)%Mod;
    }
    printf("%d\n",Ans);return 0;
}

Measured memory_bytes: 15744
#include "bits/stdc++.h"
using namespace std;
 
#define nl '\n'
#define ll long long 
#define ull unsigned long long
#define debug(x)       { cerr << #x << " = " << x << endl; } 
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
const int Max = (int)2e5+5;
 
//functions
ll lcm(ll a,ll b) {if(a==0 || b==0){return 0;}else{return (a*b)/__gcd(a,b);}}
 
//direction arry
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
//____________________________________________________________________________________________________
void solve()
{
    int k;cin>>k;
    string s;cin>>s;
    if(s.size()>k)
        s=s.substr(0,k)+"...";
    cout<<s<<endl;
}
int main()
{
    fastread;
    int tc=1;
    // cin>>tc;
    while(tc--){
        solve();
    }
    return 0;
}

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

# dp[i][j]
# 上からi桁目まで見たとき、
# j=0:XがK未満であることが未確定である場合の、f(X)の最大値
# j=1:XがK未満であることが確定である場合の、f(X)の最大値
#
# XがK未満であることが確定->確定の遷移
#  Xiは0でも1でも可なので、Aiの0と1の個数のうち多い方を足せばよい。
# XがK未満であることが未確定->確定の遷移
#  Kiが1でXiを0としたとき、未確定->確定となる。
#  Xiを0にするということは、Aiの1の個数を足すことになる。
# XがK未満であることが未確定->未確定の遷移
#  (1)Kiが1でXiを1としたとき(2)Kiが0でXiを0としたときの2パターンがある。
#  (1)の場合はAiの0の個数、(2)の場合はAiの1の個数を足すことになる。

MAX_DIGIT = 42
dp = [[-1 for _ in range(2)] for _ in range(MAX_DIGIT+1)]
dp[MAX_DIGIT][0] = 0
for i in range(MAX_DIGIT-1,-1,-1):
  c0 = c1 = 0
  for a in A:
    if (a>>i)&1 == 1:
      c1 += 1
    else:
      c0 += 1
  if dp[i+1][1] >= 0:
    # 確定->確定
    dp[i][1] = dp[i+1][1] + max((c1<<i),(c0<<i))
  if dp[i+1][0] >= 0:
    if (K>>i)&1 == 1:
      # 未確定->未確定でKi=1&Xi=1
      dp[i][0] = dp[i+1][0] + (c0<<i)
      # 未確定->確定(つまりKi=1&Xi=0) 
      dp[i][1] = max(dp[i][1], dp[i+1][0] + (c1<<i))
    else:
      # 未確定->未確定でKi=0&Xi=0
      dp[i][0] = dp[i+1][0] + (c1<<i)
# dp[0][0]:最後まで XがK未満であることが未確定、つまりK=Xの場合の最大値
# dp[0][1]:XがK未満である場合の最大値
print(max(dp[0][0],dp[0][1]))
#print(dp)


Measured memory_bytes: 68696
#include <cstdio>
#include <queue>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

const int inf = 1e9;

typedef pair<int, int> P;

struct E{
	E(int t, int c): t(t), c(c){}

	int t, c;
};

int n, m, l, k, a, h;
vector<E> g[20200];
int d[20200];

int index(int i, int j, int k){
	return (i * n + j) * (m + 1) + k;
}

int main(){
	while(scanf("%d%d%d%d%d%d", &n, &m, &l, &k, &a, &h), n){
		rep(i, l){
			int a;
			scanf("%d", &a);
			rep(j, m + 1){
				for(int k = j; k <= m; ++k){
					g[index(0, a, j)].push_back(E(index(1, a, k), k - j));
				}
			}
		}
		rep(i, k){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			rep(j, m - c + 1){
				g[index(1, a, j + c)].push_back(E(index(0, b, j), c));
				g[index(1, b, j + c)].push_back(E(index(0, a, j), c));
			}
		}
		rep(i, n){
			rep(j, m + 1){
				g[index(0, i, j)].push_back(E(index(1, i, j), 0));
			}
		}

		fill_n(d, index(2, 0, 0), inf);

		priority_queue<P, vector<P>, greater<P> > q;
		d[index(1, a, m)] = 0;
		q.push(P(0, index(1, a, m)));
		while(!q.empty()){
			P v = q.top();
			q.pop();
			if(v.first > d[v.second]){
				continue;
			}
			rep(i, g[v.second].size()){
				E e = g[v.second][i];
				if(d[e.t] > v.first + e.c){
					d[e.t] = v.first + e.c;
					q.push(P(d[e.t], e.t));
				}
			}
		}

		int ans = inf;
		rep(i, m + 1){
			ans = min(d[index(0, h, i)], ans);
		}
		if(ans != inf){
			printf("%d\n", ans);
		}
		else{
			puts("Help!");
		}

		rep(i, index(2, 0, 0)){
			g[i].clear();
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n)
{
    ll r=n%4;
    if(n<0) return 0;
    if(r==0) return n;
    else if(r==1) return 1;
    else if(r==2) return n+1;
    return 0;
}

int main(void)
{
    while(1){
        ll n; cin>>n;
        if(n==0) break;
        double sum=0,ave=0;
        vector<double> a(n);
        rep(i,n){
            cin>>a[i];
            sum+=a[i];
        }
        ave=sum/n;
        double s=0;
        rep(i,n){
            s+=(a[i]-ave)*(a[i]-ave);
        }
        s/=n;
        s=sqrt(s);
        printf("%lf\n",s);
    }
    return 0;
}


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

int main(){
	int X;
	cin>>X;
	if(400<=X and X<=599){
		cout<<8<<endl;
	}else if(600<=X and X<=799){
		cout<<7<<endl;
	}else if(800<=X and X<=999){
		cout<<6<<endl;
	}else if(1000<=X and X<=1199){
		cout<<5<<endl;
	}else if(1200<=X and X<=1399){
		cout<<4<<endl;
	}else if(1400<=X and X<=1599){
		cout<<3<<endl;
	}else if(1600<=X and X<=1799){
		cout<<2<<endl;
	}else if(1800<=X and X<=1999){
		cout<<1<<endl;
	}	
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

def warshal_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        
  return d

n, m, l = map(int, input().split())
d = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
  d[i][i] = 0

for i in range(m):
  a, b, c = map(int, input().split())
  a, b = a-1, b-1
  d[a][b] = c
  d[b][a] = c
  
d = warshal_floyd(d)

d2 = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
  d2[i][i] = 0
  
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      d2[i][j] = 1

d2 = warshal_floyd(d2)

q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  s, t = s-1, t-1
  if d2[s][t] == float('inf'):
    print(-1)
  else:
    print(d2[s][t]-1)
  

Measured memory_bytes: 130268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <limits.h>
typedef long long ll;

using namespace std;

int f[100][10];
int cnt[100];
ll p[100][11];

int main()
{
	int n,now;
	ll pp=0;
	ll max=LLONG_MIN;
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cnt[i]=0;
		for(int j=0;j<10;j++)
		{
			cin>>f[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<11;j++)
		{
			cin>>p[i][j];
		}
	}

	//ここから解答
	for(int i=1;i<1024;i++)
	{
		//各種変数の初期化
		pp=0;
		for(int j=0;j<n;j++)
		{
			cnt[j]=0;
		}
		//店ごとに開いている時間数を求める
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<10;k++)
			{
				now = i&(int)pow(2,k);//いまチェックしている時間
				if(now==(int)pow(2,k)&&f[j][k]==1)
				{
					cnt[j]++;
				}
			}
		}
		
		/*for(int j=0;j<n;j++)
		{
			cerr<<i<<":"<<cnt[j]<<endl;
		}*/
		//利益を求める
		for(int j=0;j<n;j++)
		{
			pp+=p[j][cnt[j]];
		}
		//最大値と比較する
		if(pp>max)
		{
			max=pp;
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <numeric>
#include <map>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;


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

	int n;
	cin >> n;
	double s = 0;
	for (int i = 0; i < n; i++)
	{
		double x;
		cin >> x;
		s += 1.0 / x;
	}
	cout << fixed << setprecision(10) << 1.0 / s;
}

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

int main() {
    long a, b, x;
    cin >> a >> b >> x;

    long ans;
    if (a != 0) {
        ans = b / x - (a - 1) / x;
    }
    else {
        ans = b / x + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> G(n);
	rep(i, m) {
		int x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	vector<int> seen(n);
	int ans = 0;
	rep(i, n) {
		queue<int> que;
		if (seen[i]) continue;
		ans++;
		seen[i] = 1;
		que.push(i);
		while (!que.empty()) {
			int v = que.front();
			que.pop();
			for (auto nv : G[v]) {
				if (seen[nv]) continue;
				que.push(nv);
				seen[nv] = 1;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

void __print(int x) { cerr << x; }

void __print(long x) { cerr << x; }

void __print(long long x) { cerr << x; }

void __print(unsigned x) { cerr << x; }

void __print(unsigned long x) { cerr << x; }

void __print(unsigned long long x) { cerr << x; }

void __print(float x) { cerr << x; }

void __print(double x) { cerr << x; }

void __print(long double x) { cerr << x; }

void __print(char x) { cerr << '\'' << x << '\''; }

void __print(const char *x) { cerr << '\"' << x << '\"'; }

void __print(const string &x) { cerr << '\"' << x << '\"'; }

void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i: x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}

void _print() { cerr << "]\n"; }

template<typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
#define INF 1e18
#define MOD 1e9+7
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

inline void solve() {
    int n;
    cin >> n;
    char d = (char) ((int) '0' + n % 10);
    if (d == '3') {
        cout << "bon";
    } else if (d == '0' || d == '1' || d == '6' || d == '8') {
        cout << "pon";
    } else {
        cout << "hon";
    }
}

signed main() {
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

int main(){
  int m,f,r,sum;

  while(1){
    sum = 0;
    cin >> m >> f >> r ;
    sum = m+f;
    if ( m == -1 && f == -1 && r == -1)break;
    else {
      if ( m < 0 || f < 0 || sum < 30){
	cout << "F" << endl;
      }
      else if ( 30 <= sum && sum < 50){
	if ( r >= 50){
	  cout << "C" <<endl;
	}
	else {
	  cout << "D" << endl;
	}
      }
      else if ( 50 <= sum && sum < 65){
	cout << "C" <<endl;
      }
      else if ( 65 <= sum && sum < 80){
	cout << "B" <<endl;
      }
      else if ( 80 <= sum ){
	cout << "A" <<endl;
      }
    }
  }

  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int x; scanf("%d",&x);
	rep(k,1001) if(x-100*k>=0) {
		int y=x-100*k,cnt=0;
		cnt+=y/5;
		if(y%5>0) cnt++;
		if(cnt<=k) return puts("1"),0;
	}
	puts("0");
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<lint,lint>pll;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int main(){
  int n;
  cin>>n;
  vector<pll>ab(n);
  rep(i,n){
    lint a,b;
    cin>>a>>b;
    ab[i]=pll(a,b);
  }
  sort(ab.rbegin(),ab.rend());
  cout<<ab[0].first+ab[0].second<<endl;
}


Measured memory_bytes: 1792
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    println(when (readLine()!!) {
        "25" -> "Christmas"
        "24" -> "Christmas Eve"
        "23" -> "Christmas Eve Eve"
        else -> "Christmas Eve Eve Eve"
    })
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    double n,t,a;
    cin>>n>>t>>a;
    vd h(n);
    int ans=0;
    double k=1000000000;
    rep(i,n){
        cin>>h[i];
        h[i]=abs(a-(t-h[i]*0.006));
        if(k>h[i]){
            ans=i;
            k=h[i];
        }
    }
    cout<<ans+1<<endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    Vs s(h);
    REP(i,0,h) cin>>s[i];
    
    VVi dp(h,Vi(w,0));
    dp[0][0]=1;
    
    REP(i,0,h){
        REP(j,0,w){
            if(i==0 && j==0) continue;
            if(s[i][j]=='#') dp[i][j]=0;
            else if(i==0) dp[i][j]=dp[i][j-1];
            else if(j==0) dp[i][j]=dp[i-1][j];
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return

int main(){
    CIN(N);
    map<string,int> vec1,vec2;
    REP(a,N){
        string s;cin >> s;
        if(vec1.find(s)==vec1.end()){
            vec1[s]=1;
        }else{
            vec1[s]++;
        }
    }
    CIN(M);
    REP(a,M){
        string s;cin >> s;
        if(vec2.find(s)==vec2.end()){
            vec2[s]=1;
        }else{
            vec2[s]++;
        }
  }
    int ans = 0;
    FOREACH(a,vec1){
        int s;
        if(vec2.find(a.first)==vec2.end()){
            s = a.second;
        }else{
            //cout<<a.first<<" "<<a.second<<"-"<<vec2[a.first]<<endl;
            s = max(a.second-vec2[a.first],0);
        }
        ans = max(s,ans);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int sumOfSum = 0;
		for (int i = 0; i <= n; i++) {
			int sum = 0;
			for (int j : Main.split(i)) {
				sum += j;
			}

			if (a <= sum && sum <= b) {
				sumOfSum += i;
			}
		}
		System.out.println(sumOfSum);

		scanner.close();
	}
	
	public static int[] split(int number) {
		int degits = String.valueOf(number).length();
		int[] numbers = new int[degits];
		
		for (int i = degits - 1; i >= 0; i--) {
			numbers[i] = number % 10;
			number /= 10;
		} 
		
		return numbers;
	}
}

Measured memory_bytes: 22100
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100010;

struct Edge{ int to, next;} edge[N * 2];
int head[N], num;
void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}

int s[N], ans;

void dfs(int x, int f)
{
	int tmp = 0;
	RepG(i, x) if (v != f){
		dfs(v, x);
		int ts = (s[v] & s[x]), t0 = 20;
		if (ts) {
			while (!(ts & (1 << t0))) t0 --; 
			tmp = max(tmp, t0 + 1);
		}
		s[x] |= s[v];
	}
	//if (tmp) Rep0(i, tmp - 1) s[x] ^= (1 << i);
	for (int i = tmp; i <= 20; i ++){
		if (!(s[x] & (1 << i))){
			s[x] = ((s[x] >> i) << i);
			s[x] |= (1 << i), ans = max(ans, i);
			break;
		}
		//else s[x] ^= (1 << i);
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge(a, b); add_edge(b, a);
	}
	
	dfs(1, 0);
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 5888
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#define out(S) cout<<(S)<<endl;


int main()
{
	int N;
	int T[100];
	ll sum = 0;
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		T[i] = t;
		sum += t;
	}
	int M;
	cin >> M;
	vector<ll> ans;
	for (size_t i = 0; i < M; i++)
	{
		int P, X;
		cin >> P >> X;
		ans.push_back((ll)(sum - T[P - 1] + X));
	}
	for (auto a : ans) {
		out(a);
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String s=gs();
	int x=s.indexOf('A');
	int y=s.lastIndexOf('Z');

	    	System.out.println(y-x+1);
	    
        //System.out.println(e);
//        if (xo>w || yo>h) {
//        	System.out.print(0);
//        }else {
//        	System.out.print((h-yo)*(w-xo));
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39828
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使う
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);
	var answer = "Yes";
  	if( a + b < c ){
      answer = "No";
    }
	//出力
	console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int n;
int a, b;
vector<int> c;
vector<int> d;
vector<vector<int>> path;
vector<int> visited;
int ans;

void dfs(int now) {
    visited[now] = 1;
    for (size_t i = 0; i < path[now].size(); i++) {
        int next = path[now][i];
        if (!visited[next]) dfs(next);
    }
    d[now] = c.back();
    c.pop_back();
}

int main(void)
{
    cin >> n;
    c = vector<int>(n);
    d = vector<int>(n);
    path = vector<vector<int>>(n);
    visited = vector<int>(n, 0);
    for (int i = 0; i < n; i++) {
        path[i] = vector<int>();
    }
    for (int i = 0; i < n-1; i++) {
        cin >> a >> b;
        a--;
        b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end(), greater<int>());
    int score = accumulate(c.begin()+1, c.end(), 0);
    cout << score << endl;
    dfs(0);
    for (size_t i = 0; i < d.size(); i++) {
        cout << d[i];
        if (i < d.size()-1) cout << " ";
        else cout << endl;
    }
    return 0;
}



Measured memory_bytes: 1280
n=int(input());l=list(map(int,input().split()));p=[0]*n;d=[0]*n
for i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if i&1else d[i-1],l[i]+d[i-2])
print(d[-1])

Measured memory_bytes: 39404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
typedef pair<int, i_i> iii;
int N, M;
vector<iii> paths[10050];
int dist[10050];
bool visited[10050];
void solve() {
    for(int i = 1; i <= N; i++) {
        paths[i].clear();
        dist[i] = 1e9;
        visited[i] = false;
    }
    while(M--) {
        int u, v, d, c;
        cin >> u >> v >> d >> c;
        paths[u].push_back({v, {d, c}});
        paths[v].push_back({u, {d, c}});
    }
    dist[1] = 0;
    priority_queue<i_i, vector<i_i>, greater<i_i>> que;
    que.push({0, 1});
    int ans = 0;
    while(!que.empty()) {
        i_i tmp = que.top();
        que.pop();
        int now = tmp.second;
        int nowcost = tmp.first;
        if(visited[now]) continue;
        visited[now] = true;
        if(now != 1) {
            int val = 1e9;
            for(auto a : paths[now]) {
                int to = a.first;
                if(dist[to] + a.second.first != dist[now]) continue;
                chmin(val, a.second.second);
            }
            ans += val;
        }
        for(auto a : paths[now]) {
            int to = a.first;
            int d = nowcost + a.second.first;
            if(chmin(dist[to], d)) {
                que.push({dist[to], to});
            }
        }
    }
    cout << ans << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> N >> M;
        if(N == 0) break;
        solve();
    }
    return 0;
}


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

int main() {
	string s,s2;
	cin>>s;
	s2=s;
	int ans1=0;
	int ans2=0;
	for(int i=0;i<s.size();i++){
		int j=(s[i]+i)%2;
		if(j==0){
			ans1++;
		}else{
			ans2++;
		}
	}
	if(ans1>ans2){
		cout<<ans2<<endl;
	}else{
		cout<<ans1<<endl;
	}
	return 0;
}


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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<char> ans;
  for (int i = 0; i < n - 1; i++)
  {

    if (s[i] == s[i + 1])
    {
      continue;
    }
    else
    {
      ans.push_back(s[i]);
    }
  }
  ans.push_back(s[n - 1]);

  cout << ans.size() << endl;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll L, R, D;
  cin>>L>>R>>D;
  ll Ans=0;
  for(ll i=L; i<=R; i++){
    if(i%D==0)Ans++;
  }
  cout<<Ans<<endl;
} 

Measured memory_bytes: 3592
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  c=1
  sm=1
  while True:
    if sm>=n:
      return c
    c+=1
    sm+=c

print(main())


Measured memory_bytes: 5420
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                string[] change = input.Split(' ');
                int h = int.Parse(change[0]);
                int w = int.Parse(change[1]);

                if (h == 0 && w == 0)
                    break;

                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 数値読み込み
n = int(input())
s = input()
t = input()

res=len(s)
while(len(s)>0):
  if s==t:
    break
  else:
    res=res+1
    s=s[1:]
    t=t[:-1]
print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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>>prime_factorize(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; 
}
const int MOD=1000000007;

int main() {
  int64_t N,K;
  cin>>N>>K;
  int64_t ans=0;
  for(int64_t i=K;i<=N+1;i++){
    int64_t MIN=(i-1)*(i)/2;
    int64_t MAX=(N+N-i+1)*(i)/2;
    ans+=(MAX-MIN+1);
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608