akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------


int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int i=1;i<=102;i++){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
'''
Date         : 2020-08-08 23:01:16
Author       : ssyze
Description  : 
'''
from math import *
k = int(input())
x = 7
cnt = 1
while x % k != 0:
    x = (x * 10 + 7) % k
    cnt += 1
    if cnt >= 10**6 + 5:
        break
if cnt >= 10**6 + 5:
    print("-1")
else:
    print(cnt)


Measured memory_bytes: 63164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
	int N;
	string S[114514];
	int Ans = 0;
	int m[5]={};
	int sum=0;
	cin >> N;
	REP(i,N){
	    cin >> S[i];
	    if(S[i][0]=='M'){
	        m[0]++;
	    }else if(S[i][0]=='A'){
	        m[1]++;
	    }else if(S[i][0]=='R'){
	        m[2]++;
	    }else if(S[i][0]=='C'){
	        m[3]++;
	    }else if(S[i][0]=='H'){
	        m[4]++;
	    }
	}
	REP(i,5){sum+=m[i];}
	
	Ans+=m[0]*m[1]*m[2];
	Ans+=m[0]*m[1]*m[3];
	Ans+=m[0]*m[1]*m[4];
	Ans+=m[0]*m[2]*m[3];
	Ans+=m[0]*m[2]*m[4];
	Ans+=m[0]*m[3]*m[4];
	Ans+=m[1]*m[2]*m[3];
	Ans+=m[1]*m[2]*m[4];
	Ans+=m[1]*m[3]*m[4];
	Ans+=m[2]*m[3]*m[4];
	
//	REP(i,5){cout << m[i] << " ";}
	
	cout << Ans << endl;
	
	
	return 0;
}


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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    string ans;
    if(a==b and b==c){
        ans = "No";
    }else if(a!=b and b!=c and a!=c){
        ans = "No";
    }else{
        ans = "Yes";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{

	const int mod = 1000000007;
	static void Main(string[] args)
	{
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		int N = int.Parse(Console.ReadLine());
		long ans = 0;
		if (N < 10) { ans = N; }
        else if (N < 100) { ans = 9; }
        else if (N < 1000) { ans = N - 90; }
        else if (N < 10000) { ans = 909; }
        else if (N < 100000) { ans = N - 9090; }
		else { ans = 90909; }
		Console.WriteLine(ans);


		Console.Out.Flush();
	}
}

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

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

    vector<int> manip(m);
    vector<bool> used(n+1, false);
    for(int i=0; i<m; i++){
        cin >> manip[i];
    }

    for(int i=m-1; i>=0; i--){
        if(!used[manip[i]]){
            cout << manip[i] << endl;
            used[manip[i]] = true;
        }
    }
    for(int i=1; i<=n; i++){
        if(!used[i]){
            cout << i << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> a(n),b(n),c(n);
    generate(all(a),nxt);
    generate(all(b),nxt);
    generate(all(c),nxt);
    sort(all(a));sort(all(b));
    sort(all(c));
    ll ans=0;
    vector <ll> cnt;
    cnt.resize(n,0);
    for(int i=0;i<n;i++)
    {
        int val=b[i];
        int l=0,r=n-1;
        int test=n;
        while(l<=r){
            int mid=(l+r)/2;
            if(c[mid]>val)
            {
                test=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
        cnt[i]=n-test;
        

    }
    vector <ll> suffix(n);
    suffix[n-1]=cnt[n-1];
    for(int i=n-2;i>=0;i--)
        suffix[i]=suffix[i+1]+cnt[i];
    for(int i=0;i<n;i++)
    {
        int val=a[i];
        int l=0,r=n-1;
        int test=n;
        while(l<=r){
            int mid=(l+r)/2;
            if(b[mid]>val)
            {
                test=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
        //cout<<val<<" "<<test<<endl; 
        if(test<n)
            ans+=suffix[test];


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




 
 


Measured memory_bytes: 3072
#include <iostream>
#include <map>
#include <string>

int main(int argc, char *argv[]){
    std::string S;
    std::cin >> S;
    std::map<char,int> charDist;
    for(auto s : S){
        charDist[s]++;
    }
    for(auto dist : charDist){
        if(dist.second != 2){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

int n, m, ans = 0;

int dfs(int v, vector<vector<int> >& g, vector<int>& d) {
    int temp = 0;
    if ((int)g[v].size() == 0) {
        d[v] = 0;
        return 0;
    }
    for (int c : g[v]) {
        if (d[c] == -1) {
            dfs(c, g, d);
        }
        temp = max(temp, d[c]);
    }
    d[v] = temp + 1;
    ans = max(ans, d[v]);
    return d[v];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    vector<vector<int> > g(n);
    vector<int> d(n, -1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
    }
    for (int i = 0; i < n; i++) {
        if (d[i] == -1) dfs(i, g, d);
        // cout << d[i] << " ";
    }
    // cout << endl;
    cout << ans;

    return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int c[4][4];

  REP (i, 3) REP (j, 3) {
    scanf("%d", &c[i][j]);
  }

  bool flag = true;
  REP (i, 2) {
    if (c[i + 1][0] - c[i][0] != c[i + 1][1] - c[i][1] || c[i + 1][2] - c[i][2] != c[i + 1][1] - c[i][1]) {
      flag = false; 
    }
    if (c[0][i + 1] - c[0][i] != c[1][i + 1] - c[1][i] || c[2][i + 1] - c[2][i] != c[1][i + 1] - c[1][i]) {
      flag = false; 
    }
  }

  printf("%s\n", flag ? "Yes" : "No");
}


Measured memory_bytes: 256
# coding:utf-8

n = int(input())
zorome = [0, 111, 222, 333, 444, 555, 666, 777, 888, 999]

for i in range(len(zorome)-1):
    if n == zorome[i]:
        print(zorome[i])
        break
    elif (n > zorome[i]) & (n<=zorome[i+1]):
        print(zorome[i+1])
        break
    else:
        pass


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

int main() {
  
  vector<int> M(5);
  int max_d = 0 ;
  int sum = 0 ;
  for ( int i = 0 ; i < 5 ; i++ ){
  	cin >> M.at(i) ;
    if ( M.at(i) % 10 != 0 ){
      if( 10 - M.at(i) % 10 > max_d ){
        max_d = 10 - M.at(i) % 10;
      }
      M.at(i) = ( M.at(i)/10 + 1 ) * 10 ;
    }
    sum += M.at(i);
  }
  
  cout << sum - max_d << endl;  	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
ll a[200001];
int main(void)
{
	int n;
	scanf("%d",&n);
	ll sum1=0,sum2=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(i!=n)
		sum1+=a[i];
		else
		sum2+=a[i];
	}	
	ll ans=abs(sum1-sum2);
	for(int i=n-1;i>1;i--)
	{
		sum1-=a[i];sum2+=a[i];
		ll v;
		if(sum1>=sum2) v=sum1-sum2;
		else v=sum2-sum1;
		ans=min(v,ans);
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;

	vector<tiii> arr(n);
	rep(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		arr[i] = make_tuple(a, b, c);
	}
	
	vector<tiii> dp(n);
	dp[0] = arr[0];
	loop(i, 1, n) {
		int a = max(get<1>(dp[i-1]), get<2>(dp[i-1])) + get<0>(arr[i]);
		int b = max(get<0>(dp[i-1]), get<2>(dp[i-1])) + get<1>(arr[i]);
		int c = max(get<0>(dp[i-1]), get<1>(dp[i-1])) + get<2>(arr[i]);
		dp[i] = make_tuple(a, b, c);
	}

	cout << max(get<0>(dp[n-1]), max(get<1>(dp[n-1]), get<2>(dp[n-1]))) << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{ 
  int N,K;
  cin>>N>>K;
  cout<<min(N%K,K-N%K)<<endl;
  
  
  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, Y;

    cin >> N >> Y;

    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N - x; y++) {
            int z = N - x - y;
            if (x * 10000 + y * 5000 + z * 1000 == Y) {
                cout << x << ' ' << y << ' ' << z << endl;

                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long n, m, res;
int main() {
    DAU
    cin >> n >> m;
    res = (n * m + 1) / 2;
    if (n == 1 || m == 1)
        res = 1;
    cout << res;
    PLEC
}


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

using namespace std;
using ll = long long;

#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) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

ll gcd(ll a, ll b)
{
    if(a == 0) return b;
    else if(b == 0) return a;
    else return a > b ? gcd(a % b, b) : gcd(a, b % a);
}

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

    _PR(A*B/gcd(A,B));

    return 0;
}

/*



*/

Measured memory_bytes: 764
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    String S;
    int N,Q;
    int[] l,r;
    private void solve() {
        N = nextInt();
        Q = nextInt();
        S = next();

        l = new int[Q];
        r = new int[Q];
        for(int i = 0;i < Q;i++) {
            l[i] = nextInt();
            r[i] = nextInt();
        }

        int[] sum = new int[N + 1];
        for(int i = 0;i < N;i++) {
            int add = 0;
            if (i + 1 < N) {
                add = S.charAt(i) == 'A' && S.charAt(i + 1) == 'C' ? 1 : 0;
            }
            sum[i + 1] += sum[i] + add;
        }

        for(int i = 0;i < Q;i++) {
            out.println(sum[r[i] - 1] - sum[l[i] - 1]);
        }
    }

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

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 47772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

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

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int t1 = (a+d-1)/d;
	int t2 = (c+b-1)/b;
	cout<<((t2 <= t1) ? "Yes\n" : "No\n");
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	//cin>>T;
	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 3640
dic = {}
h, w, d = map(int, input().split())
lis = [list(input().split()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        dic[int(lis[i][j])] = (i, j)
n = h * w
su = [0] * (n + 1)
for k in range(1, n - d + 1):
    x = dic[k + d][0] - dic[k][0]
    y = dic[k + d][1] - dic[k][1]
    su[k + d] = su[k] + abs(x) + abs(y)

q = int(input())
for i in range(q):
    s, g = map(int, input().split())
    print(su[g] - su[s])


Measured memory_bytes: 68184
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,X,M;
int memo[100005];
int cnt[100005];
signed main(){
    scanf("%lld %lld %lld",&N,&X,&M);
    int A=X;
    rep(i,M)memo[i]=-1;
    rep(i,M)cnt[i]=-1;
    memo[A]=A;
    cnt[A]=0;
    int circ=0;
    int laps=0;
    rep(i,M){
        int A_=(A*A)%M;
        if(memo[A_]==-1){
            memo[A_]=memo[A]+A_;
            cnt[A_]=i+1;
            A=A_;
        }else{//戻ってきた 必ずMのうちに戻ってくる
            circ=memo[A]+A_-memo[A_];
            laps=i+1-cnt[A_];
            A=A_;
            break;
        }
        //printf("%lld/",memo[A]);
        if(i==N-2){printf("%lld\n",memo[A]);return 0;}//周回する必要もない
    }
    int ans=memo[A];//ループに入る前のスコア
    int loop=(int)( (N-1-cnt[A])/laps ); //何周かする
    ans+=loop*circ;
    //何周かした後
    int left=N-1-cnt[A]-loop*laps;
    int B=A;
    rep(i,left){
        int B_=(B*B)%M;
        ans+=B_;
        //printf("%lld!\n",B_);
        B=B_;
    }
    //printf("%lld-%lld-%lld\n",laps,loop,circ);
    printf("%lld\n",ans);
    
}

Measured memory_bytes: 3284
#include<stdio.h>

int main(){
  int en[26]={},n=0;
  char a;

  while ((a = getchar()) != EOF) {

    if(a >= 'a' && a <= 'z'){
      en[a-'a']++;
    } else if(a >= 'A' && a <= 'Z'){
      en[a-'A']++;
    }
  }
  for(n=0;n<26;n++){
    printf("%c : %d\n",n+'a',en[n]);
  }
  return 0;
}



  


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int r=0, b=0;
    rep(i, s.size()) if (s[i] == 'R') r++; else b++;
    cout << (r > b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import 'dart:convert';
import 'dart:io';
import 'dart:async';
import "dart:math";

Future main() async {
  List nl = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  Stream<String> sLines =
      stdin.transform(utf8.decoder).transform(LineSplitter()); // ここ大事（複数行入力）
  int lineNum;
  lineNum = 1;
  List s = [];
  await for (String line in sLines) {
    lineNum = lineNum + 1;
    s.add(line);

    if (lineNum > nl[0]) break; // ここの場所！
  }
  List sortS = s..sort();
  String count = "";
  sortS.forEach((num0) => count += num0);

  // print(sortS);
  print(count);
}

Measured memory_bytes: 13680
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ull qpow(ull a, ull b)
{
    ull ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll s = 0;
    int n, m;
    cin >> n >> m;
    int x;
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        s += x;
    }
    if (n >= s)
        cout << n - s;
    else
        cout << -1;
}

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

#define POW(x) ((x) * (x))

int main() {
  int c1x, c1y, c1r;
  int c2x, c2y, c2r;

  cin >> c1x >> c1y >> c1r;
  cin >> c2x >> c2y >> c2r;

  if (POW(c1x - c2x) + POW(c1y - c2y) > POW(c1r + c2r))
    cout << 4 << endl;
  else if (POW(c1x - c2x) + POW(c1y - c2y) == POW(c1r + c2r))
    cout << 3 << endl;
  else if (POW(c1x - c2x) + POW(c1y - c2y) == POW(c1r - c2r))
    cout << 1 << endl;
  else if (POW(c1x - c2x) + POW(c1y - c2y) < POW(c1r - c2r))
    cout << 0 << endl;
  else
    cout << 2 << endl;

  return 0;
}


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

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

// struct CompareMyDataGreater {
//     bool operator() ( MyData &a, MyData &b) {
//         return a.age() < b.age();
//     }
// };
// bool q_compare(pair<int, int> a, pair<int, int> b)
// {
//     return a.second > b.second;
// }

int main()
{
    int N, M; cin >> N >> M;
    priority_queue<pair<int, int>> q;
    pair<int, int> AB[100001]; for(int i=0; i<N; i++) cin >> AB[i].first >> AB[i].second;
    sort(AB, AB+N, compare);
    for(int i=0; i<N; i++)
    {
        swap(AB[i].first, AB[i].second);
        //cout << AB[i].first << " " << AB[i].second << endl;
    }

    int day = M-1; int value = 0; int i = 0;
  	q.push(make_pair(0,M));
    while(1)
    {   
        while(AB[i].second == M - day && i < N)
        {
            q.push(AB[i++]);
            //cout << q.top().first << " " << q.top().second << endl;
        }
        
        if(q.top().second <=  M - day)
        {   
          	//cout << q.top().first  << " " << q.top().second << endl;
            value += q.top().first;
            q.pop();
        }
        if(day == 0) break;
      	day--;
    }
    cout << value;
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}


void solve()
{
    int n;
    cin>>n;
    vl a(n);
    ll ans=1;
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    for(int i=0;i<n;i++) {
        if(a[i]==0) {
            cout<<0;
            return;
        }
    }
    ld x=1.0;
    for(int i=0;i<n;i++) {
        x *= a[i];
        if (x>1e18)
        {
            cout << -1;
            return;
        }
    }
    ans = x;
    cout<<ans;
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
} 

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

using namespace std;

vector<vector<int>> path(8);
vector<bool> visited(8);
int N,ans=0;

void visit_node(int start){
    bool all_visit = true;
    for(int i=0; i<N; i++){
        if(!visited[i]){
            all_visit = false;
            break;
        }
    }
    if(all_visit){
        ans++;
        return;
    }
    for(int i=0; i<(int)path[start].size(); i++){
        if(!visited[path[start][i]]){
            visited[path[start][i]]=true;
            visit_node(path[start][i]);
            visited[path[start][i]]=false;
        }
    }
}
int main(){
    int M,a,b;
    cin >> N >> M;

    for(int i=0; i<M; i++){
        cin >> a >> b;
        a--;
        b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    visited[0]=true;
    visit_node(0);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
int n,a[100005],k;
int dp[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cout<<fixed;
//    cout<<setprecision(10);

    cin>>n>>k;
    for (int i=0;i<n;i++) cin>>a[i];
    //memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for (int i=1;i<n;i++)
    {
        dp[i]=abs(a[i]-a[i-1])+dp[i-1];
        for (int j=2;j<=k;j++)
        if (i-j>=0)
            dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
    }
    cout<<dp[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	
	cin >> a;
	cin >> b;
	
	if(a < b){
		cout << "a < b" << endl;
	} else if(a > b){
		cout << "a > b" << endl;
	} else{
		cout << "a == b" << endl;
	}
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  ll n,W;
  cin >> n >> W;
  vl w(n),v(n);
  REP(i,n) cin >> w[i] >> v[i];
  vvl dp(n+1,vl(W+1,0));
  REP(i,n)REP(j,W+1){
    if(j<w[i]){
      dp[i+1][j] = dp[i][j];
      continue;
    }
    dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
  }
  cout << dp[n][W] << endl;
}



Measured memory_bytes: 80256
import kotlin.math.abs

fun main() {
    val builder = StringBuilder()

    val (x, n) = readInputLine().split(" ").map { it.toInt() }

    val set = mutableSetOf<Int>()

    val input = readInputLine()

    if (input.isNotEmpty()) {
        input.split(" ").map { set.add(it.toInt()) }
    }

    var maxDiff = Int.MAX_VALUE
    var ans = 0

    for (i in -200..200) {
        if (set.contains(i)) {
            continue
        }
        if (abs(x - i) < maxDiff) {
            maxDiff = abs(x - i)
            ans = i
        }
    }

    builder.appendln(ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36568
let sum_of_digit str =
  let len = String.length str in
  let rec iter i sum = match len-i with
    | 0 -> sum
    | _ -> iter (i+1) ((int_of_char str.[i] - 48) + sum )
  in iter 0 0

let () =
  let rec loop () =
    match read_line () with
    | "0" -> ()
    | n ->
      Printf.printf "%d\n" (sum_of_digit n);
      loop ()
  in loop ()

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

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int d = m / n; d >= 1; -- d){
        int ret = m / d;
        if(m % d == 0 && ret >= n){
            printf("%d\n", d);
            break;
        }
    }


    return 0;
}

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

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	long long mx = -1LL << 60;
	
	mx = max(mx, 1LL * b * d);
	mx = max(mx, 1LL * a * c);
	mx = max(mx, 1LL * a * d);
	mx = max(mx, 1LL * b * c);
	
	printf("%lld\n", mx);
	
	return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   

    int x;
    cin>>x;
    if(x == 0)
        cout<<1;
    else
        cout<<0;
    

    return 0;
}

Measured memory_bytes: 3504
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
//        int N = input.nextInt();
//        int A = input.nextInt();
        String S = input.next();
        int count = 0;

            for (int i = 0; i < S.length() / 2; i++) {
                if (S.charAt(i) != S.charAt(S.length() - 1 - i)) {
                    count++;
                }
            }


        System.out.println(count);

//        for (int i = 0; i < N; i++){
//            for (int j = 0; j < A; j++){
//
//            }
//        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int H,W;
  cin>>H>>W;
  FOR(i,0,H){
    FOR(j,0,W){
      string S;
      cin>>S;
      if(S=="snuke"){
        char ch='A'+j;
        cout<<ch<<i+1<<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int K;
string N;

itn dp[111][3][10];


void solve() {
    FOR(i, 0, (int)N.size()) {
        N[i] -= '0';
    }
    int Z = N.size();

    int n = N[0];
    dp[0][0][0] = 1;
    dp[0][0][1] = n - 1;
    dp[0][1][1] = 1;
    FOR(i, 1, Z) {
        FOR(k, 0, 5) {
            dp[i][0][k] += dp[i - 1][0][k];
            if (k > 0)
                dp[i][0][k] += dp[i - 1][0][k - 1] * 9;
            int n = N[i];
            if (n != 0) {
                if (k > 0)
                    dp[i][1][k] += dp[i - 1][1][k - 1];
                if (k > 0)
                    dp[i][0][k] += dp[i - 1][1][k - 1] * (n - 1);
                dp[i][0][k] += dp[i - 1][1][k];
            } else {
                dp[i][1][k] += dp[i - 1][1][k];
            }
        }
    }
    /*
    FOR(i, 0, Z) {
        FOR(k, 0, K + 1) {
            //cerr << i << " " << k << endl;
            //cerr << dp[i][0][k] << " " << dp[i][1][k] << endl
            //<< endl;
        }
    }
    */
    cout << dp[Z - 1][0][K] + dp[Z - 1][1][K] << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
   int n;
   cin >> n;
   vector<int> c(n-1);
   vector<int> s(n-1);
   vector<int> f(n-1);
   vector<int> ans(n, 0);
   rep(i, 0, n-1) {
       cin >> c[i] >> s[i] >> f[i];
   }

   
   rep(i, 0, n-1) {
       //int tmp = 0;
       int tmp = c[i]+s[i];
       rep(j, i+1, n-1) {
           int diff = tmp-s[j];
           if(diff < 0) {
               tmp = s[j]+c[j];
               continue;
           }
           else if(diff > 0) {
               if(diff % f[j] == 0) {
                   tmp+=c[j];
               }
               else {
                   tmp+=c[j]+(tmp/f[j]+1)*f[j]-tmp;
               }
           }
           else {
               tmp+=c[j];
           }
           //cout << j << " " << tmp << endl;
       }
       ans[i] = tmp;
   }
   
   rep(i, 0, n) {
       cout << ans[i] << endl;
   }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func abs(x, y int) int {
	z := x - y
	if z > 0 {
		return z
	}
	return -z
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Split(bufio.ScanLines)
	n := readInt()
	m := readInt()
	x := make([]int, 0, m)
	for i := 0; i < m; i++ {
		x = append(x, readInt())
	}
	if n > len(x) {
		fmt.Println(0)
		return
	}
	sort.Ints(x)
	absSlice := make([]int, 0, m-1)
	for i := 0; i < m-1; i++ {
		absSlice = append(absSlice, abs(x[i+1], x[i]))
	}
	sort.Ints(absSlice)
	absSlice = absSlice[:len(absSlice)-(n-1)]
	var sum int
	for _, i := range absSlice {
		sum += i
	}
	fmt.Println(sum)
}


Measured memory_bytes: 2944
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

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

main :: IO ()
main = do
    !n <- readLn :: IO Int
    cs <- U.unfoldrN n C.uncons <$> C.getLine
    print $ solve n cs

solve :: Int -> U.Vector Char -> Int
solve n cs = min freqB . min (n - freqB)
    . U.minimum . U.imap f . U.scanl1' (+) $ U.map (fromEnum.(== '#')) cs
  where
    !freqB = U.length $ U.filter (== '#') cs
    f i x = x + (n - (i + 1) - (freqB - x))

-------------------------------------------------------------------------------

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

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

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

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

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

Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    for(auto c : s) {
        mp[c]++;
    }
    bool ok = true;
    for(auto p : mp) {
        if(p.second != 2) ok = false;

    }
    if(ok) Yes();
    else No();
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B;
            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            //  x = int.Parse(word[2]);
            int x = A * B;
         
            if (A <= 9 && B <= 9)
                Console.WriteLine(x);
            else
                Console.WriteLine("-1");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let [| h; n |] = reada int
    let a = reada int |> Array.sum
    if h <= a then "Yes" else "No"
    |> puts

    ()

main()
writer.Close()


Measured memory_bytes: 16608
/** author: __nishad **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979323

int main()
{
    IOS;

    ll n, m, x, y, p;
    vll v1, v2;

    cin>>n>>m>>x>>y;
    v1.pb(x);
    v2.pb(y);
    while(n--){
        cin>>p;
        v1.pb(p);
    }
    while(m--){
        cin>>p;
        v2.pb(p);
    }


    if(minv(v2) <= maxv(v1))
        cout<<"War";
    else
        cout<<"No War";

}



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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

string s1="Positive";
string s2="Negative";
string s3="Zero";

int main() {
    ll a,b;
    while(cin>>a>>b) {
        if(a*b < 0) {
            cout<<s3<<"\n";
        } else if((a>=0 and b>=0) or (abs(a-b) % 2 != 0)) {
            cout<<s1<<"\n";
        } else {
            cout<<s2<<"\n";
        }
    }

    return 0;
}


Measured memory_bytes: 256