akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] l = in.nextIntArray(n * 2);
            Arrays.sort(l);
            int ans = 0;
            for (int i = 0; i < 2 * n; i += 2) {
                ans += l[i];
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}



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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int n;
	cin >> n;
	P(800*n - 200*(n/15));
}

int main() {
    solve();
    return 0;
}


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


void solve(long long a, long long b){
    if ((a + b) % 2) cout << (a + b) / 2 + 1 << '\n';
    else cout << (a + b) / 2 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    long long int n, m, x, ans = 1000000000000;
    scanf("%lld %lld %lld", &n, &m, &x);

    long long int book[n + 1][m + 1], C[n + 1];
    long long int money, i, j, k, l, skill[m + 1];
    int ok;

    for (l = 0; l < m; l++)
    {

        skill[l] = 0;
    }

    for (i = 0; i < n; i++)
    {

        scanf("%lld", &C[i]);

        for (j = 0; j < m; j++)
        {
            scanf("%lld", &book[i][j]);
        }
    }

    k = pow(2, n);
    for (i = 0; i < k; i++)
    {
        ok = 1;

        for (j = 0; j < n; j++)
        {
            if (i >> j & 1)
            {
                money += C[j];

                for (l = 0; l < m; l++)
                {

                    skill[l] += book[j][l];
                }
            }
        }
        // printf("%lld\n", skill[0]);

        for (l = 0; l < m; l++)
        {
            if (skill[l] < x)
            {
                ok = 0;
                break;
            }
        }

        if (ok == 1)
        {
            if (ans > money)
            {
                ans = money;
            }
        }

        money = 0;
        for (l = 0; l < m; l++)
        {

            skill[l] = 0;
        }
    }
    if (ans == 1000000000000)
    {
        printf("-1");
    }
    else
    {
        printf("%lld", ans);
    }

    return (0);
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 111111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

vector <pair < int , int  > > g[MAXN] ;
ll dist[MAXN] ;
bool ok = true , visited[MAXN] ;

void dfs(int u) {
    visited[u] = 1 ;
    for(int  i = 0 ;i<g[u].size() ;i++) {
        int v =g[u][i].first ;
        int w = g[u][i].second ;

        if(!visited[v]) {
            dist[v] = dist[u] + (ll)w ;
            dfs(v) ;
        }
        else if(dist[v] != dist[u] + (ll)w) {
            ok = false ;
            return ;
        }
    }
}

int main(){
    int n , m , x ,y ,w ;
    scanf("%d %d" , &n ,&m) ;

    for(int i =1 ;i<=m ;i++) {
        scanf("%d %d %d" ,&x ,&y ,&w) ;
        g[x].pb(mp(y, w)) ;
        g[y].pb(mp(x ,-w)) ;
    }
    
    for(int i = 1 ;i<=n && ok ;i++)if(!visited[i]) dfs(i) ;

    if(ok) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}

Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <string> VS;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PIL> VPIL;


#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sort(c) sort((c).begin(),(c).end())

#define range(i,a,b) for(int i=(a); i < (b); i++)
#define rep(i,n) range(i,0,n)

#define MAX_INT 2147483647

int main(){
	int n, p, cup, tmp;
	VI have;
	while(1){
		cin >> n >> p;
		if (! (n and p)) break;
		tmp = 0;
		cup = p;
		have = VI(n,0);
		while(1){
			if (cup == 0){cup += have[tmp]; have[tmp] = 0;}
			else if (cup == 1 and have[tmp] == p-1) break;
			else { have[tmp] += 1; cup--;}

			if (tmp == n-1) tmp = 0;
			else tmp++;
		}
		cout << tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
int N[300005];
int sum[300005];
int main()
{
	int n;
	cin>>n;
	char temp1;
	//int sum=0;
	sum[0]=0;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='E') N[i+1]=1;
		if(s[i]=='W') N[i+1]=0;
		sum[i+1]=sum[i]+N[i+1];
	}
	int min=300005;
	//cout<<N[6]<<endl;
	for(int i=1;i<=n;i++)
	{
	   int temp=0;
	   temp+=(sum[n]-sum[i]);
	   temp+=(i-1-sum[i-1]);
	   //cout<<temp<<endl;
	   if(temp<min) min=temp;
	}
	//for(int i=0;i<=8;i++) cout<<i<<":"<<sum[i]<<endl;
	//cout<<sum[8]<<endl;
	//cout<<sum[n]-sum[1]<<endl;
	//cout<<1-1-sum[1-1]<<endl;
	cout<<min<<endl;
	return 0;
 } 

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int A, B;
  cin >> A;
  cin >> B;
  if (A == 1 && B == 2) {
    printf("3\n");
  }
  else if (A == 2 && B == 1) {
    printf("3\n");
  }
  else if (A == 1 && B == 3) {
    printf("2\n");
  }
  else if (A == 3 && B == 1) {
    printf("2\n");
  }
  else if (A == 2 && B == 3) {
    printf("1\n");
  }
  else if (A == 3 && B == 2) {
    printf("1\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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; }


const long long INF = 1LL << 60;
vector<ll> a(100010), dp(100010);

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  for(int i = 0; i < N; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  P A = {0, 0}, B = {0, H}, C = {W, 0};
  for(int i = 0; i < N; i++){
    if(a.at(i) == 1) chmax(A.first, x.at(i));
    else if(a.at(i) == 2) chmin(C.first, x.at(i));
    else if(a.at(i) == 3) chmax(A.second, y.at(i));
    else chmin(B.second,  y.at(i));
  }
  int result = max(0, (C.first - A.first)) * max(0, (B.second - A.second));
  cout<< result << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
} 

Measured memory_bytes: 3628
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 10:36:40
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 100000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

map<int, int> pr;
vector<int> qr;

void find_prime()
{
    pr[2]++;

    for (int i = 3; i < INF; i += 2) {
        int sq = sqrt(i);
        int ok = 1;
        for (int j = 3; j <= sq; j++) {
            if (i % j == 0) ok = 0;
        }

        if (ok) pr[i]++;
    }
}

void find_qrime()
{
    for (const auto &x : pr) {
        int y = (x.first + 1)/2;
        if (pr[y] > 0) qr.push_back(x.first);
    }
}

int main()
{
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
        cin >> l[i] >> r[i];

    find_prime();
    find_qrime();

    int n = qr.size();
    for (int i = 0; i < q; i++) {
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (qr[j] >= l[i] && qr[j] <= r[i]) {
                cnt++;
            }
        }

        cout << cnt << endl;
    }    

    return 0;
}


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

int a[100002];

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

    for(int i=1; i <= n; i++) cin >> a[i];

    int cnt = 0;
    for(int i=1; i <= n; i++){
        if(a[i] == i){
            int tmp = a[i+1];
            a[i+1] = a[i];
            a[i] = tmp;
            cnt += 1;
        }
    }

    //dubug
    /*
    for(int i=1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    */

    cout << cnt << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;
#define N 100000

int main(){

  int n;
  cin >> n;

  vector<int> cnt(N+1, 0);

  for(int i = 1; i <= N; ++i){
    for(int j = 1; i * j <= N; ++j){
      cnt[i*j]++;
    }
  }

  for(int i = 1; i < N; ++i){
    if(cnt[i] == n){
      cout << i << endl;
      break;
    }
  }

	return 0;
}



Measured memory_bytes: 3104
def f(a, b, c)
  return -1 if [a,b,c].all?(&:even?) && a == b && b == c
  cnt = 0
  while [a,b,c].all?(&:even?)
    a, b, c = b/2+c/2, a/2+c/2, a/2+b/2
    cnt += 1
  end
  cnt
end

A, B, C = gets.split.take(3).map(&:to_i)
p f(A, B, C)


Measured memory_bytes: 1788
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 200005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll l, r, d;
	cin >> l >> r >> d;
	ll ans = r / d - l / d;
	if (l % d == 0)
		++ans;
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


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


public class Main{
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        boolean b = true;
        for(int i=0;i<N;i++){
            int a = sc.nextInt();
            if(a%2==0 && (a%3!=0&&a%5!=0)) b = false;
        }
        if(b) out.println("APPROVED");
        else out.println("DENIED");


        out.flush();
    }

}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 501000;
int dp[N][3];
int n;
int solve(vector < int > a){
    int n = a.size();
    //for (auto i: a) cout << i << " ";
    //cout << endl;
    for (int i = 0; i <= n + 1; i++){
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }
    for (int i = n - 1; i >= 1; i--){
        dp[i][0] = max(a[i] - 1 + dp[i + 1][2], max(a[i - 1] + dp[i + 1][1], max(a[i] + dp[i + 2][0], dp[i + 1][0])));
        if (a[i - 1] == 1) dp[i][1] = dp[i + 1][0]; else
        dp[i][1] = max(a[i] - 1 + dp[i + 1][2], max(a[i - 1] - 1 + dp[i + 1][1], max(a[i] + dp[i + 2][0], dp[i + 1][0])));
        dp[i][2] = max(a[i] - 1 + dp[i + 1][2], max(1 + dp[i + 1][1], max(a[i] + dp[i + 2][0], dp[i + 1][0])));
    }
    return dp[1][0];
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0;
    int ans = 0;
    while (i < n){
        vector < int > v;
        while(i < n && s[i] == '0') i++;
        while(i < n){
            int x = 0;
            while(i < n && s[i] == '1'){
                i++;
                x++;
            }
            v.pb(x);
            if (i >= n - 1 || s[i + 1] != '1'){
                ans += solve(v);
                break;
            }
            i++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1172
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 1e5 + 5;
const int MAXD = 1e4 + 5;
const int MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}

ll mp[MAXN];
int main(){

        ios::sync_with_stdio(0);
        cin.tie(0);

        int n;
        cin >> n;
        ll sum = 0;
        for(int i = 0 ; i < n ; i++)
            {
                int x;
                cin >> x;
                mp[x]++;
                sum+=x;
            }
        int q;
        cin >> q;
        while(q--)
        {

         int b,c;
         cin >> b >> c;
         sum-=(mp[b]*b);
         sum+=(mp[b]*c);
         mp[c]+=mp[b];
         mp[b]=0;
         cout << sum << '\n';

        }





        
       
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    int mx = 0;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        mp[a]++;
        mx = max(mx, a);
    }
    int N = mx;
    vector<int> dp(N + 1, true);
    for (auto x:mp) {
        int i = x.first;
        if (dp[i] && i + i <= N) {
            for (int j = i + i; j <= N; j += i)
                dp[j] = false;
        }
        if (x.second != 1)
            dp[i] = false;
    }
    int res = 0;
    rep (x, 1, N + 1)
        if (mp[x] >= 1 && dp[x] == true)
            res++;
    cout << res;
    return 0;
}

// int n;
// vector<char> is_prime(n+1, true);
// is_prime[0] = is_prime[1] = false;
// for (int i = 2; i <= n; i++) {
//     if (is_prime[i] && (long long)i * i <= n) {
//         for (int j = i * i; j <= n; j += i)
//             is_prime[j] = false;
//     }
// }

Measured memory_bytes: 53940
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;

	int left = 0, right = MOD, mid;
	while(right-left > 1){
		mid = (left+right)/2;
		if((mid+1)*mid/2 >= N) right = mid;
		else left = mid;
	}
	vector<int> vec = {right};
	N -= right;
	while(N){
		--right;
		if(N >= right){
			vec.push_back(right);
			N -= right;
		}
	}
	reverse(vec.begin(), vec.end());
	for(auto e : vec){
		cout << e << endl;
	}
}

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

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

    int w_cnt = 0;
    int r_cnt = 0;
    vector<char> s(n);
    for(int i=0; i<n; i++){
        cin>>s[i];

        if(s[i] == 'W'){
            w_cnt++;
        }else{
            r_cnt++;
        }
    }
    //cout<<w_cnt<<" "<<r_cnt<<endl;

    int ans = 0;
    for(int i=0; i<r_cnt; i++){
        if(s[i] == 'W'){
            ans++;
        }
    }

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

Measured memory_bytes: 3612
n = int(input())

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

ret = 0
for ni in range(1, n+1):
    if ni % 2 == 0 :continue
    divisors = make_divisors(ni)
    if len(divisors) == 8:
        ret += 1

print(ret)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  string W[N];
  rep(i,N) cin>>W[i];
  set<string> S;
  rep(i,N) S.insert(W[i]);
  int ans=1;
  rep(i,N-1) if(W[i][W[i].size()-1]!=W[i+1][0]) ans=0;
  if(ans&&S.size()==N) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
num = gets.chomp
array = [num[0], "op1", num[1], "op2", num[2], "op3", num[3]]
mark = ["op", "op", "op"]
(2 ** 3).times do |i|
  bit = i
  new_mark = []
  mark.each_with_index do |m, j|
    if bit[j] == 1
      m = "+"
    else
      m = "-"
    end
    new_mark << m
  end
  array[1], array[3], array[5] = new_mark[0], new_mark[1], new_mark[2]
  if eval(array.join) == 7
    puts array.join + "=7"
    exit
  end
end

Measured memory_bytes: 1788
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S,T;
 
LL ans = INF;

void solve(){
	for(int i=0;i<S.size()-T.size()+1;i++){
		LL num = 0;
		for(int j=0;j<T.size();j++){
			if(S[i+j]!=T[j]) num++;
		}
		ans = min(ans,num);
	}
}
 
int main(){
    cin >> S >> T;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3144
<?php
//gcd(x, y)
fscanf(STDIN, "%d %d", $x, $y);
if($x < $y){
    list($x, $y) = array($y, $x);
}

while($y > 0){
    $r = $x % $y;
    $x = $y;
    $y = $r;
}
echo $x.PHP_EOL;

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

#define ll long long
#define endl "\n"

int main(){
  int n,f=0;
  cin >> n;
  int a[n], ans=1;
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      if(a[j]<=a[i])
        f=1;
      else{ 
        f=0;
        break;
      }  
    }
    if(f)
      ans++;
  }
  cout << ans << endl;
  return 0;  
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	long long total=0;
	for (int i=0;i<=s1.size()-1;i++)
	{
		if (s1[i]==s2[i])  total++;
	}
	cout<<total<<endl;
	return 0;
} 

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  string s = cin.next!string;
  if (s[2] == s[3] && s[4] == s[5]) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a, b;
    cin>>a>>b;
    int cost;
    if(a>=13) cost = b;
    else if(a>=6&&a<=12) cost = b/2;
    else cost = 0;
    cout<<cost;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

public class Star
{
    public long sx { get; set; }
    public long sy { get; set; }
}
public class hello
{
    public static void Main()
    {
        while (true)
        {
            var conste = new List<Star>();
            var photo = new List<Star>();
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] s = Console.ReadLine().Trim().Split(' ');
            var cx1 = int.Parse(s[0]);
            var cy1 = int.Parse(s[1]);
            for (int i = 1; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                conste.Add(new Star { sx = int.Parse(line[0]), sy = int.Parse(line[1]) });
            }
            var m = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < m; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                photo.Add(new Star { sx = int.Parse(line[0]), sy = int.Parse(line[1]) });
            }
            for (int i = 0; i < m; i++)
            {
                var dx = photo[i].sx - cx1;
                var dy = photo[i].sy - cy1;
                if (CheckPhoto(conste, photo, dx, dy))
                {
                    Console.WriteLine("{0} {1}", dx, dy);
                    break;
                }
            }
        }
    }
    public static bool  CheckPhoto (List<Star> c , List<Star>  p ,long dx  ,long dy)
    {
        var findcount = 0;
        foreach (var x in c)
        {
            var find = 0;
            for (int i = 0; i < p.Count() ; i++)
                if (x.sx + dx == p[i].sx && x.sy + dy == p[i].sy) { find = 1;findcount++; break; }
            if (find == 0)   return false; 
        }
        return true;
    }
}

Measured memory_bytes: 9616
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
arr=[[0]*m for i in range(n)]
for i in range(n):
    for j in range(m):
        if S[i] == T[j]:
            arr[i][j] = 1
acum = [[0]*m for i in range(n)]
acum[0][0] = arr[0][0]
# for i in range(1,n):
#     acum[i][0] = acum[i-1][0] + arr[i][0]
# for j in range(1,m):
#     acum[0][j] = acum[0][j-1] + arr[0][j]
for i in range(n):
    for j in range(m):
        arr[i][j] += ((acum[i-1][j-1])*(arr[i][j]) if i-1 >= 0 and j-1 >= 0 else 0)
        acum[i][j] = (acum[i-1][j] if i-1>=0 else 0) + (acum[i][j-1] if j-1>=0 else 0) - (acum[i-1][j-1]if i-1>=0 and j-1 >=0 else 0) + arr[i][j]
        arr[i][j] %= mod; acum[i][j] %= mod
print(1+sum(map(sum,arr))%mod)
# print(*arr,sep="\n");print()
# print(*acum,sep="\n")




Measured memory_bytes: 106716
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  int K, S;
  cin >> K >> S;
  int ret = 0;
  REP(x, K+1) {
    REP(y, K+1) {
      if(x + y <= S && x + y + K >= S) {
        ret++;
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

if N%2 == 0:
    l = N//2
    B1 = A[:l]
    B2 = A[l:]
    ans = 0
    for i in range(l):
        ans += (B2[i] - B1[i])*2
    ans -= B2[0] - B1[-1]
    print(ans)
else:
    l = N//2
    B1 = A[:l]
    B2 = A[l:]
    a1 = 0
    for i in range(l):
        a1 -= B1[i]*2
    for i in range(l+1):
        if i == 0 or i == 1:
            a1 += B2[i]
        else:
            a1 += B2[i]*2
    
    C1 = A[:l+1]
    C2 = A[l+1:]
    a2 = 0

    for i in range(l):
        a2 += C2[i]*2
    for i in range(l+1):
        if i == l-1 or i == l:
            a2 -= C1[i]
        else:
            a2 -= C1[i]*2
    print(max(a1, a2)) 

Measured memory_bytes: 8556
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

vector<ll> a,erased;
stack<ll> st;
ll N;
bool f(){
	if(N==st.size()){
		return true;
	}
	ll c=N-st.size()+1;
	rep(i,N){
		ll j=N-i-1;
		if(erased[j])continue;
		c--;
		if(a[j]==c){
			st.push(a[j]);
			erased[j]=true;
			if(f()){
				return true;
			}else{
				return false;
			}
		}
	}

	return false;
}

signed main() {
	cin>>N;
	a.assign(N,0);
	erased.assign(N,false);
	rep(i,N)cin>>a[i];

	if(f()){
		while(!st.empty()){
			p(st.top());
			st.pop();
		}
	}else{
		p(-1);
	}

	return 0;
}



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

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll s = a*x + b*y;
    ll t = 2*c*min(x,y) + a*(x-min(x,y)) + b*(y-min(x,y));
    ll u = 2*max(x,y)*c;
    cout << min(s,min(t,u)) << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[53][2], a[53];
int main()
{
    int n, p;
    scanf("%d%d",&n,&p);
    for(int i=1; i<=n; ++i) scanf("%lld",&a[i]);
    dp[1][a[1]&1] = 1;
    for(int i=2; i<=n; ++i)
    {
        if(a[i]&1)
        {
            dp[i][1] = dp[i-1][1] + dp[i-1][0] + 1;
            dp[i][0] = dp[i-1][1] + dp[i-1][0];
        }
        else
        {
            dp[i][1] = dp[i-1][1] + dp[i-1][1];
            dp[i][0] = dp[i-1][0] + dp[i-1][0] + 1;
        }
    }
    printf("%lld\n",dp[n][p]+((p%2==0)?1:0));
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		Arrays.sort(a);
		var result = BigDecimal.valueOf(1);
		for (int i = 0; i < n; i++) {
			result = result.multiply(BigDecimal.valueOf(a[i]));
			if (result.compareTo(BigDecimal.valueOf(Math.pow(10, 18))) > 0) {
				result = BigDecimal.valueOf(-1);
				break;
			}
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 62452
n = int(input())
a_list = list(map(int, input().split()))

MOD = (10**9)+7
a_sum = 0
ans = 0
for i in range(n-1):
    a_sum += a_list[n-i-1]
    ans += a_sum * a_list[n-i-2]
    ans = ans % MOD

print(ans)


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

int main() {
    int N; cin >> N;
    vector<int> data(N);
    for(int i = 0; i < N-1; i++){
        int tmp; cin >> tmp;
        data[tmp-1] ++;
    }
    for(int i = 0; i < N; i++){
        if(i == N-1) cout << data[i];
        else cout << data[i] << endl;
    }
}

Measured memory_bytes: 3972
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long task[][] = new long[num][2];
		for(int i = 0; i < num; i ++) {
			task[i][0] = sc.nextLong();
			task[i][1] = sc.nextLong();
		}
		Arrays.sort(task, (a, b) -> Long.compare(a[1], b[1]));
		long crt = 0;
		for(int i = 0; i < num; i ++) {
			crt += task[i][0];
			if(crt > task[i][1]) {
				System.out.println("No"); return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 111128
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = input()
n = int(N)
ans = 0
for i in range(3,10):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,m,n) for(ll i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
#define pie 3.141592653589793
#define INF 1000000007
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
pair<int, int>a[100010];
signed main() {
	int n, m,ans=0;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
		sort(a, a + n);
		while (m > 0) {
			rep(i, n) {
				if (a[i].second < m) {
					m -= a[i].second;
					ans += a[i].first*a[i].second;
				}
				else {
					ans += a[i].first*m; cout << ans << endl; endre;
				}
			}
		}
}

Measured memory_bytes: 1792
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let m: usize = sc.input();
    let k: usize = sc.input();

    const MOD: usize = 998244353;
    let max_n: usize = 500_000;
    let com = Combination::new(max_n, MOD);

    let mut ans = 0usize;
    for i in 0..=k {
        ans += com.get(n - 1, i) * m % MOD
            * mod_pow(m - 1, n - i - 1, MOD) % MOD;
        ans %= MOD;
    }

    println!("{}", ans);
}
fn mod_pow(x: usize, n: usize, modulo: usize) -> usize {
    let mut n = n;
    let mut x = x;
    let mut ret = 1;
    while n > 0 {
        if n & 1 == 1 {
            ret = ret * x % modulo;
        }
        x = x * x % modulo;
        n >>= 1;
    }
    ret
}

struct Combination {
    fac: Vec<usize>,
    finv: Vec<usize>,
    modulo: usize,
}

impl Combination {
    fn new(max_n: usize, modulo: usize) -> Combination {
        let mut fac = vec![0; max_n];
        let mut finv = vec![0; max_n];
        let mut inv = vec![0; max_n];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..max_n {
            fac[i] = fac[i - 1] * i % modulo;
            inv[i] = modulo - inv[modulo % i] * (modulo / i) % modulo;
            finv[i] = finv[i - 1] * inv[i] % modulo;
        }
        Combination {
            fac: fac,
            finv: finv,
            modulo: modulo,
        }
    }

    fn get(&self, n: usize, k: usize) -> usize {
        assert!(n >= k);
        self.fac[n] * (self.finv[k] * self.finv[n - k] % self.modulo) % self.modulo
    }

    #[allow(dead_code)]
    fn h(&self, n: usize, k: usize) -> usize {
        self.get(n + k - 1, k)
    }
}


Measured memory_bytes: 13648
#include<stdio.h>
#include<iostream>
using namespace std;

int A,B,C,D;
int main(){
    cin >> A >> B >> C >> D;
    if( B < C || D < A ) cout << 0 << endl;
    else cout << min( B,D) - max( A, C) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll n,k;
  cin >> n >> k;
  vector<double> p(n);
  vector<int> sum(n,0);
  vector<double> e(n);
  rep(i,n) cin >> p[i];

  rep(i,n){
    sum[i]=p[i]*(p[i]+1)/2;
    double s=sum[i];
    e[i]=double(s/p[i]);
  }
  //rep(i,n) printf("%.9f\n",e[i] );
  double ans=-1;
  vector<double> rui(n+1,0);

  for(int i=0; i<n; i++){
    rui[i+1]=rui[i]+e[i];
  }
  //rep(i,n+1) printf("%.9f\n",rui[i]);
  for(int i=0; i+k<=n; i++){
    double tmp=rui[i+k]-rui[i];
    chmax(ans,tmp);
  }
  printf("%.9f\n",ans );
  return 0;
}


Measured memory_bytes: 5760
#include"bits/stdc++.h"
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool ok=1;
	int n=s.length();
	ok&=s[n-1]!='1';
	ok&=s[0]=='1';

	for(int i=1;i<n-1;i++)
		ok&=(s[i]==s[n-i-2]);
	if(!ok){puts("-1");return 0;}


	vector<int> pos;
	for(int i=0;i<n;i++)if(s[i]=='1')pos.push_back(i+1);

	int k=pos.size();
	
	//body
	for(int i=1;i<=k;i++)cout<<i<<" "<<i+1<<"\n";


	int cur=k+2;
	for(int i=2;i<=k;i++)
	{
		int prn=pos[i-1]-pos[i-2]-1;

		for(int j=0;j<prn;j++)
		cout<<i<<" "<<(cur++)<<"\n";
	}
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define LL long long 
using namespace std;

int main(){
  
  LL a,b,c,k,sum=0;
  cin>>a>>b>>c>>k;
  
  
  
  if(k<=a){
  	if(k==a)
    	sum=a;
    else
    	sum=k;
  }else if(k-a>=b){
    sum=a;
  		k=k-a-b;
    	if(k>0)
          sum+=k*(-1);
          
  }
  	 
  
  cout<<sum;

  return 0;
}


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

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

using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;
	vector<string> str(N);
	rep(i, N){
		cin >> str[i];
	}

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

	rep(i, N)
		cout << str[i];
	cout << endl;
	return 0;
}


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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    long long r = 0, g = 0, b = 0;
    rep(i, n)
    {
        if (s[i] == 'R')
            r++;
        else if (s[i] == 'G')
            g++;
        else
            b++;
    }
    long long ans = r * g * b;

    rep(i, n - 2)
    {
        for (int j = i + 1; 2 * j - i < n; j++)
            if (s[i] != s[j] && s[j] != s[2 * j - i] && s[i] != s[2 * j - i])
                ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int X, N;
    cin >> X >> N;
    VEC(int) P(N);
    READVEC(P);
    set<int> pset(ALL(P));

    int bestdiff = X, best = 0;
    FOR(x, 0, 102)
        if (pset.count(x) == 0 && abs(x - X) < bestdiff) {
            bestdiff = abs(x - X);
            best = x;
        }
    cout << best << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 3668