akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        double n = in.nextInt();
        out.println(n * 2d * 3.141592);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 33296
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;


public class Main {
     
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	int a[]=new int[n+1];
	for(int i=0;i<n-1;i++)
	{int k=s.nextInt();
	a[k]++;}
	for(int i=1;i<=n;i++)
	System.out.println(a[i]);
	}
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int arr[100];
  for(int i=0;i<n;i++) cin>>arr[i];
  int dp[100001][101];
  sort(arr,arr+n);
  for(int i=0;i<=k;i++){
    for(int j=0;j<=n;j++){
      if(i==0||j==0) dp[i][j]=0;
      else if(arr[j-1]<=i){ 
        int x=dp[i-arr[j-1]][n]+1;
        if(x&1||dp[i][j-1]==1) dp[i][j]=1;
        else dp[i][j]=2;
      }
      else dp[i][j]=dp[i][j-1];
    }
  }
  int ans=2;
  for(int i=1;i<=n;i++){
    if(dp[k][i]==1){
      ans=1;
      break;
    }
  }
  //for(int i=0;i<=k;i++){
  //	cout<<"i="<<i<<" ";
  //	for(int j=0;j<=n;j++){
  //		cout<<dp[i][j]<<" ";
  //	}
  //	cout<<endl;
  //}
  if(ans==1) cout<<"First";
  else cout<<"Second";
  
}
  

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

using namespace std;

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

int n;
int happiness[N][M]; // happiness gained on day N by doing activity M

int mem[N][M]; // maximum happiness by doing activity M on day N

int dp(int day , int lastActivity){

    if(day == n) return 0;

    if(mem[day][lastActivity] != -1) return mem[day][lastActivity];


    int ans = 0;

    // try do an activity on this day
    for(int newActivity = 0 ; newActivity < 3 ; newActivity ++){

            // this activity must not be equal to the activity that have been done on the day before
            if(newActivity != lastActivity){

                    ans = max(ans , happiness[day][newActivity] + dp(day + 1 , newActivity));

            }
    }

    mem[day][lastActivity] = ans; // saving the answer of this state

    return mem[day][lastActivity]; // returning the answer of this state after saving
}


main(){

    scanf("%d" , &n);

    for(int day = 0 ; day < n ; day ++){

            for(int activity = 0 ; activity < 3 ; activity ++){

                    scanf("%d" , &happiness[day][activity]);

            }
    }

    int ans = 0;

    memset(mem , -1 , sizeof mem);
    for(int activity = 0 ; activity < 3 ; activity ++){

            ans = max(ans , happiness[0][activity] + dp(1 , activity));

    }

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

    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int pos[100009];
ll A[100009];
ll B[100009];

ll modpow(ll x, int n) {
	if (n == 0) return 1LL;
	else if (n % 2 == 0) return modpow((x*x) % MOD, n / 2) % MOD;
	else return (modpow((x*x) % MOD, n / 2) * x) % MOD;
}

// a/bを返す
ll divMod(ll a, ll b) {
	ll res = a * modpow(b, MOD - 2);
	return res % MOD;
}

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

	ll N; cin >> N;
	ll L = 0;
	for (int i = 1; i <= N + 1; i++) {
		int a; cin >> a;
		if (pos[a] == 0) pos[a] = i;
		else L = i - pos[a] + 1;
	}
	//cout << L << endl;

	A[1] = N + 1;
	B[1] = 1;

	for (ll i = 1; i <= N; i++) {
		A[i + 1] = (N - i + 1)*A[i];
		A[i + 1] %= MOD;
		A[i + 1] = divMod(A[i + 1], i + 1);

		B[i + 1] = (N + 1 - L - i + 1)*B[i];
		B[i + 1] %= MOD;
		B[i + 1] = divMod(B[i + 1], i);

	}
	//for (int i = 1; i <= N + 1; i++) cout << A[i] <<  " " << B[i] << endl;

	for (int i = 1; i <= N + 1; i++) cout << (A[i] - B[i] + MOD) % MOD << endl;

	return 0;
}

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

int main(){
	int N, L;
	cin >> N >> L;
	int ans = L * N + N * (N + 1) / 2 - N;
	if (L >= 1) {
		ans -= L;
	}
	else if (L + N - 1 < 0) {
		ans -= L + N - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll Q;
    cin >> Q ;
    
    rep(i, Q){
        ll a , b;
        cin >> a >> b;
        
        b = a + b ;
        a = min(a, b-a);
        b -= a;
        
        ll x = sqrt(a*b);
        ll y = x + 1;
        if(x*y > a*b){y--;}
        
        ll ans = x + y ;
        if(x-a == b-y && x==y)ans --;
        else ans -= 2;
        
        if(x*y == a*b) ans --;
        

        

        cerr << "-->" << endl;
        cout << ans << endl;
        
    }
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

/*int64_t lucas(int N){
  if(N==0)
    return 2LL;
  if(N==1)
    return 1LL;
  int64_t a = lucas(N-2) + lucas(N-1);
  return(a);
}

int main() {
  int N;
  scanf("%d",&N);
  int64_t a = lucas(N);
  printf("%lld",a);
}*/

int main() {
  int N;
  scanf("%d",&N);
  vector<int64_t>lucas(N+1);
  lucas[0]=2LL;
  lucas[1]=1LL;
  for(int i=2;i<=N;i++){
    lucas[i]=lucas[i-1]+lucas[i-2];
  }
  printf("%ld",lucas[N]);
}

Measured memory_bytes: 256
#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>;

int main(){
  int k=0;
  vector <int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << a[k-1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a[102];int t=1;
    gets(a);
    for(int i=0;a[i]!='\0';i++)
    {
        if((i+1)%2==0)
        {
            if(a[i]=='R')
            {
                t=0;
                break;
            }
        }
        else
        {
            if(a[i]=='L')
            {
                t=0;
                break;
            }
        }
    }
    if(t==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.math.*;

import static java.util.Comparator.*;


public class Main {
    public static void main(String[] args) throws IOException {
        FastReader s = new FastReader();
        int x=s.nextInt();
        int y=s.nextInt();
        int z=s.nextInt();

        System.out.println(z+" "+x+" "+y);
    }

}


class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

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

int main() {
    int N;
    while (cin >> N, N) {
        int sum = 0;
        for (int i = 0; i < (N-1) * N / 2; i++) {
            int x;
            cin >> x;
            sum += x;
        }

        cout << sum / (N-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3032
package main

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

func main() {
	sc := NewScanner()

	k := sc.ReadInt()

	q := make([]int64, 9)
	for i := range q {
		q[i] = int64(i + 1)
	}

	cnt := 0
	for {
		n := q[0]
		cnt++
		if cnt >= k {
			fmt.Println(n)
			return
		}
		q = q[1:]

		base := n * 10
		mostRight := n % 10
		if mostRight > 0 {
			q = append(q, base+mostRight-1)
		}
		{
			q = append(q, base+mostRight)
		}
		if mostRight < 9 {
			q = append(q, base+mostRight+1)
		}
	}
}

// util
// *   math(int)

func AbsInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func MaxInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func PowInt(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   math(int)

func AbsInt64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func MaxInt64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func PowInt64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// * io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a>c)
    return cout<<"NO\n",0;
  else if((a+b)>c)
    return cout<<"YES\n",0;
  else
    return cout<<"NO\n",0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int N, K, x, Y; //xはAを行う回数

  cin >> N >> K;

  vector<int> vec(N+1);

  for(int x = 0; x <= N; x++){
      Y = pow(2, x) + K * (N - x);
      vec.at(x) = Y;
    }

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

  cout << vec.at(0) << endl;


//  fx = 2^x + K*(N-x)
//  fx = 2^x - K*x +K*N
//  f'x = 2^x*log2 -K fxはx>0で極小値を取る

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll N;
        cin>>N;
        vl A(N);
        vl B(N);
        rep(i,N){
            cin>>A[i];
            if(i==0)continue;
            A[i]+=A[i-1];
        }
        rep(i,N){
            cin>>B[i];
            if(i==0)continue;
            B[i]+=B[i-1];
        }
        ll MAX=-INF;
        rep(i,N){
            if(i==0)chmax(MAX,A[0]+B[N-1]);
            chmax(MAX,A[i]+B[N-1]-B[i-1]);
        }
        cout<<MAX<<endl;
    }

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

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

  int ans = 0;
  for(int i=1;i<=n;i++){
    if(i%2 == 0)continue;
    if(a[i-1]%2 == 1)ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s,s1;
    cin>>s;
    s1=s;
    reverse(s.begin(),s.end());
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='b') s[i]='d';
        else if(s[i]=='d') s[i]='b';
        else if(s[i]=='p') s[i]='q';
        else if(s[i]=='q') s[i]='p';
    }
    if(s==s1) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b < c || d < a) {
        cout << 0 << endl;
    } else {
        cout << min(b, d) - max(a, c) << endl;
    }
    r0
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int SIZE = 200000 + 5;
bool v[SIZE] = {};
int n, m, tot, fa[SIZE], rnk[SIZE], cnt[SIZE];
int get(int x)
{
	if(fa[x] == x) return x;
	return fa[x] = get(fa[x]);
}
void merge(int x, int y)
{
	int v1 = get(x), v2 = get(y);
	fa[v1] = v2;
	return;
}
int main()
{
	memset(rnk, 0, sizeof(rnk));
	tot = 0;
	memset(cnt, 0, sizeof(cnt));
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++ i) fa[i] = i;
	for(int i = 0; i < m; ++ i)
	{
		int A, B;
		scanf("%d %d", &A, &B);
		merge(A, B);
	}
	for(int i = 1; i <= n; ++ i)
	{
		int Fa = get(i);
		if(!v[Fa])
		{
			v[Fa] = 1;
			cnt[++ tot] = 1;
			rnk[Fa] = tot;
		}
		else ++ cnt[rnk[Fa]];
	}
	int ans = 0;
	for(int i = 1; i <= tot; ++ i) ans = max(ans, cnt[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 12280
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "Yes\n";
string no = "No\n";
#define PI 3.1415926535 


int main() {
  fastio;
  ll n;
  cin>>n;
  for(ll i=1;i<=9;i++) {
    if(n%i==0 and n/i<=9) {
      cout<<yes;
      return 0;
    }
  }
  cout<<no;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
string s[14] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT",
                "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  string w;
  cin >> w;
  int idx = -1;
  fore(i, 0, 14) {
    if (idx != -1 && s[i] == "SUN") {
      cout << i - idx << endl;
      return 0;
    }
    if (s[i] == w) {
      idx = i;
    }
  }

  return 0;
}

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

#define int long long
struct Fast { Fast(){ std::cin.tie(0); std::cout.tie(0); ios::sync_with_stdio(false); }} fast;

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void) {
  
  int p, q, r; cin >> p >> q >> r;

  cout << min(p + q, min(r + q, p + r)) << endl;


}


Measured memory_bytes: 256
#include <stdio.h>

#define WIDTH 6
#define HEIGHT 12

enum { YET, ALREADY };

int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, char );
void fallBlock( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int stack[ WIDTH * HEIGHT ];
int sp;

int main( void ) {
	int x, y, n, chain;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		for ( y = 0; y < HEIGHT; y++ ) {
			for ( x = 0; x < WIDTH; x++ ) {
				scanf( "%c", &field[ x ][ y ].color );
				field[ x ][ y ].state = YET;
			}

			scanf( "%*c" );
		}

		for ( chain = 0; deleteBlock(); chain++ )
			fallBlock();

		printf( "%d\n", chain );
	}

	return 0;
}

int deleteBlock( void ) {
	int x, y, del;

	del = 0;
	for ( x = 0; x < WIDTH; x++ )
		for ( y = 0; y < HEIGHT; y++ )
			if ( field[ x ][ y ].color != '.' && field[ x ][ y ].color != 'O' && field[ x ][ y ].state == YET ) {
				sp = 0;
				if ( findGroup( x, y ) >= 4 ) {
					while ( sp-- )
						field[ stack[ sp ] / HEIGHT ][ stack[ sp ] % HEIGHT ].color = '.';

					del = 1;
				}
			}

	return del;
}

int findGroup( int x, int y ) {
	return findGroup_body( x, y, field[ x ][ y ].color );
}

int findGroup_body( int x, int y, char color ) {
	int i, sum;

	stack[ sp++ ] = x * HEIGHT + y;
	field[ x ][ y ].state = ALREADY;

	sum = 0;
	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ].state == YET && ( field[ nx ][ ny ].color == color || field[ nx ][ ny ].color == 'O' ) )
			if ( field[ nx ][ ny ].color == 'O' )
				stack[ sp++ ] = nx * HEIGHT + ny;
			else
				sum += findGroup_body( nx, ny, color );			
	}
	
	return sum + 1;
}

void fallBlock( void ) {
	int x, y, cnt;

	for ( x = 0; x < WIDTH; x++ ) {
		cnt = 0;
		for ( y = HEIGHT - 1; y >= 0; y-- )
			if ( field[ x ][ y ].color == '.' )
				cnt++;
			else {
				field[ x ][ y + cnt ].color = field[ x ][ y ].color;
				field[ x ][ y + cnt ].state = YET;
			}

		for ( y = cnt - 1; y >= 0; y-- )
			field[ x ][ y ].color = '.';
	}
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
#define max(a,b) a > b ? a : b

int main(){
    int n,m;
    cin >> n >> m;
    int num[10] = {0,2,5,5,4,5,6,3,7,6};
    vector<int> flag(m);

    rep(i,m) cin >> flag[i];
    sort(flag.begin(),flag.end(),greater<int>());
    vector<int> dp(n+10,-1e9);
    dp[0] = 0;


    rep(i,n+1){
        rep(j,m){
            dp[i+num[flag[j]] ] = max(dp[i+num[flag[j]] ], dp[i] + 1); 
        }
    }

    int cnt = n;
    vector<int> num_cnt(10,0);
    while(cnt > 0){
        rep(j,m){
            if(cnt-num[flag[j]] < 0) continue;

            if(dp[cnt-num[flag[j]]] == dp[cnt] - 1){
                num_cnt[flag[j]]++;
                cnt -= num[flag[j]];
                break;
            }
        }
    }

    for(int i = 9; i > 0; i--){
        rep(j,num_cnt[i]){
            cout << i;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ulli unsigned long long int
#define lli long long int
#define d double
#define mod 1000000007
#define mx 200001
using namespace std;
void add_me(lli &a,lli b){
	a+=b;
	if(a>=mod) a-=mod;
}
void sub_me(lli &a,lli b){
	a-=b;
	if(a<0) a+=mod;
}
struct disjointset{
	int parent[mx];
	disjointset(){
		for(int i=1;i<mx;i++) parent[i]=i;
	}
	int find(int x){
		int par=parent[x];
		if(par==x) return x;
		return find(parent[x]);
	}
	void union_(int x,int y){
		int par1=find(x);
		int par2=find(y);
		if(par1==par2) return;
		parent[par2]=par1;
	}
};
int main() {
	FIO;
	string str;
	cin>>str;
	int n=str.length();
	int i=0,j=n-1;
	int ans=0;
	while(i<j){
		if(str[i]!=str[j]){
			ans++;
		}
		i++;
		j--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> H(N);
	rep(i, N) {
		cin >> H[i];
	}

	map<int, vector<int> > m;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		m[a].push_back(b);
		m[b].push_back(a);
	}

	int result = 0;
	rep(i, 1, N+1) {
		if (m[i].size() == 0) {
			result += 1;
			continue;
		}

		bool is_ok = true;
		rep(j, m[i].size()) {
			vector<int> l = m[i];

			if (H[i-1] > H[l[j]-1]) continue;
			is_ok = false;
		}

		if (is_ok) result += 1;
	}
	cout << result << endl;
  return 0;
}


Measured memory_bytes: 14616
#include <stdio.h>
int main(void)
{
  float a,b,c,d,e,f,x,y;
  while(scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f) != EOF){
  	x=(c*e-b*f)/(a*e-b*d);
  	y=(c*d-a*f)/(b*d-a*e);
	if(x>=0){
		x+=0.0004;
	}
	else{
		x-=0.0004;
	}
	if(y>=0){
		y+=0.0004;
	}
	else{
		y-=0.0004;
	}
	printf("%.3f %.3f\n",x,y);
  }
  return(0);
}

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

struct edge {int num,to,color;};
vector<edge> G[100050];
int an[100050];
int ans[100050];

int main(){
    int n; cin >> n;
    for(int i=0;i<n-1;i++){
        int a,b; cin >> a >> b;
        G[a].push_back({i,b,-1});
        an[b]=a;
    }

    for(int i=0;i<n;i++){
        int col=1;
        int mycolor;
        for(int j=0;j<G[an[i]].size();j++){
            if(G[an[i]][j].to==i) mycolor=G[an[i]][j].color;
        }
        for(int j=0;j<G[i].size();j++){
            if(col==mycolor) col++;
            G[i][j].color=col;
            col++;
        }
    }
    
    int k=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<G[i].size();j++){
            ans[G[i][j].num]=G[i][j].color;
            k=max(k,G[i][j].color);
        }
    }
    cout << k << endl;
    for(int i=0;i<n-1;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}
template<typename T>
void add_self(T& a, T b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}
template<typename T>
void sub_self(T& a, T b)
{
	a -= b;
	if (a < 0)
		a += mod;
}

// dp[i][j] - number of ways to distribute i candies to j kids

int main()
{ 
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int x, y;
	cin >> x >> y;
	vi a = { 300000, 200000, 100000 };
	int res = 0;
	if (x <= 3)
		res += a[x - 1];
	if (y <= 3)
		res += a[y - 1];
	if (x == 1 && y == 1)
		res += 400000;
	cout << res;
	return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
a -= 1
def gcd(c,d):
    while (c%d):
        t = c%d
        c, d = d, t
    return d

lcm = c*d//(gcd(max(c,d),min(c,d)))

b_ans = b - (b//c + b//d - b//lcm)
a_ans = a - (a//c + a//d - a//lcm)

print(b_ans - a_ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int a, b, cnt=0; scanf("%d%d",&a,&b);
	for(int i = a; i <= b; i++){
		if(i%10 == i/10000 && i/1000%10 == i/10%10) cnt++;
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
use std::collections::HashSet;
use std::borrow::Borrow;
use std::ops::IndexMut;
use std::cmp::{min, max};
use std::mem::swap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let n = v[0];
    let ans = n * n * n;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n,a[110];
    cin >> n;
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    int ans=0;
    a[n]=0;
    for(int i=0;i<n;i+=2){
        ans+=a[i]-a[i+1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int i,j=0,b=1;
  cin>>i;
  vector <string> S(i);
  for(j=0;j<i;j++){
    cin>>S.at(j);
  }
  sort(S.begin(), S.end());
    for(j=0; j<(i-1); j++){
      if(S.at(j)!=S.at(j+1)){
        b++;
      }
    }
  cout<<b;
}

Measured memory_bytes: 9552
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 998244353;
const int maxn = 2e6 + 233;
ll fac[maxn],Inv[maxn],powm[maxn];
int exgcd(int a,int b,int& x,int &y){
	if(b==0){
		x = 1;y = 0;
		return a;
	}
	int d = exgcd(b,a%b,y,x);
	y -= (a/b)*x;
	return d;
}
inline ll inv(int i){
	int x,y;
	exgcd(i,mod,x,y);
	return (x+mod)%mod;
}
void init(){
	fac[0] = Inv[0] = 1;
	for(int i=1;i<maxn;i++){
		fac[i] = fac[i-1]*i%mod;
		Inv[i] = Inv[i-1]*inv(i)%mod;
	}
}
inline ll c(int n,int k){
	if(k>n)return 0;
	return fac[n]*Inv[k]%mod*Inv[n-k]%mod;
}
inline ll cal(int n,int k,int m)
{
	ll ans = c(n-1,k)*m%mod;
	ans = ans*powm[n-k-1]%mod;
	return ans;
}
int main()
{
	init();
	powm[0] = 1;
	int n,m,k;cin>>n>>m>>k;
	for(int i=1;i<=n;i++)powm[i] = powm[i-1]*(m-1)%mod;
	ll ans = 0;
//	cout << cal(n,0,m) << " "<<cal(n,1,m)<<endl
	for(int i=0;i<=k;i++)ans = (ans+cal(n,i,m))%mod;
	cout << ans << endl;
}

Measured memory_bytes: 36444
import string
import numpy as np
N = int(input())
S = list(input())
A2Z = string.ascii_uppercase

str_index = np.full(len(S), 0)
mod_26 = np.full(len(S), 26)
#print(str_index)

for i in range(len(S)):
    str_index[i] = A2Z.index(S[i])
str_index = (str_index+N) % mod_26
#print(str_index)

tmp = ['']*len(S)
for i in range(len(S)):
    index = int(str_index[i])
    tmp[i] = A2Z[index]
answer = ''.join(tmp)
print(answer)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  map<int, int64_t> mp;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    mp[A[i]]++;
  }
  int64_t t = 0;
  for (auto m : mp) {
    t += m.second * (m.second - 1) / 2;
  }
  for (int i = 0; i < N; i++) {
    cout << t - (mp[A[i]] - 1) << '\n';
  }
  return 0;
}


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

int enough(vector<long long> h, long long a, long long b, long long  t) {

    for(int i=0; i<h.size(); i++) {
        h[i] -= b * t;
    }

    unsigned long long count = 0;
    for(int i=0; i<h.size(); i++) {
        if(h[i] > 0) {
            count += h[i] / (a-b);
            if(h[i]%(a-b) != 0) count++;
        }
    }

//    cout << "count = " << count << " t = " << t << endl;

    if(count < t) return 1;
    else if(count > t) return -1;
    else return 0;
    
}

int main() {

    long long N, A, B;
    cin >> N >> A >> B;
    
    vector<long long> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    long long left = 0;
    long long right = 10E+9;
    long long mid;
    long long result = 10E+9;
    while(left<=right) {
        mid = (left + right) / 2;
        int ret = enough(h, A, B, mid);
//        cout << ret << " " << mid << endl;
        if(ret == 0) {
            if(result > mid) result = mid;
            break;
        }
        else if(ret == -1) {
            left = mid + 1;
        }
        else {
            if(result > mid) result = mid;
            right = mid - 1;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1792
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))



(defun main (tmp a lst &aux (heights (coerce lst 'vector)))
  (labels ((cul-error (height)
             (abs (- a (- tmp (* 0.006 height))))))
    (loop for p from 0
          for height across heights
          with res = 0
          when (> (cul-error (aref heights res)) (cul-error height))
            do
               (setf res p)
          finally (return (1+ res)))))

(let ((n (read))
      (tmp (read))
      (a (read)))
  (princ (main tmp a (read-times n))))


Measured memory_bytes: 23608
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    double d[n], r[n];
    for(int i = 0; i < n; i++)  cin >> r[i];
    double ans = 0;
    for(int i = 0; i < n; i++){
        d[i] = r[i];
        for(int j = 0; j < i; j++){
            d[i] = max(d[i], d[j]+2*sqrt(r[i]*r[j]));
        }
        ans = max(ans, r[i]+d[i]);
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


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

	int K, P;
	for (int i = 0; i < N; i++){
		cin >> K >> P;
		if (K%P != 0){
			cout << K%P << endl;
		}
		else{
			cout << P << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n){cin>>a[i];}
    sort(ALL(a));
    ll ans=0;
    for(int left=0;left<n;left++){
        ll num=a[left],sum=0,c=0;
        ll right=left;
        while(right<n&&a[right]==num){
            right++;sum++;c++;
        }
        while(right<n&&a[right]<=num+2){
            right++;
            sum++;
        }
        ans=max(sum,ans);
        left+=c-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

//const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 300020;

int siz[MAX];//錬結成分のサイズ
int par[MAX];//親
int Rank[MAX];//木の深さ

//n要素で初期化
void init(int n) {
	REP(i, n) {
		par[i] = i;
		Rank[i] = 0;
		siz[i] = 1;
	}
}

//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);//経路圧縮(根に直接つなぎなおす)もしつつ
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	//低いほうを高いほうにつなげる(効率化)
	if (Rank[x] < Rank[y]) {
		par[x] = y;
		siz[x] += siz[y];
		siz[y] = siz[x];
	}
	else {
		siz[y] += siz[x];
		siz[x] = siz[y];
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}

int idx[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	int M; cin >> M;
	init(2*N + 1);
	REP(i, N) {
		int p; cin >> p;
		idx[p] = i + 1;
		unite(p, i + 1 + N);
	}
	REP(i, M) {
		int x, y; cin >> x >> y;
		unite(idx[x] + N, idx[y] + N);
	}
	int ans = 0;
	FOR(i,1,N+1){
		if (same(i, i+N))ans++;
	}
	print(ans);
}

Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
def inpl(): 
    return tuple(map(int, input().split()))

N, K = inpl()
numbers = []

for _ in range(N):
    A, B = inpl()
    numbers.append([A, B])
res = 0

target = bin(K)[2:]
targets = [target]
while "10" in target:
    n = target.rfind("10")
    new_target = target[:n] + "0" + "1"*(len(target)-n-1)
    targets.append(new_target)
    target = new_target

targets = list(map(int, targets, [2]*len(targets)))

for target in targets:
    tmp = 0
    for a, b in numbers:
        if (target | a) == target:
            tmp += b
    res = max(res, tmp)
print(res)

Measured memory_bytes: 19760
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	if(s=="SUN")cout<<"7\n";
	if(s=="MON")cout<<"6\n";
	if(s=="TUE")cout<<"5\n";
	if(s=="WED")cout<<"4\n";
	if(s=="THU")cout<<"3\n";
	if(s=="FRI")cout<<"2\n";
	if(s=="SAT")cout<<"1\n";
}


Measured memory_bytes: 256
def insertionSort(_list, _length):
    for i in range(1, _length):
        ll = [str(_l) for _l in _list]
        print(' '.join(ll))
        val = _list[i]
        j = i - 1
        while j >= 0 and _list[j] > val:
            _list[j+1] = _list[j]
            j -= 1
        _list[j+1] = val
    ll = [str(_l) for _l in _list]
    print(' '.join(ll))


length = int(input())
eles = list(map(int, input().split()))

insertionSort(eles, length)

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

int main() {
	int t;
	cin>>t;
	while(t--) {
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		if(d>c && b<a)
			cout<<-1<<"\n";
		else if(a<=b) {
			cout<<b<<"\n";
		}
		else {

			
			
			
				ll rem = a - b;
				//time = b;
				ll pp = (rem)%(c-d);
				ll pro = 0;
				if(pp != 0) {
					pro = (rem/(c-d)) + 1;
				}
				else {
					pro = rem/(c-d);
				}
				ll ans = b + pro*c;
				cout<<ans<<"\n";
			

		}
	}
	return 0;
}*/

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

int main() {

	int k;
	string s;
	cin>>k;
	cin>>s;

	int l = s.length();

	if(l<=k)
		cout<<s;
	else {
		string s2 = s.substr (0,k);
		s2.append("...");
		cout<<s2; 
	}
	return 0;
}


/*
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ll t;
	cin>>t;
	while(t--) {
		ll n;
		cin>>n;
		n = 2*n;
		//cout<<M_PI<<" ";

		double ans = 1/(tan(3.141592653589/n));
		
		cout<<setprecision(20)<<ans<<"\n";
	}
	return 0;
}*/

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long[] b = new long[n-1];
		for(int i = 0; i < n-1; i++) {
			b[i] = a[i+1] - a[i];
		}
		long ans = 0;
		for(int i = 0; i < k-1; i++) {
			ans += b[i];
		}
		long x = ans;
		for(int i = 0; i < n-k; i++) {
			x = x - b[i] + b[i+k-1];
			if(x < ans) {
				ans = x;
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 48404
i = [int(input()) for i in range(4)]
A=i[0]
B=i[1]
C=i[2]
X=i[3]

cnt=0
for a in range(A+1):
    if 500*a >X:
        break
    else:
        for b in range(B+1):
            if 500*a + 100*b >X:
                break
            elif (X-500*a-100*b)/50<=C:
                cnt+=1
            else:
                continue
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10;

int n,k;

int32_t main(){
    string s,t;
    cin>>s>>k;
    n=s.size();
    for(int i=0;i<n;i+=k){
	t.pb(s[i]);
    }
    cout<<t<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007
#define Reg register

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

int lc(const void *a,const void *b){
    if(*(long*)a - *(long*)b){
        return  *(long*)a < *(long*)b?-1:1;
    }
    return 0;
}

static inline long mdml(long a,long b){
    Reg long long res = (long long)a * b;
    return res % MOD;
}

static inline long mdpow(long num,long ind){
    Reg unsigned long ibit = (unsigned long)ind;
    Reg long res = 1;
    while(ibit){
        if(1lu & ibit)res = mdml(res,num);
        num = mdml(num,num);
        ibit >>= 1;
    }
    return res;
}

static inline long mdadd(long a,long b){
    return (a + b) % MOD;
}

int main(void){
    int n;
    scanf("%d",&n);
    long c[n];
    for(Reg int i = 0;i < n;i++)scanf("%ld",&c[i]);
    qsort(c,n,sizeof(long),lc);
    Reg long ans = 0;
    long tmppow = mdpow(2l,n);
    Reg long tmp2inv = mdpow(2l,MOD-2l);
    Reg long t2n = mdml(tmppow,tmp2inv);
    Reg long t4n = mdml(tmppow,mdml(tmp2inv,tmp2inv));
    Reg int tmpn = n - 1;
    for(Reg int i= 0;i < n;i++)ans = mdadd(ans,mdml(c[i],mdadd(t2n,mdml(t4n,tmpn-i))));
    ans = mdml(ans,tmppow);
    printf("%ld",ans);
}

Measured memory_bytes: 3324