akhauriyash/Code-Regression huggingface dataset:
import Data.List
import Data.Ord

main = do 
    [n,m] <- map read . words <$> getLine :: IO [Int]
    xs <- sort . map read . words <$> getLine :: IO [Int]
    let xs' = sortBy (comparing Down) $ map snd $ scanl' (\(a, _) x -> (x, abs $ a - x)) (head xs, 0) (tail xs)
    print $ sum xs' - (sum $ take (n-1) xs')

Measured memory_bytes: 35580
<?php
$n = int();
$a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
echo $a[$n-1];

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define ll int 
#define int long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define F first
#define S second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int MOD=MOD1;
int ar[1000005];
int prime[1000005]; 
map<int, int> max_map; 
int mod=MOD;  
int MAX=1000005;

// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
ll lcmModuloM(int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
} 
int32_t main()
{
     int n;
     cin>>n;
     sieve();
     rep(i,0,n)cin>>ar[i];
     int x=lcmModuloM(n);
     int ans=0;
     rep(i,0,n)
     {
     	 int temp=power(ar[i],mod-2);
     	 ans=ans+temp;
     	 if(ans>=MOD)ans-=MOD;
     }
     ans=(ans*x)%mod;
     cout<<ans<<endl;
     return 0;     
}

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

int L[250002],R[250002],cnt;//分割したものをL,Rとする

//統治
void merge( int A[], int left, int mid, int right, int n ) {
  int n1 = mid - left;
  int n2 = right - mid;
  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];  
  L[n1] = R[n2] = 2000000000;//番兵
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++; //比較回数をカウント
    if ( L[i] <= R[j] ) {
      A[k] = L[i];
      i = i + 1;
    } else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

//分割
void mergeSort( int A[], int left, int right, int n ) {
  if ( left+1 < right ) {
    int mid = ( left + right ) / 2;
    mergeSort( A, left, mid, n );
    mergeSort( A, mid, right, n );
    merge( A, left, mid, right, n );
  }
}

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

  mergeSort( A, 0, n, n);
  
  for ( int i = 0; i < n-1; i++ ) cout << A[i] << " ";
  cout << A[n-1] << endl;
  cout << cnt << endl;//比較回数を出力 
  return 0;
}

Measured memory_bytes: 5072
#include <iostream>

using namespace std;

typedef long long ll;
ll N,nblue,nred;
ll ans;

int main() {
	cin>>N>>nblue>>nred;
	ll nrepetitions = (N-1) / (nblue+nred);
	ans += nrepetitions * nblue;
	ans += min(nblue, N - (nblue+nred) * nrepetitions);
	cout<<ans<<'\n';
}

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

long long N, K, X[100009], minx = (1LL << 60);

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> X[i];
	for (int i = 0; i <= N - K; i++) {
		long long L = X[i], R = X[i + K - 1];
		if (L <= 0 && R >= 0) { minx = min(minx, min(-L, R) + abs(R - L)); }
		else if (R < 0) { minx = min(minx, -L); }
		else { minx = min(minx, R); }
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n;
	int i;
	int red = 0, blue = 0;
	scanf("%d", &n);

	char* s = (char*)calloc(n, sizeof(char));
	scanf("%s", s);
	for (i = 0; i < n; i++) {
		if (s[i] == 'R') {
			red++;
			if (red > n / 2.0) {
				printf("Yes\n");
				break;
			}
		}
		else if (s[i] == 'B') {
			blue++;
			if (blue >= n / 2.0) {
				printf("No\n");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var X int
	fmt.Scan(&X)
	A := (X / 500)       // 500円を取れるだけとる
	B := (X - 500*A) / 5 // 残りから5円を取れるだけとる
	fmt.Println(A*1000 + B*5)
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

const int mod = 1000000007;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> S(n), T(m);
  for (int i = 0; i < n; i++) { scanf("%d", &S[i]); }
  for (int i = 0; i < m; i++) { scanf("%d", &T[i]); }
  vector<int> dp(m), ndp(m);
  for (int i = 0; i < n; i++) {
    int sum = 0;
    ndp = dp;
    for (int j = 0; j < m; j++) {
      if (S[i] != T[j]) {
        ndp[j] += sum;
        ndp[j] %= mod;
        continue;
      }
      sum += 1 + (j > 0 ? dp[j - 1] : 0);
      sum %= mod;
      ndp[j] += sum;
      ndp[j] %= mod;
    }
    ndp.swap(dp);
  }
  long long ans = 1 + dp[m-1];
  ans %= mod;
  ans += mod;
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> S(N);

  for (int i=0; i<N; i++){
    cin>> S.at(i);
  }

 int q;
 cin>>q;
 vector<int> t(q);

 for(int i=0; i<q;i++){
   cin >> t.at(i);
 }

 int c=0;
 for(int i=0;i<q;i++){
   c += binary_search(S.begin(),S.end(),t.at(i));
 }

 cout<<c<<endl;
}


Measured memory_bytes: 3288
K, X = map(int, input().split())
k = K - 1
if X - k < -1000000:
    result = range(-1000000, -1000000+K)
elif X + k > 1000000:
    result = range(1000000-k, 1000001)
else:
    result = range(X-k, X+K)
for i in result:
    print(str(i) + ' ', end='')


Measured memory_bytes: 3060
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int k;
	std::cin >> k;
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	print(a[k-1]);
	return 0;
}


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


using namespace std;

typedef long long ll;

int n = 0;

int main(){
    cin >> n;
    vector<ll> a;
    ll x = 0;
    ll ans = 0, cnt = 0;
    for(int i = 0; i < n; ++i){
        cin >> x;
        a.push_back(x);
    }
    for(int i = 0; i < n-1; ++i){
        if(a[i] >= a[i+1]){
            ++cnt;
        }
        else{
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1400
N, M = map(int, input().split())
I = []
for _ in range(M):
    I.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0

for i in range(2 ** N):
    flg = 1
    for j in range(M):
        o = 0
        for k in range(1, I[j][0]+1):
            if (i >> (I[j][k]-1)) & 1:
                o += 1
        if o % 2 != p[j]:
            flg = 0
            break
    if flg == 1:
        ans += 1
print(ans)

Measured memory_bytes: 9216
import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
E = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

mod = [3, 1, 2]
ans = [0 for i in range(n)]
count = [0, 0]

def bfs(cur, pre, c):
    stack = deque([[cur, pre, c]])
    while stack:
        cur, pre, c = stack.popleft()
        count[c % 2] += 1
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, c+1])

def case1(cur, pre, c, i):
    stack = deque([[cur, pre, c]])
    while stack:
        cur, pre, c = stack.popleft()
        t = c % 2
        if t == i:
            ans[cur] = mod[0]
            mod[0] += 3
        else:
            if mod[1] <= n:
                ans[cur] = mod[1]
                mod[1] += 3
            elif mod[2] <= n:
                ans[cur] = mod[2]
                mod[2] += 3
            else:
                ans[cur] = mod[0]
                mod[0] += 3
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, c+1])

def case2(cur, pre, c):
    stack = deque([[cur, pre, c]])
    while stack:
        cur, pre, c = stack.popleft()
        t = c % 2
        if mod[t+1] <= n:
            ans[cur] = mod[t+1]
            mod[t+1] += 3
        else:
            ans[cur] = mod[0]
            mod[0] += 3
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, c+1])

bfs(0, -1, 0)

if count[0] < (n + 2)// 3:
    case1(0, -1, 0, 0)
elif count[1] < (n + 2) // 3:
    case1(0, -1, 0, 1)
else:
    case2(0, -1, 0)

print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 63468
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n;

void solve(){
  cin >> n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

int main(){
    FIN;
    int n;
    cin >> n;
    vector<double> p(n, 0);
    forn(i, n) cin >> p[i];

    vector<double> dp(n + 1, 0), nex(n + 1, 0);

    dp[1] = p[0];
    dp[0] = 1 - p[0];

    forr(i,1,n){
        nex[0] = dp[0] * (1 - p[i]);
        forr(j, 1, n + 1) if (j <= i + 1)
            nex[j] = dp[j - 1] * p[i] + dp[j] * (1 - p[i]);
        forn(j, n + 1) dp[j] = nex[j];
    }
    double sum = 0;
    forn(i, n + 1) if (i > n - i) sum += dp[i];
    cout << fixed << setprecision(12) << sum << endl;
    

    return 0;
}



Measured memory_bytes: 3756
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

	//------------------------------------------

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

	//------------------------------------------



	public void exec() throws Exception{
		final int K = sc.nextInt();
		final int X = sc.nextInt();
		if(500*K >= X) {
			out.println("Yes");
		}else {
			out.println("No");
		}
	}
}


Measured memory_bytes: 21844
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    h, w, k = list(map(int, readline().split()))
    s = [list(str(readline().rstrip().decode('utf-8'))) for _ in range(h)]
    cnt = 0
    ls = []
    lsd = -1
    for i in range(h):
        if s[i].count("#") != 0:
            lsd = i
            is_f = True
            cnt += 1
            for j in range(w):
                if s[i][j] == "#":
                    if is_f:
                        is_f = False
                    else:
                        cnt += 1
                s[i][j] = cnt
            while ls:
                ti = ls.pop()
                for j in range(w):
                    s[ti][j] = s[i][j]
        else:
            ls.append(i)
            if i == h - 1:
                while ls:
                    ti = ls.pop()
                    for j in range(w):
                        s[ti][j] = s[lsd][j]
    for i in range(len(s)):
        print(*s[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 49628
#include <bits/stdc++.h>
using namespace std;
bool isprime(int n) {
    if(n >= 2) {
        for(int a = 2; a * a <= n; a++) {
            if(n % a == 0) return false;
        }
        return true;
    }
    return false;
}

int main(){
    int x,n;
    cin >> n;
    while(!isprime(n)){
        n++;
    }
    cout << n << endl;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var x1, y1, x2, y2, x3, y3, px, py float64
        var oax, oay, obx, oby, opx, opy float64
        var det float64
        var s, t float64

        for {
                _, err := fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &px, &py)
                if err != nil {
                        break
                }
                oax = x2 - x1
                oay = y2 - y1
                obx = x3 - x1
                oby = y3 - y1
                opx = px - x1
                opy = py - y1
                det = oax*oby - obx*oay

                if det == 0 {
                        fmt.Printf("NO\n")
                } else {
                        s = (oby*opx - obx*opy) / det
                        t = (oax*opy - oay*opx) / det

                        if (s+t < 1 && s > 0 && t > 0) {
                                fmt.Printf("YES\n")
                        } else {
                                fmt.Printf("NO\n")
                        }
                }
        }
}



Measured memory_bytes: 1120
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint l[6], r[6];
bool can10[6][10], can1[6][10], can[6][10][10];
llint dp[15][1<<13][10];
llint nx[1<<13][10][10];

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++) cin >> l[i] >> r[i];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 10; j++){
				can10[i][j] = can1[i][j] = false;
				for(int k = 0; k < 10; k++){
					can[i][j][k] = false;
				}
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = l[i]; j <= r[i]; j++){
				if(j/10 > 0) can10[i][j/10] = true;
				if(j/10 > 0) can[i][j/10][j%10] = true;
				if(j <= 9) can1[i][j] = true;
			}
		}
		
		llint S = 1 << (2*n+1);
		for(int j = 0; j < S; j++){
			for(int k = 0; k < 10; k++){
				for(int l = 0; l < 10; l++){
					int nj = 0;
					for(int m = 0; m < 2*n; m++){
						if((j & (1<<m)) == 0) continue;
						int p = (m+1)/2-1;
						if(m % 2 == 0){
							if(can10[p+1][l]) nj |= 1<<(m+1);
							if(can1[p+1][l]) nj |= 1<<(m+2);
						}
						else if(can[p][k][l]) nj |= 1<<(m+1);
					}
					nx[j][k][l] = nj;
				}
			}
		}
		
		
		for(int i = 0; i <= 2*n; i++){
			for(int j = 0; j < S; j++){
				for(int k = 0; k < 10; k++){
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][1][0] = 1;
		
		for(int i = 0; i < 2*n; i++){
			for(int j = 0; j < S; j++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						int nj = nx[j][k][l];
						dp[i+1][nj][l] += dp[i][j][k];
					}
				}
			}
		}
		
		llint ans = 0;
		for(int i = 1; i <= 2*n; i++){
			for(int j = 0; j < S; j++){
				if((j & (1<<(2*n))) == 0) continue;
				for(int k = 0; k < 10; k++){
					ans += dp[i][j][k];
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 17772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<string, int> m;
    rep (i, n) {
        string s; cin >> s;
        m[s]++;
    }
    cout << m.size() << "\n";
    return 0;
}

Measured memory_bytes: 19184
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
double w,h,l,r;
void solve()
{
    cin>>w>>h>>l>>r;
    //if(w/2==l&&h/2==r)
    cout<<fixed<<setprecision(12)<<h*w/2<<" "<<(((l+l)==w)&&((r+r)==h))<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3680
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; string S; cin>>N>>S;
	int ans = 0;
	for(int i=0; i<1000; i++){
		char c1=i/100 +'0', c2=i%100/10+'0', c3=i%10 +'0', c[]{c1,c2,c3};
		int t, j = -1;
		for(t=0; t<3; t++){
			for(++j; j<N && S[j]!=c[t]; j++);
			if(j==N) break;
		}
		if(t==3) ans++;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from operator import itemgetter

    n, t = list(map(int, readline().split()))
    mat = [list(map(int, readline().split())) for _ in range(n)]
    dp1 = [[0] * t for _ in range(n + 2)]
    dp2 = [[0] * t for _ in range(n + 2)]

    for i, vec in enumerate(mat):
        a = vec[0]
        b = vec[1]
        for time in range(t):
            if time + a < t:
                dp1[i + 1][time + a] = max(dp1[i][time + a], dp1[i][time] + b)
            dp1[i + 1][time] = max(dp1[i][time], dp1[i + 1][time])

    for j, vec in enumerate(mat[::-1]):
        i = n + 1 - j
        a = vec[0]
        b = vec[1]
        for time in range(t):
            if time + a < t:
                dp2[i - 1][time + a] = max(dp2[i][time + a], dp2[i][time] + b)
            dp2[i - 1][time] = max(dp2[i][time], dp2[i - 1][time])

    ans = 0
    for i, vec in enumerate(mat, 1):
        val = vec[1]
        for j in range(t):
            temp = dp1[i - 1][j] + dp2[i + 1][t - j - 1] + val
            ans = max(ans, temp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 177288
/*
 
श्रीगुरु चरन सरोज रज
निजमनु मुकुरु सुधारि
बरनउँ रघुबर बिमल जसु
जो दायकु फल चारि
बुद्धिहीन तनु जानिके, सुमिरौं पवन-कुमार
बल बुधि बिद्या देहु मोहिं, हरहु कलेस बिकार 
 
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    cout << (n * (n - 1)) / 2;
}

Measured memory_bytes: 256
N = int(input())
l = list(map(int,input().split(" ")))
num_n =[]
i=1
for j in range(N-1):
    if l[j] == l[j+1]:
        i+=1
    else:
        num_n.append(int(i/2))
        i=1
num_n.append(int((i+0.1)/2))
print(sum(num_n))

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

typedef pair<int, int> iiP;

int n;
iiP seg[4 * 2 * 100001 - 1];

void init(int q){

  n = 1;
  while(n < q) n *= 2;

  for(int i = 0; i < n; i++) seg[i] = iiP(-INF, -i);

}

void update(int i, iiP a){

  i += n - 1;
  seg[i] = a;

  while(i > 0){
    i = (i - 1) / 2;
    seg[i] = max(seg[i * 2 + 1], seg[i * 2 + 2]);
  }

}
int main(){

  int N, R, L, d, t, x, prev;
  int sumt[100001] = {0}, score[100001] = {0};
  cin >> N >> R >> L;

  init(N);
  cin >> d >> t >> x;
  sumt[1] += t, score[d] += x;
  update(d, iiP(score[d], -d));
  prev = t;
  //  cout << ":" << score[d] << " " << d << endl;
  for(int i = 1; i < R; i++){
    cin >> d >> t >> x;
    iiP p = seg[0];
    score[d] += x, sumt[-p.second] += t - prev;
    prev = t;
    //\cout << ":" << score[d] << " " << d << endl;
    update(d, iiP(score[d], -d));
  }
  iiP p = seg[0];
  //  cout << p.first << " " << -p.second << endl;
  sumt[-p.second] += L - prev;

  cout << max_element(sumt + 1, sumt + N + 1) - sumt << endl;
}

Measured memory_bytes: 8196
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back



int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	int n, d;
	re(n,d);
	ld arr[n][d];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < d; j++)
		{
			cin >> arr[i][j];
		}
	}
	ld sum[(n*(n-1))/2] = {0.0};
	ll cnt =0, jj =0;
	for(int i  =0; i +1<n; i++)
	{
		for(int j = i+1; j < n; j++)
		{
			for(int k =0; k < d; k++)
			{
				sum[jj] = sum[jj] + (arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]);
				//cout << (arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]) <<"\n"
;			}
			//cout<<sum[jj] <<" ";
			sum[jj] = sqrt(sum[jj]);
			jj++;
		}
	}
	for(ll i =0; 2*i <(n*(n-1)); i++)
	{
		//cout<<"hi";
		//cout<<sum[i] <<"\n";
		if((sum[i] - floorl(sum[i])) == 0)
		{
			cnt++;
		}
	}
	cout<<cnt <<"\n";
}


Measured memory_bytes: 512
# 16D8101022L 小林勇希 ID:k_mb python3


def insertion_sort(A,n):
    for i in range(n):
        v = A[i]
        j = i-1
        while(j>=0 and A[j]>v):
            A[j+1] = A[j]
            j = j-1
        A[j+1] = v
        for i in range(n-1):
            print(A[i],"",end="")
        print(A[n-1])

n = int(input())
A_idx = [int(i) for i in input().split()]

insertion_sort(A_idx,n)

"""実行結果

6
4 6 3 2 1 5
4 6 3 2 1 5
4 6 3 2 1 5
3 4 6 2 1 5
2 3 4 6 1 5
1 2 3 4 6 5
1 2 3 4 5 6

"""



Measured memory_bytes: 6324
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	Scanner in = new Scanner(System.in);
	int N;
	int[][] map;
	int[] dp;
	
	public void run() {
		while (true) {
			N = in.nextInt();
			if (N == 0) break;
			map = new int[N][N+1];
			for (int i = 0; i < N; i++) {
				for (int j = 0; j <= N; j++) {
					map[i][j] = in.nextInt();
				}
			}
			dp = new int[1 << N];
			Arrays.fill(dp, Integer.MAX_VALUE);
			dp[0] = 0;
			
			for (int i = 0; i < dp.length; i++) {			
				for (int k = 0; k < N; k++) {
					int before = i & ~(1 << k);
					if (dp[before] != Integer.MAX_VALUE) {
						int min = map[k][0];
						for (int j = 0; j < N; j++) {
							if ((before >> j) % 2 == 1) {
								min = Math.min(map[k][j+1], min);
							}
						}
						dp[i] = Math.min(min + dp[before], dp[i]);
					}
				}
			}
			
			System.out.println(dp[(1 << N) - 1]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INF = 1ll << 60;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());
  int A = 0, B = 0, C = 0;

  for (int i = 0; i < n; i++) {
    if (v[i] <= a) A++;
    if (a < v[i] && v[i] <= b) B++;
    if (b < v[i]) C++;
  }

  cout << min(A, min(B, C)) << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize,usize);
    let a = get!([usize]);

    let mut sums = vec![0; n+1];
    for i in 0..n {
        sums[i+1] = sums[i]+a[i];
        sums[i+1] %= k;
    }
    let calc = |i: usize| -> usize {
        if sums[i] < i%k {
            sums[i]+k-i%k
        } else {
            sums[i]-i%k
        }
    };
    let mut map = BTreeMap::new();
    let mut res = 0usize;
    for i in 0..n+1 {
        if i >=k {
            let val_del = calc(i-k);
            *map.entry(val_del).or_insert(0) -= 1;
        }
        let val_add = calc(i);
        {
            let entry = map.entry(val_add).or_insert(0);
            res += *entry;
            *entry += 1;
        }
    }
    println!("{}", res);
}


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


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

	int a, b, c;
	cin >> a >> b >> c;
	
	int count = 0;
	for(int i = a; i <= b; i++) {
		if(c % i == 0) count++;
	}
	
	cout << count << "\n";
	
	return 0;
}

Measured memory_bytes: 1196
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

ans=10**9
for i in range(2**n):
  t_ans=0
  us=[0 for j in range(m)]
  for k in range(n):
    if (i>>k)&1:
      book=l[k]
      t_ans+=book[0]
      for p in range(m):
        us[p]+=book[p+1]

  if all([q>=x for q in us]):
    ans=min(ans,t_ans)

print(ans if ans!=10**9 else -1)

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

typedef long long ll;
const int inf = 1e9;

int n, u;

double x, y, d;

double dist(double x, double y){
	return sqrt((double)(x * x) + (double)(y * y));
}

int main(){
	cin>>n>>d;
	u = 0;
	for(int i = 0; i < n; ++i){
		cin>>x>>y;
		if(dist(x,y)<=d)u++;
	}
	cout<<u<<endl;
	return 0;
}


Measured memory_bytes: 3860
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL inf = 1123456789;

std::vector<std::vector<LL>>dist;
std::set<std::pair<LL, LL>>res;
void warshall_floyd(LL V)
{
	for (LL k = 0; k < V; ++k)
	{
		for (LL i = 0; i < V; ++i)
		{
			for (LL j = 0; j < V; ++j)
			{
				if (dist[i][j] > dist[i][k] + dist[k][j])
				{
					if (dist[i][j] != inf) res.insert(std::make_pair(std::min(i, j), std::max(i, j)));
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
	}
}

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>a(M), b(M), c(M);
	rep(i, M) in >> a[i] >> b[i] >> c[i];
	rep(i, M)
	{
		if (a[i] > b[i]) std::swap(a[i], b[i]);
		--a[i]; --b[i];
	}

	dist.resize(N);
	rep(i, dist.size()) dist[i].resize(N, inf);
	rep(i, N) dist[i][i] = 0;
	rep(i, M) dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
	warshall_floyd(N);

	LL ans = 0;
	for (auto e : res)
	{
		rep(i, M)
		{
			if (e.first == a[i] && e.second == b[i])
			{
				++ans;
				break;
			}
		}
	}

	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    int i,j,a[3][n+1];
    for (i=0;i<3;i++)
        for (j=0;j<n+1;j++)
            a[i][j]=0;
    for (i=1;i<3;i++)
        for (j=1;j<n+1;j++)
            cin>>a[i][j];
    for (i=1;i<3;i++)
        for (j=1;j<n+1;j++)
            a[i][j]+=max(a[i-1][j],a[i][j-1]);
    cout<<a[2][n]<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
    public Main() {
    }

    public static void main(String[] args ) {
    		Main main = new Main();
    		main.exec();
    }

    public void exec() {
        BufferedReader bf = null;
        try{
            bf = new BufferedReader(new InputStreamReader(System.in));
            exec_body(bf);
        } catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
        finally{
            if( bf != null ) {
                try {
					bf.close();
				} catch (IOException e) {
					// TODO 自動生成された catch ブロック
					e.printStackTrace();
				}
            }
        }
    }

    public void exec_body( BufferedReader bf ) throws IOException {
    		// 標準入力から読み取り
        String line = bf.readLine();
        String[] lines = line.split(" ");
        int quantum = Integer.parseInt(lines[1]);

        Queue<Process> pList = new  LinkedList<>();
        while( (line = bf.readLine()) != null ) {
        		lines = line.split(" ");
        		Process p = new Process(lines[0],Integer.parseInt(lines[1]));
        		pList.add(p);
        }

        int time = 0;
        ArrayList<Process> list = new ArrayList<>();
        while( !pList.isEmpty() ) {
        		Process element = pList.poll();
        		if( element._time > quantum ) {
        			element._time = element._time -quantum;
        			pList.add(element);
        			time = time + quantum;
        		} else {
        			time = time + element._time;
        			list.add(new Process(element._name,time));
        		}
        }

        list.forEach((Process element) -> {
        		System.out.println(element._name + " " + element._time );
        });
    }

    public class Process {
    		private String _name = null;
    		private int _time = 0;

    		public Process( String name, int time ) {
    			_name = name;
    			_time = time;
    		}

    		public String getName() {
    			return _name;
    		}

    		public int getTime() {
    			return _time;
    		}
    }
}


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

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



int main() {
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> vpp(n);
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		vpp.at(i) = make_pair(make_pair(s, -p), i);
	}

	sort(vpp.begin(), vpp.end());

	for (int i = 0; i < vpp.size(); i++) {
		cout << vpp.at(i).second + 1 << endl;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>  
using namespace std;
int main(){
  int n, dp[100001], a[100001];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  fill_n( dp, n, 1e9+1);
  for(int i = 0; i < n; i++){
    *lower_bound( dp, dp + n, a[i]) = a[i];
  }
  cout << distance( dp, lower_bound( dp, dp + n, 1e9+1)) << endl;
}

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

int main(){
    string s;
    cin >> s;
    string s_a;
    string s_b;
    int r = 0;
    if(s.length() % 2 == 0){
        s_a=s.substr(0, s.length()/2);
        s_b=s.substr((s.length()/2));
    }else{
        s_a=s.substr(0, s.length()/2);
        s_b=s.substr((s.length()/2)+1);
    }
    reverse(s_b.begin(), s_b.end());
    for(int i=0;i<s.length()/2;i++){
        if(s_a[i] != s_b[i]){
            r++;
        }
    }
    cout << r << endl;
}

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

int main()
{
  ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
  ll n, k, a, b;
  cin >> n >> k;
  
  map<ll, ll> freq;
  
  for(int i = 0; i < n; i++)
  {
    cin >> a >> b;
    freq[a] += b;
  }
  
  for(pair<ll, ll> x: freq)
  {
    if(x.second < k)
      k -= x.second;
    else
    {
      cout << x.first << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 50+1;
int dp[maxn][maxn][maxn*maxn];// dp[i][j][k] 已经匹配到前i个，有j个没有匹配，当前已知的value是k

void Add(int &a,int b){
	a += b;
	if(a >= mod)
		a -= mod;
}
int main(void)
{
    int N,K;
    cin>>N>>K;
    dp[0][0][0] = 1;
    for(int i  = 1;i <= N;++i){
    	for(int j = 0;j <= i; ++j){
    		for(int k = 2*j;k <= K; ++k){
    			int &a = dp[i][j][k];
    			Add(a,1ll*(2*j+1)*dp[i-1][j][k-2*j]%mod);// i1,i2 匹配，或者i1与一个未匹配的匹配，或者i2与一个没匹配的匹配,没有匹配的个数不变
    			Add(a,1ll*(j+1)*(j+1)*dp[i-1][j+1][k-2*j]%mod);// i1,i2 匹配一个非 i2,i1 的，未匹配的数量-1
    			if(j)
    				Add(a,dp[i-1][j-1][k-2*j]);// i1,i2 不匹配，未匹配的数量+1
    		}
    	}
    }
    cout<<dp[N][0][K]<<endl;
   return 0;
}

Measured memory_bytes: 24704
#define SIZE 1000001
#include <iostream>
using namespace std;

int main()
{
	int  a,d,n;
	bool prime[SIZE];

	for(int i=0; i<SIZE; i++)
	{
		prime[i]=1;
	}
	prime[0]=prime[1]=0;

	for(int i=2; i<SIZE; i++)
	{
		if(prime[i])
		{
			for(int j=2; j*i<SIZE; j++)
			{
				prime[j*i]=0;
			}
		}
	}
	
	int N;
	while(cin >> N, N)
	{
		int cnt=0;
		for(int i=0; i<=N/2; i++)
		{
			if(prime[i]&&prime[N-i])
			{
				cnt++;
			}
		}
		
		cout << cnt << endl;
	}
}

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

using namespace std;
const int inf =0x3f3f3f3f;
int main(void){
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    int aux, n;

    cin>>n;
    vector<int> pd(n+10,inf);
    vector<int> pedras(n+10);
    for(int i=0; i<n; i++){
        cin>>pedras[i]; //pedras.push_back(aux);
    }

    pd[0]=0;

    for(int i=0; i<n; i++){
        if(i<=n-2)pd[i+2]=min(pd[i+2], pd[i]+abs(pedras[i]-pedras[i+2]));    
        if(i<=n-1)pd[i+1]=min(pd[i+1], pd[i]+abs(pedras[i]-pedras[i+1]));    
    }

    cout<<pd[n-1]<<endl;

    /*for(int i=0; i<n; i++){
        cout<<pd[i]<<endl;
    }*/

    return 0;
}

Measured memory_bytes: 1024
# E
#
n = int(input())
a = list(map(int, input().split()))
ans=a[0]
#S=allxor(a)を求める
for i in range(1,n):
    ans = ans ^ a[i]
# print(ans)
b = []
for i in range(n):
    b.append(ans ^ a[i])
print(*b)

Measured memory_bytes: 31552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N) cin>>A.at(n);

    map<int64_t,int64_t> mp;
    mp[0]++;
    int64_t sumA=0;
    rep(n,0,N){
        sumA+=A.at(n);
        mp[sumA]++;
    }

    int64_t ans=0;
    for(auto m:mp){
        ans+=m.second*(m.second-1)/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 14336
#include <stdio.h>
#define N 100
int main()
{
  int i,j,minj,count=0,n,kk;
  int A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }

 
  for(i=0;i<n;i++)
    {
      minj=i;
      for(j=i;j<n;j++)
	{
   
	  if(A[j]<A[minj])
	    {
	      minj=j;
	    }
	}
      kk=A[i];
      A[i]=A[minj];
      A[minj]=kk;
      if(i!=minj) count=count+1;
    }


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

Measured memory_bytes: 604
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 100000000000007;

typedef tuple<int, int> edge; // vert, dist
typedef tuple<int, int> state; // vert, 

int N;
vector<edge> V[100010];
int parent[100010];
int c_size[100010];
ll dist[100010];

void dfs(int v, int p, ll d) {
  // cerr << v << " " << p << " " << d << endl;
  parent[v] = p;
  dist[v] = d;
  for (auto x : V[v]) {
    if (get<0>(x) != p) {
      dfs(get<0>(x), v, dist[v] + get<1>(x));
    }
  }
}

int child_size(int v) {
  // cerr << "v = " << v << endl;
  if (c_size[v] != -1) return c_size[v];
  int ans = 1;
  for (auto x : V[v]) {
    if (get<0>(x) != parent[v]) {
      // cerr << v << " " << get<0>(x) << endl;
      ans += child_size(get<0>(x));
    }
  }
  return c_size[v] = ans;
}

int centroid = 0;

int main () {
  cin >> N;
  for (auto i = 0; i < N-1; ++i) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    --a;
    --b;
    V[a].push_back(edge(b, c));
    V[b].push_back(edge(a, c));
  }
  dfs(0, -1, 0);
  fill(c_size, c_size+100010, -1);
  child_size(0);
  bool cont = true;
  while (cont) {
    cont = false;
    for (auto x : V[centroid]) {
      if (get<0>(x) != parent[centroid]) {
        if (child_size(get<0>(x)) > N/2) {
          centroid = get<0>(x);
          cont = true;
          break;
        }
      }
    }
  }
  dfs(centroid, -1, 0);
  fill(c_size, c_size+100010, -1);
  child_size(centroid);
  ll mini = infty;
  if (N % 2 == 0) {
    for (auto x : V[centroid]) {
      if (child_size(get<0>(x)) == N/2) {
        mini = get<1>(x);
        break;
      }
    }
  }
  if (mini == infty) {
    for (auto x : V[centroid]) {
      if (get<1>(x) < mini) {
        mini = get<1>(x);
      }
    }
  }
  ll ans = -mini;
  for (auto i = 0; i < N; ++i) {
    ans += 2 * dist[i];
  }
  cout << ans << endl;
}


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

int main(void){
  int n; cin >> n;
  map<string,int> k;
  rep(i,n){
    string s; cin >> s;
    k[s] = 1;
  }
  int ans = 0;
  for(auto p : k){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19208