akhauriyash/Code-Regression huggingface dataset:
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct union_find
{
private:
    int n;
    vector<int> parent, tree_size;

public:
    union_find(int size) : n(size), parent(size), tree_size(size, 1)
    {
        for (int i = 0; i < size; ++i)
        {
            parent[i] = i;
        }
    }

    int size()
    {
        return n;
    }

    int root(int u)
    { // 再帰
        if (u == parent[u])
        {
            return u;
        }
        return parent[u] = root(parent[u]);
    }

    void unite(int u, int v)
    {
        u = root(u);
        v = root(v);
        if (u == v)
        {
            return;
        }
        if (tree_size[u] < tree_size[v])
        {
            swap(u, v);
        }
        parent[v] = u;
        tree_size[u] += tree_size[v];
    }

    bool same(int u, int v)
    {
        return root(u) == root(v);
    }

    int component_size(int u)
    {
        u = root(u);
        return tree_size[u];
    }

    int number_of_components()
    {
        int k = 0;
        rep(u, n)
        {
            if (u == parent[u])
            {
                ++k;
            }
        }
        return k;
    }
};

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

    int n, m;
    cin >> n >> m;
    union_find uf{n};
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        uf.unite(a,b);
    }

    cout << uf.number_of_components() - 1 << '\n';

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n, p; cin >> n >> p;
    if(n == 1) {
        cout << p << '\n';
        return 0;
    }
    ll ans = 1;
    for(ll i = 2; i*i <= p; i++) {
        ll cnt = 0;
        while(p%i == 0) {
            p /= i;
            cnt++;
        }
        if(cnt >= n) {
            cnt /= n;
            ans *= pow(i, cnt);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
int n;
long double prob[3000];
ld memo[3000][3000];
ld solve(int pos,int h)
{
	if(pos==n)
	{
		if(h>(n/2))
			return 1;
		else
			return 0;
	}
	if(memo[pos][h]!=-1)
		return memo[pos][h];
	memo[pos][h]=solve(pos+1,h+1)*prob[pos]+solve(pos+1,h)*(1-prob[pos]);
	return memo[pos][h];
}
int main()
{
    fastread;
    cin>>n;
    for(ll i=0;i<3000;i++)
    	for(ll j=0;j<3000;j++)
    		memo[i][j]=-1;
    for(ll i=0;i<n;i++)
    	cin>>prob[i];
    cout<<setprecision(10)<<solve(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 141184
# D - Coloring Dominoes

N = int(input())
S1 = input()
S2 = input()
MOD = 10**9 + 7

if S1[0] == S2[0]:
    same_domino = False
    ans = 3
else:
    same_domino = True
    ans = 3*2

for i in range(1, N):
    if S1[i] == S2[i] and S1[i-1] == S2[i-1]:
        ans *= 2
    elif S1[i] == S2[i] and S1[i-1] != S2[i-1]:
        pass
    elif S1[i] != S2[i] and same_domino:
        same_domino = False
    elif S1[i] != S2[i] and not same_domino and S1[i-1] == S2[i-1]:
        ans *= 2
        same_domino = True
    elif S1[i] != S2[i] and not same_domino and S1[i-1] != S2[i-1]:
        ans *= 3
        same_domino = True

print(ans % MOD)

Measured memory_bytes: 3064
#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;
    int a;
    cin >> a;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<vector<long long int>> res(n + 1, vector<long long int>(n * 50 + 1, 0));
    res[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j >= 0; j--) {
            for (int k = 0; k + v[i] <= n * 50; k++) {
                res[j + 1][k + v[i]] += res[j][k];
            }
        }
    }
    long long int r = 0;
    for (int i = 1; i <= n; i++) {
        r += res[i][i * a];
    }
    cout << r << endl;
}




Measured memory_bytes: 4288
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
char a[55];
char b[55];

int main()
{
	cin >>a + 1 >>b + 1;
	int len1 = strlen(a + 1);
	int len2 = strlen(b + 1);
//	printf("%d %d\n", len1, len2);
	int len = len2;
	int k, gg = len2;
	int flag = 0;
	for (int i = len1; i >= 1; i--){
		len = len2;
		k = 0;
		if (i - len2 >= 0){
			for (int j = i; j >= i - len2 + 1; j--){
				if (a[j] == '?'){
					k++;
					len--;
				}
				else {
//					cout <<k <<len <<"fffff" <<endl;
					if (a[j] == b[len--])
						k++;
					else break;
				}
			}
/*			cout <<"kkkkk" <<k <<endl;
			cout <<len2 <<endl;
			cout <<b + 1 <<endl;
cout <<a + 1 <<endl;
			cout <<i <<endl;*/
			if (k == len2){
	//			cout <<"kkkkkkkkk" <<endl;
				for (int j = i; j >= i - len2 + 1; j--){
	//				cout <<j <<"    " <<len2 <<endl;
					a[j] = b[gg--];
				}
	//			cout <<len2 <<endl;
				for (int j = 1; j <= len1; j++)
					if (a[j] == '?')	a[j] = 'a';
				flag = 1;
				break;
			}
		}
	}
	if (flag)	cout <<a + 1 <<endl;
	else cout <<"UNRESTORABLE" <<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const int MOD = 10000;
string A;
string B;
int M;
short dp[2][502][502][11][2];

void Minus() {
  int index = B.size() - 1;
  while (true) {
    if (B[index] != 0) {
      B[index]--;
      break;
    }
    B[index] = 9;
    index--;
  }
  if (index == 0 && B[0] == 0) {
    B = B.substr(1);
  }
}

int calc(bool ban, int upper, int depth, int rest, int prev, int up) {
  if (!ban && dp[upper][depth][rest][prev][up] != -1) { return dp[upper][depth][rest][prev][up]; }
  if (depth == (int)B.size()) {
    return rest == 0;
  }
  int l = 0;
  int r = 9;
  if (ban) { l = 1; }
  if (upper) { r = B[depth] - '0'; }
  if (up) {
    l = prev + 1;
  } else {
    r = min(r, prev - 1);
  }
  int ret = 0;
  if (l <= r) {
    int v = up ? l : r;
    int nupper = upper && v == B[depth] - '0';
    int nrest = (rest * 10 + v) % M;
    ret += calc(false, nupper, depth + 1, nrest, v, up ^ 1);
    ret += calc(ban, upper, depth, rest, v, up);
  }
  if (ban) { return ret % MOD; }
  return dp[upper][depth][rest][prev][up] = ret % MOD;
}
int ZigZag(int depth) {
  if (depth == (int)B.size() - 1) {
    if (B.size() == 1) { return calc(true, 1, depth, 0, 10, 0); }
    return calc(true, 0, depth, 0, 10, 0);
  }
  int ans = 0;
  if (depth == 0) {
    ans = calc(true, 1, 0, 0, 10, 0) + calc(true, 1, 0, 0, 0, 1);
  } else {
    ans = calc(true, 0, depth, 0, 10, 0) + calc(true, 0, depth, 0, 0, 1);
  }
  return ans % MOD;
}

int main() {
  while (cin >> A >> B >> M) {
    int ans = 0;
    MEMSET(dp, -1);
    FOR(i, 0, B.size()) {
      ans = (ans + ZigZag(i)) % MOD;
    }
    swap(A, B);
    Minus();
    MEMSET(dp, -1);
    FOR(i, 0, B.size()) {
      ans = (ans - ZigZag(i) + MOD) % MOD;
    }
    cout << ans << endl;
  }
}

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

int main(){
    int a=0,c=1,aux=0;
    cin>>a;
    int arr[a];

    for(int i=0; i<a; i++){
        cin>>arr[i];
    }
    for(int i=0; i<a; i++){
            
        if(i==0)aux=arr[i];
        
        else if(arr[i]<=aux){
            aux=arr[i];
            c++;
    }
}
cout<<c;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll cnt[200010];
int main() {
	ll n,m;
	cin>>n>>m;
	string a[52],b[52];
	bool ans=false;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<m;i++){
		cin>>b[i];
	}
	for(ll i=0;i+m-1<n;i++){
		for(ll j=0;j+m-1<n;j++){
			bool ch=true;
			for(ll k=0;k<m;k++){
				for(ll l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l]){
						ch=false;
					}
				}
			}
			if(ch){
				ans=true;
			}
		}
	}
	cout << (ans?"Yes":"No");
	// your code goes here
	return 0;
}

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

int i;

double a, b, c;
double pi = 3.141592653589793;
double s, l, h;
int main (){
        cin >> a >> b >> c;

        c *= pi / 180.0;

        s = a * b * sin(c) / 2;
        l = a + b + pow(a * a + b * b - 2 * a * b * cos(c), 0.5);
        h = 2 * s / a;

        cout << setprecision(100) << s << " " << l << " " << h << endl;
        return 0;
}



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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int n,k;
    while (cin >> n >> k, n) {
        vector<ll> a(n);
        REP(i,n) cin >> a[i];
        vector<ll> sum(n+1,0);
        REP(i,n) {
            sum[i+1] = sum[i] + a[i];
        }
        ll ans = 0;
        for (int i=k; i<n+1; i++) {
            ans = max(ans, sum[i] - sum[i-k]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

  vector<int> t(n);
  rep (i, n) cin >> t[i];

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

  int lt = t[0] + k;
  int p = 1;
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (t[i] <= lt && p < c)
      p++;
    else {
      ans++;
      p = 1;
      lt = t[i] + k;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
ll ans,sum=0;
map<ll,ll> map;
int N,Q,A;
cin>>N;
rep(i,N){
    cin>>A;
    sum+=A;
    map[A]++;

}
cin>>Q;
ll B,C,ansl[Q];
rep(i,Q){
cin>>B>>C;
sum+=(C-B)*map[B];
if(map[B]>0){
map[C]+=map[B];
map[B]=0;

}
ansl[i]=sum;
}
rep(i,Q){
cout<<ansl[i]<<endl;
}
return 0;
}

Measured memory_bytes: 10116
use std::io;

fn main() {
    while true {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        let _m: i32 = iter.next().unwrap().trim().parse().unwrap();
        let _n_min: i32 = iter.next().unwrap().trim().parse().unwrap();
        let _n_max: i32 = iter.next().unwrap().trim().parse().unwrap();

        if _m == 0 {
            break;
        }

        let mut P: Vec<i32> = Vec::new();

        for _ in 0.._m {
            let mut line = String::new();
            io::stdin().read_line(&mut line).unwrap();
            P.push(line.to_string().trim().parse::<i32>().unwrap());
        }

        let mut dif: i32 = 0;
        let mut ans: i32 = 1;
        for n in _n_min.._n_max + 1 {
            let temp = P[(n - 1) as usize] - P[n as usize];
            //println!("{}", temp);
            //println!("{}", P[n as usize]);
            if temp >= dif {
                dif = temp;
                ans = n;
            }
        }

        println!("{}", ans);
    }
}


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

int main() {
  string s;
  cin >> s;
  
  bool ans = true;
  if (s[0] != 'A') {
    ans = false;
  }

  int c_count = 0;
  int c_index = 0;
  for (int i = 2; i < s.length() - 1; i++) {
    if (s[i] == 'C') {
      c_count += 1;
      c_index = i;
    }
  }

  bool lower = true;
  if (c_count != 1) {
    ans = false;
  } else {
    for (int i = 1; i < s.length(); i++) {
      if (i == c_index) {
        continue;
      }
      if (!(s[i] >= 'a' && s[i] <= 'z')) {
        lower = false;
      }
    }
  }
  if (!lower) {
    ans = false;
  }

  if (ans) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

pii operator-(pii l, pii r){ return pii(l.first - r.first, l.second - r.second); }
ll operator/(pii l, pii r){ return (ll)l.first * r.second - (ll)l.second * r.first; }
ll operator*(pii l, pii r){ return (ll)l.first * r.first + (ll)l.second * r.second; }

const int MX = 1000005;

struct point{
	pii p;
	int ad;
} D[MX];
int N;
double ans[MX];

pii r90(pii x){ return pii(x.second, -x.first); }
ll sq(ll x){ return x*x; }
ll size2(pii x){ return sq(x.first) + sq(x.second); }

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d%d", &D[i].p.first, &D[i].p.second), D[i].ad = i;

	int mn = 1;
	for(int i = 2; i <= N; i++) if( D[mn].p > D[i].p ) mn = i;
	swap(D[mn], D[1]);
	for(int i = 2; i <= N; i++) D[i].p = D[i].p - D[1].p;
	D[1].p = pii(0, 0);
	sort(D+2, D+N+1, [](point l, point r){
		return l.p/r.p == 0 && size2(l.p) < size2(r.p) || l.p/r.p > 0;
	});

	vector<point> L;
	for(int i = 1; i <= N; i++){
		while(L.size() >= 2 && (L[L.size()-2].p - L.back().p) / (D[i].p - L.back().p) >= 0) L.pop_back();
		L.push_back(D[i]);
	}
	L.push_back(L[0]);
	L.push_back(L[1]);

	for(int i = 1; i+1 < L.size(); i++){
		pii u = r90(L[i].p - L[i-1].p), v = r90(L[i+1].p - L[i].p);
		ans[L[i].ad] = atan2(u/v, u*v) / 2/PI;
	}
	for(int i = 1; i <= N; i++) printf("%.20lf\n", ans[i]);
}
	


Measured memory_bytes: 13696
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <set>
#include <queue>
using namespace std;
#define N 500050
int head[N],to[N<<1],nxt[N<<1],cnt,n,a[N],p[N],du[N],K,Q[N],ans[N];
set<int>S,T;
priority_queue<int>q;
inline void add(int u,int v) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt; du[v]++;
}
int main() {
	scanf("%d%d",&n,&K);
	int i,x,lq=0;
	for(i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i;
	for(i=1;i<=K;i++) S.insert(a[i]);
	for(i=1;i<=n;i++) {
		set<int>::iterator it;
		it=S.upper_bound(a[i]);
		if(it!=S.end()) add(p[*it],i);
		it=T.upper_bound(a[i]);
		if(it!=T.end()) add(p[*it],i);
		T.insert(a[i]);if(i-K+1>=1) T.erase(a[i-K+1]);
		if(i+K<=n) S.insert(a[i+K]); S.erase(a[i]);
	}lq=n;
	for(i=1;i<=n;i++) if(!du[i]) q.push(i);
	while(!q.empty()) {
		x=q.top(); q.pop();
		Q[lq--]=x;
		for(i=head[x];i;i=nxt[i]) {
			if((--du[to[i]])==0) q.push(to[i]);
		}
	}
	for(i=1;i<=n;i++) ans[Q[i]]=i;
	for(i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 46464
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

bool isPrime(int N){
  if(N<=1) return false;
  if(N==2) return true;
  if(N%2==0) return false;

  for(int i=3 ; i*i<=N ; i+=2){
    if(N % i == 0) return false;
  }

  return true;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> pset;

  for(int i=0 ; i<=5555 ; i++){
    if((int)pset.size() == N) break;
    if(isPrime(10*i+1)) pset.push_back(10*i+1);
  }

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

  return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        x: usize,
        mut m: [usize;n],
    }

    let mut ret = x;
    for i in 0..n {
        ret -= m[i];
    }
    m.sort();
    let mut cnt = 0;
    while ret>=m[0]{
        ret -= m[0];
        cnt += 1;
    }
    println!("{}", n+cnt);
}


Measured memory_bytes: 2120
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, k;


ll solve() {
    ll l = 0, r = n;
    ll res = 0;
    for (int i = 1; i <= n+1; i++) {
        if (i >= k) {
            res += r - l + 1;
            res %= mod;
        }
        l += i;
        r += n-i;
    }
    return res;
}

void input() {
    cin >> n >> k;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3608
def sum_from_1(k):
    return k * (k + 1) // 2


def main():
    answer = 0
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())
    for i in range(k, n + 2):
        answer += sum_from_1(n) - sum_from_1(n - i) - sum_from_1(i - 1) + 1
        answer %= mod
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9184
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;


int main()
{
    long long n,m;
    while(cin>>n>>m)
    {
        long long sum;
        sum=(n-2)*(m-2);
        if(sum<0) cout<<-sum<<endl;
        else cout<<sum<<endl;
    }
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 1; i < s.size(); i += 2) {
        if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll d;
    d = n / (a + b) * a + min(n % (a + b), a);
    cout << d << endl;
    return 0;
}



Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
Q, R = divmod(C, B)
q, r = divmod(A, D)
if R > 0:
    Q = Q + 1
if r > 0:
    q = q + 1
if Q <= q:
    print('Yes')
elif Q > q:
    print('No')


Measured memory_bytes: 9120
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  unordered_map<long, long> foo;
  foo[0]++;

  long current = 0;
  rep (i, N) {
    current += A[i];
    foo[current]++;
  }

  long result = 0;
  for (auto it: foo) result += it.second * (it.second - 1) / 2;

  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 10056
import java.util.Scanner;


public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24276
package main
 
import("fmt")
 
func main(){
  var x int
  fmt.Scanf("%d",&x)
  for i:=x; ; i++ {
    for j:=2; j<i; j++ {
      if i%j == 0 {
        goto F1
      }
    }
    fmt.Printf("%d",i)
    return
    F1:
  }
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int n,c,b[10],i,j;
	while(1){
		for(i=0;i<10;i++){
			b[i]=0;
		}
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d",&c);
			b[c]=b[c]+1;
		}
		for(i=0;i<10;i++){
			for(j=0;j<b[i];j++){
				printf("*");
			}
			if(b[i]==0){
				printf("_");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int op(int a, int b) { return max(a, b); }
int e() { return int(0); }
int main() {
    int N,K;
    cin >> N >> K;
    vector<int>cnt(300005,0);
    segtree<int, op, e> ST(cnt);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        int res = ST.prod(max(0,A-K),min(300000,A+K)+1)+1;
        if(cnt[A] < res) {
            ST.set(A,res);
        }
        ans = max(ans,res);
    }
    cout << ans << endl;
}

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

#define inf 100000000000

int main()
{

    int n,m,l;
    cin>>n>>m>>l;
    long long arr[400][400];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            {
                if(i==j)
                    arr[i][j]=0;
                arr[i][j]=inf;
            }
    }

    for(int i=1;i<=m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        arr[u][v]=arr[v][u]=w;
    }

    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
                if(arr[i][j] > arr[i][k]+arr[k][j])
                    arr[i][j]= arr[i][k]+arr[k][j];
        }
    }

     long long arr1[400][400];
      for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
          {
            arr1[i][j]= arr[i][j]<=l? 1:inf;
            if(i==j)
                arr1[i][j]=0;
          }


          for(int k=1;k<=n;k++)
            {
                for(int i=1;i<=n;i++)
                {
                    for(int j=1;j<=n;j++)
                        if(arr1[i][j] > arr1[i][k]+arr1[k][j])
                            arr1[i][j]= arr1[i][k]+arr1[k][j];
                }
            }

            int q;
            cin>>q;
            for(int i=1;i<=q;i++)
            {
                int u,v;
                cin>>u>>v;
                if(arr1[u][v]==inf)
                    cout<<-1<<endl;
                else
                cout<<arr1[u][v]-1<<endl;
            }






    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define N 101

ll knapsack2(vector<pll> a,ll w,ll n){
	vector<ll> prev(w+1,0),nxt(w+1);
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=w;j++){
			if(a[i-1].first<=j){
				nxt[j] = max(prev[j],a[i-1].second + prev[j-a[i-1].first]);
			}
			else{
				nxt[j] = prev[j];
			}
		}
		prev = nxt;
	}
	return prev[w];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,w;
	cin>>n>>w;
	vector<pll> a(n);
	for(ll i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	ll x=0,i=0;
	cout<<knapsack2(a,w,n)<<endl;
}


Measured memory_bytes: 1792
N, K = map(int, input().split())
ab = [() for i in range(N)]
for i in range(N):
    ab[i] = tuple(map(int, input().split()))
    
ab.sort()
prev_ind = 0
cur_ind = 0
for (a, b) in ab:
    cur_ind = cur_ind + b
    if prev_ind < K and K <= cur_ind:
        print(a)
        break
    prev_ind = cur_ind

Measured memory_bytes: 19000
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

#define MAX 200200
int V,E;
set<int> S[MAX];

int main() {
  cin >> V >> E;
  rep(i,E) {
    int s,t;
    cin >> s >> t;
    --s, --t;
    S[s].insert(t);
    S[t].insert(s);
  }
  REP(i,1,V-1) {
    if( S[i].count(0) && S[i].count(V-1) ) { puts("POSSIBLE"); return 0; }
  }
  puts("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 28416
#include <iostream>

#define MAX_N 999999

unsigned long long int n;
bool cache[MAX_N+1];

void make_cache(void)
{
    for (int i = 0; i <= MAX_N; i++) {
        cache[i] = true;
    }

    for (int i = 2; i <= MAX_N; i++) {
        if (cache[i]) {
            for (int j = i + i; j <= MAX_N; j += i) {
                cache[j] = false;
            }
        }
    }
}

void solve(void)
{
    int count = 0;
    for (int i = 2; i <= n; i++) {
        if (cache[i]) count++;
    }
    std::cout << count << std::endl;
}
        

int main(void)
{
    make_cache();
    while (std::cin >> n) {
        if (n == 0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1836
q=[]
qqq=0
while(True):
    x,y = map(int, input().split())
    if(x==0 and y == 0):
        break
    q.append(0)
    for a in range(x):
        for b in range(x-a-1):
            for c in range(x-a-b-2):
                if(a + 1 + a + b + 2 + a+ b+c +3 == y):
                    q[qqq]+=1
    qqq+=1
for ww in q:
    print(ww)


Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int n,h,w;cin>>n>>h>>w;
    int a[n],b[n];
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]>=h&&b[i]>=w){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		// map
		Map<Integer, Integer> mapCityAndRoad = new HashMap<Integer,Integer>();
		
		Scanner sc = new Scanner(System.in);
		int numCity = sc.nextInt();
		int numRoad = sc.nextInt();
		
		for(int i=1;i<=numCity;i++){
			
			mapCityAndRoad.put(i, 0);
		}
		
		for(int i=0;i<numRoad*2;i++){
			
			int tmpCity = sc.nextInt();
			int tmpNumRoad = (int)mapCityAndRoad.get(tmpCity);
			mapCityAndRoad.put(tmpCity, tmpNumRoad+1);
		}

		for(int i=1;i<=numCity;i++){
			
			System.out.println(mapCityAndRoad.get(i));
		}
		return;
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
int main(void)
{
 int a=0;
 int W,H,x,y,r=0;
 scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W){
    if(y-r>=0&&y+r<=H){
     a=1;
    }
  }
  else{
  a = 0;
 }
  if(a==1){
  printf("Yes\n");
 }
 else if(a==0){
 printf("No\n");
}

 return 0;
}

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

int main(){

  int n, d, a[1000]={};
  string x;

  cin>>n>>x>>d;

  for(int i=0;i<n;i++){
    if(d==0) break;
    if(x[i]=='0'){
      x[i]='1';
      d--;
    }else a[i]=1;
  }

  if(d){
    for(int i=n-1;i>=0;i--){
      if(d==0) break;
      if(a[i]==1){
	x[i]='0';
	d--;
      }
    }
  }

  cout<<x<<endl;
  
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (auto& x : A) {
        cin >> x;
    }

    int T = accumulate(A.begin(), A.end(), 0);
    int c = 0;

    for (auto x : A) {
        if (4 * M * x >= T) {
            ++c;
        }
    }

    if (c >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    double ans = 0.0;
    REP(i, n){
        double x;
        string s;
        cin >> x >> s;
        if(s == "BTC"){
            x *= 380000.0;
        }
        ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <string>
#include <cstdlib>
#include <stdexcept>
using namespace std;


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

    int max_digit = 9;
    for (int j = 0; j < max_digit; ++j) {
        int candidate = (j+1) * 111;
        if(N <= candidate) {
            cout << candidate << endl;
            break;
        }
    }

    return 0;
}

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

int main() {
  
  string S, T; cin >> S >> T;
  
  int ans = 1001;
  
  for (int i = 0; i < S.size() - T.size() + 1; i++) {
    
    int memo = 0;
    
    for (int j = 0; j < T.size(); j++) {
      
      if (S.at(i + j) != T.at(j)) memo++;
      
    }
    
    ans = min(ans, memo);
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
import numpy as np
import sys

N, W = [int(v) for v in input().strip().split(' ')]
dp = np.zeros(W + 1, dtype = 'uint64')

for _ in range(N):
    w, v = [int(v) for v in sys.stdin.readline().split(' ')]
    np.maximum(dp[:-w] + v, dp[w:], out = dp[w:])

print(dp[W])


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

using namespace std;
using ll = long long;


int main()
{
    int a; cin >> a;
    int s = a % 60;
    int m = (a / 60) % 60;
    int h = (a - m * 60 - s) / 3600;
    cout << h << ":" << m <<":" << s << endl;
}


Measured memory_bytes: 3116
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split()) )for _ in range(m)]
lst=sorted(l,key=lambda x: x[1],reverse=True)
cur=0
for i in lst:
    tmpb=i[0]
    while (tmpb!=0 and cur<=len(a)-1):
        if a[cur]<i[1]:
            a[cur]=i[1]
            cur+=1
            tmpb-=1
        else:
            break
            
result=0
for i in a:
    result+=i
print(result)

Measured memory_bytes: 33640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int n, k;
int p[10];

void dfs(int c, int d) {
    if (d == n) {
        for (int i = 0; i < n; i++) {
            char t = 'a' + p[i];
            cout << t;
        }
        cout << '\n';
        return;
    }
    for (int i = 0; i <= c; i++) {
        p[d] = i;
        dfs(max(c, i + 1), d + 1);
    }
}

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

    cin >> n;

    dfs(0, 0);

    cout << flush;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
//#include <iomanip>
//#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){

	string s,ans;
	int n,h,cnt,pos;

	while (1){
		cin >> s;
		if (s == "-")break;

		cin >> n;
		cnt = 0;
		pos = 0;

		for (int i = 0; i < n; i++){
			cin >> h;
			cnt += h;
		}

		pos = cnt % s.length();
		s = s + s;
		ans = s.substr(pos, s.length() / 2);
		cout << ans << endl;

	}


	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
int a,b,c,d,e;
string s,ss,sss;
cin>>a>>b>>c;
cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int main () {
  int N;
  ll A, B;
  cin >> N >> A >> B;
  ll X[100010];
  for (auto i = 0; i < N; i++) {
    cin >> X[i];
  }
  ll ans = 0;
  for (auto i = 1; i < N; i++) {
    ans += min((X[i]-X[i-1]) * A, B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    
    int count = 0;
    string prev = "";
    
    for(int i=0;i<s.length();)
    {
        string present = {s[i]};
        
        if(prev.length() != 2 && present == prev && i<s.length())
        {
            present = s.substr(i, 2);
            i++;
        }
        
        i++;
        
        if(present == prev) break;
        
        count++;
        prev = present;
    }
    
    cout << count << endl;
    
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(long long n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(long long n, long long k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(void){
    ll N; cin >> N;
    vector<ll> C(N); REP(i,N) cin >> C[i];
    SORT(C);
    mint ans(0);
    FOR(i,1,N+1) ans += (N-i+2)*C[i-1];
    ans *= mint(4).pow(N-1);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 1792
#import<cstdio>
int main(){for(int n,a,c,r,t;c=r=scanf("%d",&n),n;printf("%d\n",r))for(char d[]="123546",s[9];n--;r+=*d-48)scanf("%s",s),*s%6-4?a=*s%5+*s%2*2+c&3,t=*d,*d=d[++a],d[a]=d[5],d[5]=d[a=++a%4+1],d[a]=t:c+=*s+3;}

Measured memory_bytes: 0
# coding: utf-8
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

INF = float('inf')
dp = [[INF for j in range(V+1)] for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for sum_v in range(V+1):
        # i番目の品を取る
        if v[i] <= sum_v:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
        # i番目の品を取らない
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

for sum_v in range(V+1):
    if dp[N][sum_v] <= W:
        ans = sum_v
print(ans)

Measured memory_bytes: 326452
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(l[K-1])

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

int main(){
  int n;
  cin>>n;
  map<pair<int,int>, int> count;
  for(int i=0; i<n; ++i){
    double a;
    cin>>a;
    long long j=(llround)(a*1e9);
    int two=0, five=0;
    while(j%2==0){
      ++two; j/=2;
    }
    while(j%5==0){
      ++five; j/=5;
    }
    ++count[{two, five}];
  }
  long long ans=0;
  for(auto p1: count){
    for(auto p2: count){
      if(p1.first.first+p2.first.first>=18 && p1.first.second+p2.first.second>=18){
        if(p1<p2){
          ans+=(long long)p1.second*p2.second;
        }
        if(p1==p2){
          ans+=(long long)p1.second*(p1.second-1)/2;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;
using work = tuple<int, int, int>;

int main(){
	int N;
	cin >> N;
	int C;
	cin>>C;
	vector<char> use(C, 0);
	vector<work> order;
	REP(i, N){
		int a, b, c;
		cin >> a >> b >> c;
		--c;
		order.push_back(make_tuple(a, -1, c));
		order.push_back(make_tuple(b, 1, c));
	}
	sort(ALL(order));
	int ans = 0;
	int sum = 0;
	foreach(i, order){
		if(use[get<2>(i)])--sum;
		use[get<2>(i)]+=get<1>(i);
		if(use[get<2>(i)])++sum;
		ans=max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4980
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    u = list(map(int, input().rstrip('\n').split()))
    d = list(map(int, input().rstrip('\n').split()))
    for i in range(1, n):
        u[i] += u[i-1]
        d[-i-1] += d[-i]
    mt = 0
    for i in range(n):
        mt = max(mt, u[i] + d[i])
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int a,b,c;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    else if(a==c)cout<<b<<endl;
    else if(b==c)cout<<a<<endl;
    return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

	vl a(n);
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	SORT(a);

	cout << a[0] << " " << a[n - 1] << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
ll power(ll a, ll b,ll m)
{
  a%=m;
  ll ans=1;
  if(a==0)  ans=0;
   
  while(b>0)
  {
    if(b&1)   ans=(ans*a)%m;
    a=(a*a)%m,  b>>=1;
  }
  return ans;}

int main()
{ 

ll x,y;
cin>>x>>y;

if((x+y)%3)
cout<<0<<endl;

else
{
    ll a=y-(x+y)/3;
    ll b=x-(x+y)/3;
    if(a<0 or b<0 or a+2*b!=x or 2*a+b!=y)
    cout<<0<<endl;
    
    else
    {
        ll z=max(a,b);
        ll f[a+b+1];
        f[0]=1;
        for(ll i=1;i<a+b+1;i++)
        f[i]=(f[i-1]*i)%mod;
        
        ll inva=power(f[a],mod-2,mod),invb=power(f[b],mod-2,mod),ans=1;
    
        ans*=f[a+b];
        ans=(ans*inva)%mod;
        ans=(ans*invb)%mod;
        cout<<ans<<endl;
    }
}
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    string s1,s2,s3;
    string tmp1,tmp2,tmp3;
    string ans;
    string tmp;

    cin >> s1 >> s2 >> s3;

    tmp1=s1[0];
    tmp2=s2[0];
    tmp3=s3[0];

    ans=tmp1+tmp2+tmp3;

    transform(ans.begin(),ans.end(),ans.begin(),::toupper);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256