akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
struct Node{
    int key;
    Node *l,*r;
};
vector<int>p;
Node *T;
int isn;
void insert(int key){

    if(T==NULL)
    {
        T=(Node* )malloc(sizeof(Node));
        T->key=key;
        T->l=NULL;
        T->r=NULL;
        //cout<<T->key<<endl;
        return;
    }
    Node *z=(Node* )malloc(sizeof(Node));
    z->key=key;
    z->l=NULL;
    z->r=NULL;
    Node *p,*temp=T;
    while(temp!=NULL)
    {
        p=temp;
        if(z->key<temp->key)
            temp=temp->l;
        else
            temp=temp->r;
    }
    if(z->key<p->key)
        p->l=z;
    else
        p->r=z;
}
void preOrder(Node *T){
    if(T==NULL){
        //cout<<1<<endl;
        return;
    }
    cout<<' '<<T->key;
    preOrder(T->l);
    preOrder(T->r);
}
void inOrder(Node *T){
    if(T==NULL)return;
    inOrder(T->l);
    cout<<' '<<T->key;
    inOrder(T->r);
}
int main(){
    int m,key;
    char com[20];
    T=NULL;
    isn=0;
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>com;
        if(com[0]=='i')
        {
            cin>>key;
            insert(key);
            //cout<<1;
        }
        else
        {
            inOrder(T);
            cout<<endl;
            preOrder(T);
            //p.clear();
            cout<<endl;
            
        }
    }
    return 0;
}


Measured memory_bytes: 18636
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	long long x; cin >> x;
	long long a=100;
	long long ans=0;
	while (true){
		long long s=a/100;
		a=a+s;
		ans++;
		if (a>=x){
			cout << ans << "\n";
			return 0;
		}
	}
}


Measured memory_bytes: 3636
#include <stdio.h>
int main()
{
    int A,B,X;
    if (1<=A&&A<=1e9&&-1<=B&&B<=1e9&&-1<=X&&X<=1e9);
    {
        scanf("%d %d %d",&X,&A,&B);
        if ((B-A)<=X&&(B-A)>0) printf("safe\n");
        if ((B-A)<=X&&(B-A)<=0)      printf("delicious\n");
        if ((B-A)>X)  printf("dangerous\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	int a[300000];
	scanf("%d", &n);
	for(i=0; i<n*3; i++){
		scanf("%d", a+i);
	}
	qsort(a, n*3, sizeof(int), comp);
	long ans=0;
	for(i=n; i<n*3; i+=2){
		ans+=a[i];
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 2556
import itertools
import math

N = int(input())
S1 = input()
S2 = input()
MOD = 1000000007
dir = 0 # 0→ よこ 1 →たて

if N == 1:
    ans = 3
    i = 1

elif S1[0] == S1[1]:
    dir = 0
    ans = 6
    i = 2
else:
    dir = 1
    ans = 3
    i = 1
p = [0,0,0,0]
while True:
    if i>=N:
        break


    if dir == 0:
        if i + 1 < N and S1[i] == S1[i + 1]: #横→横パターン

            dir = 0
            i += 2
            p[0] += 1
            ans *= 3
        else:

            i+=1  #横→縦パターン
            dir = 1
            ans *= 1


            p[1] += 1

    elif dir == 1:
        if i + 1 < N and  S1[i] == S1[i + 1]: #縦→横パターン
            i += 2
            dir = 0

            ans *= 2


            p[2] +=1
        else: #縦→縦パターン
            i += 1
            dir = 1
            ans *= 2
            p[3] +=1
    # print(ans)
    ans %= MOD
print(ans)


Measured memory_bytes: 38384
# -*- coding: utf-8 -*-
# E - Sequence Decomposing
import sys 
from bisect import bisect_right

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,read().split()))
X = [-1]*N
for a in A:
    i = bisect_right(X,a-1)-1
    X[i] = a
print(N - X.count(-1)) 

Measured memory_bytes: 89784
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n; cin >> n;
    int h[n]; for(int i=0; i<n; i++) cin >> h[i];
    int water=0;
    int ans=0;
    for(int i=0; i<n; i++){
        if(water<h[i]){
            ans += h[i]-water;
        }
        water = h[i];
    }
    cout << ans << endl;
}


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

int main()
{
	int n;
	cin>>n;
	int A[n],B[n],c[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	for(int i=0;i<n;i++)
		cin>>B[i];
	for(int i=0;i<n-1;i++)
		cin>>c[i];
	int ans=B[A[0]-1];
	for(int i=1;i<n;i++)
	{
		int x=A[i];
		ans=ans+B[x-1];//cout<<B[x-1]<<" ";
		if(A[i]-A[i-1]==1)ans=ans+c[A[i-1]-1];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char f1[200],f2[200];
  int n,len;
  int i,j,h;
  char *p1,*p2,*p;
  while(1){
    scanf("%s",f1);
    if(f1[0] == '-') break;
    else{
      scanf("%d",&n);
      p1 = &f1;
      p2 = &f2;
      len = strlen(f1);
      for(i=0;i<n;i++){
	scanf("%d",&h);
	for(j=0;j<h;j++) *(p2+len-h+j)=*(p1+j);
	for(j=0;j<len-h;j++) *(p2+j)=*(p1+h+j);
	p=p1;
	p1=p2;
	p2=p;
      }
    }
    for(j=0;j<len;j++)
      printf("%c",*(p1+j));
    printf("%c",'\n');
  }
  return 0;
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)


bool contain(string &a,string &b){
  return a.find(b)!=a.npos;
}
int common(string &a,string &b){
  int ret=0;
  int n=max(a.size(),b.size());
  REP(c,n){
    bool ok=true;
    REP(i,c){
      if(b[i]!=a[a.size()-c+i]){
        ok=false;
        break;
      }
    }
    if(ok){
      ret=max(ret,c);
    }
  }
  return ret;
}
int main(){
  int nn;
  while(cin>>nn,nn){
    vs ss(nn);
    REP(i,nn){
      cin>>ss[i];
    }
    vs s;
    REP(i,nn){
      bool ok=true;
      REP(j,nn){
        if(i!=j&&contain(ss[j],ss[i])){
          ok=false;
          break;
        }
      }
      if(ok){
        s.push_back(ss[i]);
      }
    }
    int n=s.size();
    vvi dp(1<<n,vi(n,INT_MAX/10));
    REP(i,n){
      dp[1<<i][i]=s[i].size();
    }
    REP(i,1<<n){
      REP(j,n){
        REP(k,n){
          if(((i>>k)&1)==0){
            dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],(int)(dp[i][j]+s[k].size()-common(s[j],s[k])));
          }
        }
      }
    }
    int ans=INT_MAX/10;
    REP(i,n){
      ans=min(ans,dp[(1<<n)-1][i]);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2648
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[] pow3 = new int[n + 1];
			pow3[0] = 1;
			for (int i = 1; i <= n; i++)
				pow3[i] = pow3[i - 1] * 3;
			int[] c = new int[n];
			for (int i = 0; i < 3; i++) {
				int a = scanner.nextInt();
				for (int j = a; j > 0; j--) {
					int k = scanner.nextInt();
					c[n - k] = i;
				}
			}
			int p = 0;
			int x = 0;
			for (int i = n - 1; i >= 0; i--) {
				int d = Math.abs(p - c[i]);
				x += pow3[i] * d;
				if (d == 1)
					p = 2 - p;
			}
			int y = pow3[n] - 1 - x;
			if (x > y)
				x = y;
			System.out.println(x > m ? -1 : x);
		}

	}
}

Measured memory_bytes: 17212
import sys
input=sys.stdin.readline
INF = 10**9
MOD = 10**9 + 7

def main():
    h,w,k = map(int,input().split())

    dp = [[0]*w for _ in range(h+1)]
    dp[0][0] = 1

    for i in range(h):
        for bit in range(1<<(w-1)):
            flag = False
            before = -2
            line = [0] * (w-1)
            for j in range(w-1):
                if (bit>>j)&1:
                    if  before + 1 == j:
                        flag = True
                        break
                    
                    else:
                        before = j
                        line[j] = 1
  

            if flag:
                continue

            j = 0
            while j < w:
                if j == w-1:
                    dp[i+1][j] += dp[i][j]
                    dp[i+1][j] %= MOD
                    break
                if line[j]:
                    dp[i+1][j] += dp[i][j+1]
                    dp[i+1][j] %= MOD
                    dp[i+1][j+1] += dp[i][j]
                    dp[i+1][j+1] %= MOD
                    j += 2
                else:
                    dp[i+1][j] += dp[i][j]
                    dp[i+1][j] %= MOD
                    j += 1

    print(dp[-1][k-1]%MOD)
if __name__=='__main__':
    main()


Measured memory_bytes: 3188
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
c=[0 for i in range(n)]

l=1
u=0
f=True
while True:
  u+=1
  l=a[l-1]
  if u==k:
    print(l)
    f=False
  if c[l-1]:
    break
  else:
    c[l-1]=u
k=(k-(c[l-1]))%(u-c[l-1])
while k:
  k-=1
  l=a[l-1]
if f:
  print(l)

Measured memory_bytes: 32376
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		String N = sc.next();

		if(Character.isUpperCase(N.charAt(0))) {

			System.out.println('A');
		}else {

			System.out.println('a');
		}




	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35652
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n = int(input())
a, b, c = list(map(int, input().split()))

dp = [[-1]*3 for i in range(n+1)]
dp[1][0] = a
dp[1][1] = b
dp[1][2] = c

for i in range(2,n+1):
    a, b, c = list(map(int, input().split()))
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

print(max([dp[n][0], dp[n][1], dp[n][2]]))


Measured memory_bytes: 29344
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Debug.Trace

main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve n = foldl' count 0 [1..s]
    where
        s = truncate . sqrt $ fromIntegral n

        count acc r
            | b == 0 && r < a - 1 = acc + a - 1
            | otherwise = acc
            where
                (a, b) = n `divMod` r

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
#include <bits/stdc++.h>
 
#define INT_INF (2 * 1e9)
#define LL_INF  (2LL * 1e18)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#endif
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;

void solve()
{
	int n, sum = 0, mx = -INT_INF;

	cin >> n;

	for(; n > 0; --n)
	{
		int L;
		cin >> L;

		mx = max(mx, L);
		sum += L;
	}

	if(mx < sum - mx)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;	
}

int main(int argc, char** argv)
{
	FAST_IO;
	solve();

	return 0;
}


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

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

    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int mini = 1e9;
    for(int i = 0; i < (1 << D); i++){
        int total = 0, cnt = 0;
        for(int j = 0; j < D; j++){
            if((i >> j) & 1){
                total += p[j] * (j + 1) * 100 + c[j];
                cnt += p[j];
            }
        }
        if(total < G){
            bool f = false;
            for(int j = D - 1; j >= 0; j--){
                if((i >> j) & 1) continue;
                for(int k = 0; k < p[j]; k++){
                    total += (j + 1) * 100;
                    cnt++;
                    if(total >= G){
                        f = true;
                        break;
                    }
                }
                total += c[j];
                if(total >= G){
                    f = true;
                }
                if(f) break;
            }
        }
        mini = min(mini, cnt);
    }

    cout << mini << endl;

    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 long long ll;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  while(1){
    c-=b;
    if(c<=0){
      cout<<"Yes";
      break;
    }
    a-=d;
    if(a<=0){
      cout<<"No";
      break;
    }
  }
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int x;
      cin >> x;
      if(x==3 || x==5 || x==7){
       cout << "YES" << endl; 
      }else cout << "NO" << endl;
      return 0;}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll a;
    string s;
    cin >> a >> s;
    cout << ((a >= 3200)?s : "red") << endl;
    return 0;
}

Measured memory_bytes: 256
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

char s[1000010];

inline int C(int n, int m) { return (n & m) == m; }

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n;
	scanf("%d%s", &n, s + 1);
	if(n == 1) putchar(s[1]), puts("");
	else {
		--n;
		int find1 = 0;
		for(int j = 1; j <= n; j++)
			s[j] = abs(s[j] - s[j + 1]), find1 |= s[j] == 1;
		if(!find1) for(int i = 1; i <= n; i++) s[i] >>= 1;
		find1 ^= 1;
		int t = 0;
		for(int j = 1; j <= n; j++) t ^= C(n - 1, j - 1) * (s[j] & 1);
		cout << (int(t) << find1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 5005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int A, B, K;
	scanf("%d %d %d", &A, &B, &K);
	vector <int> factors;
	for (int i = 1; i <= 100; i++) {
		if (A % i == 0 and B % i == 0) factors.push_back(i);
	}
	reverse(factors.begin(), factors.end());
	printf("%d\n", factors[K - 1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int c = 0;
    int t = n;
    while(t){
        c++;
        t=t/10;
    }
    int a[6]={9,0,900,0,90000,0};
    int ans=0;
    for(int i=1;i<=c-1;i++){
        ans=ans+a[i-1];
    }
    if(c&1){
        int x = pow(10,c-1);
        ans = ans + (n-x);
        ans++;
    }

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



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

int main(){
      string s;cin >> s;
      int y = stoi(s.substr(0, 4));
      int m = stoi(s.substr(5, 2));
      int d = stoi(s.substr(8, 2));
      if(y > 2019 || (y == 2019 && m > 4))cout << "TBD";
      else cout << "Heisei";
}

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

void maxHeapify(vector<int>& S, int i)
{
	int l = i * 2;
	int r = i * 2 + 1;
	int H = S.size() - 1;

	int largest;
	if (l <= H && S[i] < S[l]) largest = l;
	else largest = i;
	if (r <= H && S[largest] < S[r]) largest = r;

	if(i != largest)
	{
		swap(S[i], S[largest]);
		maxHeapify(S, largest);
	}
}

void buildMaxHeap(vector<int>& S)
{
	for (int i = (S.size() - 1) / 2; i > 0; i--) maxHeapify(S, i);
}

int main(void)
{
	int N;
	cin >> N;
	N += 1;
	vector<int> S(N);
	for (int i = 1; i < N; i++) cin >> S[i];

	buildMaxHeap(S);

	for (int i = 1; i < N; i++) cout << " " << S[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 4588
X = int(input())
if X>=400 and X<=599:
    print(8)
elif X>=600 and X<=799:
    print(7)
elif X>=800 and X<=999:
    print(6)
elif X>=1000 and X<=1199:
    print(5)
elif X>=1200 and X<=1399:
    print(4)
elif X>=1400 and X<=1599:
    print(3)
elif X>=1600 and X<=1799:
    print(2)
elif X>=1800 and X<=1999:
    print(1)

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

void fnInput(vector<int>& rvnNum)
{
  string sNum;
  cin >> sNum;

  for (int i = 0; i < rvnNum.size(); i++)
    rvnNum[i] = sNum[i] - '0';                 // char → int 変換
}

int fnBitFullSch(const vector<int>& cnrvnNum)
{
  for (int n = 0; n < (1 << 3); n++)
  {
    int nSum = cnrvnNum[0];
    for (int i = 0; i < 3; i++)
      if (n & (1 << i))  nSum += cnrvnNum[i + 1];
      else               nSum -= cnrvnNum[i + 1];

    if (nSum == 7)  return n;
  }
  return 7;
}
    
void fnResult(const vector<int>& cnrvnNum, int nReslt)
{
  cout << cnrvnNum[0];
  for (int i = 0; i < 3; i++)
  {
    if (nReslt & (1 << i))  cout << "+";
    else                   cout << "-";

    cout << cnrvnNum[i + 1];
  }
  cout << "=7" << endl;
}

int main()
{
  vector<int> vnNum(4);
  
  fnInput(vnNum);
  int nReslt = fnBitFullSch(vnNum);
  fnResult(vnNum, nReslt);

  return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {

	int x;
	cin >> x;
	int ans = 0;
	rep(i, x+1) {
		ans += i;
		if (ans >= x) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N, M, A, Sum;
  cin >> N >> M;
  Sum = 0;

  for (int i = 0; i < M; i++) {
    cin >> A;
    Sum += A;
  }

  if ((N - Sum) >= 0 ) {
    cout << (N - Sum) << endl;  
  }
  else {
    cout << -1 << endl;
  }
  
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
	int N,M,ans=0;
	scanf("%d%d",&N,&M);
	int a[M],b[M];
	for(int i=0;i<M;i++)scanf("%d%d",&a[i],&b[i]);
	
	//sort
	int h=M;
	int swapped=0;
	while(h>1 || swapped==1){
		if(h>1)h=h*10/13;
		swapped=0;
		for(int i=0;i<M-h;i++){
			if(b[i]>b[i+h] || (b[i]==b[i+h] && a[i]>a[i+h])){
				int tmp=a[i];
				a[i]=a[i+h];
				a[i+h]=tmp;
				tmp=b[i];
				b[i]=b[i+h];
				b[i+h]=tmp;
				swapped=1;
			}
		}
	}
	
	int remove=-1;
	for(int i=0;i<M;i++){
		if(i<M-1 && b[i]==b[i+1])continue;
		else if(a[i]<=remove && remove<b[i])continue;
		else {
			ans++;
			remove=b[i]-1;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

long long f(long long h) {
  if (h == 1)
    return 1;
  else
    return 2 * f(h / 2) + 1;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long h;
  cin >> h;
  cout << f(h) << '\n';
  return 0;
}

Measured memory_bytes: 3652
from collections import defaultdict as ddict
def cal_interval(Num):
	interval = ddict(int)
	dp = [0 for i in range(Num)]
	for i in range(Num):
		tmp = int(raw_input())
		for j in range(i+1):
			dp[j] += tmp
			interval[dp[j]] += 1
	return interval
while 1:
	N, M = map(int,raw_input().split(" "))
	if (N, M) == (0,0):
		break
	Lon = cal_interval(N)
	Lat = cal_interval(M)
	print sum(Lon[k] * Lat[k] for k in Lon if k in Lat)

Measured memory_bytes: 54300
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> dic[n];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            dic[i].push_back({x, y});
        }
    }
    int flag[n];
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                flag[i] = 1;
                cnt++;
            } else {
                flag[i] = 0;
            }
        }
        bool f = true;
        for (int i = 0; i < n; i++) {
            if (flag[i] == 1) {
                for (auto p : dic[i]) {
                    if (flag[p.first] != p.second) {
                        f = false;
                        break;
                    }
                }
            }
            if (!f) break;
        }
        if (f) ans = max(ans, cnt);
    }
    OUT(ans);
}


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 K = sc.nextInt();

        double prob=0;
//        for (int i = 1; i <= Math.min(K,N); i++) {1
        for (int i = 1; i <= N; i++) {
            if(i < K ){
                int times = log((double)K/i,2 );
//                System.out.println(i+" "+ log(K/i,2 ) +" "+ Math.max(log((double) K/i,2 ),0) +" "+ times);
                prob+= (double) 1/N * Math.pow((double) 0.5 ,times ) ;
            }else{
  //              System.out.println(i+" "+ 0 );
                prob+= (double) 1/(double)N;
            }
        }
        System.out.println(prob);
    }


    static int log(double x, int base)
    {
        return (int) Math.ceil (Math.log(x) / Math.log(base));
    }

}

Measured memory_bytes: 21716
N,K,Q=input().split(" ")
N=int(N)
K=int(K)
Q=int(Q)
Alist=[]
for i in range(Q):
    Alist.append(int(input()))

pointlist=[0]*N

for i in Alist:
    pointlist[i-1]+=1

for n in pointlist:
    if n>Q-K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8640
for i in range(5):
    a=int(input())
    A=1000-a
    x=A//500
    M=A%500
    y=M//100
    M=M%100
    z=M//50
    M=M%50
    w=M//10
    M=M%10
    u=M//5
    M=M%5
    
    if a==0: break

    print(x+y+z+w+u+M)


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){

    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    rep(i, n){
        if(i < n-1 && p[i] == i+1){
            swap(p[i], p[i+1]);
            ans++;
        }
        if(i == n-1 && p[i] == i+1){
            swap(p[i], p[i-1]);
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
N,K = map(int,input().split())
S = input()+"w"
A = []
if S[0]=="0":A.append(0)
a,b = 0,""
for s in S:
    if b!="" and b!=s:
        A.append(a)
        a=1
    else:a+=1
    b=s
if S[-2]=="0":A.append(0)
B = [0]
for i in range(len(A)):
    B.append(B[i]+A[i])
ans = 0
N = len(B)
for i in range(2*K+1,N):
    if i%2==0:continue
    ans = max(ans,B[i]-B[i-2*K-1])
print(ans if ans else B[N-1])

Measured memory_bytes: 7924
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    ll ans;
    rep(i,n){
        ll a;
        cin>>a;
        if(i==0){
            ans=a;
        }else{
            ans = gcd(ans,a);
        }
    }
    cout1(ans)
}

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

#define N 2000

int n;
int a[N];

int main()
{
	int ans = 0;
	int z, w;

	cin >> n >> z >> w;
	for( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}

	ans = abs(w - a[n-1]);
	if( n > 1 ) {
		ans = max( ans, abs(a[n-2] - a[n-1]));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>

int ch(int i){
	switch(i){
		case 0:return 'S';
		case 1:return 'H';
		case 2:return 'C';
		case 3:return 'D';
	}
}

int main(void){
	int a[4][14],c,i,j,n;
	char b;
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %c %d",&b,&c);
		if(b=='S')
			a[0][c]=1;
		else if(b=='H')
			a[1][c]=1;
		else if(b=='C')
			a[2][c]=1;
		else
			a[3][c]=1;
	}
	for(i=0;i<=3;i++){
		for(j=1;j<=13;j++){
			if(a[i][j]==0)
				printf("%c %d\n",ch(i),j);
		}
	}
	return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a,b,c;
  cin >> a;
  
  for(int i =0; i<a.length()-1;i++){
	if(a.substr(i,2)=="AC"){
		cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" <<endl;
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 10000
#define NOT -1;

int linearSearch(int n,int s[],int t){
  int i;
  for(i=0; i<n; i++){
    if(s[i] == t)return i;
  }
  return NOT;
}

int main(){
  int n,q,sum=0;
  int s[MAX];
  int t[MAX];
  int i,j;
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&t[i]);
    j = linearSearch(n,s,t[i]);
    if(j != -1)sum++;
  }


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



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <list>

using namespace std;


int main(void){
    int N, M, a, b;
    cin >> N >> M;
    priority_queue<int> que;
    vector<list<int>> data(100001);
    
    for(int n=0; n<N; n++){
        cin >> a >> b;
        data[a].push_back(b);
    }
    
    long long ans=0;
    for(int remain=1; remain<=M; remain++){
        for(int b : data[remain]) que.push(b);
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
int A,B;
bool odd = true;
cin >> A >> B;
if((A * B) % 2 == 0)odd = false;
if(odd)cout << "Odd";
else cout << "Even";

        return 0;
}

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

using namespace std;
#define rep(i,n) for ( int i =0; i < n ; i ++)
using ll =long long;

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n;
  cin>> n;
  int a[n];
  int b[n];
  int c[n-1];
  int sum =0;
  rep(i,n){
    cin >>a[i];}
  rep(i,n){
    cin >>b[i]; sum += b[i];
  }
  rep(i,n-1){
    cin >>c[i];
  }
  rep(i,n-1){
    if(a[i+1] ==a[i]+1){
      sum += c[a[i]-1];
    }
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,ans=0;cin>>N;
    vector<int> ma(N,0);
    REP(i,N)cin>>ma[i];
    for(int i=1;i<N-1;i++)if((ma[i-1]<ma[i]&&ma[i+1]>ma[i])||(ma[i-1]>ma[i]&&ma[i+1]<ma[i]))ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 long long int i,j,c,k,n;
 cin >> n >> k;
 long long int a[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 vector<long long int> v;
 set<long long int> s;
 i=0;
 v.push_back(1);
 s.insert(1);
 while(true)
 {
  i=a[i]-1;
  //cout << a[i] << " ";
  if(s.find(i+1)!=s.end())
  {
   if(k<=(long long int)v.size()-1)
   {
    cout << v[k];
    return 0;
   }
   for(j=0;j<(long long int)v.size();j++)
   {
    if(v[j]==i+1)
    {
     k-=j;
     c=(long long int)v.size()-j;
     //cout << j << " ";
     cout << v[(k%c)+j];
     return 0;
    }
   }
  }
  else
  {
   v.push_back(i+1);
   s.insert(i+1);
  }
 }
 return 0;
}

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

namespace ABC157B
{
    class Program
    {
        static void Main(string[] args)
        {
            var readJog = Read2Dim(3, 3);
            int N = int.Parse(Console.ReadLine());
            var readArr = Read1Dim(N);

            foreach (int num in readArr)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        readJog[i, j] = readJog[i, j] == num ? 0 : readJog[i, j];
                    }
                }
            }
            //
            bool ans = false;

            //判定
            for (int i = 0; i < 3; i++)
            {
                int sumR = readJog[i, 0] + readJog[i, 1] + readJog[i, 2];
                int sumC = readJog[0, i] + readJog[1, i] + readJog[2, i];

                int mult = sumR * sumC;
                if (mult == 0) ans = true;
            }
            {
                int sumCross1 = readJog[0, 0] + readJog[1, 1] + readJog[2, 2];
                int sumCross2 = readJog[2, 0] + readJog[1, 1] + readJog[0, 2];

                int mult = sumCross1 * sumCross2;
                if (mult == 0) ans = true;
            }

            if (ans) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }


        //読み取り用のclass
        static int[] Read1Dim(int row)
        {
            int[] array = new int[row];
            for (int i = 0; i < row; i++)
                array[i] = int.Parse(Console.ReadLine());

            return array;
        }

        static int[,] Read2Dim(int row, int col)
        {
            int[,] Jog = new int[row, col];
            for (int i = 0; i < row; i++)
            {
                var read = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < col; j++) Jog[i, j] = read[j];
            }

            return Jog;
        }
    }
}


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

    int main(){
        string a , b;
        cin >> a >> b;
        if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
        
        return 0;
    }

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

int main()
{
    string s, t;
    cin >> s >> t;
    int min_cnt = 1001;
    for(int i=0; i<=s.size()-t.size(); i++){
        int cnt = 0;
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != t[j]) cnt++;
        }
        if(min_cnt > cnt) min_cnt = cnt;
    }

    cout << min_cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
N = gets.to_i
A = (1..N).map { gets.split.map &:to_i }
([[0, 0, 0]] + A)
  .each_cons(2) {|(t0, x0, y0), (t1, x1, y1)|
    d = (y1-y0).abs+(x1-x0).abs 
    dt = t1-t0
    if d > dt or (d-dt)%2>0
      puts 'No'
      exit
    end
  }
puts 'Yes'


Measured memory_bytes: 10400
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int a[202020];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int z;
		scanf("%d", &z);
		a[z]++, a[z + 1]++, a[z + 2]++;
	}
	int maxi = 0;
	for (int i = 0; i <= 101010; i++)maxi = max(maxi, a[i]);
	printf("%d\n", maxi);
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        k: usize,
        a: [i64; n],
    }
    let mut ans = 0i64;
    for i in (0..40).rev() {
        let nxt = ans | 1 << i;
        let mut cnt = 0;
        for j in 0..n {
            let mut sum = 0;
            for l in j..n {
                sum += a[l];
                if (sum & nxt) == nxt { cnt += 1; }
            }
        }
        if cnt >= k {
            ans = nxt;
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int d;
	while(cin >> d){
	
	int sum = 0;
	for(int i = d; i < 600; i += d){
		sum += d * i * i;
	}
	
	cout << sum << endl;
	}
	
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// Combination {{{
// 組み合わせO(n)のc4_init実行後、O(1)でc4を実行
std::vector<ll> fac(3000000, 1), finv(3000000, 1), inv(3000000, 1);

void c4_init(ll m) {
    for (ll i = 2; i < 3000000; i++) {
        fac[i] = fac[i - 1] * i % m;
        inv[i] = m - inv[m%i] * (m / i) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
    }
}

ll c4(ll n, ll k, ll m) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % m) % m;
}
// }}}
// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
 public:
  int64_t a;

  explicit constexpr modint(const int64_t x = 0) noexcept :
    a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr modint pow(ll t) const {
    if (!t) return modint(1);
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};
// }}}

using mint = modint<1000000007>;

mint _sum (ll x, ll y) {
  return mint(c4(x+y+2, y+1, 1000000007)-1);
}

signed main() {
  c4_init(1000000007);
  ll x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  mint ans(0);
  ans += _sum(x2, y2);
  ans -= _sum(x2, y1-1);
  ans -= _sum(x1-1, y2);
  ans += _sum(x1-1, y1-1);
  cout<<ans.value()<<endl;
  return 0;
}


Measured memory_bytes: 70528
N,K=map(int,input().split())
S=input()
ans=[]
index=[]#0start, 0end
if S[0]=='0':
    index.append(0)

for i in range(1,len(S)):
    if S[i-1]!=S[i] and S[i]=='1':
        index.append(i-1)
    elif S[i-1]!=S[i] and S[i]=='0':
        index.append(i)

if S[-1]=='0':
    index.append(len(S)-1)

if K<len(index) and S[0]=='1':
    for i in range(len(index)//2-K+1):
        if i == 0:
            start=0
        else:
            start=index[2*i-1]+1
        if i==len(index)//2-K:
            end=len(S)-1
        else:
            end=index[2*(i+K)]-1
        ans.append(end-start+1)

elif K<len(index) and S[0]=='0':
    for i in range(len(index)//2-K+1):
        if i==0:
            start=0
        else:
            start=index[2*i-1]+1
        if i==len(index)//2-K:
            end=len(S)-1
        else:
            end=index[2*(i+K)]-1
        ans.append(end-start+1)


if K>=len(index)//2:
    print(len(S))
else:
    print(max(ans))

Measured memory_bytes: 8796
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdlib>

using namespace std;
typedef long long int ll;

bool debug = false;
#define show(x) if (debug) {cout << "" # x << " = " << x << endl;}
#define rep(x, a, b) for (int x = a; x < b; x++)

struct pohe {
  ll weight, dir;
  pohe(ll w, ll d) : weight(w), dir(d) {};
};

int main()
{
  ll w, h;
  cin >> w >> h;

  vector<pohe> java;

  rep (i, 0, w) {
    ll p;
    cin >> p;
    java.emplace_back(p, 0);
  }

  rep (i, 0, h) {
    ll q;
    cin >> q;
    java.emplace_back(q, 1);
  }

  sort(java.begin(), java.end(), [](auto a, auto b){return a.weight < b.weight;});

  ll sum = 0;
  
  for (auto p : java) {
    if (p.dir == 0) {
      sum += p.weight * (h + 1); w--;
    } else {
      sum += p.weight * (w + 1); h--;
    }
  }

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


Measured memory_bytes: 4464
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;cin >> n >> m;
    vector<int> mark(m+1,0);
    for(int i=1;i<=n;i++){
        int q;cin >> q;
        for(int j=1;j<=q;j++){
            int x;cin >> x;
            mark[x]++;
        }
    }
    cout << count(mark.begin(),mark.end(),n) << endl;
return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var line = (input.trim()).split("\n");

for(i = 0; i < line.length; i++) {
  var val = line[i].split(" ").map(Number);
  var res = val[0] + val[1];

  console.log((res + "").length);
}

Measured memory_bytes: 16088