akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int n;
	cin >> n;
	
	while (n!=0) {
		std::vector<int> a(n);
		int r;
		int rn;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				rn = std::abs(a[i] - a[j]);
				if (i==0 && j==1) {
					r = rn;
				} else {
					if (rn < r) {
						r = rn;
					}
				}
			}
		}
		cout << r << endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
ll nCr(ll n,ll r){return nCr(n,r,MOD);}
int main(){
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	vi dp(n+1);
	dp[0]=1;
	loop(i,a,b+1){
		vi w(n+1);
		rep(j,n+1)w[j]=nCr(j,i);
		for(int k=n;k>=0;k--){
			ll co=1;
			rep(j,c-1)if(n-k+i*(j+1)<n+1)(co*=w[n-k+i*(j+1)])%=MOD;
			loop(j,c,d+1){
				if(k-i*j<0)break;
				(co*=w[n-k+i*j])%=MOD;
				(dp[k]+=co*dp[k-i*j]%MOD*powmod(fact[j],MOD-2,MOD)%MOD)%=MOD;
			}
		}
	}
	cout<<dp[n]<<endl;
}










Measured memory_bytes: 8064
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    n, m = map(int, rl().split())
    a = list(map(int, rl().split()))
    
    a.sort(reverse=True)
    sm = sum(a)
    d = sm / (4 * m)
    for i in range(m):
        if a[i] < d:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
/*最小値、最大値の値はわかっている
N = 1の時は例外的(A==B ならば 1, A != B ならば 0)
N > 1の時、　A > B　ならば　0,　A <= B の時がメイン
A, Bを一つずつ、残りの和の個数を考えると[(N-2)A, (N-2)B]の区間の((A-B)(N-2)個)
取りうる値が区間になることを見越した考察は、より高難易度な問題であっても、すごくたくさん出てくるらしい

A,Bがどのくらい出てくるかなど考えようとしていたが、A,B,Nは非常に大きくなりうるので考察する対象は和くらいしかないことに早く気付くべきだった。
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N, A, B; cin >> N >> A >> B;
  if (A > B) cout << 0 << endl;
  else if (N == 1) cout << (A == B ? 1 : 0) << endl;
  else cout << (N - 2) * (B - A) + 1 << endl;
} 
//補足: (条件式 ?　A:B )は　条件式が成り立つならA,成り立たないならB


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> 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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    string s;cin >> s;
    LL ans = 0;
    LL ss = 0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i] == 'R') ss++;
        else{
            chmax(ans, ss);
            ss = 0;
        }
    }
    chmax(ans, ss);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(){
  int h,t,n;
  char s[200001];
  scanf("%s",s);
  for(n=0;s[n]!='\0';n++);
  for(h=0;s[h]!='A';h++);
  for(t=n;s[t]!='Z';t--);

  printf("%d",t-h+1);
}


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

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

  n = n % k;

  long long prev_n = n;
  while(true) {
    n = abs(n - k);
    if (prev_n < n) break;
    prev_n = n;
  }

  cout << prev_n << "\n";
}


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

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int N;
  cin >> N;
  int A[N];
  bool flag=false;
  for(int i=0; i<N; i++)
    {
      cin >> A[i];
    }

  for(int i=0; i<N; i++)
    {
      if(A[i]%2==0)
	{
	  if((A[i]%3)==0 || (A[i]%5)==0)
	    {
	      
	    }
	  else
	    flag=true;
	}
    }

  if(flag)
    cout << "DENIED" << endl;
  else
    cout << "APPROVED" << endl;
  


  return 0;
}


//cout << setprecision(13);
//next_permutation(v.begin(), v.end());



Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
q=int(input())
ar=[0 for i in range (100000)]
tot=0
for i in range(n):
    ar[l[i]-1]+=1
    tot+=l[i] 
for j in range(q):
    a,b=map(int,input().split())
    val=0
    tot=tot-(a*ar[a-1])-(ar[b-1]*b)
    ar[b-1]+=ar[a-1]
    tot=tot+(ar[b-1]*b)
    ar[a-1]=0
    print(tot)

Measured memory_bytes: 20900
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n,m; cin >> n >> m;
    vector<int> a(m),b(m);
    for(int i = 0;i < m;i ++){
    cin >> a.at(i) >> b.at(i);
    a.at(i) -= 1;
    b.at(i) -= 1;
    }


    vector<vector<int> > itiran(n,vector<int>(0));
    for(int i = 0;i < m;i ++){
        itiran.at(a.at(i)).push_back(b.at(i));
        itiran.at(b.at(i)).push_back(a.at(i));
    }

    queue<int> q;
    q.push(0);

    vector<int> ans(n),itta(n);
    itta.at(0) = 1;

    while(q.size() > 0){
        int now = q.front();
        q.pop();
        for(int i = 0;i < itiran.at(now).size();i ++){
            int nownow = itiran.at(now).at(i);
            if(itta.at(nownow) == 1) continue;
            ans.at(nownow) = now;
            q.push(nownow);
            itta.at(nownow) = 1;
        }
    }

    cout << "Yes" << endl;

    for(int i = 1;i < n;i ++){
        cout << ans.at(i) + 1 << endl;
    }
}

Measured memory_bytes: 16868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1001001001;
const long long MOD = 998244353;
const double EPS = 1e-10;

struct UnionFind {
    vector<int> d;
    int cc_cnt;
    UnionFind(int n): d(n, -1) { cc_cnt = n; }
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        cc_cnt--;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

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

    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.unite(a,b);
    }
    cout<<(uf.cc_cnt-1)<<endl;
}

Measured memory_bytes: 3664
n, m = map(int,input().split())
li = list(map(int,input().split()))
ans = []

if n >= m:
    print(0)
    exit()

li.sort()

for i in range(m-1):
    ans.append(li[i+1]-li[i])

ans.sort(reverse=True)
print(sum(ans[n-1:]))

Measured memory_bytes: 13968
#include <iostream>
using namespace std;
 
int main() 
{
	long long i,j,n,ans=0;
	long m=0,a=0,r=0,c=0,h=0;
	string s[100001];
  	cin >> n;

	for(i=0;i<n;i++){
		cin >> s[i];
	} 
	for(i=0;i<n;i++){
		if(s[i][0]=='M'){
			m++;
		}
		if(s[i][0]=='A'){
			a++;
		}
		if(s[i][0]=='R'){
			r++;
		}
		if(s[i][0]=='C'){
			c++;
		}
		if(s[i][0]=='H'){
			h++;
		}
	} 
	ans=(m*a*r)+(m*a*c)+(m*a*h)+(m*r*c)+(m*r*h)+(m*c*h)+(a*r*c)+(a*r*h)+(a*c*h)+(r*c*h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
//Changing a Character

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
	int a,b;string s;cin>>a>>b>>s;
  s[b-1]+=32;
  cout<<s<<nnn;
    return 0;
}

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

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

    int ans10000 = -1, ans5000 = -1, ans1000 = -1; 

    for (int i = 0; i <= n; i++){
        for (int j = 0; j + i <= n; j++){
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y){
                ans10000 = i;
                ans5000 = j;
                ans1000 = k;
            }       
        }
    }
    cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef long  double ll;
ll MOD=1e9+7;
const ll MAX=1e18;
 
void solve(){
     int n=2;
     ll ans=1;
     ll a[n];
     for(auto &x:a)cin>>x;
     sort(a,a+n);
     for(int i=0;i<n;i++){
         ans*=a[i];
     }
     cout<<(long long int)ans<<endl;
}
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;t=1;
    // cin>>t;
    // cin.ignore();
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    vi v;
    si s;
    s.insert(1);
    v.pb(1);
    int x;
    while(1){
        int y=a[v[v.size()-1]-1];
        if(s.find(y)!=s.end()){x=y;break;}
        s.insert(y);
        v.pb(y);
    }   
    int sz,in;
    for(int i=0;i<v.size();i++){
        if(v[i]==x){
            in=i;
            sz=(v.size()-i);
            break;
        }
    }
    if(k<in){
        cout<<v[k]<<endl;
    }
    else{
        k-=(in);
        k%=sz;
        cout<<v[in+k]<<endl;
    }
} 


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

typedef long long i64;

vector <i64> luat, v;

bool cbin(i64 p, i64 x);

i64 n;

int main()
{
    i64 ans(0);
    cin >> n;
    v.resize(n);
    for (i64 i(0); i < n; i++)
        cin >> v[i];

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

    for (i64 i(n - 1); i >= 0; i--) {
        i64 p(0), q(1ll << 55);
        while (q) {
            if (cbin(i, p + q))
                p += q;
            q /= 2ll;
        }
        for (i64 j(i); j < n; j++)
            v[j] += (n - i - 1) * p - 1ll * n * p;
        for (i64 j(0); j < i; j++)
            v[j] += 1ll * (n - i) * p;
        ans += p * (n - i);
    }

    while (v[n - 1] >= n) {
        v[n - 1] -= n;
        for (i64 i(0); i < n - 1; i++)
            v[i]++;
        sort(v.begin(), v.end());
        ans++;
    }

    cout << ans;

    return 0;
}

bool cbin(i64 p, i64 x)
{
    if (v[p] - n * x + (n - p - 1) * x < n)
        return false;
    if (p && v[p] - n * x + (n - p - 1) * x < v[p - 1] + (n - p) * x)
        return false;
    return true;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define MD 998244353
using namespace std;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> vecA(N);
    vector<ll> vecB(N);
    rep(i, N)
    {
        ll a, b;
        cin >> a >> b;
        vecA[i] = a;
        vecB[i] = b;
    }
    sort(vecA.begin(), vecA.end());
    sort(vecB.begin(), vecB.end());
    if (N % 2 == 1)
    {
        ll x, y;
        x = vecA[N / 2];
        y = vecB[N / 2];
        cout << y - x + 1 << endl;
    }
    else
    {
        ll x, y;
        x = (vecA[N / 2]) + vecA[(N - 1) / 2];
        y = (vecB[N / 2]) + vecB[(N - 1) / 2];
        cout << y - x + 1 << endl;
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

const int inf = 1e9;
/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vi dp(n+1, inf);
    dp[0] = 0;
    rep(i, n+1){
        if(i+1 <= n)dp[i + 1] = min(dp[i+1], dp[i] + 1);
        if(i+6 <= n)dp[i + 6] = min(dp[i+6], dp[i] + 1);
        if(i+36 <= n)dp[i + 36] = min(dp[i+36], dp[i] + 1);
        if(i+216 <= n)dp[i + 216] = min(dp[i+216], dp[i] + 1);
        if(i+1296 <= n)dp[i + 1296] = min(dp[i+1296], dp[i] + 1);
        if(i+7776 <= n)dp[i + 7776] = min(dp[i+7776], dp[i] + 1);
        if(i+46656 <= n)dp[i + 46656] = min(dp[i+46656], dp[i]+1);
        if(i+9 <= n)dp[i + 9] = min(dp[i+9], dp[i] + 1);
        if(i+81 <= n)dp[i + 81] = min(dp[i+81], dp[i] + 1);
        if(i+729 <= n)dp[i + 729] = min(dp[i+729], dp[i] + 1);
        if(i+6561 <= n)dp[i + 6561] = min(dp[i+6561], dp[i] + 1);
        if(i + 59049 <= n)dp[i + 59049] = min(dp[i+59049], dp[i] + 1);
    }
    cout << dp[n] << '\n';
}

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

int main()
{
	int n, m, s=0, a=0, z=0;
	cin >> n >> m;
	
	for(int i=1; i<=n-1; i++)
	   s+=i;
	
	for(int j=1; j<=m-1; j++)
	   a+=j;
	   
	z=a+s;
	
	cout << z << endl;
	return 0;
} 

Measured memory_bytes: 256
module ABC158.C

let nums = stdin.ReadLine().Split(' ') |> Array.map int

let s = seq { 1 .. 1009 }

let seq8 = s |> Seq.filter (fun x -> int (floor (double (x) * 0.08)) = nums.[0])
let seq10 = s |> Seq.filter (fun x -> int (floor (double (x) * 0.1)) = nums.[1])

seq8
|> Seq.filter (fun x -> seq10 |> Seq.contains x)
|> Seq.tryHead
|> function
| Some x -> printf "%d" x
| None -> printf "-1"


Measured memory_bytes: 14168
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define in insert
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, s, e) FOR(i, e, s) cout << a[i] << ' '



using namespace std;

int main()
{
    int n, k, q; cin >> n >> k >> q;
    map<int, int> amn;
    int m = 0;
    FOR(i, q, 0)
    {
        int x; cin >> x;
        amn[x]++;
    }
    FOR(i, n + 1, 1)
    {
        if(k - q + amn[i] <= 0)cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 5376
h,w = map(int,input().split())
s = [input() for i in range(h)]

left =[[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0:
            if s[i][j] == '.':
                left[i][j] = 1
        else:
            if s[i][j] == '.':
                left[i][j] = left[i][j-1] + 1
            else:
                left[i][j] = 0

right =[[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w-1,-1,-1):
        if j == w-1:
            if s[i][j] == '.':
                right[i][j] = 1
        else:
            if s[i][j] == '.':
                right[i][j] = right[i][j+1] + 1
            else:
                right[i][j] = 0

forward =[[0 for _ in range(w)] for _ in range(h)]

for j in range(w):
    for i in range(h):
        if i == 0:
            if s[i][j] == '.':
                forward[i][j] = 1
        else:
            if s[i][j] == '.':
                forward[i][j] = forward[i-1][j] + 1
            else:
                forward[i][j] = 0

backward =[[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    for i in range(h-1,-1,-1):
        if i == h-1:
            if s[i][j] == '.':
                backward[i][j] = 1
        else:
            if s[i][j] == '.':
                backward[i][j] = backward[i+1][j] + 1
            else:
                backward[i][j] = 0

ans = 0
for i in range(h):
    for j in range(w):
        now = right[i][j]+left[i][j]+forward[i][j]+backward[i][j]-3
        ans = max(ans,now)

print(ans)

Measured memory_bytes: 188676
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int flag=0;
    while(n){
        int d=n%10;
        if(d==7) flag=1;
        n=n/10;
    }

    if(flag) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3596
import itertools
N = int(input())
K = int(input())

ans = 10 ** 18
for i in itertools.product('AB', repeat = N):
    tmp = 1
    for j in i:
        if j == 'A':
            tmp *= 2
        else:
            tmp += K
    # print (i, tmp)
    ans = min(ans, tmp)

print (ans)


Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int q;
LL a, b;

LL check(LL a, LL x) {
	LL left = 1, right = x + 1;
	while (left + 1 < right) {
		LL mid = (left + right) / 2;
		if ((a + mid)*(x + 1 - mid) > (a + mid - 1)*(x + 1 - mid + 1)) left = mid;
		else right = mid;
	}
	return left;
}


int main() {
	cin >> q;
	REP(Q, q) {
		cin >> a >> b;
		if (a > b) swap(a, b);
		int ans = a - 1;
		LL left = 0, right = b;
		while (left + 1 < right) {
			LL mid = (left + right) / 2;
			LL x = check(a, mid);
			if ((a + x)*(mid + 1 - x) < a*b) left = mid;
			else right = mid;
		}
		cout << ans + left << endl;
	}
}

Measured memory_bytes: 256
def month?(n)
  (1..12).include?(n)
end

def yymm?(str)
  month?(str[2..3].to_i)
end

def mmyy?(str)
  month?(str[0..1].to_i)
end

def detect_format(str)
  if yymm?(str) && mmyy?(str)
    'AMBIGUOUS'
  elsif yymm?(str)
    'YYMM'
  elsif mmyy?(str)
    'MMYY'
  else
    'NA'
  end
end

puts detect_format(gets.chomp)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
const string d="dream";
const string e="erase";

int main() {
  int n;
  map<string,int> name;
  vector<string> st;
  cin>>n;
  rep(i,n){
    string s;
    cin>>s;
    name[s]++;
    if(find(st.begin(),st.end(),s)==st.end())
      st.push_back(s);
  }
  int m;
  cin>>m;
  rep(j,m){
    string t;
    cin>>t;
    name[t]--;
    if(find(st.begin(),st.end(),t)==st.end())
      st.push_back(t);
  }
  
  int ans=0;
  for(auto u:st)
    ans=max(ans,name[u]);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
arr = input()

ac_count = [0]
ac = 0
for i in range(1, n):
    if arr[i-1:i+1] == "AC":
        ac += 1
    ac_count.append(ac)

ans = []

for _ in range(q):
    left, right = map(int, input().split())
    ans.append(ac_count[right-1] - ac_count[left-1])

print(*ans, sep="\n")

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

int main(void) {
    int N,M; cin >> N >> M;
    vector<int> Ans(N+10,0);
    int collect = 0, penalty = 0;
    for(int i=1; i<=M; i++) {
        int p; cin >> p;
        string S; cin >> S;
        if(Ans[p] != -1) {
            if(S == "WA") Ans[p]++;
            else if(S == "AC") {
            penalty += Ans[p];
            collect++;
            Ans[p] = -1;
            }
        }
    }
    cout << collect << " " << penalty << endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i;
	int x,y;
	int a;
	bool flg=false;
	cin>>n;
	int cnt=0;
	for(i=0;i<n;i++){
		cin>>a;
		flg=false;
		for(y=1;2*y*y+2*y<=a;y++){
			if((a-y)%(2*y+1)==0){
				flg=true;
			}
		}
		if(!flg){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3108
n, a, b = map(int, input().split())
mod = 10**9+7
c = pow(2,n,mod)
def nCr(n, r, mod):
	r = min(r, n-r)
	numer = denom = 1
	for i in range(1, r+1):
		numer = numer * (n+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod
c -= 1
aa = nCr(n,a,mod)
bb = nCr(n,b,mod)
c -= (aa+bb)
print (c%mod)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int c[2];
  	c[0] = c[1] = 0;
  	string s;
	cin >> s;
	rep(i, s.size()) {
    	c[s[i] - '0']++;
    }
  	cout << 2*min(c[0], c[1]) << endl;
}


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

int main()
{
  int N, n;
  cin >> N;
  vector<int> p;
  for (int i = 0; i < N; i++)
  {
    cin >> n;
    p.push_back(n);
  }
  if (is_sorted(p.begin(), p.end()))
  {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      if (p[i] > p[j])
      {
        swap(p[i], p[j]);
        if (is_sorted(p.begin(), p.end()))
        {
          cout << "YES" << endl;
          return 0;
        }
        swap(p[i], p[j]);
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3588
//再帰関数と深さ優先探索を使う

#include<cstdio>

using namespace std;

void dfs(int,int,int,int);

int cnt=0,num=0;

int main(void){
	int n,s,i=0,sum=0;	//n=組み合わせの数、s=合計
	
	while(1){
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)	break;
		dfs(n,s,i,sum);
		printf("%d\n",cnt);
		cnt=0;
		num=0;
	}

	return 0;
}

void dfs(int n,int s,int i,int sum){
	num++;
	while(1){
		if(i>=10-n+num){
			num--;
			break;
		}
		else{
			if(num==n){
				if(sum+i==s)	cnt++;
			}
			else{
				sum+=i;
				dfs(n,s,i+1,sum);
				sum-=i;
			}
		}
		i++;
	}
	return;
}

Measured memory_bytes: 0
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc052_b.cpp
 * time   : Sun May  3 01:37:19 2020
 * quest  : B - Increment Decrement
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x = 0, max_ans = -2; string s;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    max_ans = max(max_ans, x + (s[i] == 'D' ? -1 : 1));
    x += (s[i] == 'D' ? -1 : 1);
  }
  cout << max(0, max_ans) << "\n";
  return 0;
}


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

int main() {
	string str[50], tmp;
	int max_num = 0, max_length = 0, i, max = 1, max_str = 0, a[1001] = {};
	
	while (cin >> tmp) {
		for (i = 0; i < tmp.size(); i++) {
			if ('A' <= tmp[i] && tmp[i] <= 'Z')
				tmp[i] = tmp[i] + 'a' - 'A';
		}

		for (i = 0; i < max; i++) {
			if (str[i] == tmp) {
				a[i]++;
				if (max_str < a[i]) {
					max_str = a[i];
					max_num = i;
				}
				if (tmp.size() > max_length)
					max_length = (int)tmp.size();
				break;
			}
		}
		if (i >= max) {
			str[i-1] = tmp;
			max++;
			a[i - 1]++;
			if (max_str < a[i-1]) {
				max_str = a[i - 1];
				max_num = i - 1;
			}
			if (tmp.size() > max_length)
				max_length = (int)tmp.size();
		}
	}
	cout << str[max_num];

	for (i = 0; i < max; i++) {
		if ((int)str[i].size() == max_length)
			cout <<" "<< str[i] << endl;
	}
	return 0;
}

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

int max(int a, int b) {
    if (a >= b) return a;
    return b;
}

int knapSack() {

    int n, capacity; cin >> n >> capacity;
    int weight[n];
    int value[n];
    for (int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];

    int dp[n + 1][capacity + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= capacity; j++) {
            if (i == 0 or j == 0)
                dp[i][j] = 0;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= capacity; j++) {
            if (weight[i - 1] <= j)
                dp[i][j] = max(value[i - 1] + dp[i - 1][j - weight[i - 1]], dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    return dp[n][capacity];
}

int32_t main()
{
    cout << knapSack();
    return 0;
}

Measured memory_bytes: 79104
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    HashMap<Integer, Integer> freq = new HashMap<>();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      int aa = scanner.nextInt();
      freq.put(aa, freq.getOrDefault(aa, 0) + 1);
      a[i] = aa;
    }
    long res = 0;
    for (int f : freq.values()) {
      res += comb2(f);
    }
    res += 1 - freq.get(a[0]);
    System.out.println(res);
    for (int i = 1; i < N; i++) {
      res += 1 - freq.get(a[i]);
      res += freq.get(a[i - 1]) - 1;
      System.out.println(res);
    }
  }

  private static long comb2(long n) {
    if (n < 2) return 0;
    return n * (n - 1) / 2;
  }
}


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

int tax(int p, int x) {
	int ans;
	ans = (p * (100 + x) / 100);
	return ans;
}

int main(){
	int a, b, x, y, s, maxsum, tmpsum;
	while (1) {
		cin >> x >> y >> s;
		if (x == 0 && y == 0 && s == 0) break;
		maxsum = 0;
		a = 1;
		while (a <= s - 1) {
			b = 1;
			while (a + b <= s) {
				tmpsum = tax(a, x) + tax(b, x);
				if (tmpsum == s) {
					maxsum = max(maxsum, tax(a, y) + tax(b, y));
				}
				b++;
			}
			a++;
		}
		cout << maxsum << endl;
	}




	return 0; 
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e6;

int seg_tree[MAXN]= {0};
//int a[MAXN];

void recalculate(int node)  //get the current seg tree condition
{
	seg_tree[node] = min(seg_tree[2*node+1],seg_tree[2*node+2]);
}
void build_segtree(int node,int left,int right)  //node = array's size
{
	if (left == right)  //we are in a leaf node
	{
		seg_tree[node] = 2147483647;
		//cout << node << endl;
	}else
	{
		int mid = (left+right)/2;
		build_segtree(2*node+1,left,mid);
		build_segtree(2*node+2,mid+1,right);
		recalculate(node);
	}
}

void update(int node,int left,int right,int x,int y) //updete a[x] to y
{
	if (left == right)
	{
		seg_tree[node] = y;
	}else
	{
		int mid = (left+right)/2;
		if (x <= mid)
		{
			update(node*2+1,left,mid,x,y);
		}else
		{
			update(node*2+2,mid+1,right,x,y);
		}
		recalculate(node);
	}
}

ll query(int node,int left,int right,int x,int y) // query for [x,y]
{
	if (x <= left && right <= y)
	{
		return seg_tree[node];
	}else
	{
		ll ans = 2147483647;
		int mid = (left+right)/2;
		//cout << mid << endl;
		if (x <= mid) //search left
		{
			ans = min(ans,query(node*2+1,left,mid,x,y));
		}
		if (mid+1 <= y) //search right
		{
			ans = min(ans,query(node*2+2,mid+1,right,x,y));
		}
		//else (x,y) ^ (left,right) = emptyset , so return -INF

		return ans;
	}
}



int main()
{
	int n,q;
	cin >> n >> q;
	build_segtree(0,1,n);

	// for(int i = 0; i < 3*n; i++)
	// {
	// 	cout<< seg_tree[i] << " ";
	// }printf("\n");
	for(int i = 0; i < q; i++)
	{
		int com;
		int x,y;
		cin >> com >> x >> y;
		if (com == 0)
		{
			update(0,1,n,x+1,y);
		}else
		{
			cout << query(0,1,n,x+1,y+1) << endl;
		}
	}

	return 0;
}


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

constexpr int P = 998244353;

ll modinv(int n) {
    int m = P, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + P : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

ll dp[3001][3001];//i個まで見て和がjになるものが何通りあるか

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

    int n, s;
    cin >> n >> s;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll x = modinv(2);

    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        (dp[0][0] *= 2) %= P;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i + 1][j] = dp[i][j];
        }
        for (int j = a[i]; j <= s; j++) {
            (dp[i + 1][j] += dp[i][j - a[i]] * x) %= P;
        }
    }

    //if (dp[n][s] < 0) dp[n][s] += P;

    cout << dp[n][s] << endl;

    // すべてのSについて求めることにすると
    // f(全体)は求まった ちょうどi個でSを達成する通り数は求まらないか？
    // ばらばらに求まんなくてもいいから、1個増える毎に半分になるとかそういうのは

    return 0;
}

Measured memory_bytes: 73964
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
N+=1

def naive_solver(N):
    output=[]
    for i in range(1,N):
        A=str(i)
        for j in range(1,N):
            B=str(j)
            if A[-1]==B[0] and B[-1]==A[0]:
#                 if A[0]=="1":
                output.append([A,B])
    return output

def naive_solver2(N):
    dicts={str(i):{str(j):0 for j in range(10)} for i in range(10) }
    for i in range(1,N):
        temp=str(i)
        dicts[temp[0]][temp[-1]] += 1
    return dicts

dicts = naive_solver2(N)

import itertools as it

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under



dicts = naive_solver2(N)

count = 0
for si in range(1,10):
    i=str(si)
    for sj in range(si,10):
        j = str(sj) 
        
#         count += dicts[i][j] * dicts[j][i] * 2
        if j!=i:
            count+=dicts[i][j] * dicts[j][i] * 2#2*cmb(dicts[i][j]+dicts[j][i],2)    
#             print(si,sj,dicts[i][j] * dicts[j][i] * 2)#2*cmb(dicts[i][j]+dicts[j][i],2))
        else:
            count+=dicts[i][j]*dicts[j][i]#cmb(dicts[i][j]+dicts[j][i],2)
#             print(si,sj,dicts[i][j]*dicts[j][i])

print(count)

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, w;
    cin >> n >> w;

    vector<pair<int, int>> items(n);
    for(int i=0; i<n; i++){
        int vi, wi;
        cin >> vi >> wi;
        items[i] = make_pair(vi, wi);
    }

    vector<vector<int>> knap(n, vector<int>(w+1, 0));
    for(int i = items[0].second; i<=w; i++){
        knap[0][i] = items[0].first;
    }
    for(int i=1; i<n; i++){
        for(int j=0; j<=w; j++){
            if(j-items[i].second >= 0 && knap[i-1][j] < knap[i-1][j-items[i].second] + items[i].first){
                knap[i][j] = knap[i-1][j-items[i].second] + items[i].first;
            }
            else{
                knap[i][j] = knap[i-1][j];
            }
        }
    }
    cout << knap[n-1][w] << endl;

    return 0;
}


Measured memory_bytes: 10724
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

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

	set<int> A[n+1];
	int v1, v2;
	r(i, m){
		cin >> v1 >> v2;

		A[v1].insert(v2);
		A[v2].insert(v1);
	}

	//初期の未到達状態は0
	//必要に応じて連結成分ごとに1から順に分類
	int group[n]{};
	stack<int> s;

	int q, groupNum = 0, gn1, gn2;
	cin >> q;
	r(i, q){
		cin >> v1 >> v2;

		if(group[v1] == 0 && group[v2] == 0){
			groupNum++;

			s.push(v1);
			group[v1] = groupNum;

			while(!s.empty()){
				int v = s.top();
				int size = s(A[v]);
				for(int tmp : A[v]){
					if(!group[tmp]){
						s.push(tmp);
						group[tmp] = groupNum;
					}else{
						size--;
					}
				}
				if(!size)
					s.pop();
			}
		}

		gn1 = group[v1];
		gn2 = group[v2];
		//printf("group[%d]=%d, group[%d]=%d: ", v1, gn1, v2, gn2);
		printf(gn1 == gn2 ? "yes\n" : "no\n");
	}

	return 0;
}


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

using namespace std;

int main() {
	int n,l;
	cin >> n >> l;
	string* s = new string[n];
	for (int i = 0;i < n;i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0;i < n;i++) {
		cout << s[i];
	}
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
const double pi=acos(-1);
int n,L,T[3005],i,j,k;
double x,y,z;
int main(){
	scanf("%d%d",&n,&L);
	for(i=1;i<=n;++i)scanf("%d",T+i);
	for(i=1;i<n;++i)for(j=i+1;j<=n;++j){
		z=(T[i]+T[j])*pi/L;k=i-1+n-j-(j-i-1);
		x+=cos(z)*k;y+=sin(z)*k;
	}
	x/=1ll*n*(n-1)*(n-2)/6;y/=1ll*n*(n-1)*(n-2)/6;
	printf("%.12f %.12f\n",x,y);
	return 0;
}

Measured memory_bytes: 384
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,a,b;
    cin>>n>>a>>b;
    if(b<a){
        swap(a,b);
    }
    ll mid=(b-a)/2ll;
    if(mid+a==b-mid){
        cout<<mid;
        return 0;
    }
    ll cntr1=n-b+(n-(a+(n-b)))/2ll+((n-(a+(n-b)))%2ll);
    ll cntr2=a-1+((b-(a-1))-1)/2ll+((b-(a-1)-1)%2ll);
    cout<<min(cntr1,cntr2);
	exit(0);
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    cnt = [0 for _ in range(9)]
    for a in A:
        c = min([8, a // 400])
        cnt[c] += 1
    cnt_top = cnt[-1]
    n_color = 0
    for c in range(8):
        if cnt[c] > 0:
            n_color += 1
    min_n_color = max([1, n_color])
    max_n_color = n_color + cnt_top
    print('{} {}'.format(min_n_color, max_n_color))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <chrono>
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define MIN3(a, b, c) (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c))
#define endl "\n"
#define int long long
#define forn(i, n) for (long long i = 0; i < long long(n); ++i)
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
using namespace std;
inline bool is_palindrome(const string &s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
int32_t main()
{
    auto start = chrono::high_resolution_clock::now();
    IOS
    int n;
    cin>>n;
    vector<int> v(n),dp(n,0);
    for(int i=0;i<n;i++)
    cin>>v[i];
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    for(int i=2;i<n;i++)
    dp[i]  =  min(dp[i-2] + abs(v[i-2] - v[i]),dp[i-1] + abs(v[i-1] - v[i]));
    cout<<dp[n-1];
    auto end = chrono::high_resolution_clock::now();
    double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    //cout << fixed << time_taken;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  int result = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1 && a[i-1] % 2 == 1) {
      result++;
    }
  }
  cout << result;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
long double a,b,h,m,c,d1,d2;
int main()
{
	cin>>a>>b>>h>>m;
	d1=m/2.0+h*30.0;
	d2=m*6.0;
	d2=fabs(d1-d2);
	d2/=180.0;
	c=sqrt(2.0*a*b)*sqrt((a*a+b*b)/(2.0*a*b)-cos(d2*3.14159265358979323846264338327950L));
	cout<<fixed<<setprecision(15)<<c; 
}


Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, M;
vector<vector<int>> G;
vector<int> d;
vector<double> E, C;

double expectation(int u) {
  if (E[u] != -1) return E[u];

  double res = 0;
  rep(v, N) if (G[u][v]) res += expectation(v);
  res /= d[u];
  res += 1;
  return E[u] = res;
}

double coefficient(int v) {
  if (C[v] >= 0.0) return C[v];

  double res = 0.0;
  rep(u, N) if (G[u][v]) res += coefficient(u) / d[u];
  return C[v] = res;
}

int main() {
  cin >> N >> M;
  G.resize(N, vector<int>(N, 0));
  C.resize(N, -1.0);
  d.resize(N, 0);

  rep(i, M) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    G[s][t] = 1;
    ++d[s];
  }

  E.resize(N, -1);
  E[N - 1] = 0.0;
  expectation(0);

  C[0] = 1.0;
  coefficient(N - 1);

  double m = 0.0;
  rep(u, N) {
    if (d[u] == 1 && (C[u] - 1.0) < 1e-9) continue;
    rep(v, N) if (G[u][v]) {
      double deltaE = (d[u] == 1 ? -E[u] : (E[u] - E[v] - 1) / (d[u] - 1.0));
      m = min(m, C[u] * deltaE);
    }
  }

  printf("%.7lf\n", E[0] + m);

  return 0;
}


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

int main() {
  char X, Y;
  cin >> X >> Y;
  if (X < Y) {
    cout << "<" << endl;
  } else if (X > Y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


const int INF = 1 << 29;

auto solve() {
    string S;
    cin>>S;
    int n = S.length();
    int pb = 0;
    ll res = 0;
    REP(i,n) {
        if(S[i] == 'B') {
            pb++;
        } else {
            res += pb;
        }
    }

    return res;
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  
  for(int x = 0; x*10000 <= Y; ++x) {
    for(int y = 0; y*5000 <= Y; ++y) {
      int r = Y - 10000*x - 5000*y;
      if(0 <= r && r%1000 == 0 && x+y+r/1000 == N) {
        cout << x << " " << y << " " << r/1000 << endl;
        return 0;
      }
    }
  }
     
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 3632
import scala.io.StdIn.readLine
import scala.math.min

object Main extends App {
  val lines = Iterator.continually(readLine())

  val xs = {
    val xs = for {
      line       <- lines
      Array(n, x) = line.split(" ").map { _.toInt }
    } yield (n, x)

    xs.takeWhile { _ != (0, 0) }
  }

  val results = xs.map(solve)

  results.foreach(println)

  def solve(pair: (Int, Int)): Int = pair match {
    case (n, x) =>
      val m  = min(n, x)
      val zs = for {
        i <- 1 to m
        j <- i + 1 to m
        k  = x - i - j
        if j < k && k <= m
      } yield (i, j, k)

      zs.length
  }
}



Measured memory_bytes: 51828
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var limit uint64 = 1

func init() {
	for i := 0; i < 18; i++ {
		limit *= 10
	}
}

func main() {
	N := readlineint()[0]
	In := readlineint()

	for _, v := range In {
		if v == 0 {
			fmt.Println("0")
			return
		}
	}

	var previous_result uint64 = 1
	var result uint64 = 1
	for i := 0; i < N; i++ {
		previous_result = result
		result *= uint64(In[i])

		if result > limit || previous_result > result {
			fmt.Println("-1")
			return
		}
	}
	fmt.Println(result)
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var bufreader = bufio.NewReaderSize(os.Stdin, 1e6)

func readline() string {
	a, _, _ := bufreader.ReadLine()
	return string(a)
}

func readlineint() (result []int) {
	in := strings.Split(readline(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 8092