akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0, M, K;
ll ret = 0;

int main(void){
  
  I(N);
  I(M);
  I(K);
  vl a(N);
  vl b(M);
  vl c(N+1);
  vl d(M+1);
  REP(i, N) {
    I(a[i]);
  }
  REP(i, M) {
    I(b[i]);
  }
  c[0] = 0;
  FOR(i, 1, N+1) {
    c[i] = c[i-1] + a[i-1];
  }
  d[0] = 0;
  REP(i, M) {
    d[i+1] = d[i] + b[i];
  }

  REP(i, N+1) {
    ll rest = K - c[i];
    if (rest < 0) break;
    auto itr = upper_bound(ALL(d), rest);
    itr--;
    // D(c[i]);
    // D(*itr);
    // BR;
    ll cnt = distance(d.begin(), itr) + i;
    chmax(ret, cnt);
  }
  
  P(ret);

}


Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	string s; cin >> s;
	map<char, bool> d;
	REP(i, s.size()) d[s[i]] = true;
	cout << (d['N'] == d['S'] && d['W'] == d['E'] ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    char s, s2, a, b, c, d;
    
    
        cin >> s >> s2 >> a >> b >> c >> d;
        if( a == b && c == d){
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
  int N;cin>>N;
  vector<int> W(N); for(auto &e:W) cin>>e;

  int sum = accumulate(W.begin(), W.end(), 0);
  vector<int> s1(N);
  s1[0] = W[0];
  for(int i=1;i<N;++i) s1[i] = s1[i-1] + W[i];

  vector<int> d(N);
  for(int i=0;i<N;++i) d[i] = abs(sum - s1[i] * 2);

  cout << *min_element(d.begin(), d.end()) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N, X;
ll x[100010];
//ll dist[100010];

ll gcd_euclid(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

int main() {
   cin >> N >> X;
   for (ll i=1;i<=N;i++) {
      cin >> x[i];
   }
   x[N+1] = X;
   sort(x, x+N+2);
   ll gcdval;
   ll dst;
   /*
   for (ll i=1;i<=N+1;i++) {
      cout << x[i] << endl;
   }
   */

   for (ll i=1;i<=N;i++) {
      dst = x[i+1] - x[i];
      if (i <= 1) {
         gcdval = dst;
      } else {
         gcdval = gcd_euclid(dst, gcdval);
      }
   }
   cout << gcdval << endl;
   return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstdio>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> P2;
P2 mk_P(int a,int b,int c){
  return P2(P(a,b),c);
}
int pow(int x,int y){
  if(y==0) return 1;
  int ret=pow(x,y/2);
  ret*=ret;
  if(y%2==1) ret*=x;
  return ret;
}
int main(){
  int L;
  cin>>L;
  int p=1,cnt=0;
  while(p<=L){
    p*=2;
    cnt++;
  }
  p/=2;
  cnt--;
  vector<P2> ans;

  for(int i=1;i<=cnt;i++){
    ans.push_back(mk_P(i,i+1,0));
    ans.push_back(mk_P(i,i+1,pow(2,i-1)));
  }
  int L2=L;
  L2-=pow(2,cnt);
  int c=1;
  int L3=pow(2,cnt);
  while(L2>0){
    if(L2%2==1){
      ans.push_back(mk_P(c,cnt+1,L3));
      L3+=pow(2,c-1);
    }
    L2/=2;
    c++;
  }
  cout<<cnt+1<<" "<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first.first<<" "<<ans[i].first.second<<" "<<ans[i].second<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
/*int main(){
	int a,b,result;
	cin>>a>>b;
	result=a-b;
	cout<<result<<endl;
}*/

int main(){
	int r,D,x;
	cin>>r>>D>>x;
	for(int i=0;i<10;i++){
		x=r*x-D;
		cout<<x<<endl;		
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    int c=0;
    cin>>s>>t;
    if(s[0]==t[0])c++;
    if(s[1]==t[1])c++;
    if(s[2]==t[2])c++;
    printf("%d",c);
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	ll sum=0;
	rep(i,n){
		cin >> a[i];
		sum+=a[i];
	}
	int ans_i = 0;
	ll nin = INF;
	ll now=0;
	rep(i,n){
		now+=a[i];
		if(nin>abs(sum/2-now)){
				if(i!=0&&i!=n-1){
					nin = abs(sum/2-now);
					ans_i = i;
			}
		}
	}
	ll aa=0;
	ll bb=0;
	rep(i,n){	
		if(i<=ans_i) aa+=a[i];
		else bb+=a[i];
	}
	cout << abs(aa-bb) << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;

namespace _0017
{
    class Program
    {
        public static string[] decoderStrings = { "the", "this", "that" };
        const int MAX_CHANGE_NUMBER = 25;

        static void Main(string[] args)
        {
            while (true)
            {
                var inputString = Console.ReadLine();

                if (string.IsNullOrEmpty(inputString))
                {
                    break;
                }

                for (int changeNumber = 0; changeNumber <= MAX_CHANGE_NUMBER; changeNumber++)
                {
                    inputString = Caesar(inputString);
                    if (inputString.Contains("the") || inputString.Contains("this") || inputString.Contains("that"))
                    {
                        Console.WriteLine(inputString);
                        break;
                    }
                }
            }
        }

        public static string Caesar(string sentence) 
        {
            char[] sentenceCharactor = sentence.ToCharArray();

            for (int i = 0; i < sentenceCharactor.Length; i++)
            {
                if (sentenceCharactor[i] >= 'a' && sentenceCharactor[i] <= 'z')
                {
                    if (sentenceCharactor[i] == 'z')
                    {
                        sentenceCharactor[i] = 'a';
                    }
                    else
                    {
                        sentenceCharactor[i] = (char)(sentenceCharactor[i] + 1);
                    }
                }
            }
            return new string(sentenceCharactor);
        }
    }
}

Measured memory_bytes: 6192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

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

	ll N, K, Q;
	cin >> N >> K >> Q;

	vector<ll>A (Q), point (N, 0);

	rep (i, Q) {
		cin >> A[i];
	}

	rep (i, Q) {
		++point[A[i] - 1];
	}

	rep (i, N) {
		if (K > Q) {
			cout << "Yes" << endl;
			continue;
		}

		if (point[i] == 0) {
			cout << "No" << endl;
		}
		else if (point[i] + K <= Q) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}



Measured memory_bytes: 2176
MOD = 10**9 + 7


def comb(n, k):
    if k > n - k:
        k = n - k
    ans = 1
    for i in range(1, k + 1):
        ans *= n + 1 - i
        ans *= pow(i, MOD - 2, MOD)
        ans %= MOD
    return ans


x, y = map(int, input().split())
a = 2 * y - x
b = 2 * x - y

if a < 0 or b < 0:
    ans = 0
elif a % 3 != 0 or b % 3 != 0:
    ans = 0
else:
    a //= 3
    b //= 3
    # print(a, b)
    ans = comb(a + b, a)

print(ans)


Measured memory_bytes: 40172
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    char s[3];
    int ans = 700;
    scanf("%s",s);
    for(int i=0; i<3; i++){
        if(s[i] == 'o'){
            ans += 100;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    string s;
    cin>>s;
    int x=0,y=0;
    x=10*(s[0]-'0')+(s[1]-'0');
    y=10*(s[2]-'0')+(s[3]-'0');
    if(x>=1&&x<=12){
        if(y>=1&&y<=12){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }
    }else{
        if(y>=1&&y<=12){
            cout<<"YYMM"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define unko signed
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int dp[10010][2][100];
//dp[i][isless][r]
unko main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string K;
	int D;
	cin >> K >> D;
	int N = K.size();
	//dp[0][1][0] = 1;
	dp[0][0][0] = 1;
	REP(i, N) {//i+1桁目について
		int pos = K[i] - '0';
			REP(j, 10) {//i+1桁目の数字
				REP(r, D) {
					if (j == pos) {
						dp[i + 1][0][(r + j) % D] += dp[i][0][r];
						dp[i + 1][1][(r + j) % D] += dp[i][1][r];
					}
					else if (j < pos) {
						dp[i + 1][1][(r + j) % D] += dp[i][0][r] + dp[i][1][r];
					}
					else {
						dp[i + 1][1][(r + j) % D] += dp[i][1][r];
					}
					dp[i + 1][0][(r + j) % D] %= MOD;
					dp[i + 1][1][(r + j) % D] %= MOD;
				}
			}
	}
	int ans = (dp[N][0][0] + dp[N][1][0]-1+MOD) % MOD;//この答えには「0」の分も含まれてるので1引いておく
	print(ans);
}


Measured memory_bytes: 15872
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 11/11/2018, 12:24:20 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int X, A, B;
  cin >> X >> A >> B;
  cout << (X - A) % B << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std;

const int N=300010;
int n,m,a[N],r[N],mx[N];

int main(){
    scanf("%d",&m); int n=1<<m;
    for (int i=0; i<n; i++) scanf("%d",&a[i]);
    for (int i=0; i<n; i++)
        for (int j=i; j<n; j=(j+1)|i)
            r[j]=max(r[j],a[i]+mx[j]),mx[j]=max(mx[j],a[i]);
    for (int i=1; i<n; i++) printf("%d\n",r[i]=max(r[i],r[i-1]));
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string s;
  cin >> s;

  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
using namespace std;

void solve() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<vector<int>> X(n, vector<int>(n));
  vector<vector<int>> Y(n, vector<int>(n));

  REP(i, n) {
    cin >> A[i];
    REP(j, A[i]) {
      cin >> X[i][j] >> Y[i][j];
      X[i][j]--;
    }
  }

  int ans = 0;
  bool ok = true;
  REP(bits, (1 << n)) {
    ok = true;
    REP(i, n) {
      if (!(bits & (1 << i)))
        continue;
      REP(j, A[i]) {
        if (bits & (1 << X[i][j]))
          ok &= Y[i][j];
        else
          ok &= !Y[i][j];
      }
    }
    if (ok)
      ans = max(ans, (int)__builtin_popcount(bits));
  }
  cout << ans << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,d,a,ans;
P xh[211111];
int range[211111],cond[211111];
int h[211111];
int x[211111];
int damage[214111];

signed main(){
    cin>>n>>d>>a;
    rep(i,n){
    	int x,h;
    	cin>>x>>h;
    	xh[i]={x,h};
    }
    
    sort(xh,xh+n);
    rep(i,n){
    	h[i]=xh[i].second;
    	x[i]=xh[i].first;
    }
    int r=0,sum=0;
    //rep(i,n)ARDEB(i,range)END
    rep(i,n){
    	int pos=distance(x,upper_bound(x,x+n,x[i]+d*2));
    	range[i]=pos;
    }
    
    rep(i,n){
    	h[i]-=damage[i];
    	if(h[i]>0){
    		int c=ceil2(h[i],a);
    		ans+=c;
    		damage[i]+=c*a;
    		damage[range[i]]-=c*a;
    	}
    	damage[i+1]+=damage[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll n; cin >> n;
    vl a(n);
    vl cnt(100005,0);
    rep(i,n){
        cin >> a[i];
        if(a[i]>0) cnt[a[i]-1]++;
        cnt[a[i]]++;
        cnt[a[i]+1]++;
    }
    ll ans = 0;
    rep(i,100001) ans = max(ans, cnt[i]);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n=in(); 
  vi a(n+1);
  rep(i,n) cin >> a[i+1];
  vi ball(n+1,0);
  int M = 0;
  for(int i=n; i>=1; --i){
    int num_ball = 0;
    int j=2*i;
    while(j<=n){
      //dump(i,j,ball[j]);
      num_ball += ball[j];
      j += i;
    }
    //dump(i,num_ball);
    if( (num_ball%2) != a[i]) { ball[i] = 1; M++; }
  }
  //dump(ball);
  cout << M << endl;
  rep(i,1,n+1) if(ball[i]==1) cout << i << " ";
  cout << endl;

  return 0;
}


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

ll C[55][55];
void cominit()
{
  for (int i=0; i<=50; i++) {
    for (int j=0; j<=i; j++) {
      if (j==0 || j==i) C[i][j] = 1LL;
      else C[i][j] = (C[i-1][j-1] + C[i-1][j]);
    }
  }
}

int main()
{
  ll n, a, b; cin >> n >> a >> b;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  sort(v.rbegin(),v.rend());
  cominit();

  double sum = 0;
  rep(i, a) sum += v[i];
  double ave = sum / a;

  ll x = 0;
  ll p = 0;
  for (int i=0; i<n; i++) {
    if (v[i] == v[a-1]) {
      x++;
      if (i < a) p++;
    }
  }

  ll ans = 0;
  if (p == a) {
    for (; p<=b; p++) {
      ans += C[x][p];
    }
  } else {
    ans += C[x][p];
  }

  printf("%.6lf\n", ave);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for(ll i = k; i <= n+1; i++){
        ll min = ((i*(i-1))/2);
        // cout << min << " ";
        // cout <<(n*(n+1))/2;
        ll max = ((n*(n+1) - (n-i)*(n-i+1))/2) ;
        // cout << max << " ";
        ll ans = (max - min +1)%mod;
        res = (res + ans) % mod;
    }
    cout << res;
}









Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N){
        cin>>A.at(n);
        A.at(n)-=n+1;
    }

    sort(ToEnd(A));
    int64_t b=A.at(A.size()/2);

    int64_t ans=0;
    for(auto a:A){
        ans+=abs(a-b);
    }

    cout<<ans<<endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 N, Q;
vector<int64> A, sum, bo; // bo -> 0 + 0 + ...

int main(void){
	cin >> N >> Q;
	A.resize(N); sum.resize(N+1, 0), bo.resize(N+1, 0);
	REP(i, N){
		cin >> A[i];
		sum[i+1] = sum[i]+A[i];
		bo[i+1] = bo[i]+(i%2 == (1-N%2) ? A[i] : 0);
	}
	auto ok = [&](int64 X, int64 x){ // xターン目に取る時，高橋くんが欲しいものをとれない
		int64 a = A[N-1-x];
		if(x == 0) return true;
		if(a <= X && x != 0) return false;
		int32 l = lower_bound(all(A), X-abs(X-a))-A.begin();
		int32 r = N-x-1;
		return ((r-l) >= x);
	};
	REP(i, Q){  
		int64 X;
		cin >> X;
		int32 l = 0, r = N/2+2, m;
		while(r-l > 1){
			m = (l+r)/2;
			if(ok(X, m))
				l = m;
			else
				r = m;
		}
		int64 res = sum[N]-sum[N-l-1]+(N-2*r < 0 ? 0 : bo[N-2*(l+1)]);
		cout << res << endl;
	}
}


Measured memory_bytes: 4096
A=[]
while True:
    try:
        A.append(sorted(list(map(int,input().split())),reverse=True))

    except:
        break

def triangle_types(X):
    num_of_normal = 0
    num_of_right = 0
    num_of_acute = 0
    num_of_obtuse = 0

    for i in range(len(X)):
        a,b,c = [X[i][j] for j in range(3)]
        if (a < b + c and b < a + c and c < a + b):
            num_of_normal +=1
            if (a**2 == b**2 + c**2):
                num_of_right += 1
            elif (a**2 < b**2 + c**2):
                num_of_acute +=1
            elif (a**2 > b**2 + c**2):
                num_of_obtuse += 1
        else:
            print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
            return


if __name__ == '__main__':
    triangle_types(A)


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

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    int sum2 = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x%4 == 0) {
            sum++;
        }
        else {
            if(x%2 == 0) {
                sum2++;
            }
        }
    }

    if(sum + (sum2/2) >= n/2) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


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


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define LL long long
#define DB double
#define M 400020
using namespace std;
int read() {
  int nm = 0, fh = 1;
  char cw = getchar();
  for (; !isdigit(cw); cw = getchar())
    if (cw == '-') fh = -fh;
  for (; isdigit(cw); cw = getchar()) nm = nm * 10 + (cw - '0');
  return nm * fh;
}
LL n, tot, d[M];
DB ans, fs, ed, k, dt;
int main() {
  n = read(), fs = read(), k = read();
  ed = fs + k * (n * 2 - 1);
  for (int i = (n << 1); i; i -= 2) {
    ans += ((fs + ed) / 2.0);
    fs += (fs * 2 + k * 5) / (i * 1.0);
    ed += dt = (ed * 2 - k * 5) / (i * 1.0);
    if (i > 2) k = (ed - fs) / ((i - 2) * 1.0 - 1.0);
  }
  printf("%.17lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
X = []
for i in range(N):
    X.append([int(i) for i in input().split(' ')])
    
import itertools
import math
Length = 0
for root in itertools.permutations(range(N)):
    length = 0
    
    for city in root:
        city_now = city
        if root.index(city) >0:
            length += math.sqrt(
                (X[city_now][0]-X[city_before][0])**2+(X[city_now][1]-X[city_before][1])**2)

        city_before = city
    Length += length
print(Length/math.factorial(N))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n,&x);

	if(n>12)printf("%d\n", x);
	else if (n > 5)printf("%d\n", x / 2);
	else printf("0\n");


	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int su = 0;
void solve(int n, char c, string s) {
  int sz = s.size();
  if (n == 0) {
    out(s);
    return;
  }
  for (char i = 'a'; i < c; ++i) {
    solve(n - 1, c, s + i);
  }
  solve(n - 1, c + 1, s + c);
  return;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  solve(n, 'a', "");
  return 0;
}


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

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

const long long INF = 1LL << 60;
const long long mod = 1000000007;

int main(void){
    int n; cin >> n;
    vector<int> a;
    int s=0;
    for(int i=0;i<n;i++){
	int tmp;cin >> tmp;
	s *= 10;
	s += tmp;
    }

    int e=0;
    for(int i=0;i<n;i++){
	int tmp;cin >> tmp;
	e *= 10;
	e += tmp;
    }
    for(int i=1;i<=n;i++){
	a.push_back(i);
    }
    int ans=0,ans_s,ans_e;
    do{
	int tmp=0;
	for(int i=0;i<n;i++){
	     tmp *= 10;
	     tmp += a[i];
	}   
	if(tmp==s){
	    ans_s = ans;
	}
	if(tmp==e){
	    ans_e = ans;
	}
	ans++;
    }while(next_permutation(a.begin(),a.end()));
	cout << abs(ans_s-ans_e) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	ll n, x, m; cin >> n >> x >> m;
	VI f(m,-1),s(m,0);
	ll a=x,sum=0,ans=-1;
	REP(i,n){
		if(f[a]>=0){
			ans=(sum-s[f[a]])*((n-f[a])/(i-f[a]))+s[(n-f[a])%(i-f[a])+f[a]];
			break;
		}
		if(a==0){
			break;
		}
		f[a]=i;
		sum+=a;
		s[i+1]=sum;
		a=a*a%m;
	}
	if(ans==-1)
		ans=sum;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4824
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

    ($iter:expr, $t:tt) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    macro_rules! out {
        ($fmt:expr) => {{
            let _ = out.write_fmt(format_args!($fmt));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    macro_rules! outln {
        ($fmt:expr) => {{
            out!(concat!($fmt,"
"));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "
"), $($args)*);
        }};
    }
    input! {
        source = src,
        n:usize,
        d:usize,
        xy:[(isize,isize);n],
    }

    out!(
        "{}",
        xy.iter()
            .filter(|(x, y)| ((x.pow(2) + y.pow(2)) as f64).sqrt() <= d as f64)
            .count()
    );
}
test! {
    include_str!("b1_in.txt") => "3",
    include_str!("b2_in.txt") => "7",
    include_str!("b3_in.txt") => "6",

}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

ll sento(ll a){
    while(a / 10LL > 0LL){
        a /= 10LL;
    }
    return a;
}

int main(){
    ll N;
    map<pii,int> memo;

    cin >> N;
    REP(i,1,N+1){
        ll a = sento(i);
        ll b = i%10LL;
        memo[make_pair(a,b)]++; 
    }
    ll ret = 0;
    for(auto itr=memo.begin(); itr!=memo.end(); itr++){
        pii rp = make_pair(itr->first.second, itr->first.first);
        ret += memo[itr->first] * memo[rp];
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s) + 1

A = [0] * n
for i in range(1, n):
    if s[i - 1] == "<":
        A[i] = A[i - 1] + 1

for i in range(n - 1, 0, -1):
    if s[i - 1] == ">":
        A[i - 1] = max(A[i - 1], A[i] + 1)

print(sum(A))


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

  int n; 
 long long int a[100000]={};
 long long int b[100000]={};
 long long int c[100000]={};

 long long int x[100000]={};

int main()
{
  cin >> n;

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

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

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

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  int na = n;
  int nb = n;
  int nc = n;

/*
  for(int i=0;i<n;i++){
    if( i == 0 || a[i] != a[i-1] ){
      a[na] = a[i];
      na++;
    }
  }

  for(int i=0;i<n;i++){
    if( i == 0 || b[i] != b[i-1] ){
      b[nb] = b[i];
      nb++;
    }
  }

  for(int i=0;i<n;i++){
    if( i == 0 || c[i] != c[i-1] ){
      c[nc] = c[i];
      nc++;
    }
  }
*/


  //bを選んだ時の選択肢
  int tmp = 0;
  for(int i=0;i<nb;i++){
    if( tmp == nc ){
      x[i] = 0;
    }
    else
    {
      while( c[tmp] <= b[i] && tmp < nc){
        tmp++;
        }
      x[i] = nc - tmp;
    }
  }

  for(int i= nb-2;i>=0;i--){
    x[i] = x[i] + x[i+1];
  }

  long long int ans = 0;

  tmp = 0;
  for(int i=0;i<na;i++){
    if( tmp == nb )
      break;
    while( b[tmp] <= a[i] && tmp < nb ){
      tmp++;
    }
    if( tmp == nb ){
      break;
    }
    else{
      ans += x[tmp];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for ( int i = 0; i < n; i++ ) cin >> a[i];
    sort(a.begin(), a.end());
    int an = a[n-1], ar=0;
    for ( int i = 0; i < n; i++ ) {
        if (abs(an-2*ar) > abs(an-2*a[i]) ) ar = a[i];
    }
    cout << an << " " << ar << '\n';
    return 0;
}

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

using namespace std;

typedef long long int ll;

const int mod=1e9+7;



int main()
{
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    int i;
    for(i=0;i<n;++i){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    ll sum=0;
    for(i=0;i<k;++i){
        sum+=arr[i];
    }
    cout<<sum;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int b[maxn];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&a[i]);
    for(int i=0;i<n;++i) scanf("%d",&b[i]);
    int ans=0;
    for(int v=(1<<28);v;v>>=1){
        int tp=0;
        for(int i=0;i<n;++i){
            a[i]&=((v<<1)-1);
            b[i]&=((v<<1)-1);
        }
        sort(a,a+n);
        sort(b,b+n);
        for(int i=n-1;i>=0;--i){
            int v1=lower_bound(b,b+n,v-a[i])-b;
            int v2=lower_bound(b,b+n,2*v-a[i])-b;
            int v3=lower_bound(b,b+n,3*v-a[i])-b;
            tp+=v2-v1+n-v3;
            tp&=1;
        }
        if(tp) ans|=v;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    string s; cin >> s;
    string ans="";
    ans+=s[0];
    ans+=s[1];
    ans+=s[2];
    cout << ans << endl;
return 0;
}



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

vector<vector<int>> abc;
vector<vector<long>> dp;

int main(void) {
	int N;
	cin >> N;
	abc = vector<vector<int>>(N, vector<int>(3));
	// a = 0,b = 1,c = 2として判定する
	for (int i = 0; i < N; i++) {
		cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
	}

	dp = vector<vector<long>>(N+1, vector<long>(3));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i < 3; i++) {
		dp[0][i] = abc[0][i];
	}
	for (int nday = 1; nday < N; nday++) {
		for (int action = 0; action < 3; action++) {
			for (int action2 = 0; action2 < 3; action2++) {
				if (action != action2) {
					dp[nday][action2] = max(dp[nday][action2],dp[nday - 1][action] + abc[nday][action2]);
				}
			}
		}
	}
	cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
	return 0;
}

Measured memory_bytes: 11136
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	vector<vector<ll>> binom_table;
	binom_table.push_back({});
	binom_table.back().push_back(1);
	for (ll n = 1; n <= N; n++) {
		binom_table.push_back({});
		for (ll r = 0; r <= N; r++) {
			auto b = [&binom_table](ll n, ll r) {
				if (0 <= r && r <= n) {
					return binom_table[n][r];
				} else {
					return (ll)0;
				}
			};
			binom_table.back().push_back(b(n-1, r-1)+b(n-1, r));
		}
	}
	vector<ll> vis(N);
	for (int i = 0; i < N; i++) {
		cin >> vis[i];
	}
	sort(vis.rbegin(), vis.rend());
	ll sum = 0;
	ll max_cnt = 0;
	ll min_cnt = 0;
	ll min_cnt_A = 0;
	for (ll i = 0; i < N; i++) {
		if (i < A) {
			sum += vis[i];
		}
		if (vis[i] == vis[0]) {
			max_cnt++;
		}
		if (vis[i] == vis[A-1]) {
			min_cnt++;
			if (i < A) {
				min_cnt_A++;
			}
		}
	}
	cout << fixed << setprecision(10) << (double)sum/(double)A << endl;
	if (max_cnt < A) {
		cout << binom_table[min_cnt][min_cnt_A] << endl;
	} else {
		B = min(B, max_cnt);
		ll cases = 0;
		for (ll n = A; n <= B; n++) {
			cases += binom_table[max_cnt][n];
		}
		cout << cases << endl;
	}
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int n,k,p[10000];

    int i,j,t;

    scanf("%d %d",&n,&k);

    for(i = 0;i <n;i++)
        scanf("%d",&p[i]);

    for(i=0;i<n-1;i++)
        for(j=i+1;j <n;j++)
        {
            if(p[i] > p[j])
            {
                t = p[i];
                p[i] = p[j];
                p[j] = t;
            }
        }

    int ans = 0;

    for(i = 0;i <k;i++)
        ans += p[i];


printf("%d\n",ans);

return 0;


}

Measured memory_bytes: 1720
/*
input
atcoder beginner contest

*/
#include<bits/stdc++.h>
using namespace std;
//using lint= long long ;
int main()
{
	int n;
	cin>>n;
	long long  a[n+5];
	long long cnt1=0,cnt2=0,sum=0;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sum=0;
	for(int i=0;i<n;i++)
	{
	 sum=sum+a[i];
		if(i%2==0)
		{
			if(sum<=0)
              {
              	
              	cnt1+=(1-sum);
              	sum=1;
              }

		}
		else 
		{
            if(sum>=0)
              {
              	
              	cnt1+=(sum+1);
              	sum=-1;
              }

		}
	}
	sum=0;
		for(int i=0;i<n;i++)
	{
		 sum=sum+a[i];
		if(i%2==1)
		{
			if(sum<=0)
              {
              	
              	cnt2+=(1-sum);
              	sum=1;
              }

		}
		else 
		{
            if(sum>=0)
              {
              	
              	cnt2+=(sum+1);
              	sum=-1;
              }

		}
	}
	cout<<min(cnt1,cnt2)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    
    int Ans=0;
    int S=1;
    for(int k=2;k*k<=N;k++){
        S=k;
        int n=N;
        while(n>0){
            int f = n%k;
            n/=k;
            if(f==0)continue;
            if(f==1){
                Ans++;
            }
            break;
        }
    }
    
    for(int p=1;p<S;p++){
        if((N-1)%p==0){
            Ans++;
        }
    }
    Ans++;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 0;
  int A = N /2;
  
  if(N%2 == 1) ans++;
  if(!(S.substr(0,A) == S.substr(A,A))) ans++;
  
  if(ans == 0){
    puts("Yes");
  }else{
    puts("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll calc(ll x, ll y) {
    return (y - x + 1) * (x + y) / 2;
}

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    rep(i, k, n + 2) {
        ans += calc(n - i + 1, n) - calc(0, i - 1) + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
INF = 1000000007

dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, N + 1):
	if i in a:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF

print(dp[N])

Measured memory_bytes: 13216
#include<iostream>

using namespace std;

int dp[5001];
int item[] = {200, 300, 500, 1000, 1200, 1500};
int price[] = {380, 550, 850, 1520, 1870, 2244};

int main()
{
  for(int i = 0; i < 5001; i++)
    dp[i] = 10000000;
  dp[0] = 0;
  for(int j = 0; j < 6; j++)
  {
    for(int i = 0; i < 5001; i += 100)
    {
      if(i + item[j] > 5000)
        continue;
      dp[i + item[j]] = min(dp[i + item[j]], dp[i] + price[j]);
    }
  }
  while(true)
  {
    int n;
    cin >> n;
    if(!n)
      break;

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

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  string s;
  cin >> s;
  if (s[0]==s[1] && s[1]==s[2]) puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 256