akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
    int h1=read(),m1=read(),h2=read(),m2=read();
    if (m2<m1) {m2+=60;h2--;}
    int x=60*(h2-h1)+(m2-m1),k=read();
    printf("%d\n",x-k);
    return 0;
}

Measured memory_bytes: 3636
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    V<double> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];
    vll p(n); iota(ALL(p), 1LL);
    double ans = 0.0;
    do {
        rep(i, 1, n) {
            ans += sqrt((x[p[i] - 1] - x[p[i-1] - 1]) * (x[p[i] - 1] - x[p[i-1] - 1]) + (y[p[i] - 1] - y[p[i-1] - 1]) * (y[p[i] - 1] - y[p[i-1] - 1]));
        }
    } while (next_permutation(ALL(p)));
    double nn = 1.0;
    rep(i, 1, n+1) nn *= i;
    cout << fixed << setprecision(12) << ans / nn << '\n';
    return 0;
}


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

int main() {
	while(1){
		int n,k,b[100100]={},sum=0,sum1=0,ans=0,j=0;
		cin>>n>>k;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>b[i];
			if(i<k){
				sum+=b[i];
			}else{
				ans=max(ans,sum);
				sum=sum-b[j]+b[i];
				j++;
			}
		}
	cout<<ans<<endl;
	}
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll X;
    cin >> X;
    ll sum = 0;
    REP(i, X + 1)
    {
        sum += i;
        if (X <= sum)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main()
{
    int A, B;
    std::cin >> A >> B;

    int ans = 0;
    if (A == B) {
        ans = A + B;
    }
    else {
        ans = std::max(A, B);
        ans = ans + (ans-1);
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N;
	scanf("%d",&N);
	unsigned long int sum = 0;
	double tmp;
	double min;
	int negative_counter = 0;
	for ( int i = 0; i < N; i++ ) {
		scanf("%lf",&tmp);
		if ( i == 0 ) {
			if ( tmp < 0 ) {
				min = -tmp;
			} else {
				min = tmp;
			}
		}
		if ( tmp < 0 ) {
			negative_counter++;
			tmp = -tmp;
			sum += tmp;
			if ( min > tmp ) min = tmp;
		} else {
			sum += tmp;
			if ( min > tmp ) min = tmp;
		}
	}
	if ( negative_counter % 2 != 0 ) {
		sum -= 2 * min;
	}
	printf("%ld\n",sum);
  return 0;
}

Measured memory_bytes: 128
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

typedef long long ll;

const int M = 2000 + 10, N = 6000000 + 10;
const int MOD = 1000000007;

ll dp[M][M], n, k, fac[N], inv[N];

ll mul(ll a, ll b){
	return a * b % MOD; 
}

ll add(ll a, ll b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

ll POW(ll x, ll t){
	ll res = 1;
	while (t){
		if (t & 1) res = mul(res, x);
		t >>= 1;
		x = mul(x, x);
	}
	return res;
}

ll ted(ll x, ll y){
	ll res = x * k + (y - x) * (k - 1);
	return res;
}

ll nCr(ll x, ll y){
	if (x < 0 || y < 0 || y > x) return 0;
	ll res = fac[x];
	res = mul(res, mul(inv[y], inv[x - y]));
	return res;
}

ll solve(ll ted, ll K){
	return nCr(K + ted - 1, ted - 1);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	dp[0][0] = 1;
	//cout << POW(2, 4) << '\n';
	fac[0] = 1, inv[0] = 1;
	for (int i = 1; i < N; i++){
		fac[i] = mul(fac[i - 1], i);
		inv[i] = POW(fac[i], MOD - 2);
	}
	//cout << fac[4] << '\n';
	//cout << nCr(4, 2) << '\n';
	//cout << ted(0, 1) << '\n';
	if (k == 1) return cout << 1, 0;
	for (int i = 0; i <= n; i++){
		for (int j = i; j <= n; j++){
			if (i == j && i == 0) continue;
			if (i == 0){
				if (j == 1) {dp[i][j] = 1;}
				else{
					ll res = solve(ted(i,j - 1) + 1, k - 2);
					dp[i][j] = mul(dp[i][j - 1], res);
 				}
			}
			else{
				if (i == j){
					dp[i][j] = dp[i - 1][j];
				}else{
					dp[i][j] = dp[i - 1][j];
					ll res = solve(ted(i, j - 1) + 1, k - 2);
					dp[i][j] = add(dp[i][j], mul(dp[i][j - 1], res));
				}
			}
			//cout << i << ' ' << j << ' ' << dp[i][j] << '\n';
		}		
	}
	cout << mul(dp[n][n], fac[n]);
	
	return 0;
}

Measured memory_bytes: 125312
#include <iostream>

using namespace std;

int main()
{
    string arr[7] = {"SAT","FRI", "THU","WED", "TUE","MON","SUN"};
    int r = 1;
    string S;
    cin >> S;
    for(int i=0 ;i<7;i++){
        if(S == arr[i]){
            break;
        }
        r=r+1;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		String c = null;
		c = "";

		if (Integer.parseInt(a) < Integer.parseInt(b)) {
			for (int i = 0; i < Integer.parseInt(b); i++) {

				c = c + a;
			}
			System.out.print(c);
		}
			else if (Integer.parseInt(b) < Integer.parseInt(a)) {
				for (int i = 0; i < Integer.parseInt(a); i++) {

					c = c + b;
				}
				System.out.print(c);
				} else {
					for (int i = 0; i < Integer.parseInt(b); i++) {

						c = c + a;
					}
					System.out.print(c);
				}
		sc.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin>>s;
    if(s.back() == 's') s = s + "es";
    else s = s + 's';
    cout<<s;
    return 0;
}

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

bool prime(int n)
{
    for(int i=2; i*i<=n; ++i)
        if(n%i==0) return false;
    return true;
}

void main()
{
    int[] ns;
    int m=0;
    for(int n; 0!=(n=readln().chomp().to!int()); ) m=max(m,n),ns~=n;
    auto a = new long[m+1];
    for(int i=1,n=2; i<=m; ++n)
        if(prime(n)) a[i]=a[i-1]+n,++i;
    ns.map!(n=>a[n].to!string()).join("\n").writeln();
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;



int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> L(N);
	for (ll i = 0; i < N; ++i) cin >> L[i];
	sort(L.begin(), L.end());


	ll res{0};
	for (ll i = 0; i < N; ++i)
	{
		for (ll j = i + 1; j < N; ++j)
		{

			ll tmp = L[i] + L[j];
			ll d = lower_bound(L.begin(), L.end(), tmp) - L.begin();
			res += d - j - 1;
		}
	}

	std::cout << res << std::endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int ct[n+1]; memset(ct,0,sizeof(ct));
    int a[q];
    for (int i = 0; i < q; i++) {
        scanf("%d",&a[i]);
        ct[a[i]]++;
    }
    for (int i = 1; i <= n; i++){
        printf("%s\n",q-ct[i] < k ? "Yes":"No");
    }


}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;
using ll = long long;

int main()
{
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long ans = 0;
    for (ll i = 0; i < n - 2; i++)
    {
        string a = s.substr(i, 3);
        if (a == "ABC")
        {
            ans++;
            i += 2;
        }
    }

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

Measured memory_bytes: 3576
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a == 0) cout << 1 << endl;
	if (b == 0) cout << 2 << endl;
	if (c == 0) cout << 3 << endl;
	if (d == 0) cout << 4 << endl;
	if (e == 0) cout << 5 << endl;
}

Measured memory_bytes: 3604
julia -EH,W,A,B=`tr \  ,`";M,C,Z,X=10^9+7,1,0,W+H-B-2
for I=0:H-2;C=C*(X-I)%M*invmod(-~I,M)%M;end
for I=1:H-A;Z+=C;C=(B+I-1)*(H-I)%M*C%M*invmod((X-I+1)*I,M)%M;end
Z%M"

Measured memory_bytes: 151388
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val K = sc.nextInt
  val N = sc.nextInt
  val A = Array.fill(N)(sc.nextInt)

  val x = for (i <- 0 until N) yield {
    val j = (N + i - 1) % N
    math.abs(A(i) - (if (j < i) A(j) + K else A(j)))
  }

  println(x.min)
}


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

bool a[26];
size_t i;
string s;

int main()
{
    cin >> s;
    for (i = 0; i < s.size(); i++) a[s[i]-'a'] = 1;
    for (i = 0; i < 26; i++) {
        if (a[i] == 0) {
            printf("%c\n", 'a'+i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 3860
#include <iostream>

int main() {
  int X;
  int A;
  int B;
  std::cin >> X >> A >> B;

  int XA = (X - A);
  int count = XA / B;

  int zankin = XA - B * count;
  std::cout << zankin << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define endl '\n'
#define ll long long

using namespace std;

int menor_mod_10(int v[]) {
    int menor = 11, idx = 0;
    int n;

    for(int i = 0; i < 5; i++) {
        
        n = v[i] % 10;
        if(n < menor && n != 0) {
            idx = i;
            menor = n;
        }
    }

    return idx;
}

int main() {
    int v[5], idx;

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

    idx = menor_mod_10(v);

    /*
    cout << idx << endl;
    getchar();
    getchar();
    */
   
    int tempo = 0;

    for(int i = 1; i <= 4; i++) {
        tempo += v[(idx + i) % 5];
        
        if(v[(idx + i) % 5] % 10) {
            tempo += (10 - v[(idx + i) % 5] % 10);
        }
    }

    tempo += v[idx];

    cout << tempo << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
const int maxx=1e9+7;
int main()
{
    long long int sum=1;
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        sum = (sum)*(i%maxx)%maxx;

    }

    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val cList = readLine()!!.toList()
  val n = cList.size
  val rMap = mutableMapOf<Int, Int>()
  val lMap = mutableMapOf<Int, Int>()
  for (i in 1 until n) {
    val c = cList[i]
    if (c == 'L') {
      val lNum = lMap[i - 1]
      if (lNum == null) {
        lMap[i] = 1
      } else {
        lMap[i] = lNum + 1
      }
    }
  }
  for (i in n - 2 downTo 0) {
    val c = cList[i]
    if (c == 'R') {
      val rNum = rMap[i + 1]
      if (rNum == null) {
        rMap[i] = 1
      } else {
        rMap[i] = rNum + 1
      }
    }
  }
  val ansList = (1..n).map { 0 }.toMutableList()
  for (i in 0 until n) {
    val c = cList[i]
    if (c == 'R') {
      val r = rMap[i]!!
      if (r % 2 == 0) {
        ansList[i + r]++
      } else {
        ansList[i + r - 1]++
      }
    } else {
      val l = lMap[i]!!
      if (l % 2 == 0) {
        ansList[i - l]++
      } else {
        ansList[i - l + 1]++
      }
    }
  }
  println(ansList.joinToString(separator = " "))
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

const int N = 1e5 + 10;
int arr[N];
bool visited[N];
int n ,m;

vvi graph;

bool check(int node) {
    int val = arr[node];
    for (auto neigh: graph[node]) {
        if (arr[neigh] >= val) return false;
    }
    return true;
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }

    memset(visited,0,sizeof(visited));
    graph = vvi(n+1);
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    for (int i = 1; i <= n; ++i) {
        ans += check(i);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8744
N=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(N):
   for j in reversed(range(N-i)):
      if j+1 == l[j]:
         ans.append(l[j])
         l.pop(j)
         break
      if j == 0:
         print("-1")
         exit()
ans=ans[::-1]
for i in ans:
   print(i)

Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%lld\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	
	vector<int> ans(n + 1);
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z ++) {
				int t = x * x + y * y + z * z;
				t += x * y + y * z + z * x;
				if (t > n) break;
				ans[t]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		pf(ans[i]);
	}


	return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll b[n+1];
  b[0]=0;
  rep(i,n)b[i+1]=b[i]+a[i];
  ll c[n+1];
  c[0]=0;
  rep(i,n)c[i+1]=max((ll)0,a[i])+c[i];
  ll ans=0;
  rep(i,n-k+1){
    ans=max(ans,max((ll)0,b[i+k]-b[i])+c[n]+c[i]-c[i+k]);
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math

def minCost():
    dp[0] = 0
    for i in range(1, n):
        if i == 1:
            dp[i] = math.fabs(a[i] - a[i-1])
        else:
            dp[i] = min(dp[i-1] + math.fabs(a[i] - a[i-1]), dp[i-2] + math.fabs(a[i] - a[i-2]))
    return int(dp[n-1])

dp = [0] * 100000
n = int(input())
a = list(map(int, input().split()))
print(minCost())

Measured memory_bytes: 15252
// Problem : B - FizzBuzz Sum
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound		// first element >= val(itr) 
#define ub              upper_bound		// first element >  val(itr)
#define vll							vector<ll>
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))	//x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#ifdef LOCAL_TEST
#include"/home/shrey/debug.h"
#endif

const ll inf = 1e18;
const int nax = 1e5 + 5;

void SolveTestCase()
{
	ll n;
	cin>>n;
	
	ll ans = 0;
	forn(i,1,n+1)
	{
		if(i%3 != 0 && i%5 != 0)
		{
			ans += i;
		}
	}
	
	cout<<ans;
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	forn(i, 0, t)
	{
		SolveTestCase();
	}

	return 0;
}


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

int main() {
  int N;
  cin>>N;
  int h[N];
  int dp[N];
  for (int i=0;i<N;i++){
    cin>>h[i];
    dp[i]=1000000000;
  }
  dp[0]=0;
  for(int i=1;i<N;i++){
    dp[i]=min(dp[i],dp[i-1]+abs(h[i-1]-h[i]));
    if(i>1){
      dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
n , q = map(int,input().split())
s = input()
p = [0,0]
cou = 0
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        cou += 1
    p.append(cou)
    
for i in range(q):
    l,r = map(int,input().split())
    print(p[r]-p[l])

Measured memory_bytes: 6096
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;



int main(){
    ll n,a[10],m;
    m=LLINF;
    cin >>n;
    rep(i,5) cin>>a[i];
    rep(i,5){
        if(a[i]<m) m=a[i];
    }
    if(m==1) cout <<n+4<<endl;
    else cout <<n/m+5<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector<double> A(n);
    for (int i = 0; i < n;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    double count = A[0];
    for(int i = 1;i<n;i++){
        count = (count+A[i])/2;
    }

    printf("%f\n",count);



}

Measured memory_bytes: 256
#include <stdio.h>
  
typedef struct pair* ppair;
  
typedef struct pair {
  int first, second;
} pair;
  
  
int size;
pair v[1000000];
int psize;
pair preorder[1000000];
int sorted;
  
void swap(ppair a, ppair b) {
  pair t = *a;
  *a = *b;
  *b = t;
}
  
int getp(int begin, int end) {
  int i;
  int p = begin;
  for(i = begin+1; i < end; ++i) {
    if(v[i].first < v[p].first) {
      p = i;
    }
  }
  swap(&v[end-1], &v[p]);
  return end-1;
}
  
void qsort(int begin, int end) {
  int i, j;
  if(begin >= end) return;
  getp(begin,end);
  preorder[psize++] = v[end-1];
  if(begin+1 == end) return;
  for(i = begin, j = begin; i < end; ++i) {
    if(v[i].second < v[end-1].second) {
      swap(&v[i], &v[j++]);
    }
  }
  swap(&v[j],&v[end-1]);
  qsort(begin, j);
  qsort(j+1, end);
}
  
int binary_search(int k) {
  int l, r;
  l = 0;
  r = size;
  while(l < r) {
    int m = (l+r)/2;
    if(v[m].second == k) {
      return m;
    } else if(v[m].second < k) {
      l = m+1;
    } else {
      r = m;
    }
  }
  return -1;
}
  
int main() {
  int i, j;
  int n, k;
  char s[100];
  size = 0;
  sorted = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s", s);
    if(s[0] == 'i') {
      scanf("%d", &k);
      v[size] = (pair){size,k};
      ++size;
      sorted = 0;
    } else if(s[0] == 'p') {
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      for(j = 0; j < size; ++j) {
        printf(" %d", v[j].second);
      }
      printf("\n");
      for(j = 0; j < size; ++j) {
        printf(" %d", preorder[j].second);
      }
      printf("\n");
    } else {
      scanf("%d", &k);
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      printf(binary_search(k)!=-1?"yes\n":"no\n");
    }
  }
  return 0;
}

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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}

namespace std {
	bool operator < (P a, P b) {
		return sgn(real(a), real(b)) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
G convex_hull(G g){
    int n = g.size();
	assert(n >= 3);

	sort(ALL(g));
    G c(n*2);
	int k = 0;
	REP(i, n) {
        while(k>=2 && ccw(c[k-2], c[k-1], g[i]) == -1) k--;
        c[k++] = g[i];
    }
	int t = k + 1;
	for (int i = n - 2; i >= 0; --i) {
		while (k >= t && ccw(c[k - 2], c[k - 1], g[i]) == -1) k--;
		c[k++] = g[i];
	}
    c.resize(k-1);
    return c;
}

//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;

	G g(n);
	REP(i,n){
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}

	G g2 = convex_hull(move(g));
	ll under = 10001;
	REP(i, g2.size()) under = min<ll>(under, g2[i].imag());
	ll d = -1;
	REP(i, g2.size()) if (g2[i].imag() == under) if (d == -1 || g2[d].real() > g2[i].real()) d = i;

	cout << g2.size() << endl;
	REP(i, g2.size()) cout << (int)g2[(i+d)%g2.size()].real() << " " << (int)g2[(i+d)%g2.size()].imag() << endl;
	return 0;
}

Measured memory_bytes: 12392
#include<bits/stdc++.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;


#define NUM 1001

ll nCm[NUM][NUM];
ll fact[NUM];
ll memo[NUM];
ll POW[NUM];

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll &e){
	e = 0;
	if(n == 0)return 1;

	int res = mod_fact(n/p,p,e);
	e += n/p;

	if(n/p%2 != 0)return res*(p-fact[n%p])%p;
	return res*fact[n%p]%p;
}

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	fact[0] = 1;
	for(ll i = 1; i <= K; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}

	//数字^Nを求める
	POW[0] = 1;
	ll tmp;
	for(ll i = 1; i <= K; i++){
		tmp = 1;
		for(int loop = 0; loop < N; loop++){
			tmp *= i;
			tmp %= MOD;
		}
		POW[i] = tmp;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++){
		for(int m = 0; m <= K; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	memo[1] = 1;

	for(ll num = 2; num <= K-1; num++){

		memo[num] = POW[num];

		for(int i = 1; i <= num-1; i++){
			memo[num] -= nCm[num][i]*memo[i];
			memo[num] %= MOD;
			if(memo[num] < 0)memo[num] += MOD;
		}
	}

	ll ans = POW[K];

	for(int i = 1; i <= K-1; i++){

		ans -= nCm[K][i]*memo[i];
		ans %= MOD;
		if(ans < 0)ans += MOD;
	}

	ans *= mod_inverse(fact[K],MOD);
	ans %= MOD;
	if(ans < 0)ans += MOD;

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

	return 0;
}




Measured memory_bytes: 11052
#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(itr,v) for(auto &(itr):(v))
#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*b/gcd(a,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;



// 1個ずつ運んでも5*sum(x)+2nXで終わるからlonglongをオーバーフローするような操作は考えなくていい

ll n, x, a[200200], s[200200], res = 1ll<<60;

signed main() {
	cin >> n >> x;
	rep(i,n) {
		cin >> a[i];
		s[i+1] = s[i] + a[i];
	}
	reps(k,1,n+1) {
		ll t = 0, of = 0;
		for (int i=n, j=1; i>=1 && !of; i-=k, j++) {
			ll p = (s[i] - (i-k<0 ? 0 : s[i-k])) * (j==1 ? 5 : j*2+1);
			if (p/(j==1 ? 5 : j*2+1) != s[i] - (i-k<0 ? 0 : s[i-k])) of = 1;
			t += p;
			if (res<=t) of = 1;
		}
		if (!of) chmin(res, t+(n+k)*x);
	}
	cout << res << endl;
}


Measured memory_bytes: 3456
package main

import (
	"fmt"
)

func main() {
	var r, g, b, n int
	fmt.Scan(&r)
	fmt.Scan(&g)
	fmt.Scan(&b)
	fmt.Scan(&n)

	var ret int
	for i := 0; i*r <= n; i++ {
		for j := 0; i*r+j*g <= n; j++ {
			if (n-(i*r+j*g))%b == 0 {
				ret++
			}
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 410;

LL dp[N][N];
LL n;
LL arr[N];

LL solve(int l, int r)
{
	if (l >= r) return 0;
	if (l + 1 == r) return arr[r] - arr[l - 1];
	LL &ans = dp[l][r];
	if (ans != -1) return ans;
	ans = arr[r] - arr[l - 1];
	LL temp = 1e18;
	for (int i = l; i < r; i++){
		temp = min(temp, solve(l, i) + solve(i + 1, r));
	}
	ans = ans + temp;
	return ans;
}

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

    memset(dp, -1, sizeof(dp));

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];

    for (int i = 1; i <= n; i++) arr[i] += arr[i - 1];

    cout << solve(1, n) << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void){
	int a,b,c,d,e,f,s;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	s=a+5*b+10*c+50*d+100*e+500*f;
	if(s<1000){
		printf("0\n");
	}
	else{
		printf("1\n");
	}

return 0;
}
	

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s, t;
  cin >> s >> t;

  string ans;
  if (s.size() < t.size()) {
    ans = "UNRESTORABLE";
  } else {
    set<string> st;
    for (int i = 0; i <= s.size() - t.size(); i++) {
      bool flag = true;
      for (int j = i; j < i + t.size(); j++) {
        if (s[j] == '?') continue;

        if (s[j] != t[j-i]) flag = false;
      }
      if (!flag) continue;

      string tmp = s;
      tmp.replace(i, t.size(), t);
      for (int j = 0; j < tmp.size(); j++) if (tmp[j] == '?') tmp[j] = 'a';
      st.insert(tmp);
    }

    if (st.empty()) {
      ans = "UNRESTORABLE";
    } else {
      set<string>::iterator it = st.begin();
      ans = *it;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

int ok[15];
ll c[10000];
ll dp[10000];

int main(){
    int n,m; cin >> n >> m;
    for(int i=0;i<10000;i++){
        c[i]=1e9;
    }
    for(int i=0;i<m;i++){
        ll a,b; cin >> a >> b;
        int sum=0;
        for(int j=0;j<b;j++){
            int co; cin >> co;
            co--;
            sum+=(1<<co);
        }
        c[sum]=min(c[sum],a);
    }
    for(int i=0;i<10000;i++){
        dp[i]=1e9;
    }
    dp[0]=0;
    for(int i=0;i<(1<<n);i++){
        for(int j=1;j<(1<<n);j++){
            if(dp[i]==1e9)continue;
            if(c[j]==1e9)continue;
            dp[i | j]=min(dp[i | j],dp[i]+c[j]);
        }
    }
    if(dp[(1<<n)-1]==1e9){
        cout << -1 << endl;
    }
    else{
        cout << dp[(1<<n)-1] << endl;
    }
}

Measured memory_bytes: 384
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int a, b;cin >> a >> b;
	for(int i = 1; i <= 1e6; i++){
		int x = (int)((ld)i * (ld)0.08), y =(int)((ld)i * (ld)0.1);
		if(x == a && y == b){
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}



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

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

	int cnt = 0;

	for(int i = 105; i <= N; i = i + 2) {
		int count = 0;
		for(int k = 1; k <= i; k++) {
			if(i % k == 0) {
				count++;
			}
		}

		if(count == 8) {
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           998244353
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;

void Anon_mouS(){
    string s,tn;
    cin>>s>>tn;
    string t=s;
    for(i=0;i<26;i++){
        if(t+char('a'+i)==tn){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
 
int32_t main(){
    fastio;
    int q=1;
    // cin>>q;
    // build();
    while(q--){
        Anon_mouS();
    }
    return 0;
}

Measured memory_bytes: 3612
s = input()
t = input()

lendif = len(s) - len(t)

min_global = len(s)

for i in range(lendif + 1):
  beg = i
  end = i + len(t)
  sl = s[beg:end]
  m = 0
  for j in range(len(t)):
    if t[j] != sl[j]:
      m += 1
  if m < min_global:
    min_global = m

print(min_global)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

map<ll,ll> ma;
int n;

int main(){
    cin >> n;
    rep(i,n){
        ll num;
        cin >> num;
        ma[num]++;
    }
    ll ans = 0;
    for(auto it = ma.begin();it != ma.end();it++){
        ll num = it -> first;
        ll cnt = it -> second;
        if(cnt >= num)ans += cnt - num;
        else ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6272
import java.util.Arrays;
import java.util.Scanner;

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

		for(int i = 0; i < M; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(X);
		if(N >= M) {
			System.out.println(0);
			System.exit(0);
		}
		long[] e = new long[M - 1];
		for(int i = 0; i < M - 1; i++) {
			e[i] = Math.abs(X[i + 1] - X[i]);
		}
		Arrays.sort(e);
		long sum = 0;
		for(int i = 0; i < M - N; i++) {
			sum += e[i];
		}
		System.out.println(sum);

	}
}

Measured memory_bytes: 51888
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

int N, M, Q;
vector<int> A(50);
vector<int> B(50);
vector<int> C(50);
vector<int> D(50);

int ans = 0;
void dfs(int n, vector<int> &num ){
  if( num.size() == N ){ //判定パート
  int now = 0;
    for( int i = 0; i < Q; i++ ){
      if( num.at(B[i]) - num.at(A[i]) == C[i] ) now += D[i];
    }
    ans = max(ans, now);
  }else{
    for( int i = n; i <= M; i++ ){
      num.push_back(i);
      dfs(i, num);
      num.pop_back();
    }
  }

}

signed main(){
  cin >> N >> M >> Q;
  for( int i = 0; i < Q; i++ ){
    cin >> A.at(i) >> B.at(i) >> C.at(i) >> D.at(i);
    A.at(i)--;
    B.at(i)--;
  }

  vector<int> num;
  dfs(1, num);
  cout << ans << endl;

 }

Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            in.nextLine();
            int A = in.nextInt();
            int B = in.nextInt();

            boolean ok = false;
            for (int i = A; i <= B; i++) {
                if (i % k == 0) {
                    out.println("OK");
                    ok = true;
                    break;
                }
            }
            if (!ok)
                out.println("NG");
        }

    }
}



Measured memory_bytes: 35916
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int k,n;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i=0; i<n; i++)cin >> arr[i];
    vector<int> dp(n);
    dp[0] = 0;
    for(int i=1; i<n; i++)
    {
        int temp = INT_MAX;
        for(int j = i-k; j<i; j++)
        {
            if(j<0)continue;
            int val = dp[j]+abs(arr[i]-arr[j]);
            temp = min(temp,val);
        }
        dp[i] = temp;
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
/**
*    created: 09.05.2020 11:15:22
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;
using Graph = vector<vector<int>>;
vector<bool> seen;
int N, M, ans = 0;
vector<int> a, b;
//Graph取得時各頂点の値-1
void dfs(const Graph G,int v){
    seen[v] = true;

    bool ss = true;//ssは隣接する頂点すべて訪れたか
    for(int next_v:G[v]){
        ss &= seen[next_v];
    }
    if(ss)
    { //終端条件。ss:true&&sss:trueでans++
        bool sss = true;//sssは前頂点訪れたか
        rep(i,N) sss &= seen[i];
        if(sss) ans++;
        return;
    }

    for(int next_v:G[v]){
        if(seen[next_v]) continue;
        dfs(G, next_v);
        //seen更新。
        seen[next_v] = false;
    }
}

int main() {
    cin >> N >> M;
    a.resize(M), b.resize(M);
    Graph G(N);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    seen.assign(N, false);
    dfs(G, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int K, X;
    cin >> K >> X;
    int start = max(-1000000, X - K + 1), end = min(1000000, X + K - 1);
    for (int i = start; i < end; ++i) cout << i << " ";
    cout << end << endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;
double EPS = 0.000000001;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> x(n), y(n), z(n), r(n);
    vector<Int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
    }
    vector<int> rx(q), ry(q), rz(q), bx(q), by(q), bz(q);
    for (int i = 0; i < q; i++) {
        cin >> rx[i] >> ry[i] >> rz[i] >> bx[i] >> by[i] >> bz[i];
    }
    vector<Int> res(q);
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            double a1 = x[j] - rx[i];
            double a2 = y[j] - ry[i];
            double a3 = z[j] - rz[i];
            double b1 = bx[i] - rx[i];
            double b2 = by[i] - ry[i];
            double b3 = bz[i] - rz[i];
            double c1 = a1 - b1;
            double c2 = a2 - b2;
            double c3 = a3 - b3;
            double s = (a2 * b3 - a3 * b2) * (a2 * b3 - a3 * b2) + (a3 * b1 - a1 * b3) * (a3 * b1 - a1 * b3) + (a1 * b2 - a2 * b1) * (a1 * b2 - a2 * b1);
            double rb_dist = sqrt(b1 * b1 + b2 * b2 + b3 * b3);
            if (s == 0) {
                double d1 = sqrt(a1 * a1 + a2 * a2 + a3 * a3);
                double d2 = sqrt((a1 - b1) * (a1 - b1) + (a2 - b2) * (a2 - b2) + (a3 - b3) * (a3 - b3));
                if (rb_dist + (double)r[j] < d1 or rb_dist + (double)r[j] < d2) continue;
                res[i] += l[j];
            }
            else {
                double d = sqrt(s) / sqrt(b1 * b1 + b2 * b2 + b3 * b3);
                //printf("%.12lf %.12lf\n", d, (double)r[j]);
                if (a1 * b1 + a2 * b2 + a3 * b3 < 0 and sqrt(a1 * a1 + a2 * a2 + a3 * a3) > (double)r[j]) continue;
                b1 = -b1;
                b2 = -b2;
                b3 = -b3;
                if (c1 * b1 + c2 * b2 + c3 * b3 < 0 and sqrt(c1 * c1 + c2 * c2 + c3 * c3) > (double)r[j]) continue;
                if (d <= (double)r[j] + EPS) {
                    res[i] += l[j];
                }
            }
        }
        //cout << endl;
    }
    for (int i = 0; i < q; i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3116
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

//ベルマンフォード法
//https://abc061.contest.atcoder.jp/submissions/4484303

struct edge {ll to, cost;};
vector<vector<edge>> g;
const ll INF = 1e18;
const int MAX_N = 1e5;

ll dist[MAX_N];
ll n,m;

bool bellman_ford(ll s){
  REP(i,n) dist[i] = INF;
  dist[s] = 0;

  bool negative_cycle = false;

  REP(i, n){
    REP(v, n){
      for(edge e: g[v]){
	if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
	  dist[e.to] = dist[v] + e.cost;
	  //n回目に n-1 に更新がある -> 負のサイクル
	  if(i == n-1 && e.to == n-1){
	    dist[e.to] = -INF;
	    negative_cycle = true;
	  }
	}
      }
    }
  }
  return negative_cycle;
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;  
  g.assign(n, vector<edge>());  
  REP(i, m){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--; c*=-1;
    g[a].push_back(edge{b, c});
  }
  
  bool negative_cycle = bellman_ford(0);

  cout << (!negative_cycle ? to_string(-dist[n-1]) : "inf" ) << endl;
  
  return 0;
}


Measured memory_bytes: 384