akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
using namespace std;

const int mod = 1000000007;

struct modint{
    //member variable

    long long x;

    //constructor

    modint(long long x = 0):x((x%mod+mod)%mod){}

    //operator

    modint& operator+=(const modint ob){
        if((x += ob.x) >= mod) x -= mod;
        return *this;
    }

    modint& operator-=(const modint ob){
        if((x += mod - ob.x) >= mod) x -= mod;
        return *this;
    }

    modint& operator*=(const modint ob){
        (x *= ob.x) %= mod;
        return *this;
    }

    modint operator+(const modint ob) const {
        modint res(*this);
        return res+=ob;
    }

    modint operator-(const modint ob) const {
        modint res(*this);
        return res-=ob;
    }

    modint operator*(const modint ob) const {
        modint res(*this);
        return res*=ob;
    }

    modint pow(long long index) const {
        if(!index){
            modint ob(1);
            return ob;
        }
        modint ob = pow(index>>1);
        ob *= ob;
        if(index&1) ob *= *this;
        return ob;
    }

    //for prime mod
    modint inverse() const {
        return pow(mod-2);
    }

    modint& operator/=(const modint ob){
        return (*this) *= ob.inverse();
    }

    modint operator/(const modint ob) const {
        modint res(*this);
        return res/=ob;
    }
};

struct combination{
    //member variable
    vector<modint> fact, invfact;

    //constructor
    combination(int n):fact(n+1),invfact(n+1){
        fact[0] = 1;
        for(int i=1; i<=n; i++){
            fact[i] = fact[i-1]*i;
        }
        invfact[n] = fact[n].inverse();
        for(int i=n; i>=1; i--){
            invfact[i-1] = invfact[i]*i;
        }
    }

    modint operator()(int n, int k){
        if(k < 0 || k > n) return 0;
        return fact[n]*invfact[k]*invfact[n-k];
    }
};

int main(){
    int n, k;
    cin >> n >> k;
    modint ans(1);
    if(k>=n-1){
        for(int i = n+1; i <= 2*n-1; i++){
            ans *= i;
        }
        for(int i = 1; i <= n-1; i++){
            ans /= i;
        }
        cout << ans.x << endl;
        return 0;
    }
    modint ans2(0);
    combination c(n);
    for(int i = 0; i <= k; i++){
        ans2 += c(n,i) * c(n-1, i);
    }
    cout << ans2.x << endl;
    return 0;
}

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

#define ll long long

using namespace std;

int b[105];

int a[105];

int main()
{
    int n,res = 0;
    cin >> n;
    for(int i = 1; i <= n - 1; i++)
    {
        cin >> b[i];
    }
    b[0] = 1e9;
    for(int i = 1; i <= n - 1; i++)
    {
        if(b[i] < b[i - 1]) a[i] = a[i + 1] = b[i];
             else a[i + 1] = b[i];
    }
    for(int i = 1; i <= n; i++)
    {
        res += a[i];
    }
    cout << res;
}


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

using namespace std;

const int mod = 1e9 + 7;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

int n;
vector<int> g[5000];
mint dp0[5000][5001][2];
mint dp1[5000][5001][2];
mint match[5001];
int sz[5000];

void dfs(int u, int p) {
  dp0[u][1][0] += 1;
  sz[u] = 1;
  for (int v : g[u]) if (v != p) {
    dfs(v, u);
    for (int i = 0; i <= sz[u]; i++) {
      for (int ii = 0; ii < 2; ii++) {
        dp1[u][i][ii] = dp0[u][i][ii];
        dp0[u][i][ii] = 0;
      }
    }
    for (int i = 0; i <= sz[u]; i++) {
      for (int j = 0; j <= sz[v]; j++) {
        for (int ii = 0; ii < 2; ii++) {
          for (int jj = 0; jj < 2; jj++) {
            // link
            dp0[u][i + j][ii ^ jj] += dp1[u][i][ii] * dp0[v][j][jj];
            // cut
            dp0[u][i][ii ^ jj ^ 1] += dp1[u][i][ii] * dp0[v][j][jj] * match[j];
          }
        }
      }
    }
    sz[u] += sz[v];
  }
}

int main() {
  match[2] = 1;
  for (int i = 4; i <= 5000; i += 2) {
    match[i] = (i - 1) * match[i - 2];
  }
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, -1);
  mint ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += dp0[0][i][0] * match[i];
    ans -= dp0[0][i][1] * match[i];
  }
  cout << ans << endl;
}

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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 998244353
#define INF 9999999

signed main()
{
  char c;
  cin >> c;
  (c <= 'Z') ? cout << "A\n" : cout << "a\n";
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];

            if (H % 3 == 0 || W % 3 == 0)
            {
                WriteLine(0);
                return;
            }
            var ans = Min(H, W);
            for (var i = 1; i < W; ++i)
            {
                var men = new long[3];
                men[0] = H * i;
                men[1] = (H / 2) * (W - i);
                men[2] = (H - H / 2) * (W - i);
                ans = Min(ans, men.Max() - men.Min());
            }
            for (var i = 1; i < H; ++i)
            {
                var men = new long[3];
                men[0] = W * i;
                men[1] = (W / 2) * (H - i);
                men[2] = (W - W / 2) * (H - i);
                ans = Min(ans, men.Max() - men.Min());
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 46708
import sys
t = list(map(int, list(input())))
t.append(7)
op = []

def dfs(x, i):
    if i == 4 or len(op) == 3:
        if x == 7:
            op.append('=')
            ans = ''
            for j in range(5):
                if j == 4:
                    ans += str(t[j])
                else:
                    ans += str(t[j]) + op[j]
            print(ans)
            sys.exit(0)
        return

    i += 1
    op.append('+')
    dfs(x + t[i], i)
    op.pop()

    op.append('-')
    dfs(x - t[i], i)
    op.pop()
    i -= 1

    return

dfs(t[0], 0)


Measured memory_bytes: 3064
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t,u;
//

signed main() {
  RAPID;
  IN3(s,t,u);
  YES(s[s.size()-1] == t[0] && t[t.size()-1] == u[0]);
}

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

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

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

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

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

class UnionFind {
private:
    vector<int> par, sizes;

public:

    UnionFind(int n = 100010) : par(n), sizes(n, 1) {
        rep(i, n) par[i] = i;
    }

    int root(int x) {
        if (x == par[x]) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return sizes[root(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind uf;
    set<int> roots;

    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        uf.unite(x, y);
    }

    rep(i, n) roots.insert(uf.root(i));
    cout << roots.size() << endl;
    return 0;
}


Measured memory_bytes: 5760
#pragma warning(disable:4996)
#include<stdio.h>
int min(int a, int b) { return a < b ? a : b; }
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d", min(c, b + a + 1) + b);
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s,t;
	cin>>n>>s>>t;
	int ret=0;
	REP(i,n+1) {
		bool d=true;
		REP(j,i) {
			if(s[n-1-j]!=t[i-1-j]) d=false;
		}
		if(d) ret=i;
	}
	cout<<2*n-ret<<endl;
}


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

int main (){
int n;

int r[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin >> n ; 
    cout << r[n-1] << endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	int N;
	int x = 0;
	int max = 0;
	scanf("%d",&N);

	char S[N];
	scanf("%s",S);

	for(int i = 0; i < N; i++){
		if(S[i] == 'I'){
			x++;
		}
		else{
			x--;
		}

		if(x > max){
			max = x;
		}
	}

	printf("%d\n",max);
	
	return 0;
}

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

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,k,m=0;
  cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i!=0){
      if(a[i]+a[i-1]>=k){
        m=i;
      }
    }
  }
  if(m==0)cout<<"Impossible";
  else{
    cout<<"Possible"<<endl;
    for(int i=1;i<m;i++) cout<<i<<endl;
    for(int i=n-1;i>=m;i--) cout<<i<<endl;
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  int a[200000];
  int p = 0;
  rep(i, n){
    cin >> a[i];
    p = p^a[i];
  }
  rep(i, n){
    int q = p^a[i];
    cout << q <<" ";
  }
  cout << endl;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      puts("No");
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

typedef long long ll;

main()
{
    ll n, x, t, a;
    cin >> n >> x >> t;
    a = n / x;
    if(n % x == 0){
        cout << a * t;
    }
    else{
        cout << (a+1) * t;
    }



}





///promy_pompom
//hello world


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define INF 1<<29
using namespace std;

int main(){
	int c[]={1000,500,100};
	int d[3];
int a,b;
while(scanf("%d%d",&a,&b),a|b){
	b-=a;
	for(int e=0;e<3;e++){
		int f=b/c[e];
		b-=f*c[e];
		d[e]=f;
	}
	printf("%d %d %d\n",d[2],d[1],d[0]);
}
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>
char s[524288];
int dp[4],dp2[4];
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	s[n]='1';
	n++;
	dp[2]=1;
	int ans=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<4;j++)
		{
			dp2[j]=dp[j];
			dp[j]=0;
		}
		for(int j=0;j<4;j++)
		{
			dp[j&1]+=dp2[j];
			if(dp[j&1]>=1000000007)
			{
				dp[j&1]-=1000000007;
			}
		}
		for(int j=0;j<4;j++)
		{
			if(i&1)
			{
				if(j==3)
				{
					continue;
				}
				dp[j|2]+=dp2[j];
				if(dp[j|2]>=1000000007)
				{
					dp[j|2]-=1000000007;
				}
			}
			else
			{
				dp[2+(j!=0)]+=dp2[j];
				if(dp[2+(j!=0)]>=1000000007)
				{
					dp[2+(j!=0)]-=1000000007;
				}
			}
		}
		if(s[i]=='1')
		{
			dp[0]=0;
			dp[1]=0;
		}
		else if(s[i]=='0')
		{
			dp[2]=0;
			dp[3]=0;
		}
		else
		{
			ans<<=1;
			if(ans>=1000000007)
			{
				ans-=1000000007;
			}
		}
	}
	ans-=dp[2];
	if(ans<0)
	{
		ans+=1000000007;
	}
	ans-=dp[3];
	if(ans<0)
	{
		ans+=1000000007;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nk[0];
			int k = nk[1];
			
			int ans = 1 + (n - k + k - 2) / (k - 1);
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13268
N, X = map(int, input().split())
x = [int(i) for i in input().split()]

def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a

ans = abs(x[0] - X)
for i in range(1, N):
    dx = abs(x[i] - X)
    if dx == 0: continue
    ans = gcd(ans, dx)

print(ans)

Measured memory_bytes: 14224
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
  mod = (i64)mod;
  i64 res = 1, p = a % mod;
  while (n) {
    if (n & 1) res = res * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
  cout << sizeof...(rest) << endl;
  std::cout << first;
  if (sizeof...(rest)) std::cout << " ";
  print(rest...);
}
template <typename... A>
void print(const A&... rest) {
  print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
  std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
  std::cout << std::endl;
}
i64 bit[50];  // bit[i] := i桁目が1のやつの個数
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  i64 n, k;
  cin >> n >> k;
  vector<i64> a(n);
  rep(i, n) cin >> a[i];
  vector<i64> s(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    s[i + 1] = s[i] + a[i];
  }
  vector<i64> cands;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      cands.push_back(s[j + 1] - s[i]);
    }
  }
  // print(cands);

  for (int i = 49; i >= 0; --i) {
    vector<i64> cands2;
    for (auto& c : cands) {
      if (c & (1LL << i)) {
        cands2.push_back(c);
      }
    }
    if ((i64)cands2.size() >= k) {
      cands = move(cands2);
    }
  }
  i64 ans =
      accumulate(all(cands), cands[0], [](i64 acc, i64 i) { return acc & i; });
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int K = in.nextInt();
            int A[] = CPUtils.readIntArray(N, in);

            int maxSum = 0;
            int start = 0;
            int end = K - 1;
            for (int i = 0; i < K; i++)
            {
                maxSum += A[i];
            }
            int currSum = maxSum;
            for (int i = K; i < N; i++)
            {
                currSum -= A[i - K];
                currSum += A[i];
                if (currSum > maxSum)
                {
                    maxSum = currSum;
                    start = i - K + 1;
                    end = i;
                }
            }
            double answer = 0;
            for (int i = start; i <= end; i++)
            {
                answer += ((A[i] * (A[i] + 1F) / 2F) / A[i]);
            }
            out.print(answer);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 63652
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int N,**G,*z;
long int **A;

long int dp(int n,int k)
{
  long int temp;
  int s,t,m,j;
  

  
  if(A[n][k]!=-1)
  {
    return A[n][k];
  }
  else if(z[n]==0)
  {
    A[n][k]=1;
    return A[n][k];
  }
  else
  {
    temp=1;
    for(s=0;s<z[n];s++)
    {
      m=G[n][s];
      j=0;
      for(t=0;t<z[m] && j==0;t++)
        {
          if(n==G[m][t])
          {
            G[m][t]=G[m][z[m]-1];
            z[m]--;
            j=1;
          }
        }

        temp*=(dp(m,0)+(1-k)*dp(m,1));
        temp=temp%1000000007;
      
      
    }                            
  }

  A[n][k]=temp;
  
  return temp;
  
}
 
int main()
{
  
  int i,x,y;
  long int u;
  
  scanf("%d",&N);
  
  G=(int **)malloc(sizeof(int * )*N);
  for(i=0;i<N;i++)
  {
    G[i]=(int *)malloc(sizeof(int )*N);
  }
  A=(int **)malloc(sizeof(int *)*N);
  for(i=0;i<N;i++)
  {
    A[i]=(int *)malloc(sizeof(int )*2);
  }
  z=(int *)malloc(sizeof(int )*N);

  
  for(i=0;i<N;i++)
  {
    z[i]=0;
    A[i][0]=-1;
    A[i][1]=-1;
  }

  for(i=0;i<N-1;i++)
  {
    scanf("%d %d",&x,&y);
    x--;
    y--;
    G[x][z[x]]=y;
    G[y][z[y]]=x;
    z[x]++;
    z[y]++;
  }


  u=(dp(0,0)+dp(0,1))%1000000007;


  printf("%ld",u);

  
  return 0;
}


Measured memory_bytes: 414080
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

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

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	vector< vector< int > > dp(C + 1, vector< int >(D + 1, 0));
	dp[A][B] = 1;
	for (int i = A; i <= C; i++)
		for (int j = B; j <= D; j++) {
			if (i == A && j == B)
				continue;
			(dp[i][j] += dp[i][j - 1] * i % MOD2) %= MOD2;
			(dp[i][j] += dp[i - 1][j] * j % MOD2) %= MOD2;
			if (i > A && j > B) {
				(dp[i][j] += MOD2 - (i - 1) * (j - 1) % MOD2 * dp[i - 1][j - 1] % MOD2) %= MOD2;
			}
		}
	cout << dp[C][D] << endl;
	return 0;
}

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

int s[2][210];

int main()
{

    int n,m,i,j,mx=0;
    scanf("%d",&n);

    for(i=0; i<2; i++)
    {
        for(j=0; j<n; j++)
        {
            scanf("%d",&s[i][j]);
        }
    }

    i=0;
    while(i<n)
    {
        int j,k,l;
        int cnt=0;
        {
            for(j=0; j<=i; j++)
            {
               cnt+=s[0][j];
            }

            for(l=j-1; l<n; l++)
            {
                cnt+=s[1][l];
            }
        }

        if(mx<cnt) mx=cnt;

        i++;
    }

    printf("%d",mx);

    return 0;
}




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

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

const MOD: i32 = 1000000007;


fn main() {
    let n: usize = read().unwrap();

    let mut vec = Vec::new();
    let mut sum = 0;
    for i in 0..n {
        let tmp: u64 = read().unwrap();
        vec.push(tmp);
        sum += tmp;
    }
    vec.sort();
    if sum % 10 == 0 {
        for i in 0..vec.len() {
            if (sum - vec[i]) % 10 == 0 {
                continue;
            }
            println!("{}", sum - vec[i]);
            return;
        }
    } else {
        println!("{}", sum);
        return;
    }
    println!("{}", 0);
}


Measured memory_bytes: 4476
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
//typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
ll m, p;
int a[10000];
multiset<ll> s;
//素因数分解o√n
map<ll, ll>prime_factor(ll n){
    map<ll, ll> res;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            if(res[i]%m==0)
            s.insert(i);
            n/=i;
        }
    }
    if(n!=1) {
        res[n]=1;
        if(res[n]==m)
            s.insert(n);
    }
    //for(int i=2;i<=n;i++)cout<<res[i]<<"\n";
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> m>>p;
    map<ll, ll> m=prime_factor(p);
    if(s.size()==0){
        cout<<1<<"\n";
        return 0;
    }
    ll ans=1;
    for(auto i=s.begin();i!=s.end();i++){
        ans*=*i;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<int> as;
vector<ll> bs;

ll solve(const int N) {
    ll ans = 0;

    ll cur_vs = 0;
    for (int cur_l = N; cur_l > 0; cur_l--) {
        const ll next_max = bs[cur_l - 1];

        cur_vs += as[cur_l];
        ans += cur_vs;
        // printf("cur_l: %d, next_max: %d, cur_vs: %d, ans: %lld\n", cur_l, next_max, cur_vs, ans);
        if (cur_vs > next_max) {
            if (cur_vs > 2 * next_max) {
                return -1;
            }
            cur_vs = next_max;
        }
    }

    ans += 1;
    return ans;
}

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

    as.resize(N + 1);
    for (int i = 0; i <= N; i++) {
        cin >> as[i];
    }

    if (N == 0) {
        if (as[0] == 1) {
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }

    bs.resize(N + 1);
    bs[0] = 1 - as[0];
    bs[N] = 0;
    for (int i = 1; i < N; i++) {
        bs[i] = min(LONG_LONG_MAX / 2, bs[i - 1] * 2 - as[i]);
    }
    for (int i = 0; i < N; i++) {
        // printf("bs[%d]: %lld\n", i, bs[i]);
        if (bs[i] <= 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 4236
# https://atcoder.jp/contests/m-solutions2019/submissions/5741430
from functools import reduce
from operator import mul
import sys

input = sys.stdin.readline

MOD = 10 ** 6 + 3


def inv(n):
    return pow(n, MOD - 2, MOD)


def mod_mul(x, y):
    return mul(x, y) % MOD


fact = [1]
for n in range(1, MOD):
    fact.append((fact[-1] * n) % MOD)
    # d>1 の数列を d=1 となる数列に変換する
    # MODの倍数を含む数列の積は0になるので,
    # MODの倍数を含まない区間の積が計算できればよい
    # そのような区間の右端はMOD-1であり,fact[MOD-1]が計算できればよい

Q = int(input())
for _ in range(Q):
    x, d, n = map(int, input().split())

    if x == 0:
        print(0)
        continue

    if d == 0:
        print(pow(x, n, MOD))
        continue

    xd = (x * inv(d)) % MOD
    if MOD - xd < n:
        print(0)
        continue

    dn = pow(d, n, MOD)
    print(reduce(mod_mul, (fact[xd + n - 1], inv(fact[xd - 1]), dn)))


Measured memory_bytes: 44052
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)

ll N, M, A, B, C, A1, B1;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

int main() {
	scanf("%lld %lld %lld", &A, &B, &M);
	for(int i = 1; i <= A; i++) {
		scanf("%lld", &arr[i]);
	}
	for(int i = 1; i <= B; i++) {
		scanf("%lld", &arr1[i]);
	}
	ll ans = 1e15;
	fi(i, 1, M + 1, 1) {
		scanf("%lld %lld %lld", &A1, &B1, &C);
		ans = min(ans, arr[A1] + arr1[B1] - C);
	}
	sort(arr, arr + A + 1);
	sort(arr1, arr1 + B + 1);
	ans = min(ans, arr[1] + arr1[1]);
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 1792
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 205;
char s[maxn][maxn];
int d[maxn];

int ans;
bool shit;
void bfs(int st, int n) {
	std::queue<int> q;
	d[st] = 1;
	q.push(st);

	while(!q.empty()) {
		int u = q.front();
		q.pop();
		/* debug("%d %d\n", u, d[u]); */
		if(d[u] > ans) ans = d[u];

		for(int i = 1; i <= n; i ++)
			if(s[u][i] == '1' and !d[i]) {
				d[i] = d[u] + 1;
				q.push(i);
			} else if(s[u][i] == '1' and (d[i] & 1) == (d[u] & 1))
				shit = 1;
	}
}

int main() {
	int n = input();
	for(int i = 1; i <= n; i ++)
		scanf("%s", s[i] + 1);

	for(int i = 1; i <= n; i ++) {
		/* debug("start %d\n", i); */
		for(int j = 1; j <= n; j ++)
			d[j] = 0;
		bfs(i, n);
		if(shit) {
			puts("-1");
			return 0;
		}
	}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            int questionCount = Integer.parseInt(br.readLine());
            List<String> questionTimeString = Arrays.asList(br.readLine().split(" "));
            int drinkCount = Integer.parseInt(br.readLine());
            List<List<String>> drinkTimeAndQuestionNumberString = new ArrayList<>();
            for (int i = 0; i < drinkCount; i++) {
                drinkTimeAndQuestionNumberString.add(Arrays.asList(br.readLine().split(" ")));
            }

            List<Integer> questionTime = new ArrayList<>();
            for (int i = 0; i < questionCount; i++) {
                questionTime.add(Integer.parseInt(questionTimeString.get(i)));
            }

            List<Integer> drinkTimeAndQuestionNumber = new ArrayList<>();
            for (List<String> list : drinkTimeAndQuestionNumberString) {
                for (String str : list) {
                    drinkTimeAndQuestionNumber.add(Integer.parseInt(str));
                }
            }

            for (int i = 0; i < drinkTimeAndQuestionNumber.size(); i += 2) {
                int sumTime = 0;
                for (int j = 0; j < questionCount; j++) {
                    if (drinkTimeAndQuestionNumber.get(i) - 1 == j) {
                        sumTime += drinkTimeAndQuestionNumber.get(i + 1);
                    } else {
                        sumTime += questionTime.get(j);
                    }
                }
                System.out.println(sumTime);
            }

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<int> ans;

void dfs(const vector<vector<pair<ll, ll>>> &g, int start, int color) {
    ans[start] = color;
    for (auto e : g[start]) {
        if (ans[e.first] == -1) {
            if (e.second % 2 == 0) {
                dfs(g, e.first, color);
            } else {
                dfs(g, e.first, 1 - color);
            }
        }
    }
}


int main() {
    int N;
    cin >> N;
    vector<vector<pair<ll, ll>>> graph(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        graph[u - 1].push_back({v - 1, w});
        graph[v - 1].push_back({u - 1, w});
    }

    ans.assign(N, -1);
    dfs(graph, 0, 1);

    rep(i, N){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main()
{
    int n,a,b;
    while(cin >> n >> a >> b){
        int plan_a_fee = n*a;
        int plan_b_fee = b;

            if(plan_a_fee < plan_b_fee) cout << plan_a_fee <<endl;
            else cout << plan_b_fee << endl;
    }
    return 0;
}



Measured memory_bytes: 256
// Problem : D - Triangles
// Contest : AtCoder - AtCoder Beginner Contest 143
// URL : https://atcoder.jp/contests/abc143/tasks/abc143_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
using namespace std;
bool tri(lli a,lli b,lli c){
	if(a+b>c && b+c>a && c+a>b)
	return true;
	return false;
}
int main()
{
	lli k,j,a,n,i,ans=0;
	cio;
	cin>>n;
	vector<lli>v;
	vector<lli>::iterator it;
	for(i=0;i<n;i++){
		cin>>a;
		v.pb(a);
	}
	sort(v.begin(),v.end());
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			it=lower_bound(v.begin(),v.end(),v[i]+v[j]);
			a=it-v.begin();
			ans+=a-j-1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int a[100010];
int main()
{
	int N, x;
	cin >> N >> x;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			ans += a[i] + a[i + 1] - x;
			int num = a[i] + a[i + 1] - x;
			a[i + 1] = max(0, a[i + 1] - num);\
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll K;
    cin >> N >> K;
    ll sm = 0;
    int count[50] = {};
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        stringstream ss;
        ss << bitset<50>(A[i]);
        string str = ss.str();
        for (int k = 0; k < 50; k++) {
            if (str[k] == '1') {
                count[k] += 1;
            }
        }
    }
    ll X = 0;
    for (int i = 0; i < 50; i++) {
        if (count[i] <= N/2 && X + pow(2, 49 - i) <= K) { // check
            X += pow(2, 49 - i);
        }
    }
    ll ans = 0;
    for (auto &a : A) ans += X ^ a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll A, B;
    char op;
    cin >> A >> op >> B;
    if(op == '+') {
        cout << A + B << endl;
        return 0;
    } else {
        cout << A - B << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    final String LINE_SPR = System.getProperty("line.separator");
    final int BIG_MOD = 1000000007;

    void run() throws Exception {
        String line;
        while((line = br.readLine()) != null) {
            StringBuffer sb = new StringBuffer(line);
            System.out.println(sb.reverse().toString());
        }
    }


    /*
     * Templates
     */
    void dumpObjArr(Object[] arr, int n) {
        for(int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if(i < n - 1)
                System.out.print(" ");
        }
        System.out.println("");
    }

    void dumpObjArr2(Object[][] arr, int m, int n) {
        for(int j = 0; j < m; j++) 
            dumpObjArr(arr[j], n);
    }

    int ni() throws Exception {
        return Integer.parseInt(br.readLine().trim());
    }

    long nl() throws Exception {
        return Long.parseLong(br.readLine().trim());
    }

    String ns() throws Exception {
        return br.readLine();
    }

    boolean isPrime(int n) {
        for(int i=2;i<n;i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    int getPrime(int n) {
        List<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int count = 1;

        int x = 1;
        while(primes.size() < n) {
            x+=2;
            int m = (int)Math.sqrt(x);
            for(int p : primes) {
                if(p > m) {
                    primes.add(x);
                    break;
                }

                if(x % p == 0) 
                    break;
            }
        }

        return primes.get(primes.size() - 1);
    }

    long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    long gcd(long a, long b) {
        if(a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        // a >= b
        long mod = a % b;
        if(mod == 0) 
            return b;
        else 
            return gcd(b, mod);
    }

    void gcjPrint(String str, int t) {
        System.out.println("Case #" + t + ": " + str);
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 16868
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (a, b, q) = {
        let ab:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i64>().unwrap()).collect();
        (ab[0], ab[1], ab[2])
    };
    let mut s:Vec<i64> = Vec::new();
    let mut t:Vec<i64> = Vec::new();
    let f:i64 = -100000000000;
    let e:i64 = 100000000000;
    s.push(f);
    t.push(f);
    for _i in 0..a {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        s.push(st.trim().parse::<i64>().unwrap());
    };
    s.push(e);

    for _i in 0..b {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        t.push(st.trim().parse::<i64>().unwrap());
    };
    t.push(e);

    let mut x:Vec<_> = Vec::new();
    for _i in 0..q {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        x.push(st.trim().parse::<i64>().unwrap());
    };

    for i in &x {
        let n = bisec(&mut s, &i);
        let m = bisec(&mut t, &i);
        let mut result:Vec<i64> = Vec::new();
        result.push(max(&s[n], &t[m])-i);
        result.push(i-min(&s[n-1], &t[m-1]));
        result.push(min(&(i-s[n]).abs(), &(i-t[m-1]).abs())+(s[n]-t[m-1]).abs());
        result.push(min(&(i-s[n-1]).abs(), &(i-t[m]).abs())+(s[n-1]-t[m]).abs());
        println!("{}", result.iter().min().unwrap());
    };
}

fn bisec(v:&Vec<i64>, num:&i64) -> usize {
    let mut l:usize = 0;
    let mut r = v.len() as usize;
    let mut m = (l+r)/2 as usize;
    while l < r {
        if num <= &v[m] {
            r = m;
        } else {
            l = m+1;
        };
        m = (l+r)/2;
    };
    l
}

fn max (a:&i64, b:&i64) -> i64 {
    if a < b {
        *b
    } else {
        *a
    }
}

fn min (a:&i64, b:&i64) -> i64 {
    if a > b {
        *b
    } else {
        *a
    }
}

Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
ll read(){
    char ch=gc();ll x=0;int op=1;
    for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
    for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
    return x*op;
}
#define N 105
#define mod 1000000007
int ksm(int x,int p){
    int ret=1;
    for (;p;p>>=1,x=(ll)x*x%mod) if (p&1) ret=(ll)ret*x%mod;
    return ret;
}
int n,h[N];
pii solve(int l,int r,int lim){//区间[l,r]比lim高的部分的方案数
    int mi=inf,cnt=0;pii ret;//first：存在相邻格子颜色相同情况的方案数；second：不存在的方案数（固定第一个格子的颜色）
    rep (i,l,r) if (h[i]<mi) mi=h[i],cnt=1;else if (h[i]==mi) cnt++;
    if (cnt==r-l+1){//矩形
        ret.fi=(ksm(2,r-l+1)+mod-2)%mod;
        ret.se=ksm(2,mi-lim);
        return ret;
    }
    int rest=r-l+1,s0=1,s1=1,last=0;//rest：上方没有方格的列数；s0,s1：维护上方有方格的列，当前行存在/不存在的方案数
    rep (i,l,r+1)
        if (!last&&h[i]>mi) last=i;
        else if (last&&(h[i]<=mi||i>r)){
            rest-=i-last;
            pii tmp=solve(last,i-1,mi);//子问题，递归求解
            s0=(ll)s0*(tmp.fi+2ll*tmp.se%mod)%mod;//*4是因为上一行可以取反，当前行亦然，2*2
            s1=(ll)s1*(1ll*tmp.se%mod)%mod;
            last=0;
        }
    s0=(s0+mod-s1)%mod;
    ret.fi=(ll)s0*ksm(2,rest)%mod;//如果上方方格已经存在，剩下的列随意
    ret.fi=(ret.fi+(ll)s1*(ksm(2,rest)+mod-2)%mod)%mod;//否则需要去掉两种不合法的情况
    ret.se=(ll)2ll*s1*ksm(2,mi-lim-1)%mod;//固定第一个格子（第一行）颜色
    return ret;
}
int main(){
    n=read();rep (i,1,n) h[i]=read();
    if (n==1){//注意特判
        printf("%d\n",ksm(2,h[1]));
        exit(0);
    }
    pii ans=solve(1,n,0);
    printf("%d",(ans.fi+ans.se%mod)%mod);
    return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "1 0" ].parse.expand.solve == "0 0 1 1" );
	assert( [ "1 1" ].parse.expand.solve == "-1" );
	assert( [ "5 58" ].parse.expand.solve == "-1" );

	assert( [ "2 1" ].parse.expand.solve == "0 2 1 2 0 3 1 3" );		// 追加ケース
	assert( [ "2 2" ].parse.expand.solve == "0 1 2 1 0 3 2 3" );		// 追加ケース
	assert( [ "2 3" ].parse.expand.solve == "0 1 3 1 0 2 3 2" );		// 追加ケース
	assert( [ "2 4" ].parse.expand.solve == "-1" );						// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto mk = input.front.split.to!( long[] );
	return tuple( mk[ 0 ], mk[ 1 ] );
}

auto solve( long m, long k )
{
	auto n = 2L ^^ ( m + 1 );
	auto h = n / 2;
	auto qa = n / 4;
	auto qb = h + qa;
	
	// kが0の場合は小さい順に並べるだけでOK
	if( k == 0 ) return n.iota.map!( ( a ) => ( a / 2 ).to!( string ) ).join( " " );
	
	// kが0より大きい場合はk以外の数全てのxorがkにならないと無理
	if( h <= k || reduce!( ( a, b ) => a ^ b )( k, h.iota ) != k ) return "-1";
	
	// kはk以外の数全てを一つだけ挟むように並べる
	// k以外の数はkを一つだけ挟んで、それ以外は挟まないか二つ挟んで相殺するように並べる
	auto anss = new long[ n ];
	anss[ qa ] = k;
	anss[ qb ] = k;
	auto a = 0L;
	for( auto i = 1L; i < qa; i++ )
	{
		a++;
		a += ( a == k );
		anss[ qa + i ] = a;
		anss[ qa - i ] = a;
		a++;
		a += ( a == k );
		anss[ qb + i ] = a;
		anss[ qb - i ] = a;
	}
	return anss.to!( string[] ).join( " " );
}


Measured memory_bytes: 19580
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int cnt = 0;
            while (A[i] % 2 == 0) {
                A[i] /= 2;
                cnt++;
            }
            ans = Math.min(ans, cnt);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844