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

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

    int a[N];
    int min_count = 100;

    for(int i = 0; i < N; i++) {cin >> a[i];}
        
    for(int i = 0; i < N; i++) {    
        int count = 0;
        while(true) {
            if(a[i] % 2 == 1) {
                break;
            }
            ++count;
            a[i] /= 2;
        }

        if(min_count > count) {
            min_count = count;
        }
    }
    cout << min_count;



}

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


int N;
int c[MAXN],v[MAXN];
int ans;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}

	ans = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] - c[i] > 0) {
			ans += v[i] - c[i];
		}
	}

	cout <<ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = sc.nextInt();
        int max = 1;
        for (int i = sum / n + 1; i > 1; i--) {
            if (sum % i == 0 && sum / i >= n) {
                max = i;
                break;
            }
        }
        
        System.out.println(max);
    }
}

Measured memory_bytes: 23892
// #pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin >> arr[i];
	vector <int> ans(n,0);
	int x=0;
	for(int i=0;i<n;i++)
	{
		if(i&1)
			x-=arr[i];
		else
			x+=arr[i];
	}
	ans[1]=arr[0];
	ans[0]=x;
	for(int i=2;i<n;i++)
	{
		if(i&1)
			ans[i]=ans[i-1]+arr[i-1];
		else
			ans[i]=ans[i-1]-arr[i-1];
	}
	// for(int i=0;i<n;i++)
	// 	cout << ans[i] << " ";
	// cout << "\n";
 	vector <int> fans(n);
	fans[0]=x;
	for(int i=1;i<n;i++)
	{
		if(i&1)
			fans[i]=2*ans[i]-x;
		else
			fans[i]=ans[0]-2*ans[i];
	}
	for(int i=0;i<n;i++)
	{
		cout << fans[i] <<" ";
	}
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    // input
    static int n;
    static int[] c;
    static int[] v;

    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        v = new int[n];
        c = new int[n];
        for (int i=0;i<n;i++){
            v[i] = sc.nextInt();
        }
        for (int i=0;i<n;i++){
            c[i] = sc.nextInt();
        }
        sc.close();
    }
 
    /**
     * solver
     */
    static void solve(){
        int ans = 0;
        for(int i=0;i<n;i++){
            int s = v[i] - c[i];
            if (s > 0) {
                ans += s;
            }
        }
        System.out.println(ans);
    }

    public static void main(String args[]) {

        input();

        solve();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int a, b; cin >> a >> b;

    cout << max(a + b, max(a - b, a * b));

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if ( (a * b) % 2 == 0 ){
            System.out.println( "Even" );
        }else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 0
const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int MAXN = (int) 2e5;

char str[MAXN + 1];


int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n, a, b, c, d;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> a >> b >> c >> d;
    cin >> str + 1;

    auto solve = [&](int a, int b, vector <int> &vis) -> void {
        queue <int> Q;
        Q.push(a); vis[a] = 1;

        while(Q.size()) {
            int cur = Q.front();
            Q.pop();
            for(int i = 1; i <= 2; i++) {
                if(cur + i <= n && vis[cur + i] == 0 && str[cur + i] == '.') {
                    Q.push(cur + i);
                    vis[cur + i] = 1;
                }
            }
        }
    };

    vector <int> visa(n + 1), visb(n + 1);
    solve(a, c, visa);
    solve(b, d, visb);

    if(visa[c] == 0 || visb[d] == 0) {
        cout << "No";
        return 0;
    }

    if(c < d) {
        cout << "Yes";
        return 0;
    }

    for(i = 1; i <= d; i++) {
        if(visb[i] && i + 1 <= c) {
            if(visa[i - 1] && visa[i + 1]) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";

    return 0;
}



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

int main() {
  
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u){
    cout << a - 1 << " " << b << endl;
  }
  else{
    cout << a << " " << b - 1 << endl;
  }
  
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ld a, b;
	cin>>a>>b;
	cout<<fixed<<setprecision(12)<<ld(1)/(ld(1)/ld(a) + ld(1)/ld(b))<<'\n';
}


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

int main(){
	int n;
	scanf("%d", &n);
	if(n == 25){
		puts("Christmas");
	}else if(n == 24){
		puts("Christmas Eve");
	}else if(n == 23){
		puts("Christmas Eve Eve");
	}else if(n == 22){
		puts("Christmas Eve Eve Eve");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int a,b;
    cin>>a>>b;
    cout<<((a>b*2)? a-b*2: 0)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;
int d[3];
int main() {
	int N, M;
	cin >> N >> M;
	memset(d, -1, sizeof(d));
	for (int i = 0; i < M; i++) {
		int s, c;
		cin >> s >> c;
		s--;
		if (N > 1 && s == 0 && c == 0) {
			cout << -1 << endl;
			return 0;
		}
		if (d[s] != -1 && d[s] != c) {
			cout << -1 << endl;
			return 0;
		}
		d[s] = c;
	}
	for (int i = 0; i < N; i++) {
		if (d[i] == -1) {
			d[i] = 0;
			if (i == 0 && N > 1) d[i] = 1;
		}
	}
	for (int i = 0; i < N; i++) cout << d[i];
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;

int n;
ll k,a[N],f[N];

bool check(ll res)
{
    ll tmp=k;
    int pos=1,r=n;
    for(int i=1;i<=n;i++){
        if(a[i]*f[pos]>res){
            ll tmp1=res/f[pos];
            tmp-=(a[i]-tmp1);
			if(tmp<0)return false;
			if(tmp1==0)continue;
            pos++;
        } else pos++;
    }
    if(tmp<0)return false;
    else return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>f[i];
    sort(a+1,a+1+n,[](int x,int y){return x>y;});
    sort(f+1,f+1+n);
    ll l=0,r=1e18,ans=-1;
  //  cout<<check(0)<<endl;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        } else {
            l=mid+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
use std::collections::HashMap;

fn main() {
    let _ = read();
    let vec = read_line();
    
    let mut map : HashMap<i32, i32> = HashMap::new();

    for key in vec {
        if map.contains_key(&key) {
            let cnt = *map.get(&key).unwrap();
            map.insert(key, cnt + 1);
        } else {
            map.insert(key, 1);
        }
    }

    let mut cnt = 0;
    for (k, v) in map {
        if k > v {
            cnt += v;
        } else if k < v {
            cnt += v - k;
        }
    }

    println!("{}", cnt);
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v
}

Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int n,a[100000],G,F[31];
int main(){
	int res=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];res^=a[i];
		int R=a[i]^(a[i]-1);
		for(int j=1;j<31;j++){
			if(R==(1<<j)-1)F[j-1]++;
		}
	}
	int cnt=0;
	for(int i=29;i>=0;i--){
		if(res>=(1<<i)){
			if(F[i]==0){cout<<"-1"<<endl;return 0;}
			res^=(1<<(i+1))-1;
			cnt++;
		}
	}
	if(res==0)cout<<cnt<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <limits>
#include <ctype.h> 
#include <stdio.h> 
#include <set> 
#include <iomanip>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '


int main() {
    long long n = 0;
    cin >> n;
    long long b = 1;
    while(b*2 <= n){
        b*=2;
    }
    cout << 2*b-1 << endl;
    

    return 0;
} 


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B;

  std::cin >> N >> A >> B;

  std::cout << std::min(A * N, B) << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
max_revenue = -1000000000
min_price = 1000000000
min_price = int(input())
for _ in range(n-1):
    price = int(input())
    if max_revenue < price - min_price: max_revenue = price - min_price
    if min_price > price: min_price = price
print(max_revenue)


Measured memory_bytes: 5612
import sys
range = xrange
input = raw_input

class segtree:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m < n:
            m *= 2
        self.m = m
        self.data = [0]*(m + m)
        self.data[m: m + n] = data
        for i in reversed(range(1, m)):
            self.data[i] = max(self.data[2*i], self.data[2*i + 1])

    def setter(self, i, val):
        i += self.m
        while i:
            self.data[i] = val
            val = max(val, self.data[i ^ 1])
            i >>= 1

    def maxer(self, l, r):
        l += self.m
        r += self.m
        maxi = 0
        while l < r:
            if l & 1:
                maxi = max(maxi, self.data[l])
                l -= 1
            if r & 1:
                r -= 1
                maxi = max(maxi, self.data[r])
            l >>= 1
            r >>= 1
        return maxi

inp = [int(x) for x in sys.stdin.read().split()]
ii = 0

n = inp[ii]; ii += 1

X = inp[ii + 0: ii + 2 * n: 2]
D = inp[ii + 1: ii + 2 * n: 2]

order = sorted(range(n), key = X.__getitem__)

X = [X[i] for i in order]
D = [D[i] for i in order]

MOD = 998244353
ways = [0]*(n + 1)
ways[-1] = 1

seg = segtree(list(range(n)))
for i in reversed(range(n)):
    a = i
    b = n - 1
    while a < b:
        c = a + b + 1 >> 1
        if X[c] < X[i] + D[i]:
            a = c
        else:
            b = c - 1
    reach = seg.maxer(i, a + 1)
    seg.setter(i, reach)

    ways[i] = (ways[i + 1] + ways[reach + 1]) % MOD

print ways[0]


Measured memory_bytes: 92472
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 110;
const int maxk = 100100;
const ll mod = 1LL * 1e9 + 7;
ll dp[maxn][maxk];
ll pref[maxn][maxk];
ll n, k, arr[maxn];

ll get_sum(int d, int l, int r) {
    if(l < 0) l = 0;

    if(l == 0) {
        return pref[d][r]%mod;
    }
    else {
        return (pref[d][r] + mod - pref[d][l-1])%mod;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
    }

    dp[0][0] = 1LL;
    pref[0][0] = 1LL;
    for(int i=1;i<=k;i++) {
        pref[0][i] = pref[0][i-1];
    }
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=k;j++) {
            dp[i][j] = get_sum(i-1, j-arr[i], j);
            if(j > 0)
                pref[i][j] = pref[i][j-1];
            pref[i][j] += dp[i][j];
            pref[i][j] %= mod;
            dp[i][j] %= mod;
        }
    }

    cout<<dp[n][k]<<"\n";
    return 0;
}


Measured memory_bytes: 160000
from bisect import bisect_left

n = int(input())
lengths = sorted(map(int, input().split()))

res = 0
for i in range(n):
	l1 = lengths[i]
	for j in range(i + 1, n - 1):
		l2 = lengths[j]
		res += bisect_left(lengths, l1 + l2, j + 1) - j - 1

print(res)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String a = in.next(), b = in.next();
		
		if(a.length() == b.length()){
			boolean equal = true;
			for(int i = 0; i < a.length(); i++){
				if(a.charAt(i) > b.charAt(i)){
					System.out.println("GREATER");
					equal = false;
					break;
				}else if(a.charAt(i) < b.charAt(i)){
					System.out.println("LESS");
					equal = false;
					break;
				}
			}
			if(equal){
				System.out.println("EQUAL");
			}
		}else{
			System.out.println(a.length() > b.length() ? "GREATER" : "LESS");
		}
	}
}

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

using namespace std;

int main(){
 string s,t;
  cin >> s >>t;
 vector<int> trans(26,0);
 for(int i=0;i<s.length();i++){
  if(!trans[s[i]-'a']) trans[s[i]-'a']=t[i]-'a';
  else { if(trans[s[i]-'a']!=t[i]-'a'){
    cout << "No" << endl;
    return 0;
  }
  }
 }
  
  vector<int> inv(26,0);
  
  for(int i=0;i<t.length();i++){
  if(!inv[t[i]-'a']) inv[t[i]-'a']=s[i]-'a';
  else { if(inv[t[i]-'a']!=s[i]-'a'){
    cout << "No" << endl;
    return 0;
  }
  }
 }
  
  cout << "Yes" << endl;
 }

Measured memory_bytes: 776
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/



void Main()
{
	string S;
	cin >> S;
	int n = S.size();
	string ans = "Yes"; 
	rep(i,n){
		if((i%2 == 0 && S.at(i)!='L')||(i%2 ==1 && S.at(i)!='R'))
			continue;
		ans = "No";
	}
	cout<<ans <<endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

Measured memory_bytes: 256
A,B,C = map(int,input().split( ))
k = int(input())


lis = [A,B,C]
max_num = max(A,B,C)

lis.remove(max_num)

rui = 2 ** k

nibai = max_num * rui


a = lis[0]
b = lis[1]
print(a + b + nibai)


Measured memory_bytes: 38512
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,cnt=0,x;
  cin >> n;
  for(int i=n; i<=1000000; i++) {
    x=i,cnt=0;
    for(int j=2; j*j<=x; j++) {
      if(x%j==0) {
        cnt++;
      }
    }
    if(cnt==0) {
      cout << i << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 256
#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################

#####ide_ele#####
ide_ele = 0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
dp=[0]*(300030)
seg=SegTree(dp,segfunc,ide_ele)
for x in a:
    l=max(0,x-k)
    r=min(x+k,300005)
    dp[x]=seg.query(l,r+1)+1
    seg.update(x,dp[x])
print(max(dp))





Measured memory_bytes: 105064
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
num = 0

for a in range(1, n+1):
    for b in range(1, n+1):
        for c in range(1, n+1):
            num += gcd(a, b, c)

print(num)


Measured memory_bytes: 69844
#include<stdio.h>
int main()
{
    int n,c=0,i,j,m=0;
    scanf("%d",&n);
    for(i=105; i<=n; i+=2)
    {
        c=0;
        for(j=1; j<=i; j++)
        {
            if(i%j==0)
            {
                c++;
            }
        }
        if(c==8)
        {
            m++;
        }

    }
    printf("%d\n",m);

}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	if (s == t)
	{
		println("H");
	}
	else
	{
		println("D");
	}
}


Measured memory_bytes: 3560
using System;
using System.Linq;

namespace DRainFlowsIntoDams
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var n = int.Parse(Console.ReadLine());
            var impoundments = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var rainfalls = new int[n];

            rainfalls[0] = impoundments.Select((x, i) => i % 2 == 0 ? x : -x).Sum();
            for (var i = 1; i < n; i++)
            {
                rainfalls[i] = (impoundments[i - 1] - rainfalls[i - 1] / 2) * 2;
            }

            // 解答の出力
            Console.WriteLine(string.Join(" ", rainfalls));
        }
    }
}


Measured memory_bytes: 33372
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] ch=sc.next().toCharArray();
    if(ch[0]=='9'||ch[1]=='9'){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21972
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int MOD = 1000000000 + 7;
constexpr int arithmeticSeries(int n, int a1, int d) {
    return n * (2 * a1 + (n - 1) * d) / 2;
}

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

    int n, k;
    cin >> n >> k;

    // 0からNまでの和は10^100より小さい。
    // よってK個の和はかならずK+1個の和より小さい。
    // K個選ぶときの場合の数とK+1個選ぶときの場合の数は独立。
    // K個の和は(0からK-1までの和)から(n-kからnまでの和)の範囲内の整数をとる

    int ans = 0;

    for (int i = k; i <= n + 1; i++) {
        const int min_sum = arithmeticSeries(i, 0, 1);
        const int max_sum = arithmeticSeries(i, n, -1);
        const int ways = max_sum - min_sum + 1;

        (ans += ways) %= MOD;
    }

    cout << ans << endl;
}


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

int main(){
	int m,n,x,y,maxx=-999999999,tmp,minn=999999999;
	cin>>m>>n>>x>>y;
	for(int i=1;i<=m;++i){
		cin>>tmp;
		if(maxx<tmp)	maxx=tmp;
	}
	for(int i=1;i<=n;++i){
		cin>>tmp;
		if(minn>tmp)	minn=tmp;
	}
	for(int i=x+1;i<=y;++i)
		if(i>maxx && i<=minn){
			cout<<"No War";
			return 0;
		}	
	cout<<"War";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        //List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
        //List<int> values = new List<int>();

        string input = Console.ReadLine();
        int n = int.Parse(input.Split(' ')[0]);
        int m = int.Parse(input.Split(' ')[1]);
        int k = int.Parse(input.Split(' ')[2]);




        Console.WriteLine(n*m/2);
        
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, a; cin >> n >> a;
    vi x(n+1), y(n+1);

    ll maxA = a;
    repf(i, n){
        cin >> x[i];
        y[i] = x[i]-a;
        chmax(maxA, x[i]);
    }

    // y1...ynから任意の枚数選んで合計が0になる組み合わせを数える
    // dp[i][j]; y1..yiから0枚以上選んだ合計がj-n*maxAとなるような選び方
    ll sizeSum = 2*n*maxA+1;
    vvi dp(n+1, vi(sizeSum));
    dp[0][n*maxA] = 1;

    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=sizeSum; j++){
            if(j-y[i]<0 || j-y[i]>2*n*maxA) dp[i][j] = dp[i-1][j];
            else dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i]];
        }
    }
    cout << dp[n][n*maxA]-1 << endl;
}

Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    scanf("%d",&n);
    int tmp;
    map<int,int> mp;
    while(n--){
        scanf("%d",&tmp);
        mp[tmp]++;
    }
    int result = 0;
    for(auto &x:mp){
        result+=x.second%2;
    }
    printf("%d\n",result);
    return 0;
}

Measured memory_bytes: 4992
#define DEBUG 0

/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 3/16/2019, 8:47:07 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
const ll M = 1000000007;

ll N;
string S;
ll cnt[26];

int main()
{
  cin >> N >> S;
  fill(cnt, cnt + 26, 1);
  for (auto x : S)
  {
    cnt[x - 'a']++;
  }
  ll ans = 1;
  for (auto i = 0; i < 26; i++)
  {
    ans *= cnt[i];
    ans %= M;
  }
  ans += M - 1;
  ans %= M;
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    string pre,ans;
    cin >> pre;
    if(pre == "ABC"){
        ans = "ARC";
    } else {
        ans = "ABC";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int solve(vector<ll> a, string s) {
  int n = a.size();
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) continue;
    if (s[i] == '1') {
      return 1;
    }
    ll bit = a[i] & ~(a[i] - 1);
    for (int j = 0; j < i; j++) {
      if (a[j] & bit) {
        a[j] ^= a[i];
      }
    }
  }
  return 0;
}

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  scanf("%*d");
  int n;
  while (scanf("%d", &n) == 1) {
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
    }
    char s[300];
    scanf("%s", s);
    printf("%d\n", solve(a, s));

  }

  return 0;
}


Measured memory_bytes: 3728
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        for (int i = a.Length - 1; i >= 1; i--)
        {
            Console.Write(a[i] + " ");
        }

        Console.WriteLine(a[0]);
    }
}


Measured memory_bytes: 18312
#include<bits/stdc++.h> 
using namespace std; 
#define y second
#define x first  
typedef long long ll ; 
typedef unsigned long long ull; 
 
int main(int argc, char const *argv[])
{
	int n ; 
	cin >> n; 
	ll a[n]; 
	ll p;
	ll ans = 0;  
	for(int i = 0; i<n; cin >> p, ans^=p, ++i);

	if(!ans) cout << "Yes"; 
	else cout << "No"; 


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	string s;
	cin >> s;
	int sz = s.size() - 2;
	char a = s[0], b = s.back();
	cout << a << sz << b << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace  std;
vector<int>vc;
const int N=1e5+2;
bool p[N];
void prime(){

p[0]=false;p[1]=false;
    memset(p,true,sizeof(p));
    for(int i=2;i*i<=N;i++){
        if(p[i]==true){
            for(int j=i*i;j<=N;j+=i)
            {
            p[j]=false;

            }
        }
    }
for(int i=2;i<=N;i++){

    if(p[i]==true){

    vc.push_back(i);

}
}



}


int main() {

prime();
//for(auto x: vc)cout<<x;

int q;
cin>>q;
for(int i=0;i<q;i++){

    int x,y;
    int counter=0;
    cin>>x>>y;
    for(int j=0;j<vc.size();j++){

        if(vc[j]%2!=0&&vc[j]>=x && vc[j]<=y && p[(vc[j]+1)/2]==true){ counter++;}

    }
    cout<<counter<<endl;




}

}








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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(n + 1, vector<int>(3));
    for (int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    vector<vector<int>> dp(n + 1, vector<int>(3)); // dp[i][j]: i-1日目に行動jを選択した場合のi日目の幸福度の最大値
    // DP遷移式
    // dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]) (ただしk!=j)
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
                }
            }
        }
    }
    int ans = 0;
    for (int j = 0; j < 3; j++) {
        ans = max(ans, dp[n][j]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
    
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
//using ll = long long;
    
int main(){
    int k;
    cin>>k;

    int a,b;
    cin>>a>>b;

    rep(i,1000){
        if(a <= k*i and k*i <=b){
            printf("OK");
            exit(0);
        }
    }
    printf("NG");

} // end of main
    
//実行は、Opt + Ctl + N


//pythonの入力
//s, w = map(int, input().split())


Measured memory_bytes: 3660
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)2e5 + 228;

using namespace std;

bitset < N > b;
vector < int > g[N];
int n, w, h;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	b[1] = 1;
	scanf("%d%d%d", &h, &w, &n);
	forn(i, n)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].pb(y);
	}
	for (int i = 2; i <= h; i++)
	{	
		for (auto it : g[i])
		{	
			if (b[it])
			{
				cout << i - 1 << endl;
				return 0;
			}
		}
		b |= b << 1;
		for (auto it : g[i])	
			b[it] = false;	
	}
	cout << h << endl;
	
	return 0;
}



Measured memory_bytes: 11264
#include <iostream>
#include <string>


using namespace std;

int main(){
    
    string a,b;
    cin >> a>>b;
    
    if(a == b){
    cout << "=";
    }else if(a < b){
        cout << "<";
    }else {
    cout << ">";
    }
    
  /*int a,b,c;
    cin >> a>>b>> c;
    if(a*b < c){
    cout << a*b;
    }else {
    cout << c;
    }*/
    
return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') ans++;
        if (s[i] == '-') ans--;
    }
    cout << ans << endl;
}


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

struct state{
  int bi,a,b;
  bool operator<(const state& s) const {
    if( bi == s.bi ){
      if( a == s.a ) return b < s.b;
      return a < s.a;
    }
    return bi < s.bi;
  }
};

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


map<state,int> dp;
char cie[55][55];
int fie[55][55];
int N,W,H;
bool check( int bi,int x,int y,int d,int &nst,int &nx,int &ny ){
  bool f = false;
  nst = bi;
  nx = x + dx[d];
  ny = y + dy[d];  
  if( nx < 0 || nx >= W || ny < 0 || ny >= H ) return false;
  if( cie[nx][ny] == 'X' && !(nst & (1<<fie[nx][ny])) ){
    f = true;      
    nst |= (1<<fie[nx][ny]);
  }

  while( f ){
    nx = nx + dx[d];
    ny = ny + dy[d];  
    if( ny > H-1 || ( ny == H-1 && 0 <= nx && nx < W ) ) return true;
    if( nx < 0 || nx >= W || ny < 0 ) return false;
    if( cie[nx][ny] == 'X' && !(nst & (1<<fie[nx][ny])) ){
      nst |= (1<<fie[nx][ny]);
    } else
      break;
  }
  return f;
}

int solve(int bi,int x,int y){
  if( dp.find((state){bi,x,y}) != dp.end() ) return dp[(state){bi,x,y}];
  // cout << bitset<20>(bi) << " "<< x << " "<< y << endl;
  if( y > H-1 || ( y == H-1 && 0 <= x && x < W ) ) return dp[(state){bi,x,y}] = 0;
  int ret = (1<<29);
  for(int i=0;i<8;i++){
    int nx,ny,nst;
    if( check(bi,x,y,i,nst,nx,ny) ){
      ret = min( ret, solve(nst,nx,ny)+1);
    }
  }
  return dp[(state){bi,x,y}] = ret;
}

int main(){
  N = 0;
  W=15;H=19;
  int x,y;
  for(int i=0;i<19;i++){
    for(int j=0;j<15;j++){
      cin >> cie[j][i];
      if( cie[j][i] == 'X')
	fie[j][i] = N++;
      if( cie[j][i] == 'O' ){
	x = j; y = i;
      }	
    }
  }
  int res = solve(0,x,y);
  if( res == (1<<29) )
    cout << -1 << endl;
  else 
    cout << res << endl;
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL n;
	cin>>n;
	n--;
	LL pro = 26;
	LL cnt = 1;
	while(n >= pro){
		n -= pro;
		pro *= 26;
		cnt++;
	}
	std::vector<char> ans;
	pro = 26;
	rep(i,0,cnt){
		char c = (n % 26) + 'a';
		n /= 26;
		ans.PB(c);
	}
	reverse(ALL(ans));
	for(auto c : ans)
		cout<<c;
  	return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll w = in(), h = in(), x = in(), y = in();
    SETP(20);
    cout << w * h / 2.0 << ' ' << (x * 2 == w && y * 2 == h) << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	H, W, N := getInt(), getInt(), getInt()
	sr, sc := getInt(), getInt()

	S, T := getString(), getString()

	// 先手はLのみ、後手はRのみ
	pos := sc
	for i := 0; i < N; i++ {
		//out(pos, string(S[i]), string(T[i]))
		if S[i] == 'L' {
			pos--
		}
		if pos == 0 {
			out("NO")
			return
		}
		if T[i] == 'R' {
			pos++
			if pos > W {
				pos = W
			}
		}
	}
	// 先手はRのみ、後手はLのみ
	pos = sc
	for i := 0; i < N; i++ {
		//out(pos, string(S[i]), string(T[i]))
		if S[i] == 'R' {
			pos++
		}
		if pos == W+1 {
			out("NO")
			return
		}
		if T[i] == 'L' {
			pos--
			if pos == 0 {
				pos = 1
			}
		}
	}
	// DU
	pos = sr
	for i := 0; i < N; i++ {
		if S[i] == 'U' {
			pos--
		}
		if pos == 0 {
			out("NO")
			return
		}
		if T[i] == 'D' {
			pos++
			if pos > H {
				pos = H
			}
		}
	}

	// UD
	pos = sr
	for i := 0; i < N; i++ {
		if S[i] == 'D' {
			pos++
		}
		if pos == H+1 {
			out("NO")
			return
		}
		if T[i] == 'U' {
			pos--
			if pos == 0 {
				pos = 1
			}
		}
	}

	out("YES")
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;

signed main() {
	string S;
	cin >> S;
	int A1 = 0;
	int A2 = 0;
	for(int i = 0;i < S.size();i++) {
		if(S.at(i) == '0') {
			A1++;
		}
		if(S.at(i) == '1') {
			A2++;
		}
	}
	cout << min(A1,A2) * 2 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)

#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal var
//------------------------------------------
const int MAX = 2*10e5+2;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N,M;
  while(cin >> N >> M){
    int ans=0;
    vector <tuple<str,int,int>> ress;
    vector <int> k(M);
    vector <vector <int>> ss(M);
    vector<int> p(M);
    REP(i,M){
      cin >> k[i];
      REP(j,k[i]){
        int s;
        cin >> s;
        s--;
        ss[i].PB(s);
      }
    }
    REP(i,M){
      cin >> p[i];
    }
    int swi = N;
    vector<int > pow2(N+1);
    pow2[0]=1;
    REP(i,N){
      pow2[i+1] = pow2[i]*2;
    }
    REP(i,pow(2,N)){
      int lit=0;
      REP(k,M){
        int cnt=0;
        EACH(j,ss[k]){
          if((i&(pow2[*j]))==pow2[*j]) {
            cnt++;
          }
        }
        if((cnt%2==p[k]))lit++; 
      }
      if(lit==M) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(j) for j in input().split()]
mod=10**9+7
ans=1
from collections import Counter
c=Counter()
c[0]+=3
for i in a:
    ans*=c[i]
    if ans==0:
        break
    c[i]-=1
    c[i+1]+=1
    ans%=mod
print(ans)

Measured memory_bytes: 20000
n=int(input())
i=1
nn=n
while n>0:
    n-=26**i
    i+=1
k=i-1
n+=26**(i-1)
n-=1
s=[]
for j in range(k):
    k1=n//26**(k-j-1)
    n=n%26**(k-j-1)
    s.append(chr(k1+97))
for i in s:
    print(i,end='')

Measured memory_bytes: 9080
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, _q, op, t, x;
    scanf("%d %d", &n, &_q);
    vector<priority_queue<int> > pq(n);
    while (_q--) {
        scanf("%d %d", &op, &t);
        if (op == 0) {
            scanf("%d", &x);
            pq[t].emplace(x);
        } else if (op == 1) {
            if (!pq[t].empty()) printf("%d\n", pq[t].top());
        } else {
            if (!pq[t].empty()) pq[t].pop();
        }
    }
    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int ans[n];
  int status = 0;
  int r = 0;
  for(int i = 0; i < n; i++){
    if(status == 0){
      if(s[i] == 'R'){
        ans[i] = 0;
        r++;
      }
      else{
        if(r%2 == 0) {ans[i] = r/2; ans[i-1] = r/2;}
        else {ans[i] = (r-1)/2; ans[i-1] = (r+1)/2;}
        status = 1;
        r = 1;
      }
    }
    else/*status==1*/{
      if(s[i] == 'L'){
        ans[i] = 0;
        r++;
      }
      else{
        if(r%2 == 0) {ans[i-r-1] += r/2; ans[i-r] += r/2;}
        else {ans[i-r-1] += (r-1)/2; ans[i-r] += (r+1)/2;}
        ans[i] = 0;
        status = 0;
        r = 1;
      }
    }
  }

  if(r > 1){
    if(r%2 == 0) {ans[n-r-1] += r/2; ans[n-r] += r/2;}
    else {ans[n-r-1] += (r-1)/2; ans[n-r] += (r+1)/2;}
  }
  else ans[n-1] ++;

  for(int i = 0; i < n-1; i++)
    cout << ans[i] << " ";
  cout << ans[n-1] <<endl;
  return 0;
}


Measured memory_bytes: 1088
#define MOD 1000000007
#define PI 3.14159265358979323846
#define inf 100000000000000
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
//#define int long long
#define _ <<" "<<
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
#define int long long

int dp[1009][100009];

int h[1009];
int s[1009];
signed main() {
 
   
    
    ios::sync_with_stdio(0); cin.tie(0);
    cout.tie(0);
    //freopen("test.txt" ,"r", stdin);
    double n;cin>>n;

    double tmp = (int )n/2;

    double odd = n - tmp;
    //cout<<odd;
    cout<<setprecision(10)<<( odd / n);

 
}

Measured memory_bytes: 256