akhauriyash/Code-Regression huggingface dataset:
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=2e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,mx,x,y,nv1,nv2;
vector<ll> g[ary],q;
void dfs(ll v,ll d=0,ll p=0){
	q.putb(v);
	if(d>mx){
		if(len(q)%2){
			nv1=nv2=q[len(q)/2];
		}
		else{
			nv1=q[len(q)/2-1];
			nv2=q[len(q)/2];
		}
		y=v;
		mx=d;
	}
	for(int i=0;i<len(g[v]);i++){
		ll to=g[v][i];
		if(to==p){
			continue;
		}
		dfs(to,d+1,v);
	}
	q.gainb();
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;i++){
		ll a,b;
		cin>>a>>b;
		g[a].putb(b);
		g[b].putb(a);
	}
	dfs(1);
	mx=0;
	dfs(y);
	if(mx%3==1){
		cout<<"Second";
		return 0;
	}
	cout<<"First";
}

Measured memory_bytes: 25332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  if(y % 2 == 1) {
    cout << "No";
    return 0;
  } else if(x*4 < y || x*2 > y) {
    cout << "No";
    return 0;
  }
  cout << "Yes";
}

Measured memory_bytes: 3632
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265359;

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//
    cout<<fixed<<setprecision(11);
    ld A,B,H,M;
    cin>>A>>B>>H>>M;
    H=H+M/60.0;
    ld thetaH=(360.0*(H/12));
    ld thetaM=H*360;
    ld theta=thetaH-thetaM;
    ld ans=sqrt(A*A+B*B-2.0*A*B*cosl(theta*PI/180.0));
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W;
string a[110];
int c[26];
int cnt1, cnt2, cnt4;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> a[i];
  }  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      c[a[i][j] - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    if (c[i] >= 4) {
      cnt4 += c[i] / 4;
      c[i] %= 4;
    }
    if (c[i] >= 2) {
      cnt2 += c[i] / 2;
      c[i] %= 2;
    }
    if (c[i] >= 1) {
      cnt1 += c[i];
      c[i] %= 1;
    }
  }
  if (H == 1 && W == 1) {
    cout << "Yes" << endl;
    return 0;
  }
  if (H == 1 || W == 1) {
    int tmp = max(H, W);
    cnt2 += cnt4 * 2;
    if (tmp % 2 == 1) {
      cout << (cnt1 == 1 && cnt2 * 2 == tmp - 1 ? "Yes" : "No") << endl;
    } else {
      cout << (cnt2 * 2 == tmp ? "Yes" : "No") << endl;
    }
    return 0;
  }
  if (H % 2 == 1 && W % 2 == 1) {
    if (cnt4 < ((H - 1) / 2) * ((W - 1) / 2)) {
      cout << "No" << endl;
      return 0;
    }
    cnt2 += 2 * (cnt4 - ((H - 1) / 2) * ((W - 1) / 2));
    if (cnt2 == (H - 1) / 2 + (W - 1) / 2 && cnt1 == 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (H % 2 == 1 || W % 2 == 1) {
    if (H % 2 == 1) swap(H, W);
    if (cnt4 < (H / 2) * ((W - 1) / 2)) {
      cout << "No" << endl;
      return 0;
    }
    cnt2 += 2 * (cnt4 - (H / 2) * ((W - 1) / 2));
    if (cnt2 == H / 2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << (cnt4 == (H / 2) * (W / 2) ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TEST int t;cin>>t;for(int i=1;i<=t;i++)
#define F first
#define S second
int main()
{
	ll a,c;
	double b;
	int d;
	cin>>a>>b;
	d=round(b*100);
	c=a*d/100;
	cout<<c<<endl;
	//main();
}


Measured memory_bytes: 3740
fn main() {
 let v:Vec<i8>={
  let mut b=String::new();
  let s=std::io::stdin();
  s.read_line(&mut b).unwrap();
  b.split_whitespace().flat_map(str::parse).collect()
 };
 let (w,h,x,y,r) = (v[0],v[1],v[2],v[3],v[4]);
 println!("{}",if(0+r<=x&&x<=w-r)&&(0+r<=y&&y<=h-r){"Yes"}else{"No"});
}


Measured memory_bytes: 5024
#include <cstdio>
#include <iostream>
#include <cstring>
#define MN 2010

int cnt[MN], id[MN];
int fa[MN], dep[MN];
int u[MN], v[MN];
bool ok[MN], used[MN];
int h[MN], nxt[2 * MN], to[2 * MN], K = 0;

void ins(int u, int v) {nxt[++K] = h[u]; h[u] = K; to[K] = v;}

int lca(int u, int v)
{
	while(dep[u] > dep[v]) u = fa[u];
	while(dep[v] > dep[u]) v = fa[v];
	while(u != v) u = fa[u], v = fa[v];
	return u;
}

void modify(int o, int t)
{
	int l = lca(u[o], v[o]); 
	for(int i = u[o]; i != l; i = fa[i])
		cnt[i] += t, id[i] ^= o;
	for(int i = v[o]; i != l; i = fa[i])
		cnt[i] += t, id[i] ^= o;
	if(t == -1) used[o] = 1;
}

bool calc(int a, int b, int c, int d)
{
	if(std::max(dep[b], dep[d]) < dep[lca(a, c)]) return 1;
	else return 0;
}

void solve(int x, int y)
{
	int o = 0, l1 = lca(x, y);
	for(int i = x; i != l1; i = fa[i])
		if(cnt[i] == 1) o = id[i];
	for(int i = y; i != l1; i = fa[i])
		if(cnt[i] == 1) o = id[i];
	if(!o) return;
	int l2 = lca(u[o], v[o]);
	modify(o, -1); 
	if(calc(x, l1, u[o], l2)) ok[o] = 1, solve(x, u[o]), solve(v[o], y);
	else if(calc(x, l1, v[o], l2)) ok[o] = 0, solve(x, v[o]), solve(u[o], y);
	else if(calc(y, l1, u[o], l2)) ok[o] = 0, solve(u[o], y), solve(x, v[o]);
	else if(calc(y, l1, v[o], l2)) ok[o] = 1, solve(v[o], y), solve(x, u[o]);
}

void dfs(int x, int f)
{
	fa[x] = f; dep[x] = dep[f] + 1;
	for(int i = h[x]; i; i = nxt[i])
		if(to[i] != f) dfs(to[i], x);
}

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for(int i = 1; i < n; i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		ins(a, b); ins(b, a);
	}
	dfs(1, 0);
	for(int i = 1; i <= m; i++) scanf("%d%d", &u[i], &v[i]), modify(i, 1);
	int ans = 0; for(int i = 2; i <= n; i++) ans += std::min(cnt[i], 2);
	for(int i = 1; i <= m; i++)
		if(!used[i]) modify(i, -1), solve(u[i], v[i]);
	printf("%d\n", ans);
	for(int i = 1; i <= m; i++)
	{
		if(ok[i]) printf("%d %d\n", v[i], u[i]);
		else printf("%d %d\n", u[i], v[i]);
	}
}

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

int main(){
    int n,k,i;
    char s[11];
    char c;
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&k);

    c = s[k-1];

    for(i=0;i<n;i++){
        if(s[i]!=c){
            s[i] = '*';
        }
    }

    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
N,K=map(int, input().split())
h=list(map(int, input().split()))
h=[0]+h
dp=[10*10]*(N+1)
dp[1]=0
for n in range(2,N+1):
  m=[]
  ma=K+1 if n>K else n
  for i in range(1,ma):
    m.append(dp[n-i]+abs(h[n-i]-h[n]))
  dp[n]=min(m)
print(dp[N])
         

Measured memory_bytes: 52704
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
#define BIT(S,i) ((S&(1ll<<i))>0)
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;}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin>>N;
	vector<int>a(N),b(N);
	REP(i,N)cin>>a[i];
	REP(i,N)cin>>b[i];
	priority_queue<pair<int,int>>que;
	REP(i,N){
		if(a[i]!=b[i])que.push({b[i],i});
	}
	int ans = 0;
	while(que.size()){
		int now = que.top().first;
		int idx = que.top().second;
		que.pop();
		int t = (now - a[idx]) / (b[(idx+1)%N] + b[(idx-1+N)%N]);
		if(t==0){
			cout<<-1<<endl;
			return 0;
		}
		b[idx]-=t*(b[(idx+1)%N] + b[(idx-1+N)%N]);
		now-=t*(b[(idx+1)%N] + b[(idx-1+N)%N]);
		if(b[idx]<a[idx]){
			cout<<-1<<endl;
			return 0;
		}
		if(b[idx]!=a[idx])que.push({now,idx});
		ans+=t;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
int N,A[1000010],B[1000010],C[1000010];
struct node{
	int x,y,z;
};
node W[1000010];
bool cmp(node X,node Y){
	if(X.y!=Y.y)return X.y<Y.y;
	return X.x<Y.x;
}
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)scanf("%d %d",&A[i],&B[i]),C[i]=B[i]-A[i];
	for(int i=1;i<=N;i++)W[i]=node{A[i],B[i],C[i]};
	sort(W+1,W+1+N,cmp);
	//for(int i=1;i<=N;i++)cout<<W[i].x<<" "<<W[i].y<<" "<<W[i].z<<endl;
	for(int i=1,t=0;i<=N;i++){
		//cout<<t<<endl;
		if(t>W[i].z){
			puts("No");
			return 0;
		}
		t+=W[i].x;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;
 
template<class T>
vector<pair<T, T>> PrimeFactorization(T n) {
    vector<pair<T, T>> f;
    for (T i = 2; i * i <= n; i++) {
        T cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) f.push_back(make_pair(i, cnt));
    }
    if (n != 1) f.push_back(make_pair(n, 1));
    return f;
}
 
ll power(ll n, ll p, ll mod) {
    ll ans = 1;
    while (p > 0) {
        if (p & 1) ans = ans * n % mod;
        n = n * n % mod;
        p >>= 1;
    }
    return ans;
}
 
ll modinv(ll n, ll mod) {
    return power(n, mod - 2, mod);
}
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];
 
    int factors[(int)pow(10, 6)] = {};
    REP(i, 0, N) {
        auto f = PrimeFactorization(A[i]);
        for (auto elm : f) factors[elm.first] = max(factors[elm.first], elm.second);
    }
 
    ll lcm = 1;
    REP(i, 1, pow(10, 6)) {
        if (factors[i] == 0) continue;
        lcm = (lcm * power(i, factors[i], MOD)) % MOD;
    }
 
    ll ans = 0;
    REP(i, 0, N) {
        ans = (ans + (lcm * modinv(A[i], MOD)) % MOD) % MOD;
    }
    cout << ans << endl; 
    
    return 0;
}


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

using namespace std;

namespace {
    string s;
    void input() {
        cin >> s;
    }

    void solve() {
        if (s.size() < 4) {
            cout << "No" << endl;
            return;
        }
        cout << (s.substr(0, 4)  == "YAKI" ? "Yes" : "No") << endl;
    }
}

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



Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    double a, b, x, s;
    cin >> a >> b >> x;
    s = x / a;
    if(s < a * b / 2.0){
        double th = atan(b * b / (2.0 * s));
        th *= 180 / M_PI;
        printf("%.7lf", th);
    } else {
        double th = atan(2.0 *(a * b - s)/ (a * a));
        th *= 180 / M_PI;
        printf("%.7lf", th);
    }
}

Measured memory_bytes: 512
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	std::vector<int> A(10);
	for (int i = 0; i < 10; i++) {
		std::cin >> A[i];
	}
	std::sort(A.begin(), A.end());
	std::cout << A[9] << std::endl;
	std::cout << A[8] << std::endl;
	std::cout << A[7] << std::endl;

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 3156
package main

import (
	"fmt"
	"strings"
)

type player struct {
	name  string
	cards []string
}

func (p *player) playCard() string {
	card := p.cards[0]
	p.cards = p.cards[1:]
	return card
}

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	playerA := &player{name: "A", cards: strings.Split(a, "")}
	playerB := &player{name: "B", cards: strings.Split(b, "")}
	playerC := &player{name: "C", cards: strings.Split(c, "")}
	cardPlayerMap := map[string]*player{"a": playerA, "b": playerB, "c": playerC}

	curPlayer := playerA
	for {
		if len(curPlayer.cards) == 0 {
			fmt.Println(curPlayer.name)
			return
		}
		curPlayer = cardPlayerMap[curPlayer.playCard()]
	}
}


Measured memory_bytes: 1848
import copy
Sd = list(input())
T = list(input())
S = copy.deepcopy(Sd)
ans = []
for i in range(len(Sd)-len(T)+1):
    for j in range(len(T)):
        if Sd[i+j] != '?' and Sd[i+j] != T[j]:
            Sd = copy.deepcopy(S)
            break
        elif Sd[i+j] == '?':
            Sd[i+j] = T[j]
        if j == len(T)-1:
            l = ['a' if i =='?' else i for i in Sd]
            ans.append(''.join(l))
            Sd = copy.deepcopy(S)
if len(ans) == 0:
    print('UNRESTORABLE')
else:
    print(min(ans))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define rep2(i,a,b) for(lint i=a;i<(lint)(b);i++)
#define PICK(N,m,p) (N/(int)(pow(p,m-1))-(N/(int)(pow(p,m)))*p)
using lint = long long;
using ld = long double;
using namespace std;

lint gcd(lint x,lint y){
    lint a=MAX(x,y);
    lint b=MIN(x,y);
    if(b==0) return a;
    else {
        lint q=a/b;
        lint g=gcd(b,a-q*b);
        return g;
    }
}

int main(){
    int N, X;
    lint x[100001];
    cin >> N >> X;
    rep(i,N) cin >> x[i];
    lint d[100001];
    rep(i,N) d[i]=abs(x[i]-X);
    lint D=1;
    D=d[0];
    rep(i,N-1) D=gcd(d[i+1],D);
    cout << D << endl;
	return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>

int pop_count(int n) {
	int result{ 0 };
	while (n != 0) {
		result += n & 1;
		n >>= 1;
	}
	return result;
}
int f(int n) {
	int count{ 0 };
	while (n != 0) {
		n = n % pop_count(n);
		++count;
	}
	return count;
}
int power(const int base, const int e, const int mod) {
	switch (e) {
	case 0: return 1;
	case 1: return base;
	default: return power(base * base % mod, e >> 1, mod) * power(base, e & 1, mod) % mod;
	}
}
int main() {
	int n; std::cin >> n;
	std::string x; std::cin >> x;
	const auto bit_count = std::count(x.begin(), x.end(), '1');
	std::vector<int> power_pos(n + 1, 1), power_minus(n + 1, 1);
	for (auto i = 1; i <= n; ++i) {
		power_pos[i] = (power_pos[i - 1] << 1) % (bit_count + 1);
		if (bit_count > 1) {
			power_minus[i] = (power_minus[i - 1] << 1) % (bit_count - 1);
		}
	}
	int sum_up{ 0 }, sum_down{ 0 };
	for (auto i = 0; i < n; ++i) {
		if (x[i] == '1') {
			sum_up = ((sum_up << 1) + 1) % (bit_count + 1);
			if (bit_count > 1) {
				sum_down = ((sum_down << 1) + 1) % (bit_count - 1);
			}
		}
		else {
			sum_up = (sum_up << 1) % (bit_count + 1);
			if (bit_count > 1) {
				sum_down = (sum_down << 1) % (bit_count - 1);
			}
		}
	}
	for (auto i = 0; i < n; ++i) {
		if (x[i] == '0') {
			const auto sum = (sum_up + power_pos[n - i - 1]) % (bit_count + 1);
			std::cout << f(sum) + 1 << '\n';
		}
		else if (bit_count > 1) {
			const auto sum = (sum_down - power_minus[n - i - 1] + (bit_count - 1)) % (bit_count - 1);
			std::cout << f(sum) + 1 << '\n';
		}
		else {
			std::cout << "0\n";
		}
	}
}


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

#define ff(i, a, b) for(int i = (a); i <= b; ++i)

int n;
double a[55];

int main() {
    cin >> n;
    ff(i, 1, n) cin >> a[i];
    sort(a + 1, a + 1 + n);

    ff(i, 2, n) a[i] = (a[i - 1] + a[i]) / 2;
    cout << a[n];
}


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

int main() {
  uint64_t N = 0, D = 0;
  std::cin >> N >> D;

  uint32_t ans = 0;
  for (size_t i = 0; i < N; i++)
  {
    int64_t X = 0, Y = 0;
    std::cin >> X >> Y;

    if(static_cast<uint64_t>(X*X + Y*Y) <= D*D) ans++;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


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

    long int m{0}, a{0}, r{0}, c{0}, h{0};

    for (int i = 0; i < N; ++i){
        string s;
        cin >> s;
        if (s[0] == 'M')
            m++;
        if (s[0] == 'A')
            a++;
        if (s[0] == 'R')
            r++;
        if (s[0] == 'C')
            c++;
        if (s[0] == 'H')
            h++;
    }
    long int D[5];

    int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
    D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
    long int res = 0;
    for (int d = 0; d < 10; d++)
        res += D[P[d]] * D[Q[d]] * D[R[d]];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int c = parseInt(sc.next());
		int d = parseInt(sc.next());
		sc.close();
		out.println((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d?"Yes":"No");
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll N,M;
    cin>>N>>M;
    if(N>=1&&N<=9&&M>=1&&M<=9)
        cout<<N*M<<endl;
    else cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdint.h>
#include<stdbool.h>
int main(){
  int a[3][3];
  scanf("%d %d %d", &a[0][0], &a[0][1], &a[0][2]);
  scanf("%d %d %d", &a[1][0], &a[1][1], &a[1][2]);
  scanf("%d %d %d", &a[2][0], &a[2][1], &a[2][2]);
  bool open[3][3] = {false};
  int n;
  scanf("%d", &n);
  int *b = calloc(n, sizeof(int));
  for(int i = 0; i < n; ++i){
	  scanf("%d", b+i);
	  for(int j = 0 ; j < 9 ; ++j)
		  if(!*(open[0]+j))
			  *(open[0] + j) = *(a[0]+j) == *(b+i);
  }
  if(open[0][0] != false && open[0][1] != false && open[0][2] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[1][0] != false && open[1][1] != false && open[1][2] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[2][0] != false && open[2][1] != false && open[2][2] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[0][0] != false && open[1][0] != false && open[2][0] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[0][1] != false && open[1][1] != false && open[2][1] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[0][2] != false && open[1][2] != false && open[2][2] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[0][0] != false && open[1][1] != false && open[2][2] != false){
	  puts("Yes");
	  return 0;
  }
  if(open[2][0] != false && open[1][1] != false && open[0][2] != false){
	  puts("Yes");
	  return 0;
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long int
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++) 
#define E "\n"

#define pi 3.141592653589793
int solve()
{
	int n,m;
	cin >> n >> m;
	vector<int> v[n+1];
	f(i,0,m)
	{
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans[n+1]={0};

	queue<int> q;
	q.push(1);
	ans[1]=1;

	while(!q.empty())
	{
		int cur=q.front();
		q.pop();

		for(auto x:v[cur]) 
		{
			if(ans[x]==0) 
			{
				ans[x]=cur;
				q.push(x);
			}
		}
	}
	bool flg=true;
	f(i,2,n+1) if(ans[i]==0) flg=false;

	if(!flg) cout<<"No\n";
	else
	{
		cout<<"Yes\n";
		f(i,2,n+1) cout<<ans[i]<<"\n";
	}
	
	return 0;	
}


int32_t main()
{
     int t = 1;
    // cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 12984
n, m = map(int, input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
ans = [-1 for _ in range(n)]
ans[0] = 0
tree=[[]for _ in range(n)]
for a,b in ab:
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
visited={0}
q=[0]
for i in q:
    for j in tree[i]:
        if ans[j] < 0:
            q.append(j)
            ans[j]=i+1
print("Yes")
for i in ans[1:]:
    print(i)

Measured memory_bytes: 74176
#include <iostream>
#include <climits>
#include <cstring>
#include <vector>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
const ll maxn = 3010;
double arr[maxn];
double dp[maxn][maxn];
bool calced[maxn][maxn];
ll n;

double go(ll i, ll j){
    //cerr << i << " " << j << endl;
    if(i == n+1)  if(j > n-j) return 1.0; else return 0;
    if(calced[i][j]==true) return dp[i][j];
    calced[i][j] = true;
    return dp[i][j] = arr[i]*go(i+1,j+1) + (1-arr[i])*go(i+1,j);
}
int main(){
    scanf("%lld",&n);

    for(ll i = 1; i <= n; i++)  scanf("%lf",arr+i);

    for(ll i = n/2+1; i <= n; i++)  dp[0][i] = 1;
    for(ll i = 0; i <= n/2; i++)    dp[0][i] = 0;

    printf("%.10f\n",go(1,0));
}


Measured memory_bytes: 78336
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b;
  cin >> a >> b;
  if (a <= 0 && 0 <= b) {
    cout << "Zero";
  } else if (a > 0)
    cout << "Positive";
  else if ((b - a + 1) % 2 == 1)
    cout << "Negative";
  else
    cout << "Positive";

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

#define f first
#define s second
#define all(x) (x).begin(), (x).end()

const int INF = INT_MAX;
const int MOD = 1e9 + 5;
const int N = 1e5 + 5;

int p[10], c[10];

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

	int d, g;
	cin>>d>>g;

	for(int i = 0; i < d; i++)
	{
		cin>>p[i]>>c[i];
	}

	int ans = INF;
	for(int mask = 0; mask < (1<<d); mask++)
	{
		int sum = 0, cnt = 0, flag = 1;
		for(int i = 0; i < d; i++)
		{
			if(mask & (1<<i))
			{
				sum += p[i] * (i + 1) * 100 + c[i];
				cnt += p[i];
			}
		}

		if(sum < g)
		{
			for(int i = d-1; i >= 0; i--)
			{
				if((mask & (1<<i)) == 0)
				{
					int x = ceil((float) (g - sum) / ((i + 1) * 100));
					if(x < p[i])
					{
						cnt += x;
						sum += x * ((i + 1) * 100);
					}
					if(sum < g) 
					{
						flag = 0;
					}
					break;
				}
			}
		}

		if(flag)
		{
			ans = min(ans, cnt);
		}
	}

	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  int w;
  cin >> S >> w;
  for (int i=0; i<S.size(); i+=w) cout << S[i];
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    string s;cin>>s;
    for(ll i=0;i<s.length();++i){
        if(i%2==0&&s[i]=='L'||i%2==1&&s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    ll dab;
    dab = B-A;
    ll U;
    U = V-W;
    if(A<=B){
    if(U*T>=dab)cout<<"YES"<<endl;
    else if(U*T<dab)cout<<"NO"<<endl;
    }
    else if(A>B){
        dab = A-B;
        U = V-W;
        if(U*T>=dab)cout<<"YES"<<endl;
        else if(U*T<dab)cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#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 showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define 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)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  int n, m;
  cin >> n >> m;
  vi ac(n), pena(n);
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    if (ac[p]) continue;
    if (s == "AC") ac[p] = 1;
    else pena[p]++;
  }
  int AC = 0, PENA = 0;
  rep(i,n) {
    AC += ac[i];
    if (ac[i]) PENA += pena[i];
  }
  cout << AC SP PENA << endl;
  return 0;
}

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    long long x = a * b * (c - c / 2) - a * b * (c / 2);
    long long y = a * c * (b - b / 2) - a * c * (b / 2);
    long long z = b * c * (a - a / 2) - b * c * (a / 2);
    long long ans = min({x, y, z});
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
        
        while(true){
            int sum = 0;
            double a = 0.0, m = 0.0, sum2 = 0.0;

            int n = sc.nextInt();
            int score[] = new int[n];

            if(n==0){break;}
            else{
                for(int i=0;i<n;i++){
                    score[i] = sc.nextInt();
                    sum += score[i];
                }
                m = (double)sum / n;

                for(int i=0;i<n;i++){
                    sum2 += (double)(score[i] - m)*(score[i] - m);
                }
                a = sum2 / n;

                System.out.println(Math.sqrt(a));
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 30988
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int func(int n){
  if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

void solve(){
  int s; cin >> s;
  vector<int> a;
  a.push_back(s);
  while(1){
    a.push_back(func(a[a.size() - 1]));
    int i;
    for(i = 0; i < a.size() - 1; i++){
      if(a[a.size() - 1] == a[i]) break;
    }
    if(i != a.size() - 1){
      cout << a.size() << endl;
      return;
    }
  }
  return;
}

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


Measured memory_bytes: 256
// this solution is not supported by proof.
// So next time, prove the validity of this solutionl.
// ok, I could prove the validity.
#include <bits/stdc++.h>
using namespace std;

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

  sort(a.begin(), a.end());

  int last = a[n-1];
  int theOther = 0;

  if(last % 2 == 0) {
    int half = last / 2;
    int minAb = INT_MAX;
    for(int i=0;i<n-1;i++) {
      if(abs(half-a[i]) < minAb) {
        minAb = abs(half-a[i]);
        theOther = a[i];
      }
    }
  } else {
    int half = last / 2;
    int minAb = INT_MAX;
    for(int i=0;i<n-1;i++) {
      if(min(abs(half-a[i]), abs(half+1-a[i])) < minAb) {
        minAb = min(abs(half-a[i]), abs(half+1-a[i]));
        theOther = a[i];
      }
    }
  }

  cout << last << " " << theOther << endl;
}

Measured memory_bytes: 640
N =int(input())
As = [int(x) for x in input().split()]
res = [0]*(N)
ks = range(N)

for i in range(N-1,N//2,-1):
    res[i] = As[i]
for i in range(N//2,0,-1):
    res[i] = (As[i]+sum(res[i::(i+1)]))%2
res[0] = (As[0]+sum(res[1:]))%2
ans =[]
for i,v in enumerate(res):
    if v==1:
        ans.append(i+1)
print(len(ans))
print(" ".join(map(str,ans)))

Measured memory_bytes: 79592
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int x, y , a, b, c ;
const int M = 1e5 ;
int A[M],B[M],C[M];
priority_queue<int> pqr , pqg , pql ; 
int main()
{
     cin >> x >> y >> a >> b >> c ;
     for (int i =0 ; i < a ;i++)
     {
         int aa ;
         cin >> aa ;
         pqr.push(-aa); 
     }
     for (int i =0 ; i < b ;i++)
     {
         int bb ;
         cin >> bb ;
         pqg.push(-bb); 
     }
     for (int i =0 ; i < c ;i++)
     {
         int cc ;
         cin >> cc ;
         pql.push(cc); 
     }
     while (SZ(pqr) > x)pqr.pop(); 
     while (SZ(pqg) > y)pqg.pop();
    while (!pql.empty())
    {
        int cur = pql.top();
        pql.pop(); 

        int aR = -pqr.top(); 
        int aG = -pqg.top(); 
        if (cur <= min (aR , aG))
        {
            break; 
        }
        pqr.pop();
        pqg.pop();
        if (cur - aR > cur - aG )
        {
            aR = cur ;
        }else 
        {
            aG = cur ;
        }
        pqr.push(-aR);
        pqg.push(-aG);
    }
    ll ans =0 ;
    while (!pqr.empty())
    {
        ans += -pqr.top(); 
        pqr.pop();
    }
    while (!pqg.empty())
    {
        ans += -pqg.top(); 
        pqg.pop();
    }
    cout << ans <<"\n"; 
}


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

int main(void){
    int n;
    cin >> n;

    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        // cout << a[i] << " ";
    }
    // cout << endl;

    vector<ll> b(n-1);
    b[0] = a[0];
    // cout << b[0] << " ";
    rep(i,n-2) {
        b[i+1] = (b[i] + a[i+1]) % 1000000007;
        // cout << b[i+1] << " ";
    }
    // cout << endl;

    int ans = 0;
    rep(i,n-1) {
        ans += a[i+1] * b[i] % 1000000007;
        ans %= 1000000007;
        // cout << a[i+1] << " " << b[i] << " " << ans << endl;
    }
    // cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6396
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int fh = 0;
        int five = 0;

        fh = x/500;
        x-=fh*500;

        five = x/5;

        System.out.println(fh*1000+five*5);

    }

}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char S[201];
	scanf("%s", &S);
	int len;
	int cnt = 0;
	int ok = 0;
	int ans;
	for (len = strlen(S) - 1; len >= 2; len--) {
		if (len % 2 == 0) {
			for (int i = 0; i < (len / 2); i++) {
				if (S[i] == S[(len / 2) + i]) {
					cnt++;
				}
				else{
					cnt = 0;
					break;
				}
			}
			if (cnt == len / 2) {
				ok = 1;
				break;
			}
		}
	}
	ans = cnt * 2;
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
	}

Measured memory_bytes: 128
object Main {
  def main(args: Array[String]): Unit = {
    val input_num = scala.io.StdIn.readInt
    val factors   = io.StdIn.readLine.split(" ").map{_.toInt}
    var count     = 0

    ( 0 until factors.length ).foreach { i =>
      if ( ( i + 1 )%2 == 1 && factors( i )%2 == 1 ) count += 1
    }

    println( count )
  }
}

Measured memory_bytes: 54612
n,x=map(int, input().split()) #i_1 i_2を取得し、iに値を入れる
l= list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
sum=0
cnt=1
for i in range(len(l)):
    if sum<x:
        sum+=l[i]
        cnt+=1
    else:
        break
if sum>x:
    print(cnt-1)
else:
    print(cnt)

Measured memory_bytes: 38384
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


vector<int>v;
vector<int>u;
int r;

void f(int a,int b){

	int s=v.size();
	if(s==r+5) return;

	v.push_back((10*a)/b);

	int c=(10*a)%b;
	f(c,b);

}

void g(vector<int>& v,vector<int>& u){

	int t=0;
	rep(i,r+5){
	t+=v[r+4-i]+u[r+4-i];
	u[r+4-i]=t%10;
	t/=10;

	}

	v.clear();
}

int main(){

	int n,k,m;
	while(true){

	cin >> n >> k >> m >> r;
	if(n==0 && k==0 && m==0 && r==0) break;

	u.assign(r+5,0);
	v.push_back(0);

	f(1,n);
	g(v,u);

	if(m==0){

	cout << u[0] << ".";
	REP(i,1,r) cout << u[i];

	}

	else{

	REP(i,1,n-1){

	v.push_back(0);

	f(1,i*n);
	g(v,u);

	}

	cout << u[0] << ".";
	REP(i,1,r) cout << u[i];

	}

	cout << endl;
    u.clear();

	}

	return 0;
}

Measured memory_bytes: 1812
n = int(input())
d = list(int(input()) for _ in range(n))
d.sort(reverse=True)

r = []
cnt = 0
for i in d:
  if cnt == 0:
    r.append(i)
    cnt += 1
  else:
    if r[-1] == i:
      continue
    else:
      r.append(i)
      cnt += 1
print(cnt)

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

int main() {
  int N, A;
  A = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    int B, C;
    cin >> B >> C;
    A += C-B+1;
  }
  cout << A << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=2e5+11;
const int M=2e6+11;
const int W=1e3+11;
const int inf=1e9;
const ll INF=1e18;
const ll mod=1e9+7;
const ld EPS=1e-9;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
  
public class Main{
  public static void main(String[] args){
    Scanner stdIn=new Scanner(System.in);
    int t=stdIn.nextInt();
    int h,m,s;
    s=t%60;
    t=t/60;
    m=t%60;
    t=t/60;
    h=t;
    System.out.println(h+":"+m+":"+s);
  }
}


Measured memory_bytes: 26348
k, s =  gets.split(' ')
K = k.to_i
S = s.to_i
count = 0
(K + 1).times do |x|
  (K + 1).times do |y|
    z = S - (x + y)
    if 0 <= z && z <= K then count += 1 end
  end
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 2e3 + 10;
const ll mod = 1e9 + 7;

ll dp[maxN][maxN];
int a[maxN], b[maxN];
int n, m;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i <= n; ++i) dp[i][0] = 1;
  for (int j = 0; j <= m; ++j) dp[0][j] = 1;

  for (int i = 1; i <= n; ++i)
  for (int j = 1; j <= m; ++j) {
    dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + mod) % mod;

    if (a[i] == b[j]) {
      dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % mod;
    }
  }
  cout << dp[n][m];
return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	int memo = 0;//区間の最小
	int now = 0;
	int ans = 0;
	rep(i,n) {
		if(now <= h[i]){
			now = h[i];
			memo = min(memo,now);
		} else{
			ans += now - memo;
			memo = 200;
			now = h[i];
			memo = min(memo,now);
		}
	}
	ans += now - memo;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
#include <assert.h>
#include <complex.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define FILL(A,val) memset(A,val,sizeof(A))

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double Pi = acos(-1.0);
const int INF = 1000000000;
const Int INF2 = Int(INF) * 5000;
const Int INF3 = Int(INF) * INF;
const int MAX = 510007;
const int MAXE = 2007000;
const int MAXV = 5000;
const int BASE = 1000000000;
const int ST = 1000000007;

const int MOD = 1000000007;

int p = 1000003;

Int H[MAX];
int delta[MAX];


Int pw[MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    
    pw[0] = 1;
    FOR(i,1,MAX)
    {
        pw[i] = pw[i - 1] * p;
    }
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    H[0] = 0;
    delta[0] = n + 1;
    
    FOR(i,0,n)
    {
        H[i + 1] = H[i];
        delta[i + 1] += delta[i];
        
        if (s[i] == '<')
        {
            delta[i + 1] --;
        }
        if (s[i] == '>')
        {
            delta[i + 1] ++;
        }
        
        if (s[i] == '+')
        {
            H[i + 1] += pw[delta[i + 1]];
        }
        
        if (s[i] == '-')
        {
            H[i + 1] -= pw[delta[i + 1]];
        }
        
    }
    
    Int res = 0;
    
    map<Int, int> M;
    
    
    
    
    RFOR(i,n,0)
    {
        M[H[i + 1] * pw[n]] ++;
        Int h = H[n] * pw[delta[i] - delta[0] + n] + H[i] * pw[n];
        
        res += M[h];
    }
    
    cout << res << endl;
    
    
}



Measured memory_bytes: 39940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n << endl;
    } else {
        cout << 2 * n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll sum[123456];
class UF_pop {
public:
    int sz;
    vector<int> par,nrank; vector<vector<int> > hist;
    UF_pop(int node_size) : sz(node_size), par(sz), nrank(sz, 0){
        for(int i = 0; i < sz; i++){
            par[i] = i;
        }
    }
    void reinit(){
        for(int i = 0; i < sz; i++){
            nrank[i] = 0; par[i] = i;
        }
    }
    int find(int x){
        return (par[x] == x)?(x):find(par[x]);
    }
    void pop(){
        if(!hist.empty()){
            auto& a = hist.back();
            par[a[0]] = a[0], nrank[a[0]] = a[1], par[a[2]] = a[2];
            if(!same(a[0],a[2])){
                if(get_sum(a[0]) > get_sum(a[2])){
                    sum[find(a[0])] -= sum[find(a[2])];
                }else{
                    sum[find(a[2])] -= sum[find(a[0])];
                }
            }
            hist.pop_back();
        }
    }
    void unite(int x,int y) {
        x = find(x); y = find(y);
        hist.push_back({x,nrank[x],y});
        if(x == y) return;
        if(nrank[x] < nrank[y]){
            par[x] = y;
            sum[y] += sum[x];
        }else{
            nrank[x] += (nrank[x] == nrank[y]);
            par[y] = x;
            sum[x] += sum[y];
        }
    }
    ll get_sum(int x){
        x = find(x);
        return sum[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
struct edge{
    int a,b;
    ll c;
    edge(int a,int b,ll c): a(a),b(b),c(c){}
    bool operator<(const edge&x)const{
        return c < x.c;
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,n){
        cin >> sum[i];
    }
    vector<edge>vec;
    rep(i,m){
        int a,b;
        ll c;
        cin >>a >> b >> c;
        a--,b--;
        vec.emplace_back(a,b,c);
    }
    sort(vec.begin(),vec.end());
    UF_pop uf(n);
    for(auto &x:vec){
        uf.unite(x.a,x.b);
    }
    reverse(vec.begin(), vec.end());
    int ans = 0;
    for(auto &x:vec){
        ll cost = x.c;
        if(cost <= uf.get_sum(x.a)){
            uf.hist.pop_back();
        }else{
            ans++;
            uf.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9968