akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;

ll pow2(int v) {
	ll res = 1;
	while(v--) res *= 2;
	return res;
}

ll num(string s) {
	ll res = 0;
	rep(i, 0, sz(s)) {
		res *= 10;
		res += (s[i] - '0');
	}
	return res;
}

void solve() {
	cin >> S;
	N = sz(S);
	ll ans = 0;
	rep(i, 0, N) {
		rep(j, i, N) {
			ll v = num(S.substr(i, j - i + 1));
			int d = N - 1 - (j - i) - (i != 0) - (j != N - 1);
			ans += v * pow2(d);
		}
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int maxx = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        maxx = max(maxx, A[i]);
    }
    int count = 0;
    int suf = 0;
    int max2 = 0;
    int suf2 = 0;
    for (int i = 0; i < N; i++)
    {
        if(A[i] == maxx){
            count++;
            suf = i;
        }
    }
    if(count >= 2){
        for (int i = 0; i < N;i++)
        {
            cout << maxx << endl;
        }
    }
    else{
        for (int i = 0; i < N;i++)
        {
            if(i != suf){
                max2 = max(max2, A[i]);
                suf2 = i;
            }
        }
        for (int i = 0; i < N;i++)
        {
            if(i != suf)    {
                cout << maxx << endl;
            }
            else{
                cout << max2 << endl;
            }
        }
    }
}

Measured memory_bytes: 2432
A = input().split()
X = float(A[0])
K = int(A[1])
D = int(A[2])

if abs(X) - K * D > 0:
	print(int(abs(X) - K*D))
else:
	K2 = abs(X)//D
	if (K - K2) % 2 == 0:
		print(int(abs(abs(X) - D * K2)))
	else:
		print(int(abs(abs(abs(X) - D * K2) - D)))


Measured memory_bytes: 9160
#include<iostream>
#include<string>
using namespace std;

string s;
int ans1,ans2;

int main()
{
	
	cin>>s;
	for(int i=0;i<s.size();i++)
		if((s[i]=='0')==i%2) ans1++;
	for(int i=0;i<s.size();i++)
		if((s[i]=='1')==i%2) ans2++;
	cout<<min(ans1,ans2)<<'\n';
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
constexpr int ALL1=-1;
int main(){
    int N,K;
    cin>>N>>K;
    LL ret=0;
    vector<int> A(N),B(N);
    REP(i,N)cin>>A[i]>>B[i];
    int M=-1;
    for(int i=31;i>=0;i--){
        if((K>>i)&1){
            int mask=M&(ALL1-(1<<i));
            LL ans=0;
            REP(j,N)if((A[j]&mask)==A[j])ans+=B[j];
            chmax(ret,ans);
        }
        else{
            M-=(1<<i);
        }
    }
    {
        int mask=M;
        LL ans=0;
        REP(j,N)if((A[j]&mask)==A[j])ans+=B[j];
        chmax(ret,ans);
    }
    cout<<ret<<endl;
    return 0;
}


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

int getPrimeCount(int n) {
    vector<bool> isPrime(n+1, true);
    int count = 0;
    for (int i = 2; i <= n; i++) {
        if (isPrime[i]) {
            count++;
            for (int j = i*2; j <= n; j+=i) {
                isPrime[j] = false;
            }
        }
    }
    return count;
}

int main() {
    int n;
    while (cin >> n) {
        cout << getPrimeCount(n) << endl;
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int mod = 1000000007;

int n, m;


int main(){
	ll a[200010], b[200010];
	cin >> n;
	forn(i) {
		scanf("%lld", &a[i]); 
		b[i] = a[i];
	}
	sort(a, a + n);
	forn(i) {
		if (b[i] <= a[n / 2 - 1]) {
			printf("%lld\n", a[n / 2]);
		}
		else {
			printf("%lld\n", a[n / 2-1]);
		}
	}
	return 0;
}

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

int main(){
    int n;
    int t,a;
    cin >> n;
    cin >> t >> a;
    vector <ll> h(n);
    ll tt,mi=100000000;
    int ans;
    a*=1000;
    rep(i,n){
        cin >> h[i];
        tt=1000*t-h[i]*6;
        if(abs(tt-a)<mi){
            mi=abs(tt-a);
            ans=i+1;
        }
    }

    cout << ans << endl;

    


    

    return 0;
}

Measured memory_bytes: 3608
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let n = read!(i64);
	let mut val = n;
	let mut ans = vec![];
	for i in 2..2000000 {
		let mut tmp = 0;
		loop {
			if val%i==0 {
				tmp += 1;
			}
			else {
				break;
			}
			val /= i;
		}
		if tmp>0 {
			ans.push(tmp);
		}
	}
	if val>1 {
		ans.push(1);
	}
	let mut res = 0;
	for &i in &ans {
		let mut cum = 0;
		for j in 1..100 {
			cum += j;
			if cum<=i {
				res += 1;
			}

		}
	}
	println!("{}", res);
}

fn run() {
    solve();
}


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

int main(){
  string s;
  cin>> s;
  
  sort(s.begin(),s.end());
  string ans="No";
  if (s.at(0)==s.at(1) && s.at(1)!=s.at(2) && s.at(2)==s.at(3)) ans="Yes";
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000001
#define MOD 1e9+7
ll res=0;

ll gcd(ll a,ll b){
    ll c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}


int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll ans=gcd(a[0],a[1]);
	for(ll i=2;i<n;i++){
		ans=gcd(ans,a[i]);
	}

	sort(a,a+n);
	ll g[n];


	ll tmp=sum;
	ll q=0;
	for(ll i=0;i<n;i++){
		tmp = sum;
		tmp -= a[i];
		if(i>0){
			if(ans<gcd(a[0],tmp)){
				ans = gcd(a[0],tmp);
				q=i;
			}
		}
		else{
			ans = gcd(a[1],tmp);
			q=i;
		}
	}

	for(ll i=0;i<n;i++){
		if(i==q)continue;
		ans = gcd(a[i],ans);
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var W = Console.ReadLine();
            var T = string.Empty;
            while (true)
            {
                var tmp = Console.ReadLine();
                if (tmp == "END_OF_TEXT")
                {
                    break;
                }
                T += tmp + " ";
            }
            var count = 0;
            foreach (var t in T.Split(' '))
            {
                if (t.ToLower() == W.ToLower())
                {
                    count++;
                }
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9144
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,k,ans = 1;
    cin >> n >> k;
    for(int i = 0;i < n;i++)
    {
        if(ans * 2 < ans + k){ans *= 2;}
        else{ans += k;}
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;

int main(){

	int N;

	cin >> N;

	if( N == 7 || N == 5 || N == 3){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int  selectionSort(int A[], int N) {
	int i, j,minj, tmp, count = 0;
	
	for (i = 0; i <= N - 1; i++) {
		minj = i;
		for (j = i; j <= N - 1; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;;
		if (i != minj) count++;
	}
	return count;
}

int main(void) {
	int N;
	int A[100];
	int i;
	int kai;

	scanf("%d", &N);
	
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	
	kai = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");

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

	return 0;
}

Measured memory_bytes: 604
import java.util.*;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		int age = sc.nextInt();
      
      	if(age == 3 || age == 5 || age == 7) {
        	System.out.println("YES");
        } else {
          	System.out.println("NO");
        }

    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    if(t.size() != s.size()+1){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < s.size(); i++) {
        if(t[i] != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong a, b;
	cin >> a >> b;
	cout << max({a+b, a-b, a*b}) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;
vector <int > H;





int main()
{

	cin >> N;

	cout << N*N;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(n==1){
        if(a==b){
            cout<<1<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
    else if(a>b){
        cout<<0<<endl;
    }
    else{
        cout<<(b-a)*(n-2)+1<<endl;
    }
}

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

int main() {
	char x[2];
	int i[2];
	for (int j = 0; j < 2; j++)
	{
		char tmp;
		cin >> tmp;
		if (tmp == 'A') {
			i[j] = 10;
		}
		else if (tmp == 'B') {
			i[j] = 11;
		}
		else if (tmp == 'C') {
			i[j] = 12;
		}
		else if (tmp == 'D') {
			i[j] = 13;
		}
		else if (tmp == 'E') {
			i[j] = 14;

		}
		else if (tmp == 'F') {
			i[j] = 15;
		}
	}
	if (i[0] < i[1]) {
		cout << '<' << endl;
	}
	else if (i[0] == i[1]) {
		cout << '=' << endl;
	}
	else {
		cout << '>' << endl;
	}
	
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll g, n, t[110], ans;
int main()
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &t[i]);
	}
	ans = t[0];
	for (int i = 1; i < n; i++) ans*=(t[i]/__gcd(ans, t[i]));
	printf("%lld\n", ans);
}

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

int main() {
    int N, x, res = 0;
    cin >> N >> x;

    int a[N];

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

    sort(a, a+N);

    for (int j = 0; j < N; j++) {
        if (j == N -1) {
            if (x == a[j]) {
                res++;
            }
            break;
        }
        if (x - a[j] >= 0) {
            x -= a[j];
            res++;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
   int N;
   string s;
   cin >> N;
   cin >> s;
   int r = 0;
   int b = 0;
   for(int i = 0;i < s.size();i++){
       if(s[i] == 'R'){
           r++;
       }else{
           b++;
       }
   }
   
   cout << ((r > b) ? "Yes" : "No") << endl;
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<int> adj[N];
int vis[N];
int len = OO;
vector<int> vv, ans;

void cycleAns(int node, int root, bool awlMra) {
  if(!awlMra && root == node) {
    if((int)vv.size() < len) {
      len = vv.size();
      ans = vv;
    }
    return;
  }
  if(vis[node])
    return;
  vis[node] = 1;
  vv.push_back(node);
  for(auto it: adj[node])
    cycleAns(it, root, 0);
  vis[node] = 2;
  vv.pop_back();
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof vis);
    vv.clear();
    cycleAns(i, i, 1);
  }
  if(len > n) len = -1;
  cout << len;
  if(len != -1) {
    cout << '\n';
    for(int it: ans)
      cout << it << '\n';
  }
  return 0;
}


Measured memory_bytes: 8576
var a=[1];
for(var i=1;i<1000000;i++)a[i]=a[i-1]+i+1;
var b=[1];
var i=1;
while(true){
   b[i]=b[i-1]+a[i];
   if(b[i]>1000000)break;
   i++;
}
var dpA=[];
var dpB=[];
for(var i=0;i<1000000;i++)dpA[i]=Infinity;
for(var i=0;i<1000000;i++)dpB[i]=Infinity;
dpA[0]=0;
dpB[0]=0;
for(var j=0;j<b.length;j++){
   for(var i=b[j];i<1000000;i++){
      dpA[i]=Math.min(dpA[i-b[j]]+1,dpA[i]);
      if(b[j]%2==1)dpB[i]=Math.min(dpB[i-b[j]]+1,dpB[i]);
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
while(true){
   var n=arr.shift();
   if(n==0)break;
   console.log(dpA[n]+" "+dpB[n]);
}

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


int main(){
  long int n , ans = 0;
  cin >> n;
  for(int i = 1 ; i <=n; i++){
    if(i % 15 == 0){
      continue;
    }
    else if(i % 3==0){
      continue;
    }
    else if(i % 5==0){
      continue;
    }
    else{

      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	int x,y;
	cin>>x>>y;
	ote(x+y/2);
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

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

	return true;
}








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

	vector<long long int> h(n);

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


	sort(h.begin(), h.end(), greater<long long int>());
	
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i < k)continue;
		ans += h[i];

	}

	cout << ans << endl;



	return 0;

}



Measured memory_bytes: 1792
/*An anomaly, I'm Muhammad Ali
  'Cause I know one day I'm gonna be the*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define f first
#define s second
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int main()
{
	int n; cin>>n;
	ll ans = 0;
	for(int i = 1; i<=n; i++)
	{
		for(int j = 1; j <=n ; j++)
		{
			for(int k = 1; k<=n ; k++)
			{
				ans+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int h, n,sum,i,a;
    cin>>h>>n;
    for(i=0;n>i;i++){
            cin>>a;
            sum+=a;

    }

    if (sum>=h)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<"\n"
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
typedef vector<pli>vpli;
typedef map<int,int>mii;
typedef map<ll,ll>mll;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}

main(){cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vi a(N),b(N);
	cin>>a>>b;
	int z=0;
	rf(k,29){
		for(int&_:a)_&=(1<<k+1)-1;
		for(int&_:b)_&=(1<<k+1)-1;
		Sort(b);
		ll x=0;
		for(int&_:a){
			x+=lower_bound(all(b),(2<<k)-_)-lower_bound(all(b),(1<<k)-_);
			x+=b.end()-lower_bound(all(b),(3<<k)-_);
		}
		z|=(x&1)<<k;
	}
	print(z);
}


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

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

using namespace std;
using lint=long long;
using graph=vector<vector<int>>;

using rolling_hash=pair<lint,lint>;

const lint base=10007,mod1=1e9+7,mod2=998244353;

lint modpow(lint a,lint k,int m){
	lint r=1;
	for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m;
	return r;
}

bool is_DAG(const graph& G){
	int n=G.size();
	vector<int> deg(n);
	rep(u,n) for(int v:G[u]) deg[v]++;

	int cnt=0;
	queue<int> Q;
	rep(u,n) if(deg[u]==0) Q.emplace(u);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		cnt++;
		for(int v:G[u]) if(--deg[v]==0) Q.emplace(v);
	}
	return cnt==n;
}

vector<int> topological_order(const graph& D){
	int n=D.size();
	vector<int> deg(n);
	rep(u,n) for(int v:D[u]) deg[v]++;

	vector<int> res;
	queue<int> Q;
	rep(u,n) if(deg[u]==0) Q.emplace(u);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		res.emplace_back(u);
		for(int v:D[u]) if(--deg[v]==0) Q.emplace(v);
	}
	return res;
}

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

	{
		string tmp;
		while(tmp.length()<t.length()) tmp+=s;
		s=tmp;
	}

	int m=s.length(),n=t.length();
	lint basepow1=modpow(base,n,mod1);
	lint basepow2=modpow(base,n,mod2);

	rolling_hash ht;
	rep(i,n){
		ht.first =(ht.first *base+t[i])%mod1;
		ht.second=(ht.second*base+t[i])%mod2;
	}

	vector<rolling_hash> hs(m);
	rep(i,n){
		hs[0].first =(hs[0].first *base+s[i])%mod1;
		hs[0].second=(hs[0].second*base+s[i])%mod2;
	}
	rep(i,m-1){
		hs[i+1].first =(hs[i].first *base-s[i]*basepow1+s[(n+i)%m])%mod1;
		hs[i+1].second=(hs[i].second*base-s[i]*basepow2+s[(n+i)%m])%mod2;
		if(hs[i+1].first <0) hs[i+1].first +=mod1;
		if(hs[i+1].second<0) hs[i+1].second+=mod2;
	}

	graph G(m);
	rep(u,m) if(ht==hs[u]) G[u].emplace_back((u+n)%m);

	if(!is_DAG(G)) return puts("-1"),0;

	vector<int> dp(m);
	auto p=topological_order(G);
	for(int i=m-1;i>=0;i--){
		int u=p[i];
		for(int v:G[u]) dp[u]=dp[v]+1;
	}
	printf("%d\n",*max_element(dp.begin(),dp.end()));

	return 0;
}


Measured memory_bytes: 75952
n=int(input())
cnt=0
D=[]
for i in range(n):
  d=list(map(int,input().split()))
  D.append(d)
cnt=0
for i in D:
  
  if i[0]==i[1]:
    
    cnt+=1
    #print(cnt)
    if cnt==3:
      print('Yes')
      exit()
    
  else:
    if cnt==3:
      
      print('Yes')
      exit()
      
    else:
      cnt=0

print('No')  

Measured memory_bytes: 9192
import java.security.SecureRandom;
import java.sql.Array;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int a[]= new int[n];
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        int count=0;
        for (int i=0;i<n;i++){
            for (int j=i+1;j<n;j++){
                for (int k=j+1;k<n;k++){
                    if (a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])count++;
                }
            }
        }
        System.out.println(count);
    }

}

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

int main(){
  int N, M;
  cin >> N >> M;
  priority_queue<pair<uint64_t, uint64_t>, vector<pair<uint64_t, uint64_t>>, greater<pair<uint64_t, uint64_t>>> pq;
  uint64_t want = 0;
  uint64_t cost = 0;

  for(int i = 0; i < N; i++){
    uint64_t A, B;
    cin >> A >> B;
    pq.push(make_pair(A, B));                 //最小値に関するpriority_queueにpush
  }

   while(1){
    pair<uint64_t, uint64_t> tmp = pq.top();
    
    if(tmp.second + want < M){             //当店の栄養ドリンクは買い占めできる
      want += tmp.second;
      cost += tmp.first * tmp.second;
    }else{                                                             //買い占めすると目標本数をオーバー
      cost += tmp.first * (M - want);
      break;
    }
    pq.pop();
  }

 
  cout << cost << endl;
  return 0;
    
}

Measured memory_bytes: 3444
n,k = map(int,input().split())
A = list(map(int,input().split()))
Ad = {}
for a in A:
    if not a in Ad:
        Ad[a] = 1
    else:
        Ad[a] += 1

if len(set(A)) == k:
    print (0)
else:
    x = len(set(A)) - k
    Ad = sorted(Ad.items(), key=lambda x:x[1])
    ans = 0
    for i in range(x):
        ans += Ad[i][1]
    print (ans)


Measured memory_bytes: 54452
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine().Split(' ');
        var N = int.Parse(str[0]);
        var M = int.Parse(str[1]);
        var C = int.Parse(str[2]);
        str = Console.ReadLine().Split(' ');
        
        var ans = 0;
        for (var i = 0; i < N; i++) {
            var str2 = Console.ReadLine().Split(' ');
            var a = 0;
            for (var j = 0; j < M; j++) {
                a += int.Parse(str[j]) * int.Parse(str2[j]);
            }
            if (a + C > 0) {
                ans++;
            }
        }
        
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
from collections import deque

N = int(input())
A = [int(i) for i in input().split()]

B = deque(maxlen=2*10**5)

if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])
else:
    for i in range(N):
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])

print(*B)

Measured memory_bytes: 25412
from collections import Counter
n,k=map(int,input().split())

a=[int(i) for i in input().split()]
d=Counter(a)
a=sorted(list(d.items()),key=lambda x:x[1],reverse=True)
if len(a)<=k:
    print(0)
else:
    ans=0
    for i in range(k,len(a)):
        ans+=a[i][1]
    print(ans)
    



Measured memory_bytes: 40856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll f[1000100], finv[1000100];

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll nCr(ll n, ll r) {
  if (r < 0 || r > n) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll nHr(ll n, ll r) {
  return nCr(n + r - 1, r);
}

void init() {
  f[0] = 1, finv[0] = 1;
  FOR(i, 1, 1000100) {
    f[i] = i * f[i - 1] % mod;
    finv[i] = modinv(f[i]);
  }
}

ll dp[1005][1005];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  init();

  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  dp[a - 1][n] = 1;
  FOR(i, a, b + 1) {
    rep(j, n + 1) {
      dp[i][j] = dp[i - 1][j];
      ll res = 1;
      FOR(k, 1, c) res = res * nCr(j + i * k, i) % mod;
      FOR(k, c, d + 1) {
        if (j + i * k > n) break;
        res = res * nCr(j + i * k, i) % mod % mod;
        dp[i][j] = (dp[i][j] + dp[i - 1][j + i * k] * res % mod * finv[k]) % mod;
      }
    }
  }
  cout << dp[b][0] << '\n';
  




  
  return 0;
}

Measured memory_bytes: 27064
import std.stdio;

int[10] w, s;
string[10] f;
int n, sum;
int[] ans;
double best;

void main(){
	while (readf("%d\n", &n), n) {
		sum = 0;
		best = double.max;
		foreach (i; 0..n) {
			readf("%s %d %d\n", &f[i], &w[i], &s[i]);
			sum += w[i];
		}
		solve(0, [], 0, sum, 1);
		foreach (i; ans) writeln(f[i]);
	}
}

void solve(int b, int[] order, double g, int weight, int pos){
	foreach (i; 0..n) {
		if (!((1<<i) & b) && s[i] >= weight-w[i]) {
			solve(b | (1<<i), order ~ i, g+w[i]*pos, weight-w[i], pos+1); 
		}
	}
	if (b+1 == (1<<n) && best > g/sum) {
		best = g/sum;
		ans = order;
	}
}

Measured memory_bytes: 1828
S = input()

count = 0
for s in range(len(S)):
    if (s+1) % 2 == 1 and (S[s] == 'R' or S[s] == 'U' or S[s] == 'D'):
        count += 1

    elif (s+1) % 2 == 0 and (S[s] == 'L' or S[s] == 'U' or S[s] == 'D'):
        count += 1

if count == len(S):
    print('Yes')

else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    char inp;
    cin>>inp;
    if(inp>=65&&inp<=90){
        cout<<"A";
    }
    if(inp>=97&&inp<=122){
        cout<<"a";
    }

}   


Measured memory_bytes: 3644
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> vsize;
    UnionFind(int size) : par(size), rank(size), vsize(size) {
        REP(i, size) {
            par[i] = i;
            rank[i] = 0;
            vsize[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        vsize[x] += vsize[y];
        vsize[y] = vsize[x];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return vsize[find(x)]; }
};

class DFriends {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;

        UnionFind uf(N);
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            uf.unite(a, b);
        }

        int res = 0;
        REP(i, N) {
            res = max(res, uf.size(i));
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DFriends solver;
    solver.solve(in, out);
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    string S;
    cin >> S;

    int ans = 1;
    int ck = 1;
    int i = 1;
    for(; i < S.size() ; i++){
        if(ck && S[i - 1] == S[i]) ans++, ck = 0, i++;
        else ans++, ck = 1;
    }

    if(i == S.size() + 1) ans--;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 720
using System;
using System.Linq;
using static System.Console;

namespace ConsoleApp4
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = ReadLine();
			var ta = ReadLine().Split(' ').Select(int.Parse).ToArray();
			var h = ReadLine().Split(' ')
				.Select((x, index) => new { Index = index, Value = Math.Abs(ta[1] - (ta[0] - (int.Parse(x) * 0.006))) })
				.OrderBy(x => x.Value).First().Index + 1;
			WriteLine(h);
		}
	}
}

Measured memory_bytes: 13584
#include <iostream>
using namespace std;
int main() {
    string s;
    int x = 0,y=0;
    cin >> s;
    if (s[0] != 'A' || isupper(s[1])){
        cout << "WA";
    }
    else {
        for (int i = 2; i < s.size(); i++) {
            if (s[i] == 'C' && islower(s[s.size()-1])) {
                x++;
            }
            else if (islower(s[i])) {
                y++;
            }
        }
        if (x == 1 && y == s.size() - 3) {
            cout << "AC";
        }
        else {
            cout << "WA";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,r;
	cin>>n>>r;
	if(n>=10){
		cout<<r<<'\n';
	}
	else{
		int val = r + 100*(10-n);
		cout<<val<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n,m; cin >> m >> n;
    vint x(n); rep(i,n) cin >> x[i];
    sort(all(x));
    vint diff(n-1);
    rep(i,n-1){
        diff[i]=x[i+1]-x[i];    
    }
    sort(all(diff));
    int res=0;
    
    rep(i,n-m){
        res+=diff[i];
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1792
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        a: [u64; n],
    }

    let mut t = FenwickTree::from_vec(a);
    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};

impl<T: Copy + AddAssign + Integer> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn from_vec(v: Vec<T>) -> Self {
        let n = v.len();
        let mut t = Self::new(n);
        for i in 0..n {
            t.v[i] += v[i];
            let p = i + Self::lsb(i + 1);
            if p < n {
                let v = t.v[i];
                t.v[p] += v;
            }
        }
        t
    }

    fn add(&mut self, mut i: usize, v: T) {
        while i < self.v.len() {
            self.v[i] += v;
            i += Self::lsb(i + 1);
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= Self::lsb(i);
        }
        v
    }

    fn lsb(i: usize) -> usize {
        i & i.wrapping_neg()
    }
}


Measured memory_bytes: 22976
#include <bits/stdc++.h>
#define mod 998244353
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll n,k,c[4500][4500],inv[4500],tpo[4500];
ll powlll(ll x, ll pw){
	ll res = 1;
	ll dbl[31];
	dbl[0]=x;
	for(int i=1;i<=30;i++){
		dbl[i] = (dbl[i-1]*dbl[i-1])%mod ;
	}
	for(int i=0;i<=30;i++){
		if(pw%2==1 ){
			res *= dbl[i];
			res %= mod;
		}
		pw = pw/2;
	}
	return res;
}
ll inve(ll x){
	return powlll(x,mod-2);
}
ll comb(ll x, ll y){
	if(y==0)return 1;
	else{
		ll tmp = c[x][y-1];
		tmp = (tmp*(x-y+1))%mod;
		tmp = (tmp*inv[y])%mod;
		return tmp;
	}
}
ll solve(ll n,ll k,ll x){
	if(n==1){
		return k;
	}
	if(x%2==0){
		ll tmp = solve(n,k-1,x-1)+solve(n-1,k-1,x-1);
		tmp = tmp%mod;
		return tmp;
	}
	if(x%2==1){
		if(x>k+1){
			return solve(n, k, 2*k+2-x);
		}
		else{
			ll res = 0;
			ll y = (x-1)/2;
			for(int i=0;i<=y;i++){
				ll tmp = 1;
				tmp = (tmp * c[y][i]) % mod;
				tmp = (tmp * c[n+k-x][n-y+i]) % mod;
				tmp = (tmp * tpo[y-i] ) % mod;
				res = (res + tmp) % mod;
			}
			return res;
		}
	}
}		
int main(){
	cin>>k>>n;
	tpo[0]=1;
	for(int i=1;i<=4200;i++){
		inv[i]=inve(i);
		tpo[i]=powlll(2,i);
	}
	for(int i=0;i<=4200;i++){
		for(int j=0;j<=i;j++){
			c[i][j] = comb(i,j);
		}
	}
	for(int i=2;i<=2*k;i++){
		printf("%lld\n", solve(n,k,i));
	}
	return 0;
}

Measured memory_bytes: 148096
#include<iostream>
#include<cstdio>

int main(void){
	std::int64_t r,g,b;
	std::cin >> r;
	std::cin >> g;
	std::cin >> b;

	if((100 * r + 10 * g + b) % 4 ==0){
		std::cout << "YES" << std::endl;
		return 0;
	}
	else{
		std::cout << "NO" << std::endl;
		return 0;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<int>p(n),q(n);
  rep(i,n)cin>>p[i];
  rep(i,n)cin>>q[i];
  vector<int> pp=p,qq=q;
  sort(all(pp));sort(all(qq));
  int cnt=0;
  int cnt_a=0,cnt_b=0;
  do{
    ++cnt;
    if(pp==p){
      cnt_a=cnt;
      break;
    }
  }
  while(next_permutation(all(pp)));
  cnt=0;
  do{
    ++cnt;
    if(qq==q){
      cnt_b=cnt;
      break;
    }
  }
  while(next_permutation(all(qq)));
  cout<<abs(cnt_a-cnt_b);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

int main(void)
{
    int N;
    cin >> N;
    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L, L + N);
    int num = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[j] < L[i] + L[k]) {
                    if (L[k] < L[j] + L[i]) {
                        num++;
                    }
                }
            }
        }
    }
    cout << num << endl;
}



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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  rep(i, n) { cin >> A[i]; }
  rep(i, k) {
    vector<int>  B(n + 1);
    rep(j, n) {
      int l = max(0, (j - A[j]));
      int r = min(j + A[j] + 1, n);
      B[l]++; B[r]--;
    }
    rep(j, n) B[j+1] += B[j];
    B.pop_back();
    if (A == B) break;
    A = B;
  }
  rep(i, n) cout << A[i] << endl;
  return 0;
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int sy = 0, sx = 0;
    vector<vector<char>> a(800, vector<char>(800));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a.at(i).at(j);
            if (a.at(i).at(j) == 'S') {
                sy = i;
                sx = j;
                a.at(i).at(j) = '.';
            }
        }
    }

    int dy[4] = {1, -1, 0, 0};
    int dx[4] = {0, 0, 1, -1};
    const int INF = 800 * 800 + 1;
    using P = pair<int, int>;
    queue<P> que;
    que.push(P(sy, sx));
    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[sy][sx] = 0;
    while (!que.empty()) {
        int ny = que.front().first, nx = que.front().second; que.pop();
        if (dist.at(ny).at(nx) == k) continue;

        for (int i = 0; i < 4; i++) {
            int y = ny + dy[i], x = nx + dx[i];
            if ((0 <= y && y < h) && (0 <= x && x < w) && (dist.at(y).at(x) == INF) && (a.at(y).at(x) == '.')) {
                que.push(P(y, x));
                dist.at(y).at(x) = dist.at(ny).at(nx) + 1;
            }
        }
    }

    int mini = INF;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (dist.at(i).at(j) > k) continue;

            mini = min(mini, (min({i, h - 1 - i, j, w - 1 - j}) + k - 1) / k + 1);
        }
    }
    cout << mini << endl;
}

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

int main() {
  long long a,b,c;
  cin >> c >> a >> b;
  long long  x = c / (a + b);
  long long y = c % (a + b);
  if (y > a) {
    cout << (a * x) + a <<endl;
  }
  else if (y <= a){
    cout << (a * x) + y <<endl;
  }

}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
//const int N = 100100;
const int inf = INT_MAX;
const double eps = 1e-7;
//////////////////////    Hi    ^_^  hack me if you can :P
 
int n ;
int a[200200];
ll s , s1;
ll d = 1e18;
int main()
{
    //speed;
    cin >> n;
    lop(i,n) cin >> a[i];
    lop(i,n)  s+= a[i];
    lop(i,n-1) {
        s1 += a[i];
        s -= a[i];
        d = min(d,abs(s-s1));
    }
    cout << d << endl;
 
    return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
a = gets.chomp.split("");
b = gets.chomp.split("");
c = gets.chomp.split("");
cnt = 0
0.upto(n) do |i|
  if a[i] == b[i] && a[i] == c[i] then
  elsif a[i] == b[i] || b[i] == c[i] || a[i] == c[i] then
    cnt += 1
  else
    cnt += 2
  end
end
puts cnt


Measured memory_bytes: 1788