akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


ll check(ll n, ll b) {
  ll s = 0;
  if (b <= 1) {
    return -1;
  }
  while (n > 0) {
    s += n % b;
    n /= b;
  }
  return s;
}

int main(void){
  ll n, s;
  cin >> n >> s;
  if (n < s) {
    cout << -1 << endl;
    return 0;
  }
  if (n == s) {
    cout << n + 1 << endl;
    return 0;
  }
  VL div;
  REP(b, 1, 400000) {
    if ((n - s) % b == 0) {
      div.push_back(b);
      div.push_back((n - s) / b);
    }
  }
  sort(div.begin(), div.end());
  REP(i, 0, div.size()) {
    if (s == check(n, div[i] + 1)) {
      cout << div[i] + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int32 n;
    cin >> n;
    int32 v[n], c[n];
    REP(i,n)cin >> v[i];
    REP(i,n)cin >> c[i];
    int32 ans = 0;
    REP(i,n){
        ans += max((int32)0, v[i] - c[i]);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, a[128][128];

int main(){
  scanf("%d", &N);
  rep(i, N) rep(j, N) scanf("%d", &a[i+1][j+1]);

  REP(i, 1, N+1) REP(j, 1, N+1) a[i][j] = a[i][j] - a[i-1][j-1] + a[i][j-1] + a[i-1][j];

  /*  rep(i, N+1){
    rep(j, N+1) printf("%d ", a[i][j]); puts("");
    }*/

  int res = -10000000;
  for(int x = 1; x <= N; x++){
    for(int y = 1; y <= N; y++){
      for(int i = 0; i < y; i++){
	for(int j = 0; j < x; j++){
	  res = max(res, a[y][x] - a[y][j] - a[i][x] + a[i][j]);
	}
      }
    }
  }

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

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

template<typename T> vector<T> divisor(T n){
    vector<T> res;
    for (long long i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i * i != n) { res.emplace_back(n/i); }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long n;
    cin >> n;
    vector<long> d = divisor(n);
    
    long ans = 0;
    for (const long &e : d) {
        if (e == 1) continue;
        const long p = n / (e - 1);
        const long q = n % (e - 1);
        if (p == q) ans += e - 1;
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W,K;
string S[10];

LL ans = INF;

void solve(){
	for(int bit=0;bit<(1<<(H-1));bit++){
		vector<int> H_map(H,0);
		int counter = 0;
		for(int i=1;i<H;i++){
			if(((bit>>i)&1) != ((bit>>(i-1))&1)) counter++;
			H_map[i] = counter;
		}

		int divition_vertical = 0;
		counter++;
		vector<int> numof_white(counter,0);
		for(int w=0;w<W;w++){
			for(int h=0;h<H;h++){
				numof_white[H_map[h]] += (S[h][w]=='1');
			}
			for(int h_map=0;h_map<counter;h_map++){
				if(numof_white[h_map]>K){
					divition_vertical++;
					for(int i=0;i<counter;i++) numof_white[i] = 0;
					for(int h=0;h<H;h++){
						numof_white[H_map[h]] += (S[h][w]=='1');
					}
				}
			}
			for(int h=0;h<H;h++){
				if(numof_white[H_map[h]]>K) divition_vertical = INF_INT;
			}
			if(divition_vertical==INF_INT) break;
		}
		ans = min(ans,(LL)(counter-1+divition_vertical));
	}
}

int main(){
    cin >> H >> W >> K;
    for(int i=0;i<H;i++) cin >> S[i];

    solve();

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a_dict = {}

for i in a:
    if not i in a_dict:
        a_dict[i] = 0
    a_dict[i] += 1

q = int(input())

s = sum(a)


for i in range(q):
    b, c = map(int, input().split())
    if not c in a_dict:
        a_dict[c] = 0
    s -= c * a_dict[c]

    if b in a_dict:
        s -= b * a_dict[b]
        a_dict[c] += a_dict[b]
    s += c * a_dict[c]

    a_dict[b] = 0

    print(s)

Measured memory_bytes: 88568
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, tx, ty, x[1010], y[1010], p = -1;
vector<int> d;
string di = "LDUR";

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> tx >> ty;
		int t = (abs(tx) + abs(ty)) %2;
		if (p==-1) p = t;
		else if (p!=t) return cout << -1 << endl, 0;
		x[i] = tx+ty, y[i] = tx-ty;
	}
	for(int i=30; i>=0; i--) d.push_back(1<<i);
	if (p==0) d.push_back(1);
	cout << d.size() << endl;
	rep(i,d.size()) cout << d[i] << (i==d.size()-1 ? '\n' : ' ');
	rep(i,n) {
		string ans;
		tx = 0, ty = 0;
		each(j,d) {
			bool xd, yd;
			if (tx<x[i]) tx += j, xd = 1;
			else tx -= j, xd = 0;
			if (ty<y[i]) ty += j, yd = 1;
			else ty -= j, yd = 0;
			ans.push_back(di[xd*2+yd]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
double X[100000],R[100000];

bool is_OK(double dist){

	for(int i = 0; i < N; i++){
		if(R[i] < dist)return false;
	}

	double most_left_right = 99999999.0,most_right_left=-99999999.0,diff;

	for(int i = 0; i < N; i++){
		diff = sqrt(R[i]*R[i]-dist*dist);

		most_left_right = min(most_left_right,X[i]+diff);
		most_right_left = max(most_right_left,X[i]-diff);
	}
	return most_right_left < most_left_right;
}


int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&X[i],&R[i]);
	}

	double left = 0,right = 1000000.1,m = (left+right)/2;

	for(int i = 0; i < 50; i++){

		if(is_OK(m)){
			left = m+EPS;
		}else{
			right = m-EPS;
		}
		m = (left+right)/2.0;
	}

	printf("%.10lf\n",m);

	return 0;
}

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

class UnionFind {
  vector<int> parent;

public:
  UnionFind(int n) : parent(n, -1) {}

  int root(int n) {
    return parent.at(n) < 0 ? n : parent.at(n) = root(parent.at(n));
  }

  int size(int n) {
    return -1 * parent.at(root(n));
  }

  bool same(int a, int b) {
    return root(a) == root(b);
  }

  void unite(int a, int b) {
    if (!same(a, b)) {
      if (size(a) < size(b)) swap(a, b);
      int ra = root(a);
      int rb = root(b);
      parent.at(ra) += parent.at(rb);
      parent.at(rb) = ra;
    }
  }
};

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

  UnionFind uf(n);

  for (int i = 0; i < q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      uf.unite(u, v);
    } else {
      cout << (uf.same(u, v) ? 1 : 0) << endl;
    }
  }
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int X;
  cin >> X;
  if(X == 3 || X == 5 || X == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
#define MAX_N 100010

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

const long long INF = 1LL << 60;

// Input
int N, K;
long long h[MAX_N];

long long dp[MAX_N];

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

    // Initialization
    for (int i = 0; i < MAX_N; i++) dp[i] = INF;

    // Initial state
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }

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

Measured memory_bytes: 1792
package main

import(
	"fmt"
)

func main() {
	var n int
  	fmt.Scan(&n)
  	
  	heights := make([]int,n)
  	
  	for i := 0; i < n; i++ {
  		fmt.Scan(&heights[i])
  	}
  	
  	hotelCnt := 1;
  	for tag := 1; tag < n; tag++ {
      	cnt := 0
  		for j := 0; j < tag; j++ {
  			if heights[tag] < heights[j] {
  				break
  			} else {
              	cnt++		
  			}
  		}
  		if tag == cnt {
	  		hotelCnt++
	  	}
  	}
  	fmt.Println(hotelCnt)
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		//1??????????????????????????§????????????????????????
		String line = sc.nextLine();
		String[] sentence = line.split(" ");

		int strCount = 0; //??????????????????????????°????´???¨
		String strFrequent = ""; //????????????????????????????´???¨
		String strLonger = ""; //??????????????????????´???¨
		int number = 0; //???????????????????´???¨

		HashMap<String, Integer> termMap =
				new HashMap<String, Integer>();

		for(int $ = 0; $ < sentence.length; $++) {
			//????????????????????????????????????
			int num = 1;
			if(termMap.containsKey(sentence[$])) {
				num += termMap.get(sentence[$]);
			}
			termMap.put(sentence[$], num);

			//?????£??¨???????????????
			if(number < sentence[$].length()) {
				number = sentence[$].length();
				strLonger = sentence[$];
			}
		}

		List<Map.Entry<String, Integer>> entries
		= new ArrayList<Map.Entry<String, Integer>>(termMap.entrySet());

		//???????????\??????????????????????????????????????????
		Collections.sort(entries
				, new Comparator<Map.Entry<String, Integer>>() {

			@Override
			public int compare(
            		Entry<String, Integer> entry1
            		, Entry<String, Integer> entry2) {
                // 4. ??????
                return entry2.getValue().compareTo(entry1.getValue());
            }
        });

		System.out.println(entries.get(0).getKey() + " " + strLonger);
	}


}

Measured memory_bytes: 25580
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

	ll n = x / 11;
	if (x % 11 == 0) cout << n * 2 << endl;
	else if (x % 11 <= 6) cout << n * 2 + 1 << endl;
	else cout << n * 2 + 2 << endl;

	return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> b(n);
    vector<ll> c(n);
    rep(i,n) b[i]=a[i]+i+1;
    rep(i,n) c[i]=a[i]-i-1;
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        ll now=b[i];
        now=now*(-1);
        ll cnt=upper_bound(c.begin(),c.end(),now)-lower_bound(c.begin(),c.end(),now);
        ans+=cnt;
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}











Measured memory_bytes: 7988
N = int(input())


def sb(n):
    if n == 1:
        return {1: 0}
    else:
        dic = {}
        tmp = n
        for i in range(2, int(n ** 0.5) + 1):
            if tmp % i == 0:
                dic[i] = 0
                while tmp % i == 0:
                    dic[i] += 1
                    tmp //= i

        if tmp != 1:
            dic[tmp] = 1

        if dic == {}:
            dic[n] = 1

        return dic


ans = 0

for key in sb(N):
    v = sb(N)[key]
    dv = 1
    while v - dv >= 0:
        v -= dv
        dv += 1
        ans += 1

print(ans)


Measured memory_bytes: 9472
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())

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

n = getN() #22

dig_num = math.floor(math.log2(n + 1))  # 5
# print(dig_num)
sen_end = 2 ** (dig_num) - 1  # 15

if 2 ** (dig_num) == n or n == 1:
    print("No")
    sys.exit(0)
else:
    print("Yes")

for i in range(sen_end - 1):
    print(i+1, i+2)  # 1-2, 2-3, ..., 14-15
    print(i+1+n, i+2+n)  # 23-24, 24-25, ..., 36-37

print(n + 1, sen_end)

uni_end = n
if n % 2 == 0:
    uni_end -= 1  # 21

for i in range((uni_end - sen_end) // 2):  # 3 times
    print(1, sen_end + i * 2 + 1)  # 1-16
    print(1, sen_end + i * 2 + 2 + n)  # 1-39
    print(sen_end + i * 2 + 1 + n, sen_end + i * 2 + 2 + n)  # 38-39
    print(sen_end + i * 2 + 1, sen_end + i * 2 + 2)  # 16-17

if n % 2 == 0:
    one_count = 0
    for idx, digit in enumerate(bin(n)[2:]):
        # print(digit, one_count)
        if one_count == 0:
            # print(digit)
            if digit == "1":
                one_count += 1
        else:
            if digit == "1":
                one_goal = dig_num - idx  # second "1" from upper digit
                break

    if one_goal != 1:
        print(n, 2**one_goal)
        print(2*n, n - 2**one_goal)

    else:
        print(n, 2 ** one_goal)
        print(2 * n, 2 * n - 2 ** one_goal + 1)

Measured memory_bytes: 5764
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#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 ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    int N;

    cin >> N;

    vi X(N);

    REP(i,N){
        cin >> X[i];
    }

    int mi = INF;

    REP(i,100){

        int sum = 0;

        REP(j,N){
            sum += (X[j]-(i+1))*(X[j]-(i+1));
        }

        if(mi > sum){
            mi = sum;
        }
    }

    cout << mi << endl;

    return 0;
}

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

int main(){
	long long n;
	while(cin >> n && n){
		char s[100] = {};
		char table[] = "01235789";
		sprintf(s,"%o",n);
		int i = 0;
		while(s[i]){
			putchar(table[s[i]-'0']);
			i++;
		}
		
		putchar('\n');
	}
}

Measured memory_bytes: 876
/// Comentary AC
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){ 
    int w,h,n,a_i,x_i,y_i;
    cin >> w >> h >> n;
    vector<int> vec(4);
    vec[0]=vec[1]=0;
    vec[2]=w;
    vec[3]=h;
    for (int i=0;i<n;i++){
        cin >> x_i >> y_i >> a_i;
        if (a_i==1) vec[0] = max(x_i,vec[0]);
        else if (a_i==2) vec[2] = min(x_i,vec[2]);
        else if (a_i==3) vec[1] = max(y_i,vec[1]);
        else vec[3]= min(y_i,vec[3]);  
        
    }
    
    cout << max(0,(vec[2]-vec[0]))*max(0,(vec[3]-vec[1]))<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b) {
  if(b==0) return a;
  return gcd(b,a%b);
 }
ll lcm(ll a,ll b) {
  return (a/gcd(a,b))*b;
}
int main(){
  ll n,m;
  cin >>n >>m;
  string s,t;
  cin >>s>>t;
  ll k=lcm(n,m);
  if(n<m){
    string l=s;
    s=t;
    t=l;
    swap(n,m);
  }
  ll nn=k/n; ll mm=k/m; ll p=0;
  for(ll i=0;i<m;i++){
    if((i*mm)%nn==0){
      ll c=(i*mm)/nn;
    if(s[c]!=t[i]){
       cout <<-1<<endl;
       return 0;
    }
   }
  }
  cout <<k<<endl;
  return 0;
  }


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;   
    vector<int> v;

    for(int i = 3; i <= 55555; i++){
        bool pri = true;
        for(int j = 2; j * j <= i; j++){
            if(i % j == 0) pri = false;
        }
        if(pri && i % 5 == 1) v.push_back(i);
    }
    rep(i,n) cout << v[i] << ' ';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 10000000005
#define NIL -1
int main(){
    int n; cin >> n;
    ll x; cin >> x;
    ll a[n];
    ll cnt = 0;
    ll sum = 0;
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);

    for(ll i = 0; i < n; i++){
        if(a[i] <= x){
            if(i == n-1 && a[i] < x){
            }
            else {
                cnt++;
                x -= a[i];
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b, c, d, sum;
  int x;
  while(scanf("%d", &sum) != EOF)
    {
      x = 0;
      for(a = 0; a < 10; a++)
	for(b = 0; b < 10; b++)
	  for(c = 0; c < 10; c++)
	    for(d = 0; d < 10; d++)
	      if(a + b + c + d == sum)
		x++;		
      
      printf("%d\n", x);
    }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(void){
    long double d, e, f, b;
    int a;
    long c=0,Z=0;
    cin >> a;
    long double A[a], X[a], Y[a];
    for(int i=0; i<a; i++){
        cin>>b;
        X[i]=b;
    }
    for(int i=0; i<a; i++){
        cin>>b;
        Y[i]=b;
    }
    for(int i=0; i<a; i++){
        c+=fabs(X[i]-Y[i]);
    }
    cout << setprecision(16) << c <<endl;
    c=0;
    for(int i=0; i<a; i++){
        c+=pow(fabs(X[i]-Y[i]),2);
    }
    cout << setprecision(16) <<sqrt(c)<<endl;
    c=0;
    for(int i=0; i<a; i++){
        c+=pow(fabs(X[i] - Y[i]),3);
    }
    cout << setprecision(16) << pow(c,0.33333333333333333333333) <<endl;
    c=0;
    for(int i=0; i<a; i++){
        if(fabs(X[i]-Y[i])>Z){
            Z=fabs(X[i]-Y[i]);
        }
    }
    cout << setprecision(16) << Z <<endl;
    return 0;
}


Measured memory_bytes: 3480
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    ArrayList<Integer> ar = new ArrayList<Integer>();
    for(int i=0; i<N; i++) {
      ar.add(i+1);
    }
    int K = scan.nextInt();
    for(int i=0; i<K; i++) {
      int d = scan.nextInt();
      for(int j=0; j<d; j++) {
        int A = scan.nextInt();
        ar.remove(new Integer(A));
      }
    }
    scan.close();

    System.out.println(ar.size());
  }
}

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

const long long MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<long long, long long>> v;
    for(int i = 0; i < n; i++){
        long long x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    sort(v.rbegin(), v.rend());
    map<pair<long long, long long>, int> cnt;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            pair<long long, long long> p;
            p.first = v[i].first - v[j].first;
            p.second = v[i].second - v[j].second;
            cnt[p]++;
        }
    }
    int ans = 0;
    for(auto p : cnt){
        ans = max(ans, p.second);
    }
    ans = n - ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
X, Y= input().split()
IX = int(X)
IY = int(Y)
C = 2
T = 4
i = 0

while i <= IX:
    

    
    if ((C*i) + (T*(IX-i))) == IY:
        print('Yes')
        break
    elif i == IX:
        print('No')
        break
    else:
        i = i + 1

Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
using namespace std;
int a[200001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
	if(a[i]==a[i+1])
	{
		cout<<"NO\n";
		return 0;
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <istream>
#include <sstream>
using namespace std;

int main()
{
	int N;
	int i;
	double a;
	string b;
	double goukei=0;
	

	cin >> N;

	for (i = 0; i < N; i++) 
	{
		cin >> a;
		cin >> b;
		if(b=="JPY")
		{
			goukei = goukei + a;
		}
		else if(b == "BTC")
		{
			goukei = goukei + a*380000;
		}
		
	}

	cout << goukei << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N, M, C;
	cin >> N >> M >> C;

	int B[M];
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}

	int ans = 0;
	for(int i = 0; i < N; i++){
		int x = 0;
		for(int j = 0; j < M; j++){
			int a;
			cin >> a;
			x += B[j] * a;
		}
		if( x + C > 0 ) ans++;
	}

	cout << ans << endl;

	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;
typedef pair<int, int> pii;

int N;
lint C[110][110];

int main() {
	cin >> N;
	for_(i,0,N) for_(j,0,N) cin >> C[i][j];
	lint ans = 0;
	for_(i,0,N) for_(j,i + 1,N) {
		ans += min(C[i][j], C[j][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int total = 2;
        while (n >= total) {
            total *= 2;
        }

        System.out.print(total / 2);
    }
}


Measured memory_bytes: 22608
#include <iostream>
#include <cmath>
using namespace std;
long long mod = 1000000007;
long long power(long long m, long long n){
    if(n==0)
        return 1;
    long long temp;
    if(n%2 == 0){
		temp = power(m*m%mod, n/2)%mod;
        return temp;
    }else{
        return power(m*m%mod, n/2)*m%mod;  
    }
}
 
int main() {
    long long m,n;
    cin >> m >> n;
    cout << power(m,n)%mod << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod=1e9+7;
const int N=1e6+4;

bool si[N];
 
int minp[N],div_cnt[N];
 
void sieve()
{
    for(int i=2;i*i<N;i++)
    if(si[i]==0)
    {
        for(int j=i*i;j<N;j+=i)
        si[j]=1;
    }
 
    int pri[N];
 
    int pc=0;
 
    for(int i=2;i<N;i++)
    if(si[i]==0)
    pri[pc++]=i;
 
    minp[1]=1;
 
    for(int i=2;i<N;i++)
    minp[i]=i;
 
    for(int i=2;i*i<N;i++)
    if(minp[i]==i)
    {
        for(int j=i*i;j<N;j+=i)
        if(minp[j]==j)
        minp[j]=i;
    }
 
    //div_cnt[i] stores the count of the no. of factors of i
    div_cnt[1]=1;
 
    for(int i=2;i<N;i++)
    {
    	int temp=i; div_cnt[i]=1;
 
    	while(temp>1)
    	{
    		int cur_fac=minp[temp],cnt=0;
 
    		while(temp%cur_fac==0)
    		temp/=cur_fac,cnt++;
 
    		div_cnt[i]*=(cnt+1);
    	}
    }
}
 
int main()                  
{
	int n; scn(n);

	int flag1=1,flag2=0;

	sieve();

	set<int> st;

	rep(i,1,n+1)
	{
		int val; scn(val);

		flag2=gcd(flag2,val);

		while(val>1)
		{
			int cur = minp[val];

			if(st.find(cur)!=st.end())
			flag1=0;
			else
			st.insert(cur);

			while(val%cur==0)
			val/=cur;
		}
	}

	if(flag1)
	cout<<"pairwise coprime";
	else if(flag2==1)
	cout<<"setwise coprime";
	else
	cout<<"not coprime";

    return 0;
}

Measured memory_bytes: 16152
# 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); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
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)
# pragma warning(disable:4996)

int main() {
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
}

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

int main() {
  
  int N , K , x ;
  cin >> N >> K >> x ;
  
  vector<int> vec = {N*K,x};
  int min = 1000000 ; 
  for ( int x : vec) {
   if ( x <= min ) min = x ; 
  }
  cout << min << endl ;
 }




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(void){
	int X;
	cin >> X;
	int ans = 1;
	for(int i = 2; i < sqrt(X)+ 1; i++){
		for(int j = 2; j < sqrt(X) + 1; j++){
			int C = pow(i, j);
			if(C <= X && C > ans)ans = C;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector< vector<long long> > A(N, vector<long long>(N));
  for(int i = 0; i < N; ++i)
    for(int j = 0; j < N; ++j)
      cin >> A[i][j];
  vector<long long> dp(1<<N,0);
  for(int i = 1; i < (1<<N); ++i){
    for(int j = 0; j < N; ++j){
      for(int k = j+1; k < N; ++k){
        if((i>>j)&1 and (i>>k)&1) dp[i] += A[j][k];
      }
    }
    for(int j = i; j > 0; j = (j-1)&i){
      dp[i] = max(dp[i],dp[j]+dp[i-j]);
    }
  }
  cout << dp.back() << endl;
}


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

using namespace std;

int main()
{	
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int maxNum = x <= y ? y : x;
	int ans = INT_MAX;
	for (int i = 0; i <= maxNum; i++)
	{
		ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 5
char s[MAXN];
int ans=0;
int main()
{
	scanf("%s",s);
	for(int i=0;i<MAXN-1;i++)
	{
		if(s[i]=='+') ans++;
		else if(s[i]=='-') ans--;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}


int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(n+1, vector<ll>(2, 0));
    // reverse(all(s));
    // assert(s[0] == '1');
    dp[0][1] = 2;   // [0, 1], [1, 0]
    dp[0][0] = 1;   // [0, 0]
    // dumpVL(s);
    REP(i, 1, n) {
        if(s[i] == '0') {
            // x[i] = 0 -> (a, b) = (0, 0)
            dp[i][1] = dp[i-1][1] % MOD;
            dp[i][0] = dp[i-1][0] *3 % MOD;
            // LINE;
        }
        else {
            // x[i] = 1 -> (a, b) = (0, 1), (1, 0)
            dp[i][1] = dp[i-1][1] *2 % MOD;
            dp[i][0] = dp[i-1][1] % MOD;
            (dp[i][0] += dp[i-1][0]*3) %= MOD;
        }
    }
    cout <<(dp[n-1][0] + dp[n-1][1]) % MOD << endl;
    
    // rep(i, n) {
    //     cout << dp[i][0] << " " << dp[i][1] << endl;
    // }
    return 0;
}

Measured memory_bytes: 5760
#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 _all(arg) begin(arg),end(arg)

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 namespace std;
using vi=vector<int>;
using vii=vector<vi>;

map<vii, int> memo;

bool check(vii m) {
	rep(i, 8) {
		if(m[i/3][i%3] != i+1) return false;
	}
	if(m[2][2] != 0) return false;
	return true;
}

int bfs(vii m) {
	queue<vii> Q;
	Q.push(m);
	memo[m] = 0;
	while(Q.size()) {
		vii cur = Q.front();
		Q.pop();

		if(check(cur)) return memo[cur];

		const int dr[4] = {1, 0, -1, 0};
		const int dc[4] = {0, 1, 0, -1};

		int zero_r, zero_c;

		rep(i, 3) rep(j, 3) if(cur[i][j] == 0) zero_r = i, zero_c = j;
		rep(i, 4) {
			vii next = cur;
			int nr = zero_r + dr[i];
			int nc = zero_c + dc[i];
			if(nr<0 || 3<=nr || nc<0 || 3<=nc) continue;
			swap(next[zero_r][zero_c], next[nr][nc]);
			if(memo.find(next) != memo.end()) continue;
			memo[next] = memo[cur]+1;
			Q.push(next);
		}
	}
} 

int main(void){
	vii m(3, vi(3, 0));
	rep(i, 9) cin >> m[i/3][i%3];

	cout << bfs(m) << endl;

	return 0;
}

Measured memory_bytes: 49152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();

        double a = t * Math.ceil((double)n/x);
        System.out.println((int)a);
    }
}

Measured memory_bytes: 35748
#include <iostream>
using namespace std;
int main(){
	int n,nr;
	cin >> n;

	nr = (n%10)*100 + ((n/10)%10) *10 + n/100;
	if (n == nr){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
int main() {
    string w;
  	cin >> w;
    unordered_map<char, int> list;
    for (int i = 0; i < w.length(); i++) {
        list[w[i]]++;
    }
    for (auto i : list) {
        if (i.second % 2 != 0) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var input1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        var N = input1[0];
        var M = input1[1];
        var points = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        points.Sort();

        if (points.First() < 0)
        {
            points = points.Select(x => -1 * points.First() + x).ToList();
        }
        else
        {
            points = points.Select(x => x - points.First()).ToList();
        }

        if (M == 1)
        {
            Console.WriteLine(0);
            return;
        }

        if (N == 1)
        {
            Console.WriteLine(points.Last());
            return;
        }

        var distance = new List<int>();
        for (int i = 0; i < points.Count - 1; i++)
        {
            distance.Add(points[i + 1] - points[i]);
        }

        distance.Sort((x, y) => y - x);
        Console.WriteLine(distance.Skip(N - 1).Sum());
    }
}

Measured memory_bytes: 25564
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

vec<int> Zalgo(string S) {
    int N = S.size();
    vec<int> A(N);
    A[0]  = N;
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i + j < N && S[j] == S[i + j])
            ++j;
        A[i] = j;

        if (j == 0) {
            ++i;
        } else {
            int k = 1;
            while (i + k < N && k + A[k] < j){
                A[i + k] = A[k], ++k;
            }
            i += k, j -= k;
        }
    }
    return A;
}

int main() {
    int N;
    string S;
    cin >> N >>S;
    
    int ans = 0;
    rep(i,N){
        auto A = Zalgo(S.substr(i));
        int n = A.size();
        rep(j,n){
            if(j>=A[j]) ans = max(ans,A[j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[27];
int main()
{
  char s[100001];
  cin>>s;
  for(int i=0;s[i]!='\0';i++)
  {
      a[s[i]-96]++;
  }
  int i,flag=0;
  for( i=1;i<=26;i++)
  {
      if(a[i]==0)
      {
          flag=1;
          break;
      }
  }
  if(flag==0)
    cout<<"None";
  else
    printf("%c",i+96);
    return 0;
}


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

typedef long long ll;
typedef long double ld;

const int MAX = 1e6 + 5;
int go[MAX][26];
bool leaf[MAX];
int sz = 1;
void add(string s){
    int cur = 0;
    for(auto c: s){
        if(!go[cur][c - 'a']) go[cur][c - 'a'] = sz++;
        cur = go[cur][c - 'a'];
    }
    leaf[cur] = true;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i], reverse(s[i].begin(), s[i].end());
    for(auto& x: s) add(x);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        vector<int> cnt(26);
        for(auto c: s[i]){
            cnt[c - 'a']++;
        }
        int cur = 0;
        for(int j = 0; j < (int) s[i].size() - 1; j++){
            for(int c = 0; c < 26; c++){
                if(cnt[c] && go[cur][c]){
                    ans += leaf[go[cur][c]];
                }
            }
            cnt[s[i][j] - 'a']--;
            if(!go[cur][s[i][j] - 'a']) break;
            cur = go[cur][s[i][j] - 'a'];
        }
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;



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

	int turn = 0;

	while(a > 0 && c > 0) {
		if (turn == 0) {
			c -= b;
		}	
		else {
			a -= d;
		}

		turn = turn ^ 1;
	}	

	if (a <= 0)
		cout << "No" << '\n';
	else cout << "Yes" << '\n';


	return 0;	
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int flg = 0;
		
		String s = scan.nextLine();//??????????????????
		String p = scan.nextLine();//??????????????????
		
		String s2 = s + s;//s???2?????£????????????
		
		int s2_len = s2.length();
		int p_len = p.length();
		
		for(int s2_cnt = 0; s2_cnt < s2_len - p_len; s2_cnt++){
			
			int ans_cnt = 0;
				
			for(int p_cnt = 0; p_cnt < p_len; p_cnt++){
				if(p.charAt(p_cnt) == s2.charAt(s2_cnt + p_cnt)){
					ans_cnt++;
					if(ans_cnt == p_len){
						flg = 1;
					}
				}
			}
		}
		if(flg == 1)
			System.out.println("Yes");
		else
			System.out.println("No");
		//????§????
		scan.close();
	}
}

Measured memory_bytes: 26160
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if (a>=13)
    {
        cout<<b;
    }
    else if (a<13 & a>=6)
    {
        cout<<b/2;
    }
    else if (a<6)
    {
        cout<<b*0;
    }
  return 0;
}

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

namespace CSharp
{
	class Program
	{
		static void Main(string[] args)
		{
			// var N = 5;
			// var H = new int[] { 3, 1, 2, 3, 1 };
			// //             5
			// // 3 1 2 3 1
			// // 1 2 2 1

			var N = Console.ReadLine().Split().Select(int.Parse).ToArray()[0];
			var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var res = 0;
			while (true)
			{
				if (H.Max() <= 0) break;

				var i = 0;
				res++;
				while (i < N)
				{
					if (H[i] == 0)
					{
						i++;
					}
					else
					{
						break;
					}
				}

				while (i < N && H[i] != 0)
				{
					H[i]--;
					i++;
				}
			}
			Console.WriteLine(res);
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b;
    cin >> a >> b;
    if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) {
        cout << "Possible" << "\n";
    } else {
        cout << "Impossible" << "\n";
    }
}


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

int main()
{
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0;

    p1 = a * x + b * y;
    if(x >= y){
        p2 = c * 2 * y + a * (x - y);
        p3 = c * 2 * x;
        cout << min({p1,p2,p3});
    }else{
        p4 = c * 2 * x + b * (y - x);
        p5 = c * 2 * y;
        cout << min({p1,p4,p5});
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    double T,X;
    cin >> T >> X;

    cout << fixed << setprecision(10) << T / X << endl;

    return 0;
}


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

vector<int> prime(int n){
    vector<int> t;
    vector<bool> x(n+1, true);
    t.push_back(2);

    int i;
    for(i = 3; i * i <= n; i += 2){
        if(!x[i]){
            continue;
        }
        t.push_back(i);
        for(int j = i; j <= n; j += i){
            x[j] = false;
        }
    }
    for(; i <= n; i += 2){
        if(x[i]){
            t.push_back(i);
        }
    }
    return t;
}

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

    vector<int> t = prime(55555);

    vector<int> ans;
    int i = 0;
    while((int)ans.size() != n){
        if(t[i] % 5 == 1){
            ans.push_back(t[i]);
        }
        i++;
    }
    for(int i = 0; i < (int)ans.size()-1; i++){
        cout << ans[i] << " ";
    }
    cout << ans[ans.size()-1] << endl;

    return 0;
}


Measured memory_bytes: 256