akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>

using namespace std;

int read(){
    int sum = 0;
    char ch;
    while((ch = getchar()) != '\n') sum += ch - '0';
    return sum;
}

int main(){
    int a;
    while(a = read()){
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
int main(){
    ll n; cin>>n;
    set<ll> s;
    for(ll i=0;i<n;i++){
        ll x; cin>>x;
        s.in(x);
    }
    if(s.size()==n)
        cout<<"YES";
    else cout<<"NO";
    
    return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    YES(a[0] == 5 && a[1] == 5 && a[2] == 7);

    return 0;
}



Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:], i8)")
def binary_search(a, key):
    """Meguru type binary search"""
    ok = -1
    ng = len(a)

    while (ng - ok > 1):
        mid = (ok + ng) // 2
        if a[mid] <= key:
            ok = mid
        else:
            ng = mid

    return ok


def main():
    N, M, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

    B_cumsum = np.cumsum(B)
    ans = 0
    time = 0
    for i in range(N + 1):
        if time > K:
            break
        j = binary_search(B_cumsum, K - time) + 1
        ans = max(ans, i + j)

        if i < N:
            time += A[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 140900
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const int INF = 1e9 + 10;

struct LIS {
  vector<int> dp;
  vector<pair<int, int>> hist;
  LIS(int n): dp(n, INF) {}
  void push(int x) {
    int p = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), x));
    hist.emplace_back(p, dp[p]);
    dp[p] = x;
  }
  int value() const {
    return distance(dp.begin(), lower_bound(dp.begin(), dp.end(), INF));
  }
  void rollback() {
    assert(!hist.empty());
    auto p = hist.back();
    hist.pop_back();
    dp[p.fst] = p.snd;
  }
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (~scanf("%d", &N)) {
    vector<int> A(N);
    for (auto& x : A) scanf("%d", &x);
    vec<int, 2> G(N);
    for (int i = 0; i < N - 1; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    LIS lis(N);
    vector<int> res(N);
    auto dfs = [&](auto& dfs, int v, int p = -1) -> void {
      lis.push(A[v]);
      res[v] = lis.value();
      for (int u : G[v]) {
        if (u != p) {
          dfs(dfs, u, v);
        }
      }
      lis.rollback();
    };
    dfs(dfs, 0);
    for (int x : res) printf("%d\n", x);
  }
  return 0;
}


Measured memory_bytes: 35104
#include <stdio.h>
using namespace std;
 
int main(){
    int x, y;
    for(int i = 1; ;i++){
        scanf("%d %d",&x, &y);
        if(x == 0 and y == 0) break;
        if(x>y){
            printf("%d %d\n",y,x);
        }else{
            printf("%d %d\n",x,y);
        }
    }
}


Measured memory_bytes: 2580
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- kaigyousuuretu
    cs <- map show <$> map strToInteger <$> replicateM 2 getLine
    let fs = cs!!0
        sn = cs!!1
    if (length fs) == (length sn)
        then putStrLn $ solve fs sn
        else case compare (length fs) (length sn) of
            LT -> putStrLn "LESS"
            EQ -> putStrLn "EQUAL"
            GT -> putStrLn "GREATER"

solve :: String -> String -> String
solve [] [] = "EQUAL"
solve [] _ = "LESS"
solve _ [] = "GREATER"
solve (f:fs) (s:sn) = case compare f s of
    GT -> "GREATER"
    LT -> "LESS"
    EQ -> solve fs sn


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

#define _LL long long
#define rep(i, n) for(_LL i = 0; i < (_LL)(n); i++)

int main()
{
    _LL n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    _LL dist = 1;
    _LL c = 0;
    pair<_LL, _LL>* info = new pair<_LL, _LL>[n+1];
    info[0] = make_pair(0, 0);
    for( c = 0; dist <= n; c++ )
    {
        if( c >= dist )
        {
            cout << -1 << endl;
            return 0;
        }
        if( s[c] == '1' ) continue;
        for( _LL l = dist; l <= c + m && dist <= n; l++)
        {
            info[dist++] = make_pair(info[c].first + 1, c);
        }
    }
    c = n;
    _LL* ans = new _LL[info[n].first + 1];
    while( c > 0 )
    {
        ans[info[c].first] = c - info[c].second;
        c = info[c].second;
    }
    for( _LL i = 1; i <= info[n].first; i++ )
    {
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 6048
p = int(1e9)+7
N = int(input())
c = 1
for i in range(N):
    c = (c*10)%p
d = 1
for i in range(N):
    d = (d*9)%p
e = 1
for i in range(N):
    e = (e*8)%p
print((c-(d*2-e))%p)

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


int main(){
int n ,k ;
cin >> n >> k;
if(n%k==0) cout << 0 << endl;
else cout << 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
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 = sc.nextInt();
		int y = sc.nextInt();

		List<Integer> listX = new ArrayList<>();
		List<Integer> listY = new ArrayList<>();
		for(int i=0;i<n;i++){
			listX.add(sc.nextInt());
		}
		for(int i=0;i<m;i++){
			listY.add(sc.nextInt());
		}

		Collections.sort(listX);

		Collections.sort(listY);
		
		// System.out.println(listX.get(n-1));
		// System.out.println(listY.get(0));

		if(listX.get(n-1)<listY.get(0)){
			if(listY.get(0) > x && listX.get(n-1) < y ){
				System.out.println("No War");
			}else{
				System.out.println("War");
			}
		}else{
			System.out.println("War");
		}



	}
}

Measured memory_bytes: 22612
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long ans[300000] = {};
int main() {
	int n;
	cin >> n;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	vector<int> pre = inputs;
	for (int i = 1; i < pre.size(); ++i) {
		int hoge = pre[i-1];
		pre[i] -= hoge;
		pre[i - 1] -= hoge;
	}
	int nya = (pre[pre.size() - 1]-pre[0]) / 2 + pre[0];
	ans[0] = nya*2;
	inputs[0] -= nya;
	inputs[inputs.size() - 1] -= nya;
	for (int q = 1; q < inputs.size(); ++q) {
		int hoge = inputs[q - 1];
		inputs[q - 1] -= hoge;
		inputs[q] -= hoge;
		ans[q] = hoge * 2;
	}
	REP(i, inputs.size()) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
int   x,y;
cin>>x>>y;
stringstream ss,dd;
ss<<x;
dd<<y;
string q,first,w,second;
ss>>q;
dd>>w;

for(int i=0;i<y;i++){
     first = first+q;
}

for(int i=0;i<x;i++){
second = second+w;
}
if(x<y){
    cout<<first;
}
else if(x>y){
    cout<<second;
}
else{
    cout<<second;
}
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin>>n;
  for(int i=0;i<3;i++){
    if(n[i]=='1'){
      n[i]='9';
    }else{
      n[i]='1';
    }
  }
  cout<<n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
const ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    int n,m;
    ll k;
    cin>>n>>m>>k;
    ll a[n+1],b[m+1];
    ll pref1[n+1],pref2[m+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i==1) pref1[i]=a[i];
        else pref1[i]=pref1[i-1]+a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        if(i==1) pref2[i]=b[i];
        else pref2[i]=pref2[i-1]+b[i];
    }
    int ans=0;
    int j=m;
    pref1[0]=0;
    for(int i=0;i<=n;i++){
        if(pref1[i]>k) break;
        while(j!=0 && pref1[i]+pref2[j]>k){
            j--;
        }
        ans=max(ans,i+j);
    }
    cout<<ans;
}

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

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

    for (int i = 0; i < S.size(); i++)
    {
        S[i] = 'A' + ((S[i] - 'A' + N) % 26);
    }
    cout << S << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner(System.in);
		Integer ans[] = {1,1,1,1,1} ;
		int count = 0;
		while (sc.hasNext()) {
			int num = sc.nextInt();
			ans[count] = num;
			count++;
			if(count==5){
				System.out.println(strkn(ans));
				break;
			}
		}
	}
	public static String strkn(Integer[] ans){
		Arrays.sort(ans, Comparator.reverseOrder()); // ???????????????
		String result = ans[0].toString() +" "+ ans[1].toString() +" "+ ans[2].toString() +" "+ ans[3].toString() +" "+ ans[4].toString();
		return result;
	}
}

Measured memory_bytes: 26140
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc082/submissions/7855589を参考にも作成
 */
public class Main {

	/** 方向変換するときの文字 */
	private static final char TRANSFER = 'T';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int x = scanner.nextInt(), y = scanner.nextInt();
			int[][] step = new int[2][s.length / 2 + 1];
			IntStream.range(0, 2).forEach(i -> Arrays.fill(step[i], 0));
			// X軸ステップとY軸ステップ数の数
			int[] number = new int[2];
			number[0] = 0;
			number[1] = 1;
			int current = 0, count = 0;
			for (char c : s) {
				if (TRANSFER == c) {
					step[current][number[current]] = count;
					number[current]++;
					count = 0;
					current = 1 - current;
				} else {
					count++;
				}
			}
			if (count > 0) {
				step[current][number[current]] = count;
				number[current]++;
			}
			int n = s.length;
			boolean[][][] dp = new boolean[2][Math.max(number[0], number[1])][2 * n + 1];
			dp[0][0][n + step[0][0]] = dp[1][0][n] = true;
			IntStream.range(0, 2)
					.forEach(i -> IntStream.range(1, number[i])
							.forEach(j -> IntStream.range(0, 2 * n + 1)
									.forEach(k -> dp[i][j][k] = ((k - step[i][j] >= 0) && dp[i][j - 1][k - step[i][j]])
											|| ((k + step[i][j] <= 2 * n) && dp[i][j - 1][k + step[i][j]]))));
			System.out.println((dp[0][number[0] - 1][n + x] && dp[1][number[1] - 1][n + y]) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 181288
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  ll ans = 0;
  for (int num = 1; num < 101; num++) {
    bool pooring = false;
    REP(i,N){
      if(num<=h[i]){
        pooring = true;
      }else{
        if(pooring){
          pooring = false;
          ans++;
        }
      }
    }
    if (pooring) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
ABCD=int(input())
A=(ABCD//1000)
B=(ABCD//100)-(A*10)
C=(ABCD//10)-(A*100)-(B*10)
D=ABCD-(A*1000)-(B*100)-(C*10)

if (A+B+C+D)==7:
  print('%d+%d+%d+%d=7' %(A,B,C,D))
  exit()
if (A+B+C-D)==7:
  print('%d+%d+%d-%d=7' %(A,B,C,D))
  exit()
if (A+B-C+D)==7:
  print('%d+%d-%d+%d=7' %(A,B,C,D))
  exit()
if (A+B-C-D)==7:
  print('%d+%d-%d-%d=7' %(A,B,C,D))
  exit()
if (A-B+C+D)==7:
  print('%d-%d+%d+%d=7' %(A,B,C,D))
  exit()
if (A-B-C+D)==7:
  print('%d-%d-%d+%d=7' %(A,B,C,D))
  exit()
if (A-B+C-D)==7:
  print('%d-%d+%d-%d=7' %(A,B,C,D))
  exit()
if (A-B-C-D)==7:
  print('%d-%d-%d-%d=7' %(A,B,C,D))
  exit()

Measured memory_bytes: 3064
def shuffle(cards,shuffleNum)
    cards[shuffleNum..-1] +cards[0..shuffleNum-1]
end
while true do
    cards = gets.chomp
    break if cards=="-"
        num = gets.to_i
        num.times   do
        shuffleNum =gets.to_i
        cards = shuffle(cards,shuffleNum)      

                    end
        if cards[-1]=="-"
    puts cards
else
    puts cards[0..-1]
        end
end



Measured memory_bytes: 6888
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
        int n = sc.nextInt();
        if(n==0)break;
        int[] scores = new int[n];
        for(int i=0;i<scores.length;i++){
            scores[i] = sc.nextInt();
            }
            double sum=0,ave=0,vars=0,var=0;
        for(int i=0;i<n;i++){
            sum = sum+scores[i];
        }
        ave = (double)sum /n;
        for(int i=0;i<n;i++){
            vars = vars+((scores[i]-ave)*(scores[i]-ave));
        }
        var = (double)vars/n;
        System.out.println(Math.sqrt(var));
        }
    }
}



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

int divisor(long long N) {
	vector<long long> res;
	
	for (long long a = 1; a*a <= N; a++) {
		if (N%a != 0) continue;

		long long b = N / a;

		if (b == a)
			res.push_back(a);
		else {
			res.push_back(a);
			res.push_back(b);
		}
	}

	return res.size();
}

int main(void) {
	
	long long N;

	cin >> N;
	int c = 0;

	for (long long i = 1; i <= N; i = i + 2){
		int a = divisor(i);
		if (a == 8)
			c++;
	}

	cout << c << endl;

}

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

int main(){
  int N; cin>>N;
  int dp[3][N];
  //最後がa,b,cの場合に分けてdp
  int a,b,c;
  for(int i=0;i<N;i++){
    cin>>a>>b>>c;
    if(i==0){
      dp[0][i]=a; dp[1][i]=b; dp[2][i]=c; continue;
    }
    dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a;
    dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b;
    dp[2][i]=max(dp[1][i-1],dp[0][i-1])+c;
  }
  a=max(dp[0][N-1],dp[1][N-1]);
  b=max(a,dp[2][N-1]);
  cout << b << endl;
}

Measured memory_bytes: 1408
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_array<T: FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n = read();
    let a = read_array::<u32>(n);
    let mut ans = 100;
    for mut x in a {
        let mut cnt = 0;
        while x % 2 == 0 {
            x /= 2;
            cnt += 1;
        }
        if cnt < ans { ans = cnt; }
    }
    println!("{}", ans);
}


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


int main() {
    int n;
    cin >> n;
    vector<int> a;
    rep(i,3*n){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }

    sort(a.begin(), a.end(), greater<>());

    ll ans = 0;
    rep(i,n){
        ans += a[2*i+1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    int N;
    LL x;
    cin >> N >> x;
    vector<LL> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 0;
    while (res < N and x >= a[res]) x -= a[res], res++;
    if (res == N and x > 0) res--;
    cout << res << "\n";
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
        cout << c << endl;
    }
    if(a==c){
        cout << b << endl;
    }
    if(b==c){
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php

while (true) {

// 1. 学生の点数全体の平均値を出す

    //    学生の数nを取得
    $n = intval(trim(fgets(STDIN)));

    //    学生の数nが0のとき処理をやめる
    if ($n == 0) break;

    //    学生ごとの得点をあらわす文字列を取得＞配列にする
    $scores = explode(' ', trim(fgets(STDIN)));

    //    平均点
    $average = array_sum($scores) / $n;


// 2. 偏差（それぞれの学生の得点から平均値を差し引いた値）を求める
// 3. 2で算出した偏差を2乗する
// 4. 3で出した偏差の合計を出す

    //分散（変数）を初期化
    $disperation = 0;

    //得点を一つずつ取り出して、偏差を求める　→　2乗する　→足し上げて＝合計して分散変数に入れる
    foreach ($scores as $score) $disperation += pow($score - $average, 2);


// 5. 偏差の合計をデータの総数で割って分散を求める　→　分散変数に再代入
    $disperation /= $n;

// 6. 5で出した分散の正の平方根を求めて標準偏差を算出する
    // ※マイナスの数値でもプラスにしなければならない
    // ※小数点以下9桁以降は表示しないようにする
    echo sprintf("%.9f\n", abs(sqrt($disperation)));

}



Measured memory_bytes: 9640
#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() {
    ll N, K;
    cin >> N >> K;

    if (K > (N - 1) * (N - 2) / 2) {
        cout << -1 << endl;
    }
    else {
        vector<Pii> edges;
        for (ll i = 2; i <= N; i++) {
            edges.emplace_back(1, i);
        }

        ll cnt = (N - 1) * (N - 2) / 2;
        ll ucur = 2, vcur = 3;
        while (cnt > K) {
            edges.emplace_back(ucur, vcur);
            --cnt;
            if (vcur < N)
                ++vcur;
            else {
                ++ucur;
                vcur = ucur + 1;
            }
        }

        cout << edges.size() << "\n";
        for (const auto& p : edges) {
            cout << p.first << " " << p.second << "\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: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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 fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S, T;
	cin >> N >> S >> T;

	REP(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;

	return 0;
}



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



int main() {
    
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    
    for (int i=0; i<N; i++) {
        cin >> x[i];
    }
    for (int i=0; i<M; i++) {
        cin >> y[i];
    }
    
    
    
    for (int Z=X+1; Z<=Y; Z++) {
        bool flag1 = true, flag2 = true;
        for (int i=0; i<N; i++) {
            if (x[i] >= Z) {
                flag1 = false;
                break;
            }
        }
        for (int i=0; i<M; i++) {
            if (y[i] < Z) {
                flag2 = false;
                break;
            }
        }
            
        if (flag1 && flag2) {
            cout << "No War" << endl;
            return 0;
        }
        
    }
    
    cout << "War" << endl;
    
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265

typedef struct{
  double x;
  double y;
}xy;
void kock(int,xy,xy);
int main()
{
  int n;
  xy m,l;
  m.x=0;
  m.y=0;
  l.x=100;
  l.y=0;

  scanf("%d",&n);
  if(n==0)
    {
      scanf("%d",&n);
    }
  printf("%.8f %.8f\n",m.x,m.y);
  kock(n,m,l);
  printf("%.8f %.8f\n",l.x,l.y);
  return 0;
}

void kock(int n,xy m,xy l)
{
  xy a,b,c;
  if(n==0)
    {
      return;
    }
  a.x=(l.x+2*m.x)/3;
  a.y=(l.y+2*m.y)/3;
  c.x=(2*l.x+m.x)/3;
  c.y=(2*l.y+m.y)/3;
  b.x=(c.x-a.x)*cos(PI/3)-(c.y-a.y)*sin(PI/3)+a.x;
  b.y=(c.y-a.y)*cos(PI/3)+(c.x-a.x)*sin(PI/3)+a.y;

  kock(n-1,m,a);
  printf("%.8f %.8f\n",a.x,a.y);
  kock(n-1,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  kock(n-1,b,c);
  printf("%.8f %.8f\n",c.x,c.y);
  kock(n-1,c,l);
  return;
}



Measured memory_bytes: 2108
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  std::string s;
  std::string::iterator it;
  std::cin >> s;

  char min_char = 'z';
  std::map< char, bool > mc;
  for (char c = 'a'; c <= 'z'; c++) {
    mc[c] = true;
  }

  for (it = s.begin(); it != s.end(); it++) {
    mc[*it] = false;
  }

  std::string ans = "None";
  for (char c = 'a'; c <= 'z'; c++) {
    if (mc[c] == true) {
      ans = c;
      break;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


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

typedef long long LL;
const int maxn = 1000010;
const LL INF = 100000000000000LL;
const LL mod = 998244353;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)

int n;
LL C[maxn];
LL ni[maxn];
LL quick_power(LL a, LL n) {
    LL sum = 1;
    while(n) {
        if(n&1)
            sum = sum * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return sum;
}

void solve() {
    LL A, B;
    LL K;
    cin >> A >> B >> K;
    LL ans = 0;
    for(LL i = 1;i <= n;i++) {
        ni[i] = quick_power(i, mod -  2) % mod;
    }
    C[0] = 1;
    for(LL i = 1;i <= n;i++) {
        C[i] = C[i - 1] * (n - i + 1) % mod * ni[i] % mod;
    }
    for(LL i = 0, numa, numb;i <= n;i++) {
        numa = i;
        numb = (K - numa * A) / B;
        if(numa > n || numb > n) continue;
        if(numa * A + numb * B == K) {
            ans = (ans + C[numa] * C[numb] % mod) % mod;
        }
    }
    cout << ans % mod << endl;
}

int main() {
	int t = 1;
	while(~scanf("%d",&n)) {
		solve();
	}/*
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;*/
    return 0;
}


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

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] R = Console.ReadLine().Split(' ');
        string S = R[0];
        string T = R[1];
        string result="";
        for(int i = 0; i < N; i++)
        {
            result += S[i].ToString() + T[i].ToString();
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13140
x = input()

a = 1
b = 1
other = '0'

for i in range(1,4):
  if x[0] == x[i]:
    a += 1
  else:
    if other == x[i]:
      b += 1
    else:
      other = x[i]
      
if a == b == 2:
  print("Yes")
else:
  print("No")

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
#define mins(a,...) a = min<decltype(a)>({a, ## __VA_ARGS__})
#define maxs(a,...) a = max<decltype(a)>({a, ## __VA_ARGS__})
#define plusMod(a,b) a = (a % mod + b % mod) % mod
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) {
    return os.put(os.widen('\n'));
}
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

int n, m, k[15], s[15][15], p[15];
void solve() {
    cin >> n >> m;

    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> s[i][j];
            --s[i][j];
        }
    }

    rep(i, m)
        cin >> p[i];

    int ans = 0;
    rep(l, 1 << n) {
        bool ok = true;
        rep(i, m) {
            int res = 0;
            rep(j, k[i]) {
                if ((l >> s[i][j]) & 1)
                    ++res;
            }

            if (res % 2 != p[i]) {
                ok = false;
                break;
            }
        }

        if (ok)
            ++ans;
    }

    cout << ans << endn;

}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 892
N, M = gets.chomp.split(" ").map(&:to_i);
CAV = []
(N + 1).times{|i| CAV << []}
M.times{|i|
  f, t = gets.chomp.split(" ").map(&:to_i);
  CAV[f] << t
}

expect = Array.new(N + 1, 0.0)
BRN = Hash.new
(N + 1).times{|i| BRN[i] = CAV[i].size}

(N - 1).downto(1){|rom|
  expect[rom] = CAV[rom].inject(0){|rst, cav| rst += expect[cav]}.to_f / BRN[rom] + 1
}
dm = 0  #difference max
BRN.sort_by{|k, v| v}.each{|rom, branch|
  next if branch <= 1  #can't remove
  dif = Array.new(N + 1, 0.0)
  dif[rom] = (CAV[rom].map{|to| expect[to]}.max - expect[rom] + 1) / (branch - 1)
  next if dif[rom] < dm
  (rom - 1).downto(1){|i|
    dif[i] = CAV[i].inject(0){|rst, cav| rst += dif[cav]}.to_f / BRN[i]
  }
  dm = dif[1] if dif[1] > dm
}

puts expect[1] - dm


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



Measured memory_bytes: 2068
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

int main() {
	int n, i, count, m, sum_count=0;
	vector<int>a;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> m;
		a.push_back(m);
	}

	sort(a.begin(), a.end());
	
	m = a[0];
	count = 1;

	for (i = 1; i < n; i++) {
		if (m != a[i]) {
			if (count > a[i - 1]) {
				sum_count += count - a[i - 1];
			}
			else if (count < a[i - 1]) {
				sum_count += count;
			}
			m = a[i];
			count = 1;
		}
		else {
			count++;
		}
	}
	if (count > a[i - 1]) {
		sum_count += count - a[i - 1];
	}
	else if (count < a[i - 1]) {
		sum_count += count;
	}

	cout << sum_count;

	return 0;
}

Measured memory_bytes: 892
#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; }

int n;

ll sq(ll num){
	return num*num;
}

ll mod_pow(ll x, ll n, ll m){
	if (n == 0)return 1;
	if (n == 1)return x%m;

	ll res = sq(mod_pow(x, n / 2, m));
	res %= m;
	if (n % 2 == 1){
		res *= x;
		res %= m;
	}
	return res;
}


int main(){
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(ALL(a));
    ll ans = mod_pow(2,n/2,MOD);
    if(n % 2 == 0){
        ll cnt = 0;
        for(int i = 0;i < n;i += 2,cnt++){
            if(a[i] != 2*cnt+1 || a[i+1] != 2*cnt+1)ans = 0;
        }
    }
    else{
        if(a[0] != 0)ans = 0;
        ll cnt = 1;
        for(int i = 1;i < n;i += 2,cnt++){
            if(a[i] != 2*cnt || a[i+1] != 2*cnt)ans = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;

int main() {
  int N;
  double R;
  set< Pi > sets;
  cin >> N >> R;
  for(int i = 0; i < N; i++) {
    double A, B;
    cin >> A >> B;
    sets.insert(make_pair((A + 1e6) / R, (B + 1e6) / R));
  }
  int ret = 0;
  while(!sets.empty()) {
    ++ret;
    set< Pi >::iterator it1 = sets.begin();
    for(int i = -1; i <= 1; i++) {
      for(int j = -1; j <= 1; j++) {
        if(i == 0 && j == 0) continue;
        set< Pi >::iterator it2 = sets.find(make_pair(it1 -> first + i, it1 -> second + j));
        if(it2 != sets.end()) {
          sets.erase(it2);
        }
      }
    }
    sets.erase(it1);
  }
  cout << ret << endl;
}

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

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

  double theta = abs((h+m/60.0)*M_PI/6 - m*M_PI/30);

  if(theta>M_PI) theta = 2*M_PI - theta;
  
  double c = sqrt(a*a + b*b - 2*a*b*cos(theta));

  cout<<fixed<<setprecision(10)<<c<<endl;

  return 0;
}

Measured memory_bytes: 4228
import sys
sys.setrecursionlimit(500000)

n,k = map(int,input().split())
D = list(map(int,input().split()))

ans = []
def dfs(p:str):
    if int(p)>=n:
        ans.append(int(p))
        return

    if len(p)>len(str(n))+1:
        return

    for i in range(10):
        if not i in D:
            dfs(p+str(i))

for i in range(10):
    if not i in D:
        dfs(str(i))

print (min(ans))


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector <int> v={a,b,c};
  sort(v.begin(),v.end());
  if((v.at(0)==5)&&(v.at(1)==5)&&(v.at(2)==7)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// AOJ 0526: Boat Travel
// 2017.9.1 bal4u@uu
// 2018.1.22

#include <stdio.h>
#include <string.h>

#define INF 0x10101010
int fee[101][101];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, k, a, b, c, d, e, t;

	while (n = in()) {
		k = in();
		memset(fee, INF, sizeof(fee));
		for (a = 1; a <= n; a++) fee[a][a] = 0;

		while (k-- > 0) {
			if (in()) {
				a = in(), b = in(), e = in();
				if (fee[a][b] > e) {
					fee[a][b] = fee[b][a] = e;
					for (c = 1; c <= n; c++) for (d = c+1; d <= n; d++) {
						t = fee[c][a] + e + fee[b][d];
						if (t < fee[c][d]) fee[c][d] = fee[d][c] = t;
						t = fee[c][b] + e + fee[a][d];
						if (t < fee[c][d]) fee[c][d] = fee[d][c] = t;
					}
				}
			} else {
				a = in(), b = in();
				if ((e = fee[a][b]) >= INF) e = -1; 
				printf("%d\n", e);
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2028
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,sum=0,day=0,i;
    cin>>a>>b>>c;
    while(sum<c){
        sum+=a;
        day++;
        i++;
        if(i==7){
            i=0;
            sum+=b;
        }
    }
    cout<<day<<endl;
}



Measured memory_bytes: 3084
# abc 157
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().strip())

if (N % 2) == 0:
    answer = int(N / 2)
else:
    answer = int((N + 1)/ 2)

print(answer)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n, d, x = 0, a;
    std::cin >> n >> d >> x;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a;
        for (int j = 1; j <= d; j += a) { x++; }
    }
    std::cout << x << std::endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define all(a) a.begin(), a.end()

typedef long long lint;

const lint INF = 1e12 + 9LL;

struct edge {
    int A, B;
    lint C;
};

int N, M;
lint T;
lint dist[2509];

vector<edge> edges;

int main() {
    scanf("%d%d%lld", &N, &M, &T);
    rep(i, M) {
        int A, B;
        lint C;
        scanf("%d%d%lld", &A, &B, &C);
        edges.push_back({A, B, T - C});
    }
    rep(i, N) dist[i + 1] = INF;
    dist[1] = 0LL;
    rep(i, N - 1) {
        rep(j, M) {
            edge e = edges[j];
            if (dist[e.A] != INF && dist[e.B] > 1LL * dist[e.A] + 1LL * e.C) {
                dist[e.B] = 1LL * dist[e.A] + 1LL * e.C;
            }
        }
    }
    rep(i, N - 1) {
        rep(j, M) {
            edge e = edges[j];
            if (dist[e.A] != INF && dist[e.B] > dist[e.A] + e.C) {
                dist[e.B] = -INF;
            }
        }
    }
    if (dist[N] == -INF) printf("-1\n");
    else printf("%lld\n", max(0LL, -dist[N]));
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; in(N); in(M);

  int x[M];
  rep(i, M) in(x[i]);
  sort(x, x+M);

  priority_queue<int> q;
  rep(i, M-1)
    q.push(x[i+1] - x[i]);
  rep(i, N-1) {
    if (q.empty())
      break;
    q.pop();
  }
  int sum = 0;
  while (!q.empty()) {
    sum += q.top(); q.pop();
  }
  out(sum);

  return 0;
}


Measured memory_bytes: 1276
t = {
	"i": "i",
	"w": "w",
	"(": ")",
	")": "("
}
s = raw_input()
count = 0
for i in range(len(s) / 2):
	if t[s[i]] != s[-i-1]:
		count += 1
x = len(s) / 2
if len(s) % 2 == 1 and (s[x] == "(" or s[x] == ")"):
	count += 1
print count

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

int main(){
  int n;
  cin >> n;
  vector<long long>mon(n+1);
  vector<long long>bre(n);
  for(int i=0;i<n+1;i++)
    cin >> mon.at(i);
  for(int i=0;i<n;i++)
    cin >> bre.at(i);
  long long ans=0,moti=0;
  for(int i=0;i<n;i++){
    if(mon.at(i)<bre.at(i)+moti){
      ans+=mon.at(i);
      moti=bre.at(i)-max(0ll,mon.at(i)-moti);
    }else{
      ans+=bre.at(i)+moti;
      moti=0;
    }
  }
  if(moti>0){
    ans+=min(moti,mon.at(n));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4844
#include<iostream>

using namespace std;

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

	bool res = true;
	if(a[a.length()-1] != b[0]) res = false;
	if(b[b.length()-1] != c[0]) res = false;
	
	cout << (res? "YES":"NO") << endl;
}


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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 100 * 1000 + 17;

ll n, m, q, ans[MAXN], cnt[MAXN];
vector<ll> v;

void doit(ll x, ll ind) {
	if (!x) return;
	if (x <= v[0]) ans[1] += cnt[ind], ans[x + 1] -= cnt[ind];
	else {
		int ind2 = upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
		cnt[ind2 + 1] += (x / v[ind2]) * cnt[ind];
		doit(x % v[ind2], ind);
	}

}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	v.pb(n);
	for (int i = 1; i <= m; i++) {
		cin >> q;
		while (v.size() && v.back() >= q)
			v.pop_back();
		v.pb(q);
	}
	cnt[v.size()] = 1;
	ll lst = v.back();
	v.pop_back();
	while (v.size())
		doit(lst, v.size() + 1), lst = v.back(), v.pop_back();
	ans[1] += cnt[1];
	ans[lst + 1] -= cnt[1];
	for (int i = 1; i <= n; i++) ans[i] += ans[i - 1];
	for (int i = 1; i <= n; i++) cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 4212
import itertools as it
n,k=map(int,input().split())
d=(n-1)*(n-2)//2-k
if d<0:
    print(-1)
    exit()
print(n-1+d)
for i in range(1,n):
    print(i,n)
p=[x for x in range(1,n)]
for a,b in it.combinations(p,2):
    if d == 0:
        break
    print(a,b)
    d-=1


Measured memory_bytes: 3616
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;

        signed main() {
        int n,a,b;
        cin>>n>>a>>b;
        if((b-a)%2)cout<<"Borys";
        else cout<<"Alice";
      

        
        
        


      }


        


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_right){
		right = arg_right;
	}
	int right;
};

int main(){

	int N,M,count,left,right;
	bool FLG,check[101];

	vector<Info> V[101];

	scanf("%d %d",&N,&M);

	for(int i = 1; i <= N; i++)check[i] = false;

	for(int i = 1; i <= M; i++){
		scanf("%d %d",&left,&right);

		for(int k = left; k <= right;k++){
			check[k] = true;
		}

		V[left].push_back(Info(right));
	}

	FLG = true;
	for(int i = 1; i <= N; i++){
		if(check[i] == false){
			FLG = false;
			break;
		}
	}

	if(!FLG){
		printf("Impossible\n");
		return 0;
	}

	int range_left = 1,range_right = 1,tmp_max;

	count = 0;
	while(true){

		tmp_max = 0;
		for(int i = range_left; i <= range_right; i++){
			for(int k = 0; k < V[i].size();k++){
				tmp_max = max(tmp_max,V[i][k].right);
			}
		}
		range_left = range_right+1;
		range_right = tmp_max+1;

		count++;

		if(tmp_max == N){
			break;
		}
	}

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

	return 0;
}

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



int main (){
    
  char a[4];
  int ans,u,d;
  
  scanf("%s",a);
  
  for(int i = 0;i < 4;i++){
    if(a[i] == '+'){
      u++;
    }else{
      d++;
  	}
  }

  ans = u - d; 
  printf("%d",ans);
      return 0;
  
}



Measured memory_bytes: 128
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    # n = int(input())
    # a, b = map(int, input().split())
    l = list(map(int, input().split()))

    for i in range(len(l)):
        if l[i] == 0:
            print(i + 1)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """0 2 3 4 5"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 0 4 5"""
        output = """3"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 70888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

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

	int red = 0;
	int blue = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'R') {
			red++;
		}
		else {
			blue++;
		}
	}
	
	if(red > blue) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256