akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 2000

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N;
int sticks[MAX_N];
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> sticks[i];

    sort(sticks, sticks + N);

    int res = 0;
    for(int i = 0; i < N; ++i)
        for(int j = i + 1; j < N; ++j) {
            if(j == N - 1) continue;

            int min_c = sticks[j] - sticks[i];
            int max_c = sticks[i] + sticks[j];

            int lb_index = upper_bound(sticks, sticks + N, min_c) - sticks;
            int ub_index = lower_bound(sticks, sticks + N, max_c) - 1 - sticks;

            lb_index = max(lb_index, j + 1);
            res += max(0, ub_index - lb_index + 1);            
        }

    cout << res << endl;   
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll DivisorCount(ll x) {
	ll ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {
			cnt++;
			x /= i;
		}
		ans *= (cnt + 1);
		if (x == 1) break;
	}
	if (x != 1) ans *= 2;
	return ans;
}
ll Digit(ll x) {
	return log10(x) + 1;
}


void Main() {
	ll A;
	cin >> A;
	string B;
	cin >> B;
	rep(i, 0, B.size()) {
		if (B[i] == 46) {
			B.erase(B.begin() + i);
		}
	}
	ll ans = (A * stoi(B)) / 100;
	cout << ans << endl;
}

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

	Main();
	return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
using u32 = unsigned int; using u64 = unsigned long long int;
template <typename T> using vec = vector<T>;
void in() {}; template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); };
template <typename T> void _out(const char *sep, const char *end, T &&x) { cout << x << end; };
template <typename T, typename...TS> void _out(const char *sep, const char *end, T &&x, TS &&...xs) { cout << x << sep; _out(sep, end, move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define put(...) _out("", "", __VA_ARGS__)
#define out(...) _out(" ", "\n", __VA_ARGS__)
#define times(n, i) for (i32 i =  0 ; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i32 n;
vec<i32> a;

i32 main()
{
    ios::sync_with_stdio(false);

    in(n);
    times(n, ni) {
        a.append(get(i32));
    }
    sortall(a);
    i32 mina = a[0], maxa = a[n-1];
    if (mina - maxa > 1) {
        out("No");
        return 0;
    }

    if (maxa - mina == 1) {
        i32 lowc = 0;
        times(n, ni) lowc += (a[ni] == mina ? 1 : 0);
        i32 highc = n - lowc;

        if ((maxa - lowc) > 0 && highc / (maxa - lowc) >= 2) {
            out("Yes");
            return 0;
        }
    }
    else if (maxa == mina) {
        if (maxa == n - 1 || n / maxa >= 2) {
            out("Yes");
            return 0;
        }
    }

    out("No");
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	string S;
	cin >> S;

	auto dp = make_vec(N + 1, 4, 1000, char(0));//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1
	dp[0][0][0] = 1;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			for (Int k = 0; k < 100; k++) {
				if (dp[i][j][k] == 0) {
					continue;
				}
				//i文字目を選択する場合
				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = true;
			
				//i文字目を選択しない場合
				dp[i + 1][j][k] = true;
			}
		}
	}

	Int ans = 0;
	vector<char> seen(1000,0);
	for (Int i = 1; i <= N; i++) {
		for (Int k = 0; k < 1000; k++) {
			if (dp[i][3][k] != 0) {
				if (seen[k] != 0) {
					continue;
				}
				ans++;
				seen[k] = true;
			}
		}
	}
	cout << ans << "\n";

}


Measured memory_bytes: 122368
#include<stdio.h>
int main(){
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k<=a)
    printf("%d",k);
    else if(a<k && k<=(a+b))
    printf("%d",a);
    else
    {
        printf("%d",2*a+b-k);
    }
    
}

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

int main(){
    int a, b, c;
    int x, y, z;
    cin >> a >> b >> c;
    
    if(a <= b && a <= c){
        x = a;
        if (b <= c){
            y = b;
            z = c;
        } else {
            y = c;
            z = b;
        }
    } else if( b <= c){
        x = b;
        if (a <= c){
          y = a;
          z = c;
        } else {
          y = c;
          z = a;
        }
    } else {
        x = c;
        if (a <= b){
          y = a;
          z = b;
        } else {
          y = b;
          z = a;
        }
    }
    
    cout << x << " " << y << " " << z  << endl;
    return 0;
}



Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
namespace ITP1_4_B
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }

        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata ();

            int a;
            string op;
            int b;

            for (int i = 0; i < list_result.Count; i++){
                
                a = int.Parse(list_result[i][0]);
                op = list_result[i][1];
                b = int.Parse(list_result[i][2]);

                if (op == "?")
                {
                    break;
                }

                    switch (op)
                    {
                        case "+":

                            Console.WriteLine(a + b);
                            break;

                        case "-":

                            Console.WriteLine(a - b);
                            break;

                    case "*":
                        
                            Console.WriteLine(a * b);
                            break;
                        case "/":
                        
                            Console.WriteLine(a / b);
                            break;

                    }

            }

        }
    }
}

Measured memory_bytes: 9268
#include <stdio.h>
#include <stdlib.h>
#define N 5

int int_cmp(const int *a, const int *b)
{
  if (*a > *b)
    return (-1);
  else if (*a < *b)
    return (1);
  return (0);
}

int main(){
  int data[N];
  int i;
  for (i=0;i<N;i++)
    data[i]=0;
  scanf("%d %d %d %d %d",&data[0],&data[1],&data[2],&data[3],&data[4]);

  qsort(data,N,sizeof(data[0]),(int(*)(const void*, const void*))int_cmp);

  for(i=0;i<N-1;i++){
    printf("%d ",data[i]);
  }
  printf("%d\n",data[N-1]);

  return 0;
}

Measured memory_bytes: 600
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func main() {
	n := nextInt()
	a := make(map[int]struct{}, n)

	for i := 0; i < n; i++ {
		k := nextInt()
		if _, ok := a[k]; !ok {
			a[k] = struct{}{}
		} else {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

Measured memory_bytes: 7680
import Data.List
import Control.Monad

solve xs = loop xs' 
    where
        xs' = map (\y@(a:_) -> (a,length y)) $ group $ sort $ map f xs
        loop [] acc = acc
        loop ((x, y):xs) (a, b)
            | x == 'x' = loop xs (a, b + y) 
            | otherwise = loop xs (a + 1, b + 1) 
        f x  
            | x `elem` [1..399] = 'a'
            | x `elem` [400..799] = 'b'
            | x `elem` [800..1199] = 'c'
            | x `elem` [1200..1599] = 'd'
            | x `elem` [1600..1999] = 'e'
            | x `elem` [2000..2399] = 'f'
            | x `elem` [2400..2799] = 'g'
            | x `elem` [2800..3199] = 'h'
            | otherwise = 'x'

main = do
    n <- readLn :: IO Int
    xs <- map read . words <$> getLine :: IO [Int]
    let (a, b) = solve xs (0, 0)
    putStr $ show (max 1 a)
    putStr " "
    putStrLn $ show b

Measured memory_bytes: 1148
import itertools
d,c=map(int, input().split())
p=[list(map(int, input().split())) for i in range(d)]
al=list(itertools.product(range(2),repeat=d))
ans=1000
for i in al:
    count=0
    score=0
    if 0 not in i:continue
    last0=d-list(reversed(i)).index(0)-1
    for j in range(d):
        count+=i[j]*p[j][0]
        score+=i[j]*p[j][1]+i[j]*p[j][0]*(j+1)*100
    #print(count,score,last0,i)
    if score>=c:ans=min(ans,count)
    elif (c-score)/((last0+1)*100)<p[last0][0]:ans=min(ans,count+(c-score+last0*100)//((last0+1)*100))
if d==1:print(1)
else:print(ans)

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

int main(){
	int n;
	int k[10000];

	while(cin >> n, n){
		int ans = 0;
		bool isPossible = false;
		for(int i=0; i < n; i++){
			cin >> k[i];
			if(1 < k[i]) isPossible = true;
			if(0 < k[i]) ans++;
		}
		if(!isPossible) cout << "NA" << endl;
		else cout << ans + 1 << endl;
	}
}

Measured memory_bytes: 1200
import heapq
n, m = [int(i) for i in input().split()]

numbers = [int(i) * -1 for i in input().split()]
heapq.heapify(numbers)

for i in range(m):
    maxout = heapq.heappop(numbers)
    insnumber = -(-maxout//2)
    heapq.heappush(numbers, insnumber)

numbers = list(map(lambda x: x*-1, numbers))

print(sum(numbers))

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

typedef long long ll;

const ll maxn = 1e6 + 1e2;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
ll n, d[2];
ll dp[maxn][2];
ll sufsum[maxn][2];
ll val[maxn];

int main(){
	std::ios::sync_with_stdio(false);

	std::cin >> n >> d[0] >> d[1];

	for(ll i = 0; i < n; i++){
		std::cin >> val[i];
	}

	dp[n - 2][0] = dp[n - 2][1] = dp[n - 1][0] = dp[n - 1][1] = 1;
	sufsum[n - 1][0] = sufsum[n - 1][1] = 1;
	sufsum[n - 2][0] = sufsum[n - 2][1] = 2;
	
	ll farthest[] = {n, n};

	for(ll i = n - 3; i >= 0; i--){
		for(ll order = 0; order < 2; order++){
			ll& ans = dp[i][order];

			if(val[i + 2] - val[i] >= d[order]){
				ans += dp[i + 1][!order];
				ans %= mod;
			}

			if(val[i + 2] - val[i + 1] < d[0]){
				farthest[0] = i + 2;
			}
			if(val[i + 2] - val[i + 1] < d[1]){
				farthest[1] = i + 2;
			}

			ll smallestInd = std::max(i + 3, (ll) (std::lower_bound(val, val + n, d[order] + val[i]) - &val[0])) - 1;
			if(smallestInd < farthest[!order]){
				ans += sufsum[smallestInd][!order];
				ans -= sufsum[farthest[!order]][!order];
				ans += mod;
				ans %= mod;
			}

			sufsum[i][order] = (sufsum[i + 1][order] + dp[i][order]) % mod;
		}
	}

	ll res = 0;
	ll smallestDiff = INF;

	for(ll i = 0; i < n; i++){
		if(smallestDiff >= d[0]){
			res += dp[i][0];
		}
		if(smallestDiff >= d[1]){
			res += dp[i][1];
		}

		smallestDiff = std::min(smallestDiff, val[i + 1] - val[i]);
		res %= mod;
	}

	std::cout << res << '\n';
}


Measured memory_bytes: 9216
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
function lower_bound(d,e,a=0,b=d.length){for(var c;1<b-a;)d[c=a+b>>1]<e?a=c:b=c;return d[a]<e?b:a};

var x = xArray("[]",2e5+1);
var ans, dp;
var g, a;
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  a = nexts(n);
  g = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var u = next()-1, v = next()-1;
    g[u].push(v);
    g[v].push(u);
  }
  ans = xArray(0,n);
  dp = xArray(2e9,n+1);
  var iv = Array(n), ix = Array(n);
  dp[0] = 0;
  var q = [0,-1];
  while(q.length){
    var p = q.pop(), v = q.pop();
    q.push(~v);
    ix[v] = lower_bound(dp,a[v]), iv[v] = dp[ix[v]];
    dp[ix[v]] = a[v];
    ans[v] = lower_bound(dp,2e9)-1;
    for(var i = 0; i < g[v].length; i++){
      var V = g[v][i];
      if(V === p)continue;
      q.push(V,v);
    }
    while(q[q.length-1] < 0){
      var t = ~q.pop();
      dp[ix[t]] = iv[t];
    }
  }
  return ans.join("\n");
}

Measured memory_bytes: 166176
//
//  main.cpp
//  ITP1_10-A
//
//  Created by Saicj on 2015/08/05.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <math.h>
#include <cstdio>
#include <iomanip>

/**
 ?¨??????????
 ?????¢= sqrt( (x1-x2)^2 + (y1-y2)^2 )
 */

int main(int argc, const char * argv[]) {

    double p1X;
    double p1Y;
    
    double p2X;
    double p2Y;
    
    std::cin >> p1X >> p1Y >> p2X >> p2Y;
    
    double result = sqrt(pow(p1X - p2X, 2) + pow(p1Y - p2Y, 2));

    
    printf("%.10lf\n", result);
    
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>

using namespace std;

bool judge(char c){
    if(c=='A'||c=='C'||c=='G'||c=='T')return true;
    else return false;
}

int main() {
    string s;cin >> s;
    int max=0;
    int cnt=0;
    for(char c:s){
        if(judge(c)){
            cnt++;
            if(max<cnt){
                max=cnt;
            }
        }
        else{
            cnt=0;
        }
    }
    cout << max << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

int main() {
	int k,s;
	cin >> k >> s;
	int count = 0;
	rep(x, k + 1) {
		rep(y, k + 1) {
			int z = s - x - y;
			if (z >= 0 && z <= k) {
				count ++;
			}
		}
	}
	cout << count << endl;



	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[100005];
int main(){
   int n;
   cin>>n;
   vector<ll> a(n);
   for(int i=0;i<n;i++)cin>>a.at(i);
   fill(dp,dp+n,inf);
   for(int i=n-1;i>=0;i--){
     *upper_bound(dp,dp+n,a.at(i))=a.at(i);//同じ色にできる奴は入れ替わる　＝＞　infでないものの数だけ色が必要
}
cout<<lower_bound(dp,dp+n,inf)-dp<<endl;
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	double ans = 0;
    	for(int i=1; i<=N; i++) {
    		int div = 1;
    		while(true) {
    			if(i * div >= K) {
    				break;
    			}
    			div *= 2;
    		}
    		ans += (double)1 / N / div;
    	}
    	System.out.println(ans);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22868
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=1000000000000000
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+b[j]
        mini=min(mini,x)
    b[i]=mini
print(b[0])

Measured memory_bytes: 52448
# -*- coding: utf-8 -*-

line = map(str, raw_input())
place = 0
area = 0
stack1 = []
stack2 = []
for i in line:
    if i == '\\':
        stack1.append(place)
    elif i == '/':
        if len(stack1) != 0:
            j = stack1.pop()
            s = place-j
            area += s
            while len(stack2) != 0:
                if stack2[-1][0] <= j:
                    break
                tmp = stack2.pop()
                s += tmp[1]
            stack2.append([j, s])
    place += 1
print area
temp = []
for a in stack2:
    temp.append(a[1])
if len(stack2) > 0:
    print len(stack2),
    print " ".join(map(str, temp))
else:
    print len(stack2)

Measured memory_bytes: 6988
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int days;
    int num;
    int requ=0;
    
    cin >> days;
    cin >> num;
    
    int tmp;
    while(cin>>tmp){
        requ+=tmp;
    }
    
    int result = days - requ;
    
    if(result<0){
        result=-1;
    }
    
    cout << result << endl;
}

Measured memory_bytes: 3632
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N, M; cin >> N >> M;
	vector<ll> a(M), b(M);
	rep(i, M)cin >> a[i] >> b[i];

	vector<ll> cnt(N);
	rep(i, N) {
		rep(j, M) {
			if (a[j] == i + 1) cnt[i]++;
			if (b[j] == i + 1) cnt[i]++;
		}
	}

	rep(i, N) cout << cnt[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

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

  int l[n];
  rep(i,n)cin >> l[i];
  int cnt = 0;
  for(int i = 0;i < n;i++){
    for(int j = i+1;j < n;j++){
      for(int k = j+1;k < n;k++){
        if(l[i] == l[j] or l[i] == l[k] or l[j] == l[k])continue;
        int len = l[i] + l[j] + l[k];
        int max_len = max(l[i], max(l[j], l[k]));
        int rest = len - max_len;
        if(rest > max_len)cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(void){
    int num;
    cin >> num;
    if (num % 2 == 0){
        cout << (num / 2) * (num /2) << endl;
    }else{
        cout << ((num / 2) + 1) * (num / 2) << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int,input().split()) 
sc = []
for i in range(m):
    sc.append([int(i) for i in input().split()])

if n == 1:
    if  m == 1:
        print(sc[0][1])
    if m == 0:
        print(0)
    if m >= 2:
        print(-1)
if n == 2:
    count = 0
    for i in range(10, 100):
        tmp1 = i // 10
        tmp2 = i - (tmp1 * 10)
        flag = True
        for j in range(m):
            if sc[j][0] == 1 and sc[j][1] != tmp1:
                flag = False
            if sc[j][0] == 2 and sc[j][1] != tmp2:
                flag = False
        if flag:
            print(i)
            break
        else:
            count += 1
    if count == 90:
        print(-1)
if n == 3:
    count = 0
    for i in range(100, 1000):
        tmp1 = i // 100
        tmp2 = (i - (tmp1 * 100)) // 10
        tmp3 = i - tmp1 * 100 - tmp2 * 10
        flag = True
        for j in range(m):
            if sc[j][0] == 1 and sc[j][1] != tmp1:
                flag = False
            if sc[j][0] == 2 and sc[j][1] != tmp2:
                flag = False
            if sc[j][0] == 3 and sc[j][1] != tmp3:
                flag = False
        if flag:
            print(i)
            break
        else:
            count += 1
    if count == 900:
        print(-1)


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

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

  for (ll i = 1; i < 26; i++) {
    ll p = pow(5, i);
    if (n < p) break;
    ans += n / (p * 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    os.println(search(s));

  }

  private static long search(String s) {

    s = s.replaceAll("BC", "D");

    int n = s.length();

    long sum = 0;
    int j = 0;
    while (j < n){

      if (s.charAt(j) != 'A') {
        j++;
        continue;
      }

      // for each, find A
      // found A

      int aCount = 0;
      int i = j;
      while (i < n && (s.charAt(i) == 'A' || s.charAt(i) == 'D')) {
        if (s.charAt(i) == 'A') {
          aCount++;
        }
        if (s.charAt(i) == 'D') {
          sum += aCount;
        }
        i++;
      }
      j = i;
    }
    return sum;
  }
}

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

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  
  if ( ((A % K) == 0) || ((B % K) == 0))
      cout << "OK" << endl;
    
  else if ( (B / K) > (A / K))
    cout << "OK" << endl;
 
  else
    cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    while (n--) {
        int y, m, d, res=0;
        scanf("%d%d%d", &y, &m, &d);
        while (y<1000) {
            ++d;
            if (d>20-(y%3&&m%2==0)) {
                d=1; ++m;
                if (m>10) { m=1; ++y; }
            }
            ++res;
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 596
MOD = 10**9+7
fact = [1]
invfact = [1]
for i in range(1,2*10**5 + 100):
    fact.append((fact[i-1] * i) % MOD)
    invI = pow(i,MOD-2,MOD)
    invfact.append((invfact[i-1] * invI) % MOD)

B,W = map(int,input().split())
N = B+W

pcSum = [1 for _ in range(B+W+1)]
qcSum = [1 for _ in range(B+W+1)]
def modComb(n,m):
    if m < 0 or m > n: return(0)
    ans = fact[n] * invfact[m] 
    ans %= MOD
    ans *= invfact[n-m]
    ans %= MOD
    return(ans)

for i in range(B+W-1):
    pcSum[i+1] = 2*pcSum[i] - modComb(i,B-1)
    pcSum[i+1] %= MOD
    if (i+1-W) <= B-1:
        qcSum[i+1] = 2*qcSum[i] - modComb(i,B-1) - modComb(i,i+1-W)
        qcSum[i+1] %= MOD
    else:
        qcSum[i+1] = 0

p = []
q = []
powOfTwo = []
value = 1
invTwo = pow(2,MOD-2,MOD)
for _ in range(N):
    powOfTwo.append(value)
    value *= invTwo
    value %= MOD
for i in range(B+W):
    # coefficient = pow(2,i*(MOD-2),MOD)
    coefficient = powOfTwo[i]
    pvalue = pcSum[i] * coefficient
    pvalue %= MOD
    p.append(pvalue)
    qvalue = qcSum[i] * coefficient
    qvalue %= MOD
    q.append(qvalue)
for i in range(N):
    answer = p[i] - invTwo * q[i]
    answer %= MOD
    print(answer)


Measured memory_bytes: 54220
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

string s[8];

void dfs(int y,int x){
	if(y<0||y>7||x<0||x>7) return;
	if(s[y][x]=='1'){
		s[y][x]='0';
		rer(i,1,3){
			dfs(y+i,x);
			dfs(y-i,x);
			dfs(y,x+i);
			dfs(y,x-i);
		}
	}
}

int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		int x,y;
		cin.ignore();
		rep(j,0,8){
			cin>>s[j]; //o(" "<<s[j]);
		}
		cin>>x>>y;
		dfs(y-1,x-1);
		o("Data "<<i+1<<":");
		rep(i,0,8) o(s[i]);
	}
}

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

const int maxn=2e5+5;
int k[2100],ans=0;
int s1[maxn],sum[maxn],g[maxn];

int main()
{
	string s;
	cin>>s;
	
	int len=s.size();
	for (int i=0;i<len;++i)
		s1[i+1]=s[i]-'0';
	
	int t=1;
	for (int i=len;i>=1;--i){
		g[i]=t;
		t=t*10;
		t=t%2019;
	}
	for (int i=len;i>=1;--i){
		sum[i]=(sum[i+1]+s1[i]*g[i])%2019;
		k[sum[i]]++;
	}
	
	ans=k[0];
	ans=ans+k[0]*(k[0]-1)/2;
	for (int i=1;i<=2018;++i)
		ans=ans+k[i]*(k[i]-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6012
#include<stdio.h>

int main(){
  int i, j, n, q;
  int count=0;
  int S[10001], T[501];
  
  //Sのデータの入力
  scanf("%d", &n);
  for( i=0 ; i<n ; i++){
    scanf("%d", &S[i]);
  }
  //Tのデータの入力
  scanf("%d", &q);
  for( i=0 ; i<q ; i++){
    scanf("%d", &T[i]);
  }
  //探索開始へへへ
  for( i=0 ; i<q ; i++){
    S[n] = T[i];//番兵作成なう
    j=0;
    while( S[j]!=T[i] ){
      j++;
    }
    if( j<n ){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if (x != 3 && x != 5 && x != 7)
            System.out.println("NO");
        else
            System.out.println("YES");
    }
}









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

int main() {
  int A, B, C, num, ans;
  cin >> A >> B >> C;
  A -= B;
  if (A > C){    
    ans = 0;
  }
  else {  
    ans = C - A;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
K=int(input())
S=input()

len_S=len(S)

#逆元を用いたコンビネーション
mod = 10**9+7
def mul_mod(a,b):
  return (a*b) % mod

def fact_inv(a):
  ans = 1
  for i in range(1,a+1):
    ans = (pow(i,mod-2,mod) * ans) % mod
  return ans

fact_list = [1]
for i in range(1,len_S+K):
  fact_list.append(mul_mod(fact_list[-1],i))

fact_list_inv = [1]
for i in range(1,len_S+K):
  fact_list_inv .append((pow(i,mod-2,mod) * fact_list_inv[-1]) % mod)
def comb_inv_mod(a,b):
  tmp = (fact_list[a]*fact_list_inv[b]) % mod
  return (tmp*fact_list_inv[a-b]) % mod

ans = 0
for i in range(len_S-1,len_S+K): #Snの位置
  #print(i)
  #ans += comb_inv(len_S+K-(len_S+K-i-1)-1,N-1)*pow(25,(K-(len_S+K-i-1)),mod)*pow(26,len_S+K-i-1,mod)
  A = comb_inv_mod(i,len_S-1)*pow(25,i-len_S+1,mod) % mod 
  A = A*pow(26,len_S+K-i-1,mod) % mod
  ans += A
  #print(ans)
  ans = ans % mod
print(ans)

Measured memory_bytes: 216004
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    vector<P> p(n);
    for(int i=0;i<n;i++)cin>>p[i].first>>p[i].second;
    ll a=1, k=1;
    for(P x:p){
        ll r=a/x.first;
        if(a%x.first!=0)r++;
        ll s=k/x.second;
        if(k%x.second!=0)s++;
        a=max(r,s)*x.first;
        k=max(r,s)*x.second;
    }
    cout<<a+k<<endl;
    return 0;
}



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

int main() {
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
 if(a==0)cout<<"1"<<endl;
 else if(b==0)cout<<"2"<<endl;
 else if(c==0)cout<<"3"<<endl;
 else if(d==0)cout<<"4"<<endl;
 else if(e==0)cout<<"5"<<endl;
	return 0;
}


Measured memory_bytes: 3636
import sys
import itertools

input = sys.stdin.readline

def myindex(l, element, default=-1):
    if element in set(l):
        return l.index(element)
    else:
        return default

def main():
    H, W, D = map(int, input().split())
    grid = []; locale = [0]*(H*W)
    for i in range(H):
        tmp = list(map(int, input().split()))
        for j, t in enumerate(tmp):
            x, y = i+1, j+1
            locale[t-1] = (x, y)
        grid.append(tmp)
    
    power = []
    for k in range(H*W-D):
        fr = locale[k]
        to = locale[k+D]
        need = abs(fr[0]- to[0]) + abs(fr[1] - to[1])
        power.append(need)
    
    cum = []
    for d in range(D):
        cum.append([0] + list(itertools.accumulate(power[d::D])))

    Q = int(input())
    for _ in range(Q):
        L, R = map(int, input().split())
        d = (L-1)%D
        dnum = (L-1)//D
        drange = (R-L)//D
        ans = cum[d][dnum+drange] - cum[d][dnum]
        print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 24684
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	String S;
	Deque<Byte> que;
	int Q;
	boolean inverse;
	
	void calc() {
		sc = new Scanner(System.in);
		S = sc.next();
		que = new ArrayDeque<>();
		for (int i = 0; i < S.length(); i++)
			que.addLast( (byte)(S.charAt(i)) );
		Q = sc.nextInt();
		inverse = false;
		
		for (int i = 0; i < Q; i++) {
			int t = sc.nextInt();
			if (t == 1) {
				inverse = !inverse;
			} else {
				boolean addFirst = (sc.nextInt() == 1);
				byte c = (byte)sc.next().charAt(0);
				if (inverse^addFirst) que.addFirst(c);
				else que.addLast(c);
			}
		}
		char[] ans = new char[que.size()];
		if (inverse)
			for (int i = 0; i < ans.length; i++)
				ans[i] = (char)(que.removeLast().byteValue());
		else
			for (int i = 0; i < ans.length; i++)
				ans[i] = (char)(que.removeFirst().byteValue());
		
		System.out.println(new String(ans));
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}



Measured memory_bytes: 67624
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
#include <cctype>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5+10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

vector<int> pp;
typedef string::const_iterator SC;

int number(SC& begin){
	int res = 0;
	
	while(isdigit(*begin)){
		res *= 10;
		res += *begin - '0';
		begin++;
	}
	
	return res;
}

// ?????????????¨??????????(int???)?????????
int term(SC& begin){
	int res = number(begin);
	
	while(1){
		if(*begin == '*'){
			begin++;
			res *= number(begin);
		}
		else{
			break;
		}
	}
	return res;
}

// ?¶????????????????
int expression(SC& begin){
	int res = term(begin);
	
	while(1){
		if(*begin == '+'){
			begin++;
			res += term(begin);
		}
		else{
			break;
		}
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	int n;
	cin >> n;
	if(s.size() == 1){
		if((s[0] - '0') == n)
			cout << "U" << endl;
		else
			cout << "I" << endl;
		return 0;
	}
	bool mb = false, lb = false;
	bool plus = false;
	int m = s[0] - '0';
	FOR(i,1,s.size()){
		if(i % 2){
			plus = s[i] == '+';
		}
		else{
			if(plus)
				m += s[i] - '0';
			else
				m *= s[i] - '0';
		}
	}
	if(n == m)
		mb = true;
	SC begin = s.begin();
	int l = expression(begin);
	//cout << l << endl;
	if(n == l)
		lb = true;
	if(lb && mb){
		cout << "U" << endl;
	}
	else if(lb){
		cout << "M" << endl;
	}
	else if(mb){
		cout << "L" << endl;	
	}
	else{
		cout << "I" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long a[200001];
int main()
{
	long long n,t1=0,t2=0,t,ans=9999999999;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),t1+=a[i];
	for(int i=1;i<n;i++)
	{
		t1-=a[i];
		t2+=a[i];
		t=abs(t1-t2);
		ans=min(t,ans);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;


int main() {
    string s[] = {"mon","tue","wed","thu","fri","sat","sun"};
    int x;
    cin >> x;
    int tmp = (3 + x) % 7;
    cout << s[tmp] << endl;

}

Measured memory_bytes: 3188
with open(0) as f:
    N, M = map(int, f.read().split())
mod = 1000000007

def factorial(n):
    res = 1
    for i in range(1,n+1):
        res = res * i %mod
    return res

if abs(N-M) > 1:
    ans = 0
elif N == M:
    ans = 2*factorial(M)**2 %mod 
else:
    N, M = max(N, M), min(N, M)
    ans = N * factorial(M)**2 %mod
print(ans)

Measured memory_bytes: 9060
#include <iostream>

using namespace std;

int main(void){
  int n, i;
  cin >> n;
  if(n == 1){
    cout << "Yes" << endl;
    return 0;
  }
  for(i = 2; i < 10; i++){
    if(n % i == 0 && n / i < 10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

  LL ans = 1;
  for (int i = 1; i <= n; i ++) {
    ans = (ans * i) % 1000000007;
  }

  cout << ans << endl;
}


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

const long long mod = 1e9 + 7;

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

    if (abs(n - m) > 1) {
        cout << 0 << endl;
    } else {
        long long ans = 1;
        if (n - m == 0) {
            ans = 2;
        }
        while (n != 0 && m != 0) {
            ans *= n; ans %= mod;
            ans *= m; ans %= mod;
            n--; m--;
        }

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


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

using namespace std;

int main() {
    int a,b;

    cin>>a>>b;
    int sum=0;
    for(int i=a;i<=b;i++){
        if(to_string(i)[0]==to_string(i)[4]&&to_string(i)[1]==to_string(i)[3]){
            sum++;
        }
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, x=0, r=1;
	cin>>n;
	int a[n+1], b[n];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	
	for(int i=0; a[r] != 2; i++){
		r = a[r];
		x++;
		
		if(x==n){
			cout<<"-1"<<endl;
			return 0;
		}
	}
	
	cout<<x+1<<endl;
	
	return 0;
}

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

long long mod = 1000000007LL;

typedef pair<long long, long long> ii;
int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k; cin >> n >> k;
	int arr[n];
	int ms = 0;
	int s = 0;
	for(int i = 0;i < n;i++){
		cin >> arr[i];
	}
	
	for(int i = 0;i < n;i++){
		s += arr[i];
		if(i >= k){
			s -= arr[i - k];
		}
		if(i >= k-1){
			ms = max(ms, s);
		}	
	}
	double ans = ms;
	ans += k;
	ans /= 2.0;
	cout << setprecision(12) << ans;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) = abc159e()

fun abc159e() {
    val (h, w, k) = readLine()!!.split(' ').map { it.toInt() }
    // true: white chocolate
    val grid = Array(h) { readLine()!!.toCharArray().map { Character.getNumericValue(it) }.toIntArray() }

    var answer = Int.MAX_VALUE

    bitWholeSearch@ for (bit in 0 until Math.pow(2.0, h.toDouble()).toLong()) {
        val bitSet = BitSet.valueOf(longArrayOf(bit))
        if (bitSet[0]) continue

        var above = 0
        var divCount = 0

        val rows = mutableListOf<List<IntArray>>()

        while (above < h) {
            var below = above
            while (below + 1 < h && !bitSet[below + 1]) below++
            rows.add(grid.slice(above..below))
            above = below + 1
        }

        val whiteOnLeft = IntArray(rows.size)

        for (x in 0 until w) {
            val whiteOnRows = rows.map { row -> row.map { it[x] }.sum() }
            if (whiteOnRows.any { it > k }) continue@bitWholeSearch
            if (whiteOnRows.mapIndexed { index, white -> white + whiteOnLeft[index] }.any { it > k }) {
                divCount++
                for (i in whiteOnLeft.indices) whiteOnLeft[i] = whiteOnRows[i]
            } else {
                for (i in whiteOnLeft.indices) whiteOnLeft[i] += whiteOnRows[i]
            }
        }

        answer = Math.min(answer, bitSet.cardinality() + divCount)
    }

    println(answer)
}


Measured memory_bytes: 126856
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Fri Jan 25 20:31:18 2019
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ans := 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		for a%2 == 0 {
			a /= 2
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
typedef long long ll;
int main(){
    int n,a,b;scanf("%d%d%d",&n,&a,&b);
    ll l = 1LL*a*(n-1) + b,r = 1LL*b*(n-1) + a;
    if(l > r) {puts("0");return 0;}
    else printf("%lld\n",(r-l+1));
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split( )))
count = 0

while True:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] //= 2
            count += 1
        else:
            ans = count // n
            print(ans)
            exit()


Measured memory_bytes: 2940
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace Vertial
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = NM[0];
            var M = NM[1];
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var ModDic = new Dictionary<long, long>();

            var sum = 0;
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                sum += A[i] % M;
                sum %= M;
                if (sum == 0)
                {
                    ans++;
                }

                if (!ModDic.ContainsKey(sum))
                {
                    ModDic.Add(sum,1);
                }
                else
                {
                    ModDic[sum]++;
                }
            }

            
            foreach (var item in ModDic)
            {
                var Key = item.Key;
                var value = item.Value;

                ans += item.Value * (item.Value-1)/2;

            }
            Console.WriteLine(ans);
        }




    }
}


Measured memory_bytes: 21856
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	long long int N,j=0,A[200]={},ans=0;
	bool flag=true;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
	}
	for(int i=0;i<10000;i++)
	{
		j=0;
		while(j!=N)
		{
			if(A[j]%2==0)A[j]/=2;
			else flag=false;
			j++;
		}
		if(!flag)break;
		ans++;
	}
	cout<<ans;
	}

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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> ban(h);
    for (int i = 0; i < h; i++) {
        cin >> ban[i];
    }

    bool ret = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ban[i][j] == '#') {
                bool flag = false;
                if (0 < i) {
                    if (ban[i - 1][j] == '#')flag = true;
                }
                if (0 < j) {
                    if (ban[i][j - 1] == '#')flag = true;
                }
                if (i < h - 1) {
                    if (ban[i + 1][j] == '#')flag = true;
                }
                if (j < w - 1) {
                    if (ban[i][j + 1] == '#')flag = true;
                }
                if (!flag)ret = false;
            }
        }
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[100];
  int n;cin >> n;
  for(int j=0;j<n;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  
  bool ff = true;
  for(int k=0;k<n-1;k++){
    for(int l=k+1;l<n;l++){
      bool f=false;
      for(int i=0;i<4;i++){
	d[l].roll('R');
	for(int j=0;j<4;j++){
	  d[l].roll('N');
	  if(same(d[k],d[l])) f=true;
	}
      }
      d[l].roll('E');
      for(int j=0;j<4;j++){
	d[l].roll('N');
	if(same(d[k],d[l])) f=true;
      }
      
      d[l].roll('W');
      d[l].roll('W');
      for(int j=0;j<4;j++){
	d[l].roll('N');
	if(same(d[k],d[l])) f=true;
      }
      if(f) ff=false;
    }
  }
  
  cout << (ff?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
const int maxn = 1e9;
char s[maxn];
int main()
{
    long long sum = 0;
    scanf("%s",s);
    int len = strlen(s);
    for(int i = 0; i < len; i++)
        sum += s[i] - '0';
    long long m = atoi(s);
    if(m%sum == 0)
        printf("Yes");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k;cin>>n>>k;
  ll ans=0;
  while(n){
    n/=k;
    ans++;
  }
  cout<<ans<<ENDL;

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256