akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];
  ll ans = 0;
  ll keta = (ll)log2(K) + 1LL;
  // cout << keta << endl;
  FOR(k, 0, 35) {
    ll score = 0;
    ll po = ((K >> k) << k) + (1LL << (k - 1)) - 1LL;
    if (po > K)
      continue;
    REP(i, N) {
      if ((po | A[i]) == po)
        score += B[i];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int count_num = 0;
bool is_pass[9];
bool graph[9][9];
int N, M;
void dfs(int num, int n_pass) {
    is_pass[num] = true;
    if(n_pass == N) {
        count_num++;
    } else {
        for(int i = 1; i <= N; i++) {
            if(!is_pass[i] && graph[num][i]) dfs(i, n_pass + 1);
        }
    }
    is_pass[num] = false;
}

int main() {
    int a, b;
    cin >> N >> M;
    if(M == 0) {
        cout << 0;
        return 0;
    }
    REP(i, M){
        cin >> a >> b;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    is_pass[1] = true;
    dfs(1, 1);
    cout << count_num;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max((int)0,c-(a-b))<<endl;

  return 0;
}


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

#ifndef __HEADERS__
#define __HEADERS__

#define up(i,j,k) for (int i = j; i <= k; i++)
#define down(i,j,k) for (int i = j; i >= k; i--)

#define lb long double
#define ll long long
#define ull unsigned long long

#define mp std::make_pair
#define pb push_back

#define all(x) x.begin(), x.end()
#define lowbit(x) ((x) & (-x))
#define mem(a) memset(a, 0, sizeof(a))
#define File(x)                       \
    freopen("" #x ".in", "r", stdin); \
    freopen("" #x ".out", "w", stdout);

#endif

inline int read() {
    int data = 0, w = 1; char ch = 0;
    while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); }
    return data * w;
}

inline void print (ll v) {
    if (v < 0) { putchar('-'); v = -v; }
    if (v > 9) print(v / 10);
    putchar(v % 10 + '0');
}

const double Pi = 3.1415926535897932;

double a, b, x;

int main () {
    std::cin >> a >> b >> x;
    if (a * a * b / 2.0 > x) {
        printf("%.9lf", 90 - atan(2 * x / (a * b * b)) * 180 / Pi);
    } else {
        printf("%.9lf", 90 - atan(a * a * a / 2 / (a * a * b - x)) * 180 / Pi);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		doIt();
	}
	static void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(0 < n){
			int[] nums = new int[n];
			for(int i = 0; i < n; i++) nums[i] = sc.nextInt();
			int target = sc.nextInt();
			int max = n - 1;
			int min = 0;
			int mid = 0;
			int count = 0;
			while(0 <= max - min){
				//if(min >= max){count++;break;}
				mid = (max + min) / 2;
				count++;
				if(target == nums[mid]) break;
				else if(target < nums[mid]) max = mid - 1;
				else min = mid + 1;
			}
			System.out.println(count);
			n = sc.nextInt();
		}
	}

}

Measured memory_bytes: 12000
function Main(input) {
  input = input.split(" ");
  a = parseFloat(input[0]);
  b = parseFloat(input[1]);
  r = '';
  if (a > b) {
    for (i = 0; i < a; ++i) {
      r += b;
    }
  } else {
    for (i = 0; i < b; ++i) {
      r += a;
    }
  }
  console.log(r);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b, c, d;
        a = Integer.parseInt(sc.next());
        b = Integer.parseInt(sc.next());
        c = Integer.parseInt(sc.next());
        d = Integer.parseInt(sc.next());

        int min_1 = Math.min(a, b);
        int min_2 = Math.min(c, d);

        System.out.println(min_1 + min_2);

        sc.close();
    }
}


Measured memory_bytes: 21588
#include <stdio.h>
#include <iostream>
using namespace std;

const int maxn = 2000 + 10;

int n;
char s[maxn][maxn];
bool white[maxn], black[maxn];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)    
        scanf("%s", s[i]);
    
    bool flag = false;
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < n; j++) 
            if (s[i][j] == '#') flag = true;
    if (!flag) {
        printf("-1\n");
        return 0;
    }

    for (int j = 0; j < n; j++) {
        white[j] = false; black[j] = false;
        for (int i = 0; i < n; i++) 
            if (s[i][j] == '#') black[j] = true;
            else white[j] = true;
    }
    int ans = 2 * n;
    for (int i = 0; i < n; i++) {
        int cur = 0;
        if (!black[i]) cur++;
        for (int j = 0; j < n; j++) 
            if (s[i][j] != '#') cur++;
        ans = min(ans, cur);
    }
    for (int j = 0; j < n; j++) 
        if (white[j]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps = 0.0000001;
const int N=2200;
const int M=1e5+10;
const int mod=1e9+7;
void io(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int aa[2010];
ll p(ll a,ll b,ll mod)
{
    ll ans=0;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            ans=ans+a%mod;
        }
        a=a*2%mod;
    }
    return ans%mod;
}
int main()
{
   int n;
   ll k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
       cin>>aa[i];
   int sum=0;
   for(int i=1;i<=n;i++)
       for(int j=1;j<=n;j++)
           if(aa[i]>aa[j]) sum++;
   int summ=0;
   for(int i=1;i+1<=n;i++)
       for(int j=i+1;j<=n;j++)
       if(aa[j]<aa[i]) summ++;
    ll ans=(ll)p((ll)summ,k,mod);
    ans+=p(k*(k-1)/2,(ll)sum,mod)%mod;
    cout<<ans%mod<<endl;
}

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

int main(void){
  int n, a[4], i;

  cin >> n;
  
  for(i = 0; i < 4; i ++){
    a[i] = n%10;
    n /= 10;
  }

  if((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]))
    cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 384
from subprocess import*
call(('julia','-e',"""
const lines=readlines()
input()=shift!(lines)
int(s)=parse(Int32,s)
intLine()=map(int,split(input()))
function nextLine(k)
    x,y,c=split(input())
    int(x)%2k+1,(int(y)+(c=="W")k)%2k+1
end
function solve(k,g)
    m=0
    for i=1:2k,j=1:2k
        a=0
        for x=-1:2,y=-1:2
            (x+y)%2!=0&&continue
            v,w=i+x*k,j+y*k
            v>0<w&&(a+=g[min(2k,v)][min(2k,w)])
            v>k&&w>0&&(a-=g[min(2k,v-k)][min(2k,w)])
            w>k&&v>0&&(a-=g[min(2k,v)][min(2k,w-k)])
            v>k<w&&(a+=g[min(2k,v-k)][min(2k,w-k)])
        end
        m=max(m,a)
    end
    m
end
function main()
    n,k=intLine()
    g=Array{Int32,1}[[0for j=1:2k]for i=1:2k]
    for i=1:n
        x,y=nextLine(k)
        g[x][y]+=1
    end
    println(solve(k,cumsum(map(cumsum,g))))
end
main()
"""))

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

#define ll long long
#define forn(i,n) for(int i=0; i<n; i++)
#define fors(i,s,n) for(int i=s; i<n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()

using namespace std;

const int INF = 1e8+1;

int main(){

    int n;
    cin >> n;
    int dinero=0;
    while(n>dinero){
        dinero+=1000;
    }
    cout << dinero-n << endl;

}


Measured memory_bytes: 3628
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n = int(input())
    a = list(map(int, input().split()))
    l = [0] * n
    for i in range(n):
        cnt = 0
        while a[i] % 2 == 0:
            a[i] //= 2
            cnt += 1
        l[i] = cnt
    print(sum(l))


if __name__ == '__main__':
    main()

Measured memory_bytes: 13200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<ll>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q),r(q);
    rep(i,q)cin >> l[i] >> r[i];
    vector<int> count(n);
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            count[i+1]=count[i]+1;
        }else{
            count[i+1]=count[i];
        }
    }
    rep(i,q){
        cout << count[r[i]-1]-count[l[i]-1] << endl;
    }


}

Measured memory_bytes: 4544
def stupid():
    from itertools import permutations

    ret = float('inf')
    for p in permutations(a):
        time = 0
        for dish in p:
            time += (10 - (time % 10)) % 10
            time += dish
        ret = min(ret, time)
    return ret

a = [int(input()) for _ in range(5)]
print(stupid())

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;

int X[200001];
int X_sorted[200001];
int N;

int pick_exclude_ith(int i, int j, int* ar){
  // pick jth of X-{ith}
  if(j < i){
    return ar[j];
  }else{
    return ar[j+1];
  }
}

int main(){
  scanf("%d\n", &N);
  for(int i=0; i < N; i++){
    scanf("%d", X + i);
    X_sorted[i] = X[i];
  }

  sort(X_sorted, X_sorted + N);

  for(int i=0; i < N; i++){
    auto p_excluding = lower_bound(X_sorted, X_sorted + N, X[i]);
    int id_excluding = p_excluding - X_sorted;
    printf("%d\n", pick_exclude_ith(id_excluding, ((N-1)+1)/2 - 1, X_sorted));
  }

    
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define pb push_back

using namespace std;

const int N=100005,P=1e9+7;
typedef long long ll;

int n,ans=1,crc[N],nx[N],f0,f1,f2;
vector<int>e[N];
bool vis[N],in[N];

inline void Assert(bool f){if(!f)puts("0"),exit(0);}
int find(int x){if(in[x])return x;in[x]=true;int R=find(nx[x]);return in[x]=false,R;}
int dfs(int x){vis[x]=true;Assert(e[x].size()<=1);for(int v:e[x])return dfs(v)+1;return 1;}

void check(int x){
	int u=find(x),m=1;
	static vector<int>cr,le;
	cr.clear();cr.pb(u);in[u]=vis[u]=true;
	for(int p=nx[u];p!=u;p=nx[p])cr.pb(p),in[p]=vis[p]=true,m++;
	le.resize(cr.size());
	int f=-1;
	for(int i=0,v;i<m;i++){
		Assert(e[v=cr[i]].size()<=2);
		for(int p:e[v])if(!in[p])le[i]=dfs(p),f=i;
		if(e[v].size()==1)le[i]=0;
	}
	if(f==-1){crc[m]++;return;}
	for(int i=0;i<m;i++){
		if(le[i]){
			int dis=(i-f+m)%m;
			if(f==i)dis=m;
			Assert(dis>=le[i]);
			if(dis>le[i])ans=(ans<<1)%P;
			f=i;
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&nx[i]),e[nx[i]].pb(i);
	for(int i=1;i<=n;i++)if(!vis[i])check(i);
	for(int i=1;i<=n;i++)if(crc[i]){
		int c0=1+(i%2==1&&i>=3);
		f0=1,f1=c0;
		for(int j=2;j<=crc[i];j++){
			f2=((ll)(j*i-i)*f0%P+c0*f1)%P;
			f0=f1,f1=f2;
		}
		ans=(ll)ans*f1%P;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8824
let () =
  let rec read () =
    let line = read_line () in
    if line = "END OF INPUT" then ()
    else
      begin
        let len = String.length line in
        let rec loop cnt s i =
          if i = len then s^(string_of_int cnt)
          else
            begin
              if (Char.code line.[i]) = 32 then
                loop 0 (s^(string_of_int cnt)) (i+1)
              else
                loop (cnt+1) s (i+1)
            end
        in
        Printf.printf "%s\n" (loop 0 "" 0);
        read ()
      end
  in read ()
;;

Measured memory_bytes: 2288
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b;
    scanf("%ld%ld", &a, &b);

    if(a==b) {
        printf("Draw\n");
    }
    else if(a==1 || (b!=1 && a>b)) {
        printf("Alice\n");
    }
    else {
        printf("Bob\n");
    }

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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;
}
const int maxn = 3030;
int dp[maxn];

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int N, T, A, B;
    cin >> N >> T;
    pair<int, int> ps[N];
    for (int i = 0; i < N; ++i) {
        cin >> A >> B;
        ps[i].first = A, ps[i].second = B;
    }
    sort(ps, ps + N);
    for (auto p : ps) {
        for (int j = T - 1; j >= 0; --j) {
            dp[min(T, j + p.first)] = max(dp[min(T, j + p.first)], dp[j] + p.second);
        }
    }
    cout << dp[T] << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#define PI 3.141592653589793
 
int main(void){
    int hhand,mhand,hour,minute;
    scanf("%d %d %d %d",&hhand,&mhand,&hour,&minute);
 
    double hhandangle,mhandangle,anglediff,distance;
    
    // 短針と長針の角度から角度の差（ラジアン）を出す
    hhandangle = hour * 30 + minute * 0.5;
    mhandangle = minute * 6;
    anglediff = fabs(hhandangle-mhandangle) * PI / 180.0;
 
    // 余弦定理
    distance = sqrt(pow((double)hhand,2.0) + pow((double)mhand,2.0) - 2.0*(double)hhand*(double)mhand*cos(anglediff));
 
    printf("%.9lf\n",distance);
 
    return 0;
 
}

Measured memory_bytes: 2600
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    cout << abs(C - A) + abs(D - B) - __gcd(abs(C - A), abs(D - B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 1
#define BLACK 0
#define GLAY 3
int g[120][120];
int d[120],f[120],color[120],k[120];
int time,u,v;

void DFSVisit(int u){
  int i;
  color[u] = GLAY;
  d[u] = ++time;
  for(i = 0;i < k[u];i++){
    if(color[g[u][i]] ==  WHITE){
      DFSVisit(g[u][i]);
       }
       }
  color[u] = BLACK;
  f[u] = ++time;
}

void DFS(int x){
  int i;
  for(i = 1;i <=x; i++){
    color[i] = WHITE;
    time = 0;
      }
  for(i = 0; i < x;i++){
    if(color[i] == WHITE){
      DFSVisit(i);
    }
  }
  }

main(){
  int i,j,l,n;
  scanf("%d",&n);

  for(i = 0;i < n; i++){
    scanf("%d%d",&u,&l);
    k[u] = l;
    for(j = 0;j < k[u];j++){
      scanf("%d",&v);
      g[u][j] = v;
    }
  }


      DFS(n);
    for(i = 1; i <=n;i++){
      printf("%d %d %d\n", i,d[i],f[i]);
    }
    return 0;
  }

Measured memory_bytes: 648
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,d;
	cin>>n>>d;
	int p[11][11];
	for (int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			cin>>p[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			int dist = 0;
			for (int k = 0; k < d; k++){
				dist += (p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
			}
			for (int l = 2; l <= 130; l++){
				while(dist%(l*l)==0){
					dist/=(l*l);
				}
			}
			if(dist==1)ans++;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    ll N = (ll)S.size();

    ll ans;

    for (ll i = 1; i < N; i++) {
        if ((N - i) & 1) continue;
        string t1, t2;
        t1 = S.substr(0, (N - i) / 2);
        t2 = S.substr((N - i) / 2, (N - i) / 2);
        if (t1 == t2) {
            ans = N - i;
            break;
        }
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
H, W = map(int, input().split())


# 各文字の出現回数を数えて降順ソート
Counts = defaultdict(int)
for i in range(H):
    A = input()
    for a in A:
        Counts[a] += 1
Counts = deque(sorted(Counts.values()))


# mod4をとっておく（3は1と2にわける）
mod4 = [c % 4 for c in Counts]
for i in range(len(mod4)):
    if mod4[i] == 3:
        mod4[i] = 1
        mod4.append(2)

# 両方偶数:= 全部4の倍数
if (H % 2 == 0) and (W % 2 == 0):
    print('No' if any(mod4) else 'Yes')

# Hが奇数:= 4で割って2余るものが、W // 2個以下
elif (H % 2 == 1) and (W % 2 == 0):
    if (mod4.count(2) <= W // 2) and (set(mod4) == {0, 2}):
        print('Yes')
    else:
        print('No')

# Wが奇数:= 4で割って2余るものが、H // 2個以下
elif (H % 2 == 0) and (W % 2 == 1):
    if (mod4.count(2) <= H // 2) and (set(mod4) == {0, 2}):
        print('Yes')
    else:
        print('No')

# 両方奇数:= 4で割って2余るものが、 H // 2 + W // 2個以下、かつ1が1つ。3の扱いに注意。
else:
    if (mod4.count(2) <= (H // 2) + (W // 2)) and (mod4.count(1) == 1):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3316
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, X, inputs):
    requires = list(map(lambda x: int(x), inputs))
    count = 0
    for r in requires:
        X -= r
        count += 1
    min_r = min(requires)

    while X >= min_r:
        X -= min_r
        count += 1
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, X] = string_to_int(input())
    ret = solve(N, X, inputs(N))
    print(ret)


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int a[4],b[4];

	while( cin >> a[0] >> a[1] >> a[2] >> a[3] && cin >> b[0] >> b[1] >> b[2] >> b[3] ){
		int count = 0;
		for( int i = 0;i < 4;i++ ){
			if( a[i] == b[i] ){ count++; a[i] = b[i] = -1; }
		}
		cout << count;

		count = 0;
		for( int i = 0;i < 4;i++ ){
			if( a[i] == -1 ) continue;
			for( int j = 0;j < 4;j++ ){
				if( a[i] == b[j] ) count++;
			}
		}

		cout << " " << count << endl;
	}



	return 0;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vint x(m);
    REP(i,m)cin >> x[i];
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    sort(ALL(x));
    vint dis(m-1);
    for(int i=0;i<m-1;++i){
        dis[i] = x[i+1]-x[i];
    }
    sort(ALL(dis));
    ll ans = 0;
    REP(i,m-n){
        ans += (ll)dis[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int kei(string a, string b) {
	if (a.size() < b.size()) {
		return 0;
	}
	else if (a.size() > b.size()) {
		return 1;
	}
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] - '0' < b[i] - '0') {
				return 0;
			}
			else if (a[i] - '0' > b[i] - '0') {
				return 1;
			}
		}
		return 2;
	}
}

int main() {
	string a, b;
	cin >> a >> b;
	if (kei(a, b) == 0) {
		cout << "LESS" << endl;
	}
	else if (kei(a, b) == 1) {
		cout << "GREATER" << endl;
	}
	else {
		cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <tuple>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;
int h[200000];

signed main() {
	int i;
	
	cin >> n >> k;
	rep(i, n) cin >> h[i];
	sort(h, h + n, greater<int>());
	
	int ans = 0;
	for (i = k; i < n; i++) {
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdlib.h>
#include <algorithm> 
using namespace std;

int main() {
    int n,k;
    int h[100000];
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h,h+n);
    int min = -1;
    int diff = 0;
    for(int i = 0; i < n - k + 1; i++){
        diff = h[i+k-1] - h[i];
        if(min < 0 || min > diff)
            min = diff;
        diff = 0;
    }
    cout << min << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
    #define ll long long
    #define mod 1000000007
    using namespace std;

    int main() {
        int a,b,c,d,e,f,mw=0,ms=0;
        vector<int> x;
        vector<int> y;
        double mm = 0;
        cin>>a>>b>>c>>d>>e>>f;
        for(int i=0;i<=f;i++){
            for(int j=0;j<=f;j++){
                if(c*i+d*j<=f){
                    x.push_back(c*i+d*j);
                }
            }
        }
        for(int i=0;i<=f;i++){
            for(int j=0;j<=f;j++){
                if(100*a*i+100*b*j<=f){
                    y.push_back(100*a*i+100*b*j);
                }
            }
        }
        for(int i=0;i<x.size();i++){
            for(int j=0;j<y.size();j++){
                if(x[i]+y[j]>f)continue;
                if(x[i]>(y[j]/100)*e)continue;
                double hoge = 100.0*x[i]/(double)(x[i] + y[j]);
                if(hoge >= mm){
                    mm = hoge;
                    mw = y[j];
                    ms = x[i];
                }
            }
        }
        cout << mw+ms << " " << ms << endl;
    }

Measured memory_bytes: 1400
package main

import (
	"fmt"
	"os"
)

func main() {
	var k int
	fmt.Scan(&k)

	a := 0
	var rec func(x int, ns []int)
	rec = func(x int, ns []int) {
		for i := 0; i < len(ns)-1; i++ {
			if abs(ns[i]-ns[i+1]) > 1 {
				return
			}
		}

		if x == 0 {
			a++
			if a == k {
				for i := 0; i < len(ns); i++ {
					fmt.Print(ns[i])
				}
				fmt.Println()
				os.Exit(0)
			}
			return
		}

		for i := 0; i < 10; i++ {
			if len(ns) == 0 && i == 0 {
				continue
			}
			rec(x-1, append(ns, i))
		}
	}

	for i := 1; ; i++ {
		rec(i, []int{})
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 6656
# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
skip = set(map(int, [input().rstrip() for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in skip else 0
b = 1 if not 1 in skip else 0

for i in range(2, n + 1):
    if a == 0 and b == 0:
        print(0)
        break
    if i in skip:
        a = b
        b = 0
    else:
        tmp = b
        b = (a + b) % MOD
        a = tmp
else:
    print(b)

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

int main() {
    long long l,r;
    cin >> l >> r;
    while(r>=2019){
        r -= 2019;
        l -= 2019;
    }
    if(r-l>2019){
        cout << 0 << endl;
    }
    else{
        long long ansa;
        ansa=2e9+1;
        for(long long i=l; i<r; ++i){
            for(long long j=1+l; j<=r; ++j){
                if(((i*j)%2019)<ansa){
                    ansa = (i*j)%2019;
                }
            }
        }
    cout << ansa <<endl;
    }
}

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

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

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

using namespace std;

long long f,b,fb,t,n;
int main(){
cin>>n;
t=(1+n)*n/2;
for(int i=1;i<=n;i++){if(i%3==0 && i%5==0)fb+=i;else if(i%3==0)f+=i; else if(i%5==0)b+=i;
}
cout<<t-b-f-fb;
return 0;
} 

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

int main() {
 vector<int> row1(3);
 vector<int> row2(3);
 vector<int> row3(3);
  for(int i=0 ; i<3; i++){
  cin >> row1.at(i);
  }
  for(int i=0 ; i<3; i++){
  cin >> row2.at(i);
  }
  for(int i=0 ; i<3; i++){
  cin >> row3.at(i);
  }
  int N;
  cin >> N;
 vector<int> num(N);
  for(int i=0 ; i<N; i++){
  cin >> num.at(i);
  }
  for(int j=0; j<3; j++){
  	for(int i=0; i<N; i++){
  		if( num.at(i) ==  row1.at(j) ){
      	row1.at(j) = 0;
  		}
  	}
  }
  for(int j=0; j<3; j++){
  	for(int i=0; i<N; i++){
  		if( num.at(i) ==  row2.at(j) ){
      	row2.at(j) = 0;
  		}
  	}
  }
  for(int j=0; j<3; j++){
  	for(int i=0; i<N; i++){
  		if( num.at(i) ==  row3.at(j) ){
      	row3.at(j) = 0;
  		}
  	}
  }
  bool bingo;
  if(row1.at(0) == row1.at(1) && row1.at(1) == row1.at(2) ||
     row2.at(0) == row2.at(1) && row2.at(1) == row2.at(2) ||
     row3.at(0) == row3.at(1) && row3.at(1) == row3.at(2) ||
     row1.at(0) == row2.at(0) && row2.at(0) == row3.at(0) ||
     row1.at(1) == row2.at(1) && row2.at(1) == row3.at(1) ||
     row1.at(2) == row2.at(2) && row2.at(2) == row3.at(2) ||
     row1.at(0) == row2.at(1) && row2.at(1) == row3.at(2) ||
     row1.at(2) == row2.at(1) && row2.at(1) == row3.at(0) ){
  bingo = true;
  }
  else{
  bingo = false;
  }
  if(bingo){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int n, m, a[1000000], s = 0;
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        cin >> a[i];
        s += a[i];
    }
    if(n < s) {
        cout << -1;
        return 0;
    }
    cout << n-s;
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    int N,K;
    GI(N);GI(K);
    vector<LL> h(N);
    REP(i,N)
        GI(h[i]);
    sort(ALL(h));
    LL ans = LLMAX;
    REP(i,N-K+1)
        ans = min(ans, h[i+K-1]-h[i]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N;
cin >> N; 
int a[114]; 
for(int i = 0; i < N; i++){
cin >> a[i]; 
}
sort(a, a + N);
cout << a[N-1] - a[0] << endl; 
}

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

using namespace std;

struct Restaurent {
    int id;
    string city;
    int score;
};


bool comp(Restaurent a,Restaurent b) {
   if(a.city == b.city) {
     return a.score > b.score;
   }
   else return a.city < b.city;
}

int main()
{
    int n;
    cin>>n;
    Restaurent restaurents[n];
    for(int i = 0;i < n;i++) {
        restaurents[i].id = i + 1;
        cin>>restaurents[i].city>>restaurents[i].score;
    }
    sort(restaurents,restaurents + n,comp);
    for(int i = 0;i < n;i++) cout<<restaurents[i].id<<endl;
    return 0;
}


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

int main(int argc, char const *argv[]) {
    string s, t;
    cin >> s >> t;

    int ans = 1000000;
    for (size_t i = 0; i <= s.size() - t.size(); i++) {
        int diff = 0;
        for (size_t j = 0; j < t.size(); j++) {
            if (s[i+j] != t[j]) diff++;
        }
        ans = min(ans, diff);
    }

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


Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr LL INF = 1LL << 60;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,m,l;
    cin >> n >> m >> l;
    VVLL es(n,VLL(n,INF));
    int a,b,c;
    REP(i,0,m) {
        cin >> a >> b >> c;
        if (c > l) continue;
        --a; --b;
        es[a][b] = min(es[a][b], (LL)c);
        es[b][a] = min(es[b][a], (LL)c);
    }
    REP(k,0,n) REP(i,0,n) REP(j,0,n) es[i][j] = min(es[i][j], es[i][k] + es[k][j]);
    VVLL d(n,VLL(n));
    REP(i,0,n) REP(j,0,n) d[i][j] = (es[i][j] <= l) ? 1 : (1<<30);
    REP(k,0,n) REP(i,0,n) REP(j,0,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int s,t,q;
    cin >> q;
    REP(i,0,q) {
        cin >> s >> t;
        --s; --t;
        if (d[s][t] == (1<<30)) cout << -1 << endl;
        else cout << d[s][t] - 1 << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

ll N, M;

int main(){
   cin >> N >> M;
   vector<ll> X(M);
   REP(i, M) cin >> X[i];
   SORT(X);
   ll temp = X[M - 1] - X[0];
   vector<ll> Y(M - 1);
   REP(i, M - 1) Y[i] = X[i + 1] - X[i];
   SORT(Y);
   ll ans = 0;
   REP(i, M - N) ans += Y[i];
   cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2){
      if(s[i]=='R'){
        cout<<"No";return 0;
      }
    }else{
      if(s[i]=='L'){
        cout<<"No";return 0;
      }
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string S;
    long long K;
    cin >> S >> K;

    int index_of_first_non_one_letter = -1;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != '1') {
            index_of_first_non_one_letter = i;
            break;
        }
    }

    if (index_of_first_non_one_letter != -1 && K >= index_of_first_non_one_letter + 1) {
        cout << S[index_of_first_non_one_letter] << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const ll maxn=1e9+7;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int ans1=0,ans2=0,t=0;
    for(int i=0;i<n;i++){
        if(a[i]>ans1){
            ans1=a[i];
            t=i;
        }
        else{
            if(ans2<a[i]&&a[i]<=ans1) ans2=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(i!=t) cout<<ans1<<endl;
        else cout<<ans2<<endl;
    }
    return 0;
}


Measured memory_bytes: 2432
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (n, m) = (int() as i32, int() as i32);
    let mut a = Vec::new();
    for _ in 0..n {
        a.push((int() as i32, int() as i32));
    }
    let mut c = Vec::new();
    for _ in 0..m {
        c.push((int() as i32, int() as i32));
    }

    for (x, y) in a {
        let min = c
            .iter()
            .zip((1..(m + 1)))
            .map(|(c, i)| ((x - c.0).abs() + (y - c.1).abs(), i))
            .fold((0, -1), |(xdis, xi), (dis, i)| {
                if xi == -1 {
                    (dis, i)
                } else {
                    if dis < xdis {
                        (dis, i)
                    } else {
                        (xdis, xi)
                    }
                }
            });
        println!("{}", min.1)
    }
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(X: int, A: int):
    if(X >= A):
        print(10)
    else:
        print(0)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(X, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
suite = ["S", "H", "C", "D"]

for i in range(n):
    p,r = input().split()
    r = int(r)
    for j in range(n):
        cards[suite.index(p)][r - 1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(suite[i], j + 1)



Measured memory_bytes: 5604
A,B,K = map(int,input().split())

_ = set()
for i in range(A,A+K,1):
  if (i >= A) and (i <= B):
    _.add(i)

for i in range(B,B-K,-1):
  if (i >= A) and (i <= B):
    _.add(i)
  
_ = sorted(_)
for i in _:
  print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac.resize(M + 1);
    finv.resize(M + 1);
    inv.resize(M + 1);

    fac.at(0) = 1, finv.at(0) = 1, inv.at(0) = 1;
    fac.at(1) = 1, finv.at(1) = 1, inv.at(1) = 1;

    for (ll i = 2; i <= M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

int main()
{
  combination com(400400);

  ll N, K;
  cin >> N >> K;

  if (K >= N - 1)
    FINALANS(com.H(N, N));
  
  if (K == 1)
    FINALANS(N * (N - 1) % MOD);

  ll ans = 0;
  for (ll k = 0; k <= K; k++)
  {
    ll tmp = com.C(N, k) * com.H(N - k, k) % MOD;
    ans += tmp, ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9728
N=int(input())
a=list(map(int,input().split()))
flag=0
ans=1
if min(a)==0:
    ans=0
else:
    for x in a:
        ans*=x
        if ans>10**18:
            flag=1
            break
if flag==1:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 21556
from sys import stdin                                                                                                                                                                                       
N = int(stdin.readline().rstrip())                                                                                                                                                                          
a = [int(x) for x in stdin.readline().rstrip().split()]                                                                                                                                                     
ans = 0                                                                                                                                                                                                     
for x in a:                                                                                                                                                                                                 
    ans += x -1                                                                                                                                                                                             
print(ans)

Measured memory_bytes: 3316