akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (x, y, z) = readIntegerList()
    println("$z $x $y")
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

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

    ll ans = b/x - a/x;
    if((a % x) == 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
 
 
int n, M, powers[5005];
ll dist[5005], arr[5005][205], ans[5005], best_coupon[202], sparse[202][20][5005];
 
ll rmq(int j, int l, int r){
    int k = powers[r-l+1];
    return max(sparse[j][k][l], sparse[j][k][r-(1<<k)+1]);
}


void DnC(int l, int r, int optima_l, int optima_r){

    if(l > r)   return;

    int mid = (l+r)/2, optima_mid = -1;
    ans[mid] = -(ll)1e16;

    for(int j=1;j<=M;j++)
        best_coupon[j] = rmq(j, mid, max(optima_l, mid));

// cout<<"now at "<<l<<" "<<r<<" "<<optima_l<<" "<<optima_r<<endl;
// cout<<"best_coupon: ";for(int j=1;j<=M;j++) cout<<best_coupon[j]<<" ";cout<<endl;

    for(int k=max(optima_l, mid);k<=optima_r;k++){

        ll temp = -(dist[k]-dist[mid]);
        for(int j=1;j<=M;j++){
            best_coupon[j] = max(best_coupon[j], arr[k][j]);
            temp += best_coupon[j];
        }

        if(temp > ans[mid]){
            ans[mid] = temp;
            optima_mid = k;
        }
    }

// cout<<"for "<<l<<" "<<r<<" "<<optima_l<<" "<<optima_r<<" found "<<mid<<" "<<optima_mid<<endl;

    DnC(l, mid-1, optima_l, optima_mid);
    DnC(mid+1, r, optima_mid, optima_r);
}



int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //http://codeforces.com/blog/entry/49757?#comment-337424
 
    cin>>n>>M;
    dist[1] = 0;
    for(int i=2;i<=n;i++){
        cin>>dist[i];
        dist[i] += dist[i-1];
    }
 
    for(int i=2;i<=5000;i*=2)
        powers[i]++;
    for(int i=1;i<=5000;i++)
        powers[i] += powers[i-1];
 
    for(int i=1;i<=n;i++)
        for(int j=1;j<=M;j++){
            cin>>arr[i][j];
            sparse[j][0][i] = arr[i][j];
        }
 
    for(int j=1;j<=M;j++)
        for(int k=1;(1<<k)<=n;k++)
            for(int i=1;i+(1<<k)-1<=n;i++)
                sparse[j][k][i] = max(sparse[j][k-1][i], sparse[j][k-1][i+(1<<(k-1))]);

    //optimas are monotonous
    //if (i, j1) and (i+1, j2) are optimal solutions for i and i+1 respectively
    //then j2 >= j1

    DnC(1, n, 1, n);

// cout<<"ans: ";for(int i=1;i<=n;i++) cout<<ans[i]<<" ";cout<<endl;

    cout<<*max_element(ans+1, ans+n+1);
    return 0;
}



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

int main() {
  int N, A, B, P1, P2;
  cin >> N >> A >> B;
  P1 = N * A;
  P2 = B;
  if ( P1 <= P2 ) {
    cout << P1 << endl;
  }
  if ( P1 > P2 ) {
    cout << P2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long long sum;
	int n, p, even = 0, odd = 0;
	scanf("%d %d", &n, &p);
	for (int i = 0; i < n; i++)
	{
		int temp;
		scanf("%d", &temp);
		if (temp % 2 == 0)even++;
		else odd++;
	}
	long long r = pow(2, n);
	if (!odd)
	{
		if (p == 0)printf("%lld\n", r);
		else printf("0\n");
	}
	else
	{
		printf("%lld", r / 2);
	}
	return 0;
}

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

using namespace std;

typedef long double lduo;

struct Pos{
  int x;
  int y;
};

int const nmax = 8;
Pos v[nmax];
int pos[nmax];

lduo pathLength(Pos v1, Pos v2){
  return lduo(sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y)));
}

int main()
{
  int n;
  lduo ans = 0, pol = 1;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> v[i].x >> v[i].y;
    pos[i] = i;
  }
  for(int i = 1;i < n;i++){
    ans = ans + pathLength(v[i-1], v[i]);
  }
  while(next_permutation(pos, pos + n)){
    for(int i = 1;i < n;i++){
      ans = ans + pathLength(v[pos[i-1]], v[pos[i]]);
    }
    pol++;
  }
  cout <<setprecision(10) << (ans / pol);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef long int li;
typedef unsigned long long ull;

int main(int argc,char* argv[])
{
    string s;
    cin >> s;
    rep(i,12){
        cout<<s[i];
        if(i==3)cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n; cin >> n;
    map<string, int> m;
    char pre;
    bool flag = true;
    rep(i, n){
        string w; cin >> w;
        m[w]++;
        if(m[w] > 1 || (i != 0 && pre != w[0])) {
            flag = false;
            break;
        }
        pre = w[w.length() - 1];
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.insert(0, 0)
c = 0
z = 0
for i in range(n, -1, -1):
    if z >= a[i]:
        c += a[i]
        z = b[i]
    else:
        t = b[i]-(a[i]-z)
        if t > 0:
            c += a[i]
            z = t
        elif t <= 0:
            c += b[i]+z
            z = 0
print(c)

Measured memory_bytes: 18624
#include<iostream>
#include<string>
int main(){
    std::string s;
    std::cin>>s;
    int count=0;
    const int n=s.size();
    int a[n],b[n];//a存从第i位到最后一位这个数对2019的余数，b存10的n-i-1次方对2019的余数
    int c[2019]={0};//不同的余数出现的次数
    a[n-1]=s[n-1]-'0';//a【n-1】是s【n-1】转数字
    b[n-1]=1;//b【n-1】是10^0就是1
    int temp=1;//计算b中数值
    for(int i=1;i<n;++i){
        temp=(10*temp)%2019;
        b[n-i-1]=temp;
    }
    //计算a
    for(int i=n-2;i>=0;--i){
        a[i]=((s[i]-'0')*b[i]+a[i+1])%2019;
    }
    //从a到c
    for(int i=0;i<n;++i){
        c[a[i]]+=1;
    }
    count=c[0];
    for(int i=0;i<2019;++i){
        count+=((c[i]-1)*c[i]/2);
    }
    std::cout<<count<<std::endl;
    return 0;
}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  char s[n];
  scanf("%s", s);

  s[k - 1] += 32;

  cout << s << endl;
}


Measured memory_bytes: 256
s = input()
l = len(s)

a=0
b=0
a=sum(int(s[i]) for i in range(0,l,2))
b=sum(int(s[i]) for i in range(1,l,2)) 

print(int(min(abs(l/2+0.5-a)+b,abs(l/2-b)+a)))

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
struct node
{
    int type;
    long long val;
    bool operator<(const node &a) const
    {
        return val>a.val;
    }
};
vector<node> A,B,C,all,mixed;
int main()
{
    int x,y,a,b,c;
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    long long u;
    for(int i=1;i<=a;i++)
    {
        scanf("%lld",&u);
        node cur={1,u};
        A.push_back(cur);
        all.push_back(cur);
    }
    for(int i=1;i<=b;i++)
    {
        scanf("%lld",&u);
        node cur={2,u};
        B.push_back(cur);
        all.push_back(cur);
    }
    for(int i=1;i<=c;i++)
    {
        scanf("%lld",&u);
        node cur={0,u};
        C.push_back(cur);
        all.push_back(cur);
    }
    sort(all.begin(),all.end());
    int red=0,green=0;
    for(int i=0;i<x+y;i++)
    {
        if(all[i].type==1) red++;
        else if(all[i].type==2) green++;
    }
    long long ans=0;
    if(red<=x&&green<=y)
    {
        for(int i=0;i<x+y;i++)
            ans+=all[i].val;
    }
    else if(red>x)
    {
        sort(A.begin(),A.end());
        for(int i=0;i<b;i++) mixed.push_back(B[i]);
        for(int i=0;i<c;i++) mixed.push_back(C[i]);
        sort(mixed.begin(),mixed.end());
        for(int i=0;i<x;i++) ans+=A[i].val;
        for(int i=0;i<y;i++) ans+=mixed[i].val;
    }
    else if(green>y)
    {
        sort(B.begin(),B.end());
        for(int i=0;i<a;i++) mixed.push_back(A[i]);
        for(int i=0;i<c;i++) mixed.push_back(C[i]);
        sort(mixed.begin(),mixed.end());
        for(int i=0;i<x;i++) ans+=mixed[i].val;
        for(int i=0;i<y;i++) ans+=B[i].val;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 18908
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<LL,LL>;

int main(){
	int N;
	cin >> N;
	vector<string> A(N);
	rep(i,N) cin >> A[i];
	vector<P> B;
	rep(i,N){
		string s=A[i];
		LL num=0;
		rep(j,s.size()){
			if(s[j]=='.'){
				num=s.size()-(j+1);
				s.erase(j,1);
				break;
			}
		}
		reverse(s.begin(),s.end());
		LL b=0;
		rep(j,s.size()) b+=(s[j]-'0')*pow(10,j);
		B.emplace_back(P(b,num));
	}
	//rep(i,B.size()) cout << B[i] << endl;
	vector<vector<LL>> div(21);
	rep(i,B.size()){
		LL b=B[i].first, n=B[i].second;
		LL num_f=0, num_t=0;
		while(b%5==0){
			b/=5;
			num_f++;
		}
		while(b%2==0){
			b/=2;
			num_t++;
		}
		div[num_f-n+10].emplace_back(num_t-n);
	}
	LL ans=0;
	rep(i,21) sort(div[i].begin(),div[i].end());
	rep(i,21){
		rep(j,div[i].size()){
			if(i>=10 and div[i][j]>=0) ans--;
			LL n=div[i][j]*(-1);
			for(int k=20-i; k<21; k++){
				LL res=lower_bound(div[k].begin(),div[k].end(),n)-div[k].begin();
				ans+=div[k].size()-res;
			}
		}
	}
	cout << ans/2 << endl;

	return 0;
}

Measured memory_bytes: 16512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<vector>
#include<iostream>
#include<algorithm>
typedef long long ll;

using namespace std;

int main()
{
    ll s,c;
    scanf("%lld%lld",&s,&c);
    if(!s)
        printf("%lld\n",c/4);
    else
    {
        if(s>c/2)
            printf("%lld\n",c/2);
        else
            printf("%lld\n",s+(c-2*s)/4);
    }
    return 0;
}


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

using namespace std;

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

int N;
int a[200000];
int b[200000];

int main() {
    cin >> N;
    rep(i, N) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+N);
    rep(i, N) {
        if(a[i]<=b[N/2-1]) cout << b[N/2] << endl;
        else cout << b[N/2-1] << endl;
    }
}


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

using namespace std;

const int P = 1000000007;

map<pair<long long, long long>, int> dp;

int calc(long long u, long long v) {
	if(v < 0) {
		return 0;
	}
	if(v == 0) {
		return 1;
	}
	if(dp.count({ u, v })) {
		return dp[{ u, v }];
	}
	int ret = 0;
	ret = (ret + calc(u >> 1, v >> 1)) % P;
	ret = (ret + calc((u - 1) >> 1, (v - 1) >> 1)) % P;
	ret = (ret + calc((u - 1) >> 1, (v - 2) >> 1)) % P;
	return dp[{ u, v }] = ret;
}

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

	cout << calc(n, n) << '\n';

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] b = new int[n+1];
		b[0]=999999;
		b[n]=999999;
		
		for (int i=1;i<n;i++) {
			b[i]=sc.nextInt();
		}
		
		int sum = 0;
		for (int i=0;i<n;i++) {
			sum+=Math.min(b[i], b[i+1]);
		}
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 25300
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let (a, b) = scan!(usize, usize);
    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible")
    } else {
        println!("Impossible")
    }
}


Measured memory_bytes: 4352
import sys
dataset = []
lst = []
for line in sys.stdin:
	lst.append(line)
minilist = []
for i in range(0, len(lst)):
	if lst[i] == '\n':
		dataset.append(minilist)
		minilist = []
	else: minilist.append(lst[i])
dataset.append(minilist)

for i in range(0, len(dataset)):
	memo = []
	for j in range(0, 12):
		lst = []
		for k in range(0, 12):
			lst.append(True)
		memo.append(lst)
	cnt = 0
	for j in range(0, 12):
		for k in range(0, 12):
			if dataset[i][j][k] == '1' and memo[j][k]:
				queue = [[j, k]]
				while queue != []:
					now = queue.pop(0)
					if memo[now[0]][now[1]] and dataset[i][now[0]][now[1]]=='1':
						memo[now[0]][now[1]] = False
						for p in range(0, 2):
							nexth = now[0]-1+2*p
							nextw = now[1]-1+2*p
							if 0<=nexth and nexth<12:
								queue.append([nexth, now[1]])
							if 0<=nextw and nextw<12:
								queue.append([now[0], nextw])
				cnt += 1
	print cnt


Measured memory_bytes: 4692
import java.util.Scanner;

public class Main {

	static int y1,m1,d1,y2,m2,d2;
	static int[] years, month;
	static{
		years = new int[10000];
		for(int i = 0;i<10000;i++){
			if(i%400==0){
				years[i]=366;
			}
			else if(i%100==0){
				years[i]=365;
			}
			else if(i%4==0){
				years[i]=366;
			}
			else{
				years[i]=365;
			}
		}
		month=new int[13];
		for(int i = 1;i<=7;i++){
			if(i%2==0){
				if(i==2){
					month[i]=28;
				}
				else{
					month[i]=30;
				}
			}
			else{
				month[i]=31;
			}
		}
		for(int i= 8;i<13;i++){
			if(i%2==0){
				month[i]=31;
			}
			else{
				month[i]=30;
			}
		}
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			y1=cin.nextInt();
			m1=cin.nextInt();
			d1=cin.nextInt();
			y2=cin.nextInt();
			m2=cin.nextInt();
			d2=cin.nextInt();
			if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0){
				break;
			}
			if(y1>y2){
				swap();
			}
			else if(y1==y2){
				if(m1>m2){
					swap();
				}
				else if(m1==m2){
					if(d1>d2){
						swap();
					}
					else if(d1==d2){
						System.out.println(0);
						continue;
					}
				}
			}


			int ans=0;
			for(int i = y1+1;i<y2;i++){
				ans+= years[i];
			}
			if(y1!=y2){
				for(int i = m1+1;i<13;i++){
					if(i==2&&years[y1]==366){
						ans+=29;
					}
					else{
						ans+=month[i];
					}
				}
				for(int i = 1;i<m2;i++){
					if(i==2&&years[y2]==366){
						ans+=29;
					}
					else{
						ans+=month[i];
					}
				}
			}
			else if(y1==y2){
				for(int i = m1+1;i<m2;i++){
					if(i==2&&years[y2]==366){
						ans+=29;
					}
					else{
						ans+=month[i];
					}
				}
			}
			if(m1==m2&&y1==y2){
				ans+= d2-d1;
			}
			else{
				if(m1!=2){
					ans += month[m1]-d1;
				}
				else if(m1==2&&years[m1]==366){
					ans += 29-d1;
				}
				ans += d2;
			}
			System.out.println(ans);
		}
	}
	static void swap(){
		int tmp = y1;
		y1=y2;
		y2=tmp;

		tmp = m1;
		m1=m2;
		m2=tmp;

		tmp=d1;
		d1=d2;
		d2=tmp;
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

#define MAX 101
#define INF 1000000000
// 1:white , 2:gray , 3:black
int C[MAX][MAX];
int d[MAX], p[MAX], T[MAX];
int nm;


void init(void){
    for(int i = 0; i < nm; i++){
        d[i] = INF;
        p[i] = -1;
        T[i] = 0;
    }
}

int prim(void){
    int u = -1, sum = 0, min;
    init();

    d[0] = 0;

    while(1){
        min = INF;
        u = -1;
        for(int i = 0; i < nm; i++){
            if(T[i] != 2 && d[i] < min){
                min = d[i];
                u = i;
            }
        }

        if( u == -1) break;
        T[u] = 2;
        for(int v = 0; v < nm; v++){
            if(T[v] != 2 && C[u][v] != INF){
                if(d[v] > C[u][v]){
                    d[v] = C[u][v];
                    p[v] = u;
                    T[v] = 1;
                }
            }
        }
    }

    for(int i = 0; i < nm; i++){
            if(p[i] != -1)  
                sum += C[i][p[i]];
        }

    return sum;
}

int main(){
    scanf("%d", &nm);

    for(int i = 0; i < nm; i++){
        for(int j = 0; j < nm; j++){
            scanf("%d", &C[i][j]);
            if(C[i][j] == -1) 
                C[i][j] = INF;
        }
    }

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

    return 0;
}


Measured memory_bytes: 2108
#include <iostream>

using namespace std;

#define MAX 100000
int A[MAX];

int Partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for (int j = p; j < r; ++j)
	{
		if (A[j] <= x)
		{
			++i;
			int temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}
	int temp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = temp;

	return i + 1;
}

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

	int q = Partition(A, 0, n - 1);
	for (int i = 0; i < n; ++i)
	{
		if (i == q)
			cout << "[" << A[i] << "]" << " ";
		else
			cout << A[i] << (i == n - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 3472
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"1 3 2
" => r"Yes",

r"6 5 4
" => r"No",

r"2 2 2
" => r"Yes"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
        c: i32,
    }

    if a <= c && c <= b {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
var tab = {};
tab[0] = 1; tab[1] = 1; tab[2] = 2;

function af(n) {
  if (n in tab) return tab[n];
  tab[n] = af(n-1) + af(n-2) + af(n-3);
  return tab[n];
}

function solve(n) {
  return Math.ceil(af(n) / 10 / 365)
}

require("fs").readFileSync("/dev/stdin","utf-8").split("\n")
.forEach(function(x) {
  x = +x;
  if (x == 0) return;
  console.log(solve(x))
})

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	int total = 0;
	int s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		total += s;
		a[i] = s;
	}
	if (total % 10 != 0) {
		cout << total << '\n';
	} else {
		sort(a.begin(), a.end());
		for (int i : a) {
			if (i % 10 != 0) {
				cout << total-i << '\n';
				return 0;
			}
		}
		cout << 0 << '\n';
	}
	return 0;
}

Measured memory_bytes: 3612
f = input()
m=[0,0,0,0,0]
i =0
for k in f:
    if (k=="A" and "T") or (k=="T" and "A") or (k=="C" and "G") or (k=="G" and "C"):
        m[i]+=1
    elif m[i] != 0:
        i += 1
print(max(m))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, imos[MAX_N]{}, ans=0;
    cin >> n;
    imos[0]++;
    REP(i,n){
        int a, b;
        cin >> a >> b;
        imos[a]++;
        imos[b+1]--;
    }
    REP(i,n+2){
        imos[i+1] += imos[i];
    }
    REP(i,n+2){
        if(imos[i]>=i) ans = i-1;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

#define ZFor(i,n) for(int i=0;i<n;i++)
#define WFor(i,n) for(int i=1;i<=n;i++)
#define ZWFor(i,n) for(int i=0;i<=n;i++)
#define WZFor(i,n) for(int i=1;i<n;i++)
#define Max -2100000000
#define Min 2100000000
#define F first
#define S second
#define F1 first.first
#define F2 first.second
#define F3 second

typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;


int main(void){
	
	long long int c,s,nc,ans=0;
	
	scanf("%lld %lld",&s,&c);
	
	nc=c/2;
	
	
	ans=s-nc;
	
	if(ans<0){
		ans=s;
		nc-=s;
		if(nc%2!=0 && nc!=1) nc--;
		ans+=nc/2;
	}
	else{
		if(nc%2!=0 && nc!=1) nc--;
		ans=nc;
	}
	printf("%lld\n",ans);
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin k;

double sunuke(lin n)
{
    lin a = n;
    lin d = 0;
    while(a > 0)
    {
        d += a % 10;
        a /= 10;
    }

    return (double)n / (double)d;
}

int main(void)
{
    cin >> k;
    lin count = 0;

    rep(i, 9)
    {
        cout << (i + 1) << endl;
        count++;
        if(count == k)
            return 0;
    }

    lin m = 9;
    lin current = 19;
    double currentSunuke = sunuke(current);
    while(true)
    {
        lin next = current + (m + 1);
        double nextSunuke = sunuke(next);

        if(currentSunuke <= nextSunuke)
        {
            cout << current << endl;
            current = next;
            currentSunuke = nextSunuke;

            count++;
            if(count == k)
                return 0;
        }
        else
        {
            m = m * 10 + 9;
            current = (current / m) * (m + 1) + m;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

bool isOk(bool *isDisLike, int num) {
  while(num) {
    if(isDisLike[num % 10]) return false;
    num /= 10;
  }
  return true;
}

int main () {
  int N, K;
  scanf("%d %d", &N, &K);
  bool isDisLike[10] = {};
  for(int l = 0, dislike; l < K; l++) {
    scanf("%d", &dislike);
    isDisLike[dislike] = true;
  }
  
  for(int n = N;;n++) {
    if(isOk(isDisLike, n)) {
      printf("%d\n", n);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll M, K;

signed main(){
    cin >> M >> K;
    if((1 << M) <= K){
        PRINT("-1");
        return 0;
    }
    if(M == 0){
        cout << "0 0" << endl;
        return 0;
    }
    if(M == 1){
        if(K == 0) cout << "0 0 1 1" << endl;
        else PRINT("-1");
        return 0;
    }
    for(ll i = 0; i < (1 << M); i++){
        if(i == K) continue;
        cout << i << " ";
    }
    cout << K << " ";
    for(ll i = (1 << M) - 1; i >= 0; i--){
        if(i == K) continue;
        cout << i << " ";
    }
    cout << K << endl;
    return 0;
}

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

int main() {
    int a, b, ans;
    cin >> a >> b;
    a--;
    b--;
    ans = (b + a - 1) / a;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b)
    cout << "Draw" << endl;
  else if (a == 1)
    cout << "Alice" << endl;
  else if (b == 1)
    cout << "Bob" << endl;
  else
    cout << (a > b ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 256
n = int(input())
dl = list(map(int,input().split()))
if dl[0] != 0:
  print(0)
  exit()
d_dic = dict()
for d in dl:
  if d in d_dic:
    d_dic[d] += 1
  else:
    d_dic[d] = 1
l = max(d_dic.keys())
for i in range(l):
  if not i in d_dic:
    print(0)
    exit()
if d_dic[0] != 1:
  print(0)
  exit()
ans = 1
for i in range(l):
  ans *= d_dic[i]**d_dic[i+1]
  ans = ans%998244353
print(ans)

Measured memory_bytes: 19552
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

lint mypow(lint a, lint n){
    lint res = 1;
    lint base = a;
    while(n > 0){
        if (n%2) res = res*base;
        base = base*base;
        n = n/2;
    }
    return res;
}

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

    lint n; cin>>n;

    int len = 1;
    while (n > mypow(26, len)){
        n = n - mypow(26, len);
        len++;
    }

    n--;
    string ans;
    for (int i=0; i<len; ++i){
        ans.push_back(n%26 + 'a');
        n = n/26;
    }

    reverse(ans.begin(), ans.end());
    cout<<ans;


}


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
char chlit(char c){return c+32;}
char chbig(char c){return c-32;}

int main(){
  char a,b;cin >> a >> b;
  if(a == 'H'){
    if(b == 'H')cout << "H" << endl;
    else cout << "D" << endl;
  } else {
    if(b != 'H')cout << "H" << endl;
    else cout << "D" << endl;
  }
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 1};
int dy[] = {1, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int H, W;
char board[110][110];
ll dist[110][110][2];

int main() {
    cin >> H >> W;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> board[i][j];
        }
    }

    fill(dist[0][0], dist[H][0], LONGINF);
    dist[0][0][ board[0][0] == '#' ] = (board[0][0] == '#');

    queue< tuple<int, int, int> > que;
    que.emplace(0, 0, board[0][0] == '#');
    while(que.size()) {
        int x, y, p; tie(x, y, p) = que.front(); que.pop();
        for(int k=0; k<2; k++) {
            int nx = x + dx[k], ny = y + dy[k];
            if(nx >= H or ny >= W) continue;
            int nc = dist[x][y][p], np = p;
            if(p == 0 and board[nx][ny] == '#') {
                np = 1;
                nc++;
            }
            if(p == 1 and board[nx][ny] == '.') {
                np = 0;
            }
            if(dist[nx][ny][np] > nc) {
                dist[nx][ny][np] = nc;
                que.emplace(nx, ny, np);
            }
        }
    }

    ll ans = min(dist[H-1][W-1][0], dist[H-1][W-1][1]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  ll vx = x2 - x1, vy = y2 - y1;

  cout << x2 - vy << ' ' << y2 + vx << ' ' << x1 - vy << ' ' << y1 + vx << "\n";
  
  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
using namespace std;
#define X real()
#define Y imag()

const double EPS = 1e-10;

bool EQ(double a,double b){
  return fabs(a-b) < EPS;
}

typedef complex<double> Point;

namespace std {
  bool operator == (const Point &a, const Point &b) {
    return EQ(a.X, b.X) && EQ(a.Y, b.Y);
  }
  bool operator < (const Point &a, const Point &b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}
struct Segment {
  Point p1, p2;
  Segment(){};
Segment(Point p1, Point p2) : p1(p1), p2(p2) {};
};

typedef Segment Line;
double dot(Point a, Point b){
  return a.X * b.X + a.Y * b.Y;
}


Point project(Segment s, Point p) {
  double r = dot(p - s.p1, s.p2 - s.p1) / norm(s.p2 - s.p1);
  return s.p1 + (s.p2 - s.p1) * r;
}

Point reflect(Segment s, Point p) {
return p + (project(s, p) - p) * 2.0;
}

int main()
{
  Segment s;
  cin >> s.p1.real() >> s.p1.imag() >> s.p2.real() >> s.p2.imag();

  int q;

  cin >> q;
  Point p;
  for(int i=0;i<q;i++){
    cin >> p.X >> p.Y;
    Point p2 = reflect(s,p);
    //cout << p2.X << p2.Y << endl;

    printf("%.15f %.15f\n",p2.X,p2.Y);

  }

  return 0;
}

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

int main() {
  int a[10];
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  sort(a, a + 10);
  for (int i = 0; i < 3; i++) {
    cout << a[9 - i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
using namespace std;
const int NMAX = 100;

int main()
{
    int N, sum = 0, W[NMAX + 5], dif[NMAX + 5];
    cin >> N;
    for(int i = 0; i < N; ++i) { cin >> W[i]; sum += W[i]; }
    dif[0] = sum - 2*W[0];
    for(int i = 1; i < N; ++i) {
        dif[i] = dif[i-1] - 2*W[i];
    }
    //for(int i = 0; i < N; ++i) cout << dif[i] << " ";
    //cout << endl;
    for(int i = 0; i < N; ++i) dif[i] = abs(dif[i]);
    sort(dif, dif + N);
    cout << dif[0] << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const n = parseInt(input[0], 10);
    const a = input[1].split(' ').map(function(value) { return parseInt(value, 10); });
    
    const maxA = Math.max.apply(null, a);
    const minA = Math.min.apply(null, a);

    const ans = maxA - minA;

    console.log(ans);

    return 0;
}


Measured memory_bytes: 22084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  
  cin >> N;
  
  if(N % 1111 == 0)								cout << "Yes" << endl;
  else if(	(N - N / 1000 * 1000) % 111 == 0)	cout << "Yes" << endl;
  else if(	(N - N % 10) % 111 == 0)			cout << "Yes" << endl;
  else	cout << "No" << endl;
  
}

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

int F[102][102];

void
DFS (int Y, int X, int A)
{
  if (F[Y][X] != A)
    return;

  F[Y][X] = 7;

  DFS (Y - 1, X, A);
  DFS (Y, X + 1, A);
  DFS (Y + 1, X, A);
  DFS (Y, X - 1, A);
}

int
main ()
{
  int w, h;
  int xs, ys;
  int xg, yg;
  int n;
  int c, d, x, y;

  while (true)
    {
      cin >> w >> h;
      if (w == 0 && h == 0)
	break;
      cin >> xs >> ys;
      cin >> xg >> yg;
      cin >> n;

      for (int i = 0; i < n; i++)
	{
	  cin >> c >> d >> x >> y;
	  if (d == 0)
	    {
	      for (int a = 0; a < 4; a++)
		{
		  for (int b = 0; b < 2; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}

	    }
	  else
	    {
	      for (int a = 0; a < 2; a++)
		{
		  for (int b = 0; b < 4; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}
	    }

	}


      if (F[ys][xs] == 1 || F[ys][xs] == 2 || F[ys][xs] == 3
	  || F[ys][xs] == 4 || F[ys][xs] == 5)
	{
	  DFS (ys, xs, F[ys][xs]);
	}

      if (F[yg][xg] == 7)
	{
	  cout << "OK" << endl;
	}
      else
	{
	  cout << "NG" << endl;
	}
   
    /*for (int y = 0; y < h; y++)
	{
	  for (int x = 0; x < w; x++)
	    {
	      cout << F[y][x];
	    }
         cout << endl;
	}*/
   
    for (int y = 1; y <= h; y++)
	{
	  for (int x = 1; x <= w; x++)
	    {
	      F[y][x] = 0;
	    }
	}

    
   
    }

  return 0;
}

Measured memory_bytes: 3012
fun main() {
    val (A, B, C) = readLine()!!.split(" ").map { it.toInt() }
    val K = readLine()!!.toInt()

    for (i in 0..K) {
        for (j in 0..(K - i)) {
            for (k in 0..(K - i - j)) {
                val a = if (i > 0) A * Math.pow(2.toDouble(), i.toDouble()).toInt() else A
                val b = if (j > 0) B * Math.pow(2.toDouble(), j.toDouble()).toInt() else B
                val c = if (k > 0) C * Math.pow(2.toDouble(), k.toDouble()).toInt() else C
                if (b > a && c > b) {
                    print("Yes")
                    return
                }
            }
        }
    }
    print("No")
}


Measured memory_bytes: 36356
K=gets.chomp.to_i
A=[*1..K]
ans=0
A.repeated_combination(3) do |a,b,c|
    if a==b && b==c
        ans+=a.gcd(b).gcd(c)
    elsif a!=b && b!=c
        ans+=(a.gcd(b).gcd(c))*6
    else
        ans+=(a.gcd(b).gcd(c))*3
    end
end

puts ans

Measured memory_bytes: 14364
#!/usr/bin/env python3
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()


def per(n, r, mod=10**9+7):  # 順列数
    per = 1
    for i in range(r):
        per = per*(n-i) % mod
    return per


def com(n, r, mod=10**9+7):  # 組み合わせ数
    bunshi = per(n, r, mod)
    bunbo = 1
    for i in range(1, r+1):
        bunbo = bunbo*i % mod
    return bunshi*pow(bunbo, -1, mod) % mod


def main():
    n = list(map(int, list(input())))
    k = int(input())
    keta = len(n)
    count = [n[0]-1+com(keta-1, 1)*9, (n[0]-1)*com(keta-1, 1)*9+com(keta-1, 2)
             * 9**2, (n[0]-1)*com(keta-1, 2)*9**2+com(keta-1, 3)*9**3]
    nonzero = 1
    #print(count)
    for i in range(1, keta):
        if n[i] != 0:
            nonzero+=1
            if nonzero==2:
                count[1]+=(n[i]-1)+com(keta-i-1,1)*9
                count[2]+=(keta-i-1)*(n[i]-1)*9+com(keta-i-1,2)*9**2
            elif nonzero==3:
                count[2]+=(n[i]-1)+com(keta-i-1,1)*9
        #print(count)
    print(count[k-1]+(nonzero>=k))



if __name__ == '__main__':
    main()


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  vector<int> plus, minus;
  rep(i, n)
  {
    if(a[i] >= 0) plus.emplace_back(a[i]);
    else minus.emplace_back(a[i]);
  }
  sort(plus.begin(), plus.end(), greater<int>());
  sort(minus.begin(), minus.end());
  
  if(minus.empty()) minus.emplace_back(plus.back()), plus.pop_back();
  if(plus.empty()) plus.emplace_back(minus.back()), minus.pop_back();
  
  int cur = minus[0];
  vector<P> sousa;
  
  for(int i = 0; i < (int)(plus.size() - 1); i++)
  {
    sousa.emplace_back(P(cur, plus[i]));
    cur = cur - plus[i];
  }
  sousa.emplace_back(P(plus.back(), cur));
  cur = plus.back() - cur;
  
  for(int i = 1; i < minus.size(); i++)
  {
    sousa.emplace_back(P(cur, minus[i]));
    cur = cur - minus[i];
  }
  
  cout << cur << endl;
  for(auto x : sousa) cout << x.first << " " << x.second << "\n";
  
  return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a!=1&&b!=1)	cout << 1 << endl;
	if(a!=2&&b!=2)	cout << 2 << endl;
	if(a!=3&&b!=3)	cout << 3 << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int m=in();
	vector<int> p(m);
	vector<int> k(m);
	int x;
	for(int i=0;i<m;i++)
	{
		int k1=in();
		for(int j=0;j<k1;j++)
		{
			x=in();
			x--;
			k[i]|=(1<<x);
		}
	}
	trav(i,p)i=in();int ans=0;
	for(int mask=0;mask<(1<<n);mask++)
	{
		bool ok=1;
		for(int j=0;j<m;j++)
		{
			if(__builtin_popcountll(mask&k[j])%2==p[j])ok&=1;
			else ok&=0;
		}
		if(ok)ans++;
	}
	cout<<ans;
	
}

Measured memory_bytes: 3672
import java.io.*
import java.util.*

// N のうち K　のxを訪れる最小歩数
fun solve(N: Int, K: Int, x: IntArray) {
    if (K == 0) {
        println(0)
        return
    }
    val boundary = x.toList().lowerBound(0)
    val negatives = x.slice(0..boundary - 1).asReversed().map { -it.toLong() }
    val positives = x.slice(boundary until N).map { it.toLong() }
    // i だけ negativesからとる
    val INF = 1000000000000L
    var ans = Math.min(
            negatives.getOrElse(K - 1) { INF },
            positives.getOrElse(K - 1) { INF })
    for (i in 1 until K) {
        if (i - 1 >= negatives.size || K - i - 1 >= positives.size || K - i - 1 < 0) continue
        val step1 = 2 * negatives[i - 1] + positives[K - i - 1]
        val step2 = negatives[i - 1] + 2 * positives[K - i - 1]
        ans = Math.min(ans, Math.min(step1, step2))
    }
    println(ans)
    return
}


fun <T : Comparable<T>> List<T?>.lowerBound(
        element: T,
        fromIndex: Int = 0,
        toIndex: Int = size
): Int {
    var low = fromIndex
    var high = toIndex
    while (low < high) {
        val mid = (low + high) / 2
        if (element <= this.get(mid)!!) {
            high = mid
        } else {
            low = mid + 1
        }
    }
    return low
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }

    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }

    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val x = IntArray(N)
    for (i in 0 until N) {
        x[i] = sc.next().toInt()
    }
    solve(N, K, x)
}



Measured memory_bytes: 46384
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const ll INF = LLONG_MAX/3;

/*-----Library-----*/

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
//コンビネーション
/*
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 */
/*-----Library-----*/
const int MOD=1234567;
signed main(){
	int n;
	cin>>n;
	int a[210000];
	rep(i,n)cin>>a[i];
	int cnt=0;
	int c=1;
	rep(i,0,n){
		if(a[i]==c){
			cnt++;
			c++;
		}
	}
	if(cnt==0)cout<<-1<<endl;
	else cout<<n-cnt<<endl;
}


Measured memory_bytes: 1792
#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 fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
pair<long long,long long>brp[mx];
long long level[mx],n,m,u,v,s,harus;
bool ada,sudah[mx];
int stat[mx];
vector<pair<long long,long long>>g[mx];
void dfs(int now,int par,int lev){
	sudah[now]=true;
	stat[now]=1;
	level[now]=lev;
	for(auto i:g[now]){
		if(i.f==par)continue;
		if(stat[i.f]==0){
			brp[i.f].f=-brp[now].f;
			brp[i.f].s=i.s-brp[now].s;
			dfs(i.f,now,lev+1);
		}
		else if(stat[i.f]==1){
			pair<long long,long long>sem;
			sem.f=-brp[now].f;
			sem.s=i.s-brp[now].s;
			if((level[now]-level[i.f])%2==1){
				if(sem!=brp[i.f]){
					cout<<0<<endl;
					exit(0);
				}
			}
			else{
				auto sa=sem;
				auto du=brp[i.f];
				if(sa.f==-1)swap(sa,du);
				long long tot=du.s-sa.s;
				if(tot==0){
				//	debug(now);
				//	debug(i.f);
				}
				if(tot&1){
					cout<<0<<endl;
					exit(0);
				}
				tot/=2;
				if(!ada){
					harus=tot;
					ada=true;
				}
				else{
					if(harus!=tot){
						cout<<0<<endl;
						exit(0);
					}
				}
			}
		}
	}
	stat[now]=2;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v>>s;
		g[u].pb({v,s});
		g[v].pb({u,s});
	}
	brp[1]={1,0};
	dfs(1,0,0);
	if(ada){
//	debug(harus);
		for(int i=1;i<=n;i++){
			long long bil=brp[i].f*harus+brp[i].s;
			if(bil<=0){
				cout<<0<<endl;
				return 0;
			}
		}
		cout<<1<<endl;
		return 0;
	}
	long long kecil=1,besar=1e18;
	for(int i=1;i<=n;i++){
		if(brp[i].f==1){
			long long mini=-brp[i].s+1;
			kecil=max(kecil,mini);
	//		debug(i);
	//		debug(brp[i].s);
	//		debug(mini);
		}
		else{
			long long ini=brp[i].s-1;
			besar=min(besar,ini);
	//		debug(i);
	//		debug(ini);
		}
	}
	if(kecil>besar){
		cout<<0<<endl;
	}
	else cout<<besar-kecil+1<<endl;
//	debug(besar);
//	debug(kecil);
	
}




Measured memory_bytes: 18432
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
/*namespace*/
using namespace std;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M,0);
    REP(i,N){
        int K;
        cin>>K;
        REP(j,K){
            int P;//仮取得
            cin>>P;
            A[P-1]+=1;
        }
    }
    int count=0;//出力
    REP(i,M){
        if(A[i]==N){
            count+=1;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
using namespace std;
set<int> a;
int main(void)
{
    int n,v;
    bool flag=false;
    scanf("%d" ,&n);
    while(n--)
    {
        scanf("%d" ,&v);
        if(a.count(v)==1) {
            flag=true;
            break;
        }
        else a.insert(v);
    }
    if(flag==true)
        printf("NO");
    else printf("YES");
    return 0;
}


Measured memory_bytes: 9600
/*
 * @Author: Kaizyn
 * @Date: 2020-04-12 20:28:55
 * @LastEditTime: 2020-04-12 20:29:59
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 2e2+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n;

inline void solve()
{
    cin >> n;
    long long res = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                res += __gcd(__gcd(i, j), k);
            }
        }
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import math

H = int(input())
count = 0
atk = 0
for i in range(10 ** 12):
   
    if H == 1:
        for j in range(0,atk+1):
            count += 2 ** j
        break
    else:
        H = math.floor(H / 2)
        atk += 1

print(count) 

Measured memory_bytes: 8972