akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a_list = list(map(int,input().split()))

kisuus = [a_list[i] for i in range(0,N,2)]
guusuus = [a_list[i] for i in range(1,N,2)]

n_kisuu = len(kisuus)
n_guusuus = len(guusuus)

from collections import Counter
kisuu_cnter = Counter(kisuus)
guusuu_cnter = Counter(guusuus)

def func(cnter):
    tmp = [(k,v) for k, v in sorted(cnter.items(), key=lambda x: -x[1])] + [(-1,0)]
    tmp0 = tmp[0]
    tmp1 = tmp[1]
    return tmp0,tmp1

(k0,kcnt0),(k1,kcnt1) = func(kisuu_cnter)
(g0,gcnt0),(g1,gcnt1) = func(guusuu_cnter)
kcnt0 = n_kisuu-kcnt0
kcnt1 = n_kisuu-kcnt1
gcnt0 = n_guusuus-gcnt0
gcnt1 = n_guusuus-gcnt1

if k0 != g0:
    print(kcnt0+gcnt0)
else:
    print(min(kcnt0+gcnt1,kcnt1+gcnt0))

Measured memory_bytes: 71148
#!/usr/bin/env python3
# -*- coding utf-8 -*-

a,b,k = map(int,input().split())

if a <= k : 
    ansa = 0 
    ansb = max(0,b-(k-a))
else:
    ansa = a-k 
    ansb = b 

print("%d %d" % (ansa,ansb))


Measured memory_bytes: 2940
/* ex4_2 melo */
#include <stdio.h>
#include <math.h>//数学関数のヘッダーファイルを読み込む
#define PI 3.141592653589793238//円周率PIを十分な長さ定義する
int main(void){
    int lenN,lenM,hour,min;//整数の箱を四つ用意する
    double angleN,angleM,angleN_M,lenN_M;//倍精度の実数の箱を四つ用意する
    scanf("%d%d%d%d",&lenN,&lenM,&hour,&min);//
    angleN=(2*PI/12)*hour+(2*PI/720)*min;//
    angleM=(2*PI/60)*min;//
    angleN_M=angleN-angleM;
    lenN_M=sqrt(lenN*lenN+lenM*lenM-2*lenN*lenM*cos(angleN_M));//
    printf("%.18lf\n",lenN_M);//
    return 0;
}


Measured memory_bytes: 2580
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);

  int ans = min(a, b) + min(c, d);

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


Measured memory_bytes: 128
import java.util.*

fun main (args:Array<String>) {
    val (numA, numB) = readLine()!!.split(" ").map(String::toInt)
    var stack = Stack<Int>()
    stack.push(numA + numB)
    stack.push(numA - numB)
    stack.push(numA * numB)
    while(stack.size > 1){
        val a = stack.pop()
        val b = stack.pop()
        if(a > b) stack.push(a)
        else stack.push(b)
    }
    print(stack.pop())
}

Measured memory_bytes: 36348
//#pragma GCC optimize("O3,unroll-loops")
//#pragma loop_opt(on)
#include <bits/stdc++.h>
//#include <bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    int n, ai;
    cin >> n;
    bool can = true;
    Fr(i, 0, n) {
        cin >> ai;
        can &= ai%2 || ai%3 == 0 || ai%5 == 0;
    }
    cout << (can ? "APPROVED" : "DENIED") << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = 0;
		int min = 0;
		
		max = Math.max(a, b);
		min = Math.min(a, b);
		if(max-1 >= min) {
			System.out.println(max+max-1);
		}else {
			System.out.println(max+b);
		}
    }
}


Measured memory_bytes: 25172
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		System.out.println(phi(n));
	}
	static int phi(int n){
		int ans=n;
		int tmp=n;
		for(int i=2;i*i<=n;i++){
			if(tmp%i==0){
				ans-=ans/i;
				while(tmp%i==0){
					tmp/=i;
				}
			}
		}
		if(tmp>1)ans-=ans/tmp;
		return ans;
	}
}

Measured memory_bytes: 26244
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define pf push_front
#define ll long long
using namespace std;
void TxtRead(){
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
}
void TheTime(){
    ios_base::sync_with_stdio(false);
	cin.tie();
}
const int N = 1e5+5;
const ll INF = 1e9+5;
const ll MOD = 1e9+7;
const double PI = 3.141592653589793116;

int n, k;
int ar[N], dp[N];

int main()
{
    //TxtRead();
    TheTime();

	scanf("%d %d", &n, &k);
	for(int i=1; i<=n; i++){
		scanf("%d", &ar[i]);
	}
	
	memset(dp, '?', sizeof(dp));
	dp[1]=0;
	for(int i=2; i<=n; i++){
		for(int j=i-1; j>=max(1, i-k); j--){
			dp[i]=min(dp[i], dp[j]+abs(ar[i]-ar[j]));
		}
	}
	
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	// Code for C - Go Home
	var X int
	fmt.Scanf("%d", &X)

	var sum int
	for i := 0; ; i++ {
		sum += i + 1
		//fmt.Println(sum)
		if sum == X {
			fmt.Println(i + 1)
			break
		} else if sum > X {
			fmt.Println(i + 1)
			break
		}
	}

}


Measured memory_bytes: 1832
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

def cond():
    count1 = c // b
    if c % b != 0:
        count1 += 1
    count2 = a // d
    if a % d != 0:
        count2 += 1
    return count1 <= count2

if cond():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61684
import sys
input = sys.stdin.buffer.readline

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

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

b = []
for i in range(n):
    b.append(a[i]*n + i)
b.sort(reverse = True)

for i in range(n+1):
    for j in range(n+1-i):
        val,idx = divmod(b[i+j-1],n)
        if i > 0:
            dp[i][j] = max(dp[i][j],dp[i-1][j] + val*abs(idx-i+1))
        if j > 0:
            dp[i][j] = max(dp[i][j],dp[i][j-1] + val*abs(idx-n+j))

ans = 0
for i in range(n+1):
    if ans < dp[i][n-i]:
        ans = dp[i][n-i]
print(ans)

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()

#define ll long long

const int N = 1e5 + 5, M = 1e9 + 7;

int n, m, dp[N], how[N];
deque<int> q;

void add(int x) {
    while (!q.empty() && (dp[q.back()] > dp[x] || (dp[q.back()] == dp[x] && x < q.back()))) q.pop_back();
    q.pb(x);
}

void del(int x) {
    if (!q.empty() && q.front() == x) q.pop_front();
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    string s;
    cin >> s;
    m = min(m, n);
    for (int i = 0; i <= n; i++) dp[i] = M;
    dp[n] = 0;
    for (int i = n - 1; i >= n - m; i--) {
        add(i + 1);
        if (s[i] == '1') {
            dp[i] = M;
        } else {
            if (dp[q.front()] != M) {
                dp[i] = dp[q.front()] + 1;
                how[i] = q.front();
            }
        }
    }
    for (int i = n - m - 1; i > -1; i--) {
        del(i + m + 1);
        add(i + 1);
        if (s[i] == '1') {
            dp[i] = M;
        } else {
            if (dp[q.front()] != M) {
                dp[i] = dp[q.front()] + 1;
                how[i] = q.front();
            }
        }
    }
    if (dp[0] == M) {
        cout << "-1\n";
    } else {
        int cur = 0;
        while (cur != n) {
            cout << how[cur] - cur << " ";
            cur = how[cur];
        }
    }
    return 0;
}


Measured memory_bytes: 1488
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    // int n,m;
    // cin>>n>>m;
    // n+=2;
    // m+=2;
    // for(int i=0;i<n;++i){
    // 	for(int j=0;j<m;++j){
    // 		if(i==0 || i==n-1 || j==0 || j==m-1) cout<<"#";
    // 		else{
    // 			char c;
    // 			cin>>c;
    // 			cout<<c;
    // 		}
    // 	}
    // 	cout<<'\n';
    // }

    // int x,y;
    // cin>>x>>y;
    // int ar[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    // cout<<((ar[x]==ar[y])?"Yes":"No");
    

    // string a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((a.back()==b.front()) && (b.back()==c.front()))?"YES":"NO");
    
    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<((a<=c && c<=b)?"Yes":"No");
   
	// string s;
	// getline(cin,s);
	// cout<<s;        

    int a,b,c;
    cin>>a>>b>>c;
    cout<<(((b*10+c)%4==0)?"YES":"NO");





    return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s;
	cin >> s;
	int scnt = 0, l = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'S'){
			scnt++;
		}else{
			if(scnt > 0){
				scnt--;
				l += 2;
			}
		}
	}
	cout << s.size() - l << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {

	/*string s, t;
	cin >> s;
	cin >> t;
	int i;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == t[i]) {

		}
		else {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	return 0;*/

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= a + b) {
		cout << a << endl;
	}else{
		cout << a - (k - a - b) << endl;
	}
	return 0;
}

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

int main() {
    int x,n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    bool ok1=true;
    rep(i,n){
        if(x==p[i]) ok1=false;
    }
    if(ok1){
        cout << x << "\n";
        return 0;
    }
    for(int i=1; i<=100; ++i){
        bool ok=true;
        rep(j,n){
            if(x-i==p[j]){
                ok=false;
            }
        }
        if(ok){
            cout << x-i << "\n";
            return 0;
        }else{
            ok=true;
        }
        rep(j,n){
            if(x+i==p[j]){
                ok=false;
            }
        }
        if(ok){
            cout << x+i << "\n";
            return 0;
        }
    }
}

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

using namespace std;

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

const int MAXN = 1e5 + 5;

int N;
int pt, px, py;
int t, x, y;

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

    cin >> N;
    for(int a = 0; a < N; a++){
        cin >> t >> x >> y;
        int dist = abs(x - px) + abs(y - py);
        int tm = t - pt;
        if(dist > tm || dist % 2 != tm % 2){
            cout << "No";
            return 0;
        }
        pt = t;
        px = x;
        py = y;
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e5+7;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll a,v;cin>>a>>v;
	ll b,w;cin>>b>>w;
	ll t;cin>>t;
	ll d=abs(a-b);
	ll d1=(v-w)*t;
	puts(d1>=d ? "YES" : "NO");
	
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
    int N, M, K, L;
    scanf("%d %d", &N, &M);
    int list[M];
    for(int i=0;i<M;i++){
        list[i] = 0;
    }
    for(int i=0;i<N;i++){
        scanf("%d", &K);
        for(int j=0;j<K;j++){
            scanf("%d", &L);
            list[L-1] += 1;
        }
    }
    int count=0;
    for(int i=0;i<M;i++){
        if(list[i]==N){
            count += 1;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int X, Y;
  int prize[5] = {0, 3, 2, 1};

  cin >> X >> Y;

  X = min(X, 4);
  Y = min(Y, 4);

  ll ans = prize[X] + prize[Y] + (X + Y == 2) * 4;

  cout << ans * 100000 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    string s;
    cin >> s;
    ll bcnt = 0;
    ll ans = 0;
    rep(i,0,s.size()){
        if(s[i]=='B'){
            bcnt++;
        }else{
            ans += bcnt;
        }
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<math.h>
int main()
{
    long long n;
    scanf("%lld", &n);
    long long x=1;
    for(long long i=1;i<=sqrt(n);i++)
    {
        if((n%i==0) && (((n/i)-i)<((n/x)-x)))
            x=i;
    }
    long long a=x, b=(n/x);
    long long moves=(a+b)-2;
    printf("%lld", moves);
    return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,a,sum=0,X=0,Y;
  cin >> N;
  vector<ll> A; 
  for(ll i=0;i<N;i++){
    cin >> a;
    A.push_back(a);
    X += a;
  }
  for(ll i=N;i>1;i--){
    X -= A[i-1];
    Y = X%1000000007;
    sum += Y*A[i-1];
    sum %=1000000007;
  }
  cout << sum;
}

Measured memory_bytes: 5360
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

long long max(long long a, long long b, long long c){
    if(a >= b && a >= c){
        return a;
    }else if(b >= a && b >= c){
        return b;
    }else{
        return c;
    }
}

long long min(long long a, long long b, long long c){
    if(a <= b && a <= c){
        return a;
    }else if(b <= a && b <= c){
        return b;
    }else{
        return c;
    }
}

int main(void){

    long long H, W;

    scanf("%lld%lld", &H, &W);

    long long a, b, c;
    long long ans = H * W;

    for(int i = 1; i <= W-1; i++){
        a = H * i;
        b = H * ((W-i)/2);
        c = H * W - a - b;
        if(max(a,b,c) - min(a,b,c) < ans){
            ans = max(a,b,c) - min(a,b,c);
        }
        b = (W-i) * (H/2);
        c = H * W - a - b;
        if(max(a,b,c) - min(a,b,c) < ans){
            ans = max(a,b,c) - min(a,b,c);
        }
    }

    for(int i = 1; i <= H-1; i++){
        a = W * i;
        b = W * ((H-i)/2);
        c = H * W - a - b;
        if(max(a,b,c) - min(a,b,c) < ans){
            ans = max(a,b,c) - min(a,b,c);
        }
        b = (H-i) * (W/2);
        c = H * W - a - b;
        if(max(a,b,c) - min(a,b,c) < ans){
            ans = max(a,b,c) - min(a,b,c);
        }
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
#define p pair<int,int>
#define f first
#define s second
#define dist(a,b) pow(pow(a.f-b.f,2) + pow(a.s-b.s,2),0.5)
#define get(i) p(c.f+xs[i],c.s+ys[i])

int xs[] = {1,-1,0,0};
int ys[] = {0,0,1,-1};

char getD(p c, p next) {
    if (next.f > c.f) return 'R';
    if (next.f < c.f) return 'L';
    if (next.s > c.s) return 'U';
    if (next.s < c.s) return 'D';
    return 'Z';
}

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    vector<p> d;
    d.push_back(p(sx,sy)), d.push_back(p(tx,ty));
    map<p,int> u;
    int f = 1, n, i, s;
    for (n = 0, f = 1; n < 4; n++, f = (f+1)%2) {
        s = (f+1)%2;

        char lastd = 'O';
        p c = d[s];
        while (c != d[f]) {
            p next;
            int dx = 10000;
            for (i = 0; i < 4; i++) {
                p t = get(i);
                if (u[t] || t == d[s]) continue;
                int tdx = dist(t,d[f]);
                if (tdx < dx || (tdx == dx && lastd == getD(c,t))) next = t, dx = tdx;
            }
            if (next != d[f]) u[next] = 1;
            lastd = getD(c,next);
            cout << lastd;
            c = next;
        }
    }

    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string.h>
using namespace std;

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

    int ans = 0;

    if(s%2 == 0.0){
        ans = s;
    }else{
        ans = s * 2;
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h> 
const int N = 10000;

int main(void)
{
	int i , n;
	long long sum = 0;
	int maxn = -1000001 , minn = 1000001;
	scanf("%d" , &n);
	long a[n];
	for(i = 0 ; i < n ; i++)
	{
		scanf("%ld" , &a[i]);
		if(a[i]> maxn)
		{
			maxn = a[i];
		}
		if(a[i]< minn)
		{
			minn = a[i];
		}
		sum += a[i];
	}
	printf("%d %d %lld\n" , minn , maxn , sum);
	return 0;
}



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

int main() {
  cout << "Yes" << endl;
  int N,M;
  cin >> N >> M;
  ll MOD = 100000007;
  vector<vector<int>> G(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> dist(N,MOD);
  queue<int> que;
  vector<int> ans(N);
  dist.at(0) = 0;
  que.push(0);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int nv: G.at(v)){
      if(dist.at(nv) != MOD){
        continue;
      }
      ans.at(nv) = v;
      dist.at(nv) = dist.at(v) + 1;
      que.push(nv);
    }
  }
  rep(i,N-1){
    cout << ans.at(i+1) + 1 << endl;
  }
}

Measured memory_bytes: 10680
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
#H,N = LI()
# 頻度 counter
S = [_S() for _ in range(N)]
c = collections.Counter(S)

result = ['AC', 'WA', 'TLE', 'RE']
for j in result:
    print(j + ' x ' + str(c[j]))

Measured memory_bytes: 34180
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:
    print(0)
    exit()

dif = sorted([x[i+1] - x[i] for i in range(m-1)])

if n == 1:
    print(sum(dif))
else:
    print(sum(dif[:-(n-1)]))

Measured memory_bytes: 13968
package main

import (
	"fmt"
)

func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func main() {
	var N, W int
	fmt.Scan(&N, &W)
	weight := make([]int, N)
	value := make([]int, W)
	for i := 0; i < N; i++ {
		fmt.Scan(&weight[i], &value[i])
	}

	dp := make([]int, W+1)

	for i := 0; i < N; i++ {
		for w := W; w >= 0; w-- {
			if w+weight[i] > W {
				continue
			}
			chmax(&dp[w+weight[i]], dp[w]+value[i])
		}
	}

	fmt.Println(dp[W])
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

struct Edge {
    int from, to, cost;
    Edge(int from = 0, int to = 0, int cost = 0) : from(from), to(to), cost(cost) {}
};

template <typename T> T stable_add(T x, T y) {
    T m = numeric_limits<T>::min();
    if (x == m || y == m) { return m; }
    T M = numeric_limits<T>::max();
    if (x == M || y == M) { return M; }
    return x + y;
}

void bellman_ford(const vector<Edge>& E, vi& cost, int s) {
    int v = cost.size();

    // Initialize cost.
    fill(all(cost), INT_MAX);
    cost[s] = 0;

    // Iterate (v - 1) times to find minimul distances.
    rep(i, 0, v - 1) {
        for (Edge e : E) {
            if (cost[e.to] > stable_add(cost[e.from], e.cost)) {
                cost[e.to] = stable_add(cost[e.from], e.cost);
            }
        }
    }

    // Iterate (v - 1) times to find nodes affected by negative cycles.
    rep(i, 0, v - 1) {
        for (Edge e : E) {
            if (cost[e.to] > stable_add(cost[e.from], e.cost)) {
                cost[e.to] = INT_MIN;
            }
        }
    }
}


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

    int n, m, p;
    cin >> n >> m >> p;

    vector<Edge> E;
    rep(_, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        E.emplace_back(a - 1, b - 1, -(c - p));
    }

    vi cost(n);
    bellman_ford(E, cost, 0);

    if (cost.back() == INT_MIN) {
        cout << -1 << endl;
    } else {
        cout << max(0, -cost.back()) << endl;
    }

    return 0;
}

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

int fib[46]={};
int n = 0 ;

int main(){
    
	cin >> n ;

	fib[0]=1;
	fib[1]=1;

	for(int i=2; i<46; i++){
	
	fib[i]=fib[i-1]+fib[i-2];
	
	}


cout << fib[n] << endl ;

  return 0;
}


Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e7+5;
int ans[maxn]={0};
int main(){
	long long n;
	//cin>>n;
	scanf("%lld",&n);
	long long cnt=0;
	for(int i=1;i<n;i++){
		if(ans[i]==0&&ans[n-i]==0&&i!=n-i){
			ans[i]=ans[n-i]=1;
			cnt++;
		}
		//printf("%lld",cnt);
	}
	printf("%lld",cnt);
	
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

int H,W,K;

int X[111111],Y[111111];

bool t1[111111],t2[111111];
map<pint,int>latte;

void bfs(vint src,bool t[]){
    queue<int>que;
    rep(i,src.size()){
        t[src[i]]=1;
        que.push(src[i]);
    }
    while(que.size()){
        int v=que.front();
        que.pop();
        int y=Y[v],x=X[v];
        rep(d,8){
            int ny=y+dy[d],nx=x+dx[d];
            if(latte.find({ny,nx})==latte.end())continue;
            int u=latte[{ny,nx}];
            if(t[u])continue;
            t[u]=1;
            que.push(u);
        }
    }
}

signed main(){
    scanf("%lld%lld%lld",&H,&W,&K);
    rep(i,K)scanf("%lld%lld",&Y[i],&X[i]);

    rep(i,K)latte[{Y[i],X[i]}]=i;

    vint src;
    rep(i,K)if(X[i]==W-1||Y[i]==0)src.pb(i);

    bfs(src,t1);

    src.clear();
    rep(i,K)if(X[i]==0||Y[i]==H-1)src.pb(i);
    bfs(src,t2);

    rep(i,K){
        if(t1[i]&&t2[i]){
            cout<<0<<endl;
            return 0;
        }
    }

    set<pint>luz,izr;
    rep(i,K){
        rep(d,8){
            int ny=Y[i]+dy[d],nx=X[i]+dx[d];
            if(ny<0||ny>=H||nx<0||nx>=W)continue;
            if(ny==0&&nx==0)continue;
            if(ny==H-1&&nx==W-1)continue;
            if(t1[i]){
                luz.insert({ny,nx});
            }
            if(t2[i]){
                izr.insert({ny,nx});
            }
        }
    }

    for(auto &w:luz){
        if(izr.find(w)!=izr.end()){
            cout<<1<<endl;
            return 0;
        }
    }

    for(auto &w:luz){
        if(w.fi==H-1||w.se==0){
            cout<<1<<endl;
            return 0;
        }
    }

    for(auto &w:izr){
        if(w.fi==0||w.se==W-1){
            cout<<1<<endl;
            return 0;
        }
    }

    cout<<2<<endl;
    return 0;
}

Measured memory_bytes: 42352
#include <bits/stdc++.h>
#define inf 100000000
#define rep(i,n) for(int i=0;i<n;i++) 
using namespace std;
typedef long long ll;
int main (){
 ll sum =1;
 ll n;
 cin >> n;
 ll p[n+5];

 rep(i,n){
     cin >> p[i];
 }
 int min =p[0];

 for(int i=1;i<n;i++){
     if(p[i]<min){
         min=p[i];
         sum++;
     }
     
 }

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

Measured memory_bytes: 1792
H=int(input())
W=int(input())
N=int(input())
if H>=W:
	if N%H==0:
		print(N//H)
	else:
		print(N//H+1)
else:
	if N%W==0:
		print(N//W)
	else:
		print(N//W+1)

Measured memory_bytes: 3060
n = int(input())
a = [0]*n
j = 0
for i in range(1, n+1):
    while True:
        if i%2!=0:
            break
        i=i//2
        if i==0:
            break
        else:
            a[j]+=1
    j+=1
maxv = max(a)
maxi = a.index(maxv)
print(maxi+1)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define maxn 200100
#define mod 1000000007
typedef long long ll;
using namespace std;

ll F[maxn],N,A[maxn],C[maxn],cmb;

ll put(ll a, ll p){
    if(p == 0) return 1;
    if(p == 1) return a;
    ll pt = put(a,p/2);
    return pt*pt%mod*(p%2 ? a : 1)%mod;
}

ll inv(ll x){
    return put(x,mod-2);
}

ll comb(ll n,ll k){
    return ((F[n]*inv(F[k])%mod)*inv(F[n-k]))%mod;
}


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N;
	F[0] = F[1] = 1;
    for(int i=2;i<=N+1;i++) F[i] = (F[i-1]*i)%mod;
	
	for(int i = 1;i<=N+1;i++){
		cin >> A[i];
		C[A[i]]++;
	}
	
	bool u = 0;
	for(int i = 1;i<=N+1;i++) if(C[A[i]] > 1) cmb += (u ? N+1-i : i-1), u = 1;
	
	for(int K = 1;K<=N+1;K++)
		if(K > cmb+1) cout << comb(N+1,K) << '\n'; 
		else{
			ll rs = (comb(N+1,K) - comb(cmb,K-1)) % mod;
			while(rs < 0) rs+=mod;
			cout << rs << '\n';
		}
	
}

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

long long solve(vector<int> l, vector<int> r) {
    long long ans = 0, sum = 0;
    while (!l.empty()) {
        auto x = l.back(); l.pop_back();
        sum += x; ans = max(ans, sum);
        if (!r.empty()) {
            auto y = r.back(); r.pop_back();
            sum += y; ans = max(ans, sum);
        }
        else break;
    }
    return ans;
}


int main() {
    int n; scanf("%d", &n);

    vector<int> l,r;
    while (n--) {
        int x,y; scanf("%d %d", &x, &y);
        l.push_back(x);
        r.push_back(-y);
    }
    sort(l.begin(), l.end()); 
    sort(r.begin(), r.end());
    cout << 2*max(solve(l,r), solve(r,l)) << endl;

    return 0;
}


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

using namespace std;

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

	}
	int ans = 0;
	for (int i = 0; i <= m; i++) {
		if (v[i] == n)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

ll num(ll r) 
{
    ll n = 1;
    while(true) {
        if(n*(n+1) <= r*2 && r*2 < (n+1)*(n+2)) break;
        ++n;
    }
    return n;
}

int main()
{
    ll N;
    cin >> N;

    map<ll,ll> P;
    ll a = 2;
    ll cnt = 0;
    if(N == 1) _PR(0);
    else {
        while(N >= a * a) {
            if(N % a == 0) {
                ++P[a];
                N /= a;
            }
            else {
            ++a;
            }
        }
        ++P[N];

        cnt = 0;
        for(auto itr = P.begin(); itr != P.end(); ++itr) {
            ll c = num(itr->second);
            cnt += c;
            //cout << itr->first << ":" << itr->second << " ";
        }
        //_PR("");
        _PR(cnt);
    }
    return 0;
}

/*



*/

Measured memory_bytes: 3636
import java.util.*;
public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 1;
        int[][] dic = {{20, 20},{19, 20},{19, 20}};
        int[][][] date = new int[1000][11][21];
        for(int y = 1; y < 1000; y++){
            for(int m = 1; m <= 10 ; m++){
                for(int d = 1; d <= dic[y%3][m%2]; d++){
                    date[y][m][d] = count;
                    count++;
                }
            }
        }
        while(0 < n--){
            int Y = sc.nextInt();
            int M = sc.nextInt();
            int D = sc.nextInt();
            System.out.println(count - date[Y][M][D]);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 24068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll s;
  cin >> s;

  ll x1, x2, x3, y1, y2, y3;
  x1 = y1 = 0;              // (x1, y1)は原点固定
  x2 = 1000000000, y2 = 1;  // (x2, y2)は(1, 1e9)固定
  /**
   * s/2 = (x2y3 - x3y2)/2 だから
   * x2 * y3 - x3 * y2 = sを満たす(x3, y3)を見つける
   */
  x3 = (x2 - s % x2) % x2;  // x3 = x2 * y3 - s
  y3 = (s + x3) / x2;
  printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);
  return 0;
}

Measured memory_bytes: 256
a = [int(x) for x in input().split()]
a1 = abs(a[1] - a[0]) + abs(a[1] - a[2])
a2 = abs(a[2] - a[0]) + abs(a[2] - a[1])
a3 = abs(a[2] - a[0]) + abs(a[1] - a[0])
print(min(a1,a2,a3))

Measured memory_bytes: 9068
H,W=map(int,input().split())
S=[[0 for i in range(W)] for j in range(H)]
for i in range(H):
  a=list(map(str,input()))
  for j in range(W):
    S[i][j]=a[j]
  a=[]
V=[[0 for i in range(W)] for j in range(H)]
for m in range(H):
  for n in range(W):
    if S[m][n]=="#":
      V[m][n]="#"
    if m>0 and n>0 and S[m-1][n-1]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if m>0 and S[m-1][n]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if W-1>n and m>0 and S[m-1][n+1]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if n>0 and S[m][n-1]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if W-1>n and S[m][n+1]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if H-1>m and n>0 and S[m+1][n-1]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if H-1>m and S[m+1][n]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
    if W-1>n and H-1>m and S[m+1][n+1]=="#":
      if S[m][n]=="#":
        V[m][n]="#"
      else:
        V[m][n] += 1
a=[]
for k in range(H):
  for l in range(W):
    a.append(V[k][l])
  print("".join(map(str,a)))
  a=[]

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

#define MOD 1000000007

int main()
{
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;

  if (a == b)
  {
    cout << "YES" << endl;
    return 0;
  }

  if (b > a)
  {
    b += w * t;
    a += v * t;
    if (a >= b)
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  } else {
    b -= w * t;
    a -= v * t;
    if (a <= b) {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  }


}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  ll h;
  cin >> h;
  ll res=0;
  ll c = 0;
  while(h!=0){
    //cout << h << c << endl;
    res+=pow(2LL,c);
    c++;
    h /= 2;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	char s[1001], *p;
	const char *spacing = "";

	while (scanf(" %1000s ", s) != EOF) {
		p = strstr(s, "apple");
		if (p != NULL) {
			strncpy(p, "peach", 5);
		}
		else {
			p = strstr(s, "peach");
			if (p != NULL) {
				strncpy(p, "apple", 5);
			}
		}
		printf("%s%s", spacing, s);
		spacing = " ";
	}
	puts("");
	return 0;
}

Measured memory_bytes: 564
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	ll a, b, c;
	cin >> a >> b >> c;
	set<int> ms;
	ms.insert(a);
	ms.insert(b);
	ms.insert(c);
	if (ms.size() == 2)
		cout << "Yes" << ln;
	else
		cout << "No" << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d,i,j,k,l=0,x,y;
vector<ll>v,vv;
cin>>a>>b;
for(i=1;i<=b;i++)
{
cin>>c;v.push_back(c);
}
for(i=0;i+1<b;i++)
{
vv.push_back(abs(v[i]-v[i+1]));
l+=abs(abs(v[i]-v[i+1]));

}
l+=abs(v[0]+a-v[b-1]);
vv.push_back(abs(v[0]+a-v[b-1]));
sort(vv.begin(),vv.end());

l-=vv[vv.size()-1];
cout<<l<<endl;
}

Measured memory_bytes: 4848
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = 3;
  auto s = new string[](n);
  foreach (i; 0..n) s[i] = readln.chomp;

  auto turn = 0;
  for (;;) {
    if (s[turn].empty) {
      writeln(cast(char)('A' + turn));
      return;
    }

    auto next = cast(int)(s[turn][0] - 'a');
    s[turn] = s[turn][1..$];
    turn = next;
  }
}


Measured memory_bytes: 256
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};


// abcde
fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_string();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
        elems[2].parse().ok().expect("failed to parse"),
    )
}

fn main() {

    let (n, k): (usize, usize) = read_as_pair();
    let mut hs = Vec::new();
    for _ in 0..n {
        let h: i64 = read_as_primitive();
        hs.push(h);
    }
    hs.sort();

    let ans = hs.windows(k)
                .map(|sub| sub.last().unwrap() - sub.first().unwrap())
                .min()
                .unwrap();
    println!("{}", ans);

}

Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(){
  
  int N,K,M,i,j,k;
  scanf("%d%d",&N,&K);
  M=(N+1)*N/2;
  long long int a[N],s[N+1],C[M];
  for(i=0;i<N;i++){scanf("%lld", &a[i]);}
  s[0]=0;
  for(i=1;i<=N;i++){s[i]=s[i-1]+a[i-1];}
  k=0;
  for(i=0;i<N;i++){
    for(j=i+1;j<=N;j++){C[k]=s[j]-s[i];/*printf("%lld ",C[k])*/;k++;}
  }
  
  int S[M][100];
  long long int temp;
  for(i=0;i<M;i++){
    temp=C[i];
    for(j=0;j<100;j++){
      S[i][j]=temp%2;
      //printf("%d",S[i][j]);
      temp=(long long int)(temp/2);
    }
    //printf("\n");
  }
  
  int num;int flag[M],ans[100];
  for(i=0;i<M;i++){flag[i]=1;}
  for(i=0;i<100;i++){ans[i]=0;}
  for(i=99;i>=0;i--){
    num=0;
    for(j=0;j<M;j++){
      if(S[j][i]==1 && flag[j]==1){num++;}
    }
    if(num>=K){
      ans[i]=1;
      for(j=0;j<M;j++){
	if(S[j][i]==0 && flag[j]==1){flag[j]=0;}
      }
    }
  }
  
  long long int ANS=0;
  for(i=0;i<100;i++){ANS=ANS+pow(2,i)*ans[i];}
  printf("%lld",ANS);
  
  return 0;
}
	
    
  


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var s = Console.ReadLine().ToCharArray();

            var grouped = s.GroupBy(x => x).Select(x => x.Count()).ToArray();
            var answer = grouped.Length == 2 && grouped.All(x => x == 2);

            // 解答の出力
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13408
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        switch(sc.next()){
            case "A":
                System.out.println("T");
                break;
            case "T":
                System.out.println("A");
                break;
            case "C":
                System.out.println("G");
                break;
            default:
                System.out.println("C");
        }
    }
}

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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    int n, r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r + 100*(10-n)<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int((input()))
C_p = []
C_m = []
for i in range(N):
    kakko = input()
    temp = 0
    temp_min = 0
    for s in kakko:
        if s == "(":
            temp += 1
        else:
            temp -= 1
            temp_min = min(temp, temp_min)
    if temp >= 0:
        C_p.append((temp_min, temp))
    else:
        C_m.append((temp_min - temp, temp_min, temp))
C_p.sort(reverse=True)

flag = 0
final = 0
for l, f in C_p:
    if final + l < 0:
        flag = 1
    final += f

C_m.sort()

for _, l, f in C_m:
    if final + l < 0:
        flag = 1
    final += f
    
if final != 0:
    flag = 1

print("Yes" if flag == 0 else "No")

Measured memory_bytes: 80296
/*
....................../´¯/)
....................,/¯../
.................../..../
............./´¯/'...'/´¯¯`·¸
........../'/.../..../......./¨¯\
........('(...´...´.... ¯~/'...')
.........\.................'...../
..........''...\.......... _.·´
............\..............(
..............\.............\...
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define pi 3.14159265358979323846
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n;

		x = (n % 10);



		if (x % 2 == 0 || x == 5)
			cout << -1;
		else
		{
			x = n;
			while (x > 0)
			{
				cnt++;
				x = x / 10;
			}
			ans = 0;
			temp = cnt;
			while (cnt--)
			{
				ans = (ans * 10) + 7;
			}
			flag = 0;

			cnt = n;

			while (cnt--)
			{
				if (ans % n == 0)
				{
					flag = 1; break;
				}
				else
				{
					temp++;
					ans = ans * 10;
					ans += 7;
					ans = (ans % n);

				}
			}
			if (flag)
				cout << temp;
			else
				cout << -1;
		}






		ln
	}
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
char s[100005];
int n,d;
int a[100005];
ll f[10005][105][2];
void add(ll &x,ll v)
{
	x+=v;
	if(x>=mod) x-=mod;
}
int main()
{
	scanf("%s%d",s+1,&d);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	f[0][0][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<d;j++)
		{
			for(int k=0;k<=9;k++)
			{
				int p=j-k;
				while(p<0) p+=d;
				//printf("j=%d k=%d p=%d\n",j,k,p);
				add(f[i][j][0],f[i-1][p][0]);
				if(k==a[i]) add(f[i][j][1],f[i-1][p][1]);
				else if(k<a[i]) add(f[i][j][0],f[i-1][p][1]);
			}
			//printf("f(%d,%d)=(%d,%d)\n",i,j,f[i][j][0],f[i][j][1]);
		}
	}
	ll ans=(f[n][0][0]+f[n][0][1]-1+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16768
N,M = map(int, input().split())
ans = []
if N%2==1:
  for i in range(2,N//2+2):
    ans.append((i,N+2-i))
else:
  l = 2
  r = N
  while r-l>N//2:
    ans.append((l,r))
    l += 1
    r -= 1
  l += 1
  while r>l:
    ans.append((l,r))
    l += 1
    r -= 1
for i in range(M):
  print(*ans[i])

Measured memory_bytes: 79888
/*  ex4_2
    pptenshi  */

#include<stdio.h>
#include<math.h>

int main(void) {
    int len_hour_hand,    // A
        len_minute_hand,  // B
        hour,             // H
        minute;           // M
    
    double angle_hour_hand,    // 0時からの角度
                angle_minute_hand,  // 0分からの角度
                angle_hands,        // 時針と分針がなす角
                distance;           // 短点の距離

    double pi = acos(-1);  // define pi

    //input
    scanf("%d%d%d%d", 
        &len_hour_hand, 
        &len_minute_hand, 
        &hour, 
        &minute
        );

    // calculate angle    
    angle_hour_hand = 2 * pi * (hour + minute / 60.0) / 12;
    angle_minute_hand = 2 * pi * minute / 60;
    angle_hands = fabs(angle_hour_hand - angle_minute_hand);

    // calculete distance
    distance = sqrt(
        pow(len_hour_hand, 2) + 
        pow(len_minute_hand, 2) -
        2 * len_hour_hand * len_minute_hand * cos(angle_hands)
        );
    
    // output
    printf("%.15lf\n", distance);

    return 0;
}

Measured memory_bytes: 2552
import java.util.*;
import java.lang.*;

public class Main {
    
    public static void main (String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        long power = 1;
        
        for (int i = 1; i <= n; i++) {
            power *= i;
            power %= 1000000007;
        }
        
        ans = (int) power;
        
        System.out.println(ans);
    }
}



Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        int all = 0;
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
            all += a[i];
        }
        int count = 0;
        for(int i=0;i<N;i++) {
            if (a[i] >= (all * 0.25f / M)) {
                count++;
            }
        }
        System.out.println(count >= M ? "Yes" : "No");
    }
}


Measured memory_bytes: 21716