akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	k, v int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return p[i].v > p[j].v
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

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

	ma := make(map[int]int, n/2)
	mb := make(map[int]int, n/2)
	var t int
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		if i%2 == 0 {
			ma[t]++
		} else {
			mb[t]++
		}
	}

	al, bl := make(pairs, n/2), make(pairs, n/2)
	var i int
	for k, v := range ma {
		al[i] = pair{k, v}
		i++
	}
	i = 0
	for k, v := range mb {
		bl[i] = pair{k, v}
		i++
	}

	sort.Sort(al)
	sort.Sort(bl)

	maxA, maxB := al[0], bl[0]
	secondA, secondB := al[1], bl[1]

	if maxA.k == maxB.k {
		if maxA.v == maxB.v {
			if secondA.v < secondB.v {
				maxB = bl[1]
			} else {
				maxA = al[1]
			}
		} else if maxA.v < maxB.v {
			maxA = al[1]
		} else {
			maxB = bl[1]
		}
	}

	fmt.Println(n - maxA.v - maxB.v)
}

Measured memory_bytes: 7424
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val pcnt = IntArray(n + 1)
    (2..n).forEach { i ->
        var div = i
        var j = 2
        while (j <= i) {
            if (div % j == 0) {
                pcnt[j]++
                div /= j
                if (div == 1) break
                continue
            }
            j++
        }
    }
    var result = 1L
    pcnt.filter { it != 0 }
        .forEach {
            result = (result * (it + 1)) % 1000000007
        }
    println(result)
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // int -> ll
#include <utility> // C++11から

int main(){
    ll x,y,z,t;
    cin >> x>>y>>z;
  	std::swap(x,y);
  	std::swap(x,z);
    cout << x <<" "<< y << " " << z << endl;


}


Measured memory_bytes: 3620
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const INF: i64 = 10000000000000000;

fn main() {
    let mut sc = Scanner::new();

    let n: usize = sc.cin(); // nodes
    let m: usize = sc.cin(); // edges
    let s: usize = sc.cin::<usize>() - 1;
    let t: usize = sc.cin::<usize>() - 1;

    // let mut es = vec![];
    let mut es1 = vec![vec![]; n];
    let mut es2 = vec![vec![]; n];
    for _ in 0..m {
        let u = sc.cin::<usize>() - 1;
        let v = sc.cin::<usize>() - 1;
        let a: i64 = sc.cin();
        let b: i64 = sc.cin();
        // es.push((u, v, a, b));
        es1[u].push((v, a));
        es1[v].push((u, a));
        es2[u].push((v, b));
        es2[v].push((u, b));
    }

    let mut d1 = vec![INF; n];
    let mut d2 = vec![INF; n];

    {
        d1[s] = 0;
        let mut stack = BinaryHeap::new();
        stack.push((0, s));
        while let Some((_, u)) = stack.pop() {
            for &(v, cost) in es1[u].iter() {
                if d1[v] > d1[u] + cost {
                    d1[v] = d1[u] + cost;
                    stack.push((-d1[v], v));
                }
            }
        }
    }

    {
        d2[t] = 0;
        let mut stack = BinaryHeap::new();
        stack.push((0, t));
        while let Some((_, u)) = stack.pop() {
            for &(v, cost) in es2[u].iter() {
                if d2[v] > d2[u] + cost {
                    d2[v] = d2[u] + cost;
                    stack.push((-d2[v], v));
                }
            }
        }
    }

    let d = (0..n).map(|i| d1[i] + d2[i]).collect::<Vec<_>>();
    // trace!(d);

    let money: i64 = 1000000000000000;
    let mut ans = vec![];
    let mut mn = d[n-1];
    for i in 0..n {
        mn = min(d[n - i - 1], mn);
        ans.push(money - mn);
    }

    for i in 0..n {
        put!(ans[n - i - 1]);
    }

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

const int INF = 1 << 30;

int h[100100];
int dp[100100];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];

    for (int i = 0; i < N; i++) dp[i] = INF;
    dp[0] = 0;
    
    for (int i = 0; i < N; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    cout << dp[N - 1] << endl;
}

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

int main()
{
    int n,x,y,k=0,kmax=0;

    cin>>n>>x;
    for(int i=2;i<=n;i++){
        cin>>y;
        if(x>=y){
            k++;
        }
        else{
            if(k>kmax)  kmax=k;
            k=0;
        }
        x=y;
    }
    if(k>kmax)  kmax=k;
    cout<<kmax;    
	return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    long ng = 50001;
    long ok = 0;
    while (1 < ng - ok)
    {
        long m = (ok + ng) / 2;
        if (m * 108 / 100 < N)
        {
            ok = m;
        }
        else
        {
            ng = m;
        }
    }
    if ((ok + 1) * 108 / 100 == N)
    {
        writeln(ok + 1);
    }
    else
    {
        writeln(":(");
    }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vector< complex<double> > a(N);
    vector< complex<double> > s(N+1);
    vector< pair<double,complex<double> > > b(N);

    int x,y;
    Rep(i,N){
        Scd2(x,y);
        a[i] = {x,y};
        b[i] = { arg(a[i]), a[i] };
    }

    sort(b.begin(),b.end(), [&]( const pair< double, complex<double> > &a , const pair< double, complex<double> > &b ){ return a.first < b.first; } );

    Rep(i,N){
        s[i+1] += b[i].second + s[i];
    }

    double ans = 0;

    Rep(l,N){
        Repe(r,N+1,l+1){
            ans = max( ans, abs(s[r]-s[l]) );
            ans = max( ans, abs(s[N]-s[r]+s[l]) );
        }
    }

    printf( "%.25lf\n", ans );

    return 0;
}




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

int main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }

    sort(t.begin(), t.end());
    t.push_back(2 * 1e9 + 1);

    int next = t[0];
    int cnt = 0, ans = 0;
    for (int i = 0; i < n + 1; ++i) {
        if (cnt == c || t[i] > next + k){
            cnt = 1;
            next = t[i];
            ++ans;
            continue;
        }
        if (t[i] <= next + k) ++cnt;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]
col = [[0]*3 for i in range(C)]
for i in range(N):
    for j in range(N):
        p = c[i][j]-1
        for k in range(C):
            col[k][(i+j)%3] += D[p][k]
ans = 10**18
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            ans = min(ans, col[i][0] + col[j][1] + col[k][2])
print(ans)

Measured memory_bytes: 44636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n,x,y;
  cin >> n >> x >> y;
  x--,y--;
  if(x > y){
    swap(x,y);
  }
  vector<ll> vec(n,0);
  rep(i,n){
    REP(j,i+1,n){
      t1 = min((ll)j-i,abs(x-i) + 1 + (abs(y-j)));
      vec[t1]++;
    }
  }
  REP(i,1,n){
    cout << vec[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b = 1, e;
	cin >> a;
	if (a == 1 || a == 2) {
		cout << '4' << endl;
	}
	else {
		while (a != 1) {
			if (a % 2 == 0) {
				a = a / 2;
			}
			else {
				a = a * 3 + 1;
			}
			b++;
		}
		cout << b + 1 << endl;
	}
	cin >> e;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int unused __attribute__((unused));
  int N, D, i, cnt = 0;
  long long X, Y;

  unused = scanf("%d %d", &N, &D);
  for(i=0; i<N; i++){
    unused = scanf("%lld %lld", &X, &Y);
    if(sqrt(X*X+Y*Y) <= D) cnt++;
  }

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

Measured memory_bytes: 2156
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include"math.h"

using namespace std;

int main(){
    int n, m, count = 0;
    cin >> n >> m;
    count += ((n-1)*n)/2;
    count += ((m-1)*m)/2;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define ll long long 
ll fac(ll n);
int main(){
  ll n;
  cin >> n;
  cout << fac( n ) << endl;
}
ll fac(ll n){
  if(n == 1)return 1;
  return n * fac(n-1);
}

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

using namespace std;

int N, B, R;
long long pas[2005][2005];
long long MOD = 1e9+7;

long long add(long long a, long long b){
    return (a+b)%MOD;
}

long long mult(long long a, long long b){
    return (a*b)%MOD;
}

int main(){
    cin >> N >> B;
    R = N-B;
    for(int i= 0; i<=2004; i++){
        pas[i][0] = 1;
    }
    for(int i = 1; i<=2004; i++){
        for(int j = 1; j<=i; j++){
            pas[i][j] = add(pas[i-1][j-1], pas[i-1][j]);
        }
    }
    for(int i = 1; i<=B; i++){
        cout << mult(pas[R+1][i], pas[B-1][B-i]) << "\n";
    }
}


Measured memory_bytes: 30208
n = int(raw_input())
l = [int(x) for x in raw_input().split()]
ret = 0
for bit in xrange(62):
  num = sum([(l[i] & (1 << bit)) > 0 for i in xrange(n)])
  ret += num * (n - num) * (1<<bit)
print ret % 1000000007


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

int main(void) {
   int a, b;
   cin >> a >> b;
   a = a - 1;
   b = b - 1;
   if(b % a > 0) {
      cout << b / a + 1;  
   } else {
      cout << b / a;
   }
   return 0;
}



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

int main(){
  int n;
  cin >> n;
  double d[n][n];
  double x[n], y[n];
  rep(i,n) cin >> x[i] >> y[i];
  rep(i,n) {
    rep(j,n) d[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  }
  vector<int> a(n);
  rep(i,n) a[i] = i;
  int c = 0;
  double s = 0;
  do {
    for(int i = 1; i < n; i++)  s += d[a[i]][a[i-1]];
    c++;
  } while (next_permutation(a.begin(),a.end()));
  double ans = s/c;
  printf("%.9f\n",ans); 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i,j;
  for(j=0;j<s.size();j++){
    if(s==t){
      cout << "Yes" << "\n";
      return 0;
    }
    s=s.back()+s.substr(0,s.size()-1);
  }
  cout << "No" << "\n";
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}



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

    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == t[i]) ans++;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	int R; cin >> R;
	printf("%.10f\n", 2 * R * 3.14159265358979323846);
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
int main()
{
/*	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int n;
	string s;
	cin>>n>>s;
	if(n&1)
		cout<<"No";
	else
	{
		int mid=n/2;
		if(s.substr(0,mid)==s.substr(0+mid,mid))
			cout<<"Yes";
		else
			cout<<"No";
	}
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    int n,m,ans=0;
    str s;
    cin >> n >> m;
    if(n<=0&&m>=0)cout << "Zero" << endl;
    else if(n<0&&((n-m)%2)==0)cout << "Negative" << endl;
    else cout << "Positive" << endl;
    ios::sync_with_stdio(false);
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,M,a[10000],sum=0;
	cin>>N>>M;
	for(int i=0;i<M;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>N)
        cout<<-1<<endl;
    else
        cout<<N-sum<<endl;
}


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

int main() {
  long k,ans,a,b,n;
  cin>>a>>b>>n;
  if(b-1<=n){
    k=a*(b-1);
    ans=k/b;
  }
  else{
    k=a*n;
    ans=k/b;
  }
  cout<<ans;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>
 
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
int main() {
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    
 
    string t;
    cin >> t;

    string s = "AKIHABARA";
    for (int i = 0; i < sz(s); ++i) {
        if (sz(t) == i || t[i] != s[i]) {
            t = t.substr(0, i) + 'A' + t.substr(i, sz(t) - i);
        }
    }
    cout << (t == s ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int box [3][3], n, num;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			scanf ("%d", &box[i][j]);
		}
	}
	scanf ("%d", &n);
	for (int k = 0; k < n; k++){
		scanf ("%d",&num);
		
		for (int i = 0; i < 3; i++){
			for (int j = 0; j < 3; j++){
				if(num == box[i][j]){
					box[i][j] = 0;
				}
			}
		}
	}
	
	if (box[0][0] == 0 && box[0][1] == 0 && box[0][2] == 0){
		printf ("Yes");
	} else if (box[0][0] == 0 && box[1][0] == 0 && box [2][0] == 0){
		printf ("Yes");
	}  else if (box[0][0] == 0 && box[1][1] == 0 && box [2][2] == 0){
		printf ("Yes");
	} else if (box[0][1] == 0 && box[1][1] == 0 && box [2][1] == 0){
		printf ("Yes");
	} else if (box[0][2] == 0 && box[1][2] == 0 && box [2][2] == 0){
		printf ("Yes");
	}  else if (box[1][0] == 0 && box[1][1] == 0 && box [1][2] == 0){
		printf ("Yes");
	}  else if (box[2][0] == 0 && box[2][1] == 0 && box [2][2] == 0){
		printf ("Yes");
	}  else if (box[2][0] == 0 && box[1][1] == 0 && box [0][2] == 0){
		printf ("Yes");
	}  else{
		printf ("No");
	}
	
return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

struct edge {
    edge() : link_to(0), cost(0) {}
    edge(int t, int c) : link_to(t), cost(c) {}
    int link_to;
    int cost;
};

void dijkstra(std::vector<std::vector<edge>>& g, std::vector<int>& d, int s) {
    priority_queue<P, std::vector<P>, greater<P>> que;
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : g[v]) {
            if (d[e.link_to] > d[v] + e.cost) {
                d[e.link_to] = d[v] + e.cost;
                que.push(make_pair(d[e.link_to], e.link_to));
            }
        }
    }
}


int main(int argc, char **argv) {
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n, 0);
    std::vector<std::vector<edge>> g(n);
    std::vector<int> distance;

    for (int i=0; i<n-1; ++i) {
        g[i].push_back(edge(i+1, 1));
        g[i+1].push_back(edge(i, 1));
    }
    g[x-1].push_back(edge(y-1, 1));
    g[y-1].push_back(edge(x-1, 1));

    for (int i=0; i<n; ++i) {
        vector<int> d(n, 100000);
        dijkstra(g, d, i);
        for (int i=0; i<n; ++i) {
            ++ans[d[i]];
        }
    }

    for (int i=1; i<n; ++i) {
        cout << (ans[i]/2) << endl;
    }

    return 0;
}

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

int main(){
  ll x;
  cin >> x;
  vector<ll> v(2000);
  for(ll i = 0; i < 2000; i++) v[i] = (i-1000)*(i-1000)*(i-1000)*(i-1000)*(i-1000);
  rep(i,2000) {
    rep(j,2000) {
      if(v[i]-v[j] == x) {
        cout << i-1000 << " " << j-1000 << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    int d[10001];
    for(int i=0;i<n;i++)
        cin>>d[i];
    sort(d,d+n);
    int cal=0,co=0;
    for(int i=n-1;i>=0;i--)
        if((double)(cal+d[i]+c)/((co+1)*b+a)>(double)(cal+c)/(co*b+a))
            cal+=d[i],co++;
        else
            break;
    cout<<(cal+c)/(co*b+a)<<endl;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vint A(N + 2);
    ll S = 0;
    rep(i, N)
    {
        cin >> A[i + 1];
    }
    rep(i, N + 1)
    {
        if (i + 1 < N + 1)
            S += abs(A[i] - A[i + 1]);
        else
            S += abs(A[i]);
    }
    rep(i, N)
    {
        cout << S - (abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i + 2])) + abs(A[i] - A[i + 2]) << "\n";
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    s[3] = '8';
    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, sum, cnt;
	int i, j;

	while (1) {
		scanf("%d", &n);
		if (n == 0)
			break;
		cnt = 0;
		for (i = 1; i <= n / 2; i++) {
			sum = 0;
			for (j = i; j < n; j++) {
				sum += j;
				if (sum >= n)
					break;
			}
			if (sum == n)
				cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}
			

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		long[] dp = new long[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for (int i = 2; i < n; i++) {
			long cost1 = dp[i - 1] + Math.abs(h[i] - h[i - 1]);
			long cost2 = dp[i - 2] + Math.abs(h[i] - h[i - 2]);
			
			dp[i] = Math.min(cost1, cost2);
		}
		
		System.out.println(dp[n - 1]);
		
		sc.close();
	}
}



Measured memory_bytes: 50948
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500006;
int dp[5001][5001];
void solve(){
	int n,m;
	cin>>n>>m;
	vi s(n),t(m);
	cin>>s>>t;
	//~ int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i>0)add(dp[i][j],dp[i-1][j]);
			if(j>0)add(dp[i][j],dp[i][j-1]);
			if(i>0&&j>0)add(dp[i][j],-dp[i-1][j-1]);
			if(s[i]==t[j]){
				if(i>0&&j>0)
				add(dp[i][j],dp[i-1][j-1]+1);
				else add(dp[i][j],1);
				//~ add(ans,dp[i][j]);
			}
		}
	}
	//~ add(ans,1);
	cout<<(dp[n-1][m-1]+1)%mod;
	
	
	
}
	
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}


}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 40448
#include <iostream>
#include <algorithm>
#include <vector>

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

struct Coord {
    int y; 
    int x;
    int cost;
};

void Warshall (vector<vector<int> > &cost) {
    int cost_number = cost[0].size();
    for (int k = 0; k < cost_number; k++) {
        for (int i = 0; i < cost_number; i++) {
            for (int j = 0; j < cost_number; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    return;
}

int main(void) {
    int n; // ????????°
    int m; // ???????????????????????§?????¶?????????
    int l; // ??????????¨??????????????????° 
    int k; // ?????¨????????´??\?????¶???????????°
    int a; // ??¬?????????????????¨????????? towm[a] = 1
    int h; // ????§??§??????¬?????????????????¢????????????????????? town[h] = 2

    int temp_input; // ??\??????????????????
    Coord coord; // ??\??????????????????

    while (1) {
        cin >> n >> m >> l >> k >> a >> h;
        if (n == 0 && m == 0 && l == 0 && k == 0 && a == 0 && h == 0) {
            break; 
        }
        vector<int> frozen_list; 
        frozen_list.push_back(a); // ??????????¨?????????????????????? 
        frozen_list.push_back(h); // ??????????¨?????????????????????? 
        for (int input = 0; input < l; input++) {
            cin >> temp_input; 
            frozen_list.push_back(temp_input); // ??????????¨?????????????????????? 
        }

        vector<vector<int> > cost(n, vector<int>(n, 1e09));
        for (int i = 0; i < n; i++) {
            cost[i][i] = 0;
        }
        for (int input = 0; input < k; input++) {
            cin >> coord.y >> coord.x >> coord.cost;
            cost[coord.y][coord.x] = coord.cost;
            cost[coord.x][coord.y] = coord.cost;
        }
        Warshall (cost);

        vector<vector<int> > frozen_array(l + 2, vector<int>(l + 2, 1e09));
        for (int i = 0; i < frozen_list.size(); i++) {
            for (int j = 0; j < frozen_list.size(); j++) {
                frozen_array[i][j] = cost[frozen_list[i]][frozen_list[j]];
                if (frozen_array[i][j] > m) {
                    frozen_array[i][j] = 1e09;
                }
            }
        }

        Warshall (frozen_array); 

        if (frozen_array[0][1] >= 1e09) {
            cout << "Help!" << endl; 
        } else if (frozen_array[0][1] <= m) {
            cout << frozen_array[0][1] << endl;
        } else {
            cout << 2 * frozen_array[0][1] - m << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3116
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

counts = 0

(A+1).times do |fiveHandredCounts|
    (B+1).times do |oneHandredCounts|
        (C+1).times do |fiftyCounts|
            coinSum = 500*fiveHandredCounts + 100*oneHandredCounts + 50*fiftyCounts
            if coinSum == X
                counts += 1
            end
        end
    end
end

puts counts

Measured memory_bytes: 1788
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()
            



Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m;
long long dp[2005][3], ans;
int main(){
	scanf("%d%d", &n, &m);
	dp[0][0] = 1;
	for(int i=3*n-1; i>=0; i--) for(int j=n; j>0; j--){
		(dp[j][0] += dp[j][1] + dp[j][2]) %= m;
		dp[j][2] = dp[j][1] * i % m;
		dp[j][1] = dp[j-1][0] * i % m;
	}
	rep(j,n+1) ans += dp[j][0];
	printf("%lld\n", ans % m);
}

Measured memory_bytes: 256
while gets do
  ar = $_.split(' ').map(&:to_i)
  br = gets.split(' ').map(&:to_i)
  hit = ar.map.with_index { |a, i| a == br[i] ? 1 : 0 }.inject(&:+)
  brow = (ar&br).size - hit
  puts "#{hit} #{brow}"
end

Measured memory_bytes: 6112
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.typecons;

alias Tuple!(int, "id", int, "ranking", int, "ans") Team;

void main() {
  Team[] team;
  int[] ranking;
  int i = 0;
  while(true) {
    int[] line = readln.chomp.split(",").map!(to!(int)).array;
    if (line[0] == 0 && line[1] == 0) break;
    team ~= Team(line[0], 0, line[1]);
  }
  sort!((a, b) => a.ans > b.ans)(team);
  auto prev = team[0].ans;
  int rank = 1;
  team[0].ranking = rank;
  foreach(ref t; team[1..$]) {
    if (prev > t.ans) rank++;
    t.ranking = rank;
    prev = t.ans;
  }
  while(true) {
    string number = readln.chomp;
    if (stdin.eof()) break;
    foreach(t; team) if (number.to!(int) == t.id) writeln(t.ranking);
  }
}

Measured memory_bytes: 1084
N, M = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.sort()

dev = M - N
if dev <= 0:
    print(0)
else:
    distance_list = [X_list[i + 1] - X_list[i] for i in range(M - 1)]
    distance_list.sort()
    # print(distance_list)
    ans = 0
    for i in range(len(distance_list)-N+1):
        ans += distance_list[i]
    print(ans)


Measured memory_bytes: 13960
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, K = ni()
    val A = na(N)
    val cum = cumSum(A)
    var p = 0
    val C = Array.ofDim[Long](N * (N + 1) / 2)
    rep(N) { l =>
      l until N foreach { r =>
        C(p) = cum(r + 1) - cum(l)
        p += 1
      }
    }

    var ans = 0L
    rep_r(60) { k =>
      val b = 1L << k
      var cnt = 0
      rep(C.length) { i =>
        if ((ans == 0 || (C(i) & ans) == ans) && (C(i) & b) > 0) {
          cnt += 1
        }
      }
      if (cnt >= K) ans |= b
    }

    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    rep(n) { i =>
      rep(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 32452
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	ll N, M;
	cin >> N >> M;
	if(N*2 >= M) {
		cout << M/2 << endl;
	}
	else {
		ll res = 0;
		res = N;
		M -= N*2;
		res += M/4;
		cout << res << endl;
	}
	return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<vector<char>> ss(n, vector<char>(n));
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < n; j++) {
            cin >> ss[i][j];
        }
    }

    i64 ans = 0;
    for (i64 i = 0; i <= 2 * n - 2; i++) {
        i64 ay = min(i, n - 1), ax = min(2 * n - 2 - i, n - 1);

        i64 err = 0;
        for (i64 ry = 0; ry < n; ry++) {
            for (i64 rx = ry; rx < n; rx++) {
                if (ss[(ay + ry) % n][(ax + rx) % n] != ss[(ay + rx) % n][(ax + ry) % n]) err++;
            }
        }
        if (!err) ans += min(ay, ax) + 1;
    }

    cout << ans << endl;
}

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


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){


	int N; cin >> N;
	char s[1000000]; cin >> s;

	char buf = s[0];

	int ans = 1;
	FOR(i,1,N){
		if(buf != s[i]){
			buf = s[i];
			ans++;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc099/tasks/arc099_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    res = (N-1+K-2)/(K-1);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[1000];
  cin>>n;
  for(int k=0;k<n;k++){
    cin>>a[k];
  }
  long long res=100000000,y;
  for(int l=1;l<=100;l++){
    y=0;
    for(int k=0;k<n;k++){
      y+=(a[k]-l)*(a[k]-l);
      //cout<<(a[k]-l)*(a[k]-l)<<endl;
    } 
    res=min(res,y);
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    if(((n-1)*(n-2))/2 < k) cout << -1 << endl;
    else{
        ll m = (n-1) + (((n-1)*(n-2))/2-k);
        cout << m << endl;
        for(ll i=1; i<=n-1 && m>0; i++){
            for(ll j=i+1; j<=n && m>0; j++){
                cout << i << " " << j << endl;
                m--;
            }
        }
    }
}

Measured memory_bytes: 3596
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def isok(a,idx):##適宜変更
    if a+m<ap:
        return False
    elif idx<=p:
        return True
    tmp = 0 #a+mを超えないように割り振れる最大値
    for i in range(n-1,-1,-1):
        if a+m<A[i] or i<p-1:break
        tmp+= min(a+m - A[i],m)
    tmp-=m#自分自身
    #print(a,tmp)
    return  tmp>=(v-p)*m

def bisect(ls): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1,Trueならlen(ls)-1
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,x):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2
    return ok ##一番右のTrueのindex  Trueの個数はok+1こ

n,m,v,p = ma()
A = lma();A.sort(reverse=True)
#print(A)
ap = A[p-1]
ans = bisect(A)+1
print(ans)


Measured memory_bytes: 91272
#include <cstdio>

int main()
{
		int Count =0;
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		for (int i = a; i <= b; i++){
			if(c%i ==0){
				Count+=1;
		}
}
		printf("%d\n",Count);
}

Measured memory_bytes: 2748
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
n = int(input())
if n == 2:
    print(1)
elif n == 3:
    print(2)
elif n == 4:
    print(3)
else:
    count = 2
    check_list = make_divisors(n-1)
    count += len(check_list)
    check_list = make_divisors(n)
    for k in check_list:
        temp_n = n // k
        while(True):
            if temp_n % k == 0:
                temp_n = temp_n // k
            elif temp_n % k == 1:
                count += 1
                break
            else:
                break
    print(count)


Measured memory_bytes: 3188
#include <stdio.h>

void Chessboard(int H, int W)
{	
	for(int y = 0; y < H; y++){
		for(int x = 0; x < W; x++){
			if(y % 2 != 0){				//y????\???°?????¨???
				if(x % 2 != 0){			//xy????\???°?????¨???			
					printf("#");
				}
				else{					//??¶??°?????¨???
					printf(".");
				}
			}
			else{						//y?????¶??°?????¨???
				if(x % 2 != 0){			//xy????\???°?????¨???			
					printf(".");
				}
				else{					//??¶??°?????¨???
					printf("#");
				}
			}
		}
		printf("\n");
	}
}
		
int main(void)
{
	int H, W;
	
	while(true){
	
		scanf("%d %d",&H, &W);
		
		if(H == 0 && W == 0){
			break;
		}
		
		Chessboard(H, W);
				
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 2620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n,k;
    cin>>n>>k;
    map<int,ll> mp;
    rep(i,n){
        int a;
        cin>>a;
        mp[a]++;
    }
    V<pair<ll,int>> p;
    for(auto pp:mp){
        int b=pp.ft,bb=pp.sc;
        p.push_back(make_pair(bb,b));
    }
    if(p.size()<=k) cout<<0<<endl;
    else{
        sort(all(p));
        int m=p.size();
        ll ans=0;
        for(int i=0;i<m-k;i++) ans+=p[i].ft;
        cout<<ans<<endl;
    }
}

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

int main() {
    string s, p;
    cin >> s >> p;

    s += s;

    size_t found = s.find(p);
    if (found != string::npos) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    cout << endl;
}


Measured memory_bytes: 3220
until (xyz = gets.split(" ").map(&:to_i)) == [0, 0, 0]
  xy = xyz.combination 2
  gets.to_i.times do
    r = gets.to_i
    puts xy.any? {|(x, y)| (x / 2) ** 2 + (y / 2) ** 2 < r ** 2} ? 'OK' : 'NA'
  end
end

Measured memory_bytes: 6104
N,P = map(int,input().split())
A = list(map(int,input().split()))
odd = 0
for i in range(N) :
    if A[i] % 2 != 0 :
        odd += 1
if odd == 0 :
    if P == 0 :
        ans = 2**N
    else :
        ans = 0
else :
    ans = 2**(N-1)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define pie M_PI
#define maxx 2147483647
#define FOR(i,a,b) for(int i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const long long int maxs = 100000000;




int main()
{

    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    // cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    int c = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] != t[i])
            c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 3836
import sys
readline = sys.stdin.readline

X, K, D = map(int, readline().split())

if X < 0:
  X = -X

s = X//D

if s > K:
  print(X-K*D)
  exit()

k = K - s
x = X - D*s
if k%2 == 0:
  print(x)
else:
  print(D-x)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n,k;
    cin>>n>>k;
    if(n%k==0)cout<<0<<endl;
    else cout<<min(abs((n%k)-k),n)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    string s,t;
    cin>>s>>t;
    
    vector<int> cs(s.size(),0),ct(t.size(),0);
    
    rep(i,s.size()){
        if(s[i]=='A')cs[i]=1;
    }
    rep(i,t.size()){
        if(t[i]=='A')ct[i]=1;
    }
    rep(i,s.size()-1)cs[i+1]+=cs[i];
    rep(i,t.size()-1)ct[i+1]+=ct[i];
    
    int q;
    cin>>q;
    rep(i,q){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--,b--,c--,d--;
        
        int x=cs[b], y=ct[d];
        if(a!=0)x-=cs[a-1];
        if(c!=0)y-=ct[c-1];
        x+=b-a+1;
        y+=d-c+1;
        
        if(abs(x-y)%3==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    cin >> N;
    vector<ll> result = vector<ll>(0);
    ll count = 0;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    while(N != 0){
        //cout << N % 2 << endl;
        if(N % 2 == 1 || N % 2 == -1){
            result.push_back(1);
            N -= pow(-1,count);
        }else{
            result.push_back(0);

        }
        //cout << N << endl;
        count++;
        N = N / 2;
    }
    for(int i = result.size()-1; i >= 0; i--){
        cout << result[i];
    }
    cout << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <sstream>
using namespace std;
string i2s(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}
int main(){
  int n,i,j,k,b;
  string str;
  char c;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> c;
    str+=c;
  }
  k=0;
  while(str.find(i2s(k))!=-1){
    k++;
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 1228