akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 5e5+17;
int a[MAXN];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif
	LL n,x,b;
	cin>>n>>x>>b;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	LL ans = 0;
	for (int i = 1; i < n; ++i)
	{
		ans += min(x*(a[i]-a[i-1]),b);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
// #define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair<int,int>
// #define pii pair< int, pi >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
using namespace std::chrono;

string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<vector<int>> vis;
int h,w,ch,cw,dh,dw;
int X[]={1,0,0,-1};
int Y[]={0,1,-1,0};
bool safe(int x,int y){
  return x>=0 && x<h && y>=0 && y<w;
}
void solve(){
	int h,w,m;
	cin>>h>>w>>m;
	vector<pii> v1(m);
	map<int,int> r,c;
	set<pii,greater<pii>> st;
	map<int,set<int>> mp2;
	rep(i,0,m){
		cin>>v1[i].f>>v1[i].s;
		r[v1[i].f]++;
		c[v1[i].s]++;
		mp2[v1[i].f].insert(v1[i].s);
	}
	int mx1=0,mx2=0;
	for(auto i:r) mx1=max(i.second,mx1);
	for(auto i:c) mx2=max(i.second,mx2);
	vector<int> r1; set<int> c1;
	for(auto i:r) if(i.s==mx1) r1.push_back(i.f);
	for(auto i:c) if(i.s==mx2) c1.insert(i.f);
	int ans=mx1+mx2-1;
	rep(i,0,r1.size()){
		int cnt=0;
		set<int> st2=mp2[r1[i]];
		for(auto j:st2) if(c1.find(j)!=c1.end()) cnt++;
		if(cnt!=c1.size()){
			cout<<ans+1<<endl;
			return;
		}
	}
	cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 91124
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()

    def bunkai(num):
        i = 2
        ret = []
        a = num
        while i*i <= num:
            c = 0
            while a%i == 0:
                a //= i
                c += 1
            if c > 0: ret.append([i, c])
            i += 1
        if a != 1: ret.append([a, 1])
        return ret

    pl = bunkai(N)
    output = 0
    for i in range(len(pl)):
        _, c = pl[i]
        j = 1
        while c >= j:
            c -= j
            j += 1
            output += 1
    print(output)

    return

if __name__ == '__main__':
    main()


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


void solve(long long N, long long M, std::vector<long long> A){
    ll cnt = accumulate(A.begin(), A.end(), 0LL);
    if(N < cnt){
        cout<<-1<<endl;
    }else{
        cout<<N - cnt<<endl;
    }
}

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


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

int main()
{
    string s;

    while (true)
    {
        cin >> s;
        if (s == "-")
        {
            break;
        }
        int n = s.length();
        int m;
        cin >> m;
        int sum = 0;
        while (m--)
        {
            int h;
            cin >> h;
            sum += h;
        }

        for (int i = 0; i < n; i++)
        {
            cout << s[(i+sum) % n];
        }
        cout << endl;
    }

    return 0;
}



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

int top = 0, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main(void) {
	int a,b;
	char s[100];

	while(scanf("%s",s) != EOF) {
		if(s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if(s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if(s[0] == '*') {
			b = pop();
			a = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

Measured memory_bytes: 2664
#include <iostream>
#include <algorithm>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int N;
int A[105];

int main(void) {
    scanf("%d", &N);

    REP(i, 0, N) scanf("%d", &A[i]);

    sort(A, A+N);
    
    printf("%d\n", A[N-1] - A[0]);

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
r = n.times.map { gets.to_i }

maxv = r[1] - r[0]
minv = r[0]

for i in 1..n-1
  maxv = maxv > r[i] - minv ? maxv : r[i] - minv
  minv = minv < r[i] ? minv : r[i]
end

p maxv

Measured memory_bytes: 7800
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll a, b;
        cin >> a >> b;
        if(a < b){
            swap(a, b);
        }
        if((a + b) % 2 == 0){
            cout << (a + b) / 2;
        }
        else{
            cout << "IMPOSSIBLE";
        }
    }
    return 0;
}

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

int main (void){
	char u[5];
	double x,n;
	int i;
	double ans=0;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> x >> u;
		if(u[0]=='J') ans+=x;
		else ans+=x*380000.0;
	}
	cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

random_device rd;
mt19937 rng(rd());

template<class T>
T randomize(T mod)
{
	return uniform_int_distribution<T>(0, mod - 1)(rng);
}

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int MAXN = 200013;

int N;
int A[MAXN], B[MAXN];
ll ans;
priority_queue<pii> pq;

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    FOR(i, 0, N)
    {
        cin >> A[i];
    }
    FOR(i, 0, N)
    {
        cin >> B[i];
        if (B[i] < A[i])
        {
            cout << "-1\n";
            return 0;
        }
        if (B[i] != A[i])
        {
            pq.push({B[i], i});
        }
    }
    while(!pq.empty())
    {
        int d = pq.top().fi, u = pq.top().se; pq.pop();
        int sum = B[(u == 0) ? N - 1 : u - 1] + B[(u == N - 1) ? 0 : u + 1];
        // cerr << d << ' ' << A[u] << ' ' << u << ' ' << sum << endl;
        if (d % sum <= A[u] || d < sum)
        {
            if ((A[u] - d) % sum)
            {
                cout << "-1\n";
                return 0;
            }
            ans += (d - A[u]) / sum;
            B[u] = A[u];
        }
        else
        {
            ans += (d / sum);
            B[u] = d % sum;
            pq.push({B[u], u});
        }
    }
    cout << ans << '\n';
    return 0;
    //find the largest B[i]

}


Measured memory_bytes: 3828
/*
 * Given N numbers denoting the heights of consecutive bars of a histogram,
 * find the area of the largest rectangle contained within the histogram.
 *
 * N <= 1e5
 * 0 <= h_i <= 1e9
 */

#include <algorithm>
#include <iostream>
#include <iterator>
#include <stack>
#include <vector>
using namespace std;

int A[100010];
int main() {
  int n;
  cin >> n;
  copy_n(istream_iterator<int>{cin}, n, A);
  stack<int> st;
  vector<int> l(n), r(n);
  unsigned long long M = 0;
  for (int i = 0; i < n; ++i) {
    while (!st.empty() && A[st.top()] >= A[i])
      st.pop();
    l[i] = st.empty() ? -1 : st.top();
    st.push(i);
  }
  while (!st.empty())
    st.pop();
  for (int i = n - 1; i >= 0; --i) {
    while (!st.empty() && A[st.top()] >= A[i])
      st.pop();
    r[i] = st.empty() ? n : st.top();
    st.push(i);
    M = max(M, (1ull * A[i]) * (unsigned long long)(r[i] - l[i] - 1));
  }
  cout << M << endl;
}


Measured memory_bytes: 4508
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if N >= i+j and 10000*i + 5000*j + 1000*(N-(i+j)) == Y:
            print(i, j, N-(i+j))
            sys.exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int main()
{
  int n; cin >> n;
  for (int i = 1; i <= n; i++)
  {
    cin >> h[i];
  }
  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= n; i++)
  {
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 2000000000
#define INFLL 9000000000000000000
#define MOD 1000000007

typedef long long int ll;

int main() {
    string o, e;

    cin >> o >> e;

    rep(i, o.length() - 1) {
        cout << o[i] << e[i];
    }

    if (o.length() - e.length() == 1) {
        cout << o[o.length() - 1];
    } else {
        cout << o[o.length() - 1] << e[e.length() - 1];
    }

    cout << endl;

    return 0;
}


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

long long query, ans, NUM;
char c;
bool isnine = true;

long long po(int k){
    long long x = 10, ans = 1;
    while (k){
        if (k&1) ans *= x;
        x = x * x;
        k >>= 1;
    }
    return ans;
}

bool ask(long long query){
    cout << "? " << query << "\n"; cout.flush();
    cin >> c;
    return c == 'Y';
}

void answer(long long x){
    cout << "! " << x << "\n";
}

int main(){
    for (int i = 10; i >= 0; i--){
        int l = (i == 10), r = 9;
        while (l != r){
            int mid = (l + r + 1) / 2;
            if (ask(query + mid * po(i+1))) r = mid-1;
            else l = mid;
        }
        if (r != 9){
            isnine = false;
            if (ask((query + (r+1) * po(i+1)) / po(i+1))) {
                if (ask((query + r * po(i+1)) / po(i))) answer((query + r * po(i+1)) / po(i+1));
                else answer((query + (r+1) * po(i+1)) / po(i+1));
            }
            else {
                ans *= 10;
                ans += r;
                query += r * po(i+1);
            }
        }
        else{
            if (ask((query + r * po(i+1)) / po(i+1) + 1) != isnine) {
                answer((query + r * po(i+1)) / po(i+1));
            }
            else {
                ans *= 10;
                ans += r;
                query += r * po(i+1);
            }
        }
    }
    answer(ans);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N,K;
  cin>>N>>K;
  int ans=0;
  rep(i,N){
    int X;
    cin>>X;
    if(K-X>X)ans+=X*2;
    else ans+=(K-X)*2;
  }
  cout<<ans<<endl;
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int H, W, K;
    cin >> H >> W >> K;
    vector<Vi> mas(H, Vi(W));
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            mas[i][j] = s[j] - '0';
        }
    }

    ll ans = L_INF;
    Vl wsum(H);
    for (ll mask = 0; mask < (1LL << (H - 1)); mask++) {
        bool ok = true;
        ll num_b = 0;
        wsum.assign(H, 0);
        for (int w = 0; w < W; w++) {
            for (int h = 0; h < H; h++) {
                wsum[h] += mas[h][w];
            }
            ll vmx = 0;
            ll cnt = 0;
            for (int h = 0; h < H; h++) {
                if ((mask >> h) & 1) {
                    cnt += wsum[h];
                    vmx = max(vmx, cnt);
                    cnt = 0;
                }
                else {
                    cnt += wsum[h];
                }
            }
            if (cnt > 0) {
                vmx = max(vmx, cnt);
            }

            if (vmx > K) {
                ++num_b;
                wsum.assign(H, 0);
                for (int h = 0; h < H; h++) {
                    wsum[h] += mas[h][w];
                }
                vmx = 0;
                cnt = 0;
                for (int h = 0; h < H; h++) {
                    if ((mask >> h) & 1) {
                        cnt += wsum[h];
                        vmx = max(vmx, cnt);
                        cnt = 0;
                    }
                    else {
                        cnt += wsum[h];
                    }
                }
                if (cnt > 0) {
                    vmx = max(vmx, cnt);
                }
                if (vmx > K) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok) {
            ans = min(ans, num_b + __builtin_popcountll(mask));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        long[] DP = new long[W+1];
        for(int j=0;j<N;j++){
            str = Console.ReadLine().Split(' ');
            int v = int.Parse(str[0]);
            int w = int.Parse(str[1]);
            int count = int.Parse(str[2]);
            int b = 1;
            while(count > 0){
                int vb,wb;
                if(count >= b){
                    vb = v*b;
                    wb = w*b;
                    count -= b;
                    b *= 2;
                }
                else{
                    vb = v*count;
                    wb = w*count;
                    count = 0;
                }
                for(int i=W;i>=wb;i--){
                    DP[i] = Math.Max(DP[i],DP[i-wb]+vb);
                }
            }
        }
        sb.Append(DP[W]+"\n");
    }
}

Measured memory_bytes: 9260
#include<iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;

	if (a < b){
		cout << "a < b" << endl;
	}
	else if (a > b){
		cout << "a > b" << endl;
	}
	else if (a == b){
		cout << "a == b" << endl;

	}

	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

ll mod = 998244353;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(1e5, 0);
  ll initial;
  for (ll i = 0; i < n; ++i) {
    ll tmp;
    cin >> tmp;
    ++vec[tmp];
    if (i == 0)
      initial = tmp;
  }

  ll ans = int((vec[0] == 1) && (initial==0));
  for (ll i = 1; i < 1e5; ++i) {
    for (ll j = 0; j < vec[i]; ++j)
      ans = (ans * vec[i-1]) % mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
#define maxn 301
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair

int cnt[2];
void solve(){
    int n,m,k;
    int x,y,z;
    cin >> n >> m;
    while(n--){
        cin >> x;
        x &= 1;
        cnt[x] ++;
    }
    long long ans = 1;
    if(m==1 && cnt[1]==0){
        ans = 0;
    }else{
        rep(i,cnt[0]) ans *= 2;
        if(cnt[1] > 0){
            rep(i,cnt[1] - 1) ans *= 2;
        }
    }
    cout << ans;
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


/////////////////////////////////////////////////////////////////////////////////////

int main(){
    int x, n;
    cin >> x >> n;
    int ans = 1e9;
    int diff = 1e9;
    set<int> p;

    for (int i = 0;i < n;i++){
        int a;
        cin >> a;
        p.insert(a);
    }

    for (int i = -1000;i <= 1000;i++){
        if (p.count(i)) continue;
        if (diff > abs(i - x)){
            ans = i;
            diff = abs(i - x);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>

int n;
bool field[8][8];

void dfs( int x, int y )
{
	field[y][x] = false;

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

	for( int i = 1; i <= 3; ++i )
	{
		for( int j = 0; j != 4; ++j )
		{
			int nx = x + dx[j] * i, ny = y + dy[j] * i;

			if( nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && field[ny][nx] )
				dfs( nx, ny );
		}
	}

	return;
}

int main()
{
	std::cin >> n;
	for( int t = 0; t != n; ++t )
	{
		for( int i = 0; i != 8; ++i )
		{
			for( int j = 0; j != 8; ++j )
			{
				char c;
				std::cin >> c;
				field[i][j] = c - '0';
			}
		}

		int x, y;
		std::cin >> x >> y;

		--x; --y;
		dfs( x, y );

		std::cout << "Data " << t + 1 << ":" << std::endl;

		for( int i = 0; i != 8; ++i )
		{
			for( int j = 0; j != 8; ++j )
				std::cout << field[i][j];

			std::cout << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N,k,i,j,a[200002],l;
  int n[200002],idx=0,sum=0;
    map<int,int>m;
    set<int>s;
    cin>>N>>k;
    for(i=0;i<N;i++){cin>>a[i];m[a[i]]++;}
    for(i=0;i<N;i++){s.insert(a[i]);}
    set<int>::iterator it;
    for(it=s.begin();it!=s.end();it++){
       n[idx]=m[*it];idx++;
    }
    sort(n,n+idx);
    if(s.size()<=k){cout<<"0\n";}
    else{
       l=s.size()-k+1;
       for(j=0;j<l-1;j++){sum+=n[j];}
        cout<<sum<<endl;
     }
    
    

    }

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

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

  for (int i=0; i<n.size(); i++) {
    if (n[i] == '1') cout << 9;
    else cout << 1;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = sorted(list(map(int, input().split())))
dp = [0] * (ls[-1] + 1)
for i in ls:
    dp[i] += 1
    if dp[i] == 1:
        for j in range(i*2, ls[-1] + 1, i):
            dp[j] += 2

print(dp.count(1))



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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string S;
	cin >> S;
	string tmp = "hi";
	for (int i = 0; i < 10; i++){
		if (S == tmp) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			tmp += "hi";
		}
	}

	cout << "No" << endl;
	return 0;
}

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

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

Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a * a + b * b == c * c)
    {
        cout << (a * b) / 2 << endl;
    }
    else if (b * b + c * c == a * a)
    {
        cout << (b * c) / 2 << endl;
    }
    else
    {
        cout << (c * a) / 2 << endl;
    }
    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vl a(x),b(y),c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];

    vl bc;
    rep(i,y) rep(j,z) bc.push_back(b[i]+c[j]);
    sort(rall(bc));

    priority_queue<tuple<ll,ll,ll>> Q;
    rep(i,x) Q.emplace(a[i]+bc[0], i, 0);
    rep(i,k){
        auto t = Q.top(); Q.pop();
        ll ans = get<0>(t);
        ll xi = get<1>(t);
        ll bci = get<2>(t);
        if(bci < y*z-1){
            Q.emplace(a[xi]+bc[bci+1], xi, bci+1);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11672
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int Maxn=200010;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n; 
LL u11,u10,u01,u00;
void upd(LL&x,LL y){x=max(x,y);}
int main()
{
	n=read();
	u11=u10=u01=u00=-inf;
	for(int i=1;i<=n;i++)
	{
		LL x=read(),y=read();
		upd(u11,x+y);
		upd(u10,x-y);
		upd(u01,-x+y);
		upd(u00,-x-y);
	}
	LL ans=0;
	upd(ans,u11+u00);
	upd(ans,u10+u01);
	printf("%lld",ans);
}

Measured memory_bytes: 3764
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
array = []
m.times do
  b, c = gets.split.map(&:to_i)
  array << [b, c]
end

array = array.sort_by { |x| x[1] * -1 }

sum = 0
array.each do |x|
  if a.size == 0
    break
  end

  key, value = x
  key = a.size if key > a.size

  if a[key-1] <= value
    sum += key * value
    a.shift(key)
    next
  end

  nn = a.size
  nn.times do
    if a[0] >= value
      sum += a.inject(:+)

      a = []
      break
    end

    sum += value
    a.shift(1)
  end
end

if a.size > 0
  sum += a .inject(:+)
end
puts sum

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

public class Main {

	public static Map<Integer, LinkedList<Integer>> graph = new HashMap<>();
	public static long[][] arr;
	public static int n;
	public static final long mod = 1000000007;

	public static long recurse(int cur, int parent, boolean black) {
		int col = black ? 1 : 0;
		if (arr[cur][col] != -1)
			return arr[cur][col];

		LinkedList<Integer> temp = graph.get(cur);
		long sum = 1;
		if (black) {
			for (int k : temp) {
				if (k != parent) {
					sum *= recurse(k, cur, false);
					sum = sum % mod;
				}
			}

			return arr[cur][1] = sum;
		} else {
			for (int k : temp) {
				if (k != parent) {
					sum *= recurse(k, cur, false) + recurse(k, cur, true);
					sum = sum % mod;
				}
			}
			return arr[cur][0] = sum;
		}
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		if (n == 1) {
			System.out.println(2);
			return;
		}
		arr = new long[n + 1][2];
		for (int i = 0; i < n + 1; i++)
			Arrays.fill(arr[i], -1);
		String[] s;
		int a, b;
		for (int i = 0; i < n - 1; i++) {
			s = br.readLine().split(" ");
			a = Integer.parseInt(s[0]);
			b = Integer.parseInt(s[1]);
			if (!graph.containsKey(a))
				graph.put(a, new LinkedList<>());
			if (!graph.containsKey(b))
				graph.put(b, new LinkedList<>());
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		System.out.println((recurse(1, 0, true) + recurse(1, 0, false)) % mod);
	}

}


Measured memory_bytes: 103456
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

ll n, a, b, c;

int main() {

	cin >> n >> a >> b;
	c = a + b;

	if ((n % c) > a) {
		cout << ((n / c) + 1) * a << endl;
	}
	else cout << ((n / c) * a) + (n % c) << endl;




	return 0;
}



Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    string s = readln.chomp;
    string s2 = "CODEFESTIVAL2016";

    zip(s, s2).count!"a[0] != a[1]".writeln;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>

using namespace std;

/*
int N, W;
int w[100], v[100];
int dp[100][1000];

int solve(int now, int m){
	if(now == N) return 0;


}

int main(){
	cin >> N >> W;
	for(int i=0; i<N ; i++){
		cin >> w[i] >> v[i];
	}



	return 0;
}
*/

/*
vector<char> seg;
int K, n, size;



void update(int i, char x){
	i += n-1;
	seg[i] = x;

	while(i>0){
		i = (n-1)/2;
		seg[i] = min(seg[2*i+1], seg[2*i+2]);
	}
}

int smaller(int a, int now, int l, int r){
	int b = a + K;

	if(r <= a || b <= l) return 0;
	if(a <= l && r <= b){
		if(seg[a] < seg[now]){
			int tmp = now;
			while (tmp >= n - 1)
			{
				tmp = 2*now + 1;
				if(seg[tmp] == seg[now]){}
				if(seg[tmp+1] == seg[now]) tmp++;
			}

			return tmp;
		}
	}
	else{
		int a1 = smaller(a, 2*now+1, l, (l+r)/2);
		int a2 = smaller(a, 2*now+1, (l+r)/2, r);

		if(seg[a] < seg[a1]){
			if(seg[a1] < seg[a2]){
				return a2;
			}
			else{
				return a1;
			}
		}

	}
}

int main(){
	string s;
	cin >> s >> K;

	size = 1;
	while (size < s.size())
	{
		size *= 2;
	}
	size = 2*size - 1;

	n = (1+size)/2;


	for(int i=0; i<size; i++){
		seg.push_back('z');
	}

	for(int i=0; i<s.size(); i++){
		update(i, s[i]);
	}

	int now = 0;
	while (K>0)
	{
		int tmp = smaller(now, 0, 0, n);
	}



	return 0;
}
*/

/*
int N, q;
vector<int> seg;
int segSize = 2;
int n;

void add(int x, int y){

	x += n - 1;
	seg[x] += y;

	while(x > 0){
		x = (x-1)/2;
		seg[x] = seg[2*x+1] + seg[2*x+2];
	}
	
}

int sum(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0;
	if(a <= l && r <= b){
		return seg[k];
	}
	else{
		return sum(a, b, 2*k+1, l, (l+r)/2 ) + sum(a, b, 2*k+2, (l+r)/2, r);
	}
}

int main(){

	cin >> N >> q;

	

	while(segSize < N){
		segSize *= 2;
	}

	segSize *= 2;
	segSize--;

	n = (segSize+1)/2;

	for(int i=0; i<segSize; i++){
		seg.push_back(0);
	}

	for(int i=0; i<q; i++){
		int com, x, y;
		cin >> com >> x >> y;

		if(com == 0){
			add(x-1, y);
		}

		if(com == 1){
			cout << sum(x-1, y, 0, 0, n) << endl;
		}
	}


	return 0;
}
*/

/*
long long K, A, B;
long long ans = 0;
int main() {
	cin >> K >> A >> B;
 
 
	if (A + 1 < B) {
		
		if (K + 1 > A + 1) {
			ans += B;
			K -= A + 1;
 
			ans += K / (A + 2) * B;
			ans += K % (A + 2);
		}
 
		
	}
	else {
		ans = K + 1;
	}
 
	cout << ans << endl;
 
 
	return 0;
}
*/



int N, W;
long long w[100], v[100] = {};
long long dp[101][100100];

int main(){

	cin >> N >> W;
	for(int i=0; i<=N; i++){
		if(i<N)
			cin >> w[i] >> v[i];

		for(int j=0; j<=100000; j++){
			dp[i][j] = 99999999999LL;
		}
	}

	for(int i=0; i<=N; i++){
		dp[i][0] = 0;
	}

	
	for(int i=1; i<=N; i++){
		for(int j=1; j<=100000; j++){

			dp[i][j] = j-v[i-1] < 0 ? dp[i-1][j] : min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1]);

		}
	}

	int ans = 0;
	for(int i=0; i<=100000; i++){
			if(dp[N][i] <= W){
				ans = max(ans, i);
			}
	}



	cout << ans << endl;

	/*
	for(int i=1; i<=N; i++){
		for(int j=1; j<=100*N; j++){

			cout << dp[i][j] << " ";

		}
		cout << endl;
	}
	*/

	return 0;
}


Measured memory_bytes: 79232
#include<stdio.h>

int main(void)
{
   int x,a500,b500,a5,s;
   scanf("%d",&x);
   a500=x/500; //500円硬貨の枚数
   b500=x%500; //残るお金
   a5=b500/5; //5円硬貨の枚数
   s=a500*1000+a5*5;
   printf("%d",s);
   return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
	char a[1100];
	gets(a);
	int n=strlen(a);
	n--;
	if(a[n]=='3')printf("bon");
	else if(a[n]=='0'||a[n]=='1'||a[n]=='6'||a[n]=='8')printf("pon");
	else printf("hon"); 
	return 0;
}

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

int main(){
  long n,k,kekka = 0;
  cin >> n >> k;
  for(long i = 1;i <= n;i++){
    if(i > k){
      if(n+1 - i*((n+1)/i) - k >= 0){
        kekka += (i-k)*((n+1)/i) + (n+1 - i*((n+1)/i) - k);
      }
      else{
        kekka += (i-k)*((n+1)/i);
      }
    }
  }
  if(k == 0){
    kekka -= n;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

    int a[200001] = {};
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (a[x] == 0) ++cnt;
        ++a[x];
    }

    int ans = 0;
    if (cnt <= k) {
        cout << ans << endl;
    } else {
        sort(a, a + 200001, greater<int>());
        while (k != cnt) {
            ans += a[cnt - 1];
            --cnt;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> N >> M;
	UnionFind uf(N);
	vector<int>cost(N);
	for (int i = 0; i < N; i++) {
		cin >> cost[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		uf.Unite(L, R);
	}
	set<int>s;
	vector<vector<int>>c(N);
	for (int i = 0; i < N; i++) {
		int box = uf.Find(i);
		s.insert(box);
		c[box].push_back(cost[i]);
	}
	if (s.size() == 1) {
		cout << 0 << endl;
		return 0;
	}
	if ((s.size() - 1) * 2 > N) {
		cout << "Impossible\n";
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (c[i].empty()) {
			continue;
		}
		sort(c[i].begin(), c[i].end());
	}
	vector<int>box;
	for (int i = 0; i < N; i++) {
		if (c[i].empty()) {
			continue;
		}
		K += c[i][0];
		for (int j = 1; j < c[i].size(); j++) {
			box.push_back(c[i][j]);
		}
	}
	sort(box.begin(), box.end());
	for (int i = 0; i < s.size() - 2; i++) {
		K += box[i];
	}
	cout << K << endl;
	return 0;
}


Measured memory_bytes: 11648
require "set"

def divisors(num)
  (1..Math.sqrt(num).floor).map do |divisor|
    next unless num % divisor == 0

    quotient = num / divisor
    quotient == divisor ? [divisor] : [divisor, quotient]
  end.compact.flatten.sort
end

N = gets.to_i

res = 0
res += divisors(N-1).length
res -= 1

ds = divisors(N)
ds.delete(1)
ds.each do |k|
  n = N
  while n != 0 && n % k == 0
    n /= k
  end
  res += 1 if n % k == 1
end

puts res


Measured memory_bytes: 27312
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<map>
#include<bits/stdc++.h>
using namespace std;


int main()
{
#define int long long
    int N,W;
    cin>>N>>W;

    int w[N+1], v[N+1];
    for(int i=0;i<N;i++)
        cin>>w[i+1]>>v[i+1];

    int dp[N+1][W+1];
    for(int i=1;i<N+1;i++)
    {
        dp[i][0]=0;
        for(int j=1;j<W+1;j++)
        {
            int temp1;
            int temp2;
            if(i-1<=0 && j-w[i]<0)
            {
                temp1=0, temp2=0;
            }
            else if(i-1<=0)
            {
                temp1=0, temp2=v[i];
            }
            else if(j-w[i]<0)
            {
                temp1=dp[i-1][j],temp2=0;
            }
            else
            {
                        temp1=dp[i-1][j];
             temp2=dp[i-1][j-w[i]]+v[i];
            }

            dp[i][j]=max(temp1, temp2);
        }
    }
    cout<<dp[N][W];
    return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

void calc_depths(vvi &tree, int loc, int par, int dep, vi &mc) {
    int nc = 0;
    for (int nbr : tree[loc]) {
        if (nbr != par) {
            nc++;
            calc_depths(tree, nbr, loc, dep+1, mc);
        }
    }

    if (nc) {
        while (mc.size() <= dep) mc.push_back(0);
        mc[dep] = max(mc[dep], nc);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;

    vvi tree(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        tree[u-1].push_back(v-1);
        tree[v-1].push_back(u-1);
    }

    int md = INT_MAX;
    vvi depths(N);
    for (int i = 0; i < N; i++) {
        calc_depths(tree, i, i, 0, depths[i]);
        md = min(md, (int) depths[i].size());
    }

    vi centers;
    for (int i = 0; i < N; i++) {
        if (depths[i].size() == md)
            centers.push_back(i);
    }

    if (centers.size() == 2) {
        vi mc1; calc_depths(tree, centers[0], centers[1], 0, mc1);
        vi mc2; calc_depths(tree, centers[1], centers[0], 0, mc2);
        ll ans = 2;
        for (int i = 0; i < mc1.size(); i++)
            ans = ans * max(mc1[i], mc2[i]);
        cout << mc1.size() + 1 << " " << ans << endl;
        return 0;
    }

    // case that we just use the center as the root
    vi mc; calc_depths(tree, centers[0], centers[0], 0, mc);
    int col = mc.size() + 1;
    ll ans = 1; for (int v : mc) ans *= v;

    // try making a neighbor the second center
    for (int nbr : tree[centers[0]]) {
        vi mc1; calc_depths(tree, centers[0], nbr, 0, mc1);
        vi mc2; calc_depths(tree, nbr, centers[0], 0, mc2);
        while (mc1.size() < mc2.size()) mc1.push_back(0);
        while (mc2.size() < mc1.size()) mc2.push_back(0);
        ll cand = 2;
        for (int i = 0; i < mc1.size(); i++)
            cand *= max(mc1[i], mc2[i]);
        if (mc1.size() + 1 < col) {
            col = mc1.size() + 1;
            ans = cand;
        } else if (mc1.size() + 1 == col) {
            ans = min(ans, cand);
        }
    }

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



Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
const int maxn = 200010;
int main()
{
    int a, b, x;
    scanf("%d%d%d", &a, &b, &x);
    int V = a * a * b;
    int empty = V - x;
    if(empty > x){
        printf("%.10f", 90.0 - 180.0 / acos(-1.0) * atan(2.0 * x / b / b / a));
    }
    else{
        printf("%.10f", 180.0 / acos(-1.0) * atan(2.0 * empty / a / a / a));

    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MAX = 105;
int val[MAX], wt[MAX];
ll dp[MAX][100005];
int main() {
	int n,w,i,j,k;
	cin>>n>>w;
	for(i=0;i<n;++i) {
		cin>>wt[i]>>val[i];
	}
    
    for(j=wt[0];j<=w;++j)
        dp[0][j] = val[0];
	for(i=1;i<n;++i) {
		for(j=0;j<=w;++j) {
			if(wt[i] <= j) dp[i][j] = max(dp[i-1][j-wt[i]] + val[i], dp[i-1][j]);
			else dp[i][j] = dp[i-1][j];
		}
	}

	cout<<dp[n-1][w]<<endl;
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include <x86intrin.h>
int main(int argc, char *argv[])
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, max = 0;
    cin >> x;
    if (x == 1)
    {
        cout << 1;
        return 0;
    }
#pragma omp parallel for firstprivate(max)
    for (int b = 2; b <= x + 1; ++b)
    {
        for (int p = 2;; ++p)
        {
            int bp = pow(b, p);
            if (x >= bp)
            {
                if (bp > max)
                {
                    max = bp;
                }
            }
            else
            {
                break;
            }
        }
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define true 1
#define false 0
#define f(x, y, z) for (int x = y; x < z; x++)
#define fd(x, y, z) for (int x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
using namespace std;
lli tmod(lli x,lli m){return (x%m+m)%m;}
class RMQ  //gives index of min-max in a given range
{
    public:
	struct node
    {
	lli mx;int l,r; 
    };
	v64 h;
	vt <node> st;
 
    bool is_intersection(int l,int r,int ll,int rr)
    {
       if(r<ll || rr<l)
         return 0;
         return 1;
    }
	RMQ(v64 a)
	{
       h=a;
       st.resize(4*h.size());
       build(0,h.size()-1);
	}
	void build(int l,int r,int k=0)
	{
		st[k].l=l,st[k].r=r;
	    if(l==r)
		   {st[k].mx=l;
             return;
		   }
	    build(l,(l+r)/2,2*k+1);
	    build((l+r)/2+1,r,2*k+2);	
      if(h[st[2*k+1].mx]>=h[st[2*k+2].mx])
	    st[k].mx=st[2*k+1].mx;
	    else st[k].mx=st[2*k+2].mx;
	}
	int maxquery(int l,int r,int k=0)
    {
       int ll=st[k].l,rr=st[k].r,mid=(ll+rr)>>1;
       if(r<ll || rr<l)return -1; 
       if(ll>=l && rr<=r)
          return st[k].mx;
   	      int p1=maxquery(l,r,2*k+1);
   	      int p2=maxquery(l,r,2*k+2);
       if(p1==-1)return st[k].mx=p2;
       if(p2==-1)return st[k].mx=p1;
       if(h[p1]>=h[p2])return st[k].mx=p1;
       return st[k].mx=p2;      
    }
    void update(int id,lli val,int k=0)
    {
        int l=st[k].l,r=st[k].r,mid=(l+r)>>2;
        if(id<l || id>r)return;
        if(l==r)
        {
            h[l]=val;
            return;
        }
        update(id,val,2*k+1);
        update(id,val,2*k+2);	
      if(h[st[2*k+1].mx]>=h[st[2*k+2].mx])
	    st[k].mx=st[2*k+1].mx;
	    else st[k].mx=st[2*k+2].mx;
    }
};
int main()
{
  fastio;
  lli n;
  cin>>n;
  v32 h(n);
  v64 ANS(1+n,0);
  v64 a(n);
  f(i,0,n)cin>>h[i];
  f(i,0,n)cin>>a[i];
  RMQ ans(ANS);
  f(i,0,n) ans.update(h[i],a[i]+ans.h[ans.maxquery(0,h[i]-1)]);
  cout<<ans.h[ans.maxquery(0,n)];
  return 0;    	
}

Measured memory_bytes: 19840
// Author: MOHAMAMD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int * arr = new int [3];
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr,arr+3);
	cout<<arr[0]+arr[1]<<endl;
	delete [] arr;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#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 debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  VI x(n);
  iota(all(x), 1);
  int i, j, c;
  i = j = c = 0;
  do
  {
    if(equal(all(p), x.begin())) i = c;
    if(equal(all(q), x.begin())) j = c;
    c++;
  } while (next_permutation(all(x)));
  out(abs(j - i));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int D;
  scanf("%d", &D);
  switch(D){
    case (25): printf("Christmas"); break;
    case (24): printf("Christmas Eve"); break;
    case (23): printf("Christmas Eve Eve"); break;
    case (22): printf("Christmas Eve Eve Eve"); break;
  }
  return 0;
}


Measured memory_bytes: 128
n,w=[int(k) for k in input().split()]
li=[]
 
 
ans=0
for i in range(n):
    li.append([int(k) for k in input().split()])
dp=[[0 for i in range(100001)] for j in range(n+1)]
for i in range(1,100001):
    dp[0][i]=10**10
dp[0][0]=0    
for a in range(1,n+1):
    for b in range(0,100001):
        if(li[a-1][1]<=b):
            x=li[a-1][0]+dp[a-1][b-li[a-1][1]]
            y=dp[a-1][b]
            dp[a][b]=min(x,y)
        else:
            dp[a][b]=dp[a-1][b]
        if dp[a][b]<=w:
          ans=max(ans,b)
 
 
print(ans)    
 

Measured memory_bytes: 171784
#include <iostream>
#include <utility>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cmath>
         
typedef long long ll;
using namespace std;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
   
#define PI 3.14159265358979323846
         
const double EPS = 1e-8;
        
int main()
{
   	ll A,B,C;

	cin >> A >> B >> C;

	
	cout << ((C>=A&&C<=B) ? "Yes" : "No") <<endl;

   	return 0;
}

Measured memory_bytes: 256
from itertools import product
N = int(input())
S = []
for i in range(1, 10):
  S += list(product("753",repeat=i))
cnt = 0
for s in S:
  if int("".join(s)) > N:
    continue
  if all(s.count(c) > 0 for c in "753"):
    cnt += 1
print(cnt)

Measured memory_bytes: 7028
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> d(n,0);
	
	for (int i = 0; i < n; i++) {
		cin >> d.at(i);
	}
	
	std::sort(d.begin(),d.end());
	
	int ans = 0;
	
	if(d.at(n/2-1) == d.at(n/2)){
		
//		cout << "EQ d(" << n/2-1 << "):" << d.at(n/2-1) << 
//			", d(" << n/2 << "):" << d.at(n/2) << endl;
		
		ans = 0;
		cout << ans << endl;
		return 0;
	}
	
//			cout << "notEQ d(" << n/2-1 << "):" << d.at(n/2-1) << 
//			", d(" << n/2 << "):" << d.at(n/2) << endl;
	
	ans = d.at(n/2) - d.at(n/2-1);
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640