akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define MAX 500000
#define INFTY 2000000000

int L[(MAX/2)+2],R[(MAX/2)+2],count;

void merge(int A[], int n, int left, int mid, int right){

  int i,j,k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }

  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = INFTY;

  i = j = 0;

  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int n, int left, int right){

  int mid;

  if((left + 1) < right){
    mid = (left + right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){

  int A[MAX], n ,i;

  scanf("%d",&n);

  count = 0;
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i] >= INFTY){
      return 1;
    } 
  }

  mergeSort(A,n,0,n);

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

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

  return 0;

}



Measured memory_bytes: 5636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<string>s(n);
    REP(i,n)cin >> s[i];
    vector<pair<int,string> >p;
    map<string,int>m;
    int maxnum = 0;
    REP(i,n){
        m[s[i]]++;
    }
    for(auto itr = m.begin(); itr != m.end(); ++itr) {
        p.push_back(make_pair(itr->second,itr->first));
        maxnum = max(maxnum,itr->second);
    }
    SORT(p);
    //cout << " " << endl;
    REP(i,p.size()){
        if(p[i].first == maxnum)
            cout << p[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 30708
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

int main() {

	string n; cin >> n;

	long a = 0;
	for (auto& s : n){
		string b{s};
		a += stol(b);
	}

	if ((stol(n) % a) == 0){
		cout << "Yes";
	} else {
		cout << "No";
	}

}


Measured memory_bytes: 256
# E - Red Scarf
from functools import reduce
from operator import xor


def main():
    _, *A = map(int, open(0).read().split())
    total_xor = reduce(xor, A)
    res = [a ^ total_xor for a in A]
    print(" ".join(map(str, res)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 42192
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> v(N),ans;
    REP(i,N) cin>>v[i];
    for(int i=N; i>=1; --i){
        int pos = -1;
        for(int j=0; j<i; ++j){ // which num should be removed in turn-i
            if(v[j]==j+1){
                pos = j;
            }
        }
        if(pos == -1){
            cout << -1 << '\n';
            return 0;
        }
        ans.push_back(pos);
        for(int j=pos; j < i; ++j) v[j] = v[j+1];
    }
    
    for(int i=ans.size()-1; i>=0; --i) cout << ans[i]+1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

long long f(ll a) {
    if (a == 2) return 1;
    else if (a == 4 || a == 6 || a == 9 || a == 11) return 2;
    else return 3;
}

int main() {
    ll x,y; cin >> x >> y;
    if (f(x) == f(y)) cout << "Yes" << endl;
    else cout << "No" << endl; 
    
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll x; cin >> x;

    ll ans;
    if(400<= x && 599>=x){
        ans = 8;
    }
    if(600<= x && 799>=x){
        ans = 7;
    }
    if(800<= x && 999>=x){
        ans = 6;
    }
    if(1000<= x && 1199>=x){
        ans = 5;
    }
    if(1200<= x && 1399>=x){
        ans = 4;
    }
    if(1400<= x && 1599>=x){
        ans = 3;
    }
    if(1600<= x && 1799>=x){
        ans = 2;
    }
    if(1800<= x && 1999>=x){
        ans = 1;
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#import time

def main():
    inputlst=[]

    while 1 :
        n=int(input())
        if n==0 : break
        inputlst.append(n)

    #start=time.time()

    lst=[]

    for i in range(1,181):
        j=i*(i+1)*(i+2)//6
        if j>=10**6 : break
        lst.append(j)

    olst=[i for i,x in enumerate(lst) if x%2==1]    

    nlst=len(lst)

    #dpのアップデート(i番目)は(i-1番目)の自身とこれまで計算したi番目の結果しか使わないので1次元配列で済む
    dp=[i for i in range(10**6)]
    dpo=[i for i in range(10**6)]


    for i in range(nlst):
        li=lst[i]
        if i in olst:
            for j in range(li,10**6):
                if dp[j-li]+1<dp[j]:
                    dp[j]=dp[j-li]+1
                if dpo[j-li]+1<dpo[j]:
                    dpo[j]=dpo[j-li]+1
        else :
            for j in range(li,10**6):
                if dp[j-li]+1<dp[j]:
                    dp[j]=dp[j-li]+1                

    for x in inputlst:
        print("{} {}".format(dp[x],dpo[x]))

    #print(time.time()-start)       



main()


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

int m[101];
set<int> p[101];
int r[101];

int main() {
    int n,k,tmp;
    while(cin>>n, n) {
        for(int i=0; i<n; ++i) {
            p[i].clear();
            cin>>m[i];
            for(int j=0; j<m[i]; ++j) {
                cin>>tmp;
                p[i].insert(tmp);
            }
        }
        cin>>k;

        for(int i=0; i<k; ++i)
            cin>>r[i];

        int ans = -1;
        for(int i=0; i<n; ++i) {
            bool same = true;
            for(int j=0; j<k; ++j) {
                if(p[i].find(r[j]) == p[i].end())
                    same = false;
            }

            if(same) {
                if(ans >= 0) ans = -2;
                if(ans == -1) ans = i+1;
            }
        }

        if(ans < 0) ans = -1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1104
<?php
  fscanf(STDIN,"%d %d",$a,$b);
  $count = 1;
  $tap = $a;
  while($tap < $b){
    $count++;
    $tap+=$a-1;
  }
  if($b == 1){
    $count = 0;
  }
  echo $count."\n";

Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

vector<vector<int>> G;
vector<bool> mark;
vector<vector<int>> cnt;
vector<int> num;

void add(string &s){
    int pos=0;
    rep(i,s.length()){
        if(G[pos][s[i]-'a']!=-1){
            pos=G[pos][s[i]-'a'];
            continue;
        }
        int npos=G.size();
        G[pos][s[i]-'a']=npos;
        G.push_back(vector<int>(26,-1));
        mark.push_back(false);
        pos=npos;
        //cout << pos << " " << s[i] << endl;
    }
    mark[pos]=true;
}

int search(string &s){
    int pos=0;
    rep(i,s.length()){
        pos=G[pos][s[i]-'a'];
    }
    return pos;
}

void dfs(int s){
    rep(k,26){
        if(G[s][k]==-1) continue;
        int t=G[s][k];
        //cout << t << " " << (char)(k+'a') << endl;
        dfs(t);
        rep(l,26){
            if(k!=l) cnt[s][l]+=cnt[t][l];
        }
        cnt[s][k]+=num[t];
        num[s]+=num[t];
    }
    if(mark[s]) num[s]+=1;
}

int n;
string S[200010];

void solve(){
    cin >> n;
    G.push_back(vector<int>(26,-1));
    mark.push_back(0);
    rep(i,n){
        cin >> S[i];
        reverse(S[i].begin(),S[i].end());
        //cout << S[i] << endl;
        add(S[i]);
    }
    cnt.resize(G.size(),vector<int>(26,0));
    num.resize(G.size(),0);
    dfs(0);
    // rep(i,G.size()){
    //     rep(j,26) cout << cnt[i][j] << " ";
    //     cout << "" << endl;
    // }
    ll ans=0;
    rep(i,n){
        string T=S[i].substr(0,S[i].length()-1);
        int t=search(T);
        //cout << T << " " << t << endl;
        ans+=cnt[t][S[i][S[i].length()-1]-'a']-1;
    }
    cout << ans << endl;
}

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

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

class Node{
  public:
    int key;
    Node *parent, *left, *right;

    Node(int k){
      key = k;
      parent = nullptr;
      left = nullptr;
      right = nullptr;
    }

};

int n;
Node *root, *nil;

void inOrder(Node *node){
  if(node == nil) return;
  inOrder(node->left);
  cout << " " << node->key;
  inOrder(node->right);
}

void preOrder(Node *node){
  if(node == nil) return;
  cout << " " << node->key;
  preOrder(node->left);
  preOrder(node->right);
}


void myInsert(int key){
  auto *parent = nil;  // xの親
  auto *x = root;
 // tree.push_back(Node(key));
  auto *obj = new Node(key);

  while(x != nil){
    parent = x;
    x = (obj->key < x->key) ? x->left:x->right;
  }

  obj->parent = parent;
  if(parent == nil){
    root = obj;
  }else {
    if(obj->key < parent->key){
      parent->left = obj;
    } else{
      parent->right = obj;
    }
  }
}

bool find(int key){
  auto *parent = nil;
  auto *node =  root;

  while(node != nil && key != node->key){
    parent = node;
    node = (key < node->key) ? node->left : node->right;
  }

  return node != nil ? true : false;
}

int main(){
  cin >> n;
  int key;

  for(auto i = 0; i < n; i++){
    string command;
    cin >> command;
    if(command == "insert"){
      cin >> key;
      myInsert(key);
    }else if(command == "print"){
      inOrder(root);
      cout << endl;
      preOrder(root);
      cout << endl;
    }else if(command == "find"){
      // find
      cin >> key;
      cout << (find(key) ? "yes" : "no") << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 21924
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {rep(i, sz(v)) is >> v[i]; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    int n; cin >> n;
    print(1 - n);
}

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

int n;
string seats;
char set_left(char ch) { for (char &c: seats) if (c == '#') return c = ch; }
char setB() {
    for (int i = n - 1; i >= 0; i--) {
        bool ok = seats[i] == '#';
        if (i + 1 < n) ok &= seats[i + 1] != 'A';
        if (i) ok &= seats[i - 1] != 'A';
        if (ok) return seats[i] = 'B';
    }
    return set_left('B');
}
char setC() {
    if (seats == string(n, '#')) return seats[n / 2] = 'C';
    for (int i = 0; i < n; i++) if (seats[i] != '#') {
        if (i + 1 < n && seats[i + 1] == '#') return seats[i + 1] = 'C';
        if (i && seats[i - 1] == '#') return seats[i - 1] = 'C';
    }
}
char setD() {
    if (seats == string(n, '#')) return seats[0] = 'D';
    vector<int> dist(n, n);
    for (int i = 0; i < n; i++) if (seats[i] != '#') {
        for (int j = i; j < n; j++) dist[j] = min(dist[j], j - i);
        for (int j = i; j >= 0; j--) dist[j] = min(dist[j], i - j);
    }
    int idx = max_element(dist.begin(), dist.end()) - dist.begin();
    return seats[idx] = 'D';
}

int main() {
    int m;
    while (cin >> n >> m, n) {
        seats = string(n, '#');
        while (m--) {
            char c; cin >> c;
            if (c == 'A') set_left('A');
            if (c == 'B') setB();
            if (c == 'C') setC();
            if (c == 'D') setD();
        }
        cout << seats << endl;
    }
    return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int k;
string s;

int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> k >> s;
	int n = s.length();
	if (n <= k) cout << s << endl;
	else {
		for(int i=0; i<k; i++) cout << s[i];
		cout << "..." << endl;
	}	
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod


string str[11];

void solve() {
        int n, m, k; cin >> n>> m>> k;

        for (int i= 0; i< n; i++) cin >> str[i];

        int pw= n- 1, ans= 1e18;
        for (int i= 0; i< (1<< pw); i++) {
                vector<int> cuts;
                int cur= 0;
                cuts.push_back(0);

                for (int j= 0; j< pw; j++) {
                        if (i& 1<< j) {
                                cuts.push_back(j+ 1);
                        }
                }

                cuts.push_back(n);
                cur= cuts.size()- 2;

                vector<int> nmone(cuts.size(), 0);

                bool can= 0;

                for (int ii= 0; ii< m; ii++) {
                        bool findcut= 0;

                        for (int kk= 1; kk< cuts.size(); kk++) {
                                int pls= 0;
                                for (int j= cuts[kk- 1]; j< cuts[kk]; j++) {
                                        if (str[j][ii]== '1') {
                                                pls++;
                                        }
                                }

                                if (nmone[kk]+ pls> k) {
                                        findcut= 1;
                                } else nmone[kk]+= pls;

                                if (pls> k) {
                                        can= 1;
                                        break;
                                }
                        }

                        if (can) break;

                        if (findcut) {
                                cur++;
                                for (int kk= 1; kk< cuts.size(); kk++) {
                                        int pls= 0;
                                        for (int j= cuts[kk- 1]; j< cuts[kk]; j++) {
                                                if (str[j][ii]== '1') {
                                                        pls++;
                                                }
                                        }
                                        nmone[kk]= pls;
                                }
                        }
                }

                if (!can) ans= min(ans, cur);
        }

        cout << ans<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) solve();
return 0;
}


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

#define ll long long

int main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    
    // cout<<__gcd(420 ,660);
    
    ll a,b;
    cin>>a>>b;
    
    ll k = __gcd(a,b);
    
    ll ans =1;
    
    if(k%2==0)
    {
        ans++;
        while(k%2==0)
        {
            k/=2;
        }
    }
    
    for(ll i=3;i*i<=k;i++)
    {
        if(k%i==0)
        {
            ans++;
            while(k%i==0)
            {
                k/=i;
            }
        }
    }
    if(k>2)
        ans++;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List

judge :: Bool -> (String,String) -> String
judge f (ts,fs) = case f of
  True -> ts
  False -> fs

func :: Ord a => [a] -> [a] -> Bool
func _ [] = False
func [] _ = True
func (x:xs) (y:ys)
  | x < y = True
  | x > y = False
  | x == y = func xs ys

main = do
  line1 <- getLine
  line2 <- getLine
  let
    ret = func (sort line1) (sortBy (flip compare) line2)
  putStrLn $ judge ret ("Yes","No")


Measured memory_bytes: 508
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll n, h;
  cin >> n >> h;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a.at(i) >> b.at(i);

  ll maxa = *max_element(all(a));

  b.erase(remove_if(all(b), [&](const ll &i) { return i <= maxa; }), b.end());
  sort(b.rbegin(), b.rend());
  ll cnt = 0;
  for (const auto &i: b) {
    h -= i;
    ++cnt;
    if (h <= 0) break;
  }
  if (h > 0) cnt += h / maxa + (h % maxa == 0 ? 0 : 1);

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

  if (k % 2 == 1) {
    ll t = n / k;
    cout << t * t * t << endl;
    return 0;
  }

  ll t = n / (k / 2);
  ll u = t / 2, v = t - u;
  cout << u * u * u + v * v * v << endl;
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-07-09(Thr)
   note   
**********************************************************************/

#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; cin >> N;
  int payment = 0;
  for (int i = 1; i <= 10; ++i) {
    payment = 1000*i - N;
    if (payment >= 0) {
      cout << payment << endl;
      return 0;
    }
  }
  return 0; 
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#define fastio cin.tie(0); ios::sync_with_stdio(0)
#define multitc int _t; cin>>_t; while(_t--)
#define arrin(arr, n, type) arr.assign(n,type()); for(auto& i : arr) cin>>i;
#define all(x) (x).begin(), (x).end()
const int dir[9][2] = {{0,-1},{-1,0},{0,1},{1,0},{1,1},{-1,-1},{1,-1},{-1,1},{0,0}};
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll INF = 1e15+7;
const ll MOD = 998244353;
using namespace std;
using namespace __gnu_pbds;
int nextInt(){int x; cin>>x; return x;}
ll nextLong(){ll x; cin>>x; return x;}
template<typename T>
void arrin2d(vector<vector<T>>& arr, int y, int x)
{
    arr.assign(y,vector<T>(x));
    for(int i=0;i<y;++i)
    {
        for(int j=0;j<x;++j)
        {
            cin>>arr[i][j];
        }
    }
}
 
//using template
//code goes here
 
int k, n;
vector<int> arr;
int main()
{
    fastio;
    cin>>k>>n;
    arrin(arr,n,int);
    int dist = k-arr.back()+arr[0];
    for(int i=0;i<n-1;++i)
    {
        dist = max(dist, arr[i+1]-arr[i]);
    }
    cout<<k-dist;
}

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()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<LL, LL> P;
P half(LL h, LL w) {
	if (h % 2 == 0 || w % 2 == 0) return P(h*w / 2, h*w / 2);
	if (h <= w) return P(h*(w / 2 + 1), h*(w / 2));
	return P(w*(h / 2 + 1), w*(h / 2));
}
int main() {
	LL H, W;
	cin >> H >> W;
	LL ans = 1LL << 60;
	for (int k = 0; k < 2; k++) {
		for (int i = 1; i <= H - 1; i++) {
			P p = half(H - i, W);
			ans = min(ans, max(i*W, p.first) - min(i*W, p.second));
		}
		swap(H, W);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  int s=0;
  for(int i=0;i<y;i++)
  {
    int a;
    cin>>a;
    s=s+a;
  }
  if(s>x)
  {
    cout<<-1<<endl;
  }
  else
  {
    cout<<x-s<<endl;
  }
}
  
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int k;
  cin >> k;
  ll ans=0;
  for(int i=1;i<=k;i++){
    for(int r=1;r<=k;r++){
      for(int q=1;q<=k;q++){
        int g=__gcd(i,r);
        ans+=__gcd(g,q);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
from sys import stdin

S = str(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())

l = len(S)
ans = 0

for i in range(l):
    mo = S[0]*l
    if mo == S:
        ans = l*K//2
        print(ans)
        exit()
    else:
        pass


if S[0] == S[l-1]:
    S2 = S*2
    l2 = len(S2)
    a = 0#位置
    ans2 = 0
    while a < l2-1:
        if S2[a] == S2[a+1]:
            t = S2[a]
            c = 1
            for i in range(1,l2-a):
                if t == S2[a+i]:
                    c += 1
                else:
                    break
            j = c//2
            ans2 += j
            a += c
        else:
            a += 1
    a = 0#位置
    ans1 = 0
    while a < l-1:
        if S[a] == S[a+1]:
            t = S[a]
            c = 1
            for i in range(1,l-a):
                if t == S[a+i]:
                    c += 1
                else:
                    break
            j = c//2
            ans1 += j
            a += c
        else:
            a += 1
    differ = ans2-ans1*2
    ans = differ*(K-1) + ans1*K
else:
    a = 0#位置
    while a < l-1:
        if S[a] == S[a+1]:
            t = S[a]
            c = 1
            for i in range(1,l-a):
                if t == S[a+i]:
                    c += 1
                else:
                    break
            j = c//2
            ans += j
            a += c
        else:
            a += 1

    ans = ans*K

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<sz(s);i++)
    {
        if(s[i]=='+')
        c++;
        else
        c--;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <string>

typedef long long ll;

using namespace std;

int main() {
    int N;

    cin >> N;

    vector<string> s(N);

    for (int i = 0; i < N; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    sort(s.begin(), s.end());

    ll ans = 0;
    int cnt = 0;

    for (int i = 1; i < N; i++) {
        if (s[i] == s[i - 1]) {
            cnt++;
            ans += cnt;
        } else {
            cnt = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7296
#include <iostream>

int main()
{
  int R, G, B, N;
  
  std::cin >> R >> G >> B >> N;
  
  long long ret = 0;
  
  for (auto r = N / R; r >= 0; r--)
  {
    auto mod1 = N - R * r;
    for (auto g = mod1 / G; g >= 0; g--)
    {
      auto mod2 = mod1 - G * g;
      if ((mod2 % B) == 0)
        ret++;
    }
  }
  
  std::cout << ret;
}


Measured memory_bytes: 256
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = min(A) + min(B)
X = []
for _ in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x-1]+B[y-1]-c)

print(ans)


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

int main() {
    int A,B,C,D;
    cin >> A>>B>>C>>D;
    int x,y = 0;
    do{
        A -= D;
        x++;
    } while (A > 0);
    do{
        C -= B;
        y++;
    } while (C > 0);
    if(x >= y) cout << "Yes";
    else cout << "No" ;

	return 0;
}

Measured memory_bytes: 3628
n=input()
  
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
   
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      s[int(k)-1] = 0
   elif m == 'H':
      h[int(k)-1] = 0
   elif m == 'C':
      c[int(k)-1] = 0
   elif m == 'D':
      d[int(k)-1] = 0
  
for i in range(0, 13):
   if s[i] != 0:
      print 'S '+str(s[i])
  
for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(h[i])
  
for i in range(0, 13):
   if c[i] != 0:
      print 'C '+str(c[i])
  
for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(d[i])

Measured memory_bytes: 6392
import sys
import re
import queue
import collections
import math
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N,K = i_map()
	A = i_list()

	for i in range(0,len(A)):
		A[i] = A[i] - 1

	lengthA = math.ceil(math.log2(K))

	next = [[0 for _ in range(N)] for _ in range(lengthA)]
	
	for i in range(0,N):
		next[0][i] = A[(i)%(N)]

	for i in range(1,lengthA):
		for j in range(0,N):
			next[i][j] = next[i-1][next[i-1][j]]

	current = 0

	for i in range(0,lengthA):
		if((1 << i) & K):
			current = next[i][current]

	print(current+1)

	return

if __name__ == '__main__':
	main()

Measured memory_bytes: 221704
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, H;
    cin >> N >> H;
    vector<pii> vp(N);
    int a, b;
    for (int i = 0; i < N; i++) { cin >> b >> a; vp[i] = pii(a, b); }
    sort(vp.begin(), vp.end(), greater<pii>());

    int ma = 0;
    for (pii p : vp) { ma = max(ma, p.second); }

    int ans = 0;
    for (int i = 0; i < N && H > 0; i++) {
        if (vp[i].first > ma) {
            H -= vp[i].first;
            ans++;
        }
    }

    if (H > 0) ans += (H + ma - 1) / ma;
    cout << ans << '\n';
}


Measured memory_bytes: 1024
use v5.18;
use warnings;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my @nums = sort { $a <=> $b } splited_read_line;
my $ans = 0;
for my $i (1 .. $#nums) {
  $ans += abs($nums[$i - 1] - $nums[$i]);
}
say $ans;


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

using int128_t = __int128_t;

int128_t MOD;
void add(int128_t& a, int128_t b){
    a = (a+b) % MOD;
}
void mul(int128_t& a, int128_t b){
    a = a*b % MOD;
}

int dig(int128_t n){
    int d = 1;
    int128_t prod = 1;
    while(prod*10 <= n){
        d++;
        prod *= 10;
    }
    return d;
}

int128_t power_mod(int128_t num, int128_t power){
    int128_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}


map<int128_t, int128_t> mpT, mpS;
int128_t T(int128_t r, int128_t N){
    if(N == 0) return 0;
    if(mpT.count(N)) return mpT[N];
    int128_t res;
    if(N%2){
        res = 1 + r*(T(r, N-1));
    }else{
        res = (1 + power_mod(r, N/2)) * T(r, N/2);
    }
    res %= MOD;
    mpT[N] = res;
    return res;
}

int128_t S(int128_t r, int128_t N){
    if(N == 0) return 0;
    if(mpS.count(N)) return mpS[N];
    int128_t res;
    if(N%2){
        res = S(r, N-1) + N*power_mod(r, N-1);
    }else{
        res = S(r, N/2) + power_mod(r, N/2)*((N/2)*T(r, N/2) + S(r, N/2));
    }
    res %= MOD;
    mpS[N] = res;
    return res;
}

int128_t calc_T(int128_t r, int128_t N){
    mpT.clear();
    return T(r, N);
}

int128_t calc_S(int128_t r, int128_t N){
    mpT.clear();
    mpS.clear();
    return S(r, N);
}

int main(){
    int64_t tmp1, tmp2, tmp3, tmp4;
    cin >> tmp1 >> tmp2 >> tmp3 >> tmp4;
    int128_t L = tmp1, A = tmp2, B = tmp3;
    MOD = tmp4;

    int D = dig(A+B*(L-1));
    int64_t last = L-1;
    int128_t ans = 0, base = 1;
    for(int d=D; d>=dig(A); d--){
        if(dig(A+B*last) != d) continue;
        int64_t ok = last, ng = -1;
        while(ok-ng>1){
            int128_t mid = (ok+ng)/2;
            (dig(A + B*mid) == d ? ok : ng) = mid;
        }
        int128_t N = last-ok+1;
        int128_t res = (A + (last+1)*B) % MOD * calc_T(power_mod(10, d), N) % MOD;
        int128_t sub = B * calc_S(power_mod(10, d), N) % MOD;
        add(res, MOD - sub);
        add(ans, res*base);
        mul(base, power_mod(10, N*d));
        last = ok-1;
    }
    int64_t Ans = ans;
    cout << Ans << endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;



using namespace std;

int main()
{



  IOS;

  ll a,x;
  double  b;

  cin >> a >> b;

  long double ans = a * b;

  x = floor(ans);

  cout << x;



  return 0;

}

Measured memory_bytes: 3740
N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

ans = float('inf')
for i in range(pow(2, N)):
    cost = 0
    x_array = [0]*M
    for j in range(N):
        if (i>>j & 1) == 1:
            cost += CA[j][0]
            for m in range(M):
                x_array[m] += CA[j][m+1]
    flag = True
    for m in range(M):
        if x_array[m] < X:
            flag = False
            break
    if flag:
        ans = min(ans, cost)

if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9156
N, M= map(int, input().split())
a_list = sorted(map(int, input().split()), reverse = True)

# インデックスを分かりやすくするために先頭に0を追加
match_num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

inf = 10 ** 5
dp = [-inf] * (N + 1)
dp[0] = 0

# 桁数を調べる
for i in range(1, N+1):
    dp[i] = max([dp[i - match_num[a]] + 1 for a in a_list if i - match_num[a] >= 0] + [-inf])

# 各桁に使う数字を調べる
ans = [""] * dp[N]
rest_match = N
for i in range(dp[N]):
    for a in a_list:
        index = rest_match - match_num[a]
        if index >= 0 and dp[index] == dp[N] - i - 1:
            rest_match -= match_num[a]
            ans[i] = str(a)
            break
print("".join(ans))


Measured memory_bytes: 3688
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  re0 bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int mod=1e9+7;
int main(){
ll s=1;
for (int n=read();n;n--) s=s*n%mod;
write(s);
}

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

using namespace std;
#define ll long long int

int main(){
    ll A;
    ll B;
    ll C;
    ll K;
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>K;
    if(A>=K){
        cout<<K;
    }else if(A+B>=K){
        cout<<A;
    }else
    {
        cout<<A-(K-(A+B));
    }
    
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
 
int main() {
	int n; cin >> n; 
    bool OK = false;
	for (int j = 0; j <= n / 4; j++) {
		for (int k = 0; k <= n / 7; k++) {
			if (4 * j + 7 * k == n) OK = true;
		}
	}
	if (OK == false) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


string Main(int A, string S)
{
    return (A < 3200) ? "red" : S;
}

int main(void){
    int A;
    cin >> A;
    string S;
    cin >> S;
    cout << Main(A, S) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
  #include<fstream>
  #include<vector>
  #include<initializer_list>
  #include<string>
  using namespace std;
    int main(){
   string a;
   cin >> a;
  string b;
  cin >> b;
  string c;
  cin >> c;


cout << a.at(0) << b.at(0) << c.at(0) << endl;




  }

Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    fastio();

    int n, x, t;
    cin >> n >> x >> t;

    cout << ((n + x - 1) / x) * t;


    return 0;
}

/*

*/

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int cmpint(const void* n1, const void* n2)
{
	if (*(int*)n1 > * (int*)n2) {
		return 1;//降順なら-1
	}
	else if (*(int*)n1 < *(int*)n2) {
		return -1;//降順なら1
	}
	else {
		return 0;
	}
}

int main(){
	int n;
	double val;
	int v[50]={};
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	qsort(v, n, sizeof(int), cmpint);
	val=(double)(v[0]+v[1])/2;
	for (int i = 2; i < n; i++) {
		val=(double)(val+v[i])/2;
	}
	printf("%.6f\n", val);
	return 0;
}


Measured memory_bytes: 128
def getlist():
	return list(map(int, input().split()))

L, R = getlist()

if R - L >= 2019:
	print(0)
else:
	X = []
	for i in range(L, R + 1):
		X.append(i % 2019)
	n = len(X)
	ans = float("inf")
	for i in range(n):
		for j in range(i + 1, n):
			val = (X[i] * X[j]) % 2019
			if val < ans:
				ans = val

	print(ans)

Measured memory_bytes: 40812
#include<iostream>
#include<map>
#include<cstdio>

using namespace std;

int main()
{
	int num;
	map<int, int, greater<int> > mp;

	while(cin >> num, num)
	{
		mp.clear();

		int patient, walk1, walk2;
		for(int i = 0; i < num; i++)
		{
			cin >> patient >> walk1 >> walk2;
			mp.insert( make_pair( walk1 + walk2 , patient ) );
		}

		map<int,int>::iterator it = mp.begin();
		printf("%d %d\n",(*it).second ,(*it).first);		
	}
	return 0;
}

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

# define F first    
# define S second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r"))
    freopen (in, "r", stdin);
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int p[Sz], a[Sz];
   
int main()
{
  # ifdef Local
    localInput();
  # endif
  Read_rap();
  int n; cin >> n; 
  for (int i = 1; i <= n; i++)  cin >> a[i];
  for (int i = 1; i <= n; i++)  p[i] = i;

  sort (p + 1, p + n + 1, [] (int i, int j) { return a[i] < a[j]; });
  int ans = 0;
  for (int i = 1; i <= n; i += 2)
    ans += (p[i] % 2 == 0);
  cout << ans;  

  return 0;
}






// Coded by Z..


Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int D = V[0];
            int N = (V[1] != 100) ? V[1] : 101;
            Console.WriteLine(new int[] { 1, 100, 10000 }[D] * N);
        }
    }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    ll r;
    cin>> r;

    cout<< 3 * r* r;
    nl;

    return 0;
}




Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
	int N, M;
	cin >> N >> M;
	priority_queue<ll> work;
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;

	rep(i, N) {
		ll a, b;
		cin >> a >> b;
		pq.push({ a,b });
	}

	ll res = 0;
	REP(day, 1, M+1) {
		while (!pq.empty() && pq.top().first <= day) {
			auto best = pq.top(); pq.pop();
			work.push(best.second);
		}
		if (!work.empty()) {
			res += work.top(); work.pop();
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(){
 int time;
 int h, m, s;

 scanf("%d", &time);

 h = time / 3600;
 time %= 3600;

 m = time / 60;
 time %= 60;

 s = time;

 printf("%d:%d:%d\n", h, m, s);
}

Measured memory_bytes: 1812
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 
 

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			int k=n-i-j;
			if(i+j+k==n && k>=0){
				if(i*10000+j*5000+k*1000==m){
					cout<<i<<" "<<j<<" "<<k<<endl;
					return 0;
				}
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
}

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

map<string, int> M;

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

    while(N--)
    {
        string S;
        cin >> S;

        sort(S.begin(), S.end());
        M[S]++;
    }

    long long ans = 0;

    for(auto it : M)
        ans += 1LL * (it.second) * (it.second - 1) / 2;

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11136