akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, a;
	map<int, int> mp;
	cin >> n;
	while (n--) {
		cin >> a;
		mp[a]++;
	}

	int ans = 0;
	for (auto t : mp) {
		if (t.first < t.second)
			ans += t.second - t.first;
		else if (t.first > t.second)
			ans += t.second;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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

int main() {

	int n;
	cin >> n;

	int ans = 0;
	Rep(i, 1, n + 1) {
		int tmp = i;
		int cnt = 0;
		while (tmp != 0) {
			tmp /= 10;
			cnt++;
		}
		if (cnt % 2 == 1) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a,b,c,d;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> a >> b >> c >> d;
}

int solve(){
    int takahasi = (c+b-1)/b;
    int aoki = (a+d-1)/d;
    cout << (aoki>=takahasi?"Yes":"No") << endl;
    return 0;
}   

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


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n;
	cin >> n;
	cout << (n*n*n) << endl;
	return 0;
}


Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline


def main():
    N = input()[:-1]
    S = sum([int(N[i:i+1]) for i in range(len(N))])
    if int(N)%S==0:
        print('Yes')
    else:
        print('No')
    
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(2e5)+10;
const int K = int(2e6)+10;
const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

vi adj[N];
int a[N];

void dfs () {

}

void solve () {
    int n;cin>>n;
    int rem = n % 1000;
    if (rem != 0) rem = 1000 - rem;
    cout<<rem<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
	int N;
	long long K;
	cin >> N >> K;
	int A[N];
	for (int i = 0; i < N; i++){
		cin >> A[i];
		A[i]--;
	}

	vector<int> route, circle;
	bool isVisited[N] = {0};
	int startCircle;
	int current = 0;

	while(!isVisited[current]){
		isVisited[current] = true;
		route.push_back(current);
		current = A[current];
	}
	// now current is the start village of the circle

	for (int i = 0; i < route.size(); i++){
		if(route[i] == current){
			startCircle = i;
			for (int j = i; j < route.size(); j++){
				circle.push_back(route[j]);
			}
			break;
		}
	}

	K++;
	if(K <= startCircle){
		cout << route[K - 1] + 1<< endl;
	} else {
		int temp = (K - startCircle) % circle.size();
		if (temp == 0){
			temp = circle.size();
		}
		cout << circle[temp - 1] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 6616
#include<stdio.h>
const int maxn = 100000;
int main()
{
	int i = 0, j = 0, k = 0,n,value[maxn];
	scanf("%d", &n);
		for (int pos = 0; pos < n; pos++)
		{
			scanf("%d", &value[pos]);
			if (value[pos] % 4 == 0)
				i++;
			else if (value[pos] % 2 == 0)
				j++;
			else
				k++;
		}
		if (j == 0)
		{
			if(k>i+1)
				printf("No\n");
			else
				printf("Yes\n");
		}
		else if(j != 0)
		{
			if (k > i)
				printf("No\n");
			else
				printf("Yes\n");
		}
		return 0;
}

Measured memory_bytes: 512
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;


int d,n,ans;
int main()
{
    cin>>d>>n;
    if(d==0)
    {
        if(n==100)cout<<n+1;
        else cout<<n; 
    }
    else if(d==1)
    {
        if(n==100)cout<<n*100+100;
        else cout<<n*100;
    }
    else if(d==2)
    {
        if(n==100)cout<<n*10000+10000;
        else cout<<n*10000;
    }
    //system("pause");
    return 0;
}  

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

using namespace std;


int main(){
    int a,b,c,d;
//    cout << 10/9 + 1;
    cin >> b >> a >> d >> c;
    int at,ct;
    if(d <= a){
        at = 1;
    }else{
        if(d % a == 0){
            at = d / a;
        }else{
            at = d / a + 1;
        }
    }
    if(b <= c){
        ct = 1;
    }else{
        if(b % c == 0){
            ct = b / c;
        }else{
            ct = b / c + 1;
        }
    }


    if(at <= ct)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}




Measured memory_bytes: 3540
int main() {
    // insert code here...
    char S[3];
    int a=0;
    int b=0;
    scanf("%c%c%c", &S[0], &S[1], &S[2]);
    
    for(int i=0; i<3; i++){
        if(S[i]=='A'){
            a=a+1;
        }
        else
            b=b+1;
    }
    if(a==3 || b==3){
        printf("No\n");
    }
    else
        printf("Yes\n");
    
    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif


        
        int n;
        cin>>n;
        vi v;
        int flag=0;
        for(int i=1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                flag  =1;
                v.pb(i);
                //if(i!=(n/i))
                    v.pb(n/i);
            }
        }
        if(flag==0)
        {
            cout<<n-1<<"\n";
            return 0;
        }
        sort(all(v));

       int xx = v[v.size()/2-1];
       int yy = n/xx;
       cout<<yy+xx-2<<"\n";











    #ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	double d,t,s;
	cin >> d >> t >> s;
	double x=double(d)/s;
	if(x<=t)cout << "Yes\n";
	else cout << "No\n";


	return;
}

int main()
{
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();

	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll H;
    cin>>H;
    ll D=1;
    while( D<=H) {
        D*=2;
    }
    D/=2;
    ll counter=0;
    while(D>0) {
        counter+=D;
        D/=2;
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double PI = acos(-1);

int main(){
    int a,b,x;
    scanf(" %d %d %d", &a, &b, &x);

    double ok = 0, ng = 90;
    rep(loop,100){
        double mid = (ok+ng)/2;
        double theta = mid*PI/180;

        double V = a*b*b*0.5/tan(theta);
        if(a*sin(theta) < b*cos(theta)){
            double X = b*cos(theta) - a*sin(theta);
            V = a*a*b - a*a*0.5*(b-X/cos(theta));
        }

        if(x<=V) ok = mid;
        else ng = mid;
    }
    printf("%.15f\n", ok);
    return 0;
}


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

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


    for (int x=1; x<=sqrt(N); x++){
        for (int y=1; y<=sqrt(N); y++) {
            for (int z=1; z<=sqrt(N); z++) {
                v = x*x + y*y + z*z + x*y + y*z + z*x;
                if (N >= v) {
                    f[v-1]++;
                }
            }
        }
    }

    for (int i=0; i<N; i++) {
        cout << f[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3556
#include <stdio.h>
#include <ctype.h>
 
int main() {
    char str[1000];
    int i, sum;
    while (gets(str)) {
        if (str[0] == '0') {
            break;
        }
        sum = 0;
        for (i = 0; str[i]; i++) {
            sum += str[i] - 48;
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(){
    int i, a, b, c, count = 0;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < 1) return 0;
    if(b > 10000 || c > 10000) return 0;
    if(a > b) return 0;
    
    for(i = a; i <= b; i++){
        if(c / i >= 1 && c % i == 0) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
typedef pair<ll, int> pli; 
template <class T> using Tree = tree<T, null_type, less<T>, 
	rb_tree_tag, tree_order_statistics_node_update>; 
Tree<pli> t;
int n, k;
ll s, ans;
int main()
{
	t.insert(mp(0, 0));
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i)
	{
		int v;
		scanf("%d", &v);
		s += v;
		s -= k;
		ans += t.order_of_key(mp(s, i));
		t.insert(mp(s, i));
	}
	cout << ans << endl;
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var ps = Input();
		var p = new double[n];
		for(int i = 0; i < n; i++)
		{
			p[i] = double.Parse(ps[i]);
		}
		
		//i枚の時j枚表の確率;
		
		var dp = new double[n+1, n+2];
		dp[0, 0] = 1;
		
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j <= i; j++)
			{
				dp[i+1, j+0] += dp[i, j] * (1.0 - p[i]);
				dp[i+1, j+1] += dp[i, j] * p[i];
			}
		}
		
		double wa = 0;
		
		for(int i = (n / 2 + (n % 2 == 0 ? 0 : 1)); i <= n; i++)
		{
			wa += dp[n, i];
		}
		Console.WriteLine(wa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 82784
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static List<int> Divisor(int input)
        {
            List<int> result = new List<int>();

            for (int i = 1; i * i <= input; i++)
            {
                if (0 == input % i)
                {
                    result.Add(i);
                    if (i * i != input)
                    {
                        result.Add(input / i);
                    }
                }
            }

            return result;
        }


        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int K = int.Parse(s[2]);

            List<int> p0 = Divisor(A);
            List<int> p1 = Divisor(B);
            List<int> comm = new List<int>();

            foreach(int i0 in p0)
            {
                foreach(int i1 in p1)
                {
                    if( i1 == i0)
                    {
                        comm.Add(i1);
                    }
                }
            }

            comm.Sort();
            comm.Reverse();

            Console.WriteLine(comm[K-1]);
        }
    }
}


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

int GetDigit(ll num){
    return log10(num)+1;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    bool zero_flag = false;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0)
            zero_flag = true;
    }
    
    if (zero_flag)
        cout << 0 << endl;
    else {
        ll ans = A[0];
        for (int i = 1; i < N; i++) {
            int a_keta = GetDigit(ans);
            int b_keta = GetDigit(A[i]);
            ans *= A[i];
            if (a_keta + b_keta - 1 >= 19 && ans != ll(1e18) || ans > ll(1e18)) {
                ans = -1;
                break;
            }
        }
        
        cout << ans << endl;
    }
}


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

int main() {
	while (1) {
		int n, x;
		cin >> n >> x;
		if (n == 0) break;

		int count = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}



Measured memory_bytes: 3052
#include<iostream>

using namespace std;

int main(void) {
	long long int Q[4]; //順にQ,H,S,Dを表す
	long double C[4];
	long long int M[4] = { 1,2,4,8 };

	long long int N;
	for (int i = 0; i < 4; i++) {
		cin >> Q[i];
	}
	cin >> N;
	
	C[0] = Q[0] * 4.0;
	C[1] = Q[1] * 2.0;
	C[2] = Q[2];
	C[3] = (long double)Q[3] / 2.0;

	long double temp1;
	long long int temp;

	for (int i = 0; i < 3; i++) {
		for (int j = 3; j > i; j--) {
			if (C[j - 1] > C[j]) {
				temp1 = C[j];
				C[j] = C[j - 1];
				C[j - 1] = temp1;
				temp = Q[j];
				Q[j] = Q[j - 1];
				Q[j - 1] = temp;
				temp = M[j];
				M[j] = M[j - 1];
				M[j - 1] = temp;
				
			}

		}
	}

	N = N * 4;

	long long int sum = 0;
	while (N != 0) {
		for (int i = 0; i < 4; i++) {
			sum += Q[i] * (N / M[i]);
			N = N % M[i];
		}
	}
	cout << sum;

	/*for (int i = 0; i < 4; i++) {
		cout <<M[i] <<" "<< C[i] << " " << Q[i] << endl;
	}*/

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
#define MOD 1000000007


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) {
        ans += A[i];
        ans%=MOD;
    }
    ans *= ans;
    ans %= MOD;
    rep(i, N) {
        ans -= A[i]*A[i];
        if (ans < (ll)0) {
            ans += ((-ans)/MOD + 1) * MOD;
        }
        ans %= MOD;
    }
    cout << (ans * modinv(2, MOD)) % MOD << endl;
}


Measured memory_bytes: 4844
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int A, B;
int main(void){
    cin >> A >> B;
    int count = 0;
    while(1 + count * (A-1) < B)
        count++;
    cout << count << endl;

    return 0;
}



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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000000000000018
#define mod 1073741824
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>

#define MX 1000000
char str[MX];
int rem[2019];

int main()
{
	scanf("%s", &str);

	rem[0]++;
	ll val = 0, pow10 = 1;
	for(int i = strlen(str)-1; i >= 0; i--) {
		val = ((str[i]-'0')*pow10 + val)%2019;
		rem[val]++;
		pow10 = (pow10*10)%2019;
	}

	ll res = 0;
	for(int i = 0; i < 2019; i++) {
		res += (rem[i]*(rem[i]-1))/2;
	}

	printf("%lld\n", res);
}

/*
let, cm[n-1]=str[n-1], cm[n-2]=str[n-2]*10+cm[n+1], ... , cm[0]=str[0]*(10^n-1)+cm[1];
for specific (i, j) pair to check whether its divisible by 2019:
	(cm[i]-cm[j+1])/(10^(n-j-1)) == 0 (mod 2019) [as gcd(10, 2019)=1,so its mod inv. exists]
	(cm[i]-cm[j+1]) == 0 (mod 2019)
	cm[i] == cm[j+1] (mod 2019), this formula is used above.
*/


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
ll mod=1e9+7;
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;ans%=mod;
if(ans<0)ans+=mod;
x*=x;n>>=1;}return ans;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll fact(ll x){
    ll ans=1;
    while(x){
        ans*=x--;
        ans%=mod;
        if(ans<0)ans+=mod;
    }
    return ans;
}
ll c(ll x,ll y){
    ll res=1;
    ll tmp=x;
    while(tmp>=(x-y+1)){
        res*=tmp--;
        res%=mod;
        if(res<0)res+=mod;
    }
    return res*modinv(fact(y),mod)%mod;
}
long long INF = 1LL<<60;
int main(){
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    ll res=modpow(2LL,n,mod)-1;
    res-=(c(n,a));
    res%=mod;
    if(res<0)res+=mod;
    res-=(c(n,b));
    res%=mod;
    if(res<0)res+=mod;
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

int main ()
{
	int r, c;
	std::cin >> r >> c;
	
	int** table = new int*[r+1];
	for (int i=0; i<r+1; i++) {
		table[i] = new int[c+1];
	}
	
	for (int i=0; i<r; i++) {
		for (int j=0; j<c; j++) {
			std::cin >> table[i][j];
		}
	}
	
	for (int i=0; i<r; i++) {
		int r_sum = 0;
		for (int j=0; j<c; j++) r_sum += table[i][j];
		table[i][c] = r_sum;
	}
	
	for (int j=0; j<c+1; j++) {
		int c_sum = 0;
		for (int i=0; i<r; i++) c_sum += table[i][j];
		table[r][j] = c_sum;
	}
	
	for (int i=0; i<r+1; i++) {
		for (int j=0; j<c+1; j++) {
			if (j==0) std::cout << table[i][j];
			else std::cout << " " << table[i][j];
		}
		std::cout << std::endl;
	}
	
	for (int i=0; i<r+1; i++) delete[] table[i];
	delete[] table;
	
	return 0;
}




Measured memory_bytes: 3128
x = []
for _ in range(5):
	x.append(int(input()))
k = int(input())
flag = False
for i in range(5):
    for j in range(i, 5):
        if abs(x[i] - x[j]) > k:
            flag = True
if flag:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
cost = 0
for i, x in enumerate(a):
    cost += x
    if cost > k:
        cnt = i
        cost -= x
        break
else:
    for j, y in enumerate(b):
        cost += y
        if cost > k:
            cnt = n + j
            cost -= y
            break
    else:
        cnt = n + m

if cnt <= n:
    i_max, j = cnt - 1, 0
else:
    i_max, j = n - 1, cnt - n

while j < m and cost + b[j] <= k:
    cost += b[j]
    j += 1
    cnt += 1

ans = cnt
for i in range(i_max, -1, -1):
    if j == m: break
    cost -= a[i]
    cnt -= 1
    while j < m and cost + b[j] <= k:
        cost += b[j]
        j += 1
        cnt += 1

    ans = max(cnt, ans)

print(ans)

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    ll l,r;
    cin >> l >> r;
    if ((l-1)/2019 != r/2019) {
        cout << 0 << endl;
    } else {
        ll ans = 2018;
        for (ll i = l;i < r;++i) for (ll j = i+1;j < r+1;++j) ans = min(ans,i*j%2019);
        cout << ans;
    }
    return 0;
}

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

int main() 
{
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    bool t = (x==w/2.0 && y==h/2.0);
    printf("%.9f %d", w*h/2, t); 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
int n;
int a[310];
double dp[310][310][310];
double rec(int i,int j,int k){
  if( dp[i][j][k] >= 0) return dp[i][j][k]; 
  int sum = i + j + k;
  double res = 0;
  if( i != 0) res += (double)i/sum * rec(i-1,j,k);
  if( j != 0) res += (double)j/sum * rec(i+1,j-1,k);
  if( k != 0) res += (double)k/sum * rec(i,j+1,k-1);
  res += (double)n/sum;
  return dp[i][j][k] = res;
}
int main()
{
  cin >> n;
  rep(i,n) cin >> a[i];

  rep(i,n+1) rep(j,n+1) rep(k,n+1) dp[i][j][k] = -1;
  dp[0][0][0] = 0;
  
  int one = 0,two = 0,thr = 0;
  rep(i,n){
    if(a[i]==1) one++;
    else if(a[i]==2) two++;
    else thr++;
  }  
  
  printf("%.10f\n", rec(one,two,thr));
  return 0;
}


Measured memory_bytes: 227584
s = input()
ans = 0
for n in range(1 << (len(s) - 1)):
    t = ""
    for j in range(len(s) - 1):
        t += s[j]
        if (n >> j & 1) == 1:
            t += "+"
    t += s[-1]


    sums = 0
    for i, c in enumerate(t):
        if c != "+":
            sums *= 10
            sums += int(c)
        elif c == "+":
            ans += sums
            sums = 0
        if i == len(t) -1:
           ans += sums

print(ans)


Measured memory_bytes: 3060
n,q = map(int,input().split())
rl = [0] * n
al = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a -1
for j in range(q):
    p,x = map(int,input().split())
    al[p-1] += x
for k in range(n):
    if k == 0:
        pass
    else:
        al[k] += al[rl[k]]
print(*al)


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

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    ll latest_pos = 0;

    rep(i, s.length()) {
        if (s[i] == 'W') {
            ans += i - latest_pos;
            latest_pos++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
   
   int n, a, b;
   cin >> n;
   if (n == 1){
     cout << "Hello World" << endl;
   }
   else if (n == 2){
     cin >> a >> b;
     cout << a + b << endl;
   }
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
              int count=1;
		Scanner sc = new Scanner(System.in);
		int x;
		while((x=sc.nextInt()) != 0){
		    System.out.printf("Case %d: %d\n",count++,x);
		}
	}
}


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

#define s(n)                        scanf("%d",&n)
#define ss(n)                       scanf("%s",n)
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define fill(a,v)                   memset(a, v, sizeof a)
#define fi              freopen("input.txt", "rt", stdin)
#define fo              freopen("output.txt", "wt", stdout)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

void solve(){
	//fi; fo;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll res = 0;
    ll n,k,x,y;
    cin>>n>>k>>x>>y;

    if(k>=n)
    res=(x*n);
    if(k<n)
        res=x*k+y*(n-k);

    cout<<res<<'\n';
}


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


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

int dp[200][200];

int rec(int x,int y){
	if(dp[x][y]!=-1)return dp[x][y];
	set<int>se;
	if(x)se.insert(rec(x-1,y));
	for(int i=1;i<=min(x,y);i++){
		se.insert(rec(x,y-i));
	}
	if(y)se.insert(rec(x+1,y-1));
	for(int i=0;;i++){
		if(!se.count(i))return dp[x][y]=i;
	}
}

int main(){
	int n;cin>>n;
	memset(dp,-1,sizeof(dp));
	int x=0;
	rep(i,n){
		int a,b;scanf("%d%d",&a,&b);
		x^=rec(a,b);
	}
	if(x)puts("0");
	else puts("1");
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, a, b; cin >> n >> a >> b;
  V<> p(n); for (int i = 0; i < n; ++i) cin >> p[i];
  V<> c(3);
  for (int i = 0; i < n; ++i) {
    if (p[i] <= a) ++c[0];
    else if (p[i] <= b) ++c[1];
    else ++c[2];
  }
  cout << *min_element(begin(c), end(c)) << '\n';
}

Measured memory_bytes: 256
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
class Main {
    public static void main(String[] args) throws IOException {
        FastReader in = new FastReader(System.in);
        StringBuilder sb = new StringBuilder();
        int t,no, i, j;
        t=1;
        for(no=1;no<=t;no++) {
            int n = in.nextInt(), ans=0;
            if(n<600)
                ans=8;
            else if(n<800)
                ans=7;
            else if(n<1000)
                ans=6;
            else if(n<1200)
                ans=5;
            else if(n<1400)
                ans=4;
            else if(n<1600)
                ans=3;
            else if(n<1800)
                ans=2;
            else
                ans=1;
            System.out.println(ans);
        }
        //System.out.print(sb);
    }
}
class FastReader {
    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }
    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}




Measured memory_bytes: 32352
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<string> vs{"oo", "ox", "xx", "xo"};
    for (auto r : vs) {
        int flag = 1;
        string res(n, ' ');
        res[0] = r[0];
        res[1] = r[1];
        for (int i = 1; i < n - 1; i++) {
            char c = 'o';
            if (res[i] != s[i]) c = 'x';
            if (c == 'o') {
                res[(i + 1) % n] = res[i - 1];
            } else {
                res[(i + 1) % n] = (res[i - 1] == 'o' ? 'x' : 'o');
            }
        }

        if (res[n - 1] == s[n - 1] && res[0] != res[n - 2]) flag = 0;
        if (res[n - 1] != s[n - 1] && res[0] == res[n - 2]) flag = 0;
        if (res[0] == s[0] && res[1] != res.back()) flag = 0;
        if (res[0] != s[0] && res[1] == res.back()) flag = 0;
        if (flag == 1) {
            for (auto rr : res) {
                if (rr == 'o')
                    cout << 'S';
                else
                    cout << 'W';
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3796
import java.util.Random;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt(),
                                       sc.nextInt(), sc.nextInt(), sc.nextInt()});

        int count = sc.nextInt();
        char[] choice = new char[]{'N', 'E', 'S', 'W'};
        Random rand = new Random();
        for (int i = 0; i < count; i++) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            while (dice.eyes[dice.now[0]] != a[0] || dice.eyes[dice.now[3]] != a[1]) {
                dice.move(choice[rand.nextInt(choice.length)]);
            }
            System.out.println(dice.eyes[dice.now[2]]);
        }
    }

    static class Dice {

        int[] eyes;
        int[/*TOP N E S W BOT*/] now;

        public Dice(int[] eyes) {
            this.eyes = eyes;
            this.now = new int[]{0, 4, 2, 1, 3, 5};
        }

        void move(char way) {
            int tmp;
            switch (way) {
                case 'N':
                    tmp = now[0];
                    now[0] = now[3];
                    now[3] = now[5];
                    now[5] = now[1];
                    now[1] = tmp;
                    break;
                case 'E':
                    tmp = now[0];
                    now[0] = now[4];
                    now[4] = now[5];
                    now[5] = now[2];
                    now[2] = tmp;
                    break;
                case 'S':
                    tmp = now[0];
                    now[0] = now[1];
                    now[1] = now[5];
                    now[5] = now[3];
                    now[3] = tmp;
                    break;
                case 'W':
                    tmp = now[0];
                    now[0] = now[2];
                    now[2] = now[5];
                    now[5] = now[4];
                    now[4] = tmp;
                    break;
            }
        }
    }
}

Measured memory_bytes: 26416
#include <bits/stdc++.h>
using namespace std;
int ba[9];
int a,b,c,n;
int dfs(int l,int a1,int b1,int c1)
{
	if(l==n)
	{
		if(a1==0||b1==0||c1==0)
			return 8001;
		return abs(a-a1)+abs(b-b1)+abs(c-c1);
	}
	int r1,r2,r3,r4;
	r1=dfs(l+1,a1+ba[l+1],b1,c1)+10;
	r2=dfs(l+1,a1,b1+ba[l+1],c1)+10;
	r3=dfs(l+1,a1,b1,c1+ba[l+1])+10;
	r4=dfs(l+1,a1,b1,c1);
	return min(r1,min(r2,min(r3,r4)));
}
int main()
{
	int i;
	scanf("%d %d %d %d",&n,&a,&b,&c);
	for(i=1;i<=n;i++)
		scanf("%d",&ba[i]);
	printf("%d",dfs(0,0,0,0)-30);
	return 0;
}

Measured memory_bytes: 256
import math
n, d  = map(int, input().split())
ll = []
count = 0
for i in range(n):
    ll.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i+1,n):
        dd = 0
        for k in range(d):
            dd += (ll[i][k]-ll[j][k])**2
            s = math.sqrt(float(dd))
        if s == int(s):
            count+=1
print(count)


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string s,t,u; cin>>s>>t;
    int a,b; cin>>a>>b;
    cin>>u;
    if(s==u) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    if l[i] > l[i-1] and l[i] < l[i+1]:
        c = c+1
    elif l[i] < l[i-1] and l[i] > l[i+1]:
        c = c+1
    else:
        continue

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include<queue>
#include <map>
#define endl '\n'
using namespace std;
int h,w,k,b,cnt,cases,ht=1,wt=1;
map<pair<char,int>,int>box;
char m[6][6];

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

    cin>>h>>w>>k;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j) {
            cin>>m[i][j];
            if(m[i][j]=='#') b++;
        }
    }
    for(int i=0;i<h;++i){
        int temp=0;
        for(int j=0;j<w;++j){
            if(m[i][j]=='#') temp++;
        }
        box.insert(make_pair(make_pair('r',i),temp));
    }
    for(int j=0;j<w;++j){
        int temp=0;
        for(int i=0;i<h;++i){
            if(m[i][j]=='#') temp++;
        }
        box.insert(make_pair(make_pair('c',j),temp));
    }
    for(int i=0;i<h;++i) ht*=2;
    for(int i=0;i<w;++i) wt*=2;
    for(int i=0;i<ht;++i){
        for(int j=0;j<wt;++j){
            cnt=0;
            queue<int>rq,cq;
            for(int p=0;p<h;++p){
                if(1<<p&i) {
                    cnt+=box.find(make_pair('r',p))->second;
                    rq.push(p);
                }
            }
            for(int q=0;q<w;++q){
                if(1<<q&j) {
                    cnt+=box.find(make_pair('c',q))->second;
                    cq.push(q);
                }
            }
            while(!rq.empty()){
                int curr_r=rq.front();
                rq.pop();
                int cqs=cq.size();
                for(int i=0;i<cqs;++i){
                    int curr_q=cq.front();
                    if(m[curr_r][curr_q]=='#') cnt--;
                    cq.pop();
                    cq.push(curr_q);
                }
            }
            if(b-cnt==k) cases++;
        }
    }
    cout<<cases<<endl;
    return 0;
}


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

static const int N = 100;

int main() {
    
    int n, p[N + 1], m[N + 1][N + 1];
    
    cin >> n;
    
    for(int i = 1; i <= n; i++ ) {
        
        cin >> p[i - 1] >> p[i];
        
    }
    
    for(int i = 1; i <= n; i++ ) {
        
         m[i][i] = 0;
         
    }
    
    for(int l= 2; l <= n; l++ ) {
        
        for(int i = 1; i <= n - l + 1 ; i++ ) {
            
            int j = i + l - 1;
            
            m[i][j] = (1 << 21);
            
            for (int k = i; k <= j - 1; k++ ) {
                
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
                
            }
            
        }
        
    }
    
    cout << m[1][n] << endl;
    
    return 0;
    
}


Measured memory_bytes: 3136
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    
    C = [0] * N
    for a in A:
        C[a-1] += 1
    
    print(*C, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 105436
N = int(input())
A = [int(x) for x in input().split()]
square = 0
even = 0
odd = 0
for a in A:
  if a % 4 == 0:
    square += 1
  elif a % 2 == 0:
    even += 1
  else:
    odd += 1
if square >= odd:
  print('Yes')
elif square == odd - 1 and even == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),k=sc.nextInt();
    Integer[] array= new Integer[n];
    for(int i=0; i<n; i++){
      array[i]=sc.nextInt();
    }
    Arrays.sort(array,Collections.reverseOrder());
    int sum=0;
    for(int j=0; j<k; j++){
      sum+=array[j];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21204