akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
    long La = 2L;
    long Lb = 1L;
    long Lc = 1L;
    public static void main(String[] args) {
        new Main().run();
    }
    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i = 0; i < N-1; i++) {
            Lc = Lb + La;
            La = Lb;
            Lb = Lc;
        }
        System.out.println(Lc);
    }
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

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

map<long long, long long> prime_factor(long long n) {
	map<long long, long long> ret;
	for(long long i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n] = 1;
	return ret;
}

ll n;
map<ll, ll> prime;

template<typename Iterator>
ll solve(Iterator it, ll num)
{
	if (it == prime.end())
	{
		if (num == 1)
			return 1;
		else
			return 0;
	}

	ll res{0};
	for (ll i = 1; i <= it->second+1; ++i)
	{
		if (num % i != 0) continue;
		res += solve(next(it), num/i);
	}

	return res;
}

int main(int argc, char **argv)
{
	cin >> n;
	for (ll i = 1; i <= n; ++i)
	{
		auto tmp = prime_factor(i);
		for (auto &p : tmp)
		{
			prime[p.first] += p.second;
		}
	}
	std::cout << solve(prime.begin(), 75) << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, c;
	char b, n, m;
	int sum;
	while (scanf("%d", &a) != EOF)
	{
		scanf("%c", &m);
		scanf("%c", &b);
		scanf("%c", &n);
		scanf("%d", &c);
		if ( b== 43)
		{
			sum = a + c;
			printf("%d\n", sum);
		}
		else
		{
			sum = a - c;
			printf("%d\n", sum);
		}
	}
	return 0;
}

Measured memory_bytes: 128
x = list(map(lambda x:int(x), input().split()))
X = x[0]
Y = x[1]

kame = (Y-X*2)//2
#print(kame)

if kame >= 0 and X-kame >= 0 and Y - kame*4 == (X-kame)*2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9120
def lscan; gets.split.map(&:to_i); end
def bye(msg); puts msg.to_s; exit; end

a, b, x = lscan.map(&:to_f)

rad = (0.0..(Math::PI/2)).bsearch{|rad|
  h = a*Math.tan(rad)
  l = b/Math.tan(rad)
  v = h < b ? a*a*(b - h/2) : a*b*l/ 2
  v < x
}


p rad/Math::PI*180

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

dic = {}

for x in range(n):
    a = input()
    dic.setdefault(a,0)
    dic[a] += 1

dic2 = sorted(dic.items(),key=lambda x:x[1],reverse=True)

max_word = [k for k,v in dic2 if v == dic2[0][1] ]

max_word.sort()

for x in max_word:
    print(x)


Measured memory_bytes: 48208
// C++ program to count number of triangles that can be 
// formed from given array 
#include <bits/stdc++.h> 
using namespace std; 
 
/* Following function is needed for library function 
qsort(). Refer 
http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/ */
int comp(const void* a, const void* b) 
{ return *(int*)a > *(int*)b ; } 
 
// Function to count all possible triangles with arr[] 
// elements 
int findNumberOfTriangles(int arr[], int n) 
{ 
	// Sort the array elements in non-decreasing order 
	qsort(arr, n, sizeof( arr[0] ), comp); 
 
	// Initialize count of triangles 
	int count = 0; 
 
	// Fix the first element. We need to run till n-3 
	// as the other two elements are selected from 
	// arr[i+1...n-1] 
	for (int i = 0; i < n - 2; ++i) 
	{ 
		// Initialize index of the rightmost third 
		// element 
		int k = i + 2; 
 
		// Fix the second element 
		for (int j = i + 1; j < n; ++j) 
		{ 
			// Find the rightmost element which is 
			// smaller than the sum of two fixed elements 
			// The important thing to note here is, we 
			// use the previous value of k. If value of 
			// arr[i] + arr[j-1] was greater than arr[k], 
			// then arr[i] + arr[j] must be greater than k, 
			// because the array is sorted. 
			while (k < n && arr[i] + arr[j] > arr[k]) 
			++k; 
 
			// Total number of possible triangles that can 
			// be formed with the two fixed elements is 
			// k - j - 1. The two fixed elements are arr[i] 
			// and arr[j]. All elements between arr[j+1]/ to 
			// arr[k-1] can form a triangle with arr[i] and arr[j]. 
			// One is subtracted from k because k is incremented 
			// one extra in above while loop. 
			// k will always be greater than j. If j becomes equal 
			// to k, then above loop will increment k, because arr[k] 
			// + arr[i] is always greater than arr[k] 
			if(k > j) 
			count += k - j - 1; 
		} 
	} 
 
	return count; 
} 
 
// Driver code 
int main() 
{ 
	 
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
 
	cout<<findNumberOfTriangles( arr, n ); 
 
	return 0; 
} 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct BipartiteMatching {
    vector<vector<int>> E; int n, m; vector<int> match, dist;
    void init(int _n,int _m){n=_n,m=_m;E.resize(n+m+2);match.resize(n+m+2);dist.resize(n+m+2);}
    bool bfs() {
        queue<int> que;
        rep(i, 1, n + 1) {
            if (!match[i]) dist[i] = 0, que.push(i);
            else dist[i] = inf;
        }
        dist[0] = inf;
        while (!que.empty()) {
            int u = que.front(); que.pop();
            if (u) fore(v, E[u]) if (dist[match[v]] == inf) {
                dist[match[v]] = dist[u] + 1;
                que.push(match[v]);
            }
        }
        return (dist[0] != inf);
    }
    bool dfs(int u) {
        if (u) {
            fore(v, E[u]) if (dist[match[v]] == dist[u] + 1) if (dfs(match[v])) {
                match[v] = u; match[u] = v;
                return true;
            }
            dist[u] = inf;
            return false;
        }
        return true;
    }
    void add(int a, int b) { b += n; E[a + 1].push_back(b + 1); E[b + 1].push_back(a + 1); }
    int whois(int x) { return match[x + 1] - 1; }
    int solve() {
        rep(i, 0, n + m + 1) match[i] = 0;
        int res = 0;
        while (bfs()) rep(i, 1, n + 1) if (!match[i] && dfs(i)) res++;
        return res;
    }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/









int N, A[101], B[101], C[101], D[101];
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i] >> B[i];
    rep(i, 0, N) cin >> C[i] >> D[i];

    BipartiteMatching bm;
    bm.init(N, N);
    rep(i, 0, N) rep(j, 0, N) {
        if (A[i] < C[j] and B[i] < D[j]) bm.add(i, j);
    }
    cout << bm.solve() << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.lang.Integer;
import java.lang.String;
import java.lang.System;
import java.util.Arrays;

class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int [] mountains = new int[10];
        int i = 0;
        while (true) {
            String s = r.readLine();
            mountains[i++] = Integer.valueOf(s);
            if(i >= 10) break;
        }
        Arrays.sort(mountains);
        for(i = 9; i > 6; i--) {
            System.out.println(mountains[i]);
        }
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi a(n); rep(i,n) cin  >> a[i];
    sort(all(a));

    int ans1 = a[n-1], ans2 = -1;
    int p = inf;
    for(auto i : a) {
        if(chmin(p, abs(i - (a[n-1]+1)/2))) {
            ans2 = i;
        }
    }
    cout << ans1 << ' ' << ans2 << '\n';
}

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

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

int h,w;
bool f[10][10];
vector<int> ans;

void dfs(int x, int y, int d, set<pair<int,int> > s, vector<int> v){
	s.insert(pair<int,int>(y,x));
	bool f2 = false;
	for(int i=0;i<4;i++){
		if(i == (d+2)%4) continue;
		int ay = y;
		int ax = x;
		while(1){
			ay += dy[i];
			ax += dx[i];
			if(ay < 0 || ay >= h || ax < 0 || ax >= w) break;
			if(!f[ay][ax]) continue;
			if(s.find(pair<int,int>(ay,ax)) == s.end()){
				vector<int> v2 = v;
				v2.push_back(i);
				f2 = true;
				dfs(ax,ay,i,s,v2);
				break;
			}
		}
	}
	if(!f2 && ans.size() < v.size()) ans = v; 
}

int main(){
	while(cin >> h >> w){
		int x,y,d;
		ans.clear();

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				char c;
				cin >> c;
				f[i][j] = true;
				if(c == '.') f[i][j] = false;
				else if(c == 'U'){
					x = j;
					y = i;
					d = 0;
				}
				else if(c == 'R'){
					x = j;
					y = i;
					d = 1;
				}
				else if(c == 'D'){
					x = j;
					y = i;
					d = 2;
				}
				else if(c == 'L'){
					x = j;
					y = i;
					d = 3;
				}
			}
		}
		set<pair<int,int> > s;
		vector<int> v;
		dfs(x,y,d,s,v);

		for(int i=0;i<ans.size();i++){
			if(ans[i] == 0) cout << 'U';
			else if(ans[i] == 1) cout << 'R';
			else if(ans[i] == 2) cout << 'D';
			else if(ans[i] == 3) cout << 'L';
		}
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 904
/* A */
 
#include <iostream>
using namespace std;
 
int main(){
	char c;
	cin >> c;
	if(c == 'A') cout << "T" << endl;
	else if(c == 'T') cout << "A" << endl;
	else if(c == 'C') cout << "G" << endl;
	else if(c == 'G') cout << "C" << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  int64_t K;
  cin >> S >> K;
  const int64_t L = static_cast<int64_t>(S.length());
  vector<int64_t> A[26];
  for (int64_t i = 0; i < L; ++i) {
    A[S[i] - 'a'].emplace_back(i);
  }

  queue<int64_t> q;
  int64_t num = 0;
  for (int64_t a = 0; a < 26; ++a) {
    if (A[a].size() > 0) {
      ++num;
      for (auto &i : A[a]) {
        q.emplace(i);
      }
      if (num > K) {
        break;
      }
    }
  }

  vector<string> result;
  unordered_map<string, int32_t> ump;
  while (!q.empty()) {
    const int64_t i = q.front();
    q.pop();
    for (int64_t j = i; j < L && j - i + 1 <= K; ++j) {
      string temp = S.substr(i, j - i + 1);
      if (ump.find(temp) == ump.end()) {
        result.emplace_back(temp);
        ump[temp] = 0;
      }
    }
  }
  nth_element(result.begin(), result.begin() + (K - 1), result.end());
  cout << result[K - 1] << endl;
  return 0;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (2000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a<c&&c<b)||(b<c&&c<a)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vsort(a) sort(a.begin(),a.end(),greater<int>());

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> r(a), g(b), t(c);
	rep(i, a) cin >> r[i];
	rep(i, b) cin >> g[i];
	rep(i, c) cin >> t[i];
	vsort(r);
	vsort(g);
	rep(i, x) {
		if (r.size() == 0) break;
		t.push_back(r[0]);
		r.erase(r.begin());
	}
	rep(i, y) {
		if (g.size() == 0) break;
		t.push_back(g[0]);
		g.erase(g.begin());
	}
	
	vsort(t);
	ll sum = 0;
	rep(i,x + y) sum += t[i];
	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
ll n, m, x;
ll ans=INF;
vector<vector<ll> > a;
void dfs(vector<int> A){
    if(A.size()<n){
        A.push_back(1);
        dfs(A);
        A.erase(A.end()-1);
        A.push_back(0);
        dfs(A);
        A.erase(A.end()-1);
    }
    if(A.size()==n){
        bool flg=true;
        ll price=0;
        rep(i,n){
            price+=a[i][0]*A.at(i);
        }
        for(int j=1;j<m+1;j++){
            ll cnt=0;
            rep(i, n){
                cnt+=a[i][j]*A.at(i);
            }
            if(cnt<x){
                flg=false;
                break;
            }
        }
        if(flg){
            chmin(ans, price);
        }
    }
}
int main(int argc, char const *argv[]){
    cin >> n >> m >> x;
    a = vector<vector<ll> >(n, vector<ll>(m+1));
    rep(i, n){
        rep(j, m+1){
            cin >> a[i][j];
        }
    }
    dfs(vector<int>(0));
    if(ans==INF) ans=-1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int r,tmp;
int main () {
	
	int K;
	scanf("%d",&K);
	
	int answer =0;
	
	for(int i=1;i<=K;i++) {
		for(int j=1;j<=K;j++) {
			int a=i;int b=j;
			if(a<b){
				tmp = a;
				a=b;
				b=tmp;
			}
			r=a%b;
			while(r!=0){
				a=b;b=r;
				r=a%b;
			}
			
			for(int k=1;k<=K;k++) {
				int a=b;int b=k;
				if(a<b){
					tmp = a;
					a=b;
					b=tmp;
				}
				r=a%b;
				while(r!=0){
					a=b;b=r;
					r=a%b;
				}
				
  				answer += b;
  			}
  		}
  	}
  printf("%d",answer);
	
	return 0;
}

Measured memory_bytes: 1732
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const long long MAX = 1000000000000001;
const int N = 50;
long long n;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	string ans;
	while (n){
		n--;
		ans =  (char)(n % 26 + 'a') + ans;
		n/=26;
	}
	cout << ans;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(int x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(int i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
      string s;
      map<string,int>tes;
      while(n--)
      {
          cin>>s;
          tes[s]++;
      }
      cout<<"AC x "<<tes["AC"]<<'\n';
      cout<<"WA x "<<tes["WA"]<<'\n';
      cout<<"TLE x "<<tes["TLE"]<<'\n';
      cout<<"RE x "<<tes["RE"]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
main(){
int n,a[25];
while(scanf("%d",&n),n){
memset(a,0,sizeof(a));
for(int i = 0;i < n;i++)scanf("%d",a+i);
int i = 0,s = 32,t = 1;
while(s != 0){
(t)?s -= ((s - 1) % 5):s -= a[i++ % n];
if(s < 0)s = 0;
printf("%d\n",s);
t = !t;
}
}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    for(int i = 0; i < b; i++) cout << a;

    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int N;
  cin >> N;
  int A[N];
  rep(i, 0, N) cin >> A[i];
  sort(A, A+N);

  int ans = 0;
  int cnt = 1;
  rep(i, 1, N) {
    if (A[i] == A[i-1]) {
      cnt++;
    } else {
      ans += (cnt%2);
      cnt = 1;
    }
  }
  ans += (cnt%2);
  cout << ans << "\n";
}

Measured memory_bytes: 640
#include<stdio.h>

int search(int A[],int n,int key){
	int i = 0;
	A[n] = key;
	while(A[i] != key){
		i++;
	}
	return i != n;
}

int main(void){
	int i, n, A[10000+1], q, key, sum = 0;
	scanf("%d", &n);
	for(i = 0;i < n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i = 0;i < q;i++){
		scanf("%d",&key);
		if(search(A,n,key)){
			sum++;
		}
		
	}
	printf("%d\n", sum);
	return 0;
}



Measured memory_bytes: 2084
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n;


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    cin>>n;
    ll sum = 0;
    foo(a,1,n){
        foo(b,1,n){
            foo(c,1,n){
                ll gc = a;
                gc = __gcd(gc,b);
                gc = __gcd(gc,c);
                
                sum += gc;
            }   
        }
    }

    cout<<sum;
    newl;
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8344
#include <stdio.h>

int N,M;
char S[511][511],R[511][511],B[511][511];
int main()
{
	scanf ("%d %d",&N,&M);

	for (int i=0;i<N;i++) scanf ("%s",S[i]);

	for (int i=0;i<N;i++) for (int j=0;j<M;j++) R[i][j] = B[i][j] = '.';

	for (int i=0;i<M;i++){
		R[0][i] = B[N-1][i] = '#';
	}

	for (int i=1;i<N-1;i++) for (int j=1;j<M-1;j++){
		if (S[i][j] == '#') R[i][j] = B[i][j] = '#';
		if (j % 2) R[i][j] = '#';
		else B[i][j] = '#';
	}

	for (int i=0;i<N;i++) puts(R[i]); puts("");
	for (int i=0;i<N;i++) puts(B[i]);;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const ll N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e9;
vi a(N);
void solve(){
    int n;
    cin >> n;
    ll sum = 0;
    //memset(a, 0, sizeof(a));
    for(int i = 0; i < N; i++){
        a[i] = 0;
    }
    for(int i = 0; i < n; i++){
        int j;
        cin >> j;
        sum += j;
        a[j]++;
    }
    int q;
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        sum -= a[b] * 1ll * b;
        sum += a[b] * 1ll * c;
        a[c] += a[b];
        a[b] = 0;
        //cout << a[b] << " " << a[c] << " ";
        cout << sum << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
# PDFで解法が4つも書いてある。これはその最初の解法

x,y,z,k =  list(map(int, input().split() ))

aa = list(map(int, input().split() ))
bb = list(map(int, input().split() ))
cc = list(map(int, input().split() ))

aa.sort(reverse = True)
bb.sort(reverse = True)
cc.sort(reverse = True)
# 降順＝大きい方から順

ab = [i + j for i in aa for j in bb]
# appendを使うと遅いので、二重の内包記法を使う 
# 外側でaaの要素、内側でbbの要素が動いていく。今回はどっちでも良いけど。
ab.sort(reverse = True)

max_len = min(k, len(ab))
abc = [i + j for i in ab[:max_len] for j in cc]
abc.sort(reverse = True)

for i in range(k):
	print(abc[i])


Measured memory_bytes: 145032
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    int last = 1;
    int res = 1;
    int n = s.size();
    int index = 1;
    while (index < n) {
        if (last == 2) {
            last = 1;
            res++;
            index++;
        } else {
            if (s[index] != s[index - 1]) {
                res++;
                index++;
            } else {
                if (index != n - 1) res++;
                index += 2;
                last = 2;
            }
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

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

using namespace std;
using ll = long long;

int main()
{
	int K;
	cin >> K;
	if (K % 2) {
		int a = K / 2 + 1;
		cout << a * (a-1) << endl;
	} else {
		int a = K / 2;
		cout << a * a << endl;
	}
}



Measured memory_bytes: 256
const Main = (input) => {
  const tmp = input.trim().split(' ').map(n => parseInt(n))
  const A = tmp[0]
  const B = tmp[1]
  const N = tmp[2]

  let x = Math.min(B - 1, N)

  const result = Math.floor(A * x / B) - (A * Math.floor(x / B))

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29500
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;

int n, k;
int a[maxn], dp[maxn];

int dfs(int rem)
{
    if (dp[rem])
        return dp[rem];
    bool flag = false;
    for (int i = 0; !flag && i != n; ++i)
        if (a[i] <= rem && dfs(rem - a[i]) == -1)
            flag = true;
    return dp[rem] = (flag ? 1 : -1);
}

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i != n; ++i)
        scanf("%d", &a[i]);
    puts(dfs(k) == 1 ? "First" : "Second");
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct edge { int to; int i; };

vector<vector<edge>> e;
vector<bitset<50>> root;

bool dfs(int u, int v, int i, int p=-1) {
  for (auto x: e[u]) {
    if (x.to==p) continue;
    if (x.to==v||dfs(x.to,v,i,u)) {
      root[i].set(x.i);
      return true;
    }
  }
  return false;
}

int main() {
  int N; cin >> N;
  e.resize(N);
  rep(i,N-1) {
    int a, b; cin >> a >> b; a--; b--;
    e[a].push_back({b,i});
    e[b].push_back({a,i});
  }
  int M; cin >> M;
  root.resize(M);
  rep(i,M) {
    int u, v; cin >> u >> v; u--; v--;
    dfs(u,v,i);
  }
  // debug(all(root));

  ll result = 0;
  rep(i,(1<<M)) {
    bitset<50> tmp = {};
    int count = 0;
    rep(j,M) if (i&(1<<j)) { tmp |= root[j]; count++; }
    result += pow(2,(N-1)-tmp.count()) * (count%2==0 ? 1 : -1);
    // cout << i << " " << count << " " << pow(2,(N-1)-tmp.count()) << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	static int[] nk = new int[2];
	static int[] a; 
	static List<Long> sel = new ArrayList<>();
	
	public static void main(String[] args) throws Exception{
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			nk = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			a = new int[nk[0]];
			a = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			
		}
		
		long max = 0;
		for (int i=0; i<nk[0]; i++) {
			long tmp = 0;
			for (int j=i; j<nk[0]; j++) {
				tmp += a[j];
				sel.add(tmp);
				if(tmp > max) max = tmp;
			}
		}

		long rst = 0;
		
		for(long i=40; i>=0; i--) {
			int cnt = 0;
			long y = 1L << i;
			for (Long l : sel) {
				if((l & y) > 0) cnt++;
				if(cnt == nk[1]) {
					rst |= y;
					sel.removeIf(n -> (n & y) == 0);
					break;
				}
			}
		}
		
		System.out.println(rst);
	}
}


Measured memory_bytes: 51028
#include <bits/stdc++.h>
using namespace std;
string solve(int k, string s) {
    if (k == 1) return s;
    for (int i = s.size()-1; i > 0; i--) {
        if (s[i-1] < s[i]) {

        }
        else {
            if (s[i] != '9') {
                s[i]++;
                for (int j = i+1; j < s.size(); j++) {
                    s[j] = max(s[j-1]-1, (int)'0');
                }
                return solve(k-1, s);
            }
        }
    }
    if (s[0] == '9') {
        return solve(k-1, '1'+string(s.size(), '0'));
    }
    else {
        s[0]++;
        for (int j = 1; j < s.size(); j++) {
            s[j] = max(s[j-1]-1, (int)'0');
        }
        return solve(k-1, s);
    }
}
int main () {
    int K;
    cin >> K;
    if (K <= 9) {
        cout << K << endl;
        return 0;
    }
    cout << solve(K-9, "10");
}

Measured memory_bytes: 17408
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
aa=[[False for i in range(3)] for j in range(3)]
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                aa[j][k]=True

bingo=False

for i in range(3):
    if aa[i][0] & aa[i][1] & aa[i][2]:
        bingo=True

for i in range(3):
    if aa[0][i] & aa[1][i] & aa[2][i]:
        bingo=True

if aa[0][0] & aa[1][1] & aa[2][2]:
    bingo=True

if aa[0][2] & aa[1][1] & aa[2][0]:
    bingo=True

if bingo:print("Yes")
else:print("No")

Measured memory_bytes: 3064
a,b,c = map(int,input().split())
k = int(input())

m = a
count = 0
if b>m:
    m=b
    count=1
if c>m:
    m=c
    count=2

if count==0:
    print(a*2**k+b+c)
if count==1:
    print(a+b*2**k+c)
if count==2:
    print(a+b+c*2**k)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

	int N;
	cin >> N;

	int a, b, c;
	while (N--)
	{
		cin >> a >> b >> c;

		if (a*a + b*b == c*c || b*b + c*c == a*a || a*a + c*c == b*b)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
//shivamgor498
// https://codeforces.com/gym/100886/problem/G
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define L 1000000000
using namespace std;
//vector<ll>prime(15000002,0);
ll mM(ll a,ll b,ll mod){ll res = 0;a %= mod;while(b){if (b & 1)res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}
ll fpow(ll x,ll y,ll p){x=x%p;ll res=1;while(y){if(y&1)res=(res*x)%p;res%=p;if(res<0)res=(res+p)%p;y=y>>1;x=(x*x)%p;if(x<0)x=(x+p)%p;x%=p;}return res;}
ll inv(ll n,ll p){return fpow(n,p-2,p);}
ll modmul(ll x,ll y){return (x*y)%hell;}
ll modadd(ll x,ll y){if(x>=hell)x-=hell;if(y>=hell)y-=hell;ll temp=x+y;if(temp>=hell)temp-=hell;if(temp<0)temp = temp+hell;return temp;}
/*void sieve(){
	prime[0] = -1;
	prime[1] = 0;
	for(ll i=2;i<=15000000;i++)
		if(!prime[i])
			for(ll j=i;j<=15000000;j+=i)
				if(!prime[j])
					prime[j] = i;
}*/
int main(){
	ios
	ll t = 1;
	//cin >> t;
	//sieve();
	while(t--){
		ll n;
		cin >> n;
		vector<long double>p(n+1);
		for(int i=1;i<=n;i++)
			cin >> p[i];
		long double dp[n+1][n+1]; //dp[i][j] means probablity of getting i heads from j coins
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				dp[i][j] = 0;
		dp[0][0] = 1; //probablity of getting 0 heads from 0 coins
		for(int i=1;i<=n;i++)
		{
			long double head = p[i],tail = 1-p[i];
			dp[0][i] = tail*dp[0][i-1];
			for(int j=1;j<=i;j++)
				dp[j][i] = head*dp[j-1][i-1] + tail*dp[j][i-1];
		}
		long double ans = 0;
		for(int i=(n/2)+1;i<=n;i++)
			ans+=dp[i][n];
		cout << fixed << setprecision(10);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 140928
#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(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()){
        if(s[i]==t[i]) ++ans;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
def addset(args):
    global a
    for m in args:
        if dic[m]==1:
            a.add(m)
        else:
            if m not in used:
                used.add(m)
                addset(dc[m])
 
while True:
    n=int(input())
    if n==0:
        break
    dic={}
    first=[]
    dc={}
    for i in range(n):
        g,m=input().split(':')
        m=m.rstrip('.').split(',')
        dc[g]=m
        if i==0:
            first.append(g)
            first+=m
        dic[g]=2
        for mem in m:
            if mem not in dic:
                dic[mem]=1
    a=set()
    used=set()
    addset(first[1:])
    print(len(a))


Measured memory_bytes: 5848
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const double INF = 1e18;
const int MAX = 1000004;

int N,M;
LL a[MAX];

LL DP(int N)
{
    if(a[N]!=0)
        return a[N];
    else
        return a[N] = DP(N-1)+DP(N-2);
}

int main()
{
    cin>>N;
    a[0] = 2,a[1] = 1;
    cout<<DP(N)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
string a,b="CF";
int al,bl;
int main()
{
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ 
            bl++;
            if(bl==2)   
                break;
        }
    if(bl==2) cout<<"Yes"; 
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    int result = 0;
    while (n > 0) {
        if ((n%10 != 9) && n>9) {
            result += 9;
            n = (n/10) - 1;
        } else {
            result += n%10;
            n /= 10;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3560
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int x = Integer.parseInt(sc.next());
        if (x == 1) {
            out.println(0);
        } else {
            out.println(1);
        }
        sc.close();
        out.close();
    }

}

Measured memory_bytes: 35648
var input = function(){
  return input= require('fs').readFileSync('/dev/stdin', 'utf8').split(" ").map(Number);
  };

var out = function(x)
{
  console.log(x);
  return x;
}

var range = function(a,b)
{
  var array = [];
  for (var i = a; i <= b; i++) {
    array[i] = i;
  }
  return array;
}

var calc = function(x)
{
  out(range(x[0],x[1]).filter(function(element)
  {
    if ((x[2] % element) == 0 )
    {
      return true;
    }
  }).length);
};

calc(input());

Measured memory_bytes: 9340
#include <cstdio>
#include <vector>
#include <stack>
#include <utility>

bool visit[100000];
int x[100000];
using pair = std::pair<int, long long>;

struct edge
{
  int to;
  long long cost;
};
std::vector<edge> edges[200000];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int l, r; long long d;
    scanf("%d%d%lld", &l, &r, &d);
    --l, --r;
    edges[l].emplace_back(edge{r, d});
    edges[r].emplace_back(edge{l, -d});
  }
  std::stack<pair> stack;
  for (int i = 0; i < n; ++i)
  {
    if (visit[i]) continue;
    visit[i] = true;
    stack.emplace(std::make_pair(i, 0));
    while (stack.size() > 0)
    {
      auto p = stack.top();
      stack.pop();
      for (auto e : edges[p.first])
      {
        if (visit[e.to])
        {
          if (x[e.to] != p.second + e.cost)
          {
            puts("No");
            return 0;
          }
        }
        else
        {
          visit[e.to] = true;
          x[e.to] = p.second + e.cost;
          stack.emplace(std::make_pair(e.to, p.second + e.cost));
        }
      }
    }
  }
  puts("Yes");
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;

#define endl "\n"

const int MOD = 1000000007;


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    char a,b,t;
    char z = '>';
    char x = '<';
    char y = '=';
    
        scanf("%c %c",&a,&b);
        if(a > b){
        printf("%c\n",z);
        }
        else if(a < b){
            printf("%c\n",x);
        }
        else if(a == b){
            printf("%c\n",y);
        }
    
	return 0;
}


Measured memory_bytes: 3820
#include<iostream>
#include<cstdio>
#include<vector>


using namespace std;

int main()
{
  int n;
  
  cin >> n;
  
  vector<int> a(n);
  long long s=0,t=0;
  
  for(int i=0;i<n;i++){
    cin >> a[i];
    t += a[i];
  }
  
  long long min = 9223372036854775807;
  
  for(int i=0;i<n-1;i++){
    s += a[i];
     t-= a[i];
    
    if(min > abs(s-t)){
        min = abs(s-t);
    }
  }
  
  cout << min << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

struct diff {
  int index;
  int value;
  bool operator<( const diff& right ) const {
    return value < right.value;
  }
};

bool sortByIndex( const diff& left, const diff& right ) {
    return left.index < right.index;
}

bool sortByValue( const diff& left, const diff& right ) {
    return left.value < right.value;
}

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  int n,m;
  cin >> n >> m;
  vector<int> x(m,0);
  r(i,m) cin >> x[i];
  if(n>m) {
    cout << 0 << endl;
    return 0;
  }
  sort(ALL(x));
  vector<struct diff> diff(m-1);
  r(i,m-1){
    diff[i].index = i;
    diff[i].value = abs(x[i+1]-x[i]);
  }
  sort(ALL(diff),sortByValue);
  int count = 0;
  r(i,m-n) count += diff[i].value;
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  // ビンゴを入力する
  // 出玉を入力する
  // 出玉について、ビンゴから0にする
  // ビンゴ判定をする

  int N, a, b;
  vector<vector<int>> vec(3, vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a;
      vec.at(i).at(j) = a;
    }
  }

  cin >> N;
  for (int n = 0; n < N; n++) {
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if(vec.at(i).at(j) == b) vec.at(i).at(j) = 0;
      }
    }
  }

  if(
      ((vec.at(0).at(0) + vec.at(0).at(1) + vec.at(0).at(2)) == 0) ||
      ((vec.at(1).at(0) + vec.at(1).at(1) + vec.at(1).at(2)) == 0) ||
      ((vec.at(2).at(0) + vec.at(2).at(1) + vec.at(2).at(2)) == 0) ||
      ((vec.at(0).at(0) + vec.at(1).at(0) + vec.at(2).at(0)) == 0) ||
      ((vec.at(0).at(1) + vec.at(1).at(1) + vec.at(2).at(1)) == 0) ||
      ((vec.at(0).at(2) + vec.at(1).at(2) + vec.at(2).at(2)) == 0) ||
      ((vec.at(0).at(0) + vec.at(1).at(1) + vec.at(2).at(2)) == 0) ||
      ((vec.at(0).at(2) + vec.at(1).at(1) + vec.at(0).at(2)) == 0)
    ){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

  return 0;
}

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

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

#define p 2019

int main() {
	int l, r;
	while (scanf("%d%d", &l, &r) != EOF) {
		if (r - l + 1 >= 3000) {
			puts("0");
			continue;
		} else {
			int res = 1e9;
			for (int i = l; i <= r; ++i) {
				for (int j = l; j < i; ++j) {
					res = min(res, (i % p) * (j % p) % p);
				}
			}
			printf("%d\n", res);
		}
	}
	return 0;
}


Measured memory_bytes: 256
n= int(input())
x=[]
for i in  range(n):
    x.append([int(x ) for  x in input().split()])

dp = [[x[0][0],x[0][1],x[0][2]] for i in range(n)]
for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+x[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+x[i][1]
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+x[i][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

Measured memory_bytes: 100972
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	string S;
	int AC=0,WA=0,TLE=0,RE=0;
	for (i=0;i<N;i++){
		cin>>S;
		if (!S.compare("AC")){
			AC++;
		}
		if (!S.compare("WA")){
			WA++;
		}
		if (!S.compare("TLE")){
			TLE++;
		}
		if (!S.compare("RE")){
			RE++;
		}
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
	return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int A, B;
    cin>>A>>B;
    cout << A*B << endl; 
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
	}
	cout << (N - 1 + K - 2) / (K - 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,l;
  cin>>n>>l;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  deque<int> q;
  auto pb=[&](int x){
    while(!q.empty()&&a[q.back()]>=a[x]) q.pop_back();
    q.push_back(x);
  };
  for(int i=0;i<l;i++) pb(i);
  for(int i=l;i<n;i++){
    cout<<a[q.front()]<<" ";
    pb(i);
    while(!q.empty()&&q.front()<=i-l) q.pop_front();
  }
  cout<<a[q.front()]<<endl;
  return 0;
}

Measured memory_bytes: 10936
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main ()
{
  int n,k;
  cin>>n;
  map<int,int> m;
  int temp;
  for(int i=0;i<n;i++)
  {
      cin>>temp;
      m[temp]=i+1;
  }
  for(int i=0;i<n;i++)
  {
      cout<<(m.find(i+1)->second)<<" ";
  }
  return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int get(int a)
{
	int ret=0;
	while(a)
	{
		ret+=a%10;
		a/=10;
	}
	return ret;
}
int main()
{
	int a,b,c;
	scanf("%d",&a);
	int tmp=a%get(a);
	if(tmp==0) cout<<"Yes";
	else cout<<"No"; 
	return 0; 
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;



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

  int n, k;
  cin >> n >> k;

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

  int see[n];
  int cur = 0;

  for (int i = 0; i < n; i++)
    see[i] = -1;
  
  see[0] = 0;
  int offset, T;
  for (int i = 1; i < n + 1; i++){
    cur = a[cur];
    if (see[cur] != -1){
      T = i - see[cur];
      offset = see[cur];
      break;
    }
    see[cur] = i;
  }

  int g = k <= offset? k: offset + (k - offset) % T;
  cur = 0;
  for (int i = 0; i < g; i++)
    cur = a[cur];
  cout << cur + 1 << endl;
  
}


Measured memory_bytes: 6780
N, K = map(int, input().split())
X = list(map(int, input().split()))
k = float("INF")
for i in range(N-K+1):
	l = X[i]
	r = X[i+K-1]
	k = min(k, abs(l)+abs(r-l), abs(r)+abs(r-l))
print(k)

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

ls = len(s)
lt = len(t)

res = 0
for i in range(ls-lt+1):
    ss =s[i:i+lt]
    cnt = 0
    for j in range(lt):
        if ss[j] == t[j]:
            cnt += 1
    res = max(res, cnt)

print(lt - res)

Measured memory_bytes: 67704
use proconio::input;

fn main() {
  input! {
    n: usize,
    k: usize,
  };
  let mut has = vec![true; n];
  for _i in 0..k {
    input! {
      d: usize,
      a: [usize;d],
    };
    for j in 0..d {
      has[a[j]-1] = false;
    }
  }
  println!("{}", has.iter().filter(|x| **x).count());
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int d, t, s;
	cin >> d >> t >> s;

	if (d <= t * s)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 3580