akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
ll a[85];
ll ans = 1000;

void solve()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%lld", &a[i]);
    int i = 1;
    while (i < n)
    {
        int j = i;
        while (j <= n && a[j] >= a[j + 1])
            j++;
        if (j == n + 1)
            break;
        ll cnt = ans / a[j];
        ans = ans - cnt * a[j] + cnt * a[j + 1];
        i = j + 1;
    }
    printf("%lld\n", ans);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N, A, B, C ,D, E;
	long long S[5];

	cin >> N;
	cin >> A; S[0] = A;
	cin >> B; S[1] = B;
	cin >> C; S[2] = C;
	cin >> D; S[3] = D;
	cin >> E; S[4] = E;

	long long m = 1L<<60;
	long long t = 0;

	for(int i=0; i<5; i++){
		if(m > S[i]){
			m = S[i];
		}
		long long u = N - (t - i) * m;
		t += u / m + 1;
		if((u % m) == 0){
			t--;
		}
	}
	cout << t << endl ;
	return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> lcr(M);
    REP(i, M) {
        int l, r, c;
        cin >> l >> r >> c;
        lcr[i] = make_tuple(l, c, r);
    }
    sort(lcr.begin(), lcr.end());
    if (get<0>(lcr[0]) != 1) {
        cout << -1 << endl;
        exit(0);
    }

    vector<ll> dp(N + 1, LLONG_MAX);
    dp[1] = 0;

    int l = get<0>(lcr[0]);
    int r = get<2>(lcr[0]);
    int c = get<1>(lcr[0]);
    FOR(i, l + 1, r + 1) dp[i] = c;
    int i = 1;
    while (i < M) {
        int il = get<0>(lcr[i]);
        int ic = get<1>(lcr[i]);
        int ir = get<2>(lcr[i]);
        if (il == l) {
            if (ir > r && dp[ir] > dp[l] + ic) {
                FOR(j, r + 1, ir + 1) dp[j] = min(dp[j], dp[l] + ic);
                r = ir;
            }
            i++;
        } else {
            l = il;
            r = il;
            if (dp[l] == LLONG_MAX) {
                cout << -1 << "\n";
                exit(0);
            }
        }
    }
    cout << (dp[N] == LLONG_MAX ? -1 : dp[N]) << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define cf ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define fox(i,j,n) for( i=j;i<n;i++)
#define srtar(a,n) sort(a,a+n)
#define srtvec(v) sort(v.begin(),v.end())
#define fauto(x,t) for(auto x: t)
#define mem(n,x) memset(n, x, sizeof(n))
const double pi=acos(-1);

int main()
{
    int t, i ;
    string s;
    cin >> s;
    if(s[3]==s[2] && s[4]==s[5])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  unordered_map<int,int> mp;
  for(int i=0;i<m;i++)
  {
    int x,y;
    cin>>x>>y;
    if(mp.find(x)!=mp.end())
    {
      if(mp[x]!=y)
      {
        cout<<-1;
        return 0;
      }
    }
    else mp[x]=y;
    if(x==1 && y==0)
    {
      if(n==1)
      {
        cout<<0;
        return 0;
      }
      else 
      {
        cout<<-1;
        return 0;
      }
    }
  }
  for(int i=1;i<=n;i++)
  {
    if(mp.find(i)==mp.end())
    {
      if(i==1)
      {
        if(n==1)  
        {
          cout<<0;
          return 0;
        }
        else cout<<1;
      }
      else
      cout<<0;
    }
    else cout<<mp[i];
  }
  return 0;
}


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


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

int N;
string A,B,C;
int main(){
	cin >> N >> A >> B >> C;
	int ans = 0;
	set<char> s;
	for(int i=0;i<N;i++){
		s.insert(A[i]);
		s.insert(B[i]);
		s.insert(C[i]);
		ans += s.size()-1;
		s.clear();
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
let readInt () = stdin.ReadLine() |> int

()
|> readInt
|> fun x -> [ 1 .. x ]
|> List.map (fun _ -> readInt ())
|> List.sortDescending
|> fun l ->
    (l |> List.head |> (/) <| 2)
    + (l |> List.tail |> List.sum)
|> printfn "%d"


Measured memory_bytes: 30384
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main()
{
    long long n;cin>>n;
    if(n==1) printf("2\n");
    else if(n&1) cout<<2*n<<endl;
    else cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
l = []
ansewered_question = set()
submit_for = {}

for i in range(M):
  a = input().split()
  l.append([int(a[0]), a[1]])
  ansewered_question.add(int(a[0]))
for submition in l:
    if submition[0] in submit_for:
        submit_for[submition[0]].append(submition[1])
    else:
        submit_for[submition[0]] = [submition[1]]
AC = 0
WA = 0
for i in ansewered_question:
    wa = 0
    for submit in submit_for[i]:
      if submit == "WA":
        wa += 1
      else:
          AC += 1
          WA += wa
          break
print(AC, WA)

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#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 ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    char b, c[128];
    c['A'] = 'T';
    c['T'] = 'A';
    c['C'] = 'G';
    c['G'] = 'C';
    cin >> b;
    cout << c[char(b)] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	i := 0
	for {
		if s[i] == 'A' {
			break
		}
		i++
	}
	j := len(s)
	for {
		if s[j-1] == 'Z' {
			break
		}
		j--
	}
	con.Println(j - i)
	return nil
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string s;
    cin>>s;
    s=s.substr(0,3);
    cout<<s;
}



Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	int N;
	string S;
	cin>>N;
	cin>>S;
	int ans=0;
	REP(i,S.size()-3+1){
		if(S.substr(i,3)=="ABC"){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int countt(int n) 
{ 
	long long count = 1; 
	long long rem = 7; 
	while (rem != 0) { 
		rem = (rem * 10 + 7) % n; 
		count++; 
	} 
	return count; 
} 
int main() 
{ 
	int n;
  	cin>>n;
  	if(n==1 || n==7){
    cout<<"1"<<endl;
    }
  	else if(n%2==0 || n%5==0){
      cout<<"-1"<<endl;
    }
	else{
      cout << countt(n);
    } 
} 


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    int cumulative_sum[N + 1];
    int cumulative_xor[N + 1];
    cumulative_sum[0] = 0;
    cumulative_xor[0] = 0;
    for(int i = 1; i <= N; i++){
        int num;
        cin >> num;
        cumulative_sum[i] = cumulative_sum[i - 1] + num;
        cumulative_xor[i] = (cumulative_xor[i - 1] ^ num);
    }
    long ans = 0;
    for(int i = 0; i < N; i++){
        int left = i + 1, right = N + 1; // [left, right)
        while(left + 1 < right){
            int middle = (left + right) / 2;
            if(cumulative_sum[middle] - cumulative_sum[i] == (cumulative_xor[middle] ^ cumulative_xor[i])){
                left = middle;
            }else{
                right = middle;
            }
        }
        ans += left - i;
    }
    cout << ans << endl;
}





Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <utility>
using namespace std;

int main() {
	long long N,M;
	cin >> N >> M;
	if(N<M){
		swap(N,M);
	}
	
	if(N-M>=2){
		cout << 0 << endl; 
		return 0;
	}
	
	
	long long ans=1;
	for(long long i=1; i<=N; i++){
		ans*=i;
		ans%=1000000007;
		
	}
	
	for(long long i=1; i<=M; i++){
		ans*=i;
		ans%=1000000007;
	}
	
	
	if(N==M){ans*=2; ans%=1000000007;}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val ans = readLongList()
        .sorted()
        .drop(n)
        .filterIndexed { i, v -> i % 2 == 0 }
        .sum()
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

//double x[0][0]=0.0;
//double y=100.0;

int Koch(double x1,double y1,double x3,double y3,int n){
    double x2=0,y2=0;
    double px=0,py=0,tx=0,ty=0;
    
    
    if(n==0){
        printf("%f %f\n",x3,y3);
        return 0;
    }else{
        
        px=((x3-x1)/3)+x1;
        py=((y3-y1)/3)+y1;
       // x2=px+(x3-x1)/6;
       // y2=px+sqrt(-(x2-px)*(x2-px)+px*px);
       x2 = (x1+x3)/2 -sqrt(3.0)*(y3-y1)/6;
       y2 = (y1+y3)/2 +sqrt(3.0)*(x3-x1)/6;
       // x2 = sqrt(3.0)*(-y3+y1)/2.0+(x3-x1)/2.0;
      //  y2 = sqrt(3.0)*(x3-x1)/2.0+(y3-y1)/2.0;
       // y2=(py-y1)+(y3-y1)/3;
        tx=((x1-x3)/3)+x3;
        ty=((y1-y3)/3)+y3;
        
        Koch(x1,y1,px,py,n-1);
        Koch(px,py,x2,y2,n-1);
        Koch(x2,y2,tx,ty,n-1);
        Koch(tx,ty,x3,y3,n-1);
        //Koch(size/3+size/3,n-1);
        
        
        
       // printf("%f %f\n",x1,y1);
      //  printf("%f %f\n",px,py);
      //  printf("%f %f\n",x2,y2);
       // printf("%f %f\n",tx,ty);
        
        
        
    }
    return 0;
}



int main(int argc , char *argv[]){
    
    int n;
    double x1=0,x3=100;
    double y1=0,y3=0;
    
    scanf("%d",&n);
    printf("%f %f\n",0.0,0.0);
    Koch(x1,y1,x3,y3,n);
    return 0;
 }

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

using pii=pair<int,int>;
vector<pii> ary;

const ll mod=1000000007LL;

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


	rep(i,n){
		int in;
		cin >> in;
		ary.emplace_back(pii(in,1));
	}

	rep(i,n){
		int in;
		cin >> in;
		ary.emplace_back(pii(in,-1));
	}

	sort(_all(ary));
	ll ans=1LL,cnt=0LL;
	
	for(auto &it:ary){
		if(abs(cnt)>abs(cnt+it.second)) ans*=abs(cnt),ans%=mod;
		cnt+=it.second;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2420
(let* ((n (read))
       (m (read))
       (lst (let* ((ll (loop :repeat m :collect (read))))
              (concatenate 'list ll (list (+ (car (last ll)) (car ll) (- n (car (last ll))))))))
       (lst-d (mapcar #'- (cdr lst) lst)))
  (princ (- n (reduce #'max lst-d))))

Measured memory_bytes: 69220
#include <stdio.h>
#include <algorithm>
long long ansy, ansx;
long long e, f;
long long b, w;
long long p = 1000 * 1000 * 1000 + 7;
long long beki[200005];
long long kai[200005];
long long rui(long long a, long long b) {
	if (b == 0)return 1;
	if (b == 1)return a % p;
	if (b == 2)return a * a%p;
	if (b % 2 == 1) {
		return (rui(rui(a, b / 2), 2))*a%p;
	}
	else return rui(rui(a, b / 2), 2) % p;
}
long long inv(long long a) {
	return rui(a, p - 2);
}
int main() {
	beki[0] = 1;
	for (int i = 1; i < 200005; i++)beki[i] = beki[i - 1] * 2 % p;
	kai[0] = 1;
	for (int i = 1; i < 200005; i++)kai[i] = i * kai[i - 1] % p;
	scanf("%lld%lld", &b, &w);
	for (long long i = 0; i < w + b; i++) {
		ansy = beki[i];
		if (i >= w) {
			e = e * 2 + kai[i - 1] * inv(kai[i - w] * kai[w - 1] % p);
			e %= p;
		}
		if (i >= b) {
			f = f * 2 + kai[i - 1] * inv(kai[i - b] * kai[b - 1] % p);
			f %= p;
		}
		ansy += e;
		ansy -= f;
		ansy += p;
		ansy %= p;
		ansx = beki[i + 1];
		printf("%lld\n", ansy*inv(ansx) % p);
	}
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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 = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;

    vector<char> c(100 * 98, '#');
    REP(i, a - 1) {
        c[i * 4] = '.';
    }
    FOR(i, 100 * 98 / 2, 100 * 98) {
        c[i] = '.';
    }
    REP(i, b - 1) {
        c[100 * 98 - 1 - i * 4] = '#';
    }

    cout << "100 98" << endl;

    REP(i, 100 * 98) {
        cout << c[i];
        if (i % 98 == 97) {
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
		cout<<"ACL";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int H, W; cin >> H >> W; 
	for(int i = 1; i <= H; i++){
		for(int j = 0; j < W; j++){
			string s; cin >> s; 
			if(s == "snuke"){
				cout << (char) ('A' + j) << i << endl; 
				return 0; 
			}
		}
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
flgs = [0] * N
penas = [0] * N
ac = 0
pena = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    s = (s=='AC')
    if flgs[p - 1]:
        continue
    elif s:
        ac += 1
        flgs[p - 1] = 1
        pena += penas[p-1]
    else:
        penas[p - 1] += 1

print(ac, pena)


Measured memory_bytes: 72612
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let n: u32 = iter.next().unwrap().parse().unwrap();
    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();
    
    let max = std::cmp::min(a, b);
    let min = (a + b).saturating_sub(n);
    
    println!("{} {}", max, min);
}

Measured memory_bytes: 4352
from collections import Counter
def check(n, k):
    if k > (n-1)*(n-2)//2 :
        return False
    return True

def solve():
    N, K = map(int, input().split())
    if not check(N, K):
        print(-1)
        return
    
    Ans = []
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            Ans.append((i, j))
    dim = [N-1]*(N+1)
    for _ in range(K):
        for i, j in Ans:
            if i != 1:
                Ans.remove((i, j))
                dim[i] -= 1
                dim[j] -= 1
                break
    
    print(len(Ans))
    for a in Ans:
        print(*a)
solve()

Measured memory_bytes: 42992
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  if(n>m)swap(n,m);
  if(n==m&&m==1)cout<<1<<endl;
  else if(n==1)cout<<m-2<<endl;
  else {
    int ans=m*n;
    ans-=4;
    ans-=(m-2)*2;
    ans-=(n-2)*2;
    cout<<ans<<endl;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    if( s == "Y")
    {cout << "Four" << endl;
     break;
    }
    if( i == N-1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = [int(i) for i in readline().strip()[::-1]]

    a = {}
    a[0] = 1
    t = 0
    x = 1
    for s in S:
        t += s * x
        t %= 2019
        
        if t in a:
            a[t] += 1
        else:
            a[t] = 1

        x *= 10
        x %= 2019
    
    ans = 0
    for v in a.values():
        ans += v * (v-1) // 2
    
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 10916
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int m,k,a[500000],i,s=0;
    cin>>m>>k;
    for(i=0;i<m;i++)cin>>a[i];
    sort(a,a+m);
    for(i=0;i<k;i++)s+=a[i];
    cout<<s;
}


Measured memory_bytes: 3644
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int h = scanner.nextInt();
		int n = scanner.nextInt();
		int w_l = 0;
		int w_r = w;
		int h_l = 0;
		int h_h = h;
		for(int i = 0; i < n; i++){
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			int a = scanner.nextInt();
			if(a == 1){
				w_l = Math.max(x, w_l);
			}else if (a == 2) {
				w_r = Math.min(x, w_r);
			}else if (a == 3) {
				h_l = Math.max(y, h_l);
			}else {
				h_h = Math.min(y, h_h);
			}
		}
		if(w_l >= w_r || h_l >= h_h){
			System.out.println(0);
		}else {
			System.out.println((w_r-w_l) * (h_h-h_l));
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)
#define forl(n) for (ll i = 0 ; i < n ; i++)

int main() {
    ios::sync_with_stdio(false);
 	int n, x = 0;
 	cin >> n;
 	string s = to_string(n);
 	for1(s.length()) x += s[i] - '0';
 	if (n % x) cout << "No";
 	else cout << "Yes";
}

Measured memory_bytes: 3652
use whiteread::parse_line;

fn main() {
    let (n, a, b): (u64, u64, u64) = parse_line().unwrap();
    let ans: u64;
    match n % (a + b) {
        x if x <= a => ans = (n / (a + b)) * a + x,
        _ => ans = (n / (a + b)) * a + a,
    }
    println!("{}", ans);
}


Measured memory_bytes: 2188
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = set(map(int, input().split()))
    d = 0
    while True:
    	if x-d not in p:
    		print(x-d)
    		break
    	if d+x not in p:
    		print(d+x)
    		break
    	d+=1

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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

const int D = 60;
const int max_n = 200005;

ll cal(ll a, ll b, ll k){
    ll n = (k-(a-1))/2;
    if(b-a-2ll>0){
        return (b-a-2ll) * n + k + 1ll;
    }else{
        return k + 1ll;
    }
}


int main() {
    ll k, a, b; cin >> k >> a >> b;
    ll ans = cal(a, b, k);
    cout << ans << endl;
}




Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a+b, min(b+c, a+c)) << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  char a = S.at(0), b = S.at(1), c = S.at(2), d = S.at(3);
  
  if ((a == b && c == d && a != c) || (a == c && b == d && a != b) || (a == d && b == c && a != b)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int A, B, C;
	cin >> A >> B >> C;

	if (A + B >= C) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int m,n;
bool isP[10000000];
int main(){
    while(cin>>m>>n,m!=0){
        for(int i=0;i<10000000;i++){
            isP[i]=true;
        }
        int count=0;
        int now=m;
        int ans=0;
        while(count<=n){
            if(isP[now]){
                ans=now;
                count++;
                for(int i=now;i<10000000;i+=now){
                    isP[i]=false;
                }
            }
            now++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 12852
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial



def main():
    high, widdth = map(int, input().split())
    for i in range(high * 2):
        if i % 2 == 0:
            aaa = input()
        print(aaa)







if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
h,w = map(int,input().split())
s =["."*(w+2)]+["."+input()+"." for i in range(h)]+["."*(w+2)]

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] !="#":
            a=s[i][j-1]+s[i][j+1]+s[i-1][j-1:j+2]+s[i+1][j-1:j+2]
            s[i]=s[i][:j]+str(a.count("#"))+s[i][j+1:]

[print(s[i][1:w+1]) for i in range(1,h+1)]


Measured memory_bytes: 68968
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int const N = 2e5+9;
int arr[N];
ll mn = 1e18;
int n;
ll get(ll x){
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += abs(arr[i] - x - i);
    }
    return ans;
}
int main(){
    cin>>n;
    for(int i = 1;i<=n;i++)
        cin>>arr[i];
    ll lo = -1e12 , hi =1e12;
    while(lo < hi){
        ll mid = lo +(hi - lo +1)/2;
        if(get(mid) < get(mid-1)){
            lo = mid;
        }else{
            hi = mid-1;
        }
    }
    cout<<get(lo);
    return 0;
}

Measured memory_bytes: 1024
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ll n; cin>>n;
    ll arr[n+3];
    map<ll,ll> mp;
    for(int i=1;i<=n;i++) {cin>>arr[i]; mp[arr[i]]++; }
    ll ans=0;
    for(auto i: mp) {
        ll val=(i.second*(i.second-1))/2;
        ans+=val;
    }
    for(int i=1;i<=n;i++){
        ll prev=mp[arr[i]];
        ll val=(mp[arr[i]]*(mp[arr[i]]-1)) /2;
        ll fin=ans-val;
        ll x= mp[arr[i]]; x--;
        ll fck=(x*(x-1))/2;
        fin+=fck;
        cout<<fin<<endl;
    }
    
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
  int n;
  cin>>n;
  vi a(n);
  map<ll,int>mp;
  rep(i,n)cin>>a[i];
  ll sum=0;
  ll ans=0;
  rep(i,n){
      mp[sum]++;
      sum+=a[i];
      ans+=mp[sum];
  }
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13568
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
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); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b, c;

int main(){
    cin >> a >> b >> c;
    if((a <= c && c <= b) || (a >= c && c >= b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int N, T, A, ans = 0;
double H[1000], d;
int main() {
  cin >> N >> T >> A;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (int i = 0; i < N; i++) {
    H[i] = T - H[i] * 0.006;
  }
  d = abs((double)A - H[0]);
  for (int i = 0; i < N; i++) {
    if (d > abs((double)A - H[i])) {
      ans = i;
      d = abs((double)A - H[i]);
    }
  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}



vector<int> step(2010, 0);

void bfs(int st,  vector<vector<int>>& line){

    queue<int> q;
    q.push(st);
    while(!q.empty()){
        int now = q.front();
        for (auto next: line[now])
        {
            if (step[next] != 0) continue;
            q.push(next);
            step[next] = step[now] + 1;
        }
        q.pop();
    }

}


int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> k(n);
    vector<vector<int>> line(n);
    rep(i, n-1){ 
        line[i].push_back(i+1);
        line[i+1].push_back(i);
    }
    line[x-1].push_back(y-1);
    line[y-1].push_back(x-1);

    rep(i, n){
        step = vector<int>(n, 0);
        bfs(i, line);
        for (int j = i+1; j < n; j++)
        {
            k[step[j]]++;
        }
    }

    rep(i, n-1){
        cout << k[i+1] << endl;
    }
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d" ,&a,&b,&c);
	if(a<b && b<c){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	};
	return 0;
}

Measured memory_bytes: 580
using System;
class aizu{
    public static int Main(){
        int i;
        double[] n = new double[100];
        string[] str = new string[100];
        str = Console.ReadLine().Split(' ');
        for(i=0;i<1;i++)
            n[i] = double.Parse(str[i]);
        Console.WriteLine("{0:f8} {1:f8}",n[0]*n[0]*Math.PI,2*n[0]*Math.PI);
        return 0;
    }
}

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

using namespace std;

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

  int w, h, n;
  cin >> w >> h >> n;
  pair<int, int> ll, ur;
  ll = {0, 0};
  ur = {w, h};
  int x, y, a;
  vector<vector<int>> img(h, vector<int>(w,0));
  for (int k = 0; k < n; ++k) { 
    cin >> x >> y >> a;
    if (a == 1) {
      for (int j = 0; j < x; ++j) 
        for (int i = 0; i < h; ++i) 
          img[i][j] = 1;
    } else if (a == 2) {
      for (int j = x; j < w; ++j) 
        for (int i = 0; i < h; ++i) 
          img[i][j] = 1;
    } else if (a == 3) {
      for (int i = 0; i < y; ++i) 
        for (int j = 0; j < w; ++j) 
          img[i][j] = 1;
    } else {
      for (int i = y; i < h; ++i) 
        for (int j = 0; j < w; ++j) 
          img[i][j] = 1;
    }
  }
  int res = 0;
  for (int i = 0; i < h; ++i) 
    for (int j = 0; j < w; ++j) 
      if (img[i][j] == 0) res++;

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
    int K;
    cin >> K;

    int m = 7;
    for (int i = 1; i <= 10000000; i++)
    {
        m %= K;
        if (m == 0)
        {
            cout << i << endl;
            return 0;
        }
        m = m * 10 + 7;
    }

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

 

Measured memory_bytes: 3164
from collections import deque

def dfs(q, keta):
    global K
    
    if len(q)==keta:
        K -= 1
        
        if K==0:
            q = list(map(str, q))
            print(''.join(q))
            exit()
        
        return
    
    for nex in range(max(0, q[-1]-1), min(9, q[-1]+1)+1):
        q.append(nex)
        dfs(q, keta)
        q.pop()

K = int(input())

for i in range(1, 100):
    for j in range(1, 10):
        q = deque([j])
        dfs(q, i)

Measured memory_bytes: 53084
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	long long a[2], k;
	cin >> a[0] >> a[1] >> k;

	rep(i,k){
		if(a[i % 2] % 2) a[i % 2]--;
		a[i % 2] /= 2;
		a[(i + 1) % 2] += a[i % 2];
	}
	cout << a[0] << ' ' << a[1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	vector<int> x(m);

	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	sort(x.begin(), x.end(), [](const int& a, const int& b) {return a < b;});
	vector<int>l(m-1);
	for (int i = 0; i < m - 1; i++) {
		l[i] = x[i+1] - x[i];
	}
	sort(l.begin(), l.end(), [](const int& a, const int& b) {return a > b;});

	int ans = x[m-1] - x[0];
	for (int i = 0; i < n - 1; i++) {
		ans -= l[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
s = str(input())#2bit全検索
ans = 0
n = len(s)-1
for i in range(1<<n):#0-2**(len(s)-1)まで
    tmp = int(s[0])
    for j in range(n):
        if i & (1<<j):
            ans += tmp
            tmp = int(s[j+1])
        else:
            tmp = 10*(tmp)+int(s[j+1])
    ans += tmp
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    if (s == 'AAA' or s == 'BBB'):
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  string s;
  cin >> s;
  int b, e;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' && flag) {
      flag = false;
      b = i;
    }
    if (s[i] == 'Z') {
      e = i;
    }
  }
  D(e - b + 1);
  return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
int h[N];
vector<int> g[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	for(int i = 1; i <= n; i++){
		cin>>h[i];
	}
	for(int i = 0; i < m; i++){
		int a, b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int mx = 0;
		for(auto u : g[i]){
			mx = max(mx, h[u]);
		}
		if(h[i] > mx)ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 9172
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 1000000000
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=1e5+10;
const double eps=1e-6;

int a,b,c,d;

int main(){
    #ifdef ONLINE_JUDGE
    #else

    //freopen("output.txt","w",stdout);
    #endif

    cin>>a>>b>>c>>d;
    int ans=a+d;
    ans=min(ans,a+c);
    ans=min(ans,b+c);
    ans=min(ans,b+d);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cstdio>
#include<cmath>
#include<set>
#include<deque>
#include<map>
#include<string>
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int maxn=1e6+10;
const int seed=131;
const int N=1e5+10;
const int M=2e5+10;
const int mod=1e9+7;
const double eps=1e-6;

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}

int qpow(ll a,ll b){
    ll ret=1;
    while(b){
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return (int) ret;
}


int inv[N];
int a[N];

int main(){
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;

    int n;
    cin>>n;
    for(int i=1;i<=n;i++) inv[i]=qpow(i,mod-2);
    for(int i=1;i<=n;i++) inv[i]=(inv[i]+inv[i-1])%mod;
    ll ans=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        ans=(ans+1ll*a[i]*inv[n-i+1]%mod)%mod;
        ans=(ans+1ll*a[i]*((inv[i]-inv[1]+mod)%mod)%mod)%mod;
    }
    for(int i=1;i<=n;i++) ans=ans*i%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4552
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

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

  sort(d, d + N);

  if (d[N/2] == d[N/2 - 1]) {
    cout << 0 << endl;
  } else {
    cout << d[N/2] -  d[N/2 - 1]<< endl;
  }

  return 0;
}

Measured memory_bytes: 640
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];

	long su(ulong n) {
		return n * (n + 1) / 2;
	}

	long res;
	const long MOD = 1000000007;
	foreach(k; K..N+1) {
		debug writefln("k: %d", k);
		auto m = su(N) - su(N-k) - su(k-1);
		debug writefln("m: %d", m);
		res += m+1;
		res %= MOD;
	}
	(res+1).writeln;
}


// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#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 INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
2 3 1
1 1
1 2
2 2
1 2
)");
#define cin input
#endif

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

	int kyu[500][500] = {};

	REP(i,m)
	{
		int l, r;
		cin >> l >> r;
		l--, r--;
		kyu[l][r]++;
	}

	REP(i,n)
	{
		FOR(j,1,n)
		{
			kyu[i][j] += kyu[i][j-1];
		}
	}

	REP(i,q)
	{
		int p,q;
		cin >> p >> q;
		p--, q--;
		int sum = 0;
		FOR(j,p,q+1)
		{
			sum += kyu[j][q];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1920