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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define R(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

    int64 n, l;
    while (cin >> n >> l && n + l) {
        vector<int64> d(n), p(n);
        REP(i, n) {
            char c;
            cin >> c >> p[i];
            d[i] = c == 'R' ? 1 : -1;
        }
        int turn = 0, res = -1;
        while (1) {
            int c = 0;
            vector<int> cnt(l+1, 0);
            REP(i, n) {
                if (p[i] == 0 || p[i] >= l) continue;
                p[i] += d[i];
                if (p[i] == 0) res = i;
                if (p[i] == l && res == -1) res = i;
                cnt[p[i]]++;
            }
            FOR(i, 1, l) {
                if (cnt[i] == 2) {
                    REP(j, n) {
                        if (p[j] == i) {
                            d[j] *= -1;
                        }
                    }
                }
                if (cnt[i])
                    c++;
            }
            turn++;
            if (c == 0) break;
            res = -1;
        }
        cout << turn << " " << res+1 << endl;
    }
}



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

using namespace std;

const int N = 1000 + 10;

int main()
{
    int n;
    int val[N];
    scanf("%d", &n);
    for(int i = 0; i < 2*n; ++i)
        scanf("%d", &val[i]);

    sort(val, val + 2*n);

    int ans = 0;
    for(int i = 2*n-2; i >=0; i -= 2)
        ans += val[i];

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  string S;
  cin >> S;
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

from fractions import gcd
# from math import gcd
def lcm(x, y):
  return x // gcd(x, y) * y

def solve():
    N, M = MI()
    A = LI()

    A = list(map(lambda x: x // 2, A))

    EX = 0
    b = A[0]
    while b % 2 == 0:
        b //= 2
        EX += 1

    l = 1
    for a in A:
        ex = 0
        while a % 2 == 0:
            a //= 2
            ex += 1
        if ex != EX:
            print(0)
            return
        l = lcm(l, a)

    M //= pow(2, EX)
    # print(l)

    print(ceil((M // l) / 2))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16272
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  if(b-a == c-b)System.out.println("YES");
  else System.out.println("NO");
}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
int main(void){
   double x1,y1,x2,y2,d,d1,d2;
   scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
   
   d1=pow(x2-x1,2.0);
   d2=pow(y2-y1,2.0);
   d=sqrt(d1+d2);
   printf("%f\n",d);
   
   return 0;
   
}


Measured memory_bytes: 2104
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=500001;
P a[maxn],b[maxn];
vector<ll> divisor(ll x){
  vector<ll> res;
  for(ll i=1LL;i*i<=x;i++){
    if(x%i==0){
      res.push_back(i);
      if(i!=x/i)res.push_back(x/i);
    }
  }
  return res;
}
int aa[51];
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int res1=a*x+b*y;
  int res2=min(x,y)*c*2+a*(x-min(x,y))+b*(y-min(x,y));
  int res3=max(x,y)*2*c;
  cout<<min(res3,min(res1,res2))<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;

}
P dequeue()
{
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a,int b){return a<b?a:b;}

int main()
{
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);

    for(int i=1;i<=n;i++)
    {
        scanf("%s",&Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;tail=n+1;
    while(head!=tail)
    {
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0)enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}



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

#define ll long long int
#define ld long double

void solve() {
	int count = 0, i = 0;
	string s, t;
	cin >> s;
	cin >> t;
	while (s[i] != '\0') {
		count = (s[i] == t[i]) ? count : count + 1;
		++i;
	}
	cout << count << endl;
}

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

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

using namespace std;
typedef long long ll;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char> > c(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int bith = 0; bith < (1<<h); ++bith) {
        vector<int> S;
        for (int i = 0; i < h; ++i) {
            if (bith & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        for (int bitw = 0; bitw < (1<<w); ++bitw) {
            vector<int> T;
            for (int j = 0; j < w; ++j) {
                if (bitw & (1<<j)) { // 列挙に i が含まれるか
                    T.push_back(j);
                }
            }

            auto tmpc = c;
            for (int i = 0; i < (int)S.size(); ++i) {
                for (int j = 0; j < w; j++) {
                    tmpc[S[i]][j] = 'r';
                }
            }
            for (int j = 0; j < (int)T.size(); ++j) {
                for (int i = 0; i < h; i++) {
                    tmpc[i][T[j]] = 'r';
                }
            }

            int cnt = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (tmpc[i][j] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
# coding: utf-8
import math
a, b = map(float, input().split())
i = math.ceil(a/0.08)
while i*0.08 < a+1:
    #print(i)
    if math.floor(i*0.1) == b:
        print(i)
        break
    else:
        i += 1
else:
    print('-1')

Measured memory_bytes: 2940
//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll len(pll X){
	return X.second - X.first;
}

pll I (pll X, pll Y){
	pll Z;
	Z.first = max(X.first, Y.first);
	Z.second = min(X.second, Y.second);
	if (Z.first >= Z.second)
		Z = {-1, -1};
	return Z;
}

pll U (pll X, pll Y){
	pll Z;
	Z.first = min(X.first, Y.first);
	Z.second = max(X.second, Y.second);
	return Z;
}

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b; scanf("%lld%lld", &a, &b);
	if (a == b)
		return printf("1\n"), 0;
	int ix = 63 - __builtin_clzll(a ^ b);
	ll p = (1ll << ix);
	ll c = a & (p - 1);
	ll d = b & (p - 1);
	int tmp = (d ? 64 - __builtin_clzll(d) : 0);
	pll A = {p, p + (1ll << tmp)};
	pll B = {p + c, p << 1};
	ll ans = len({c, p}) + (I(A, B).first == -1 ? len(A) + len(B) : len(U(A, B)));
	printf("%lld\n", ans);
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 


Measured memory_bytes: 3856
#include<bits/stdc++.h>
#include<tr1/unordered_map>
using namespace std;
#define ll long long
#define fr first
#define se second
#define fi(i,s,e,inc) for(auto i=s; i<e; i+=inc)
#define fie(i,s,e,inc) for(auto i=s; i<=e; i+=inc)
#define fd(i,s,e,dec) for(auto i=s; i>e; i-=dec)
#define fde(i,s,e,dec) for(auto i=s; i>=e; i-=dec)
#define umap tr1::unordered_map
#define nl cout<<"\n";
#define vt vector
#define pb push_back
#define pr(x) cout<<x;
#define ps(x) cout<<x<<" ";
#define sp cout<<" ";
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define rev reverse
#define tc ll t; cin>>t; while(t--)
#define pq priority_queue
ll n,k,a[100005],dp[100005];
ll solve(ll idx){
    if(idx==n-1) return 0;

    if(dp[idx]!=-1) return dp[idx];

    ll mn = INT_MAX;

    fie(i,idx+1,min(n,idx+k),1){
        mn = min(mn,abs(a[idx]-a[i]) + solve(i));  
    }

    return dp[idx]=mn;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    fi(i,0,n,1) cin>>a[i];
    memset(dp,-1,sizeof(dp));
    pr(solve(0)) nl
    return 0;
}


Measured memory_bytes: 6528
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = [II() for _ in range(n)]

    B = A[:]
    A.sort()

    return (n + 1) // 2 - len(set(A[::2]) & set(B[::2]))


print(main())


Measured memory_bytes: 14612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int k,n,a[200005];
	vector<int>v;
	cin>>k>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	a[n+1]=k+a[1];
	for(int i=1;i<n+1;i++)
	{
		v.push_back(k-(a[i+1]-a[i]));
	}
	sort(v.begin(),v.end());
	cout<<v[0]<<endl;
	return 0;
}

Measured memory_bytes: 2168
# ABC126C

n, k = map(int, input().split())
P = 0
for i in range(1, n + 1):
    if i >= k:
        P += (n - i + 1) / n
        break
    pow = 1
    while i * 2**pow < k:
        pow += 1
    P += 0.5**pow / n
print(P)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <climits>
#define endl "\n"
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    int i, j;
    vector < pair <int, int> > A(n);
    vector < pair <int, int> > B(m);
    for(i = 0; i < n; i ++)
    {
    	cin >> A[i].first >> A[i].second;
    }

    for(i = 0; i < m; i ++)
    {
    	cin >> B[i].first >> B[i].second;
    }

    for(i = 0; i < n; i ++)
    {
    	int minDist = INT_MAX;
    	int minIndex = 0;
    	for(j = 0; j < m; j ++)
    	{
    		int dist = abs(B[j].first - A[i].first) + abs(B[j].second - A[i].second);
    		if(dist < minDist)
    		{
    			minDist = dist; 
    			minIndex = j;
    		}
    	}
    	cout << minIndex + 1 << endl;
    }    
}

Measured memory_bytes: 256
#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>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


uint64_t V[4];
uint64_t N; 

vector<pair<uint64_t,uint64_t>> Vs;



int main(){

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

        cin>>V[i];
    }
    cin>>N;
    uint64_t ans=0;
    V[1]=min(V[1],2*V[0]);
    V[2]=min(V[2],2*V[1]);
    if(2*V[2]<=V[3]){
        ans=N*V[2];
    }
    else{
        cerr<<"V[2] "<<N%2<<" "<<V[2]<<endl;
        ans=(N/2)*V[3]+(N%2)*V[2];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define Fi first
#define Se second
using namespace std;
static const LL INF = 1LL<<61LL;
typedef pair<int,int> PII;

string s;
int sum;
int res;
int ans;
int k;
bool my=false;

int main(){
    cin>>s;
    res=s[s.size()-1]-'0';
    rep(j,s.size()){
        if(s[j]=='?'){
            k=11-j;
        }
    }
    rep(i,s.size()){
        int t;
        if(11-i>=1&&11-i<=6)t=11-i+1;
        if(11-i>=7&&11-i<=11)t=11-i-5;
        if(s[i]!='?'&&i!=s.size()-1){
            sum+=(s[i]-'0')*t;
        }
    }
    if(k==0){
        int temp=0;
        ans=11-(sum%11);
        if(ans%11<=1)ans=0;
        cout<<ans<<endl;
        return 0;
    }
    FOR(i,0,9){
        int t;
        int temp;
        if(k>=1&&k<=6)t=k+1;
        if(k>=7&&k<=11)t=k-5;
        temp=11-((sum+(t*i))%11);
        if((sum+(t*i))%11<=1)temp=0;
        if(temp==res&&my==true){
            cout<<"MULTIPLE"<<endl;
            return 0;
        }
        if(temp==res){
            ans=i;
            my=true;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<class T>
istream &operator>>(istream &ist, vector<T> &vec)
{
	for (auto i = vec.begin(); i != vec.end(); ++i)
	{ ist >> vec[i]; }
	return ist;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

vector<ll> count_ans(vector<ll> a)
{
	vector<ll> ans;
	ll n = a.size();
	bool check = true;
	for(int i =0;i  < n && check; ++i){
		check = false;
		for(int j = a.size(); j >= 0; --j){
			if(a[j] == j){
				ans.push_back(j + 1);
				a[j] = -1;
				auto ind = remove_if(all(a),[](ll l){
					return l == -1;
				});
				a.erase(ind,a.end());
				check = true;
				break;
			}
		}
	}
	return ans;
}

int main()
{
	IOS

	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		--a[i];
	}
	vector<ll> ans = count_ans(a);
	reverse(all(ans));
	if(ans.size() == a.size())
	{
		for (auto i : ans)
		{
			cout << i __;
		}
	}
	else{
		cout << -1;
	}


	return 0;
}
/*
 5 3
 100 1
 3 5
 2 5
 2 7
 1 8
 */

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

def main():
    na = list(map(int, input().split()))
    A, B, C = na[0], na[1], na[2]
    K = int(input())

    print(A + B + C + max(A, B, C) * (2 ** K - 1))


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut g = 0;
    for _ in 0..n {
        let x = sc.read();
        let k = sc.read();
        g ^= grundy(x, k);
    }
    println!("{}", if g == 0 { "Aoki" } else { "Takahashi" });
}

fn grundy(x: usize, k: usize) -> usize {
    if x < k {
        0
    } else if x % k == 0 {
        x / k
    } else {
        let t = x / k;
        let prev = t * k;
        let diff = x - prev;
        let width = t + 1;
        grundy(x - ((diff + width - 1) / width * width), k)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        long N = long.Parse (Console.ReadLine ());
        string ans = "";
        while (N > 0) {
            ans = DecToLetter ((N - 1) % 26 + 1) + ans;
            N -= (N - 1) % 26 + 1;
            N /= 26;
        }
        Console.WriteLine (ans);

    }

    static string DecToLetter (long i) {
        return ((char) (96 + i)).ToString ();
    }
}

//dotnet run --project test

Measured memory_bytes: 27528
N = int(input())
if N >= 64 :
    print(64)
elif N >= 32 :
    print(32)
elif N >= 16 :
    print(16)
elif N >= 8 :
    print(8)
elif N >= 4 :
    print(4)
elif N >= 2 :
    print(2)
else :
    print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define ceili(x,y) (x+y-1)/y  
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  DV(G,int,N,0,0);//親の顔より見たグラフ(Graph[頂点][隣接頂点])
  Vec(ct,int,N,0);//こたえを入れる(counter)
  Vec(dist,int,N,0);//探索済みかどうか
  rep(i,0,N-1){
    cin >> X >> Y;//頂点,隣接頂点
    G[X-1].pb(Y-1);//辺を張る
    G[Y-1].pb(X-1);//辺を張る
  }
  rep(i,0,K){
    cin >> X >> Y;
    ct[X-1]+=Y;
  }
  queue<int> que;
  que.push(0);//根は頂点0
  //BFS
  while(!que.empty()){
    auto v=que.front();que.pop();
    dist[v]++;
    for(auto nv:G[v]){
      if(dist[nv])continue;//二重探索は死
      ct[nv]+=ct[v];//†累積和†
      que.push(nv);
    }
  }
  rep(i,0,N)Out(ct[i]);
}
 

Measured memory_bytes: 16372
"use strict";
const main = input => {
    const n = parseInt(input[0].split(' ')[0], 10);
    let m = parseInt(input[0].split(' ')[1], 10);
    let arr = new Array(n);
    let ans = 0;
    for(let i=0; i<n; i++) {
        arr[i] = new Array(2);
        arr[i][0] = parseInt(input[i+1].split(' ')[0], 10);
        arr[i][1] = parseInt(input[i+1].split(' ')[1], 10);
    }
    arr = arr.sort((p,q) => p[0]-q[0]);
    // console.log(arr);
    for(let i=0; i<n; i++) {
        if (arr[i][1]<=m) {
            m-=arr[i][1];
            ans+=arr[i][0]*arr[i][1];
        } else {
            ans+=arr[i][0]*m;
            break;
        }
    }
    console.log(ans);
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 52496
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define MOD 1000000007

using namespace std;


int main()
{
   FAST/**/
   
   ll n,t;
   cin>>n>>t;
   
   t--;
   pair<ll,ll> arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i].first>>arr[i].second;
   
   sort(arr,arr+n);        
   
   ll dp[n][t+1];
   memset(dp,0,sizeof(dp));
   if(arr[0].first<=t)
        dp[0][arr[0].first] = arr[0].second;
   
   ll ans = arr[0].second;
   
   for(ll i=1;i<n;i++)
   {
       for(ll j=0;j<=t;j++)
       {
           dp[i][j] = max(dp[i-1][j], dp[i][j]);
           if(j+arr[i].first<=t)
                dp[i][j+arr[i].first] = max(dp[i][j+arr[i].first], dp[i-1][j] + arr[i].second);
           else
                ans = max(ans, dp[i-1][j] + arr[i].second);
       }
   }
   
   for(ll i=0;i<=t;i++)
        ans = max(ans, dp[n-1][i]);
   
   cout<<ans;        
   
   
   
   return 0;
}  
   

Measured memory_bytes: 70656
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
 	int n,a,b;
    cin >> n >> a >> b;
    cout<<min(n*a,b);
    return 0;
    // Bye Bye 2019
}



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

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll, ll> pll;
typedef map< ll, ll> mll;

#define pie_value 3.14159265358979323846

int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
#endif

	ll n;
	cin >> n;

	ll pre[n + 4] = {0};
	ll a[n + 5] = {0};

	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
		pre[i] = (pre[i - 1] % mod +  a[i] % mod) % mod;
	}

	ll sum = 0;
	for (ll i = 1; i < n; i++) {
		sum = (sum + ((a[i] % mod) * ((pre[n] - pre[i] + mod) % mod)) % mod) % mod;
		//watch(sum);
	}
	cout << sum % mod << nl;

	return 0;
}


Measured memory_bytes: 6728
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll dp[103][100005];

int main(){
    //memset(dp,-1,sizeof dp+1);
    ll n,cap;
    cin>>n>>cap;
    ll wgt[n+1],pft[n+1];
    for(int i=1;i<=n; i++){
        cin>>wgt[i]>>pft[i];
        }

    dp[0][0] = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=cap; j++){
            if(j>=wgt[i]){
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-wgt[i]] + pft[i]);

            }else{
                dp[i][j] = dp[i-1][j];
            }

        }
    }
    cout<<dp[n][cap]<<"\n";
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

using i64=int64_t;

vector<i64> fact;
void init_fact(i64 n,i64 m){
	fact.resize(n+1);
	fact[0]=fact[1]=1;
	for(i64 i=2; i<=n; ++i) fact[i]=(i*fact[i-1])%m;
}

i64 extgcd(i64 a,i64 b,i64 &x,i64 &y){
	i64 d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	} else {
		x=1; y=0;
	}
	return d;
}

i64 mod_inverse(i64 a,i64 m){
	i64 x,y;
	if(extgcd(a,m,x,y)==1) return (x+m)%m;
	return 0;
}

i64 rep_pow(i64 x,int64_t y,i64 mod){
	i64 res(1);
	while(y>0){
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}

vector<vector<i64>> comb;
void init_mod_comb(int n,int k,i64 mod){
	comb.resize(n+1);
	for(int i=0; i<=n; ++i){
		comb[i].resize(min(i+1,k+1));
		comb[i][0]=1;
		if(i<=k) comb[i][i]=1;
	}
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=min(i-1,k); ++j){
			comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%mod;
		}
	}
}

void solve(){
	i64 mod=1000000007;
	init_mod_comb(1024,1024,mod);
	init_fact(1024*1024,mod);
	/*
	vector<i64> inv(1001*1001);
	rep(i,1,1001*1001) inv[i]=mod_inverse(i,mod);
	*/
	i64 inv_table[1000000];
	rep(i,1,1000000) inv_table[i]=mod_inverse(i,mod);
	auto inv=[&](i64 x){
		if(x<1000000) return inv_table[x];
		return mod_inverse(x,mod);
	};

    i64 N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    static i64 dp[1024][1024];
    fill_n((i64*)dp,1024*1024,0);
    dp[A][0]=1;
    rep(i,C,D+1){
        if(A*i>N) break;
        dp[A][A*i]=comb[N][A*i]*fact[A*i]%mod*inv(fact[i]*rep_pow(fact[A],i,mod)%mod)%mod;
    }

	rep(i,A,B){
		rep(j,0,N+1){
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			rep(k,C,D+1){
				if(j+(i+1)*k>N) break;
				dp[i+1][j+(i+1)*k]=(dp[i+1][j+(i+1)*k]+dp[i][j]*comb[N-j][(i+1)*k]%mod*fact[(i+1)*k]%mod*inv(fact[k]*rep_pow(fact[i+1],k,mod)%mod)%mod)%mod;
			}
		}
	}

	cout << dp[B][N] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 28544
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;



signed main(){
    string s;
    cin >> s;
    cout << (s[0] == s[2] ? "Yes" : "No" ) << endl;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>>
using namespace std;
int main()
{
   string s,t,u;

   int a,b;
 cin>>s>>t;
 cin>>a>>b;
 cin>>u;
 if(s==u)
    a=a-1;
 else
    b=b-1;

 cout<<a<<" "<<b<<endl;


    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, cnt = 0, i = 1;
	cin >> n;
	while (cnt < n) {
		cnt += i;
		i++;
	}
	cout << i - 1 << endl;
	return 0;
}

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

int main() {
  int N,M,C;
  cin>>N>>M>>C;
  vector<int>B(M);
  vector<vector<int>>A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }
  int a=0; int b=0;
  for(int i=0;i<N;i++){
    b=0;
    for(int j=0;j<M;j++){
      b=b+A.at(i).at(j)*B.at(j);
    }
    if(b+C>0){
      a++;
    }
  }
  cout<<a<< endl;
}



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

using namespace std;

int N, M;

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

    int res_min = 1;
    int res_max = N;

    for(int i=0;i<M;i++){
        int l, r;
        cin >> l >> r;

        if(res_min < l){
            res_min = l;
        }
        if(r < res_max){
            res_max = r;
        }
    }

    int ans = res_max - res_min + 1;

    cout << max(0, ans) << endl;

    return 0;
}


Measured memory_bytes: 256
S = input().strip()
N=len(S)
T = input().strip()
M=len(T)
A = []
for i in range(N-M+1):
    flag = 0
    for j in range(i,i+M):
        if S[j]=="?" or S[j]==T[j-i]:continue
        else:
            flag=1
            break
    if flag==0:
        X = list(S)
        for j in range(i,i+M):
            X[j] = T[j-i]
        for i in range(N):
            if X[i]=="?":
                X[i]="a"
        A.append(X)
if len(A)==0:
    print("UNRESTORABLE")
else:
    A = sorted(A)
    print("".join(A[0]))

Measured memory_bytes: 63216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> L(2*N);
    for(int i = 0; i < 2*N; i++)
    {
        cin >> L.at(i);
    }
    sort(L.begin(),L.end());
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        ans += L.at(2*i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
 int N,K,X,Y;	
 cin>>N>>K>>X>>Y;
 int answer;
 if (K <= N) {answer = X * K + Y * (N - K);}
 else {answer = X * N;}
 cout << answer << endl;
 return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
void PrintRectangle (int H, int W){
	int i, j;
	for(i=1; i<=H; i++){
		for(j=1; j<=W; j++)
			putchar('#');
		putchar('\n');
	}
}
int main(void)
{
	int H,W;
	while (1){
		scanf("%d %d", &H, &W);
		if (H==0 && W==0)
			break;
		PrintRectangle(H,W);
	putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
// #pragma GCC target("avx2")  // CPU 処理並列化
 // #pragma GCC optimize("O3")  // CPU 処理並列化
 // #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[1100][1100];
int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		int t=0;
		if(i<d)t++;
		if(j<c)t++;
		in[i][j]='0'+t%2;
	}
	for(int i=0;i<a;i++)printf("%s\n",in[i]);
}


Measured memory_bytes: 2176
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


class UnionFind():
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

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


def main():
    V, E = map(int, readline().split())
    L = []
    for _ in range(E):
        s, t, w = map(int, readline().split())
        L.append([s, t, w])
    # 重みが軽い順にソート
    L.sort(key=lambda x: x[2])
    uf = UnionFind(V)
    ans = 0
    for i in range(E):
        s, t, w = L[i]
        if not uf.same(s, t):
            uf.union(s, t)
            ans += w
    print(ans)


if __name__ == '__main__':
    main()



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

int main() {
    int n, m; cin >> n >> m;
    int h[n]; for (int i = 0; i < n; ++i) cin >> h[i];

    vector<vector<int>> bucket(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        bucket[a].push_back(b);
        bucket[b].push_back(a);
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (bucket[i].size() == 0) {
            res++;
            continue;
        }

        int highest = 0;
        for (int j = 0; j < bucket[i].size(); ++j) {
            highest = max(highest, h[bucket[i][j]]);
        }

        if (h[i] > highest) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8804
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long        ll;
typedef unsigned long long    ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N 100

int N;

int a[MAX_N+5];
int acount[MAX_N+5];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	int D=0;
	cin >> N;
	FOR(n,N) {
		cin >> a[n];
		D = max(D,a[n]);
		acount[a[n]]++;
	}

	// DOUT << "D=="<<D<<endl;
	bool result = true;
	FORULE(i,0,D) {
		int d = max(i,D-i);	
		if(acount[d]==0) {
			// DOUT << "[1]: acount["<<d<<"]=="<<acount[d]<<endl;
			result = false;
			break;
		}
		acount[d]--;
	}
	if(result) {
		int mind = D%2==0 ? D/2 : D/2+1;
		// DOUT << "mind=="<<mind<<endl;
		FORULE(d,0,mind) {
			if(acount[d]>0) {
				// DOUT << "[1]: acount["<<d<<"]=="<<acount[d]<<endl;
				result = false;
				break;
			}
		}
	}

	if(result) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}
 


Measured memory_bytes: 256
# AtCoder Beginner Contest 138
# D - Ki
# https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
sys.setrecursionlimit(10**6)

input = sys.stdin.readline
N, Q = map(int, input().split())

G = [[] for _ in [0]*N]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

counter = [0]*N

for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False]*N


def dfs(v=0, x=0):
    visited[v] = True
    counter[v] += x
    for u in G[v]:
        if visited[u]:
            continue
        dfs(u, counter[v])


dfs()
print(*counter)


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

using namespace std;

int
main(void){
	string s; cin >> s;
	vector<int> ans(s.size());
	int l = 0, r = 0;
	int i = 0;
	int ind1, ind2;
	int n = s.size();
	while(i < n){
		while(s[i] == 'R' && i < n){
			r++; i++;
		}
		ind1 = i - 1;
		ind2 = i;
		while(s[i] == 'L' && i < n){
			l++; i++;
		}
		int sum = (l + r);
		if((sum)%2 == 0){
			ans[ind1] = sum/2;
			ans[ind2] = sum/2;
		}
		else{
			if(l > r){
				if(l%2 == 0){
					ans[ind2] = sum/2;
					ans[ind1] = sum/2 + 1;
				} 
				else{
					ans[ind2] = sum/2 + 1;
					ans[ind1] = sum/2;
				}
			}
			else{
				if(r%2 == 0){
					ans[ind1] = sum/2;
					ans[ind2] = sum/2 + 1;
				}
				else{
					ans[ind1] = sum/2 + 1;
					ans[ind2] = sum/2;
				}
			}
		}
		l = 0; r = 0;
	}
	for(int i = 0; i < s.size(); i++) cout << ans[i] << " ";
}

Measured memory_bytes: 1024
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define fi first
#define se second
#define int long long
using namespace std;
#define lowbit(x) (x&-x)

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x * f;
}
const int MAXN = 2e5 + 100;
int n,k,a[MAXN],s[MAXN],ans = 0;
int C[MAXN];
vector<int>v;
inline void add(int x,int d){for(int i=x;i<MAXN;i+=lowbit(i)) C[i]+=d;}
inline int Gsum(int x){int ret = 0;for (int i=x;i>=1;i-=lowbit(i)) ret += C[i]; return ret;}
///------------------head------------------
signed main(signed argc, char *argv[]){
    //freopen("b14.in","r",stdin);
    //freopen("my.out","w",stdout);
    n=read(); k=read();
    rep(i,1,n) a[i]=read()-k,s[i]=s[i-1]+a[i];
    rep(i,0,n) v.pb(s[i]);
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    rep(i,0,n) s[i]=lower_bound(v.begin(),v.end(),s[i])-v.begin()+1;
    rep(i,0,n){
        ans += Gsum(s[i]);
        add(s[i],1);
    }
    printf("%lld\n",ans);
	return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 6640
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int x,y; cin >> x >> y;
  int ans = 0;
  while(x <= y){
    x *= 2;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int N,M;
    cin>>N>>M;
    vvi s(M+1,vi(N+1,0));
    vi k(M+1);
    for(int i=1;i<=M;i++){
        cin>>k[i];
        for(int j=1;j<=k[i];j++){
            cin>>s[i][j];
        }
    }
    vi p(M+1,0);
    for(int i=1;i<=M;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int bits=0;bits<(1<<N);bits++){
        bool clear=1;
        for(int i=1;i<=M;i++){
            int sum=0;
            for(int j=1;j<=k[i];j++){
                if(bits&(1<<(s[i][j]-1))) sum++;
            }
            if(!(sum%2==p[i])) clear = false;
        }
        if(clear) ans++;
    }
    out(ans);
}

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

Measured memory_bytes: 256
n = int(input())
c = [int(input()) for i in range(n)]
MOD = 10**9 + 7

dp = [0]*(n+1)
dp[0] = 1
memo = {}
for i in range(n):
    if c[i] not in memo:
        memo[c[i]] = i
        dp[i+1] = dp[i]
    else:
        if c[i]==c[i-1]:
            dp[i+1] = dp[i]
            memo[c[i]] = i
            continue
        # memo[c[i]]からiの区間を変えるとき
        dp[i+1] += dp[memo[c[i]]+1]
        # memo[c[i]]からiの区間を変えないとき
        dp[i+1] += dp[i]
        
        memo[c[i]] = i
        dp[i+1] %= MOD
print(dp[-1] % MOD)

Measured memory_bytes: 36552
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   string str;cin>>str;
   sort(str.begin(),str.end());
   if(str[0]==str[1] && str[1] != str[2] && str[2]==str[3])cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


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

class rout{
	char t;
public: 
	rout(){
		t='A';
	}
	void next(char n){
		if(t == 'A'){
			if(n == '1'){
				t = 'Y';
			}else{
				t = 'X';
			}
		}else if(t == 'X'){
			if(n == '1'){
				t = 'Z';
			}else{
				t = 'E';
			}
		}else if(t == 'Y'){
			if(n == '1'){
				t = 'E';
			}else{
				t = 'X';
			}
		}else if(t == 'Z'){
			if(n == '1'){
				t = 'B';
			}else{
				t = 'W';
			}
		}else if(t == 'W'){
			if(n == '1'){
				t = 'Y';
			}else{
				t = 'B';
			}
		}else if(t == 'B'){
			if(n == '1'){
				t = 'X';
			}else{
				t = 'Y';
			}
		}
	}
	bool isOk(){
		if(t=='B')
			return true;
		return false;
	}
};

int main()
{
	char str[101];
	while(cin >> str){
		if(str[0] == '#'){
			break;
		}
		rout r;
		int i = 0;
		while(str[i] != '\0'){
			r.next(str[i]);
			i++;
		}
		if(r.isOk()){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
	}
	return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N;
long long K;
vector<int> A;

int solve() {
    deque<int> syu;
    set<int> se;
    int cur = 0;
    while (true) {
        if (se.count(cur)) {
            while (syu[0] != cur) {
                --K;
                syu.pop_front();
                if (K == 0) return syu[0] + 1;
            }
            break;
        }
        syu.push_back(cur);
        se.insert(cur);
        cur = A[cur];
    }

/*
    COUT(K);
    COUT(syu);
    */
    return syu[K % syu.size()] + 1;
}

int main() {
    while (cin >> N >> K) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i], --A[i];
        cout << solve() << endl;
    }
}

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

using namespace std;

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

	const int MOD = 1e9 + 7;
	int n;
	cin >> n;
	map<int, int> count;
	for (int i = 2; i <= n; i++) {
		int x = i;
		for (int j = 2; j * j <= x; j++) {
			while (x % j == 0) {
				count[j]++;
				x /= j;
			}
		}
		if (x != 1) {
			count[x]++;
		}
	}
	long long res = 1;
	for (auto &p : count) {
		res = (res * (p.second + 1)) % MOD;
	}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 256