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

ll X=1000000007;

int main() {
  ll N;
  cin>>N;
  vector<bitset<60>> A(N);
  for(ll i=0;i<N;i++){
    ll a;
    cin>>a;
    bitset<60> p(a);
    A.at(i)=p;
  }
  ll Ans=0;
  for(ll i=59;i>=0;i--){
    ll count=0;//i桁目が1の個数を数える
    for(ll j=0;j<N;j++){
      if(A.at(j).test(i)==1){count++;}
    }
    Ans*=2;
    Ans%=X;
    Ans+=count*(N-count)%X;
    Ans%=X;
  }
  cout<<Ans<<endl;
}




Measured memory_bytes: 2560
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N;

    scanf("%jd", &N);

    switch (N % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            puts("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            puts("pon");
            break;
        case 3:
            puts("bon");
            break;
        default:
            break;
    }

    return 0;
}


Measured memory_bytes: 2088
#include<stdio.h>

int main()
{
  long n;
  scanf("%ld", &n);
  
  char asciiCodes[20];
  int i = 0;
  while (1) {
    int surplus = n % 26;
    int code = (surplus == 0) ? 26 : surplus;
    
    asciiCodes[i] = code + 96; // asciiコードに対応させるための加算
    i++;
    
    if (n <= 26) {
      break;
    }
    
    if (surplus == 0) {
      n--;
    }
    
    n /= 26;
  }
  
  char ans[20];
  for (int j = 0, k = i - 1; j < i; j++, k--) {
    ans[j] = asciiCodes[k];
  }
  ans[i] = '\0';
  
  printf("%s\n", ans);
  
  return 0;
}

Measured memory_bytes: 1640
import java.util.Arrays;
import java.util.Scanner;

public class Main{

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

	private Scanner scan;
	int max = 1000000;

	boolean[] Prime = new boolean[max];
	private void mainrun() {
		scan = new Scanner(System.in);
		Arrays.fill(Prime, true);

		Prime[0] = Prime[1] = false;
		for(int i = 2;i < Math.sqrt(max);i++) {
			if(Prime[i]) {
				for(int j = i * 2;j < max;j += i) {
					Prime[j] = false;
				}
			}
		}

		while(scan.hasNext()) {
			int N = scan.nextInt();
			int Ans = 0;

			for(int i = 2;i <= N;i ++) {
				if(Prime[i]) {Ans++;}
			}
			System.out.println(Ans);
		}

	}
}


Measured memory_bytes: 27732
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

template <class T>
struct SegmentTree{
	std::vector<T> v;
	T def;
	int n;
	SegmentTree(int n_, T default_value): def(default_value) {
		n = 1;
		while(n < n_) n <<= 1;
		v.assign(2*n-1, default_value);
	}
	template<class I>
	SegmentTree(I first, I last, T default_value){
		n = 1;
		def = default_value;
		while(n < last-first) n <<= 1;
		v.assign(2*n-1, default_value);
		copy(first, last, v.begin()+n-1);
		for(int i=n-2; i>=0; i--)
			v[i] = merge(v[2*i+1], v[2*i+2]);
	}
	SegmentTree(std::vector<T> initial_data, T default_value):
	SegmentTree(initial_data.begin(), initial_data.end(), default_value){}
	void update(int idx, T val){
		idx += n-1;
		v[idx] = val;
		while(idx > 0){
			idx = (idx-1)/2;
			v[idx] = merge(v[2*idx+1], v[2*idx+2]);
		}
	}
	T q(int a, int b, int k, int l, int r){
		if(a<=l&&r<=b) return v[k];
		if(b<=l||r<=a) return def;
		return merge(q(a, b, 2*k+1, l, (l+r)/2), q(a, b, 2*k+2, (l+r)/2, r));
	}
	T query(int a, int b){
		return q(a, b, 0, 0, n);
	}
	T merge(T left, T right);
};

// Example

template <>
int SegmentTree<int>::merge(int a, int b){
	return std::min(a, b);
}

int main(){
	cout << setprecision(20);
	int N;
	cin >> N;
	vector<int> T(N+2), V(N+2);
	for(int i=0; i<N; i++) cin >> T[i+1];
	for(int i=0; i<N; i++) cin >> V[i+1];

	SegmentTree<int> st1(N+2, 1e9), st2(N+2, 1e9);
	int tsum = 0;
	for(int i=0; i<=N; i++){
		tsum += T[i];
		st1.update(i, V[i]-tsum);
		st2.update(i, V[i+1]+tsum);
	}

	double ans = 0;
	tsum = 0;
	for(int i=1; i<=N; i++){
		int v0 = tsum+st1.query(0, i);
		int v1 = -tsum-T[i]+st2.query(i, N+1);
		int t = T[i];
		tsum += T[i];
		debug(any{i, t, V[i], v0, v1});
		if(v0 < V[i] && v1 < V[i]){
			if(V[i]-v0 + V[i]-v1 < t){
				ans += (v0+V[i])*(V[i]-v0)*0.5 + (t-(2*V[i]-v0-v1))*V[i] + (v1+V[i])*(V[i]-v1)*0.5;
			} else if(v0+t<=v1) {
				ans += (2*v0+t) * t * 0.5;
			} else if(v1+t<=v0) {
				ans += (2*v1+t) * t * 0.5;
			} else {
				double v = 0.5 * (v1 + v0 + t);
				ans += (v0+v) * (v-v0) * 0.5 + (v1+v) * (v-v1) * 0.5;
			}
		} else if(v0 < V[i]){
			if(v0+t<=V[i]) {
				ans += (2*v0+t) * t * 0.5;
			} else {
				ans += (v0+V[i])*(V[i]-v0)*0.5 + V[i]*(t-V[i]+v0);
			}
		} else if(v1 < V[i]){
			if(v1+t<=V[i]) {
				ans += (2*v1+t) * t * 0.5;
			} else {
				ans += (v1+V[i])*(V[i]-v1)*0.5 + V[i]*(t-V[i]+v1);
			}
		} else {
			ans += t * V[i];
		}
		debug(any{ans});
	}

	cout << setprecision(20) << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

typedef pair<int, int> P;

int main(){
  int n, m;
  while(cin >> n >> m){
    if(n == 0 && m == 0) break;
    map<string, P> era;
    string e;
    int a, b;
    for(int i = 0 ; i < n ; i++){
      cin >> e >> a >> b;
      era[e] = P(b-a, b);
    }

    for(int i = 0 ; i < m ; i++){
      cin >> a;
      bool f = false;
      for(map<string, P>::iterator it = era.begin() ; it != era.end() ; it++){
	if(it->second.first < a && a <= it->second.second){
	  cout << it->first << ' ' << a-it->second.first << endl;
	  f = true;
	  break;
	}
      }
      if(!f) cout << "Unknown" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1336
#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,x,t;
  cin>>n>>x>>t;
  if(n%x!=0){
  cout<<(n/x+1)*t<<endl;
  }
  else{
    cout<<(n/x)*t<<endl;
}
}

Measured memory_bytes: 3592
import math

n = int(input())

sum = 0
memo = {'1,1':1}
for i in range(1, n+1):
  for j in range(1, n+1):
      if str(i)+','+str(j) in memo:
        ret = memo[str(i)+','+str(j)]
      elif str(j)+','+str(i) in memo:
        ret = memo[str(j)+','+str(i)]
      else:
        ret = math.gcd(i, j)
        memo[str(i)+','+str(j)] = ret
        memo[str(j)+','+str(i)] = ret

for i in memo.values():
  for j in range(1, n+1):
    sum += math.gcd(i, j)

print(sum)

Measured memory_bytes: 12728
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  if (n / 10 == 9 || n % 10 == 9) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

/**
 * Made by egor https://github.com/chermehdi/egor.
 * 
 * @author Azuz
   
 */
public class Main {

    void solve(Scanner in, PrintWriter out) {
        int m = in.nextInt();
        long n = in.nextInt();
        long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += in.nextInt();
        }

        out.println(sum > m ? -1 : m - sum);
    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}


Measured memory_bytes: 46300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMegalomania solver = new DMegalomania();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMegalomania {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            ArrayList<Pair<Integer, Integer>> alp = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                alp.add(new Pair<>(in.nextInt(), in.nextInt()));
            }

            alp.sort(Comparator.comparing(p -> p.u));

            int time = 0;
            for (Pair<Integer, Integer> p : alp) {
                if (time + p.t > p.u) {
                    out.println("No");
                    return;
                }
                time += p.t;
            }

            out.println("Yes");


        }

    }

    static class Pair<T, U> {
        public T t;
        public U u;

        public Pair(T t, U u) {
            this.t = t;
            this.u = u;
        }

        public String toString() {
            return "Pair{" +
                    "t=" + t.toString() +
                    ", u=" + u.toString() +
                    '}';
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair<?, ?> pair = (Pair<?, ?>) o;
            return Objects.equals(t, pair.t) &&
                    Objects.equals(u, pair.u);
        }

        public int hashCode() {
            return Objects.hash(t, u);
        }

    }
}



Measured memory_bytes: 116832
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

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

  cout <<min(N%K,K-N%K) <<'\n';
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

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

int main()
{
  ll N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (N == 2) {
    cout << 1 << endl;
    return 0;
  }

  cout << (N-1)*N/2 << endl;

  return 0;
}


Measured memory_bytes: 256
def bellman_ford(v, G):
    import copy
    INF = 10 ** 10
    ret = [INF] * len(G)
    ret[v] = 0

    for _ in range(len(G) - 1):
        for u, g in enumerate(G):
            for w, l in g:
                if not ret[u] == INF and ret[w] > ret[u] + l:
                    ret[w] = ret[u] + l

    for _ in range(len(G) - 1):
        for u, g in enumerate(G):
            for w, l in g:
                if not ret[w] == INF and ret[w] > ret[u] + l:
                    ret[w] = -INF

    return ret


N, M, P = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    A, B, C = map(int, input().split())
    G[A - 1].append((B - 1, - C + P))

ans = bellman_ford(0, G)[-1]
print("-1" if ans == -10 ** 10 else max(-ans, 0))


Measured memory_bytes: 54488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  map<int, int> ans;
  FOR(x, 1, N)
  FOR(y, 1, N)
  FOR(z, 1, N)
  {
    int n = x * x + y * y + z * z + x * y + y * z + z * x;
    if (n > N)
      break;
    ans[n]++;
  }
  for (int i = 1; i <= N; i++)
  {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

int n,v,d1,d2,sa1,sa2,dd1,dd2,sb1,sb2;

int main(){
    cin >> n;
    map<int,int> s1, s2;
    rep(i,n){
        cin >> v;
        if(i%2) s1[v]++; else s2[v]++;
    }
    for(auto v : s1) if(d1 < v.second) { sa1 = v.first; d1 = v.second; }
    for(auto v : s2) if(d2 < v.second) { sa2 = v.first; d2 = v.second; }
    if(sa1 != sa2) { cout << n - d1 - d2 << endl; }
    else if(d1 == n/2 && d2 == n/2) { cout << n/2 << endl; }
    else if(d2 == n/2){
        for(auto v : s1) if(sa1 != v.first && dd1 < v.second) dd1 = v.second;
        cout << n/2 - dd1;
    }
    else if(d1 == n/2){
        for(auto v : s2) if(sa2 != v.first && dd2 < v.second) dd2 = v.second;
        cout << n/2 - dd2;
    }
    else{
        for(auto v : s1) if(sa1 != v.first && dd1 < v.second) dd1 = v.second;
        for(auto v : s2) if(sa2 != v.first && dd2 < v.second) dd2 = v.second;
        cout << min(n - d1 - dd2, n - d2 - dd1) << endl;
    }
}

Measured memory_bytes: 8316
chA = {' ':'101', "'":'000000', ',':'000011', '-':'10010001', '.':'010001', '?':'000001', 'A':'100101', 
       'B':'10011010', 'C':'0101', 'D':'0001', 'E':'110', 'F':'01001', 'G':'10011011', 'H':'010000',
       'I':'0111', 'J':'10011000', 'K':'0110', 'L':'00100', 'M':'10011001', 'N':'10011110', 'O':'00101',
       'P':'111', 'Q':'10011111', 'R':'1000', 'S':'00110', 'T':'00111', 'U':'10011100', 'V':'10011101',
       'W':'000010', 'X':'10010010', 'Y':'10010011', 'Z':'10010000'}

chB = {'00000':'A', '00001':'B', '00010':'C', '00011':'D', '00100':'E', '00101':'F',
       '00110':'G', '00111':'H', '01000':'I', '01001':'J', '01010':'K', '01011':'L',
       '01100':'M', '01101':'N', '01110':'O', '01111':'P', '10000':'Q', '10001':'R',
       '10010':'S', '10011':'T', '10100':'U', '10101':'V', '10110':'W', '10111':'X',
       '11000':'Y', '11001':'Z', '11010':' ', '11011':'.', '11100':',', '11101':'-', '11110':"'", '11111':'?'}


while True:
    try:
        s = input()

    except EOFError:
        break
    
    chlst = ''
    numlst = []
    anslst = ''
    for i in s:
        if i == '\\':
            chlst = chlst + chA[' ']
        else:
            chlst = chlst + chA[i]

    if len(chlst)%5 != 0:
        for k in range(5-(len(chlst)%5)):
            chlst += '0'

    for j in range(len(chlst)//5):
        numlst.append(chlst[5*j: 5*j+5])

    for l in numlst:
        anslst = anslst + chB[l]

    print(anslst)



Measured memory_bytes: 5596
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


n=int(input())
A=make_divisors(n)

ans=0
for m in A[1:]:
    m -=1
    if int(n/m)==n%m:
        ans +=m
print(ans)

Measured memory_bytes: 39408
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, M;
	cin >> N;
	M = N / 2;
	cout << 1- (double)M / N << endl;

	return 0;
}



Measured memory_bytes: 3752
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

def gcd(a, b):
    if b == 0: return a
    if (a, b) in memo: return memo[(a, b)]
    return gcd(b, a % b)
memo = {}

def main():
    md = 10 ** 9 + 7
    h, w, t = MI()
    # t=1のパターンに置き換える
    h1 = h // gcd(h, t)
    w1 = w // gcd(w, t)
    ans = (pow(2, h1, md) + pow(2, w1, md) + pow(2, gcd(h1, w1), md) - 3) % md
    # print(ans)
    # t=1のパターンの個数分累乗
    ans = pow(ans, gcd(h, t) * gcd(w, t), md)
    print(ans)

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int X,K;
	cin>>X>>K;
	
	vector<int> R(K);
	for(int i=0;i<K;i++)cin>>R[i];
	R.push_back(2000000000);
	int Q;
	cin>>Q;
	
	vector<int> t(Q),a(Q);
	for(int i=0;i<Q;i++)cin>>t[i]>>a[i];
	
	int l = 0,r = X,u = X,b = 0;
	int ind = 0;
	for(int i=0;i<R.size();i++){
		while(ind!=Q && t[ind]<R[i]){
			//cout<<i<<ind<<endl;
			
			int A;
			if(l==r)A = u;
			else if(a[ind]<=l){
				A=b;
			}
			else if(a[ind]>=r){
				A=u;
			}
			else{
				A=b;
				A += a[ind]-l;
			}
			int x;
			x = t[ind];
			if(i!=0)x -= R[i-1];
			if(i%2==0)A -= x;
			else A += x;
			A = clamp(A,0,X);
			cout<<A<<endl;
			
			
			ind++;
		}
		
		
		
		int T = R[i];
		if(i!=0)T -= R[i-1];
		
		if(i%2==0){
			b -= T;
			if(b<0){
				l += abs(b);
				b=0;
			}
			u -= T;
			if(u<0){
				r=l;
				u=0;
			}
		}
		else{
			u += T;
			if(u>X){
				r -= abs(u-X);
				u = X;
			}
			b += T;
			if(b>X){
				l = r;
				b=X;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 4428
from collections import defaultdict
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))

d = defaultdict(lambda:0)

for i in range(N):
    d[A[i]] += 1

C = [0]*(N+1)

for i in d:
    C[d[i]] += 1

C1 = [0]*(N+1)
C2 = [0]*(N+1)

for i in range(N):
    C1[i+1] = C1[i] + (i+1)*C[i+1]
    C2[i+1] = C2[i] + C[i+1]

l = [0]*N
for n in range(N):
    l[n] = C1[n+1]//(n+1)+C2[N]-C2[n+1]
    l[n] *= -1


for i in range(N):
    print(bisect(l,-(i+1)))

Measured memory_bytes: 122416
object Main extends App {
	val line = scala.io.StdIn.readLine
	val A = line.split(" ")(0).toInt
	val B = line.split(" ")(1).toInt
	val C = line.split(" ")(2).toInt

	var list: List[Int] = List();

	for(i<-0 to B){
		list = A*i%B :: list
	}

	if(list.contains(C)){
		println("YES")
	}else{
		println("NO")
	}
}

Measured memory_bytes: 25676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll solve(){
    ll res = 0;
    
    ll N,M,R; cin >> N >> M >> R;
    vector<ll> r(R);
    for(auto& in:r) { cin >> in; in--; }
    vector<vector<ll>> G(N,vector<ll>(N,LINF));
    for(int i = 0; i < N;i++) G[i][i] = 0;
    for(int i = 0; i < M;i++){
        ll A,B,C; cin >> A >> B >> C;
        A--; B--;
        G[A][B] = G[B][A] = min(G[A][B],C);
    }
    
    for(int i = 0; i  < N;i++) for(int j = 0; j  < N;j++)for(int k = 0; k < N;k++){
        G[j][k] = min(G[j][k],G[j][i]+G[i][k]);
    }
    
    vector<vector<ll>> dp(1<<R,vector<ll>(R,LINF));
    for(int i = 0; i < R;i++) dp[1<<i][i] = 0;
    for(int i = 0; i < (1<<R); i++){
        for(int j = 0; j < R;j++){
            if(dp[i][j] == LINF) continue;
            for(int k = 0; k <R;k++){
                if((i>>k)&1) continue;
                dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+G[r[j]][r[k]]);
            }
        }
    }
    res = *min_element(dp[(1<<R)-1].begin(),dp[(1<<R)-1].end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    auto ret = solve();
    cout << ret << endl;
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int t,c=0;
  t=N;
  while(t>0){
  c+=t%10;
  t/=10;
  }
  
  if(N%c==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main(){
    int N;
    cin>>N;
    int ans = 1;
    for(int i=1;i<=6;i++){
        if(N<(int)pow(2,i)){
            cout<<(int)pow(2,i-1)<<endl;
            return 0;
        }else if(N==(int)pow(2,i)){
            cout<<(int)pow(2,i)<<endl;
            return 0;
        }else if(N>64){
            cout<<"64"<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n,a;
  cin>>n>>a;
  if(n%a)
    cout<<n/a+1<<endl;
  else
    cout<<n/a<<endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int n, int d) {
    int ans = 1;
    int p = d + 1;
    while (p + d < n) {
        ans++;
        p += d * 2 + 1;
    }
    return ans;
}

void main() {
    int n, d; scan(n, d);
    writeln(calc(n, d));
}


Measured memory_bytes: 256
x, y, z = [0] * 3

def format_input(filename = None):
	global x, y, z
	if filename == None:
		x, y, z = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		x = rng(1, 10**2)
		y = rng(1, 10**2)
		z = rng(1, 10**2)
		print(x, y, z)

def get_answer():
	print(z, x, y)

if __name__ == '__main__':
	format_input()

	get_answer()


Measured memory_bytes: 3060
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n,sum=0;
    cin >> n;
    vector<int> pro(n);
    for(int i = 0; i < n; ++i) {
        cin>>pro.at(i);
        sum += pro.at(i);
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; ++i) {
        int p, t; cin >> p >> t;
        cout << sum + (t - pro.at(p - 1)) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    if(a<=b/k * k) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;

  int disA = abs(x-a);
  int disB = abs(x-b);

  cout << ((disA<disB) ? "A" : "B") << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

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

fn main() {
    let s: String = read().unwrap();
    println!("{}", s.replace("2017", "2018"));
}

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

using namespace std;

int main()
{
    int n;
    int v[100], c[100];
    int sum = 0, cost = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            sum += v[i];
            cost += c[i];
        }
    }

    cout << sum-cost << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc147/tasks/abc147_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	ll n;
	n=s.length();
	vector<char> lis;
	ll i;
	for(i=0;i<n;i++)
	{
		lis.push_back(s[i]);
	}
	ll cnt=0;
	ll ans=0;
	vector <char> alis;
	vector <char> blis;
	if(n%2==0)
	{
		for(i=0;i<(n/2);i++)
		{
			alis.push_back(lis[i]);
		}
		for(i=n-1;i>=n/2;i--)
		{
			blis.push_back(lis[i]);
		}
		for(i=0;i<(n/2);i++)
		{
			if(alis[i]==blis[i])
			{
				cnt=cnt+1;
			}
			else
			{
				cnt=cnt;
			}
		}
		ans=(n/2)-cnt;
		cout<<ans<<"\n";
	}
	else
	{
		for(i=0;i<(n-1)/2;i++)
		{
			alis.push_back(lis[i]);
		}
		for(i=n-1;i>=(n+1)/2;i--)
		{
			blis.push_back(lis[i]);
		}
		for(i=0;i<(n-1)/2;i++)
		{
			if(alis[i]==blis[i])
			{
				cnt=cnt+1;
			}
			else
			{
				cnt=cnt;
			}
		}
		ans=(n-1)/2-cnt;
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
#include<math.h>
#include<pthread.h>
#include<omp.h>
#define mall (node*)malloc(sizeof(node))
using namespace std;
typedef long long ll;
ll mod=998244353;
ll sum[200005]={0};
ll n,q;
ll tree[800005]={0},laz[800005]={0};
void chan(ll k,ll l,ll r,ll l1,ll r1,ll x)
{
//	printf("%lld %lld %lld %lld\n",l,r,tree[k],laz[k]);
	if(l1<=l&&r<=r1)
	{
		tree[k]=(sum[r+1]-sum[l])*x%mod;
		tree[k]=(tree[k]+mod)%mod;
		laz[k]=x;
	}
	else if(l1<=r&&l<=r1)
	{
		ll m=(l+r)/2;
		if(laz[k])
		{
			laz[k*2+1]=laz[k];
			laz[k*2+2]=laz[k];
			tree[k*2+1]=(sum[m+1]-sum[l])*laz[k]%mod+mod;
			tree[k*2+2]=(sum[r+1]-sum[m+1])*laz[k]%mod+mod;
			tree[k*2+1]%=mod,tree[k*2+2]%=mod;
			laz[k]=0;
		}
		chan(k*2+1,l,m,l1,r1,x);
		chan(k*2+2,m+1,r,l1,r1,x);
		tree[k]=(tree[k*2+1]+tree[k*2+2])%mod;
	}
}
ll cal(ll k,ll l,ll r,ll l1,ll r1)
{
	if(l1<=l&&r<=r1)
	{
		return tree[k];
	}
	else if(l1<=r&&l<=r1)
	{
		ll m=(l+r)/2;
		if(laz[k])
		{
			laz[k*2+1]=laz[k];
			laz[k*2+2]=laz[k];
			tree[k*2+1]=(sum[m+1]-sum[l])%mod+mod;
			tree[k*2+2]=(sum[r+1]-sum[m+1])%mod+mod;
			tree[k*2+1]%=mod,tree[k*2+2]%=mod;
			laz[k]=0;
		}
		ll ans=cal(k*2+1,l,m,l1,r1)+cal(k*2+2,m+1,r,l1,r1);
		ans%=mod;
		tree[k]=(tree[k*2+1]+tree[k*2+2])%mod;
		return ans;
	}
	else return 0;
}
int main(void)
{
	scanf("%lld%lld",&n,&q);
	sum[1]=1;
	for(ll i=2;i<=n;i++) sum[i]=(sum[i-1]*10)%mod;
	for(ll i=2;i<=n;i++) sum[i]=(sum[i]+sum[i-1])%mod;
	tree[0]=sum[n],laz[0]=1;
	while(q--)
	{
		ll l,r,d;
		scanf("%lld%lld%lld",&l,&r,&d);
		chan(0,0,n-1,n-r,n-l,d);
		printf("%lld\n",tree[0]);
	}
}

Measured memory_bytes: 13588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c, k; cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if(k <= a+b) cout << a << endl;
    else cout << a-(k-(a+b)) << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3 + 3;
int n, a[N];
int bs(int i, int j) {
	int lo = j + 1, hi = n - 1, ret = j;
	while (lo <= hi) {
    	int mid = (lo + hi) / 2;
		if (a[i] + a[j] > a[mid]) {
 	    	ret = mid;
        	lo = mid + 1; 
        }else{
  	      	hi = mid - 1;
        }
    }
  	return ret - j;
}
int main() {
  	cin >> n;
  	for (int i = 0; i < n; ++i) 
      	cin >> a[i];
    sort(a, a + n);
  	long long res = 0;
  	for (int i = 0; i < n; ++i) 
    	for (int j = i + 1; j < n; ++j) 
        	res += bs(i, j);
 	cout << res << endl;
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

signed main(){
	int L,R,D;
	cin>>L>>R>>D;
	cout<<R/D-(L-1)/D<<endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



int main() {
	int A;
	int B;
	int C;
	int D;

	cin >> A >> B >> C >> D;

	for (int i = 0; i < 100;i++) {
		C -= B;
		if (C <= 0) {
			break;
		}

		A -= D;
		if (A <= 0) {
			break;
		}
	}

	if (C <= 0) {
		cout << "Yes";
	}
	else if(A<=0){
		cout<<"No";
	}

}

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

using namespace std;

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

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

  for(int i = N-1 ; i >= 0; i--){
    cout << vec.at(i);
    if(i != 0){
    cout << " ";
    }
  }
  cout << endl;
  return 0;
}


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

int a[1001];
int main(){
    set<int> primenum;
    for(int i=2;i<=1000;i++){
        if(a[i]==0){
            primenum.insert(i);
            int j=1;
            while(i*j<=1000){
                a[i*j]++;
                j++;
            }
        }
    }
    auto itr=primenum.begin();
    int N;cin>>N;
    ll ans=1;
    while(*itr<=N and itr!=primenum.end()){
        int p=N;
        ll count=0;
        while(p){
            count+=ll(p/(*itr));
            p/=*itr;
        }
        ans*=count+1;
        ans%=1000000007;
        itr++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll _x;
	cin>>_x;
	double x=_x;
	double p;
	cin>>p;
	p = p/100;
	double ans;
	if(_x%2==0){
		ans = 1/p*x/2;
	}
	else{
		ans = p*(1/p*(x-1)/2) + (1-p)*(1/p*(x+1)/2);
		ans+=1;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 0X3F3F3F3F;
const ll N = 1e5+7;
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

int main()
{
	IOS();
	ll a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
rt = int(N ** 0.5)

ans = 0
for i in range(1,rt+1):
    if N % i == 0:
        ans += ((N//i - i) * 2 - 1)
    else:
        ans += ((N//i - i + 1) * 2 - 1)
if rt * rt == N:
    ans += 1
print(ans)

Measured memory_bytes: 9432
h,w = map(int,input().split(" "))
s = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    tmp = list(input())
    for j in range(w):
        s[i][j] = tmp[j]

dp1= []
dp2= [[-1 for i in range(w)] for j in range(h)]
dp3=[]
dp4=[[-1 for i in range(w)] for j in range(h)]


for i in range(h):
    dp1.append([])
    dp3.append([])
    for j in range(w):
        dp1[i].append(-1)
        dp3[i].append(-1)

        if s[i][j] == "#":
            dp1[i][j] = 0
        elif j == 0:
            dp1[i][j] = 1
        else:
            dp1[i][j] = 1 + dp1[i][j-1]

        if s[i][w-j-1] == "#":
            dp2[i][w-j-1] = 0
        elif w-j-1 == w-1:
            dp2[i][w-j-1] = 1
        else:
            dp2[i][w-j-1] = 1 + dp2[i][w-j]

        if s[i][j] == "#":
            dp3[i][j] = 0
        elif i == 0:
            dp3[i][j] = 1
        else:
            dp3[i][j] = 1 + dp3[i-1][j]

        if s[h-i-1][j] == "#":
            dp4[h-i-1][j] = 0
        elif h-i-1 == h-1:
            dp4[h-i-1][j] = 1
        else:
            dp4[h-i-1][j] = 1 + dp4[h-i][j]



        

a = 1
for i in range(h):
    for j in range(w):
        a = max(a,dp1[i][j]+dp2[i][j]+dp3[i][j]+dp4[i][j]-3)


print(a)

Measured memory_bytes: 443912
K, N = map(int, input().split())
A = list(map(int,input().split()))
dis_list = []
dis_list.append(K-A[-1]+A[0])
for i in range(1,N):
  dis_list.append(A[i]-A[i-1])
dis_list.sort() 
print(sum(dis_list[:-1]))

Measured memory_bytes: 25840
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  s = input()
  if len(set(s)) == 1:
    print(0)
    sys.exit()
  a = Counter(s)
  ans = min(a.values()) * 2
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
 
        FastIO
        string s,temp1="",temp2="";
        int q,i,flag=1,f,z;
        cin>>s;
        cin>>q;
        char c;
        while(q--)
        {
        	cin>>z;
        	if(z==1)
        	{
        		flag*=-1;
        	}
        	else
        	{
        		cin>>f>>c;
        		if(f==1)
        		{
        			if(flag==1)
        				{
        					temp1+=c;


        				}
        				else
        				{
        					temp2+=c;
        				}
        		}
        		else
        		{
        			if(flag==1)
        			temp2+=c;
        		else
        		{
        					temp1+=c;
        		}

        		}
        }
       }
       if(flag==1)
        {
        	reverse(temp1.begin(),temp1.end());
        	cout<<temp1<<s<<temp2;
        }
    	else
    	{
    		reverse(temp2.begin(),temp2.end());
    		reverse(s.begin(),s.end());
    		cout<<temp2<<s<<temp1;
    	}
        return 0;
    }

Measured memory_bytes: 1104
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)

int main()
{
	uint32_t n;
	cin >> n;
	vector<int32_t> v(100000,0);

	int32_t temp;
	int32_t max_elem = 0;
	uint32_t result = 0;
	for (uint32_t i = 0; i < n; i++) {
		cin >> temp;
		if (temp > 100000) {
			result++;
			continue;
		}
		v[temp]++;
		if (temp > max_elem) { max_elem = temp; }
	}
	for (int32_t i = 1; i <= max_elem; i++) {
		if (!v[i]) { continue; }
		if (i == v[i]) { continue; }
		result += i > v[i] ? v[i] : v[i] - i;
	}

	cout << result;

	return 0;
	//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 640
x, y = map(int, input().split())

if abs(x) == abs(y):
	if x * y >= 0:
		ans = 0
	else:
		ans = 1

elif 0 in [x,y]:
	ans = abs(x-y)
	if x == 0:
		if y > 0:
			ans += 0
		else:
			ans += 1
	elif y == 0:
		if x > 0:
			ans += 1
		else:
			ans += 0

else:
	ans = abs(abs(x)-abs(y))
	if x > 0 and y > 0:
		if abs(x) < abs(y):
			ans += 0
		else:
			ans += 2

	elif x > 0 and y < 0:
		if abs(x) < abs(y):
			ans += 1
		else:
			ans += 1

	elif x < 0 and y > 0:
		if abs(x) < abs(y):
			ans += 1
		else:
			ans += 1

	else:
		if abs(x) < abs(y):
			ans += 2
		else:
			ans += 0

print(ans)

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

int main() {
  int n,sum=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0; i<n-1; i++) {
    sum+=v[i]-v[i+1];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    long N = Long.parseLong(scanner.next());
	    long max = (long)N;
	    int c = Integer.MAX_VALUE;
	    for (long i = 1; i <= max; i++) {
	        if ((N % i) == 0) {
	            long a = i;
	            long b = (long)N / i;
	            if (a > b) break;
	            int ad = getDigit(a);
	            int bd = getDigit(b);
	            int md = Math.max(ad, bd);
	            max = Math.max(a, b);
	            if (md < c) {
	                c = md;
	            }
	        } else {
	            max = N / i + 1;
	        }
	    }

        System.out.print(c);
	}

	public static int getDigit(long n) {
	    int c = 0;
		while (n >= 1)
	    {
			c++;
	        n = n/10;
	    }
		return c;
	}
}

Measured memory_bytes: 35564
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
from collections import Counter
import math
from functools import reduce
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def solve(K: int, S: int):
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S - i - j <= K:
                ans += 1
    print(ans)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66152
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, C = LI()
    K = I()

    while A >= B:
        B *= 2
        K -= 1
    while B >= C:
        C *= 2
        K -= 1

    if K >= 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            l.Sort();

            var count = 0L;

            for(int i = 0; i < l.Count; i++) {
                for (int j = i + 1; j < l.Count; j++) {
                    for (int k = j + 1; k < l.Count; k++) {
                        if(l[i] + l[j] > l[k] && (l[i] != l[j] && l[j] != l[k] && l[i] != l[k])) {
                            count++;
						}
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 28264
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
  
  int x,y;
  cin>>x>>y;
 if(x==4||x==6||x==9||x==11){
     if(y==4||y==6||y==9||y==11){
         cout<<"Yes"<<endl;
     }
     else{
         cout<<"No"<<endl;
     }
 }
 else if(x==2){
   
         cout<<"No"<<endl;
     
 }
  else {
     if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
         cout<<"Yes"<<endl;
     }
     else{
         cout<<"No"<<endl;
     }
 }
}

Measured memory_bytes: 256