akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int max_n=10000001;
bool is_prime[max_n];
int sieve(int m,int n){
    int cnt=0;
    FOR(i,m,max_n+1){
        if(!is_prime[i]){
            ++cnt;
            for(int j=i;j<=max_n;j+=i) is_prime[j]=true;
        }
        if(cnt==n) break;
    }
    FOR(i,m,max_n+1)if(!is_prime[i]) return i;
}
int main(){
    int m,n;
    while(cin>>m>>n,m){
        memset(is_prime,0,sizeof(is_prime));
        cout<<sieve(m,n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 12900
#include <stdio.h>

int main(void) {

  int a, b, c;
  int i;
  int n = 0;

  scanf("%d %d %d", &a, &b, &c);

  /* a が b より小さいことを保証する */
  if (a > b) {
    int temp = a;
    a = b;
    b = temp;
  }

  for (i = a; i <= b; i++) {
    if ((c % i) == 0)
      n++;
  }

  /* 結果表示 */
  printf("%d\n", n);
  return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  LL N;
  cin >> N;
  vector<string> S(N);
  rep(i,N) cin >> S[i];
  map<char,LL> m;
  rep(i,N) m[S[i][0]]++;
  LL num[5];
  num[0]=m['M'], num[1]=m['A'], num[2]=m['R'], num[3]=m['C'], num[4]=m['H'];
  LL ans=0;
  rep(i,5){
    for(int j=i+1; j<5; j++){
      for(int k=j+1; k<5; k++) ans+=num[i]*num[j]*num[k];
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve(int &test) {
    int n, ans = 0;
    cin >> n;
    int cnt[n+1] = {0};
    for(int x = 1; x <= 100; x++) {
        for(int y = 1; y <= 100; y++) {
            for(int z = 1; z <= 100; z++) {
                int cal = x*x+y*y+z*z+x*y+x*z+z*y;
                if(cal <= n)cnt[cal]++;
            }
        }
    }
    for(int i = 1; i <= n; i++)
        cout << cnt[i] << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

   

    int t = 1;
   
    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= t; ++i){
        solve(i); 
    }

    cerr << time(start);
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
using namespace std;
int tmp[100010]={0};

int ans(int x){
  if(x<=0){             //先にxが負のところ処理しないと配列でセグフォ
    return 100000;
  }else if(tmp[x]!=0){
    return tmp[x];
  }else if(x<=5){
    tmp[x]=x;
    return tmp[x];
    //同じの５つ出すときから６つ出すときへの移動がどうやるかわからない
  }else if(x==6){
    tmp[x]=1;
    return tmp[x];
  }else if(x==9){
    tmp[x]=1;
    return tmp[x];
  }else if(x==36){
    tmp[x]=1;
    return tmp[x];
  }else if(x==81){
    tmp[x]=1;
    return tmp[x];
  }else if(x==216){
    tmp[x]=1;
    return tmp[x];
  }else if(x==729){
    tmp[x]=1;
    return tmp[x];
  }else if(x==1296){
    tmp[x]=1;
    return tmp[x];
  }else if(x==6561){
    tmp[x]=1;
    return tmp[x];
  }else if(x==7776){
    tmp[x]=1;
    return tmp[x];
  }else if(x==46656){
    tmp[x]=1;
    return tmp[x];
  }else if(x==59049){
    tmp[x]=1;
    return tmp[x];
  } else{
    //計算量が多いので配列に格納していった方がいい
   tmp[x]=min({ans(x-1),ans(x-6), ans(x-9), ans(x-36), ans(x-81), 
              ans(x-216), ans(x-729), ans(x-1296), ans(x-6561),
              ans(x-7776), ans(x-46656), ans(x-59049)})+1;
    return tmp[x];
  }
}

int main() {
  int res;
  cin >> res;
  cout << ans(res);
}


Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int main(void){
    int i, j, H, W;
    
    while(cin >> H >> W){
        if(H == 0 && W == 0)    break;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

pii safe_range(int s[], int t[], int m, int l) {
    pii ret = {0, m - 1};

    RREP(i, l) {
        if (t[i] > 0 && ret.first > 0) ret = {ret.first - 1, ret.second};
        else if (t[i] < 0 && ret.second < m - 1) ret = {ret.first, ret.second + 1};

        if (s[i] > 0) ret = {ret.first, ret.second - 1};
        else if (s[i] < 0) ret = {ret.first + 1, ret.second};
        if (ret.second < ret.first) return {-1, -1};
    }
    return ret;
}

int main() {
    int H, W, N, sr, sc;
    string S, T;
    cin >> H >> W >> N >> sr >> sc >> S >> T;

    int s[N], t[N];

    REP(i, N) {
        if (S[i] == 'D') s[i] = 1;
        else if (S[i] == 'U') s[i] = -1;
        else s[i] = 0;

        if (T[i] == 'D') t[i] = 1;
        else if (T[i] == 'U') t[i] = -1;
        else t[i] = 0;
    }
    pii range = safe_range(s, t, H, N);
    if (range.first > sr - 1 || sr - 1 > range.second) {
        cout << "NO" << endl;
        return 0;
    }

    REP(i, N) {
        if (S[i] == 'R') s[i] = 1;
        else if (S[i] == 'L') s[i] = -1;
        else s[i] = 0;

        if (T[i] == 'R') t[i] = 1;
        else if (T[i] == 'L') t[i] = -1;
        else t[i] = 0;
    }
    range = safe_range(s, t, W, N);
    if (range.first > sc - 1 || sc - 1 > range.second) {
        cout << "NO" << endl;
        return 0;
    }

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

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

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

int n,m,q;
vector<int> g[100000];
int v[100000],d[100000],c[100000];
int dp[11][100000];

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

	REP(i,11) fill(dp[i],dp[i]+100000,-1);

	cin>>n>>m;
	REP(i,m) {
		int x,y;cin>>x>>y;x--,y--;
		g[x].pb(y),g[y].pb(x);
	}
	cin>>q;
	REP(i,q) {
		cin>>v[i]>>d[i]>>c[i];
		v[i]--;
		dp[d[i]][v[i]]=i;
	}

	for(int i=10;i>0;i--) {
		REP(j,n) {
			if(dp[i][j]!=-1) {
				dp[i-1][j]=max(dp[i-1][j],dp[i][j]);
				for(auto u:g[j]) dp[i-1][u]=max(dp[i-1][u],dp[i][j]);
			}
		}
	}
	REP(i,n) cout<<(dp[0][i]==-1?0:c[dp[0][i]])<<endl;

	return 0;
}


Measured memory_bytes: 12024
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, A, B;
  scanf("%d%d%d", &n, &A, &B);
  if ((int64)A * B < n || n < A + B - 1) {
    puts("-1");
    return 0;
  }
  deque<int> ret;
  for (int i = 1; i <= A; ++i) {
    ret.push_back(i);
  }
  if (B > 1) {
    int q = (n - A) / (B - 1);
    int r = (n - A) % (B - 1);
    int cur = A + 1;
    for (int k = 0; k < B - 1; ++k) {
      int len = q + (k < r ? 1 : 0);
      for (int i = len - 1; i >= 0; --i) {
        ret.push_front(cur + i);
      }
      cur += len;
    }
  }
  for (int i = 0; i < ret.size(); ++i) {
    printf("%d%c", ret[i], " \n"[i + 1 == ret.size()]);
  }
  return 0;
}


Measured memory_bytes: 3456
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
A.sort()
#print(A)
C=[]
cnt=1
D=0
for i in range(N-1):
    if A[i]==A[i+1]:
        cnt+=1
    else:
        C.append(cnt-1)
        D+=cnt-1
        cnt=1
C.append(cnt-1)
D+=cnt-1
#print(C)


if D%2==0:
    print(len(C))
else:
    print(len(C)-1)

Measured memory_bytes: 55916
#include <iostream>

using namespace std;

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

  long long A[200000];


   long i;

   for (i=0;i<N;i++)
      cin >> A[i];

  long long DP[200000];
  long long SUM_A[200000];
  SUM_A[0] = A[0]; // on somme les impairs
  for (i=2;i<N;i+=2)
    SUM_A[i] = SUM_A[i-2] + A[i];


  DP[0] = 0;
  DP[1] = max(A[0],A[1]);

  for (i=3;i<=N;i++) {
    if (i % 2) { // si c'est 7, alors A_7 + DP(5) ou DP(6)
      DP[i-1] = max(DP[i-2],A[i-1]+DP[i-3]);
    }
    else { // si c'est 8
      DP[i-1] = max(SUM_A[i-2],DP[i-3]+A[i-1]);
    }
  }


   cout << DP[N-1] << endl;
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

// AtCoder Beginner Contest 140
int main(){

    int a;
    cin >> a;
    cout << a * a * a << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def f(A, n):
    A.sort()
    if A[-1] >= n:
        A[-1] -= n
    else:
        print("No")
        exit()


def main():
    H, W = map(int, input().split())
    import collections
    D = collections.defaultdict(int)
    for _ in range(H):
        s = input().strip()
        for c in s:
            D[c] += 1
    A = list(D.values())

    for i in range(H//2):
        for j in range(W//2):
            f(A, 4)
    if H % 2 == 1:
        for j in range(W//2):
            f(A, 2)
    if W % 2 == 1:
        for i in range(H//2):
            f(A, 2)
    if W % 2 == 1 and H % 2 == 1:
        f(A, 1)

    print("Yes")


if __name__ == '__main__':
    main()


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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

int main() {
    int X;
    cin >> X;
    if (X < 100) {
        cout << 0 << endl;
        return 0;
    }

    if (X % 100 == 0) {
        cout << 1 << endl;
        return 0;
    }

    int l1 = X % 10;
    int l2 = X % 100 - l1;

    int count = 0;
    count += l2 / 5;
    if (1 <= l1 && l1 <= 5) {
        count++;
    } else if (6 <= l1 && l1 <= 9) {
        count += 2;
    }

    if (X >= count * 100) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long calc(long n, long k)
{
    long sum = 0;
    while(n>0) {
        sum += (n%k);
        n/=k;
    }
    return sum;
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long min=n;
    long i;
    for(i=0; i<=n; i++) {
        long tmp = calc(i, 6) + calc(n-i, 9);
        if(min>tmp)
            min=tmp;
    }
    printf("%ld\n", min);
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	string S;
	cin >> S;
	llong S_size = S.size();

	string before = "";
	llong ret = 0;
	bool same_last = false;
	for (int i = 0; i < S_size; ++i) {
		string check;
		check += S[i];
		while (check == before && ++i < S_size) {
			check += S[i];
		}
		// cerr << check << endl;

		if (before == check)
			same_last = true;
		before = check;
		ret++;
	}

	if (same_last) ret--;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 640
n=int(input())
matrix=[list(map(int,input().split())) for _ in range(n)]
weight=[]
for x in range(n):
    for y in range(x,n):
        if matrix[x][y]>=0: weight.append((x,y,matrix[x][y]))
weight.sort(key=lambda x:x[2])
ans=0
p=[i for i in range(n)]

def root(x):
    path_to_root=[]
    while p[x]!=x:
        path_to_root.append(x)
        x=p[x]
    for node in path_to_root:
        p[node]=x
    return x
    
def is_same_set(x,y):
    return root(x)==root(y)
    
def unite(x,y):
    p[root(x)]=root(y)
        
for x,y,w in weight:
    if not is_same_set(x,y):
        unite(x,y)
        ans+=w
print(ans)


Measured memory_bytes: 6248
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main() {
	string g;
	int y, m, d;
	while (cin >> g, g != "#") {
		cin >> y >> m >> d;
		if (y < 31 || (y == 31 && m <= 4)) {
			cout << g << " " << y << " " << m << " " << d << endl;
		}
		else {
			cout << "? " << (y - 30) << " " << m << " " << d << endl;
		}
	}
}


Measured memory_bytes: 3064
import sys
import numpy as np
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()


def convolve(x, y):
    MOD = 10**9+7
    z = np.convolve(x, y) % MOD
    z[:12] += z[13:25]
    return z[:13] % MOD


def main():
    mod = 10**9+7
    S = input()[::-1]
    dp = np.zeros((len(S), 13), dtype='int64')
    amari = 1
    if S[0] == '?':
        for j in range(10):
            dp[0][j] = 1
    else:
        dp[0][int(S[0])] = 1

    for i in range(1, len(S)):
        arr = np.zeros(13, dtype='int64')
        amari = 10*amari % 13
        if S[i] == '?':
            for si in range(10):
                arr[amari*si % 13] += 1
        else:
            arr[amari*int(S[i]) % 13] = 1
        dp[i] = convolve(dp[i-1], arr)

    print(dp[len(S)-1][5])


if __name__ == '__main__':
    main()

Measured memory_bytes: 37140
#include <stdio.h>
#include <stdlib.h>
int up(const void*a,const void*b){
    return*(int*)a<*(int*)b?-1:*(int*)a>*(int*)b?1:0;
}

void sort(int*a,int n){
    qsort(a,n,sizeof(int),up);
}
double min(double a,double b){
    return(a<b)?a:b;
}

double tansaku(int n,int i,int cango[][3600],int* num,double* e){
    if(num[i]<2)return 0;
    double E[n+1],Max=0;
    int maxj=0;
    
    for(int j=0;j<num[i];j++){
        if(Max<e[cango[i][j]]){
            Max=e[cango[i][j]];
            maxj=j;
        }
    }
     
    for(int j=0;j<i+1;j++)E[j]=0;
    for(int j=i+1;j<n+1;j++)E[j]=e[j];
    for(int j=0;j<num[i];j++){
        if(j!=maxj)E[i]+=E[cango[i][j]];
    }
    E[i]/=(num[i]-1);
    E[i]++;
    for(int j=i-1;j>0;j--){
        for(int k=0;k<num[j];k++){
            E[j]+=E[cango[j][k]];
        }
        E[j]/=num[j];
        E[j]++;
    }
    return E[1];
}

int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    int s[m],t[m];
    double EXP,EXP_tmp;
    for(int i=0;i<m;i++)scanf("%d%d",s+i,t+i);
    int cango[n][3600],num[n];
    for(int i=0;i<n;i++)num[i]=0;
    for(int i=0;i<m;i++){
        cango[s[i]][num[s[i]]]=t[i];
        num[s[i]]++;    //k
    }
    double e[n+1];
    for(int i=0;i<n+1;i++)e[i]=0;
    for(int i=n-1;i>0;i--){
        for(int j=0;j<num[i];j++){
            e[i]+=e[cango[i][j]];
        }
        if(num[i]>0)e[i]/=num[i];
        e[i]++;
    }
    EXP=e[1];
    
    for(int i=1;i<n;i++){
        EXP_tmp=tansaku(n,i,cango,num,e);
        //printf("%f\n",EXP_tmp);
        if(EXP_tmp>0)EXP=min(EXP,EXP_tmp);
    }
    
    printf("%f\n",EXP);
    return 0;
}


Measured memory_bytes: 8576
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 998244353;

int K;
int n;
int a[maxn];
int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>K>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int ret = K;
  for(int i=1;i<n;i++) {
    ret = min(ret, K - (a[i] - a[i - 1]));
  }
  ret = min(ret, K - (a[0] + K - a[n-1]));
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
const int BILL = 1e3;


int main()
{
    cin.sync_with_stdio(0);

    int N;
    cin >> N;

    cout << (BILL - N % BILL) % BILL;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

bool is_no_need(int num, vector<int>& A, int K)
{
  int ix = num - 1;
  int n = A.size();

  vector<int> v(A.begin(), A.begin() + ix);
  copy(A.begin() + ix + 1, A.end(), back_inserter(v));

  vector<vector<int>> dp(n, vector<int>(K + 5, false));
  dp[0][0] = 1;
  int M = v.size();
  for (int i = 0; i < M; ++i) {
    for (int sum = 0; sum <= K; ++sum) {
      dp[i + 1][sum] = dp[i][sum];
      if (sum - v[i] >= 0) {
        dp[i + 1][sum] |= dp[i][sum - v[i]];
      }
    }
  }
  bool ret = true;
  for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
    if (dp[M][sum]) {
      ret = false;
      break;
    }
  }
  return ret;
}

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

  sort(A.begin(), A.end());
  int high = N + 1, low = 0;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    if (is_no_need(mid, A, K)) { low = mid; }
    else { high = mid; }
  }

  int ans = low;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 98312
s=input()
s=set(s)
t=[ord(i) for i in s]
t.sort()
#print(t)
flag=0

for i in range(97,122+1):
  if t.count(i)==0 and flag==0:
    ans=i
    flag=1

print(chr(ans) if flag==1 else 'None')

Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main(){
	int s;
	cin >> s;
	int s1,s2;
	s1=s/100;
	s2=s-s1*100;
	if((s1>12 || s1==0) && s2!=0 && s2<=12){
		cout << "YYMM";
	}else if(s1!=0 && s1<=12 && (s2>12 || s2==0)){
		cout << "MMYY";
	}else if((s1==0 && s2==0) || (s1>12 && s2>12) || (s1==0 && s2>12) || (s1>12 && s2==0)){
		cout << "NA";
	}else{
		cout << "AMBIGUOUS";
	}
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint d(n);
    REP(i,n){
        cin >> d[i];
    }
    sort(ALL(d));
    n = n/2;
    cout << d[n]-d[n-1];

    return 0;
}

Measured memory_bytes: 640
from sys import stdin
import math


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    R = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 2*math.pi*R
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 62012
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Node {
    int id;
    Node left;
    Node right;
}

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

        for (int i = 0; i < n; i++) {
            String command = sc.next();
            if (command.charAt(0) == 'i') {
                int id = sc.nextInt();
                insert(id);
            } else if (command.charAt(0) == 'p') {
                System.out.println(inParse(root));
                System.out.println(preParse(root));
            } else if (command.charAt(0) == 'f') {
                int id = sc.nextInt();
                System.out.println(find(id));
            }
        }
    }

    public static void insert(int id) {
        Node insertedNode = new Node();
        insertedNode.id = id;

        if (root == null) {
            root = insertedNode;
            return;
        }

        Node node = root;
        while(true) {
            if (id < node.id) {
                if (node.left == null) {
                    node.left = insertedNode;
                    return;
                }
                node = node.left;
            } else {
                if (node.right == null) {
                    node.right = insertedNode;
                    return;
                }
                node = node.right;
            }
        }
    }

    public static String find(int id) {
        Node node = root;
        while(true) {
            if (node == null) {
                return "no";
            } else if (id == node.id) {
                return "yes";
            }

            if (id < node.id) {
                node = node.left;
            } else {
                node = node.right;
            }
        }
    }

    public static String preParse(Node node) {
        if (node == null) {
            return "";
        }
        return " " + node.id + preParse(node.left) + preParse(node.right);
    }

    public static String inParse(Node node) {
        if (node == null) {
            return "";
        }
        return inParse(node.left) + " " + node.id + inParse(node.right);
    }
}



Measured memory_bytes: 555576
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
 
    public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	char[] cArray = str.toCharArray();
    	int len = cArray.length;
    	for (int i = 0; i < len; i++) {
    		int b = (int)Character.toString(cArray[i]).getBytes()[0];
    		if (b >= 65 & b <= 90) {
    			cArray[i] = Character.toLowerCase(cArray[i]);
    		} else if (b >= 97 & b <= 122) {
    			cArray[i] = Character.toUpperCase(cArray[i]);
    		}
    	}
    	System.out.println(new String(cArray));
    }
}

Measured memory_bytes: 24532
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
fuko a;
int cmp(int u,int v){
return abs(u-*a/2)>abs(v-*a/2);
}
int main() {
int i,n=read();
for (i=1;i<=n;++i) a[i]=read();
sort(a+1,a+n+1),*a=a[n]; 
sort(a+1,a+n,cmp);
printf("%d %d",a[n],a[n-1]);
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


int main(){
   ll n; cin>>n;
   vector<ll>a(n);
   rep(i,n)cin>>a[i];
   sort(a.begin(),a.end());
   rep(i,n-1){
       if(a[i] == a[i+1]){
           cout<<"NO"<<endl;
           return 0;
       }
   }
   cout<<"YES"<<endl; 
}


Measured memory_bytes: 1792
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

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

int n;
int v[100005];
ll A, B, ans;

int main()
{
	scanf("%d%d%d", &n, &A, &B);
	
	FOR (i, 1, n)
		scanf("%d", &v[i]);
	
	int pr = v[1];
	FOR (i, 2, n) {
		ans += min(B, (v[i]-pr)*1LL*A), pr = v[i];
	}
	printf("%lld", ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+5, L = 18;
int st[N][L], A[N], n, rt;
int gt(int x) { for(int i=1;;i++) if((1<<i)>x) return(i-1); }
int get(int l, int r){
    int d = r-l+1;
    int g = gt(d);
    return(min(st[l][g], st[r-(1<<g)+1][g]));
}
int32_t main(){
    scanf("%lld", &n);
    for(int i=0;i<n;i++) scanf("%lld", &A[i]);
    for(int j=0;j<L;j++) for(int i=0;i<n;i++) if(i+(1<<j)<=n){
        st[i][j] = !j?A[i]:min(st[i][j-1], st[i+(1<<(j-1))][j-1]);
    }
    for(int i=0;i<n;i++){
        int l = 0, r = i;
        while(r-l>1){
            int mid = ((l+r)>>1);
            if(get(mid, i)!=A[i]) l = mid;
            else r = mid;
        }
        if(l<i && get(l, i)!=A[i]) l++;
        if(l && get(l-1, i)==A[i]) l--;
        int d1 = i-l;
        l = i, r = n;
        while(r-l>1){
            int mid = ((l+r)>>1);
            if(get(i, mid)!=A[i]) r = mid;
            else l = mid;
        }
        if(l>i && get(i, l)!=A[i]) l--;
        if(l^n && get(i, l+1)==A[i]) l++;
        int d2 = l-i;
        rt += A[i] * (d1+1)*(d2+1);
    }
    printf("%lld", rt);
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  int max = a+b;
  if (a-b > max) max = a-b;
  if (a*b > max) max = a*b;
  
  cout << max << endl;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	string s;
	cin >> s;
	if(s[5] == ',') s[5] = ' ';
	if(s[13] == ',') s[13] = ' ';
	cout << s << endl;
	return 0;
	
}

Measured memory_bytes: 256
H,N=map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]
dp = [[0]*(N+1) for _ in range(2*10**4+5)]

for j in range(1,H+1):
  for i in range(1,N+1):
    if AB[i-1][0] < j:
      dp[j][i] = dp[j - AB[i-1][0]][i] + AB[i-1][1]
    else:
      dp[j][i] = AB[i-1][1]
  MIN = min(dp[j][1:])
  dp[j][1:] = [MIN]*(len(dp[j])-1)

print(min(dp[H][1:]))

Measured memory_bytes: 228144
#include<iostream>
#include<string>

class dice {
public:
	int d1, d2, d3, d4, d5, d6, tmp;

	void set(int a1,int a2, int a3, int a4, int a5, int a6) {
		d1 = a1;
		d2 = a2;
		d3 = a3;
		d4 = a4;
		d5 = a5;
		d6 = a6;
	}
	void n(void) {
		tmp = d1;
		d1 = d2;
		d2 = d6;
		d6 = d5;
		d5 = tmp;
	}
	void s(void) {
		tmp = d1;
		d1 = d5;
		d5 = d6;
		d6 = d2;
		d2 = tmp;
	}
	void e(void) {
		tmp = d1;
		d1 = d4;
		d4 = d6;
		d6 = d3;
		d3 = tmp;
	}
	void w(void) {
		tmp = d1;
		d1 = d3;
		d3 = d6;
		d6 = d4;
		d4 = tmp;
	}
};


int main() {

	dice dice[100];
	std::string c;
	int a[7], i,j,k,f,u,n,found=0;

	c = "EEENEEENEEESEEESEEENEEEN";

	std::cin >> n;

	for (i = 0; i < n; i++) {
		for (j = 1; j < 7; j++) {
			std::cin >> a[j];
		}
		dice[i].set(a[1], a[2], a[3], a[4], a[5], a[6]);
	}

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

			for (k = 0; k < c.size(); k++) {

				if ((dice[i].d1 == dice[j].d1) && (dice[i].d2 == dice[j].d2) && (dice[i].d3 == dice[j].d3) && (dice[i].d4 == dice[j].d4) && (dice[i].d5 == dice[j].d5) && (dice[i].d6 == dice[j].d6)) {
					found = 1;
					break;
				}

				if (c[k] == 'N') dice[j].n();
				else if (c[k] == 'S')dice[j].s();
				else if (c[k] == 'E')dice[j].e();
				else if (c[k] == 'W')dice[j].w();
				else std::cout << "Error" << std::endl;
			}
		}
	}

	if (found == 1)std::cout << "No" << std::endl;
	else std::cout << "Yes" << std::endl;

	return 0;
}


Measured memory_bytes: 3200
// ConsoleApplication2.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <map>
#include <string>
using namespace std;

map<int, int> mp;
int main()
{
	map<int, int> ::iterator iter;
	int n, m;
	cin >> n >> m;
	long long cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		cnt += a;
		if (mp.count(a) == 1)
		{
			mp[a]++;
		}
		else
		{
			mp[a] = 1;
		}
	}
	do
	{
		iter = mp.end();
		iter--;
		if ((*iter).second >= m)
		{
			while (m)
			{
				cnt -= ((*iter).first - (*iter).first / 2);
				m--;
			}
		}
		else
		{
			m -= (*iter).second;
			int temp = (*iter).second;
			while (temp)
			{
				cnt -= ((*iter).first - (*iter).first / 2);
				temp--;
			}

			int temp1 = (*iter).first / 2;
			int temp2 = (*iter).second;
			mp.erase((*iter).first);
			if (mp.count(temp1) == 1)
			{
				mp[temp1] += temp2;
			}
			else
			{
				mp[temp1] = temp2;
			}
		}
	} while ((m != 0) && (cnt > 0));

	cout << cnt;

	return 0;
}


//int CalNP(vector <int> a, int pos, int len)
//{
//	int value = a[pos];
//	for (int i = 1; i < len; i++)
//	{
//		value *= a[pos + i];
//	}
//	return value;
//}
// 
//int main()
//{
//	int n;
//	int temp;
//	int N = 0;
//	int P = 0;
//	vector <int> a;
//	cin >> n;
//	for (int i = 0; i < n; i++)
//	{
//		cin >> temp;
//		if (temp < 0)
//		{
//			a.push_back(-1);
//		}
//		else
//		{
//			a.push_back(1);
//		}
//	}
//	for (int len = 1; len <= n; len++)//len
//	{
//		for (int j = 0; (j + len) <= n; j++)
//		{
//			if (CalNP(a, j, len)>0)
//			{
//				P++;
//			}
//			else
//			{
//				N++;
//			}
//		}
//	}
//
//	cout << N<<endl;
//	cout << P;
//}


//int main()
//{
//	int a1, a2, k1, k2, n;
//
//	cin >> a1;
//	cin >> a2;
//	cin >> k1;
//	cin >> k2;
//	cin >> n;
//
//	//先比较k1和k2的大小
//	if (k1 <= k2)
//	{
//		if(k1)
//
//	}
//
//
//	cout << "Hello World!\n";
//}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N,D,X; cin >> N >> D >> X;
    int A[N];
    for (int i=1;i<=N;i++) {
        cin >> A[i];
        for (int j=1;j<=((D-1)/A[i])+1;j++){
            X++;
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: i32 = read::<String>().parse().unwrap();
    let u = s / 100;
    let d = s % 100;
    let mut um = false;
    let mut dm = false;
    if u > 0 && u <= 12 {
        um = true;
    }
    if d > 0 && d <= 12 {
        dm = true;
    }
    if um && dm {
        println!("AMBIGUOUS");
    } else if um {
        println!("MMYY");
    } else if dm {
        println!("YYMM");
    } else {
        println!("NA");
    }
}

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


Measured memory_bytes: 4352
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

struct node_t{
    int value;
    struct node_t* left;
    struct node_t* right;
};

struct node_t* mallocNode(int adds) {
    struct node_t* add;

    add = (struct node_t*)malloc(sizeof(struct node_t));
    if (add == NULL) {
        return NULL;
    }

    add->left = NULL;
    add->right = NULL;
    add->value =  adds;

    return add;
}

int addNode(struct node_t* root, int tmps) {
    struct node_t* node;
    if (root == NULL) {
        root = mallocNode(tmps);
        return 0;
    }

    node = root;
    while (1) {
        if (tmps < node->value) {
            if (node->left == NULL) {
                node->left = mallocNode(tmps);
                return 0;
            }
            node = node->left;
        }
        else if (tmps > node->value) {
            if (node->right == NULL) {
                node->right = mallocNode(tmps);
                return 0;
            }
            node = node->right;
        }
        else {
            return 1; // 重複のときのみ1を返す
        }
    }

}


int main() {
    int i,j;
    int n;
    char s[11];
    char t[12];

    scanf("%s", s);
    scanf("%s", t);

    if(strncmp(s,t,strlen(s))==0 && strlen(s)+1 == strlen(t)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;

}

Measured memory_bytes: 1776
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=200100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
#include<map>
map<ll,int>f;
int n,i;ll ans,s;
int main(){
	//freopen("1.out","w",stdout);
	n=read();f[0]++;
	for(i=1;i<=n;i++){
		s+=read();
		ans+=f[s];f[s]++;
	}write(ans);puts("");
	return 0;
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	ll arr[n][3];
	ll dp[n][3];
	for(ll i=0;i<n;i++)
	for(ll j=0;j<3;j++)
	cin>>arr[i][j];
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(ll i=1;i<n;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][2],dp[i-1][0]);
		dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1000000007
#define ll unsigned long long int
ll bitZero[65];
ll bitOne[65];
ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res%mod;
}
void solve()
{
	ll n;
	cin>>n;
	vector<ll> vect(n);
	ll ans = 0;
	REP(i, n)
	{
		cin>>vect[i];
	}
	ll two_factor = 1;
	REP(i, n)
	{
		ll x = vect[i];
		for(int j=0; j<61; j++)
		{
			ll bit = 1LL<<j;
			if((x>>j)&1 == 1)
			{
				bitOne[j]++;
			}
			else
			{
				bitZero[j]++;
			}
		}
	}
	REP(i, 61)
	{
//		cout<<bitZero[i]<<" --- "<<bitOne[i]<<"\n";
		ans = (ans + ((bitOne[i] * bitZero[i] % mod) *power(2,i)) % mod) % mod;
//		two_factor = (two_factor * 2LL) % mod;
	}
	cout<<ans%mod<<"\n";
}
int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//	freopen("random_31", "r", stdin); 
	int t = 1;
//	cin>>t;
	REP(i, 64)
		bitZero[i] = 0, bitOne[i] = 0;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

const long long INF = 3e18 + 239;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    multiset<long long> S, T;
    S.insert(a);
    S.insert(b);
    if (a < b) {
        S.insert(a + 1);
        S.insert(b - 1);
    }
    if (a <= 0LL && 0LL <= b) S.insert(0LL);
    T.insert(c);
    T.insert(d);
    if (c < d) {
        T.insert(c + 1);
        T.insert(d - 1);
    }
    if (c <= 0LL && 0LL <= d) T.insert(0LL);
    long long res = -INF;
    for (long long x: S) {
        for (long long y: T) res = max(res, x * y);
    }
    cout << res;
    return 0;
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;

    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

P_NUM = 1000000007


def solv(n, m, a):
    comb_m2 = 1
    if 1 in a:
        comb_m1 = 0
    else:
        comb_m1 = 1

    for i in range(2, n+1):
        if i in a:
            comb_m1, comb_m2 = 0, comb_m1
        else:
            comb_m1, comb_m2 = (comb_m1 + comb_m2) % P_NUM, comb_m1

    return comb_m1


if __name__ == '__main__':

    n, m = map(int, input().split())
    if m:
        a = set(map(int, sys.stdin))
    else:
        a = set()

    ans = solv(n, m, a)

    print(ans)


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

ll s, c, ans;

int main(){
	cin >> s >> c;
	if(2 * s >= c){
		cout << (c / 2) << endl;
	}
	else{
		ans += s;
		c -= 2 * s;
		ans += (c / 4);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  int a =1000000,b=100,c=1;
  cin >> n ;
  vector<int> x(n);
  vector<int> y(100);
  vector<int> z(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    b=min(b,x[i]);
    c=max(c,x[i]);
  }
  for (int i = 0; i <= c; i++) {
    y[i]=i*i;
  }
  for (int i = b; i <= c; i++) {
    m=0;
    for (int ii = 0; ii < n; ii++) {
      m+=y[max(x[ii]-i,i-x[ii])];
    }
    a=min(a,m); 
  }
  cout << a << endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
x_n1 = Y[N//2 - 1]
x_n2 = Y[N//2]

for i in range(N):
	if X[i] <= x_n1:
		print(x_n2)
	else:
		print(x_n1)

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

using namespace std;
int main(int argc, char const *argv[])
{
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i];
    }

    vector<int> R;
    for(int i=N; i>0; --i) {

        int sum=0;
//        cout << i;
        for(int j=i*2; j<=N; j+=i) {
            sum += A[j-1];
 //           cout << " A[" << j << "] " << A[j-1] << ", ";
        }
//        cout << "sum=" << sum << endl;

        if( (sum%2) != A[i-1] ) {
            R.push_back(i);
            A[i-1] = 1;
//            cout << "A[" << i << "]=1" << endl;
        } else {
            A[i-1] = 0;
//            cout << "A[" << i << "]=0" << endl;
        }
    }

    cout << R.size() << endl;
    for(auto i: R) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2424
import java.util.*;

public class Main {
	static int swap=0;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] A =new int[N];
		for(int i=0;i<N;i++){
			A[i]=sc.nextInt();
		}
		BubbleSort(A);
		for(int i=0;i<N;i++){
			if(i==N-1){
				System.out.println(A[i]);
			}else{
				System.out.print(A[i]+" ");
			}
		}
		System.out.println(swap);
	}
	
	static void BubbleSort(int[] a){
		for(int i=0;i<a.length;i++){
			for(int j=a.length-1;j>i;j--){
				if(a[j]<a[j-1]){
					int t=a[j];
					a[j]=a[j-1];
					a[j-1]=t;
					swap++;
				}
			}
		}
	}
}

Measured memory_bytes: 26496
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    double l;
    double ans=0.0;
 
    cin>>l;
    ans=pow(l/3.0,3.0);

    //cout<<ans<<endl;
    printf("%.9lf",ans);
}

Measured memory_bytes: 384
B=[
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
]
]

def f(x):
    for k in range(3):
        word = ""
        for i in range(10):
            if i !=10:
                word = word +" "+str(B[x][k][i])
            else:
                word = word +str(B[x][k][i])
        print(word)


N = int(input())
K = []
for i in range(N):
    b, f, r, v = map(int, input().split())
    B[b-1][f-1][r-1] = B[b-1][f-1][r-1] + v

def f(x):
    for k in range(3):
        word = ""
        for i in range(10):
            if i !=10:
                word = word +" "+str(B[x][k][i])
            else:
                word = word +str(B[x][k][i])
        print(word)

f(0)
print("####################")
f(1)
print("####################")
f(2)
print("####################")
f(3)



Measured memory_bytes: 5620
#include <iostream>
#include <string>
using namespace std;
string s;
int main()
{
    int n, i, x;
    cin>>n;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]+n >'Z')
        {
            x = s[i]+n-'Z';
            s[i] = 'A'-1 + x;
        }
        else
            s[i] = s[i]+n;
    }
    cout<<s<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n;cin>>n;
    vector<ll> l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(),l.end(),greater<ll>());

    ll ans=0;
    rep(i,n-2){
        for(ll j=i+1;j<n-1;j++){
            for(ll k=j+1;k<n;k++){
                if(l[i]<l[j]+l[k] && l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k]) ans++;
            }
        }
    }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
using namespace std;

typedef long long LL;
int a[105];
int n,mn;
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+2+n);
	rep(i,1,n+1) {
		if (i&1) a[i]=24-a[i];
	}
	sort(a+1,a+2+n);
	mn=a[1]+24-a[n+1];
	rep(i,2,n+1) mn=min(mn,a[i]-a[i-1]);
	printf("%d\n",mn);
	return 0;
}


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

int main()
{
    int a,b; cin>>a>>b;
    cout<<ceil((b-1)*1.0f/(a-1))<<'\n';

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Measured memory_bytes: 70992
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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

  int r,g,b;
  cin >> r >> g >> b;
  int total = r * 100 + g * 10 + b;
  if(total % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256