akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200005],sum,cnt,ans=11111111111;
signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(int i=0;i<n-1;i++){
    cnt+=a[i];
    ans=min(ans,abs((sum-cnt)-cnt));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	int pa = 0, gu = 0;
	rep(i, n) {
		if (s[i] == 'p') pa++;
		else gu++;
	}
	int ans = n / 2 - pa;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
Scanf.scanf "%d" (fun n ->
    let rec loop_a a acc =
        let rec loop_b b acc =
            if a * b >= n then loop_a (a + 1) acc else
                loop_b (b + 1) (acc + 1)
        in
        if a >= n then acc else loop_b 1 acc
    in
    loop_a 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 5896
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = (1<<18) + 100, mod = 1e9 + 7;
int n, prec[606][1<<17], w[maxn], v[maxn];
int k;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= 1<<9; i++) {
		for(int j = 0; j < maxn; j++) prec[i][j] = prec[i/2][j];
		for(int j = (1<<17)-1; j >= w[i]; j--) {
			prec[i][j] = max(prec[i][j], prec[i][j-w[i]] + v[i]);
		}
		for(int j = 1; j < 1<<17; j++) prec[i][j] = max(prec[i][j], prec[i][j-1]);
	}
	int q, u, l;
	cin >> q;
	while(q--) {
		cin >> u >> l;
		vector<int> t;
		while(u > 512) t.pb(u), u/=2;
		int m = t.size(), ans = 0;
		for(int i = 0; i < 1<<m; i++) {
			int cv = 0, cw = 0;
			for(int j = 0; j < m; j++) if(((i>>j)&1)) {
				cw += w[t[j]];
				cv += v[t[j]];
			}
			if(cw <= l) ans = max(ans, cv + prec[u][l-cw]);
		}
		cout << ans << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 268336
function main(input) {
  	var tmp = input.split(' ');
    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);

    var n = b - a - 1;
    var answer = n*(n+1)/2 - a;

    console.log(answer);

  }
  main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

public class Main {
	private static void solve(){
	//Implement solution here.
		String s = next();
		int n = s.length() + 1;
		char[] c = s.toCharArray();
		long result = 0;
		int cnt = 0;
		int[] l = new int[n];
		int[] r = new int[n];
		for(int i = 0; i < n - 1; i++) {
			if(c[i] == '<') {
				cnt++;
				l[i + 1] = cnt;
			} else {
				cnt = 0;
			}
		}
		
		cnt = 0;
		for(int i = n - 2; i >= 0; i--) {
			if(c[i] == '>') {
				cnt++;
				r[i] = cnt;
			} else {
				cnt = 0;
			}
		}
		
		for(int i = 0; i < n; i++) {
			result += Math.max(l[i], r[i]);
		}
		
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

int main() {
  
  int N, M; cin >> N >> M; vector<int> vec(N);
  
  for (int i = 0; i < M; i++) {
    
    int a, b; cin >> a >> b;
    
    vec.at(a - 1)++; vec.at(b - 1)++;
    
  }
  
  for (int x : vec) cout << x << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>

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

    int32_t N, K;
    std::cin >> N >> K;
    std::vector<int64_t> Height(N);
    for(auto& i : Height){
        std::cin >> i;
    }
    std::sort(Height.begin(), Height.end());

    constexpr int64_t INF = 1LL << 60;
    int64_t res = INF;
    int32_t start = 0;
    int32_t end = start + K - 1;
    while(end < N){
        res = std::min(res, Height[end] - Height[start]);
        start++;
        end++;
    }

    std::cout << res;
    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int ALP_SIZE = 26;

int main()
{
    int N;
    std::string S,T;
    std::cin >> N >> S >> T;
    
    std::vector<int> s(ALP_SIZE), t(ALP_SIZE);
    for (int i = 0; i < N; i++) {
        s[S[i] - 'a'] += 1;
        t[T[i] - 'a'] += 1;
    }
    
    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end());
    
    int res = 0;
    for (int i = 0; i < ALP_SIZE; i++) {
        res += std::max(s[i] - t[i], 0);
    }
    
    std::cout << res << std::endl;
    
    return 0;
}

Measured memory_bytes: 3360
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
  ans+=a[0]-x
  a[0]=x
for i in range(n-1):
  if a[i]+a[i+1]>x:
    if a[i+1]>(x-a[i]):
      ans+=(a[i+1]-(x-a[i]))
      a[i+1]=(x-a[i])
if a[-2]+a[i-1]>x:
  if a[-1]>(x-a[-2]):
    ans+=(a[-1]-(x-a[-2]))
    a[-1]=(x-a[-2])
print(ans)
    
  

Measured memory_bytes: 19996
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
    int n=s.size();
    int i,j,cnt=0,k;
    i=0;    
   for(i=0;i<n;i++){
    if(s[i]=='0'){
         cnt++;
    }
}
    j=n-cnt;
   cout<<2*min(j,cnt)<<endl;
   

}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int l[100010];
ll t[100010] = {};
int main() {
    int n, m;
    cin >> n >> m;
    l[0] = -1;
    l[n+1] = -2;
    for (int i = 1; i <= n; i++) {
        scanf("%d", l+i);
    }
    for (int i = 1; i <= n; i++) {
        if (l[i-1] < l[i] && l[i] > l[i+1]) {
            t[i] = m-l[i];
            for (int j = i-1; j >= 1; j--) {
                if (l[j] > l[j+1]) break;
                t[j] = max(t[j], t[j+1] + m-l[j]);
            }
            for (int j = i+1; j <= n; j++) {
                if (l[j] > l[j-1]) break;
                t[j] = max(t[j], t[j-1] + m-l[j]);
            }
        }
    }
    ll r = 0;
    for (int i = 1; i <= n; i++) {
        r = max(r, t[i]);
    }
    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 2384
N,M,Q = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]
pq = [list(map(int,input().split())) for _ in range(Q)]


L = [[0] * N for _ in range(N)]
for l,r in LR:
    L[l-1][r-1] += 1
for i in range(1,N):
    for j in range(N - i):
        L[j][j+i] += L[j][j+i-1] + L[j+1][i+j] - L[j+1][j+i-1]
for p,q in pq:
    print(L[p-1][q-1])

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() > k) {
    for (int i; i < k; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  } else {
    cout << s << endl;
  }
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToList();
        for (int i = 0; i < vals.Count; i++)
        {
            if (vals.Where(x => x == vals[i]).Count() == 2)
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


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

typedef long long lint;
typedef pair<int,int> pii;
typedef long double louble;

#define so(x) ((int)((x).size()))
#define fi first
#define se second

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n,lim,val[_];
pii bas[_];

inline lint finder(vector<pii> &v)
{
	lint ans=0,sum=0;
	for(int i=0,j=lim-1;j<so(v);i++,j++)sum+=v[i].fi,ans+=sum*v[j].se;
	return ans;
}

vector<pair<pii,pii>> f,g;
// <interval_L, interval_R>, <cntBeingL, cntBeingR>

int main()
{
	n=ty(),lim=ty();
	for(int i=1;i<=n;i++)val[i]=ty(),bas[i]=pii(val[i],i);

	sort(bas+1,bas+n+1);

	lint ans=n;
	int now=0,pos=1;
	
	while("pick the smallest values first")
	{
		if(f.empty()){if(pos>n)break;else now=bas[pos].fi;}
		else now++;

		while(pos<=n && bas[pos].fi==now)
			f.emplace_back(pii(bas[pos].se,bas[pos].se),pii(1,1)),pos++;
		sort(f.begin(),f.end());
		g.clear();
		
		for(int l=0,r=0;l<so(f);l=r+1)
		{
			r=l;
			while(r+1<so(f) && f[r].fi.se+1==f[r+1].fi.fi)r++;
			int len=r-l+1,llen=len/lim;
			if(llen<=0)continue;

			vector<pii> temp(len),temp1(llen),temp2(llen,pii(0,0));
			for(int i=0;i<llen;i++)
				temp1[i]=pii(f[l].fi.fi+i*lim,(i==llen-1)?f[r].fi.se:(f[l].fi.fi+i*lim+lim-1));
			for(int i=l,ll=1,rr=len;i<=r;i++,ll++,rr--)
			{
				temp[i-l]=f[i].se;
				if(ll>=lim)temp2[ll/lim-1].se+=f[i].se.se;
				if(rr>=lim)temp2[llen-rr/lim].fi+=f[i].se.fi;
			}
			ans+=finder(temp)-finder(temp2);
			for(int i=0;i<llen;i++)g.emplace_back(temp1[i],temp2[i]);
		}

		f.swap(g);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 10852
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
bool test(const vector<Int> &A, int prime)
{
    vector<Int> B = A;
    for (int i = B.size()-1; i >= 0; i--) {
        if (i >= prime) B[i - prime + 1] += B[i];
        else if (B[i] % prime != 0) return false;
    }
    return true;
}
void factors(Int x, set<int>& S)
{
    if (x < 0) x *= -1;
    if (x == 0) return;
    for (Int i = 2; i*i <= x; i++) {
        if (x % i == 0) S.insert(i);
        while (x % i == 0) x /= i;
    }
    if (x != 1) S.insert(x);
}
vector<int> sieve(int x) // { p | p is prime, p <= x }
{
    vector<bool> B(max(2, x+1));
    B[0] = B[1] = true;
    for (int i = 2; i*i <= x; i++) {
        if (B[i]) continue;
        for (int j = i + i; j <= x; j += i) {
            B[j] = true;
        }
    }
    vector<int> ans;
    for (int i = 0; i <= x; i++) if (!B[i]) ans.push_back(i);
    return ans;
}
int main()
{
    int N; cin >> N;
    vector<Int> A(N+1); for (int i = N; i >= 0; i--) cin >> A[i];
    auto primes = sieve(N);
    set<int> S(begin(primes), end(primes));
    for (auto a : A) factors(a, S);
    for (auto p : S) if (test(A, p)) cout << p << '\n';
    return 0;
}


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

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

  sort(a,a+N);

  cout << a[N/2]-a[N/2-1] << endl; 

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    string s;
    long long k;
    cin >> s >> k;
    vector <int> cnt(s.size(), 1);
    int cntOne = 0;
    for (int i = 0; i < s.size() && s[i] == '1'; i++, cntOne++);
    if (cntOne >= k) cout << 1 << endl;
    else             cout << s[cntOne] << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

List = [list(map(int, input().split())) for i in range(n)]
sum = 0

for i in range(1,m+1):
    cnt = 0
    for j in range(n):
        if i in List[j][1:]:
            cnt += 1
            if cnt == n:
                sum += 1

print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if ((k + 1) / 2 > x) ans += x * 2;
		else ans += (k - x) * 2;
	}
	cout << ans << endl;
    return 0;
}

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

vector<pair<int, int> > v;
int arr[101][101];
int brr[101];
int crr[101];

int main(){
while(1){//start

	//init
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 101; j++){
			arr[i][j] = 0;
			brr[i] = 0;
			crr[i] = 0;
		}
	}
	v.clear();


	int n;
	cin >> n;
	if(n == 0) break;
	for(int i = 1; i <= n; i++){
		int m;
		cin >> m;
		for(int j = 0; j < m; j++){
			int temp;
			cin >> temp;
			arr[i][temp] = 1;
		}
	}

	int k;
	cin >> k;
	for(int i = 0; i < k; i++){
		int temp;
		cin >> temp;
		brr[temp] = 1;
		crr[temp] = 1;
	}


	for(int i = 1; i <= n; i++){
		int point = 0;
		for(int j = 1; j <= 100; j++){
			if(arr[i][j] and brr[j]){
				point++;
				crr[j] = 0;
			}
		}
		v.push_back(make_pair(point, i));
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	bool flag = false;
	for(int i = 0; i < 101; i++){
		if(crr[i]) flag = true;
	}

	if(flag) cout << -1 << endl;
	else if(v[0].first == v[1].first) cout << -1 << endl;
	else cout << v[0].second << endl;
}//end


	return 0;
}



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

int main() {
    ll n, k, x;
    vector<ll> nums;
    cin >> n >> k;
    for (ll i=0; i<n; i++) {
        cin >> x;
        nums.push_back(x);
    }
    for (ll i=k; i<n; i++) {
        if (nums[i]>nums[i-k]) cout << "Yes";
        else cout << "No";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5364
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  vector<int> b(n);
  REP(i,n) cin >> b[i];
  
  vector<int> c(n-1);
  REP(i,n-1) cin >> c[i];
  
  int ans = accumulate(b.begin(),b.end(),0LL);

  REP(i,n-1){
    if(a[i]+1==a[i+1]) ans += c[a[i]-1];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
D=int(input())
c=list(map(int,input().split()))
s=[]
t=[]
for i in range(D):
  s.append(list(map(int,input().split())))
l=[0]*26

max=0
target=0
deg=0
#初期t生成
for d in range(D):
  degsum=0
  max=0
  for i in range(26):
    degsum+=c[i]*(d-l[i])
  for i in range(26):
    w=degsum-c[i]*(d-l[i])-s[d][i]
    if max < -w:
      max=-w
      target=i
  t.append(target+1)
  l[target]=d

for i in range(D):
  print(t[i])


Measured memory_bytes: 9260
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

const int mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    if(k!=0&&k<=n) rep(i, k) h[n-i-1] = 0;
    if(k>n) rep(i, n) h[i] = 0;
    ll ans = 0;
    rep(i, n) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include <functional>
#include<algorithm>
#include <iterator>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=1e9;

int main()
{
	int N,res=1;
	cin>>N;
	vector<int>A,B(N+1,INF);
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		A.push_back(-a);
	}
	for(int i=0;i<N;i++)
	{
		*lower_bound(B.begin(),B.end(),A[i]+1)=A[i];
	}

	cout<<(lower_bound(B.begin(),B.end(),INF)-B.begin())<<endl;
}

Measured memory_bytes: 1276
import java.util.PriorityQueue;
import java.util.Scanner;

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		}
		
		
		int[] p = new int[N];
		
		int j = 0;
		while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		}
		
		int total = 0;

		
		for(int i=0; i<K; i++){
			total += p[i];
		}
		
		System.out.println(total);

	}
}



Measured memory_bytes: 38664
// Problem : C - Count Order
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main () {
	int n;
	scanf ("%d",&n); vector<int> a(n), b(n);
	for (auto &au : a) scanf ("%d",&au);
	for (auto &au : b) scanf ("%d",&au);
	vector<int> cur;
	for (int i = 1; i <= n; i++) cur.push_back(i);
	int which = 0; int aa = -1, bb = -1;
	do {
		++which;
		for (int i = 0; i < n; i++) if (cur[i] != a[i]) goto fail;
		aa = which; break;
		fail:;
	} while (next_permutation(all(cur)));
	for (int i = 1; i <= n; i++) cur[i-1] = (i);
	which = 0;
	do {
		++which;
		for (int i = 0; i < n; i++) if (cur[i] != b[i]) goto fair;
		bb = which; break;
		fair:;
	} while (next_permutation(all(cur)));
	printf ("%d\n",abs(aa-bb));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
#define INF bit(60)
#define pb push_back
#define mod 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
using namespace std;
using uif=uint_fast64_t;
using ll=long long int;
 
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
 
#define FACSIZE 2002
 
ll invfac[FACSIZE];
ll fac[FACSIZE];
 
ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );
 
 
 
int main(void){
 
  string s,t;
  cin>>s>>t;
 
  map<char, vector<ll> > m;
 
  for(ll i=0;i<s.size();i++){
    char c=s[i];
    m[c].push_back(i+1);
  }
 
  ll ans=0;
 
  ll prev=0;
 
  for(auto c:t){
    if( m.find(c) == end(m) ){
      cout << -1 << endl;
      return 0;
    }
    else{
 
      auto itr=upper_bound( begin(m[c]),end(m[c]),prev );
      //cout << *itr << endl;
      if( itr == end( m[c] ) ){
        ans+= s.size() - prev + m[c][0];
        prev = m[c][0];
      }
      else{
        ans+= *itr - prev;
        prev = *itr;
      }
      
    }
    //cout << ans << endl;
  }
 
  //ll ans=t.size() * s.size();
 
  
 
  cout << ans << endl;
 
  return 0;
 
}
 
ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}
 
ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}
 
ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}
 
void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}
 
void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }
 
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

void solve(){
	int n;
	cin>>n;
	map<int, int>m;
	rep(i,0,n){
		int t;
		cin>>t;
		m[t]++;
	}
	int ans = 0;
	for(auto it = m.begin(); it != m.end(); it++){
		if(it->y >= it->x)
			ans += it->y-it->x;
		else
			ans += it->y;
	}
	cout<<ans<<endl;
}
	
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
  t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4736
#include<cstdio>
#include<iostream>
using namespace std;
const int maxn=500100;
int a[maxn],ps[maxn];
int top;
void readl(int &x){
	x=0;
	char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)){
		x=x*10+ch-'0';
		ch=getchar();
	}
}
long long Min(long long x,long long y){
	return x<y?x:y;
}
namespace Splay{
	int l[maxn],r[maxn],f[maxn];
	int val[maxn],sum[maxn];
	int num=0;
	int rt=0;
	void push_up(int h){
		if(h==0) return;
		sum[h]=val[h];
		if(l[h]) sum[h]=Min(sum[l[h]],sum[h]);
		if(r[h]) sum[h]=Min(sum[r[h]],sum[h]);
	}
	void rotate(int h){
		int fa=f[h],gfa=f[fa];
		if(fa==l[gfa]) l[gfa]=h;
		else if(fa==r[gfa]) r[gfa]=h;
		f[h]=gfa;
		if(h==l[fa]){
			l[fa]=r[h],f[r[h]]=fa;
			r[h]=fa,f[fa]=h;
		}
		else{
			r[fa]=l[h],f[l[h]]=fa;
			l[h]=fa,f[fa]=h;
		}
		push_up(fa);
		push_up(h);
	}
	void splay(int h){
		int fa,gfa;
		while(f[h]){
			fa=f[h];
			if(f[fa]==0){
				rotate(h);
				rt=h;
				return;
			}
			gfa=f[fa];
			if((fa==l[gfa])^(h==l[fa])){
				rotate(h);
				rotate(h);
			}
			else{
				rotate(fa);
				rotate(h);
			}
		}
		rt=h;
	}
	int newnode(int fa,int v){
		num++;
		f[num]=fa;
		sum[num]=val[num]=v;
		return num;
	}
	void insert(int v,int p){
		int h=rt;
		if(!h){
			rt=newnode(0,v);
			return;
		}
		while(h){
			if(!l[h]){
				if(!r[h]){
					if(val[h]<p)
					{
						r[h]=newnode(h,v);
						splay(h);
						return;
					}
					else
					{
						l[h]=newnode(h,v);
						splay(h);
						return;
					}
				}
				else{
					if(val[h]<p||sum[r[h]]<p)
						h=r[h];
					else
					{
						l[h]=newnode(h,v);
						splay(h);
						return;
					}
				}
				continue;
			}
			else if(!r[h]){
				if(val[h]<p)
				{
					r[h]=newnode(h,v);
					splay(h);
					return;
				}
				else
					h=l[h];
				continue;
			}
			if(sum[r[h]]<p||val[h]<p) h=r[h];
			else h=l[h];
		}
	}
	void solve(int h){
		if(l[h]) solve(l[h]);
		a[val[h]]=++top;
		if(r[h]) solve(r[h]);
	}
}
int main(){
//	freopen("permutation.in","r",stdin);
//	freopen("permutation.out","w",stdout);
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		readl(a[i]);
		ps[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		Splay::insert(ps[i],ps[i]+k);
		top=0;
	}
	top=0;
	Splay::solve(Splay::rt);
	for(int i=1;i<=n;i++)
		printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 25088
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;

int main(){
    int s, w; cin >> s >> w;
    cout << ((s <= w) ? "unsafe" : "safe") << endl;

    return 0;
}

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

int main() {
  int N, M, s;
  cin >> N >> M;

  while(N){
    s += N - 1;
    N--;
  }

  while(M){
    s += M - 1;
    M--;
  }

  cout << s << endl;
  
}


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

int main(){
    int H, W;
    cin >> H >> W;

    int h_b, w_b;
    cin >> h_b >> w_b;

    int total[H][W];

    for(int i = 0; i < H; i++){
        for(int  j= 0; j < W; j++){
            total[i][j] = 1;
        }
    }

    
    for(int i = H - h_b; i < H; i++){
        for(int  j= 0; j < W; j++){
            total[i][j] = 0;
        }
    }

    for(int i = 0; i < H; i++){
        for(int  j= 0; j < w_b; j++){
            total[i][j] = 0;
        }
    }    


    int counter = 0;
    for(int i = 0; i < H; i++){
        for(int  j= 0; j < W; j++){
            if(total[i][j] == 1){
                counter += 1;
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	an := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&an[i])
	}

	max := max(an)
	min := min(an)
	fmt.Println(max - min)
}

func max(a []int) int {
	ret := -100000000
	for _, e := range a {
		if e > ret {
			ret = e
		}
	}
	return ret
}

func min(a []int) int {
	ret := 1000000000
	for _, e := range a {
		if e < ret {
			ret = e
		}
	}
	return ret
}


Measured memory_bytes: 512
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++)
        os << v[i] << (i+1<v.size()?", ":"");
    os << "}";
    return os;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

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

int main(){
    iostream_init();
    int N, W, H;
    cin >> N >> W >> H;
    vector<pair<int, int>> xs(N);
    vector<pair<int, int>> ys(N);
    REP(i, N){
        int x, y, w;
        cin >> x >> y >> w;
        xs[i] = make_pair(2*x, 2*w);
        ys[i] = make_pair(2*y, 2*w);
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    bool ans = false;
    W *= 2;
    H *= 2;
    {
        int cur = 0;
        bool ok = true;
        REP(i, W+1) {
            while(cur < N && abs(xs[cur].first - i) > xs[cur].second) {
                cur++;
            }
            if(cur == N){
                ok = false;
                break;
            }
        }
        ans = ans || ok;
    }
    {
        int cur = 0;
        bool ok = true;
        REP(i, H+1) {
            while(cur < N && abs(ys[cur].first - i) > ys[cur].second) {
                cur++;
            }
            if(cur == N){
                ok = false;
                break;
            }
        }
        ans = ans || ok;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

/* vim:set foldmethod=marker: */

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

#include <set>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

void solve(long long N, std::vector<std::string> S) {
    set<string> s;
    rep(i, N) { s.insert(S[i]); }
    cout << s.size() << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 25132
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_I
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray();

            var dp = new double[n + 2];
            dp[1] = 1;

            for (int i = 0; i < n; i++)
                for (int j = i + 1; j >= 0; j--)
                    dp[j + 1] = dp[j] * p[i] + dp[j + 1] * (1 - p[i]);

            double ans = 0;
            for (int i = (n + 1) / 2 + 1; i <= n + 1; i++)
                ans += dp[i];

            Console.WriteLine(ans.ToString("R"));
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    int h[N];
    for(int i=0;  i<N; i++){
        cin >> h[i];
    }
    int ans=0;
    while(1){
        int st=0;
        while(1){
            if(h[st] > 0) break;
            st++;
        }
        if(st > N-1) break;
        ans++;
        for(int i=st; i<N; i++){
            if(h[i] == 0) break;
            h[i]--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	var xdist int
	var ydist int
	xdist = x2 - x1
	ydist = y2 - y1
	fmt.Printf("%d %d %d %d\n", x2-ydist, y2+xdist, x1-ydist, y1+xdist)
}


Measured memory_bytes: 512
n=int(input())
l=[int(i) for i in input().split()]
o=[[0,i] for i in range(100001)]
e=[[0,i] for i in range(100001)]
for i in range(n//2):
 o[l[i*2]][0]+=1
 e[l[i*2+1]][0]+=1
o.sort(reverse=True)
e.sort(reverse=True)
res=10000000000000000
for i in range(2):
  for j in range(2):
    if o[i][1]!=e[j][1]:
      res=min(res,n-o[i][0]-e[j][0])
print(res)

Measured memory_bytes: 73184
import sys
input = sys.stdin.readline
N = int(input())
S = list(input())[: -1]
a = ord("A")
z = ord("Z")
#print(S)

for i in range(len(S)):
  t = ord(S[i]) + N
  if t > z:
    t = t % z + a - 1
  S[i] = chr(t)
print("".join(S))

Measured memory_bytes: 39920
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

max = a[1]-a[0]
min = a[0]
for i in range(1,n):
    if max < (a[i]-min):
        max = (a[i]-min)
    if min > a[i]:
        min = a[i]
        
print(max)


Measured memory_bytes: 13372
# -*- coding: utf-8 -*-
# D-Knapsack2

# DPはnumpy使わずにpypy3で提出する(pythonより3倍くらい早い）
# Dとの違い：Wが大きく、vは小さい

'''
3 8
3 30
4 50
5 60
'''

N, W = map(int, input().split())
w, v = [None] * N, [None] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

v_max = (max(v)+1) * N
dp = [[None] * v_max for _ in range(N+1)]
dp[0] = [float('inf')] * v_max
dp[0][0] = 0

for i in range(N):
    for j in range(v_max):
        if j > v[i]:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = min(dp[i][j], w[i])

# print(dp)
print(len([i for i in dp[N] if i <= W]) - 1)


Measured memory_bytes: 268136
h,w=map(int,input().split());b=[input()for i in range(h)];a=[]
for i in b:
  if i!="."*w:a.insert(0,i)
b=[]
for i in range(w):
  s=""
  for j in a:s=j[i]+s
  if s!="."*len(a):b.insert(0,s)
c=[]
for i in range(len(a)):
  s=""
  for j in b:
    s=j[i]+s
  print(s)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main(){
	var a,b,c,d,e,k int
	fmt.Scan(&a,&b,&c,&d,&e,&k)
	if e - a <= k {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

string s;

signed main() {
  cin >> s;

  int ans = 1e18;
  rep (i, s.size()) {
    int a = stoi(s.substr(i, 3));
    if (s.substr(i, 3).size() != 3) continue;
    chmin(ans, abs(a - 753));
  }

  cout << ans << endl;

  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

map<ll, int> sisuu; // key:素数, value:素数の個数

ll rec(map<ll, int>::iterator p, ll mul) {
    if (p == sisuu.end()) {
        if (mul == 1) return 1;
        else return 0;
    }

    ll res = 0;
    for (int i = 0; i < p->second + 1; i++) { // 素数をi個使う場合
        if (mul % (i + 1) != 0) continue;
        res += rec(++p, mul / (i + 1));
        --p;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    // N!の素因数分解
    for (int i = 2; i <= N; i++) {
        auto ps = prime_factorize(i);
        for (auto it: ps) sisuu[it.first] += it.second;
    }
    cout << rec(sisuu.begin(), 75) << endl;
}


Measured memory_bytes: 256
a = $stdin.read.split("\n")
x = a[0].split(' ')[1].to_i
a = a[1].split(' ').map(&:to_i).sort!
result = 0
a.each_with_index do |aa, i|
  break if aa > x
  x -= aa
  result += 1 unless i == a.size - 1 && x > 0
end

puts result

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
char s[(int)1e5 + 5], t[(int)1e5 + 5];
vector<ll> p[300];
ll next(ll pidx, ll v) {
	if (p[v].size() == 0) return -1;
	if (p[v].back() <= pidx) return p[v][0];
	return p[v][upper_bound(p[v].begin(), p[v].end(), pidx) - p[v].begin()];
}
ll n;
ll ans;
ll calc(ll a, ll b) {
	if (a < b) return b - a;
	return n - 1 - a + b + 1;
}
int main(void) {
	scanf("%s %s", s, t);
	for (ll i = 0; s[i]; i++, n++) {
		p[s[i]].push_back(i);
	}
	ll pidx = -1;
	for (ll i = 0; t[i]; i++) {
		ll cidx = next(pidx, t[i]);
		if (cidx == -1) return !printf("-1\n");
		ans += calc(pidx, cidx);
		pidx = cidx;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, total = 0, choiceCount = 0;
	float border;
	cin >> N >> M;
	vector<int> A(N);
	for (int count = 0; count < N; count++)
	{
		cin >> A.at(count);
		total += A.at(count);
	}
	sort(A.begin(), A.end(), [](int a, int b) {
		return a > b;
	});
	border = (float) total / (float) (4 * M);
	for (int count = 0; count < N; count++)
	{
		if (A.at(count) >= border)
		{
			choiceCount++;
		}
		else
		{
			break;
		}
	}
	if (choiceCount >= M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const double eps = 1e-9;
bool equal(double a, double b) { return abs(a-b) < eps;}
 
struct V {
  double x, y;
  V(double x=0, double y=0) : x(x), y(y) {}
  V operator+(const V& p) const { return V(x+p.x, y+p.y);}
  V operator-(const V& p) const { return V(x-p.x, y-p.y);}
  V operator*(double a) const { return V(x*a, y*a);}
  double sqrNorm() const { return x*x+y*y;}
  double norm() const { return sqrt(sqrNorm());}
  V rotate90() const { return V(y, -x);}
};
 
struct Circle {
  V o; double r;
  Circle(V o=V(), double r=0) : o(o), r(r) {}
  vector<V> xp(const Circle& c) {
    V v = c.o-o;
    double l = v.norm();
    if (equal(l, 0)) return {};
    if (equal(l+r+c.r, max({l,r,c.r})*2)) {
      return {o + v*(r/l)};
    }
    if (l+r+c.r < max({l,r,c.r})*2) return {};
    double x = -(c.r*c.r - l*l - r*r) / (2*l);
    double y = sqrt(r*r - x*x);
    V mid = o + v*(x/l);
    v = v.rotate90();
    return {mid + v*(y/l), mid - v*(y/l)};
  }
  bool isInside(const V& p) {
    return (p-o).norm() < r+eps;
  }
};
 
int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<Circle> c(n);
  rep(i,n) {
    cin >> c[i].o.x >> c[i].o.y >> c[i].r;
  }
  double l = 0, r = 400000;
  rep(ti,100) {
    double x = (l+r)/2;
    vector<V> ps;
    rep(i,n) ps.push_back(c[i].o);
    rep(i,n)rep(j,i) {
      Circle a = c[i], b = c[j];
      a.r = x/a.r;
      b.r = x/b.r;
      auto tmp = a.xp(b);
      ps.insert(ps.end(), tmp.begin(), tmp.end());
    }
    bool ok = false;
    for (V p : ps) {
      int cnt = 0;
      rep(ci,n) {
        Circle nc = c[ci];
        nc.r = x/nc.r;
        if (nc.isInside(p)) cnt++;
      }
      if (cnt >= k) ok = true;
    }
    if (ok) r = x; else l = x;
  }
  printf("%.10f\n", r);
  return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int a = tmp[0], b = tmp[1];
	if (a <= 8 && b <= 8)
	{
	    WriteLine("Yay!");
	}
	else
	{
	    WriteLine(":(");
	}
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define repeat(n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if((e - a) <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int cnt[50];
signed main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		cnt[a]++; cnt[b]++;
	}
	rep(i, n)cout << cnt[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n,k;
	cin>>n>>k;
	if(n%k == 0)cout<<0<<endl;
	else cout<<1<<endl;
	return 0;
}


Measured memory_bytes: 256
int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ll N, X;
  cin >> N >> X;
  vector<ll> xs(N);
  for (auto i = 0; i < N; i++) {
    cin >> xs[i];
    xs[i] = abs(X - xs[i]);
  }

  ll res = xs[0];
  for (auto i = 1; i < N; i++){
    res = gcd_euclid(res, xs[i]);
  }

  cout << res << endl;

  return 0;
}


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

int main() {
	int x,y;
	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		if (x > y) {
			swap(x, y);
		}
		cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 3056
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
 //   freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    set<string> s;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        string op;
        cin >> op;
        s.insert(op);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 15728
n=int(input())
x=list(map(int,input().split()))
ans1=sum(x)
ans2=0
ans=10000000
for i in range(n):
  ans2+=x[i]**2
for p in range(1,max(x)+1):
  ans=min(ans,n*p*p+ans2-2*p*ans1)
print(ans)

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

int main()
{
    int N, H, W;
    cin >> N >> H >> W;

    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] >= H && B[i] >= W)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	bool b = true;
	rep(i,n){
		if(s[i]!=s[n-1-i])
			b = false;
	}
	// cout << b << endl;
	rep(i, (n - 1) / 2)
	{
		if (s[i] != s[(n - 1) / 2 - 1 - i])
			b = false;
	}
	// cout << b << endl;
	for (int i = (n + 3) / 2-1; i<n;i++)
	{
		if (s[i] != s[n - 1 - i])
			b = false;
	}
	cout << (b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256