akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<ll> a(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '>') {
            a[i] = a[i + 1] + 1;
        }
    }
    bool start = false;
    for (int i = 0; i <= n; i++) {
        if (a[i] == 0) {
            if (start) {
                a[i] = a[i - 1] + 1;
            } else {
                start = true;
            }
        } else {
            if (start) {
                a[i] = max(a[i - 1] + 1, a[i]);
            }
            start = false;
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += a[i];
        // cout << a[i] << ' ';
    }
    // cout << '\n';
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<bits/stdc++.h>
#define ll long double
using namespace std;
 
int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     
    int n;
    cin>>n;
    int flag=0;
    while(n!=0)
    {
    	
      int r=n%10;
      n=n/10;
      if(r==7)
      {
      	flag=1;
      	
	  }
    	
    	
	}
	
	
	if(flag==1)
	{
		
		
		cout<<"Yes"<<endl;
	}
	
	
	else if(flag==0)
	{
		cout<<"No"<<endl;
		
	}
    
    
     
    return 0;
    
}

Measured memory_bytes: 3528
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
ans = None
for i in range(n-1):
    if s[i]==s[i+1]:
        ans = (i+1,i+2)
        
for i in range(n-2):
    if s[i]==s[i+2]:
        ans = (i+1,i+3)
if ans is not None:
    print(" ".join(map(str, ans)))
else:
    print("-1 -1")

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

using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}


double const eps = 1e-10;
ll const mod = 1e9+7;

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

    int a,b,c;
    cin >> a >> b >> c;
    if ( b-a == c-b ) cout << "YES";
    else cout << "NO";



    return 0;

    // 274751WM
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    string s;
    int q;
    cin >> s >> q;
    vector<char> Front;
    vector<char> Back;
    bool is_reversed = 0;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            if (is_reversed) is_reversed = 0;
            else is_reversed = 1;
        }
        else if (t == 2) {
            int f; char c;
            cin >> f >> c;
            if (f == 1) {
                if (is_reversed) Back.push_back(c);
                else Front.push_back(c);
            }
            else if (f == 2) {
                if (is_reversed) Front.push_back(c);
                else Back.push_back(c);
            }
        }
    }
    if (is_reversed) {
        rep(i, Back.size()) cout << Back[Back.size() - i - 1];
        reverse(s.begin(), s.end());
        cout << s;
        rep(i, Front.size()) cout << Front[i];
    }
    else {
        rep(i, Front.size()) cout << Front[Front.size() - i - 1];
        cout << s;
        rep (i, Back.size()) cout << Back[i];
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <utility>
#include <cmath>
#include <stdlib.h> 
#include <stdio.h>
#include <iterator>
#include <chrono>
#include <iomanip>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <deque>
#include <stack>
#include <queue>
#include <fstream>
#include <limits>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <sstream>
#include <random>
#include <cassert>

using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;

int main(void) {
	cin.tie(0); ios::sync_with_stdio(0);
	
	string s; int ans = 0;
	cin >> s;
	for (char c : s) {
		ans += c - '0';
		ans %= 9;
	}
	cout << (ans % 9 == 0 ? "Yes" : "No");
}





/*
C:\Users\User\Desktop\comp_programming\final_straw_after_this_im_switching_to_vs_code\final_straw_after_this_im_switching_to_vs_code.cpp
*/

Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		int[] l = new int[10];
		int[] v = new int[2];

		while ((line = br.readLine()) != null) {
			String[] data = line.trim().split(",");
			int distance = 0;
			for (int i = 0; i < 10; i++) {
				l[i] = Integer.parseInt(data[i]);
				distance += l[i];
			}
			for (int i = 0; i < 2; i++)
				v[i] = Integer.parseInt(data[i + 10]);
			double see = distance * ((double) v[0] / (v[1] + v[0]));

			for (int i = 0; i < 10; i++) {
				if (see - l[i] > 0) {
					see -= l[i];
				} else {
					System.out.println(i + 1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 16908
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> cnt(n);
    int maxi = 0;
    rep(i, n){
        cnt[a[i]]++;
        maxi = max(maxi, a[i]);
    }

    if(maxi % 2){
        for(int i = maxi; i > 0; i--){
            if(i <= maxi / 2){
                if(cnt[i] > 0){
                    cout << "Impossible" << endl;
                    return 0;
                }
                continue;
            }
            if(i == (maxi + 1) / 2){
                if(cnt[i] != 2){
                    cout << "Impossible" << endl;
                    return 0;
                }
                continue;
            }
            if(cnt[i] < 2){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }else{
        for(int i = maxi; i > 0; i--){
            if(i < maxi / 2){
                if(cnt[i] > 0){
                    cout << "Impossible" << endl;
                    return 0;
                }
                continue;
            }
            if(i == maxi / 2){
                if(cnt[i] != 1){
                    cout << "Impossible" << endl;
                    return 0;
                }
                continue;
            }
            if(cnt[i] < 2){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A;
    int temp;
    for(int i = 0; i < N; i++){
        cin >> temp;
        A.push_back(temp);
    }
    sort(A.begin(),A.end());
    cout << abs(A[(int)(A.size()/2)] - A[(int)(A.size()/2) - 1]) << endl;
    
}

Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  long long ans = 1;
  REP(i, n) {
    long long t; cin >> t;
    // ans = ans * t / __gcd(ans, t);
    long long g = __gcd(ans, t);
    t /= g;
    ans *= t;
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>graph(n+1, vector<int>(0));
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		graph.at(x).push_back(y);
		graph.at(y).push_back(x);
	}
	queue<int>s;
	s.push(1);
	vector<int>ed(n+1,-1);
	ed.at(1) = 1;
	int x = s.front();
	for (int i = 0; i < graph.at(x).size(); i++) {
		if (ed.at(graph.at(x).at(i)) == -1) {
			s.push(graph.at(x).at(i));
			ed.at(graph.at(x).at(i)) = 1;
		}
	}
	s.pop();
	while (s.size() >= 1) {
		int y = s.front();
		for (int i = 0; i < graph.at(y).size(); i++) {
			if (ed.at(graph.at(y).at(i)) == -1) ed.at(graph.at(y).at(i)) = 1;
		}
		s.pop();
	}
	if (ed.at(n) != -1)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;  
  cout << "AB" << "CD"[N > 999] << "\n";  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <string.h>

using namespace std;

int main()
{
	map< char, int > table;
	table['A'] = 0;
	table['I'] = 1;
	table['V'] = 5;
	table['X'] = 10;
	table['L'] = 50;
	table['C'] = 100;
	table['D'] = 500;
	table['M'] = 1000;
	string str;
	int sum, sz;

	while ( cin >> str )
	{
		sum = 0;
		sz = str.size();
		str.push_back( 'A' );
		for ( int i = 0 ; i < sz ; i++ )
		{
			if( table[str[i]] < table[str[i+1]] )
				sum = sum - table[str[i]];
			else 
				sum = sum + table[str[i]];
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 2e3 + 5;

vector <int> g[N];
int d[N][N];
int n;

void bfs(int s) {
  queue<int> q;
  vector<bool> used(n);
  vector<int> p(n);

  q.push(s);
  used[s] = true;
  p[s] = -1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : g[v]) {
        if (!used[u]) {
            used[u] = true;
            q.push(u);
            d[s][u] = d[s][v] + 1;
            p[u] = v;
        }
    }
  }
}

int main() {
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  int x, y; cin >> x >> y;
  x--, y--;
  g[x].push_back(y);
  g[y].push_back(x);
  for(int i = 0; i < n; i++) {
    bfs(i);
  }
  vector <int> cnt(n, 0);
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      cnt[d[i][j]]++;
    }
  }
  for(int i = 1; i <= n - 1; i++) {
    cout << cnt[i] << '\n';
  }
}

Measured memory_bytes: 16128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
#define reps(i,j,N) for(LL i=j;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

int N, K, a[5112];
int ans;

int main()
{
	in >> N >> K;
	rep(i, N) { in >> a[i]; }

	LL sum;
	std::sort(a, a + N, std::greater<int>());
	rep(i, N)
	{
		sum = 0;
		reps(j, i, N)
		{
			sum += a[j];
			if (sum >= K)
			{
				ans = std::max<LL>(ans, j + 1);
				sum -= a[j];
			}
		}
	}
	ans = N - ans;

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  string s, t; cin >> s >> t;
  int N, M;
  N = s.size();
  M = t.size();
  vector<int> vs(26, 0), vt(26, 0);
  bool ok = false;
  for(int i = 0; i < N; i++){
    int num = s[i] - 'a';
    vs[num]++;
  }
  for(int i = 0; i < M; i++){
    int num = t[i] - 'a';
    vt[num]++;
  }
  int s_top, t_tail;
  for(int i = 0; i < 26; i++){
    if(vs[i] > 0){
      s_top = i;
      break;
    }    
  }
  for(int i = 25; i >= 0; i--){
    if(vt[i] > 0){
      t_tail = i;
      break;
    }    
  }
  if(s_top < t_tail) ok = true;
  if(N < M){
    for(int i = 0; i < 26; i++){
      if(s[i] > t[i]) break;
      if(i == 25) ok = true;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define mst(x, a) memset(x, a, sizeof(x))

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9 + 7;

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

int main() {
  int K, N;
  scanf("%d %d", &K, &N);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }

  int ans = a[N - 1] - a[0];
  for (int i = 1; i < N; i++) {
    ans = min(ans, K - a[i] + a[i - 1]);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=1000005;
const int mod=1e9+7;
inline int Add(int x,int y){
    return (x+=y)>=mod?x-mod:x;
}
inline int Sub(int x,int y){
    return (x-=y)>=0?x:x+mod;
}
inline int Mul(int x,int y){
    return 1ll*x*y%mod;
}
inline int Pow(int x,int y){
    if(y==0)return 1;
    int res=1;
    while(y){
        if(y&1)res=1ll*res*x%mod;
        y>>=1;
        x=1ll*x*x%mod;
    }
    return res;
}
int x,y;
int fac[max_n],inv[max_n];
int C(int n,int m){
    if(n<m||m<0)return 0;
    return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void init(int n){
    fac[0]=1;
    for(int i=1;i<=n;i++)fac[i]=Mul(fac[i-1],i);
    inv[n]=Pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--)inv[i]=Mul(inv[i+1],i+1);
}
int main(){
    scanf("%d%d",&x,&y);
    if((2*x-y)%3)return printf("0\n"),0;
    int a=(2*y-x)/3,b=(2*x-y)/3;
    if(a<0||b<0)return printf("0\n"),0;
    init(a+b);
    printf("%d\n",C(a+b,a));
    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10 , mod = 1e9 + 7;
int d[N][2];
vector < int > edges[N];
void dfs(int x , int p){
      int all_white = 1;
      int all = 1;
      for(int i : edges[x]){
            if(i != p){
                  dfs(i , x);
                  all_white *= d[i][0];
                  all_white %= mod;
                  all *= d[i][0] + d[i][1];
                  all %= mod;
            }
      }
      d[x][1] = all_white;
      d[x][0] = all % mod;
}
main(){
      int n;
      cin >> n;
      for(int i = 1; i < n; i ++){
            int a , b;
            cin >> a >> b;
            edges[a].push_back(b);
            edges[b].push_back(a); 
      }
      dfs(1 , 0); 
      cout << (d[1][0] + d[1][1]) % mod << "\n";
}

Measured memory_bytes: 14208
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int k = in.nextInt();
      int[] p = new int[n];
      for (int i = 0; i < n; i++) p[i] = in.nextInt();
      Arrays.sort(p);
      int ans = 0;
      for (int i = 0; i < k; i++) ans += p[i];
      out.println(ans);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 33364
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        
        c-=b;
        if(c<=0){
            cout<<"Yes";
            break;
        }
        
        a-=d;
        if(a<=0){
            cout<<"No";
            break;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		long x = sc.nextLong();

		for(int i=0; i<10; i++) {
			x = r * x - D;
			System.out.println(x);
		}

		sc.close();
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    assert(i < n);
    for (i++; i <= n; i += i&-i) { //LSB:i&(-i)
      d[i] += x;
    }
  }
  T sum(int i) {
    assert(i < n);
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) { //[l,r)
    assert(l < n);
    assert(r <= n);
    return sum(r-1) - sum(l-1);
  }
  T operator[](const int &i){
    assert(i < n);
    return sum(i, i+1);
  }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<vector<int> > a(2*n),b(2*n);
  rep(i,n) {
    int x,y;
    cin >> x >> y;
    a[x].emplace_back(y);
  }
  rep(i,n) {
    int x,y;
    cin >> x >> y;
    b[x].emplace_back(y);
  }
  BIT<int> bit(2*n);
  int ans = 0;
  for (int bx = 2*n-1; bx > 0; --bx) {
    for (auto by : b[bx]) {
      bit.add(by);
    }
    if (a[bx-1].size() == 0) continue;
    sort(all(a[bx-1]), greater<int>());
    for (auto y : a[bx-1]) {
      if (y == 2*n-1) continue; //どうやっても取れない
      if (bit.sum(y+1,2*n) > 0) {
        for (int i = y+1; i < 2*n; ++i) {
          if (bit[i] > 0) {
            bit.add(i,-1);
            ans++; break;
          }
        }
      }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int z = 0; z < n; z++) {
		int r, t;
		cin >> r >> t;
		if (r % 100 == 0 && t % 30 == 0) {
			cout << (t / 30 * 5 + r / 100) << endl;
		}
		else if (r%100 == 0) {
			int t2 = t % 30, t3 = t + (30 - t2);
			t2 = t - t2;
			int b[2] = { (t2 / 30 * 5 + r / 100),(t3 / 30 * 5 + r / 100) };
			sort(b, b + 2);
			for (int i = 0; i < 2; i++) {
				if (i == 0) cout << b[i];
				else cout << " " << b[i];
			}
			cout << endl;
		}
		else if (t % 30 == 0) {
			int r2 = r % 100, r3 = r + (100 - r2);
			r2 = r - r2;
			int b[2] = { (t / 30 * 5 + r2 / 100),(t / 30 * 5 + r3 / 100) };
			sort(b, b + 2);
			for (int i = 0; i < 2; i++) {
				if (i == 0) cout << b[i];
				else cout << " " << b[i];
			}
			cout << endl;
		}
		else {
			int t2 = t % 30, t3 = t + (30 - t2);
			t2 = t - t2;
			int r2 = r % 100, r3 = r + (100 - r2);
			r2 = r - r2;
			int b[4] = { (t2 / 30 * 5 + r2 / 100),(t2 / 30 * 5 + r3 / 100) , (t3 / 30 * 5 + r2 / 100),(t3 / 30 * 5 + r3 / 100) };
			sort(b, b + 4);
			for (int i = 0; i < 4; i++) {
				if (i == 0) cout << b[i];
				else cout << " " << b[i];
			}
			cout << endl;
		}
	}
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int segment[] = {
    63, //(0111111)_2                                                                                                                                                     
    6,  //(0110000)_2                                                                                                                                                     
    91, //(1101101)_2                                                                                                                                                     
    79, //(1111001)_2                                                                                                                                                     
    102,//(0110011)_2                                                                                                                                                     
    109,//(1011011)_2                                                                                                                                                     
    125,//(1011111)_2                                                                                                                                                     
    39, //(1110010)_2                                                                                                                                                     
    127,//(1111111)_2                                                                                                                                                     
    111,//(1111011)_2                                                                                                                                                     
    0,  //(0000000)_2                                                                                                                                                     
  };
  const int Default = 10;
  int n, num;

  while (cin >> n, n != -1) {
    int before = Default;
    int change;
    for (int i = 0; i < n; i++) {
      cin >> num;
      change = segment[before] ^ segment[num];
      for (int j = 0; j < 7; j++) {
        cout << (change & 64 ? 1 : 0);
        change <<= 1;
      }
      before = num;
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b, c, d) = sc.nextLine.split(" ").map(_.toInt)
    val left = a + b
    val right = c + d
    if (left == right) println("Balanced")
    else if (left > right) println("Left")
    else println("Right")
  }
}


Measured memory_bytes: 25528
// AOJ 2818: Imagawayaki Man
// 2017.11.23 bal4u@uu

#include <stdio.h>

#define N 10000
int p[N+N+2];
int a[N+1];
char buf[10], *bp;

int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, i, j, x;
	char s[20];

	fgets(bp=buf, 10, stdin), n = getint();
	for (i = 2; i <= n; i++) {
		printf("? 1 %d\n", i), fflush(stdout);
		fgets(bp=buf, 10, stdin), a[i] = getint();
		if (a[i] == 1) j = i;
	}
	p[N] = 1, p[N-1] = j;
	sprintf(s, "? %d ", j);
	for (i = 2; i <= n; i++) {
		if (i == j) continue;
		printf(s), printf("%d\n", i), fflush(stdout);
		fgets(bp=buf, 10, stdin), x = getint();
		if (x < a[i]) p[N-a[i]] = i;
		else          p[N+a[i]] = i;
	}
	for (i = 0; !p[i]; i++);
	printf("!");
	for (j = 0; j < n; j++) printf(" %d", p[i++]);
	putchar('\n');
	return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for(auto& i : v){
    cin >> i;
  }
  sort(v.begin(), v.end());
  int ret = 0;
  for(int i = 0; i < k; ++i){
    ret += v[i];
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3628
// 169_c.cc
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

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

	ll a;
	long double b;
	cin >> a >> b;

	ll x = b * a;
	cout << x << endl;

}

Measured memory_bytes: 3748
X, K, D = map(int, input().split())

X = abs(X)

# 1. 近づく
k = X // D
k = min(K, k)
X = abs(X - k * D)
K = K - k
if K == 0:
    print(X)
    exit()

# 2. 相殺する
K = K % 2
if K == 0:
    print(X)
    exit()

# 3. 最小の移動
X = abs(X - D)
print(X)


Measured memory_bytes: 9188
import sys
from collections import defaultdict
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ac = 0
    wa = 0
    b = defaultdict(lambda: 0)
    for _ in range(m):
        q, j = input().split()
        if b[q] != -1 and j == 'AC':
            ac += 1
            if q in b:
                wa += b[q]
                b[q] = -1
        else:
            if b[q] != -1:
                b[q] += 1
    print(ac, wa)

if __name__ == "__main__":
    main()


Measured memory_bytes: 53976
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val s = readLine()!!

    val rCount = s.count { it == 'R' }.toLong()
    val gCount = s.count { it == 'G' }.toLong()
    val bCount = s.count { it == 'B' }.toLong()
    var ans = rCount * gCount * bCount

    for (i in 0 until n) {
        for (j in (i + 1) until n) {
            val k = j + (j - i)
            if (k < n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
                ans--
            }
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36184
#include <bits/stdc++.h>
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
using namespace std;

const int N = 1e6 +3; 

int n , h ;
int arr[N];
 
int32_t main(){IOS;
	int test = 1; //cin >> test;
	while(test--){
		cin >> h >> n ;
		for(int i=0;i<n;i++){
			cin >> arr[i];
			h -= arr[i];
		}
		cout << ( (h<=0)?"Yes":"No" ) << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;





int main()
{
    int N,M;
    cin >> N >> M;
    vector<vector<pair<int,ll>>> G(N);
    rep(i,M){
        int L, R;
        ll C;
        cin >> L >> R >> C;
        L--,R--;
        G[L].push_back({R,C});
    }
    for (int i = 1; i < N; i++) G[i].push_back({i-1,0});
    
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
    pq.push({0,0});
    
    vector<int> f(N,true);
    ll d = 0;
    int a = 0;
    
    while (!pq.empty()) {
        
        pair<ll,int> g = pq.top();
        pq.pop();
        if(f[g.second]){
            f[g.second] = false;
            a = g.second;
            d = g.first;
            //cout << a+1 << " " << d << endl;
            if(a == N-1){
                cout << d << endl;
                return 0;
            }
            
            for (pair<ll,int> i : G[a]) {
                pq.push({i.second+d, i.first});
            }
        }
        
    }
    
    
    cout << -1 << endl;
    
    
    return 0;
}


Measured memory_bytes: 9720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramD
    {
        static void Main()
        {
            int n = NextInt, k = NextInt;
            var v = IntList;
            int result = int.MinValue;

            for (int i = 0; i <= Math.Min(n, k); i++)
            {
                for (int j = 0; i + j <= Math.Min(n, k); j++)
                {
                    var array = v.Take(i).Concat(v.Skip(n - j)).ToArray();
                    result = Math.Max(array.Where(x => x >= 0).Sum() + array.Where(x => x < 0).OrderBy(x => x).Skip(k - i - j).Sum(), result);
                }
            }

            System.Console.WriteLine(result);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 15572
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int so = (a * b)%2;
        if(so == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 23252
#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;
  ll yen;
  cin >> n >> yen;

  for(int x = 0; x <= n; x++){
    for(int y = 0; y <= n-x; y++){
      int z = n - x - y;
      if(10000*x+5000*y+1000*z==yen){
        printf("%d %d %d",x,y,z);
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 3764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int p = -1;
 //   String[] ans = new String[n];
    char[] temp = new char[n];
    for(int k = 0; k < 4; k++) {
      int m = k;
      if((m % 2) == 0) {
        temp[0] = 'W';
      } else {
        temp[0] = 'S';
      }
      m /= 2;
      if((m % 2) == 0) {
        temp[1] = 'W';
      } else {
        temp[1] = 'S';
      }
      for(int i = 1; i < (n - 1); i++) {
        if(s.charAt(i) == 'o') {
          if(temp[i] == 'W') {
            if(temp[i - 1] == 'W') {
              temp[i + 1] = 'S';
            } else {
              temp[i + 1] = 'W';
            }
          } else {
            temp[i + 1] = temp[i - 1];
          }
        } else {
          if(temp[i] == 'W') {
            temp[i + 1] = temp[i - 1];
          } else {
            if(temp[i - 1] == 'W') {
              temp[i + 1] = 'S';
            } else {
              temp[i + 1] = 'W';
            }
          }
        }
      }
      int q = 0;
      for(int i = 0; i < n; i++) {
        int a = i - 1;
        int b = i + 1;
        if(i == 0) a = (n - 1);
        if(i == (n - 1)) b = 0;
        if(s.charAt(i) == 'o') {
          if(temp[i] == 'W') {
            if(temp[a] == temp[b]) q = 1;
          } else {
            if(temp[a] != temp[b]) q = 1;
          }
        } else {
          if(temp[i] == 'W') {
            if(temp[a] != temp[b]) q = 1;
          } else {
            if(temp[a] == temp[b]) q = 1;
          }
        }
      }
      if(q == 0) {
        p = 0;
        break;
      } else {
        
      }
    }
    if(p == -1) {
      System.out.println(-1);
    } else {
      System.out.println(new String(temp));
    }
  }
}

Measured memory_bytes: 26556
#include <stdio.h>
#include <string.h>
#define N 2000000

int n=0;
int A[N+1];

void maxheapify(int i){
  int l,r,largest,cmp;

  l = 2*i;
  r = 2*i+1;

  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i) {
     cmp = A[i];
     A[i] = A[largest];
     A[largest] = cmp;
     maxheapify(largest);
  }
}
void  buildMaxHeap(){
  int i;

  for(i=n/2;i>0;--i) maxheapify(i);
}

int extractMax(){
  int max;

  max = A[1];
  
  A[1] = A[n];
  n--;

  maxheapify(1);

  return max;
  
}

void Increasekey(int i,int num){
  int cmp;
  if(num<A[i])printf("error");

  A[n] = num;

  while(i > 1 && A[i/2] < A[i]){
    cmp = A[i];
    A[i] = A[i/2];
    A[i/2] = cmp;
    i = i/2;
  }
  
}
void Heap_insert(int num){
  int i;
  
  n++;
  A[n] = -1;
  Increasekey(n,num);
}




int main(){
  int i,num;
  char order[10];
 
 
  while(1){
    scanf("%s",order);

    if(strcmp("end",order) == 0)break ;

    if(order[0]=='e')printf("%d\n",extractMax());

    else if(order[0] == 'i') {
      scanf("%d",&num);
      Heap_insert(num);
    }
  }

  return 0;
}



Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)

int main(){
	io;
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<ll>rap(a),gap(b),cap(c);
	for(ll i=0;i<a;i++){
		cin>>rap[i];
	}for(ll i=0;i<b;i++){
		cin>>gap[i];
	}for(ll i=0;i<c;i++){
		cin>>cap[i];
	}
	
	sort(rap.rbegin(),rap.rend());
	sort(gap.rbegin(),gap.rend());
	sort(cap.rbegin(),cap.rend());
	
	priority_queue<ll>q;
	ll ans=0;
	for(ll i=0;i<x;i++){
		ans+=rap[i];
		q.push(-rap[i]);
	}
	
	for(ll i=0;i<y;i++){
		ans+=gap[i];
		q.push(-gap[i]);
	}
	//cout<<ans<<endl;
	ll i=0;
	while(i<c && !q.empty()){
		ll val=q.top();
		val=-val;
		//cout<<val<<" "<<cap[i]<<endl;
		if(cap[i]>val){
			ans-=val;
			ans+=cap[i];
			i++;
			q.pop();
		}else{
			break;
		}
	}
	
	cout<<ans;
	return 0;
}


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

using namespace std;
int main() {
	for (int i=1;i>0;i++){
		int a;
		string b;
		int c;
		cin >> a >> b>>c;
		if (b == "+") {
			cout << a + c << endl;
		}
		if (b == "-") {
			cout << a - c << endl;
		}
		if (b == "*") {
			cout << a*c << endl;
		}
		if (b == "/") {
			cout << a/c << endl;
		}
		if (b == "?") break;
	}
	return 0;
}


Measured memory_bytes: 3140
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s;
        while ((s = in.readLine()) != null) {
            int i = Integer.parseInt(s);
            int ret = i + i * i + i * i * i;
            System.out.println(ret);
        }
    }
}


Measured memory_bytes: 32572
#coding:utf-8
n = int(input())
inf = 1000000000000000

def minHeapify(Q,i):
    H = len(Q)
    l = 2*i
    r = 2*i + 1
    if l < H and Q[l][1] < Q[i][1]:
        smallest = l
    else:
        smallest = i
    if r < H and Q[r][1] < Q[smallest][1]:
        smallest = r

    if smallest != i:
        Q[i], Q[smallest] = Q[smallest], Q[i]
        minHeapify(Q,smallest)

def buildMinHeap(Q):
    H = len(Q)
    for i in range(H // 2, -1, -1):
        minHeapify(Q,i)

def Insert(Q,key):
    v = key[0]
    Q.append([v,inf])
    lens = len(Q)
    heapIncreaseKey(Q,lens-1,key)

def heapIncreaseKey(Q,i,key):
    Q[i][1] = key[1]
    while i > 0 and Q[i // 2][1] > Q[i][1]:
        Q[i], Q[i // 2] = Q[i // 2], Q[i]
        i //= 2

def heapExtractMin(Q):
    H = len(Q)
    minv = Q[0][0]
    Q[0] = Q[H-1]
    Q.pop()
    minHeapify(Q,0)
    return minv




def dijkstra(s):
    color = ["white" for i in range(n)]
    d = [inf for i in range(n)]
    d[s] = 0
    Q = [[s,0]]
    while Q != []:
        u = heapExtractMin(Q)
        color[u] = "black"
        for vw in mtrx[u]:
            [v,w] = vw
            if color[v] != "black":
                if d[u] + w < d[v]:
                    d[v] = d[u] + w
                    color[v] = "gray"
                    Insert(Q,[v,d[v]])
    return d



mtrx = [[] for i in range(n)]
for i in range(n):
    col = list(map(int,input().split()))
    u,k = col[0], col[1]
    for j in range(k):
        [v,w] = col[2*j+2: 2*j+4]
        mtrx[u].append([v,w])



d = dijkstra(0)
for i,j in enumerate(d):
    print(i,j)


Measured memory_bytes: 77016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s,k,sum=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(s-i-j>=0&&s-i-j<=k)
			{
				sum++;
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    s = SI()
    t = SI()

    from collections import defaultdict
    s_dict = defaultdict(list)
    for i, char in enumerate(s):
        s_dict[char].append(i)

    # s_dict[char] には、 char が s の何番目に入っているかが記載されている。

    from bisect import bisect, bisect_left

    current_position = 0
    s_loops = 0
    first = True
    for char in t:
        li = s_dict[char]
        if not li:
            print(-1)
            return
        if first:  # 最初の位置は current_position を信用しないで決める。（そうしないと s,t の1文字目が一致していた場合にひとつ後ろから始めてしまう）
            first = False
            current_position = li[0]
        else:
            # current_position より大きい最小の要素を二分探索で得る。
            # たぶんここで二分探索ができることがオーダーの削減に一役買っていて、このループの計算量が O(len(t) log len(s)) になってる。
            pos = bisect_left(li, current_position)
            try:
                if li[pos] == current_position:
                    current_position = li[pos+1]
                else:
                    current_position = li[pos]
            except IndexError:
                # s は次のループに入った。
                s_loops += 1
                current_position = li[0]

    print(len(s)*s_loops + current_position+1)



main()

Measured memory_bytes: 46320
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	BufferSize = 10 * 10 * 10 * 10 * 10 * 10 * 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	l := make([]int, n, n)
	p := make([]int, n, n)
	m := make([]int, 0, n)

	for i := 0; i < n; i++ {
		l[i] = scanInt(sc)
		p[i] = l[i]
	}
	sort.Ints(p)

	for i := 0; i < n; i++ {
		if l[i] != p[i] {
			m = append(m, i)
			if len(m) > 2 {
				fmt.Printf("NO\n")
				return
			}
		}
	}

	fmt.Printf("YES\n")
}


Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<pair <long long,long long>> pa(n);
	for(int i=0;i<n;i++){
		cin >> pa[i].first >> pa[i].second;
	}
	sort(pa.begin(),pa.end());
	long long cost=0,sum=0;
	for(int i=0;i<n;i++){
		if(sum>=m){
			break;
		}else{
			long long now=min((m-sum),pa[i].second);
			cost+=pa[i].first*now;
			sum+=now;
		}	
	}
	cout << cost << endl;
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n,m; cin >> n >> m;
  vl x(m);
  rep(i,m)cin>>x[i];
  sort(all(x));
  ll res = x[m-1] - x[0];
  vl dist;
  rep(i,m-1)dist.push_back(abs(x[i+1] - x[i]));
  sort(rall(dist));
  if(n>=m){
    out(0);
    return 0;
  }
  rep(i,n-1){
    res-=dist[i];
  }
  out(res);
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    int n;
    cin >> n;
    vector<string> s;
    rep(i, 0, n) {
        string str;
        cin >> str;
        s.push_back(str);
    }
    sort(s.begin(), s.end());
    for(auto itr = s.begin(); itr < (s.end()-1); ++itr){
        while(*itr == *(itr+1)){
            if(itr+1 == s.end()){
                cout << n;
                return 0;
            }
            itr++;
            n--;
        }
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 11600
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;


ll N, M;
ll a[100000];
priority_queue<ll> que;


int main()
{
	cin >> N >> M;
	rep(i, N)
	{
		cin >> a[i];
		que.push(a[i]);
	}
	rep(i, M)
	{
		ll temp = que.top();
		que.pop();
		que.push(temp / 2);
	}
	ll ans = 0;
	rep(i, N)
	{
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1912
#include<stdio.h>

int main()
{
	int i, j;
	for (i = 1; i < 10; i++)
	{
		for (j = 1; j < 10; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 924
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include<queue>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

#define MOD 1000000007
int main(){
    string s;
    cin >> s;

    ll dp[100010][13] = {};
    dp[0][0] = 1;
    rep(i, s.size()){
        int num;
        if(s[i] == '?')num  = -1;
        else num = s[i] - '0';
        rep(j, 10)if(num == -1 || num == j){
            rep(k, 13)dp[i+1][(k*10+j)%13] = (dp[i+1][(k*10+j)%13]+dp[i][k])%MOD;
        }
    }
    cout << dp[s.size()][5] << endl;
} 

Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);

ll A[200005];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll ans = 0;
    for(int i=0; i<n; i++) cin >> A[i];
    for(int i=0; i<n; i++) 
    {
        if(mp[i+A[i]]>=1) mp[i+A[i]]++;
        else mp[i + A[i]]=1;
    }
    for(int i=0; i<n; i++)
    {
        ans += mp[i-A[i]];
        if(A[i] == 0) ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27860
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    int n;
    cin >> n;

    double ans = ( n%2==0 ? 0.5 : ((n+1)/2.0)/n );
    printf("%.10lf",ans);
    return 0;
}

Measured memory_bytes: 256