akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, K, C; cin >> N >> K >> C;
  string S; cin >> S;
  vecll work(K), work2(K);
  ll cur = 0, br = 2000000000;
  REP(i, N) {
    if (cur < K) {
      if (br >= C && S[i] == 'o') {
        work[cur] = i;
        cur++;
        br = 0;
      } else {
        br++;
      }
    } else {
      break;
    }
  }
  cur = 0;
  br = 2000000000;
  REP(i, N) {
    ll j = N-i-1;
    if (cur < K) {
      if (br >= C && S[j] == 'o') {
        work2[K-cur-1] = j;
        cur++;
        br = 0;
      } else {
        br++;
      }
    } else {
      break;
    }
  }
  REP(i, K) if (work[i] == work2[i]) cout << work[i]+1 << endl;
  return 0;
}


Measured memory_bytes: 4996
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
def f():
  n, a, b, c, d = map(int, input().split())
  dp = dict()
  def dfs(n):
    if n == 0:
      return 0
    if n == 1:
      return d
    if n in dp:
      return dp[n]
    res = n*d
    for s, k in ((a, 2), (b, 3), (c, 5)):
      q, r = divmod(n, k)
      res = min(res, dfs(q)+d*r+s)
      if r:
        res = min(res, dfs(q+1)+d*(k-r)+s)
    dp[n] = res
    return res
  ans = dfs(n)
  print(ans)
t = int(input())
for _ in range(t):
  f()

Measured memory_bytes: 20316
a[2][21];main(t,n,m,f,i,j,x){for(;scanf("%d%d",&n,&m),n;printf("Case %d: %d\n",t++,i))for(memset(a,f=0,sizeof(a)),a[f][i=0]=n;!a[f][m];f^=1,i++)for(j=0;j<m;j++)x=a[f][j],a[f^1][j+1]+=x/2,a[f^1][a[f][j]=0]+=x/2,a[f^1][j]+=x%2;exit(0);}

Measured memory_bytes: 600
import logging
import copy

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    S = input()
    S_len = len(S)
    child = [1 for _ in range(S_len)]
    logging.info("Hello!")

    R_counter = 1
    L_counter = 0
    R = [0 for _ in range(S_len)]
    L = [0 for _ in range(S_len)]
    L2R = 0
    R2L = 0
    
    for i in range(1, S_len):
        if S[i] == "R" and S[i - 1] == "R":
            R_counter += 1
        elif S[i] == "L" and S[i - 1] == "R":
            R2L = i
            R[i - 1] = R_counter
            R_counter = 0
            L_counter += 1
        elif S[i] == "L" and S[i - 1] == "L":
            L_counter += 1
        elif S[i] == "R" and S[i - 1] == "L":
            R[R2L] = L_counter
            L_counter = 0
            R_counter += 1

        if i == S_len - 1:
            R[R2L] = L_counter

    logging.info(R)

    counter = 0
    while counter < S_len:
        if (R[counter] != 0):
            temp1 = R[counter]
            temp2 = R[counter + 1]
            R[counter] = (temp1 - temp1 // 2) + (temp2 // 2)
            R[counter + 1] = (temp1 // 2) + (temp2 - temp2 // 2)
            
            counter += 1
        counter += 1
            

    answer = ""
    for x in R:
        answer += str(x)
        answer += " "

    print(answer)
            
    
if __name__ == "__main__":
    main()


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

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

    if (N[0] == '7' || N[1] == '7' || N[2] == '7') {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1,2,4,3);}
  void roll_y(){roll(0,2,5,3);}
  void roll_x(){roll(0,1,5,4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

int getRight( Cube c1, int f1, int f2){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if(c1.f[0] == f1 && c1.f[1] == f2) return c1.f[2];
      c1.roll_z();
    }
    if(i % 2 == 0) c1.roll_y();
    else c1.roll_x();
  }
  return -1;
}

int main(){
  Cube c;
  int f1, f2;

  for(int i=0;i<6;i++) cin >> c.f[i];
  int q; cin >> q;

  for(int i=0;i<q;i++){
    cin >> f1 >> f2;
    cout << getRight(c, f1, f2) << endl;
  }

  return 0;
}



Measured memory_bytes: 3004
#include <stdio.h>
#include <cmath>

long long int f(long long int b, long long int n){
    if (n < b) {
        return n;
    } else {
        return f(b, n / b) + n % b;
    }
}

int main(){
    long long int n, s;
    scanf("%lld", &n);
    scanf("%lld", &s);

    if (n == s) {
        printf("%lld\n", n + 1);
        return 0;
    } else if (s > n) {
        printf("-1\n");
        return 0;
    }

    for(long long int b = 2; b <= std::sqrt(n); ++b){
        if (f(b, n) == s){
            printf("%lld\n", b);
            return 0;
        }
    }

    long long int b = 0;
    for(long long int p = std::sqrt(n); 1 <= p; --p){
        b = 1 + (n - s) / p;
        if (b >= 2 && b > p && p*p!=n) {
            if (f(b, n) == s) {
                printf("%lld\n", b);
                return 0;
            }
        }
    }

    printf("-1\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
 
#define PI 3.141592
 
typedef struct{
  double x;
  double y;
} Point;
 
void kock(int,Point,Point);
 
int main(){
   
  Point p1={0.0 ,0.0},p2={100.0 ,0.0};
  int n;
   
  //in
  scanf("%d",&n);
   
  printf("%f %f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
   
  return 0;
}
 
void kock(int n,Point p1,Point p2){
  Point s,t,u;
   
  double rad = (60*PI)/180.0;
   
  if(n==0) return ;
   
  //calc
  s.x = (2*p1.x+1*p2.x)/3.0;
  s.y = (2*p1.y+1*p2.y)/3.0;
   
  t.x = (1*p1.x+2*p2.x)/3.0;
  t.y = (1*p1.y+2*p2.y)/3.0;
   
  u.x = (t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
  u.y = (t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;
   
  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);
 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int w,a,b; cin >> w >> a >> b; 
   cout << (abs(a-b)-w<0 ? 0 : abs(a-b)-w) << endl;
}

Measured memory_bytes: 256
#include<iostream>
int num[10][10];
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        num[s[0]-'0'][s[s.size()-1]-'0']++;
    }
    for(int i=0;i<10;i++)for(int j=0;j<10;j++)ans+=num[i][j]*num[j][i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {
	int x, y;

	cin >> x >> y;

	if (x == 2 || y == 2) {
		cout << "No" << endl;
	}
	else if ((x==4||x==6||x==9||x==11)
		&&(y == 4 || y == 6 || y == 9 || y == 11)) {
		cout << "Yes" << endl;
	}
	else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
		&& (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
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int k[1000];
int main(){
	int n;
	cin>>n;
	bool l=false;
	for(int i=0;i<n;i++){
		cin>>k[i];
		if(k[i]==0)
			l=true;
	}
	if(l==true){
	int ans=1;
	while(true){
		bool t=false;
		for(int start=0;start+(int)log10((double)ans+0.0)<n;start++){
			bool f=true;
			for(int len=start;len-start<=(int)log10((double)ans+0.0);len++){
				int u=pow(10.0,1+start-len+(int)log10((double)ans+0.0));
				if(k[len]!=ans%u/(u/10))
					f=false;
			}
			if(f==true)
				t=true;
		}
		if(t==false)
			break;
		ans++;
	}
	cout<<ans<<endl;
	}
	else
		cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 1228
n = gets.to_i
cr = []
sr = []
fr = []
(n-1).times do
  c,s,f = gets.strip.split.map(&:to_i)
  cr << c
  sr << s
  fr << f
end
if n == 1
  puts 0
  exit
end
#以下nは２以上
for i in 0..n-2
  time = sr[i]
  j = i
  while j<n-1 do
    time += cr[j]
    if j != n-2
      if time <= sr[j+1].to_i
        time = sr[j+1]
      else
        time = (((time-sr[j+1].to_i).to_f/fr[j+1]).ceil)*fr[j+1].to_i+sr[j+1].to_i
      end
    end
    j += 1
  end
  puts time
end
puts 0



Measured memory_bytes: 14372
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void){
    int i, N;
    double A[101], ANS=0;
    scanf("%d", &N);
    for(i=0; i<N; i++) scanf("%lf", A+i);
    for(i=0; i<N; i++) ANS += 1.0/A[i];
    printf("%lf\n", 1.0/ANS);
    return 0;
}


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

using namespace std;

int main() {
    char N[5];
    int count = 0;
    cin >> N;
    for (int i = 0; i < 4; i++) {
        if (N[i] == '2') {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

int main(int argc, const char * argv[]) {
  int a, p; cin >> a >> p;
  p += 3*a;
  cout << p/2 << endl;
  return 0;
}

Measured memory_bytes: 256
def solve(lr,N,Q,S):
    #ACの総数をindex0~N-1まで全てだす
    count = [0]*N
    sum = 0
    for i in range(1,N):
       
        if S[i-1]=='A' and S[i]=='C':
            sum += 1
            count[i] = sum
        else:
            count[i] = sum

    # print(count)
    
    for i in range(Q):
        # print(int(lr[i][1]),int(lr[i][0]))
        print(count[int(lr[i][1])-1]-count[int(lr[i][0])-1])
    #     # print(S[int(lr[i][0])-1:int(lr[i][1])].count('AC'))



 
def main():
    N,Q= map(int,input().split())
    S = input()
    lr = [0]*Q
    for i in range(Q):
        lr[i]=input().rstrip().split()
    # S = 'ACACTACG'
    # N = 8
    # Q = 3
    # lr = [['3', '7'], ['2', '3'], ['1', '8']]
    solve(lr,N,Q,S)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 35460
/* Arpit Pandey*/ 

#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdint.h>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
void fast_io()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif
}

void sol()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int arr[4];
	arr[0]=a*c; arr[1]=a*d;
	arr[2]=b*c;arr[3]=b*d;
	int ans=-1e18;
	for(int i=0;i<4;i++)
		ans=max(ans,arr[i]);
	cout<<ans;

}
int32_t main()
{
	fast_io();
	//test(t)
	sol();
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3668
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.print(s.charAt(0));
        System.out.print(s.length() - 2);
        System.out.print(s.charAt(s.length() - 1));
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		ll N=in();
		if(!N) break;

		int num=0;
		while(N!=1){
			if(N%2) N = 3LL*N+1LL;
			else N /= 2LL;
			num++;
		}
		out(num);
	}
	
	return 0;
}



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

int main() {

  int N ;
  string S ; 
  cin >> N ; 
  cin >> S ; 
  int T = S.size() ; 


  
  for( int i = 0 ; i < T ; i++  ){
    char A = S.at(i) ; 
    int X =  A - 'A' ; //char から intに変換 
    X = (N+X)%26 ; 
    putchar('A' + X ) ; 
  }
  


 
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int r, d, x; cin>>r>>d>>x;
    for (int i = 0; i < 10; ++i) {
        x = r*x-d;
        cout << x << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 3534567;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;
int a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    rep(i , 1 , n) {
    	cin >> a[i];
    }

    vector < pair < int , int > > res;

    rep(i , 1 , n) {
    	res.push_back({a[i] , i});
    }

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

    rep(i , 1 , n) {
    	cout << res[i - 1].second << " ";
    }
    cout << endl;
    return 0;
}


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

int main(){
  int k, n, ans = 0;
  cin >> k >> n;
  vector<int> a(n), b(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  b.at(0) = a.at(0) + k - a.at(n-1);
  for(int i = 1;i < n;i++){
    b.at(i) = a.at(i) -a.at(i-1);
  }
  sort(b.begin(), b.end());
  for(int i = 0;i < n-1;i++){
    ans = ans + b.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
//
// Hopcroft-Karp's maximum cardinality bipartite matching
//
// Description:
//   Compute the maximum cardinality matching for bipartite graph.
//
// Algorithm:
//   The algorithm iterates following procedures:
//     (1) BFS from the source to get the distance to the sink.
//         If not reachable, there are no augment path hence break.
//     (2) Find vertex disjoint shortest augment paths by DFS.
//   It can be shown that the outer-loop is atmost O(\sqrt{n}) times
//   therefore the whole complexity is O(m \sqrt{n}).
//   Note that this is a specialzation of Dinic's maximum flow.
//
//
// Complexity:
//   O(m \sqrt{n}) time
//
// Verified:
//   SPOJ 4206: Fast Maximum Matching
//
// References:
//   J. E. Hopcroft and R. M. Karp (1973):
//   An n^5/2 algorithm for maximum matchings in bipartite graphs.
//   SIAM Journal on Computing, vol.2, no.4, pp.225-231.
//

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>
#include <functional>
#include <algorithm>

using namespace std;

struct graph {
  int L, R;
  vector<vector<int>> adj;
  graph(int L, int R) : L(L), R(R), adj(L+R) { }
  void add_edge(int u, int v) {
    adj[u].push_back(v+L);
    adj[v+L].push_back(u);
  }
  int maximum_matching() {
    vector<int> level(L), mate(L+R, -1);

    function<bool(void)> levelize = [&]() { // BFS
      queue<int> Q;
      for (int u = 0; u < L; ++u) {
        level[u] = -1;
        if (mate[u] < 0) {
          level[u] = 0;
          Q.push(u); 
        }
      }
      while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (int w: adj[u]) {
          int v = mate[w];
          if (v < 0) return true;
          if (level[v] < 0) {
            level[v] = level[u] + 1;
            Q.push(v); 
          }
        }
      }
      return false;
    };
    function<bool(int)> augment = [&](int u) { // DFS
      for (int w: adj[u]) {
        int v = mate[w];
        if (v < 0 || (level[v] > level[u] && augment(v))) {
          mate[u] = w;
          mate[w] = u;
          return true;
        }
      }
      return false;
    };
    int match = 0;
    while (levelize()) 
      for (int u = 0; u < L; ++u) 
        if (mate[u] < 0 && augment(u)) 
          ++match;
    return match;
  }
};

int main() {
  int L, R, m; 
  scanf("%d %d %d", &L, &R, &m);
  graph g(L, R);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    g.add_edge(u, v);
  }
  printf("%d\n", g.maximum_matching());
}

Measured memory_bytes: 1312
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}// x^n%mod
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<int> >;//int と P

int main(){
    int n;cin>>n;
    vector<P>a(n);
    rep(i,n){
        cin>>a[i].fi;
        a[i].se=i+1;
    }
    sort(ALL(a));
    rep(i,n)cout<<a[i].se<<" ";
    cout<<Endl;
}

Measured memory_bytes: 2432
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n;

void Input() {
	cin >> n;
}

void Solve() {
	vll a(n);
	ll xr = 0;
	for (ll i = 0; i < n; i++) cin >> a[i], xr ^= a[i];
	for (ll i = 0; i < n; i++) {a[i] ^= xr; cout << a[i] << " ";}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
     
using namespace std;
     
#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'
     
typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;
     
const int MX = 3005;

ll dp[MX][MX][2];
const ll BIG = 10000000000LL;

ll solve(int p, int l, int r, vi &A)
{
	if (l > r) return 0;
	if (dp[l][r][p] != BIG) return dp[l][r][p];
	if (p&1) {
		ll res1 = -A[l]+solve((p+1)&1,l+1,r,A);
		ll res2 = -A[r]+solve((p+1)&1,l,r-1,A);
		return dp[l][r][p] = min(res1,res2);
	} else {
		ll res1 = A[l]+solve((p+1)&1,l+1,r,A);
		ll res2 = A[r]+solve((p+1)&1,l,r-1,A);
		return dp[l][r][p] = max(res1,res2);
	}
}

int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vi a(n);
	FOR(i,0,n) cin >> a[i];
	FOR(i,0,n) FOR(j,0,n) FOR(k,0,2) dp[i][j][k] = BIG;
	ll x = solve(0,0,n-1,a);
	cout << x << endl;
    return 0;
}


Measured memory_bytes: 141312
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, op, B := sc.nextInt(), sc.nextStr(), sc.nextInt()

	if op == "+" {
		fmt.Fprintln(wtr, A+B)
	} else {
		fmt.Fprintln(wtr, A-B)
	}
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for(int i = 1; i < 11; i++){
        x = r*x - d;
        cout << x << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int p,q,r;
    while(~scanf("%d%d%d",&p,&q,&r))
    {
        int Max,Max1;
        Max=max(p,q);
        Max1=max(Max,r);
        printf("%d\n",p+q+r-Max1);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i,m){
        int s,t;
        cin >> s >> t;
        --s;--t;
        to[s].pb(t);
    }
    vector<double> dp(n);
    repr(v,n-1){
        double now = 0;
        for(int u:to[v]){
            now += dp[u];
        }
        now /= to[v].size();
        now += 1;
        dp[v] = now;
    }
    
    double ans = dp[0];
    rep(nv,n-1){
        if (to[nv].size() == 1) continue;
        int nu = to[nv][0];
        for (int u:to[nv]){
            if (dp[nu] < dp[u]) nu = u;
        }
        
        double now = [&]{
            vector<double> dp(n);
            repr(v,n-1){
                double now = 0;
                for(int u:to[v]){
                    if (v == nv && u == nu) continue;
                    now += dp[u];
                }
                int deg = to[v].size();
                if (v==nv) deg--;
                now /= deg;
                now += 1;
                dp[v] = now;
            }
            rn dp[0];
        }();
        ans = min(ans,now);
    }
    
    printf("%.10f",ans);
}
int mainA(){
    int N,M; cin >> N >> M;
    vector<vector<int>> g(N);
    int s,t;
    rep(i,M){
        cin >> s >> t; s--; t--;
        g[s].pb(t);
    }
    

    vector<double> dp(N);
    cout << endl;
    repr(i,N-1){
        double now = 0;
        double p = 1/double(g[i].size());
        for (int t : g[i]){
            now += dp[t]*p;
        }
        now ++;
        dp[i] = now;
    }
    double ans = dp[0];
    
    rep(nu,N-1){
        if (g[nu].size() == 1) continue;
        int nv = g[nu][0];
        for (int u: g[nu]){
            if(dp[u]>dp[nv]) nv = u;
        }
        double cur = [&]{
            vector<double> dp(N);
            repr(i,N-1){
                double now = 0;
                double p = 0;
                p = 1/double(g[i].size());
                if (i==nu) p = 1/double(g[i].size()-1);
                for (int u : g[i]){
                    if (u == nv && i == nu) continue;
                    now += dp[u]*p;
                }
                now ++;
                dp[i] = now;
            }
            rn dp[0];
        }();
        ans = min(ans,cur);
    }
    printf ("%.10f\n",ans);
    rn 0;
}



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

int main()
{
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    
    int ct[h][w];
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0 && j==0){
                ct[0][0] = 1;
            }
            else if(i==0){
                if(a[i][j]=='.') ct[0][j] = ct[0][j-1]%1000000007;
                else ct[0][j] = 0;
            }
            else if(j==0){
                if(a[i][j]=='.') ct[i][0] = ct[i-1][0]%1000000007;
                else ct[i][0] = 0;
            }
            else{
                if(a[i][j]=='.'){
                    ct[i][j] = (ct[i-1][j]%1000000007 + ct[i][j-1]%1000000007)%1000000007;
                }
                else{
                    ct[i][j] = 0;
                }
            }
        }
    }
    
    cout << (ct[h-1][w-1])%1000000007 << endl;

    return 0;
}


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

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		int kaisu=0;
		String str="";
		str=bfr.readLine();
		kaisu=Integer.parseInt(str);
		int ninzu=0;
		String[] ba=new String[2];
		for(int i=0; i<kaisu; i++) {
			str=bfr.readLine();
			ba=str.split(" ");
			ninzu+=Math.abs(Integer.parseInt(ba[0])-Integer.parseInt(ba[1]))+1;
		}
		System.out.println(ninzu);
	}
}

Measured memory_bytes: 21972
import java.util.*;

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

        long h = sc.nextLong();

        long ans = 1;
        long a = 1;

        for (int i = 1; i < 10000000; i++) {

            if (ans < h) {
                ans += a * 2;
                a = a * 2;
            } else {
                break;
            }

        }

        System.out.println(ans);

    }
}

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

int main() {
  int N, M; cin >> N >> M;
  map<int, int> m;
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    if (m.count(A)) m[A]++;
    else m[A] = 1;
  }
  for (int i = 0; i < M; i++) {
    int B, C; cin >> B >> C;
    if (m.count(C)) m[C] += B;
    else m[C] = B;
  }
  priority_queue<pair<int, int>> pq;
  for (auto p : m) pq.push(make_pair(p.first, p.second));
  long long ans = 0;
  long long tmp = 0;
  while (tmp < N) {
    long long num = pq.top().first;
    long long cnt = pq.top().second;
    pq.pop();
    ans += num * min(cnt, N - tmp);
    tmp += min(cnt, N - tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11768
N, K = map(int, input().split())
x = list(map(int, input().split()))

shortest = float("inf")
for i in range(N - K + 1):
    left = x[i]
    right = x[i + K - 1]
    left_first = abs(left) + abs(left - right)
    right_first = abs(right) + abs(left - right)
    shortest = min(shortest, left_first, right_first)
print(shortest)

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n],a[n][m];
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int b[m] = {};
    int ans = 100000000;

    //bit全探索
    for(int bit = 0; bit < (1<<n); ++bit){
        int money = 0;
        for(int i = 0; i < n; ++i){
            if(bit & (1<<i)){
                money += c[i];
                for(int j = 0; j < m; j++){
                    b[j] += a[i][j];
                }
            }
        } 

        for(int i = 0; i < m; i++){
            //cout << b[i] << " ";
        }
        //cout << endl;
        

        bool p = 1;
        for(int i = 0; i < m; i++){
            if(b[i] < x){
                p = 0;
            }
        }
        if(p == 1){
            ans = min(ans,money);
        }
        money = 0;
        for(int i = 0; i < m; i++){
            b[i] = 0;
        }
    }

    if(ans == 100000000){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int i=sc.nextInt();
	int N[]=new int[i];
	for(int j=0;j<i;j++){
		N[j]=sc.nextInt();
	}
	for(int s=0;s<i;s++){
		System.out.print(N[i-1-s]);
		if(s<(i-1))System.out.print(" ");
	}
	System.out.print("\n");
	}
}



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

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


int dp[100010];

int main(int argc, char const *argv[])
{
	int n; cin >> n;

	rep(i, 100010) dp[i] = 1e9;
	dp[0] = 0;
	
	rep(i, n) {
		dp[i + 1] = min(dp[i + 1], dp[i] + 1);

		int cnt = 1;
		while(1) {
			int sum = pow(6, cnt++);
			if (sum + i > 100000) break;
			dp[sum + i] = min(dp[sum + i], dp[i] + 1);
		}

		cnt = 1;
		while(1) {
			int sum = pow(9, cnt++);
			if (sum + i > 100000) break;
			dp[sum + i] = min(dp[sum + i], dp[i] + 1);
		}
	}

	printf("%d\n", dp[n]);
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int N;
    cin >> N;
    int min = INF;
    int ans = 0;
    rep(i, N) {
        int p;
        cin >> p;
        if (p < min) {
            min = p;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,ans;
  cin >> n;
  ans = 0;
  vector<int> p(n);
  for(int i = 0;i < n;i++){
    cin >> p.at(i);
  }
  
  for(int j = 0;j < n;j++){
	if(p.at(j) != j+1){
      ans++;
    }
  }

  if(ans < 3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}

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

using namespace std;
int n;
int x;
int m;
int a[10009];
multiset<int> s;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        s.insert(x);
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        if(s.find(x)!=s.end())
        {
            s.erase(s.find(x));
        }
        else
        {
            cout<<"NO";return 0;
        }
    }
    cout<<"YES";
}


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

int w,h,n,x[100],y[100],a[100];

signed main(){
	cin>>w>>h>>n;
	int cnt0=0;
	int cnt1=w;
	int cnt2=0;
	int cnt3=h;
	rep(i,n){
		cin>>x[i]>>y[i]>>a[i];
		if(a[i]==1)cnt0=max(cnt0,x[i]);
		else if(a[i]==2)cnt1=min(cnt1,x[i]);
		else if(a[i]==3)cnt2=max(cnt2,y[i]);
		else cnt3=min(cnt3,y[i]);
	}
	if(cnt0>=cnt1||cnt2>=cnt3){
		cout<<0<<endl;
		return 0;
	}
	int ta=cnt0+(w-cnt1);
	int mu=cnt2+(h-cnt3);
	cout<<w*h-(ta*h+mu*w-ta*mu)<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
ans = []
if n.odd?
  (n/2).times do |i|
    ans << [i+1, n-i]
  end
else
  (n/2-1).times do |i|
    ans << [i+1, n-i]
    ans << [i+n/2+1, n/2-1-i]
  end
end
m.times do |i|
  puts ans[i].join(" ")
end


Measured memory_bytes: 25396
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <cstring>
#include <queue>


#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define eREP(i, n) for(int (i) = 0; (i) <= (n); ++(i))
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; ++(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

template <class T> inline T& chmax(T& a, T b){return (a < b) ? a = b : a;}
template <class T> inline T& chmin(T& a, T b){return (a > b) ? a = b : a;}

using lli = long long int;
using pli = std::pair<lli, int>;

std::vector<lli> A, B;

int main(void){
    std::priority_queue<pli> Q;
    int n; scanf("%d", &n);
    A.resize(n); B.resize(n);
    REP(i, n) scanf("%lld", &A[i]);
    REP(i, n) {scanf("%lld", &B[i]); if(A[i] < B[i]) Q.push(pli(B[i], i));}

    lli res = 0;
    while(not Q.empty()){
        int idx; lli v = 0;
        std::tie(std::ignore, idx) = Q.top(); Q.pop();
        if(not Q.empty()) std::tie(v, std::ignore) = Q.top();
        int idx_p = (idx-1 + n) % n;
        int idx_l = (idx+1) % n;
        lli V = B[idx_p] + B[idx_l];
        lli K1 = (B[idx] - A[idx]) / V; if(K1 == 0) K1 = 1;
        B[idx] -= K1 * V; res += K1;
        if(B[idx] < A[idx]) break;
        else if(B[idx] > A[idx]){
            Q.push(pli(B[idx], idx));
        }
    }
    bool same = true;
    REP(i, n) if(A[i] != B[i]){
        same = false;
        break;
    }
    if(same) printf("%lld\n", res);
    else puts("-1");
    return 0;
}


Measured memory_bytes: 9584
N,K = map(int,input().split())
V = list(map(int,input().split()))

cum = [0]
rcum = [0]

for i in range(N):
    cum.append(cum[-1]+V[i])
    rcum.append(rcum[-1]+V[-1-i])

ans = 0

for i in range(N+1):
    for j in range(N+1):

        if i+j > min(N,K):
            continue

        value = cum[i]+rcum[j]
        neg = []

        for ii in range(i):
            if V[ii] < 0:
                neg.append(V[ii])

        for jj in range(j):
            if V[-1-jj] < 0:
                neg.append(V[-1-jj])

        neg.sort()

        value -= sum(neg[:min(K-i-j,len(neg))])

        ans = max(ans,value)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (d >= abs(a - c) || (d >=abs(a - b) && d >=abs(b - c))) {
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
require 'pp'
n, h = gets.split.map(&:to_i)
ab = []
n.times do
  ab << gets.split.map(&:to_i)
end
cnt = 0

a_max = ab.sort_by{|x|-x[0]}[0][0]

sum = 0
ab.sort_by!{|x|-x[1]}
ab.size.times do |i|
  if sum >= h
    p cnt
    exit
  end

  break if ab[i][1] <= a_max
  sum += ab[i][1]
  cnt += 1
end


cnt += ((h-sum) / a_max.to_f).ceil

p cnt


Measured memory_bytes: 13660
import math

x = int(raw_input())
rmax = 1
lmax = int(math.ceil(math.sqrt(x)))
for j in range(2, lmax):
    for k in range(2, 10 + 1):
        r = j ** k
        if r > x:
            break
        else:
            if r > rmax:
                rmax = r

print rmax

Measured memory_bytes: 2568
from collections import deque
N,M = map(int,input().split())
a = deque([int(input()) for m in range(M)]+[-1])
ans = []
P = 10**9+7
for n in range(N):
    if n+1 == a[0]:
        ans.append(0)
        a.popleft()
    else:
        if n == 0:
            ans.append(1)
        elif n == 1:
            ans.append(ans[0]+1)
        else:
            ans.append((ans[n-1]+ans[n-2])%P)
print(ans[N-1])


Measured memory_bytes: 8184
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n < k)
		cout << n * x << endl;
	else
		cout << x * k + (n - k) * y << endl;
}


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(x) (x).begin(), (x).end()

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c)
        cout << "Yes" << endl;
    else if (a == b + c)
        cout << "Yes" << endl;
    else if (a + c == b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // end

    return 0;
}


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

int main() {
  int K, N;
  cin >>K >>N;
  vector<int> vec(N), data(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int i = 1; i < N; i++){
    data.at(i) = K - vec.at(i) + vec.at(i - 1);
  }
  data.at(0) = vec.at(N - 1) - vec.at(0);
  sort(data.begin(), data.end());
  cout << data.at(0) << endl;
}



Measured memory_bytes: 1792
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, K = getNM()
A = getList()
minus = [-x for x in A if x < 0]
plus = [x for x in A if x >= 0]

minus.sort()
plus.sort()

def cnt(x):
    ans = 0
    if x < 0:
        x = -x
        r = 0
        # - * +
        for num in minus[::-1]:
            while r < len(plus) and plus[r] * num < x:
                r += 1
            ans += len(plus) - r
        return ans

    r = 0
    for num in minus[::-1]:
        if num * num <= x:
            ans -= 1
        while r < len(minus) and minus[r] * num <= x:
            r += 1
        ans += r
    r = 0
    for num in plus[::-1]:
        if num * num <= x:
            ans -= 1
        while r < len(plus) and plus[r] * num <= x:
            r += 1
        ans += r
    ans //= 2
    # -になるものはまとめて計算
    ans += len(minus) * len(plus)
    return ans

bottom = 0
top = 2 * (10 ** 18) + 2


while top - bottom > 1:
    mid = (top + bottom) // 2
    if cnt(mid - 10 ** 18 - 1) < K:
        bottom = mid
    else:
        top = mid

print(int(top - 10 ** 18 - 1))

Measured memory_bytes: 150664
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> x(n);
	vector<ll> med(n);
	rep(i, n) {
		cin >> x[i];
		med[i] = x[i];
	}
	sort(all(med));
	ll l, r;
	l = med[(n - 1) / 2];
	r = med[n / 2];
	rep(i, n) {
		if (x[i] <= l) {
			cout << r << endl;
		}
		else {
			cout << l << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5376