akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define  p5         100007
#define  p6          1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair < int, int>
#define  pq         priority_queue
#define  pb         push_back
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
	ll n,i,j,cnt=0,k;
	cin>>n>>k;
	for(i=0;i<n;i++){
        ll x;
        cin>>x;
        if(x>=k)
            cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
//https://prosenc.blogspot.com/2016/
//https://www.sanfoundry.com/dynamic-programming-solutions-longest-increasing-subsequence-problem/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,ans=1;
  cin>>a>>b>>c;
  
  if(a!=b){
    ans+=1;
  }
  else{
    ans+=0;
  }
  
  if(a!=c&&b!=c){
    ans+=1;
  }
  else{
    ans+=0;
  }
  
  cout<<ans<<endl;
}

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

int n, s[1001];
double sum = 0, m = 0, d_sum = 0, d = 0, sd = 0;


int main(){
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; i++){
      cin >> s[i];
      sum += s[i];
    }
    m = sum/n;
    sum = 0;

    for(int i = 0; i < n; i++){
      d_sum += pow(s[i] - m, 2);
    }
    sd = sqrt(d_sum / n);
    printf("%.8f\n", sd);
    d_sum = 0;
  }
}

Measured memory_bytes: 3216
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, sort)
import Control.Monad (forM_)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  -- n >= 2
  -- xs <- U.fromListN n . sort . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  xs <- mergeSortBy compare . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let (xs0, xs1) = U.span (< 0) xs
  let (r, zs)
        | U.length xs0 == 0 =
            let xs10 = U.head xs1
                xs11 = U.tail xs1
                loop 0 !y = (U.head xs11, y) : []
                loop i !y = let !z = xs11 U.! i
                            in (y, z) : loop (i - 1) (y - z)
            in (U.sum xs11 - xs10, loop (U.length xs11 - 1) xs10)
        | U.length xs1 == 0 =
            let xs00 = U.init xs0
                xs01 = U.last xs0
                loop i !y | i < 0 = []
                          | otherwise = let !z = xs00 U.! i
                                        in (y, z) : loop (i - 1) (y - z)
            in (xs01 - U.sum xs00, loop (U.length xs00 - 1) xs01)
        | otherwise =
            let xs00 = U.init xs0
                xs01 = U.last xs0
                xs10 = U.head xs1
                xs11 = U.tail xs1
                loopP i !y | i < 0 = (xs10, y) : loopN (U.length xs00 - 1) (xs10 - y)
                           | otherwise = let !z = xs11 U.! i
                                         in (y, z) : loopP (i - 1) (y - z)
                loopN i !y | i < 0 = []
                           | otherwise = let !z = xs00 U.! i
                                         in (y, z) : loopN (i - 1) (y - z)
            in (U.sum xs1 - U.sum xs0, loopP (U.length xs11 - 1) xs01)
  print r
  forM_ zs $ \(x,y) ->
    putStrLn $ concat [show x, " ", show y]

---

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result


Measured memory_bytes: 6908
using namespace std;
#include <bits/stdc++.h>
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,arr[200005];
    cin>>n;
    ll st=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        st=st^arr[i];
    }

    for(i=0;i<n;i++)
    {
        cout<<(st^arr[i])<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5204
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			string s = cin.Next();
			int cnt = 0;
			for (int i = 1; i < n; i++) {
				if (s[i] == 'E') {
					++cnt;
				}
			}

			int ans = cnt;
			for (int i = 1; i < n; i++) {
				if (s[i] == 'E') {
					--cnt;
				}

				if (s[i - 1] == 'W') {
					++cnt;
				}

				ans = Math.Min(ans, cnt);
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13212
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	LL x, y;
	LL ans = 0;
	cin >> x >> y;
	if (x == y) {
		// 10 10
		ans = 0;
	}
	else if (x*-1 == y || y*-1 == x) {
		// -10 10    10 -10
		ans = 1;
	}
	else if (x >= 0 && y > 0) {
		//10 20     20 10
		ans = abs(x - y);
		if (x > y) {
			ans += 2;
		}
	}
	else if (x < 0 && y < 0){
		// -10 -20      -20 -10
		ans = abs(x - y);
		if (x > y) {
			ans += 2;
		}
	}
	else {
		// 10 -20   -20 10   10 -5   -5 10   -2 0   0 -2   2 0   0 2
		if (y == 0) {
			if (x > 0) {
				ans += 1;
			}
			ans += abs(x);
		}
		else {
			ans = abs(x - (y*-1));
			ans += 1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
void main(){
	long n = _scan!long();
	long[] stat = [0, 0, 0];
	bool legitimate_travel = true;
	foreach(i; 0..n){
		long[] tmp_stat = _scanln!long();
		long tdif = tmp_stat[0] - stat[0]; // 所要時間
		long xdif = abs( tmp_stat[1] - stat[1] ); // x方向移動距離
		long ydif = abs( tmp_stat[2] - stat[2] ); // y方向移動距離
		// 移動可能判定
		if( xdif+ydif <= tdif ){
			// tdifで移動できる範囲である
			if( tdif%2 == (xdif+ydif)%2 ){
				// かつ, 余らず移動できるか
				stat = tmp_stat; // 移動できれば位置を変更
			}else legitimate_travel = false;
		}else legitimate_travel = false;
		
		if(legitimate_travel == false)break;
	}
	writeln(legitimate_travel?"Yes":"No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main()
{
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++)
	{
		char s[128]{};
		scanf("%s", s);
		printf("%s\n%s\n", s, s);
	}
	
	return 0;
}

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

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

    int L[M];
    int R[M];

    for(int i = 0; i < M; i++){
        cin >> L[i] >> R[i];
    }

    int L_sta = 0;
    int R_sta = N + 1;

    L_sta = L[0];
    R_sta = R[0];

    for(int i = 1; i < M; i++){
        if(L_sta < L[i]){
            L_sta = L[i];
        }
        if(R_sta > R[i]){
            R_sta = R[i];
        }
    }

    int k = R_sta - L_sta + 1;

    if(k < 0){
        cout << 0 << endl;
    }else{
        cout << k << endl;
    }
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    uf = UnionFind(N)
    for a, b in zip(A, B):
        uf.union(a-1, b-1)
    sizes = [uf.size(r) for r in uf.roots()]
    return max(sizes)

# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    print(solve(N, M, A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 30036
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int n;
  cin >> n;
  vi data1(n);
  vi data2(n);
  rep(i,n) cin >> data1[i];
  rep(i,n) cin >> data2[i];
  vi data3(n);
  rep(i,n) data3[i] = data1[i] - data2[i];
  int ans = 0;
  rep(i,n) if(data3[i] >= 0) ans += data3[i];
  cout << ans;
  hinata;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)




int main(){
    int n,k;
    cin>>n>>k;
    int ans=INT_MAX;
    vector<int> h(n);
    rep(i,n)cin>>h[i];
    sort(h.begin(),h.end());
    rep(i,n-k+1){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 768
/*
AizuOnline A2331
A Way to Invite Friends
13/01/08
*/
#define DEBUGx 1
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
#define min(x,y) (((x)<(y))?(x):(y))
//Global data section
int N;
int a[100000];
int b[100000];
int ab[200000]; // merge A+B
//
// desc
int comp(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int search_run(int ** ar,int num,int * limit)
{
  int i=0;
  while(**ar == num && *ar < limit)
    {
      *ar=*ar+1;
      i++;
    }
  return(i);
}
print()
{
  int i;
  printf("a:");
  for(i=0;i<N;i++)
    printf("%d ",a[i]);
  printf("\nb:");
  for(i=0;i<N;i++)
    printf("%d ",b[i]);
  printf("\nab:");
  for(i=0;i<N*2;i++)
    printf("%d ",ab[i]);
  printf("\n");
}
main()
{
  int s,i,j,nin,w1,w2;

  int *pa,*pb,*pab,**ppa,**ppb,**ppab;

  
  if(EOF != scanf("%d",&N))
    {
      for(i=0;i<N;i++)
	{
	  scanf("%d %d",&(a[i]),&(b[i]));
	}
      //print();
      memmove(ab,a,N*sizeof(int));
      memmove(ab+N,b,N*sizeof(int));

      qsort(a,N,sizeof(int),comp);
      qsort(b,N,sizeof(int),comp);
      qsort(ab,2*N,sizeof(int),comp);
#ifdef DEBUG
      print();
#endif
      if(N == 1)
	{
	  if(a[0] <= 2 && b[0] > 1)
	    printf("%d\n",1);
	  else
	    printf("%d\n",0);
	  goto END;
	}
      /*
      if(a[n-1] < N && b[0] > N)
	{
	  
	}
      */
      s=ab[0];
      nin=0;pa=a;pb=b;pab=ab;ppa=&pa;ppb=&pb;ppab=&pab;
      while(*ppa < pa +N && *ppb < pb + N && *ppab < pab+2*N && s)
	{
	  w1=search_run(ppb,s,a+N);
	  w2=search_run(ppa,s,a+N);
	  nin += w1;
#ifdef DEBUG
	  printf("s:%d nin:%d w1:%d w2:%d \n",s,nin,w1,w2);	  
#endif
	  if(nin+1 >= s)
	    {	    
	      printf("%d\n",s-1); //except me 
	      goto END;
	    }
	  if(nin == N && a[0] < N)     // call all friends
	    {	    
	      printf("%d\n",N);  
	      goto END;
	    }
	  nin -= w2;
	  search_run(ppab,s,ab+2*N);
	  s = **ppab;
	}
    }
    printf("%d\n",0);
 END:
return(0);
}

Measured memory_bytes: 3236
/*
ID: duttonl1
TASK: I_Coins.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "; ";
    err(++it, args...);
}


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

double dp[3001][3001] = {1};
double C[3001];
int n;
void run() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> C[i];

    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i-1][0] * (1-C[i]);
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= i; j++) { 
            dp[i][j] = dp[i-1][j] * (1-C[i]) + dp[i-1][j-1]*C[i];
        }
    cout << fixed << setprecision(10);
    cout << accumulate(dp[n]+((n+1)>>1),dp[n]+n+1,.0) << endl;
}




Measured memory_bytes: 46464
N,M = map(int,raw_input().split())
ds = []
while 1:
    s,t,e = map(int,raw_input().split())
    if s == t == e == 0: break
    ds.append([s-1,t-1,e])
L = int(raw_input())
for loop in xrange(L):
    b = map(int,raw_input().split())
    c = [0]*N
    for s,t,e in ds:
        c[s] += e*b[t]
    print " ".join(map(str,c))

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


char s[3];

int main() { 
  scanf("%s", &s[0]);
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == '9') {
      cout << '1';
    } else {
      cout << '9';
    }
  }
  return 0;
} 

Measured memory_bytes: 256
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

int n, m;
vector< P > es;

void judge(vector<int>& depth, int l, int r){
    vector<int> s(n), t(n);
    rep(i, m){
        int u = es[i].first;
        int v = es[i].second;
        if(l <= depth[u] && depth[u] <= r && l <= depth[v] && depth[v] <= r){
            ++t[u];
            ++s[v];
        }
    }

    bool flag = true;
    vector<int> ans;
    rep(i, n){
        if(depth[i] < l || r < depth[i]){
            continue;
        }
        flag &= (s[i] == 1 && t[i] == 1);
        ans.emplace_back(i);
    }

    if(flag){
        cout << ans.size() << endl;
        rep(i, ans.size()){
            cout << ans[i] + 1 << endl;
        }
        exit(0);
    }

    return;
}

void dfs(int v, int cnt, vector<bool>&visited, vector<int>& depth, const vector< vector<int> >& g){
    visited[v] = true;
    depth[v] = cnt;

    for(auto to : g[v]){
        if(visited[to]){
            judge(depth, depth[to], cnt);
        }else{
            dfs(to, cnt + 1, visited, depth, g);
        }
    }

    depth[v] = -1;
    return;
}

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

    cin >> n >> m;

    vector< vector<int> > g(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        g[--a].emplace_back(--b);
        es.emplace_back(a, b);
    }

    vector<bool> visited(n, false);
    vector<int> depth(n, -1);

    rep(i, n){
        if(!visited[i]){
            dfs(i, 0, visited, depth, g);
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N, K;
int main()
{
   cout << fixed << setprecision(10);
   cin >> N >> K;
   cout << int(log(N) / log(K)) + 1 << endl;
   return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K, D;
    cin >> N >> K;
    D = 0;
    for(int i = 0; i < K; i++) {
        int dislike; cin >> dislike;
        D |= (1 << dislike);
    }
  	D = ~D;
    for(int i = N; i < N*100; i++) {
        bool valid = true;
        for(int j = i; j > 0 && valid; j /= 10) {
            valid = D & (1 << (j%10));
        }
        if(valid) {
            cout << i;
            break;
        }
    }
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

bool graph[50][50];
bool visited[50];
int a[50],b[50];
int n,m;

void dfs(int v){
	visited[v]=true;

	for (int i = 0; i < n; ++i){
		if(graph[v][i]==false)continue;
		if(visited[i]==true)continue;
		dfs(i);
	}
}

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

	for (int i = 0; i < m; ++i){
		cin>>a[i]>>b[i];
		graph[a[i]-1][b[i]-1]=graph[b[i]-1][a[i]-1]=true;
	}

	int ans=0;
	for (int i = 0; i < m; ++i){
		graph[a[i]-1][b[i]-1]=graph[b[i]-1][a[i]-1]=false;

		for (int j = 0; j < n; ++j){
			visited[j]=false;
		}

		dfs(0);

		bool bridge=false;
		for (int j = 0; j < n; ++j){
			if(visited[j]==false)bridge=true;
		}
		if(bridge)ans+=1;

		graph[a[i]-1][b[i]-1]=graph[b[i]-1][a[i]-1]=true;
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
a = gets.split.map(&:to_i)

if n == 1
  puts 0
  exit
end
c = 0
(1..(n - 1)).each do |i|
  d = [a[i - 1] - a[i], 0].max
  a[i] += d
  c += d
end
puts c


Measured memory_bytes: 27948
#include <iostream>
#include <vector>
 
int main()
{
    constexpr int INF = 1000000000;
    
    int h = 0;
    int n = 0;
    std::cin >> h >> n;
    
    std::vector<std::vector<int>> dp(n + 1, std::vector<int>(h + 1, INF));
    dp.at(0).at(0) = 0;
    
    for(int i = 0; i < n; ++i)
    {
        int a = 0;
        int b = 0;
        std::cin >> a >> b;
        for(int j = 0; j <= h; ++j)
        {
            dp.at(i + 1).at(j) = std::min(dp.at(i + 1).at(j), dp.at(i).at(j));
            dp.at(i).at(std::min(j + a, h)) = std::min(
                dp.at(i).at(std::min(j + a, h)),
                dp.at(i).at(j) + b);
        }
    }
    
    std::cout << dp.at(n).at(h) << std::endl;
}

Measured memory_bytes: 39552
# frozen_string_literal: true

require 'set'

a, b, c, d = gets.split(' ').map!(&:to_i)

alice = Set.new(a..b)
bob = Set.new(c..d)
ans = (alice & bob).size

ans -= 1 if ans > 0 # 秒数なので最初の要素はカウントしない

puts ans


Measured memory_bytes: 2172
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T x; cin >> x; return x; }

struct vec2d {
	int x, y;
	vec2d() {}
	vec2d(int x, int y) :x(x), y(y) {}
	double norm()const {
		return hypot(x, y);
	}
	vec2d operator+(const vec2d&v)const {
		return vec2d(x + v.x, y + v.y);
	}
	vec2d operator-(const vec2d&v)const {
		return vec2d(x - v.x, y - v.y);
	}
	bool operator==(const vec2d&v)const {
		return x == v.x && y == v.y;
	}
	bool operator!=(const vec2d&v)const {
		return !operator==(v);
	}
	static double cos_arg(const vec2d&v0, const vec2d&v1) {
		return (v0.x * v1.x + v0.y * v1.y) / v0.norm() / v1.norm();
	}
	static double cross_product(const vec2d&v0, const vec2d&v1) {
		return v0.x * v1.y - v0.y * v1.x;
	}
};
vector<vec2d>get_convex_hull(vector<vec2d>input) {
	sort(ALL(input), [](vec2d v0, vec2d v1) {return v0.y < v1.y || (v0.y == v1.y) && v0.x < v1.x; });
	vector<vec2d>output;
	output.push_back(input[0]);
	output.push_back(input[1]);
	for (int i = 2; i < input.size(); ++i) {
		output.push_back(input[i]);
		while (output.end() - 2 != output.begin() && vec2d::cross_product(*(output.end() - 3) - *(output.end() - 2), *(output.end() - 1) - *(output.end() - 2)) > 0) {
			output.erase(output.end() - 2);
		}
	}
	output.push_back(input[input.size() - 2]);
	for (int i = input.size() - 3; i >= 0; --i) {
		output.push_back(input[i]);
		while (output.end() - 2 != output.begin() && vec2d::cross_product(*(output.end() - 3) - *(output.end() - 2), *(output.end() - 1) - *(output.end() - 2)) > 0) {
			output.erase(output.end() - 2);
		}
	}
	output.pop_back();
	return output;
}
signed main() {
	int n = in();
	vector<vec2d>point(n);
	REP(i, n) {
		int x = in(), y = in();
		point[i] = (vec2d(x, y));
	}
	vector<vec2d>res = get_convex_hull(point);
	cout << res.size() << endl;
	REPC(i, res) {
		cout << i.x << ' ' << i.y << endl;
	}
}


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

int main(){
  string S;
  cin>>S;
  map<char,int> T;
  for(int i=0;i<S.size();++i){
    ++T[S.at(i)];
  }

  bool ans=true;
  if(T.size()!=2){
    ans=false;
  }
  else{
    for(auto p:T){
      if(p.second!=2){
        ans=false;
      }
    }
  }

  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			B[A[i]-1] = i+1;
		}
		for(int i = 0; i < N; i++) {
			System.out.print(B[i] + " ");
		}
	}
}

Measured memory_bytes: 62668
A, B, C, D = map(int, input().split())

CSeries = B//C -(A-1)//C
DSeries = B //D - (A-1) //D

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

LCM = int(C*D/ gcd(C,D))

CDSeries = B//LCM - (A-1)//LCM

Answer2 = B-A +1 - CSeries - DSeries + CDSeries

print(Answer2)

Measured memory_bytes: 3064
object Main extends App {
  val n = io.StdIn.readLine().toInt
  var seq = Seq[(String, Int, Int)]()
  for {i <- 1.to(n)} {
    val Array(s, p) = io.StdIn.readLine().split(" ")
    seq :+= (s, p.toInt, i)
  }
  seq.sorted.sortWith((i, j) => {
    if (i._1 != j._1) {
      i._1 < j._1
    } else {
      i._2 > j._2
    }
  }).foreach(i => println(i._3))
}

Measured memory_bytes: 27444
from enum import IntEnum


class Direction(IntEnum):
    NORTH = 0
    EAST = 1
    SOUTH = 2
    WEST = 3


class Dice:
    """Dice class implements the structure of a dice
    having six faces.
    """
    def __init__(self, v1, v2, v3, v4, v5, v6):
        self.top = 1
        self.heading = Direction.NORTH
        self.values = [v1, v2, v3, v4, v5, v6]

    def to_dice_axis(self, d):
        return (d - self.heading) % 4

    def to_plain_axis(self, d):
        return (self.heading + d) % 4

    def roll(self, d):
        faces = [[(2, Direction.NORTH), (6, Direction.NORTH),
                  (6, Direction.WEST), (6, Direction.EAST),
                  (6, Direction.SOUTH), (5, Direction.SOUTH)],
                 [(4, Direction.EAST), (4, Direction.NORTH),
                  (2, Direction.NORTH), (5, Direction.NORTH),
                  (3, Direction.NORTH), (4, Direction.WEST)],
                 [(5, Direction.SOUTH), (1, Direction.NORTH),
                  (1, Direction.EAST), (1, Direction.WEST),
                  (1, Direction.SOUTH), (2, Direction.NORTH)],
                 [(3, Direction.WEST), (3, Direction.NORTH),
                  (5, Direction.NORTH), (2, Direction.NORTH),
                  (4, Direction.NORTH), (3, Direction.EAST)]]
        f, nd = faces[self.to_dice_axis(d)][self.top-1]
        self.top = f
        self.heading = self.to_plain_axis(nd)

    def value(self):
        return self.values[self.top-1]


def run():
    values = [int(v) for v in input().split()]
    dice = Dice(*values)
    for d in input():
        if d == 'N':
            dice.roll(Direction.NORTH)
        if d == 'E':
            dice.roll(Direction.EAST)
        if d == 'S':
            dice.roll(Direction.SOUTH)
        if d == 'W':
            dice.roll(Direction.WEST)

    print(dice.value())


if __name__ == '__main__':
    run()



Measured memory_bytes: 6352
import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.Counter(arr)
keys=cnt.keys()
keys=sorted(keys,reverse=True)
a=0
b=0
for key in keys:
  if b!=0:
    break
  if a==0:
    if cnt[key]>=2:
      a=key
      if cnt[key]>=4:
        b=key
  else:
    if cnt[key]>=2:
      b=key
print(a*b)

Measured memory_bytes: 18600
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

  string s; cin >> s;

  auto checkb = [&](int i, int j){
    FOR(x, i, j){
      if(s[x] == '#' && s[x+1] == '#') return false;
    }

    return true;
  };

  auto checkw = [&](int i, int j){
    FOR(x, max(1, i), min(n-1, j+1)){
      if(s[x-1] == '.' && s[x] == '.' && s[x+1] == '.') return true;
    }

    return false;
  };

  if(!checkb(a, c) || !checkb(b, d) || (c > d && !checkw(b, d)))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(void)
{
    int num[6],sta;
    for(int i=0;i<5;i++){
        cin>>num[i];
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(num[j]<num[j+1]){
                sta=num[j];
                num[j]=num[j+1];
                num[j+1]=sta;
            }
        }
    }
    for(int i=0;i<5;i++){
        cout<<num[i];
        if(i==4)cout<<"\n";
        else cout<<" ";
    }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    ll N,A,B;
    cin>>N>>A>>B;

    ll ans = ((N/(A+B))*A);
    ans += min(N%(A+B),A);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
H,W,h,w=map(int,input().split())
if H%h==0 and W%w==0:
	print("No")
else:
	print("Yes")
	for i in range(H):
		print(' '.join("-1000" if i%h or j%w else str(1000*(h*w-1)-1) for j in range(W)))

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

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


void printV(vector<int>A){
  rep(i,A.size()){
    //cout << A[i] << " ";
  }
  //cout << endl;
}
bool eq(vector<int>A, vector<int>B){
  bool a = true;
  rep(i,A.size()){
    if(A[i] != B[i]){
      printV(A);
      printV(B);
      a = false;
      break;
    }
  }
  return a;
}

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

  vector<int>A(n);
  int a,b;
  vector<int>P;
  vector<int>Q;
  rep(i,n){
    int x;
    cin >> x;
    P.push_back(x);
  }
  rep(i,n){
    int x;
    cin >> x;
    Q.push_back(x);
  }
  rep(i,n)A[i]=i+1;
  
  
  int i = 0;
  do{
    if(eq(A,P))a=i;
    if(eq(A,Q))b=i;
    i++;
    //printV(A);
    //cout << i;
    //cout << a << endl;
  }while(next_permutation(A.begin(),A.end()));
  cout << abs(a-b) <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int M,N,L;

	while(1)
	{
		int sum = 0;
		int count = 0;
		int ans;
		cin >> L;

		if(L == 0)
		{
			break;
		}

		for(int i = 1; i <= 12; i++)
		{

			cin >> M >> N ;

			sum += M - N;

			if(sum >= L && count < 1)
				{
					count++;
					ans = i;
				}
		}

		if(sum >= L && count < 2)
				{
					cout << ans << endl;
				}	
		else
		{
			cout << "NA" << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 1160
s=gets.chomp
k=gets.to_i

ord_a = 'a'.ord
ret = []
s.each_char do |c|
    n = (26 - (c.ord - ord_a))%26
    if n <= k
        ret << 'a'
        k -= n
    else
        ret << c
    end
end

ret[-1] = (ret[-1].ord + (k%26)).chr
puts ret.join

Measured memory_bytes: 20488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




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

   
    int n, m;
    cin >> n >> m;
    
    set<int> s;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            s.insert(i);
            s.insert(m / i);
        }
    }
    // for (auto e : s) cout << e << " "; cout << endl;
    for (auto it = s.end(); ; --it) { // n個の要素がすべてeの倍数
        if (it == s.end()) continue;
        // out(*it);
        if ((ll)*it * n <= m && (m - (ll)*it * n) % *it == 0) {
            out(*it);
            return 0;
        }
        if (it == s.begin()) break;
    }
}



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

using namespace std;

const int MaxN = 100005;

int n;
long long Mod;
vector<int> Adj[MaxN];
long long f[MaxN], g[MaxN];
long long pre[MaxN], suf[MaxN];

void DFS1(int u, int p)
{
    f[u] = 1;
    for (auto v : Adj[u])
    {
        if (v != p)
        {
            DFS1(v, u);
            f[u] = (f[u] * (f[v] + 1)) % Mod;
        }
    }
}

void DFS2(int u, int p)
{
    int sz = Adj[u].size();
    pre[0] = suf[sz] = suf[sz + 1] = 1;
    int Count = 0;
    for (auto v : Adj[u])
    {
        if (v != p)
        {
            Count++;
            pre[Count] = (pre[Count - 1] * (f[v] + 1)) % Mod;
        }
    }
    for (int i = sz - 1; i >= 0; i--)
    {
        int v = Adj[u][i];
        if (v != p)
        {
            suf[Count] = (suf[Count + 1] * (f[v] + 1)) % Mod;
            Count--;
        }
    }
    for (auto v : Adj[u])
    {
        if (v != p)
        {
            Count++;
            g[v] = ((pre[Count - 1] * suf[Count + 1]) % Mod * g[u] + 1) % Mod;
        }
    }
    for (auto v : Adj[u])
    {
        if (v != p)
        {
            DFS2(v, u);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> Mod;
    int u, v;
    for (int i = 1; i < n; i++)
    {
        cin >> u >> v;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }
    DFS1(1, -1);
    g[1] = 1;
    DFS2(1, -1);
    for (int i = 1; i <= n; i++)
    {
        cout << (f[i] * g[i]) % Mod << '\n';
    }
    return 0;
}

Measured memory_bytes: 16212
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int till = s.size() / 2;
  rep(i, till) {
    if (s[i] != s[s.size()-(1+i)]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI ans(n+1, 0);
  REP2(int, x, 1, 101)
  {
    REP2(int, y, 1, 101)
    {
      REP2(int, z, 1, 101)
      {
        int v = x*x+y*y+z*z+x*y+y*z+z*x;
        if (v > n) break;
        ++ans[v];
        // cout << x << " " << y << " " << z << " : v = " << v << endl;
      }
    }
  }
  REP2(int, i, 1, n+1) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++)
    {
        if(i%2==0)
        {
            if(a%2==1)
            {
                a=a-1;
            }
            b=b+a/2;
            a=a/2;
        }
        else
        {    
            if(b%2==1)
            {
                b=b-1;
            }
            a=a+b/2;
            b=b/2;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
define_method :max, -> (a,b) { a > b ? a : b }
define_method :min, -> (a,b) { a < b ?  a : b }
define_method :swap, -> (a,b) { a, b = b, a }
define_method :rep, -> (num, &block) { num.times do |i| block.call(i) end }
define_method :repl, -> (st,en, &block) { st.upto en-1 do |i| block.call(i) end }
define_method :array, -> (size,init = nil) { Array.new(size){init} }
define_method :darray, -> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :gi, -> () { gets.split.map(&:to_i) }
define_method :gs, -> () { gets.chomp }
define_method :putall, -> (obj) { obj.each do |o| puts o end }
ans = []
loop{
num = gets.to_i
break if num == 0
score = 0
rep 600 / num do |i|
	score += num*num*num*i*i
end

ans << score
}

putall ans

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


int N, X;
vi x;

unsigned long long f(int m) {
	vi sizes(m);
	unsigned long long cand = N * 1LL * X;
	for (int j = N, p = 0; j >= 1; --j, ++p) {
		p %= m;
		if (!sizes[p])
			cand += X + x[j];

		++sizes[p];

		cand += (sizes[p] + 1) * 1ULL * (sizes[p] + 1) * (x[j] - x[max(j - m, 0)]);

	}
	return cand;
}


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);


	cin >> N >> X;

	x.assign(N + 1, 0);

	for (int i = 1; i <= N; ++i)
		cin >> x[i];

	unsigned long long ans = ULLONG_MAX;

	int l = 1, r = N;
	while (r - l > 3) {
		int diff = r - l;
		int candL = l + diff / 3, candR = r - diff / 3;
		if (f(candL) < f(candR))
			r = candR;
		else
			l = candL;
	}
	for (int i = l; i <= r; ++i)
		ans = min(ans, f(i));

	cout << ans << '\n';
	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 4824
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

int main(){
	ll z;
	while(cin >> z && z){
		ll minc = INF;
		ll z3 = z * z * z;
		for(ll i = 1; i < z; i++){
			ll i3 = i * i * i;
			for(ll j = 1; j <= i; j++){
				ll j3 = j * j * j;
				if(z3 >= i3 + j3){
					minc = min(minc , z3 - (i3 + j3));
				}
			}
		}
		cout << minc << endl;
	}
	return 0;
}

Measured memory_bytes: 864
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++){
            int h = sc.nextInt();
            if(h >= k)
                sum += 1;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 47288