akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
int main(){
	ll n, k;
	cin >> n >> k;
	vector <ll> v;
	fop(i,0,n){
		ll x;
		cin >> x;
		v.push_back(x);
	}
	bool win[k+1] = {};
	fop(i,1,k+1){
		fop(j,0,n){
			if(i >= v[j] && !win[i - v[j]]){
				win[i] = true;
				break;
			}
		}
	}
	if(win[k]) cout << "First";
	else cout << "Second"; 
}

Measured memory_bytes: 384
def getnewline(line,N):
    newline=[0 for x in range(N)]
    dnum={}
    for x in line:
        if x in dnum:
            dnum[x]=dnum[x]+1
        else:
            dnum[x]=1
    for i in range(N):
        newline[i]=dnum[line[i]]
    return newline

while(1):
    N=int(raw_input())
    if N==0:
        break
    else:
        line=[int(x) for x in raw_input().split()]
        n=0
        continuecount=1
        while(continuecount):
            newline=getnewline(line,N)
            continuecount=line!=newline
            line=newline
            n=n+1
        print n-1
        print ' '.join([str(x) for x in line])# your code goes here

Measured memory_bytes: 4240
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static class Dish {
        long a;
        long b;
        public Dish(long a, long b) {
            this.a = a;
            this.b = b;
        }
    }
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        PriorityQueue<Dish> food = new PriorityQueue<>(
                (d1, d2) ->
                {
                    long diff = d2.a + d2.b - (d1.a + d1.b);
                    if (diff > 0) {
                        return 1;
                    } else if (diff == 0) {
                        return 0;
                    } else {
                        return -1;
                    }
                }
        );
        for (int i = 0; i < n; ++i) {
            long a = scanner.nextLong();
            long b = scanner.nextLong();
            food.add(new Dish(a, b));
        }
        long result = 0;
        for (int i = 0; i < n; ++i) {
            final Dish dish = food.poll();
            if (i % 2 == 0) {
                result += dish.a;
            } else {
                result -= dish.b;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 96832
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,j;
    if(n<=10)
    {
    	cout<<"Yes"<<endl;
    	return 0;
    }
    for(i=2;i<=9;i++)
    {
    	if(n%i==0)
    	{
    		if(n/i>=2&&n/i<=9)
    		{
    			cout<<"Yes"<<endl;
    	        return 0;
    		}
    	}
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    for i in 1..n + 1 {
        let mut x = i;
        if x % 3 == 0 {
            print!(" {}", i);
            continue;
        } else {
            while x != 0 {
                if x % 10 == 3 {
                    print!(" {}", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    println!("",);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5028
package main

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

func greatOceanView(ar []int32) int32 {
    if len(ar) == 0 {
        return int32(0)
    }
    cnt := int32(1)
    max := ar[0]

    for i := 1; i < len(ar); i++ {
        if ar[i] >= max {
            cnt++
            max = ar[i]
        }
    }
    return cnt
}

func main() {
    reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)

    arCount, err := strconv.ParseInt(readLine(reader), 10, 64)
    checkError(err)

    arTemp := strings.Split(readLine(reader), " ")

    var ar []int32

    for arItr := 0; arItr < int(arCount); arItr++ {
        arItemTemp, err := strconv.ParseInt(arTemp[arItr], 10, 64)
        checkError(err)
        arItem := int32(arItemTemp)
        ar = append(ar, arItem)
    }

    res := greatOceanView(ar)
    fmt.Println(res)
}

func readLine(reader *bufio.Reader) string {
    str, _, err := reader.ReadLine()
    if err == io.EOF {
        return ""
    }

    return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
    if err != nil {
        panic(err)
    }
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        final int n = Integer.parseInt(br.readLine());
        final card[] A = new card[n];
        for(int i = 0; i<n; i++)
            A[i] = new card(br.readLine(), i);
        quickSort(A, 0, n-1);
        sb.append(isStable(A) ? "Stable\n" : "Not stable\n");
        for(int i = 0; i<n; i++)
            sb.append(A[i]).append('\n');
        System.out.print(sb);
    }
    private static int partition(card[] A, int p, int r){
        final card x = A[r];
        int i = p;
        card t;
        for(int j = p; j<r; j++){
            if(A[j].getNum()<=x.getNum()){
                t = A[i];
                A[i] = A[j];
                A[j] = t;
                i++;
            }
        }
        A[r] = A[i];
        A[i] = x;
        return i;
    }
    private static void quickSort(card[] A, int p, int r){
        if(p>=r) return;
        final int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
    private static boolean isStable(card[] A){
        for(int i = 1, n = A.length; i<n; i++){
            if(A[i-1].getNum()==A[i].getNum()&&A[i-1].getId()>A[i].getId()) return false;
        }
        return true;
    }
}
 
class card{
    final private String str;
    final private int num;
    final private int id;
    card(String str, int id){
        this.str = str;
        num = Integer.parseInt(str.substring(2));
        this.id = id;
    }
    final int getId(){
        return id;
    }
    final int getNum(){
        return num;
    }
    @Override
    public final String toString(){
        return str;
    }
}


Measured memory_bytes: 49728
import java.util.Scanner;

/**
 * 
 * @author morisin
 * 
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double T = sc.nextInt();
		double X = sc.nextInt();
		
		System.out.println(T/X);
	}

}


Measured memory_bytes: 23764
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
plus = 0
for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        plus += C[A[i]-1]

print(sum(B)+plus)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,s;cin>>k>>s;
  int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j>=0&&s-i-j<=k)ans+=1;
    }
  }
  cout<<ans<<endl;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  string S;
  cin >> S;

  int cnt_w = 0;
  int cnt_b = 0;
  rep(i, S.size())
  {
    if (i % 2 == 0)
    {
      if (S[i] == '0')
      {
        cnt_w++;
      }
      else
      {
        cnt_b++;
      }
    }
    else
    {
      if (S[i] == '1')
      {
        cnt_w++;
      }
      else
      {
        cnt_b++;
      }
    }
  }

  cout << std::min(cnt_w, cnt_b) << endl;

  return 0;
}


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

int main(){

    while(1){
        string S;
        cin >> S;
        if(S == "-") break;

        int m;
        cin >> m;

        for(int i = 0; i < m; i++){
            int h;
            cin >> h;
            string front = S.substr(0,h);
            string back = S.substr(h,S.size() - h);

            S = back + front;
        }

        cout << S << endl;
    }
}


Measured memory_bytes: 3148
n = int(input())
s = [list(str(input())) for i in range(n)]
m,a,r,c,h = 0,0,0,0,0
for i in range(n):
    if s[i][0] == "M":
        m = m + 1
    elif s[i][0] == "A":
        a = a + 1
    elif s[i][0] == "R":
        r = r + 1
    elif s[i][0] == "C":
        c = c + 1
    elif s[i][0] == "H":
        h = h + 1

t = [m,a,r,c,h]
p = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            p = p + t[i] * t[j] * t[k]

print(p) 

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

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

        if(n == 0)  break;

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

        int cnt = 0;
        for(int i = n-1; i > 0; i--){
            for(int j = 0; j < i; j++){
                if(A[j] > A[j+1]){
                    swap(A[j], A[j+1]);
                    cnt++;
                }
            }
        }

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 10000;
int N;
string S[MAX_N];

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

  cin >> N;
  rep(i, N) cin >> S[i];

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
      for (int j = 0; j+1 < len(S[i]); ++j) {
          if (S[i].substr(j, 2) == "AB") ++ans;
      }
  }

  cerr << ans << endl;

  int lastA = 0, firstB = 0, firstBlastA = 0;
  for (int i = 0; i < N; ++i) {
      if (S[i][0] == 'B' && S[i][len(S[i])-1] == 'A') {
          ++firstBlastA;
      } else if (S[i][0] == 'B') {
          ++firstB;
      } else if (S[i][len(S[i])-1] == 'A') {
          ++lastA;
      }
  }

  cerr << "firstBlastA: " << firstBlastA << endl;
  cerr << "firstB: " << firstB << endl;
  cerr << "lastA: " << lastA << endl;

  ans += max(0, firstBlastA-1);
  if (lastA != 0 && firstBlastA != 0) {
      ++ans;
      --lastA;
  }
  if (firstB != 0 && firstBlastA != 0) {
      ++ans;
      --firstB;
  }

  ans += min(lastA, firstB);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1144
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cl(int a, int b) {
	return (a - (a%b)) / b;//b=0だと積む
}
int up(int a, int b) {
	return cl(a + b - 1, b);//b=0だと積む
}
int main() {
	int a, b, n, k;
	cin >> n >> k;
	while(n+k!=0){
	int ch = 0; int ans = 0; int n0 = 0;
	vector<int> c(n,0);
	for (int i = 0; i < k; i++) {
		int x;
		cin >> x;
		if (x != 0) {
			c[x - 1] = 1;
		}
		else {
			n0 = 1;
		}
	}
	vector<int> p(n+1,0);
	vector<int> q(n + 1, 0);
	int ba = 0;
	for (int i = 0; i < n; i++) {
		if (c[i] == 1) {
			p[ch]++;
			if (i >= 2) {
				if (c[i - 1] == 0 and c[i - 2] == 1) {
					q[ch] = 1;
				}
			}
		}
		if (c[i] == 0 and ba==1) {
			ch++;
		}
		ba = c[i];
	}
	for (int i = 1; i <= n; i++) {
		ans = max(ans, q[i] * n0*(p[i]+p[i-1]+1));
	}
	sort(p.begin(), p.end());
	ans = max(ans, p[n]);
	cout << ans<<endl;
	cin >> n >>k;
	}
}



Measured memory_bytes: 3904
fn input<T: std::str::FromStr>() -> T
{
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}
fn main() {
    let tem=input::<i32>();
	if tem>=30{
		println!{"Yes"};
	}else{
		println!{"No"};
	}
}

Measured memory_bytes: 2080
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a<c && c<b) || (b<c && c<a)){
        printf("Yes");
    }else{
        printf("No");
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 128
N,K,Q=input().split()
N=int(N)
K=int(K)
Q=int(Q)

point = [K-Q for i in range(N)]

for i in range(Q):
    p=(int)(input())
    point[p-1]+=1
    
for i in range(N):
    if(point[i] <= 0):
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    vll d(n);
    rep(i,n) cin >> d[i];
    sort(all(d));
    cout << d[n/2]-d[n/2-1] << endl;
    return 0;
}

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

int main(){
  vector<int> v(10);
  for(int i = 0; i < 10; i++){
    cin >> v.at(i);
  }
  sort(v.begin(), v.end(), greater<int>());
  for(int i = 0; i < 3; i++){
    cout << v.at(i) << endl;
  }
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    ll N;

    cin >> N;

    string ans;
    ll base26 = 1;
    REPinit(i, 1, 100) {
        base26 *= 26;
        if (N <= base26) {
            N--;
            REPinit(j, 0, i) {
                ans.push_back((char)('a' + N % 26));
                N /= 26;
            }
            break;
        }
        else {
            N -= base26;
        }
    }

    std::reverse(CONTAINER_ALL(ans));
    cout << ans << endl;

    return 0;
}


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

ll N, M;
vector<ll> V(50, 0);
vector<vector<ll>> D(50, vector<ll>(50, 0));

void DFS(ll num) {
        if (V[num] == 1) return;
        V[num] = 1;

        rep(i,N) {
                if (num == i) continue;
                if (D[num][i] == 1) {
                        DFS(i);
                }
        }
}

int main()
{
        cin >> N >> M;
        vector<ll> a(M, 0);
        vector<ll> b(M, 0);
        rep(i,M) {
                ll aa, bb; cin >> aa >> bb;
                a[i] = aa-1; b[i] = bb-1;
                D[a[i]][b[i]] = 1;
                D[b[i]][a[i]] = 1;
        }
        ll ans = 0;
        rep(i, M) {
                D[a[i]][b[i]] = 0; D[b[i]][a[i]] = 0;
                rep(j,N) V[j] = 0;
                DFS(0);
                bool bridge = false;
                rep(j,N) {
                        if (V[j] == 0) {
                                bridge = true;
                                break;
                        }
                }
                if (bridge) ans++;
                D[a[i]][b[i]] = 1; D[b[i]][a[i]] = 1;
        }
        cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int> > vv;
///-------------------------
vector<int> p;
void init(){
    p.push_back(2);
    int lim = (int) 1e6;
    for(int i=3; i*i<=lim; i+=2){
        bool can = true;
        for(int x:p) {
            if(i%x==0) {
                can=false;
                break;
            }
        }
        if(can) p.emplace_back(i);
    }
}

int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    init();
    int ans=0;
    for(int c=1; c<n; ++c){
        int num = n-c;
        int len=1;
        for(int x:p) {
            int dem=0;
            while(num%x==0){
                dem++;
                num/=x;
            }
            len*=(dem+1);
            if(num==1) break;
        }
        if (num>1) len*=2;
        if(len&1){
            ans+= (len/2) * 2;
            ans++;
        } else ans += len;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

da = [a[n-1] for i in range(n)]
for i in range(n-2, -1, -1):
    da[i] = da[i+1] + a[i]
sum = 0
for i in range(n-1):
    # print (str(a[i]) + " : " + str(da[i+1]))
    sum += a[i] * da[i+1]
    sum %= 1000000007
# print(da)
print(sum)

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

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

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  ll a, b;
  cin >> a >> b;

  cout << a*b/__gcd(a, b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int c[100010];
int a[100010], b[100010];

bool cmp(int i, int j) {
	return a[i] + b[i] > a[j] + b[j];
}

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d %d", &a[i], &b[i]);
		c[i] = i;
	}
	sort(c + 1, c + n + 1, cmp);
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		int id = c[i];
		if(i & 1) {
			ans += a[id];
		} else {
			ans -= b[id];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define taskname "MedianOfMedians"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n;  cin >> n;
    vector<int> a(n + 1), med;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        med.emplace_back(a[i]);
    }
    sort(med.begin(), med.end());
    vector<int> :: iterator it;
    it = unique(med.begin(), med.end());
    med.resize(distance(med.begin(), it));
    int l = 0, r = med.size() - 1;
    vector<int> s(n + 1, n);
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        vector<int> bit(2 * n + 1, 0);
        int num = 0;
        for (int i = 0; i <= n; ++i)
        {
            if (i) s[i] = s[i - 1] + ((a[i] >= med[mid])? 1 : -1);
            for (int x = s[i]; x; x &= x - 1) num += bit[x];
            for (int x = s[i]; x <= 2 * n; x += x & -x) ++bit[x];
        }
        if (num >= n * (n + 1) / 4) l = mid + 1;
        else r = mid - 1;
    }
    cout << med[l - 1];
}


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

int main() {
  int h,w;
  cin >> h >> w;
  for ( int i=0; i<h; i++ ) {
    string s;
    cin >> s;
    cout << s << '\n';
    cout << s << '\n';
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 2100000000
#define MOD 1000000007

bool dbgflag = false; //debug

ll dpfunc(int i, int j, vector<vector<ll>>&dp, string s) {
  if (dbgflag) cout << "dp " << i << " " << j << endl; 
  int n = s.size();
  if (dp[i][j] != -1) return dp[i][j];
  if (j == 0) { if (dbgflag) cout << "case1" << endl;
    dp[i][j] = 1;
    return dp[i][j];
  }
  if (n-i < j) { if (dbgflag) cout << "case2" << endl;
    dp[i][j] = 0;
    return dp[i][j];
  }
  if (i == n-1) { if (dbgflag) cout << "case3" << endl;
    dp[i][j] = (ll)(s[i]-'0');
    return dp[i][j];
  }
  //0から始まるとき
  if (s[i] == '0') { if (dbgflag) cout << "case4" << endl;
    dp[i][j] = dpfunc(i+1, j, dp, s);
    return dp[i][j];
  }
  //0でないとき
  if (s[i] != '0') { if (dbgflag) cout << "case5" << endl;
    //上の桁が同じ
    dp[i][j] = dpfunc(i+1, j-1, dp, s); 
    //なんでもよくなったけど0でない
    ll ansn0 = (s[i] - '1');
    for (int p = 0; p < j-1; p++) ansn0 *= (ll) (n-i-1-p);
    for (int p = 0; p < j-1; p++) ansn0 /= (p+1);
    for (int p = 0; p < j-1; p++) ansn0 *= 9;
    //なんでもいい
    ll ansy0 = 1;
    for (int p = 0; p < j; p++) ansy0 *= (ll) (n-i-1-p);
    for (int p = 0; p < j; p++) ansy0 /= (p+1);
    for (int p = 0; p < j; p++) ansy0 *= 9;
    
    if (dbgflag) cout << dp[i][j] << " " << ansn0 << " " << ansy0 << endl;
    dp[i][j] += ansn0 + ansy0;
    return dp[i][j];
  }
  return dp[i][j];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;

  vector<vector<ll>> dp(n, vector<ll>(k+1, -1)); //dp[i][j]: 左からi桁目以降の数字より小さく、j個の0以外の数
  //最上位桁が0
  /*ll ans = 1;
  for (int i = 0; i < k; i++) ans *= (ll) (n-1-k);
  for (int i = 0; i < k; i++) ans /= (i+1);
  for (int i = 0; i < k; i++) ans *= 9;
  */

  cout << dpfunc(0, k, dp, s) << endl;
  
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    D, G = MI()
    P = []
    C = []
    for _ in range(D):
        p, c = MI()
        P.append(p)
        C.append(c)

    ans = INF
    for i in range(1 << D):
        bag = []
        cag = []
        for j in range(D):
            if (i >> j) & 1:
                bag.append(j)
            else:
                cag.append(j)
        # print(bag, cag)
        score = 0
        cnt = 0
        for b in bag:
            score += (b+1) * 100 * P[b] + C[b]
            cnt += P[b]
        # print(score, cnt, G)
        if score >= G:
            ans = min(ans, cnt)
            # print('a', ans)
        else:
            c = cag[-1]
            for i in range(P[c]):
                score += (c+1) * 100
                cnt += 1
                if score >= G:
                    ans = min(ans, cnt)
                    # print(ans)
                    break

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3192
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define psi std::pair<string,int>
#define pli std::pair<ll,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%I64d",&x)
#define prll(x) printf("%I64d ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vli std::vector<std::list<int>>
#define vlpi vector<list<pii>>
#define li std::list<int>
#define Endl printf("\n")
#define ma 1000000
#define mod 786433
#define FOR(i,a) for(int i=0; i<a; i++)
#define FORL(i,a) for(ll i=0 ;i<a ; i++)
#define MAXN 1000
#define paire(a,b)  make_pair(a,b)

using namespace std;

int main()
{
    int a , b  ; cin >> a>> b;
    int r =0 ;
    while(b-a>0) {
        b=b-a+1 ;
        r++ ;
    }
        if (b<=1)
        cout << r ;
    else
        cout << r+1 ;
}







Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: k,a,b,ans

    read*, k,a,b
    ans=a + ((k-(a-1))/2)*(b-a)
    if (mod(k-(a-1),2_8) == 1) ans=ans+1
    print'(i0)', max(k+1,ans)
end program name

Measured memory_bytes: 256
C = [list(map(int, input().split()))  for _ in range(3)]

x = [list() for _ in range(2)]
y = [list() for _ in range(2)]
for i in range(3):
  for j in range(2):
    x[j].append(C[i][j] - C[i][j+1])
    y[j].append(C[j][i] - C[j+1][i])

out = False
for j in range(2):
  if min(x[j]) != max(x[j]):
    break
  if min(y[j]) != max(y[j]):
    break
else:
  print("Yes")
  out = True
if not out:
  print("No")




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

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

	int a;
	cin >> a;

	int min = a;
	int max = a;
	long sum = a;

	while (--n) {
		cin >> a;
		
		if (a < min) min = a;
		else if (max < a) max = a;
		sum += a;
	}

	cout << min << ' '
	     << max << ' '
	     << sum << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector <int> a(N);
    int ans = 0;
    bool renzoku = false;
    rep (i, N) {
        cin >> a[i];
        if (i != 0) {
            if (!renzoku) {
                if (a[i] == a[i - 1]) {
                    ans ++;
                    renzoku = true;
                }
                else {
                    renzoku = false;
                }
            }
            else {
                renzoku = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

#define MOD 1000000007

// x^n in mod
ll mod_pow(ll x, ll n){
  if(n==0) return 1;

  if(n%2==0){
    return mod_pow(x*x%MOD, n/2) % MOD;
  }else{
    return x * mod_pow(x, (n-1)) % MOD;
  }
}

ll mod_pow_r(ll x, ll n){
  if(x==0)return 0;
  if(n==0) return 1;

  ll ret = 1;
  while(n){
    if(n&1) ret=ret*x%MOD;
    n /= 2;
    x=x*x%MOD;
  }
  
  return ret;
}


ll fac(ll n){
  ll res = 1;
  rep(i, n){
    res *= (i+1);
    res %= MOD;
  }
  return res;
}

// nCr
ll comb(ll n, ll r){
  if(n<0 || n<r || r<0)return 0;
  ll fn = fac(n);
  ll fr = fac(r);
  ll fn_r = fac(n-r);
  
  ll d = (mod_pow_r(fr, MOD-2)*mod_pow_r(fn_r, MOD-2))%MOD;
  ll u = fn%MOD;

  return u * d % MOD;
}

int main(){
  ll x,y;
  cin>>x>>y;
  
  if((x+y)%3!=0){
    cout<<0;
    return 0;
  }

  ll k = x-(x+y)/3;
  ll l = y-(x+y)/3;

//  cout<<k<<' '<<l<<endl;
  cout<<comb(k+l, k);
  

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  static int[] a;
  static final int INIT = 2147483647;
  static ArrayList<Integer> ansArr = new ArrayList<Integer>();

	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();

    a = new int[n];
    for(int i = 0 ; i < n ; i++) {
      a[i] = INIT;
    }

    int com,x,y = 0;
    q=q-1;
    while(q != -1) {
      com = sc.nextInt();
      x = sc.nextInt();
      y = sc.nextInt();
      if(com == 0) {
        a[x] = y;
      } else ansArr.add(find(x, y));
      q--;
    }

    for(int ans: ansArr) System.out.println(ans);
	}

  static int find(int x, int y) {
    if(x == y) return a[x];
    int min = INIT;
    for(int i = x; i <= y; i++) {
      if (a[i] < min) {
        min = a[i];
      }
    }
    return min;
  }
}



Measured memory_bytes: 102292
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#define FILE_NAME "a"

const int MAXN = 1e5 + 10;

int n;
vi a;

bool read() {
	if  (scanf("%d", &n) < 1) {
		return 0;
	}
	a.clear();
	forn(i, n) {
		int x;
		scanf("%d", &x);
		if  (a.empty() || x != a.back()) {
			a.pb(x);
		}
	}
	return 1;
}


int go(int s) {
	if  (s >= sz(a)) {
		return 0;
	}
	for (int i = s + 2; i < sz(a); ++i) {
		if  ((a[i] < a[i - 1]) != (a[s + 1] < a[s])) {
			return 1 + go(i);
		}
	}
	return 1;
}

int solve() {
	return go(0);
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		cout << solve() << endl;
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 892
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        sc.close();

        StringBuilder sb = new StringBuilder();
        String S1 = S.substring(0, 1);
        sb.append(S1);
        for (int i=1; i<N; i++) {
            if (!S1.equals(S.substring(i, i+1))) {
                S1 = S.substring(i, i+1);
                sb.append(S1);
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(sb.length());
        out.flush();
    }
}

Measured memory_bytes: 33380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner fr = new Scanner(System.in);
        int n = fr.nextInt();
        int x = fr.nextInt();
        int xx = x;
        int t = fr.nextInt();
        int tt = t;
        if(n<x){
            System.out.println(t);
        }
        else{
            while(x<n){
                x+=xx;
                t+=tt;
            }
            System.out.println(t);
        }
    }
}


Measured memory_bytes: 35736
book_count, subject_count, each_understanding_level = gets.split.map(&:to_i)
book_info_list = book_count.times.map { gets.split.map(&:to_i) }

buy_pattern_list = [0,1].repeated_permutation(book_count).map do |bits|
  array = bits.each_with_index.each_with_object([]) do |(bit, i), result|
    result << book_info_list[i] if bit == 1
  end
  next if array.empty?
  array
end.compact

understand_list = buy_pattern_list.filter do |patterns|
  transposed_list = patterns.transpose
  transposed_list.each_with_index.all? do |list, i|
    next true if i == 0
    list.sum >= each_understanding_level
  end
end

p understand_list.empty? ? -1 : understand_list.map { |items| items.transpose[0].sum }.min

# 流れをまとめると・・・
# bit全探索で、購入パターンを網羅。bit全探索 => 購入パターンに変換と言う感じ
# ※後書き: combination使えばbit全探索のロジック書かずに、全パターン出してくれた。のでそれを連結する処理だけ書いた
# その中から、理解度を満たしている購入パターンを抽出
# その中から、最小合計金額を算出

# ポイントは、買うか買わないかのパターンに気づいて、bit全探索が使えると閃けるか。
# これ、conmbinationで書き直してみよう

Measured memory_bytes: 15608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (d <= s * t ? "Yes" : "No") << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)

def esth(x, y, h, cx, cy):
    return h + abs(x-cx) + abs(y-cy)


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0 and h > 0:
                ch = esth(x, y, h, cx, cy)
            elif h > 0:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
            else:
                if max(ch - abs(x-cx) - abs(y-cy), 0) != h:
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
N = int(input())
if N < 105 :
    print(0)
elif N >= 105 and N<135 :
    print(1)
elif N>= 135 and N<165 :
    print(2)
elif N>=165 and N<189 :
    print(3)
elif N>=189 and N<195 :
    print(4)
else :
    print(5)

Measured memory_bytes: 3064
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, x] <- map read.words <$> getLine :: IO [Int]
    ls <- U.unfoldrN n (C.readInt.C.dropWhile isSpace) <$> C.getLine
    print . U.length . U.takeWhile(<=x) $ U.scanl'(+)0ls

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 508
N = int(input())
H = list(map(int, input().split()))

now = H[0] - 1
H[0] = H[0] - 1

for i in range(1, N):
    if H[i] > now:
        H[i] -= 1
    now = H[i]


for i in range(N - 1):
    if H[i + 1] >= H[i]:
        continue
    else:
        print('No')
        exit()
print('Yes')


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

int main() {
    int r, t, i;
    char A[4];
    scanf("%c%c%c%c", &A[0], &A[1], &A[2], &A[3]);
    A[0] -= '0';
    A[1] -= '0';
    A[2] -= '0';
    A[3] -= '0';
    for (r = 0; r < 8; ++r) {
        t = A[0];
        for (i = 0; i < 3; ++i) t += A[i + 1] * ((r & (1 << i)) ? -1 : 1);
        if (t == 7) {printf("%d%c%d%c%d%c%d=7\n", A[0], ((r & 1) ? '-' : '+'), A[1], ((r & 2) ? '-' : '+'), A[2], ((r & 4) ? '-' : '+'), A[3]); return 0;}
    }
}


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

using namespace std;

const int N = 2005;
const int mod = 1e9 + 7;

int n, k, a[N], x[N], y[N], ans = 0;

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main(){
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (a[i] > a[j]) y[i]++;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i != j && a[i] > a[j]) x[i]++;
        }
    }

    for (int i = 1; i <= n; i++) {
        add(ans, 1LL * k * (k - 1) % mod * 500000004 % mod * x[i] % mod);
        add(ans, 1LL * y[i] * k % mod);
    }

    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
    
    static class Task {
    	public void solve(int TestNumber, InputReader in, PrintWriter out) {
    		int n = in.nextInt();
    		int m = in.nextInt();
    		boolean[] has = new boolean[n];
    		int[] cnt = new int[n];
    		has[0] = true;
    		for(int i = 0; i < n; ++i) {
    			cnt[i] = 1;
    		}
    		int a, b;
    		for(int i = 0; i < m; ++i) {
    			a = in.nextInt() - 1;
    			b = in.nextInt() - 1;
    			if(has[a]) {
    				has[b] = true;
    			}
    			cnt[a]--;
    			cnt[b]++;
    			if(cnt[a] == 0)has[a] = false;
    		}
    		int ans = 0;
    		for(int i = 0; i < n; i++) {
    			if(has[i])ans++;
    		}
    		out.println(ans);
    	}
    }
    
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}


Measured memory_bytes: 21240
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n,m;
int main(void){
	scanf("%d%d",&n,&m);
	vector<tuple<lli,lli,lli>> vs;
	rep(i,m){
		lli l,r,c;
		scanf("%lld%lld%lld",&l,&r,&c);
		vs.push_back(make_tuple(l,r,c));
	}
	sort(vs.begin(),vs.end());
	
	typedef tuple<lli,lli> qt;
	pque(qt) que;
	que.push(make_tuple(0,1));
	rep(i,vs.size()){
		lli l,r,c;
		tie(l,r,c) = vs[i];
		for(;;){
			if(que.empty()){
				puts("-1");
				return 0;
			}
			lli nc,p;
			tie(nc,p) = que.top();
			if(p < l)que.pop();
			else{
				que.push(make_tuple(c+nc,r));
				break;
			}
		}
	}
	
	lli ans=-1;
	while(!que.empty()){
		lli nc,p;
		tie(nc,p) = que.top();
		que.pop();
		if(p >= n){
			ans = nc;
			break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}






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

int main (){
  long int A, B;
  cin >> A >> B;

  long int ans = 1;
 
  rep(i, B+1){
    ans = A * i;
    if (ans % B == 0){
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int base(int N, int B){
  int res = 0;
  int pow = 1;
  while(N){
    if(N % B >= 10) return INF;
    res += pow * (N % B);
    N /= B;
    pow *= 10;
  }
  return res;
}
int solve(int A, int B, int C){
  bool exist = false;
  for(int b = 2; b <= 16; b++) if(base(A, b) == B) exist = true;
  if(!exist) return -1;
  int last = B;
  for(int x = A + 1; x <= C; x++){
    int next = INF;
    for(int b = 2; b <= 16; b++) if(base(x, b) >= last) next = min(next, base(x, b));
    if(next == INF) return -1;
    last = next;
  }
  return last;
}

int main(){
  int A, B, C;
  while(cin >> A >> B >> C && A != -1){
    cout << solve(A, B, C) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
use POSIX qw(ceil); 
($N,$K)=glob<>;
$p=0;

foreach (1..$N){
    if ($_<$K){
        $T=2 ** ceil(log($K/$_)/log(2));
        $p += (1/$N)/$T;
    }else{
        $p += 1/$N;
    }
}
print $p;


Measured memory_bytes: 1920
n, a, b=map(int, input().split())
if a%2==b%2:
  print((b-a)//2)
else:
  if b-a>1:
    if a-1<=n-b:
      print(a+(b-a-1)//2)
    else:
      print(n-b+1+(b-a-1)//2)
  else:
    if a-1<=n-b:
      print(b-1)
    else:
      print(n-a)

Measured memory_bytes: 3060