akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
ll power(ll a,ll b,ll m)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a)%m;
       }
       a=(a*a)%m;
       b=b/2;
   }
   return ans;
}
ll inverse(ll a,ll m)
{
       return (power(a,m-2,m));
}
const int N = 2000005;
ll fct[N];
ll invf[N];
ll C(ll n,ll r)
{
       if(r>n){return 0;}
       ll xx = (invf[r]*invf[n-r])%mod;
       xx *= fct[n];
       xx %= mod;
       return xx;
}
void initialize()
{
       fct[0] = 1;
       invf[0] = 1;
       fri(i,1,N){
              fct[i] = (i*fct[i-1])%mod;
              invf[i] = inverse(fct[i],mod);
       }
}
int main()
{
       ll x,y;
       cin>>x>>y;
       ll ans = 0;
       initialize();
       fri(i,0,x+1){
              if((x-i)%2){continue;}
              ll j = (x-i)/2;
              if(i*2 + j == y){
                     ans += C(i+j,j);
                     ans %= mod;
              }
       }
       cout<<ans<<endl;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
const int inf = 1e9;

int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,k,T,cas=0;
	cin>>n>>k;
	vector<int> A(n);
	for(int &x: A) {
		cin>>x;
	}
	vector<int> dp(n, inf);
	dp[0]=0;
	for(int i=0;i<n;++i) {
		for(int j=i+1;j<=i+k && j<n;++j) {
			dp[j] = min(dp[j], dp[i] + abs(A[j]-A[i]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 50;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, C, K;
    cin >> R >> C >> K;
    int r, c;
    ll v;
    vector<vector<ll>> grid(R, vector<ll>(C, 0));
    rep(i, 0, K) {
        cin >> r >> c >> v;
        --r, --c;
        grid[r][c] = v;
    }
    vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4, -INF)));
    if (grid[0][0]) {
        dp[0][0][1] = grid[0][0];
    }
    dp[0][0][0] = 0;
    rep(i, 0, R) rep(j, 0, C) rep(k, 0, 4) {
        if (dp[i][j][k] == -INF) {
            continue;
        }
        if (i + 1 < R) {
            chmax(dp[i + 1][j][0], dp[i][j][k]);
            chmax(dp[i + 1][j][grid[i + 1][j] > 0], dp[i][j][k] + grid[i + 1][j]);
        }
        if (j + 1 < C) {
            chmax(dp[i][j + 1][k], dp[i][j][k]);
            if (k + 1 <= 3) {
                chmax(dp[i][j + 1][k + (grid[i][j + 1] > 0)], dp[i][j][k] + grid[i][j + 1]);
            }
        }
    }
    ll ans = -INF;
    rep(i, 0, 4) {
        chmax(ans, dp[R - 1][C - 1][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 706600
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (isalpha(c)) {
            if (islower(c)) {
                s[i] = toupper(c);
            }
            else {
                s[i] = tolower(c);
            }
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	long int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%ld %ld %.6lf\n", d, r, f);
	return 0;
}


Measured memory_bytes: 3232
s = input()
ans = ""
for i in range(len(s)):
    if s[i] == "B" and len(ans) > 0:
        ans = ans[0:len(ans)-1]
    elif s[i] == "1":
        ans = ans + "1"
    elif s[i] == "0":
        ans = ans + "0"
print(ans)

Measured memory_bytes: 38384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, k, ans = INF;
	cin >> n >> k;;
	VI h(n);
	REP(i, n)cin >> h[i];
	sort(ALL(h));
	REP(i, n - k + 1) {
		int x = h[i + k - 1] - h[i];
		ans = x < ans ? x : ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto ob : v) os << ob << " ";
    return os;
}

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class ADontBeLate {
public:
    void solve(std::istream &in, std::ostream &out) {
        int d, t, s;
        in >> d >> t >> s;
        double ti = (double) d / s;
        if (ti - t <= 0) out << "Yes" << endl;
        else out << "No" << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ADontBeLate solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
  int A,B;
  cin >> A >> B;
  
  int answer = -1;
  for(int i=0;i<=1500;i++){
    int x1 = floor(i*0.08);
    int x2 = floor(i*0.10);
    //cout << i << ":" << x1 << "/" << x2 << endl;
    if(A==x1 && B==x2){
      answer = i;
      break;
    }
  }
 
  cout << answer << endl;
}


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

int main()
{
  int X,A,B ;
  cin>>X>>A>>B ;
  int i ;
  for(i=0;;i++) if(X-A-B*i<0) break ;
  
  cout<<X-A-B*(i-1)<<endl ;
  return 0 ;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll S[100050][3];
ll sum(int from, int to, int index){
    ll val = S[to][index];
    if(from > 0){
        val -= S[from - 1][index];
    }
    return val;
}

int main() {
    //cout.precision(10);
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < 3; i++){
        S[0][i] = a[0];
    }
    S[0][1] = 0;
    for(int i = 1; i < n; i++){
        for(int k = 0; k < 3; k++){
            S[i][k] = S[i - 1][k] + a[i];
            if(k == 2) continue;
            if((i % 2) != (k % 2)){
                S[i][k] = S[i - 1][k];
            }
        }
        for(int k = 0; k < 3; k++){
            //cout << S[i][k] << " " ;
        }
        //cout << endl;
    }
    while(q--){
        ll x;
        cin >> x;
        ll ok = n - 1;
        ll ng = 0;
        while(ok - ng > 1){
            ll mid = (ok + ng) / 2;
            ll Takahashi = a[mid];
            ll delta = n - mid;
            if(mid - delta + 1 < 0) {
                ng = mid;
                continue;
            }
            ll Aoki = a[mid - delta + 1];
            if(abs(Takahashi - x) < abs(Aoki - x)){
                ng = mid;
                continue;
            }
            if(abs(Takahashi - x) >= abs(Aoki - x)){
                ok = mid;
            }
        }
        //cout << ok << endl;
        ll get = n - ok;
        ll checked = n - get - get;
        //cout << checked << endl;
        ll ans = sum(ok, n - 1, 2);
        if(checked >= 1){
            ans += sum(0, checked - 1, 1 - (n % 2));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4864
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,n,k;
    cin>>n>>k;
    ll a[n],ans=0,mini=INT_MAX;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0; i<=n-k; i++)
    {
        mini=min(mini,abs(a[i]-a[i+k-1]));
    }


    cout<<mini<<endl;

    return 0;
}





Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n,k;
    cin >> n >>k;
    int ans =0;
    while(1){
        ans++;
        n /= k;
        if(n==1){
            ans++;
            break;
        }
        if(n==0){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * 
 *      Created By : Fedora_Day
 *      Date : Sun May 05 2019
 * 
 * */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626

 using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;




//----------------------------------------------------------------------------------------------------------------------

void swap(int &a,int &b){
    int temp = a;
    a = b;
    b = temp;
}

ll calcAv(vector< pair<ll,int > > &arra){
    ll sum = 0;
    for(auto it : arra){
        sum+= it.first;
    }
    return sum;
}


int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin >> n >> k;
    vi arr(n); scanVec(arr,n);
    vector<int> ans (n,INF);
    ans[0] = 0;
    for(int i = 0;i < n;i++){

        for(int j = 1;j <= k && j+i < n;j++){
            ans[i+j] = min(ans[i + j],ans[i] + abs(arr[i]-arr[i+j]));
        }
    }
    cout << ans[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1152
A, B = map(int, input().split())
bin_A = bin(A - 1)
bin_B = bin(B)
A_xor = [0 for _ in range(len(bin_B) - 2)]
B_xor = [0 for _ in range(len(bin_B) - 2)]
for i in range(len(bin_B)):
    if i == 0:
        if B % 4 == 1 or B % 4 == 2:
            B_xor[i] = 1
    else:  
        if (B // pow(2, i)) % 2 == 1 and (B % pow(2, i)) % 2 == 0:
            B_xor[i] = 1
if A == 0:
    print(int("".join(map(str, B_xor[::-1])), 2))
    exit()
for i in range(len(bin_A)):
    if i == 0:
        if (A - 1) % 4 == 1 or (A - 1) % 4 == 2:
            A_xor[i] = 1
    else:
        if ((A - 1) // pow(2, i)) % 2 == 1 and ((A - 1) % pow(2, i)) % 2 == 0:
            A_xor[i] = 1
ans = []
for a, b in zip(A_xor, B_xor):
    if a != b:
        ans.append(1)
    else:
        ans.append(0)
print(int("".join(map(str, ans[::-1])), 2))

Measured memory_bytes: 3064
#include <stdio.h>

#define N 262144
#define HALFN 131072 // 2^17
#define INFTY 1000000001 // 10^9 + 1

int L[HALFN] = {0}, R[HALFN] = {0};
long cnt = 0;

/* void swap(int *x, int *y) { */
/*   int tmp; */

/*   tmp = *x; */
/*   *x = *y; */
/*   *y = tmp; */
/* } */

/* int bubbleSort(int n, int *A) { */
/*   int i, j; */

/*   for (i = 0; i < n; i++) { */
/*     for (j = n - 1; i < j; j--) { */
/*       if (A[j] < A[j-1]) { */
/* 	swap(&A[j], &A[j-1]); */
/* 	cnt++; */
/*       } */
/*     } */
/*   } */
/*   return cnt; */
/* } */
	
void merge(int *A, int left, int mid, int right) {
  int i, j, k, n1, n2;
  
  n1 = mid - left;
  n2 = right - mid;

  for (i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;

  /* // count the number of inversions */
  /* for (j = 0; j < n2; j++) { */
  /*   for (i = 0; i < n1; i++) { */
  /*     if (R[j] < L[i]) { */
  /* 	cnt += (n1 - i); */
  /* 	break; */
  /*     } */
  /*   } */
  /* } */
  
  // sort array
  for (i = 0, j = 0, k = left; k < right; k++) {
    if (R[j] < L[i]) {
      cnt += (n1 - i);
      A[k] = R[j];
      j++;
    }
    else {
      A[k] = L[i];
      i++;
    }
  }
}

void mergeSort(int *A, int left, int right) {
  int mid;
  
  if ((left + 1) < right) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){
  int i, n, A[N] = {0};

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);

  mergeSort(A, 0, n);
  printf("%ld\n", cnt);
  return 0;
}

Measured memory_bytes: 2416
using System;


class AOJ
{

    public static void Main()
    {
        int[,] a = new int[10, 10];
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
                a[i, j] = 0;
        }

        int x,y,size;

        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;

            string[] ss = s.Split(',');

            x = int.Parse(ss[0]);
            y = int.Parse(ss[1]);
            size = int.Parse(ss[2]);

            switch (size)
            {

                case 1:
                    if (y - 1 >= 0)
                        a[y - 1, x] += 1;
                    if (x - 1 >= 0)
                        a[y, x - 1] += 1;
                    a[y, x] += 1;
                    if (y + 1 <= 9)
                        a[y + 1, x] += 1;
                    if (x + 1 <= 9)
                        a[y, x + 1] += 1;

                    break;

                case 2:
                    for (int i = x - 1; i <= x + 1; i++)
                    {
                        for (int j = y - 1; j <= y + 1; j++)
                        {
                            if (i >= 0 && j >= 0 && i <= 9 && j <= 9)
                                a[j, i] += 1;
                        }
                    }
                    break;

                case 3:
                    if (y - 2 >= 0)
                        a[y - 2, x] += 1;
                    if (x - 2 >= 0)
                        a[y, x - 2] += 1;

                    for (int i = x - 1; i <= x + 1; i++)
                    {
                        for (int j = y - 1; j <= y + 1; j++)
                        {
                            if (i >= 0 && j >= 0 && i <= 9 && j <= 9)
                                a[j, i] += 1;
                        }
                    }

                    if (y + 2 <= 9)
                        a[y + 2, x] += 1;
                    if (x + 2 <= 9)
                        a[y, x + 2] += 1;
                    break;
            }
        }

        int noink = 0, Md = 0;

        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                if (a[j, i] == 0)
                    noink++;
                if (a[j, i] > Md)
                    Md = a[j, i];
            }
        }

        Console.WriteLine(noink);
        Console.WriteLine(Md);
    }
}

Measured memory_bytes: 5616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int n;
int main() {
	cin >> n;
	cout << ((n + 1) / 2) << endl;
	return 0;
}

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



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	int N;
	cin >> N;
	int tmp= N%10;

	switch (tmp)
	{
	case 2 :
	case 4 :
	case 5 :
	case 7 :
	case 9 :
		cout<< "hon\n";
		break;

	case 0 :
	case 1 :
	case 6 :
	case 8 :
		cout<< "pon\n";
		break;	
	default:
		cout << "bon\n";
		break;
	}
	


	
	return 0;
}

Measured memory_bytes: 3132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		String[] elements = br.readLine().split(" ");
		
		for (int i = 0; i < n; i++){
			a[i] = Integer.parseInt(elements[i]);
		}
		
		int swap = 0;
		
		for (int i = 0; i < a.length - 1; i++){
			for(int j = a.length - 1; j >= i + 1; j--){
				if(a[j] < a[j-1]){
					int v = a[j-1];
					a[j-1] = a[j];
					a[j] = v;
					swap++;
				}
			}
		}
		
		System.out.print(a[0]);	
		if(n > 1){
			for (int i = 1; i < a.length; i++) {
				System.out.print(" " + a[i]);
			}
		}
		System.out.println();
		System.out.println(swap);
	}
}

Measured memory_bytes: 17068
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限x
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


X, Y = map(int, input().strip().split())
if (X + Y) % 3 != 0:
    print(0)
    exit(0)

a = (2*X-Y)//3
b = (2*Y-X)//3

if a < 0 or b < 0:
    print(0)
    exit(0)

print(cmb(a+b,a, mod))


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    //int ans 
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long


main(){

	int n; cin >> n;

	vector < vector <int> > g(n);

	vector <int> a(n), b(n), deg(n);

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

	int k = 1;

	for(int i = 0; i < n; i++){
		k = max(k, deg[i]);
	}

	map < pair <int, int>, int> m;

	map <int, set <int> > s;

	for(int i = 0; i < n; i++){
		int color = 1;
		for(int to : g[i]){
			if(m.find(make_pair(to, i)) == m.end()){
				while(s[i].find(color) != s[i].end()){
					color++;
				}

				m[make_pair(to, i)] = color;
				m[make_pair(i, to)] = color;
				s[to].insert(color);
				s[i].insert(color);
			}
		}
	}


	cout << k << endl;

	for(int i = 0; i < n - 1; i++){
		cout << m[make_pair(a[i], b[i])] << endl;
	}


	return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();
    ull n,m; cin>>n>>m;
    vector<ull> arr(n);
    FOR(i, 0, n) {
        cin>>arr[i];
    }
    ull lc = arr[0];
    FOR(i, 1, n) {
        lc = (arr[i] / __gcd(arr[i], lc)) * lc;
        if(lc > 2*m) {
            cout<<0;
            return 0;
        }
    }
    ll tmp = lc / 2;
    FOR(i, 0, n) {
        if((tmp % arr[i]) != (arr[i] / 2)) {
            cout<<0<<endl;
            return 0;
        }
    }

    ll res = m / lc;
    if((m % lc) >= lc / 2) res++;
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 1024
n,*a=map(int,open(0).read().split())
b=sum(a)
c=1
ans=1
if a[0]==1 and n==0:
    print(1)
    exit()
if a[0]>0:
    print(-1)
    exit()
for i in a[1:]:
    b-=i
    c=min(c*2-i,b)
    ans+=c
    if c<0:
        print(-1)
        exit()
print(ans+sum(a))

Measured memory_bytes: 19992
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)


int a, b, c, x, y;

long long solve()
{
  long long ans = LLONG_MAX;
  for (long long i = 0; i <= 1000000; ++i)
    ans = min(ans, max(x - i, 0LL) * a + max(y - i, 0LL) * b + 2 * i * c);
  return ans;
}

int main()
{
  cin >> a >> b >> c >> x >> y;
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int cnt, rating; cin >> cnt >> rating;
    
    if(cnt >= 10) cout << rating << endl;
    else cout << rating + 100*(10-cnt) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    s = input().strip()
    stack = []
    for c in s:
        if c == 'S':
            stack.append('S')
        else:
            if len(stack) > 0 and stack[-1] == 'S':
                stack.pop()
            else:
                stack.append('T')
    print(len(stack))

if __name__ == '__main__':
    main()


Measured memory_bytes: 48736
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

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

int main(){
  ll a,b;
  cin>>a>>b;
  cout << a*b/gcd(a,b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

// X = max({x[0],...,x[n-1],a})
// y[i] = x[i] - a
//ll dp[i][j]: y[0],..,y[i-1] から0枚以上選んで合計をj-n*Xにするような選び方の総数

ll dp[55][100050];
ll x[55];

int main () {
  int n, a;
  cin >> n >> a;
  rep(i,n) cin >> x[i];
  int X = *max_element(x,x+n);

  vi y(n);
  rep(i,n) y[i] = x[i] - a;

  rep(i,55)rep(j,6050) dp[i][j] = 0;
  dp[0][n*X] = 1;
  rep(i,50) {
    rep(j,5050) {
      if (dp[i][j] == 0) continue;
      dp[i+1][j] += dp[i][j];
      dp[i+1][j+y[i]] += dp[i][j];
    }
  }

  ll ans = dp[n][n*X] - 1;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w;
    cin >>h>>w;
    vector<string> a(h);
    vector<bool> gyo(h, false);
    vector<bool> retsu(w, false);
    
    for(int i=0;i<h;i++) cin >> a[i];
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#') gyo[i]= true, retsu[j] = true;
        }
    }
    
    for(int i=0;i<h;i++){
        if(gyo[i]){
            for(int j=0;j<w;j++){
                if(retsu[j]) cout << a[i][j];
            }
            cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    total = c
    a = list(map(int, input().split()))
    for i in range(m):
        total += a[i] * b[i]
    if total > 0:
        ans += 1
print(ans)

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

using namespace std;

const int maxn = 100010,inf = 0x7ffffff;
int n,du[maxn],tong[1 << 16],ans,limit,f[1 << 16];

int prework(int sta)
{
    if (sta == 0)
        return 0;
    int res = 0,cnt = 0;
    for (int i = 0; i <= 15; i++)
        if (sta >> i & 1)
        {
            res ^= i;
            cnt++;
        }
    if (res == 0)
        return cnt - 1;
    else
        return inf;
}

int main()
{
    scanf("%d",&n);
    for (int i = 1; i < n; i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        x++;
        y++;
        du[x] ^= z;
        du[y] ^= z;
    }
    for (int i = 1; i <= n; i++)
        tong[du[i]]++;
    for (int i = 1; i <= 15; i++)
    {
        ans += tong[i] / 2;
        tong[i] %= 2;
        limit |= (tong[i] << i);
    }
    for (int i = 0; i <= limit; i++)
        f[i] = prework(i);
    for (int i = 0; i <= limit; i++)
        for (int j = i;j;j = (j - 1) & i)
            f[i] = min(f[i],f[j] + f[i ^ j]);
    printf("%d\n",f[limit] + ans);

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
	double r;
	cout << fixed << setprecision(5);
	cin >> r;
	double a = r * r * M_PI, c = 2 * r * M_PI;
	cout << a << " " << c;
	return 0;
}


Measured memory_bytes: 3264
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
long double pi=3.141592653589793238;
ll r;
cin>>r;
long double ans=2.0*pi*r;
cout<<fixed<<setprecision(10)<<ans<<endl;


return 0;
}


Measured memory_bytes: 3820
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

import sys
D,total1,total2,cnt1,cnt2 = [],0,0,0,0
for i in range(N):
    if A[i] == B[i]:
        continue
    elif A[i] > B[i]:
        D.append(A[i]-B[i])
    else:
        total1 += B[i]-A[i]
        cnt1 += 1

D.sort(reverse=True)

if total1==0:
    print(0)
    sys.exit()
else:
    for d in D:
        total2 += d
        cnt2 += 1
        if total2 >= total1:
            print(cnt1+cnt2)
            sys.exit()

print(-1)

Measured memory_bytes: 19068
n = gets.to_i
vv = gets.split.map(&:to_i)
cc = gets.split.map(&:to_i)
kari = []
n.times do |i|
  kari.push(vv[i] - cc[i])
end
ans = 0
kari.each do |a|
  ans += a if ans < ans + a
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    string s;
    cin >> s;
    int n = s.size();
    string fsub = s.substr(0, (n - 1) / 2);
    string bsub = s.substr(n - (n - 1) / 2, (n - 1) / 2);
    string rs = s;
    reverse(all(rs));
    string rfsub = fsub;
    reverse(all(rfsub));
    string rbsub = bsub;
    reverse(all(rbsub));
    if(rs == s && rfsub == fsub && bsub == rbsub){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> v(n);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		v[i] = make_pair(a, b);
	}
	sort(v.begin(), v.end());
	ll num = 0;
	ll cost = 0;
	for (auto p : v)
	{
		if (num + p.second < m)
		{
			num += p.second;
			cost += p.first * p.second;
		}
		else
		{
			cost += p.first * (m - num);
			cout << cost << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
itta2 = set([])
mati = 1
i = 0
itta = []
while True:
    if mati in itta2:
        saisyo = mati
        break
    else:
        itta2.add(mati)
        itta.append(mati)
        mati = c[mati-1]
        i += 1
risuto2 = set([])
risuto = []

while True:
    if mati in risuto2:
        break
    else:
        risuto2.add(mati)
        risuto.append(mati)
        mati = c[mati-1]
if b <= i-1:
    print(itta[b])
else:
    print(risuto[(b-i) % len(risuto)])

Measured memory_bytes: 43428
#include<bits/stdc++.h>
#define Maxn 100010
#define NIL -1 
using namespace std;
typedef struct{
	int parent, left, right;
}Node;
Node T[Maxn];
int D[Maxn];
void init(int n){
	for(int i = 0; i < n; i++) T[i].left = T[i].parent = T[i].right = NIL;
}
void rec(int u, int p){
	D[u] = p;
	if(T[u].right != NIL) rec(T[u].right, p);
	if(T[u].left != NIL) rec(T[u].left, p + 1);
}
void print(int u){
	printf("node %d: parent = %d, depth = %d, ", u, T[u].parent, D[u]);
	if(T[u].parent == NIL) printf("root, [");
	else if(T[u].left == NIL) printf("leaf, [");
	else printf("internal node, [");
	if(T[u].left != NIL){
		int c = T[u].left;	
		printf("%d", c);
		while(T[c].right != NIL){
			printf(", %d", T[c].right);
			c = T[c].right;
		}
	}
	printf("]\n");
}
int main()
{
	int n, id, k, c, l, r;
	scanf("%d", &n);
	init(n);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &id, &k);
		for(int j = 0; j < k; j++){
			scanf("%d", &c);
			if(!j) T[id].left = c;
			else T[l].right = c;
			l = c;
			T[c].parent = id; 
		}
	}
	
	int t = 0;
	while(T[t].parent != NIL) t++;
	
	rec(t, 0);
	for(int i = 0;  i < n; i++) print(i);
	return 0;
} 


Measured memory_bytes: 7888
n, k = map(int, input().split())
s = input()
r = [0, 1]
prev = s[0]

for i in range(1, len(s)):
    if prev == s[i]:
        r[-1] += 1
    else:
        r.append(r[-1] + 1)
    prev = s[i]

lr = len(r)
import math
# 0の数よりkが大きい
if s[0] == '0' and math.ceil((lr-1) / 2) <= k:
    print(len(s))
    exit()
if s[0] == '1' and math.floor((lr-1) / 2) <= k:
    print(len(s))
    exit()

start = 0
if s[0] == '0':
    start = 1

ans = 0
for i in range(start, lr - (2 * k + 1), 2):
    ans = max(ans, r[i + (2 * k + 1)] - r[i])
    #print(i, i+(2*k)+1, r[i+(2 * k)+1] - r[i])

#print(ans)
# 0始まり
if s[0] == '0':
    ans = max(ans, r[2 * k] - r[0])
    #print(ans)
# 0終わり
if s[-1] == '0':
    ans = max(ans, r[-1] - r[lr - 2 * k - 1])
    #print(ans)
#print(r)
print(ans)



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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int64_t ans=0;
  for(int i=0;i<=999;i++){
    string T=to_string(i);
    char x,y,z;
    if(T.size()==1){
      x='0';
      y='0';
      z=T.at(0);
    }else if(T.size()==2){
      x='0';
      y=T.at(0);
      z=T.at(1);
    }else{
      x=T.at(0);
      y=T.at(1);
      z=T.at(2);
    }
    bool flagx=false;
    bool flagy=false;
    for(int j=0;j<N;j++){
      if(!flagx){
        if(S.at(j)==x){
          flagx=true;
        }
      }else{
        if(!flagy){
          if(S.at(j)==y){
            flagy=true;
          }
        }else{
          if(S.at(j)==z){
            ans++;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC141B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int L = S.Length;
            bool ans = true;
            for(int i = 0; i < L; i++)
            {
                if (i % 2 == 0)
                {
                    if (S[i].ToString() == "L")
                    {
                        ans = false;
                    }
                }
                else
                {
                    if (S[i].ToString() == "R")
                    {
                        ans = false;
                    }
                }
            }
            if (ans) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25720
use List::Util qw(max min sum);

my ($n,$m) = (split(/\s+/, <>));
my (@a) = (split(/\s+/, <>));

my $th = sum(@a)/4/$m;

my $c = 0;
for (@a) {
    $c++ if $_>=$th;
}
if ($c>=$m) {
    print "Yes\n";
} else {
    print "No\n";
}


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

using namespace std;

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

    int n,m,ac=0,wa=0,contest_no;
    string verdict;
    cin>>n>>m;
    bool contests[n+1]={0};
    int wanum[n+1]={};
    for(int i=0;i<m;i++)
    {
        cin>>contest_no>>verdict;
        if(!contests[contest_no])
        {
            if(verdict=="AC")
            {
                ac++;
                contests[contest_no]=1;
                wa+=wanum[contest_no];
            }
            else wanum[contest_no]++;
        }
    }
    cout<<ac<<" "<<wa<<endl;

}


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

int main() {
  int N,dan=1;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)
    cin >> d.at(i);
  
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  if(N>1){
    for(int i=0;i<N-1;i++){
      if(d.at(i) == d.at(i+1))
        continue;
      dan++;
    }
  }
  cout << dan << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
f = defaultdict(lambda : 0)
for i in range(n):
    s = input()
    f[s] += 1

print("AC x " + str(f["AC"]))
print("WA x " + str(f["WA"]))
print("TLE x " + str(f["TLE"]))
print("RE x " + str(f["RE"]))


Measured memory_bytes: 74748
A,B,C,D,E,F = gets.split.map(&:to_i)
G = Hash.new(false)

SugerWater = Struct.new(:a,:b,:c,:d) do
  def weight
    water + suger
  end
  def water
    (a*A + b*B)*100
  end
  def suger
    c*C + d*D
  end
  def key
    water*100+suger
  end
  def concentration
    suger*100.0 / weight
  end
  def is_dissolved
    water * E >= suger * 100
  end
  def is_valid
    if G[key]
      false
    else
      G[key] = true
      is_dissolved && weight <= F
    end
  end
  def values
    [A,B,C,D,E,F,a,b,c,d,weight,suger,water,concentration,is_dissolved]
  end
  def candidates
    [
      SugerWater.new(a+1,b,c,d),
      SugerWater.new(a,b+1,c,d),
      SugerWater.new(a,b,c+1,d),
      SugerWater.new(a,b,c,d+1),
    ].select(&:is_valid)
  end
end

root = SugerWater.new(0,0,0,0)
Q = [root]
weight = 0
suger = 0
concentration = -1

until Q.empty?
  node = Q.shift
  if concentration < node.concentration
    concentration = node.concentration
    weight = node.weight
    suger = node.suger 
  end
  node.candidates.each{ |c| Q.push(c) }
end

puts [weight,suger].join(" ")

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    cout << a*b-a-b+1 << "\n";

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int n,k;
string calc(string s){
  reverse(s.begin(),s.end());
  Int cnt=0;
  while(cnt<n&&s[0]==s[cnt]) cnt++;
  Int len=cnt<<k;
  if(len>=n) return string(n,s[0]);
  string res;
  for(Int i=cnt;i<n;i++)
    if(len+(Int)res.size()<n) res+=s[i];
  //reverse(res.begin(),res.end());
  //reverse(s.begin(),s.end());
  //cout<<s<<" "<<res<<":"<<cnt<<" "<<len<<endl;
  return string(len,s[0])+res;
}
signed main(){
  string s;
  cin>>n>>k>>s;
  chmin(k,20);
  k--;
  string ans=s;

  string t(s);
  reverse(t.begin(),t.end());
  {
    string b=s+t;
    for(Int i=0;i<=n;i++){
      string c=b.substr(i,n);
      chmin(ans,calc(c));
    }
  }
  if(k){
    k--;
    string b=t+s;
    for(Int i=0;i<=n;i++){
      string c=b.substr(i,n);
      chmin(ans,calc(c));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384