akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

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

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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

struct Edge{
    int from, to, dir=0;
};

void Main(){
    int N,M; cin >> N >> M;
    vector<Edge> edge(M);
    VVI adj(N);
    map<P,int> m;
    REP(i,M){
        Edge e; cin >> e.from >> e.to; e.from--; e.to--;
        edge[i] = e;
        adj[e.from].push_back(e.to);
        adj[e.to].push_back(e.from);
        m[P(e.from,e.to)] = i;
        m[P(e.to,e.from)] = i;
    }

    VI d(N,INF);
    queue<P> que; que.emplace(0,0);
    while(!que.empty()){
        P p = que.front(); que.pop();
        if(d[p.first] < INF) continue;
        d[p.first] = p.second;
        for(int& e : adj[p.first]) que.emplace(e, p.second+1);
    }

    VI path(N,0);
    REP(i,M){
        Edge e = edge[i];
        if(d[e.from]-1 == d[e.to]) path[e.from] = e.to;
        if(d[e.to]-1 == d[e.from]) path[e.to] = e.from;
    }

    VI guki(N,0);
    REP(i,M) guki[edge[i].from] ^= 1;

    auto c = [&](int i, int j){return d[i]<d[j];};

    priority_queue<int,VI,decltype(c)> q(c); REP(i,N-1) if(guki[i+1] == 1) q.push(i+1);
    while(!q.empty()){
        int v = q.top(); q.pop();
        if(guki[v] == 0) continue;

        int to = path[v];
        int i = m[P(v,to)];
        guki[v] ^= 1;
        guki[to] ^= 1;
        edge[i].dir ^= 1;
        if(guki[to] == 1 && to!=0) q.push(to);
    }

    if(guki[0] == 1) cout << -1 << en;
    else{
        REP(i,M){
            int from = edge[i].from+1, to = edge[i].to+1;
            if(edge[i].dir == 1) swap(from,to);
            cout << from << " " << to << en;
        }
    }
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 22140
import math
def main():
    a,b,x=map(int,input().split(' '))
    if x>= a*a*b//2:
        print(math.atan(2/(a**2)*((b*a)-x/a))*180/math.pi)
    else:
        print(90-math.atan(2*x/(a*b*b))*180/math.pi)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char A, B, C, D;
    cin >> A >> B >> C >> D;
    int a = A - '0';
    int b = B - '0';
    int c = C - '0';
    int d = D - '0';
    rep(op1,2){
        rep(op2,2){
            rep(op3,2){
                int res = a;
                string ans = to_string(a);
                if(op1){
                    res += b;
                    ans += "+" + to_string(b);
                }
                else{
                    res -= b;
                    ans += "-" + to_string(b);
                }
                if(op2){
                    res += c;
                    ans += "+" + to_string(c);
                }
                else{
                    res -= c;
                    ans += "-" + to_string(c);
                }
                if(op3){
                    res += d;
                    ans += "+" + to_string(d);
                }
                else{
                    res -= d;
                    ans += "-" + to_string(d);
                }
                if(res == 7){
                    ans += "=7";
                    cout << ans << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;


int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << max(min(B,D)-max(A,C),0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[3005][3005];
int A,B,C,D,mod=998244353;
int main(){
	
	scanf("%d%d%d%d",&A,&B,&C,&D);
	f[A][B]=1;
	for (int i=A;i<=C;++i) {
		for (int j=B+(i==A);j<=D;++j) {
			f[i][j]=(f[i][j-1]*i+f[i-1][j]*j-f[i-1][j-1]*(i-1)%mod*(j-1))%mod;
		}
	}
	printf("%lld",(f[C][D]+mod)%mod);
	
	return 0;
}

Measured memory_bytes: 74148
#include<iostream>

using namespace std;

int main() {
	int a, b;
	double r1, r2;
	int num;
	cin >> a >> b;
	for (num = a;; num++) {
		if (int((double)num * 0.08) == a && int((double)num * 0.1) == b) {
			cout << num;
			break;
		}
		if (int((double)num * 0.08) == a && int((double)num * 0.1) > b) {
			cout << -1;
			break;
		}
		if (int((double)num * 0.08) > a && int((double)num * 0.1) == b) {
			cout << -1;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// She is Pretty pretty!
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 310;
int a[4], x, n;
double dp[N][N][N];
double dfs(int i , int j , int k){
    if(dp[i][j][k])return dp[i][j][k];
    if(i + j + k == 0) return 0;
    /*double ans = 1;
    if(i) ans += dfs(i - 1, j , k) * i / n;
    if(j) ans += dfs(i + 1, j - 1, k) * j / n;
    if(k) ans += dfs(i , j+1 , k-1) * k / n;
    if(i+j+k!=n)ans*=1.0*n/(j+k+i);*/
    double ans = 1.0*n/(i+j+k);
     if(i) ans += dfs(i - 1, j , k) * i / (i+j+k);
    if(j) ans += dfs(i + 1, j - 1, k) * j / (i+j+k);
    if(k) ans += dfs(i , j+1 , k-1) * k / (i+j+k);
    return dp[i][j][k] = ans;
}
int main()
{
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> x;
        a[x]++;
    }
    printf("%.10f", dfs(a[1],a[2],a[3]));
    return 0;
}

Measured memory_bytes: 225536
/*input
100 1
-100000
*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/

int main()
{
    ifalse;
    int n, m;
    cin >> n >> m;
    vector < int > v;
    rep(i, 0, m) {
    	int x;
    	cin >> x;
    	v.pb(x);
    }
    sort(all(v));
    vector < int > v1;
    for(int i = 1; i < m; i ++) {
    	v1.pb(v[i] - v[i -1]);
    }
    sort(all(v1));
    ll sum = 0;
    for(int i = 0; i < min(int(v1.size()), m - n); i ++) {
    	sum += v1[i] * 1LL;
    }
    cout << sum,nl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 52
#define mod 998244353
ll n,q,i,k,t,arr[sz],brr[sz],crr[sz],a,b,c,d,m,x,y,l,r,z,dp[sz][sz][sz],drr[sz];
int main()
{
    scanf("%lld %lld",&n,&m);
    k=m;
    l=n-m-1;
    a=m-1;
    while(k>0 && m>0)
    {
        printf("%lld %lld\n",n,n-k);
        n--;
        m--;
        k-=2;
    }
   // if(m>0)
   // {
      /*  if(k==0)
        {
            printf("%lld %lld\n",n,l);
            m--;
            n=l-1;
            a-=2;
        }
        else*/
            n=l;
        for(i=0; i<m; i++)
        {
            printf("%lld %lld\n",n,n-a);
            n--;
            a-=2;
        }
    //}
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) {
    cin >> a.at(i);
    a[i] /= 400;
  }
  map<int,int> mp;
  int free = 0;
  rep(i,n) {
    rep(j,8) if(a[i]==j) mp[j]++;
    if(a[i]>7) free++;
  }
  int ans = 0;
  for(auto p : mp) ans++;
  if(ans==0) {
    cout << 1 << " " << free << endl;
    return 0;
  }
  cout << ans << " " << ans+free << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A - B == 0) {
		printf("%d\n", C);	
	} else if(C > (A - B)) {
		printf("%d\n", C - (A - B));	
	} else {
		printf("%d\n", 0);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int num[30];
vector<int> ve;
vector<int> vi;
vector<int> tmp;
int main(){
    int n;
    cin>>n;
    int x;
    for(int i=1;i<=n;i++){
        cin>>x;
        num[x]++;
    }
    if(num[0]>0){
        puts("0");
        return 0;
    }
    for(int i=0;i<=12;i++){
        if(num[i]==0) continue;
        if(num[i]>2){
            puts("0");
            return 0;
        }
        if(num[i]==2){
            //cout<<i<<" "<<24-i<<endl;
            ve.push_back(i);
            ve.push_back(24-i);
        }
        if(num[i]==1){
            vi.push_back(i);
        }
    }
    int len=vi.size();
    int ans=0;
    if(len==0){
        ve.push_back(0);
        ve.push_back(24);
        sort(ve.begin(),ve.end());
        ans=100;
        for(int i=1;i<ve.size();i++){
            ans=min(ans,ve[i]-ve[i-1]);
        }
        cout<<ans<<endl;
        return 0;
    }
    for(int i=0;i<(1<<len);i++){
        tmp.clear();
        for(int j=0;j<len;j++){
            if((i>>j)&1) tmp.push_back(vi[j]);
            else tmp.push_back(24-vi[j]);
        }
        for(int j=0;j<ve.size();j++){
            tmp.push_back(ve[j]);
        }
        tmp.push_back(0);
        tmp.push_back(24);
        int ff=100;
        sort(tmp.begin(),tmp.end());
        //for(int j=0;j<tmp.size();j++) cout<<tmp[j]<<endl;
        for(int j=1;j<tmp.size();j++){
            ff=min(ff,tmp[j]-tmp[j-1]);
        }
        ans=max(ans,ff);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
v32 a;
vv64 dp;
ll solve(int x,int y){
	if(dp[x][y]!=-1e18) return dp[x][y];
	ll c1= solve(x+1,y),c2=solve(x,y-1);
	bool mv=(n-(y-x+1))&1; // 0 for +ve
	if(mv){
		c1-=a[x], c2-=a[y];
		return dp[x][y]=min(c1,c2);
	}else{
		c1+=a[x], c2+=a[y];
		return dp[x][y]=max(c1,c2);
	}
}
int main(){
	fastio;
	cin>>n;
	a.resize(n);
	dp.assign(n,v64(n,-1e18));
	forn(i,n) cin>>a[i],dp[i][i]=a[i];
	if( (n-1)&1 ) forn(i,n) dp[i][i]*=-1;
	cout<< solve(0,n-1) <<ln;
	return 0;
}

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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7  ;

vector < int > adj[MAXN] ;

int h[MAXN] , st[MAXN] , en[MAXN] , mark[MAXN] , par[MAXN][20] , tme , a[MAXN];

queue < int > q ;

set < int > s ;

set < pair < int , int > > s2 ;

void dfs(int u , int p )
{
    //cout<<u<<' '<<h[u]<<endl;
    st[u] = tme ++ ;
    a[st[u]] = u ;
    s.insert(st[u]);
    s2.insert({h[u],u});
    par[u][0] = p ;
    for(int i = 1 ; i < 20 ; i ++ )
        par[u][i] = par[par[u][i-1]][i-1] ;
    for(auto v  : adj[u] )
        h[v] = h[u] + 1 , dfs(v,u) ;
    en[u] = tme ;
}

int ipar(int x , int y)
{
    for(int i = 0 ; i < 20 ; i ++ )
        if(y&(1<<i))
            x = par[x][i] ;
    return x ;
}

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int n , k , x ;
   cin >> n >> k >> x;
   int ans = (x>1) ;
   for(int i = 2 ; i <= n ; i ++ )
     cin >> x , adj[x].pb(i);
   if(k>n)
    return cout<<ans,0;
    dfs(1,0);
    while(s2.size()&&(s2.rbegin()->F)>k)
    {
        int v = ipar(s2.rbegin()->S,k-1) ;
        ans ++ ;
        while(s.size())
        {
            auto u = s.lower_bound(st[v]) ;
            if(u==s.end()||*u>=en[v])
                break ;
            s2.erase({h[a[*u]],a[*u]});
            s.erase(u);

        }
    }
    cout << ans ;




}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll am_memo_m1[200005];
ll am_memo_p1[200005];

ll count_bit(ll val) {
  ll r = 0;
  ll c = 1;
  for (;;) {
    if (val & c) {
      r += 1;
    }
    c *= 2;
    if (c > val) {
      break;
    }
  }
  return r;
}

ll calc(ll val) {
  ll r = 0;
  for (;;) {
    if (val == 0) {
      break;
    }
    ll bnum = count_bit(val);
    val = val % bnum;
    r += 1;
  }
  return r;
}

int main() {
  ll N;
  scanf("%lld", &N);

  string s;
  cin >> s;

  ll popcount = 0;

  vector<int> digits(N + 1);
  for (ll i = N - 1; i >= 0; i--) {
    ll index = N - i;
    if (s[i] == '1') {
      digits[index] = 1;
      popcount++;
    } else {
      digits[index] = 0;
    }
  }
  // cout << "popcount:" << popcount << endl;

  ll am_m1 = 0;
  ll am_p1 = 0;

  ll cur_m1 = 1;
  ll cur_p1 = 1;

  ll popcount_m1 = popcount - 1;
  ll popcount_p1 = popcount + 1;

  for (ll i = 1; i <= N; i++) {
    if (digits[i]) {
      if (popcount_m1 > 0) {
        am_m1 = (am_m1 + cur_m1) % popcount_m1;
      }
      am_p1 = (am_p1 + cur_p1) % popcount_p1;
    }
    am_memo_m1[i] = cur_m1;
    am_memo_p1[i] = cur_p1;

    if (popcount_m1 > 0) {
      cur_m1 = (cur_m1 * 2) % popcount_m1;
    }
    cur_p1 = (cur_p1 * 2) % popcount_p1;
  }

  // cout << "digits[1]:" << digits[1] << endl;  // => 1
  // cout << "digits[2]:" << digits[2] << endl;  // => 1
  // cout << "digits[3]:" << digits[3] << endl;  // => 0

  // cout << "am_memo_p1[1]:" << am_memo_p1[1] << endl;  // => 1
  // cout << "am_memo_p1[2]:" << am_memo_p1[2] << endl;  // => 2
  // cout << "am_memo_p1[3]:" << am_memo_p1[3] << endl;  // => 1

  // cout << "popcount_p1:" << popcount_p1 << endl;

  // cout << "am_m1:" << am_m1 << endl;
  // cout << "am_p1:" << am_p1 << endl;

  // digits = [1, 1, 0]
  for (ll i = N; i >= 1; i--) {
    ll popcount;
    ll am;
    if (digits[i]) {
      popcount = popcount_m1;
      if (popcount_m1 == 0) {
        am = 0;
      } else {
        popcount = popcount_m1;
        // i桁目が消滅する
        am = (((am_m1 - am_memo_m1[i]) % popcount) + popcount) % popcount;
      }
    } else {
      popcount = popcount_p1;
      // i桁目が出現する
      am = ((am_p1 + am_memo_p1[i]) % popcount);
    }

    // cout << 1 + calc(am) << endl;
    if (popcount == 0) {
      cout << 0 << endl;
    } else {
      cout << 1 + calc(am) << endl;
    }
  }

  ll am_ll = 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<int> lis(n, 0);
    map<int, int> mp;
    REP(i, 0, n){
        cin >> lis[i];
        mp[lis[i]] = i;
    }
    int key = -1, mid = 0, ans = 0;
    REP(i, 1, n+1){
        int pos = mp[i];
        if(key < pos){
            mid++;         
        }else{
            mid = 1;
        }
        key = pos;
        ans = max(ans, mid);
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7;

int main(){
  ll N;
  cin>>N;
  
  vector<ll>A(N+2);
  vector<ll>ans(N+2);


  A[0]=0;
  A[N+1]=0;
  
  for(ll i=1;i<N+1;i++){
cin>>A[i];
  }
   ll d=0;
  
  for(ll i=1;i<N+2;i++){
    d+=abs(A[i]-A[i-1]);
  }
 

  
  for(ll i=1;i<N+1;i++){
    ans[i]=abs(A[i+1]-A[i-1]);
    ans[i]-=abs(A[i]-A[i-1]);
    ans[i]-=abs(A[i+1]-A[i]);
    
  }
  
for(ll i=1;i<N+1;i++){
  cout<<d+ans[i]<<endl;
}

}
   

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

const int MAX = 210000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理O(n)
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算O(1)
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {

    ll n, m;
    cin >> n >> m;

    COMinit();

    if (n == m) {
        cout << ((fac[n]*fac[n])%MOD * 2)%MOD << endl;
    } else if (abs(n-m) == 1) {
        cout << (fac[n]*fac[m])%MOD << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 8564
def find(A):
    A=sorted(A)
    MAX=A[-1]
    mid=MAX/2
    MIN=MAX
    need=-1
    for i in range(len(A)-1):
        if abs(A[i]-mid)<MIN:
            need=A[i]
            MIN=abs(A[i]-mid)
    return (MAX,need)
input()
x,y=find(list(map(int,input().strip().split(' '))))
print("{} {}".format(x,y))

Measured memory_bytes: 58664
N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)

Measured memory_bytes: 32180
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int K;
  cin >> K;
  int cnt = 0;
  vector<vector<long long>> Ans(11);
  int l2 = 0,l3 = 0,n1 = 0;
  while(cnt < K) {
    if(n1 == 0) {
      Ans[n1].push_back(cnt+1);
      cnt++;
      if(cnt == 9)n1++;
    }
    else {
      if(Ans[n1-1][l2] % 10 == 0) {
        Ans[n1].push_back(Ans[n1-1][l2]*10+l3);
        l3++;
        cnt++;
        if(l3 == 2) {
          l2++;
          l3 = 0;
        }
      }
      else if(Ans[n1-1][l2] % 10 == 9) {
        Ans[n1].push_back(Ans[n1-1][l2]*10+8+l3);
        l3++;
        cnt++;
        if(l3 == 2) {
          l2++;
          l3 = 0;
        }
      }
      else {
        Ans[n1].push_back(Ans[n1-1][l2]*10+(Ans[n1-1][l2]%10)+l3-1);
        l3++;
        cnt++;
        if(l3 == 3) {
          l2++;
          l3 = 0;
        }
      }
      if(l2 == Ans[n1-1].size()) {
        n1++;
        l2 = 0;
        l3 = 0;
      }
    }
    if(cnt == K)cout << Ans[n1][Ans[n1].size()-1] << endl;
  }
}

Measured memory_bytes: 1272
#include <stdio.h>

int main(void){
  char sa[101] = { '\0' };
  char sb[101] = { '\0' };
  char sc[101] = { '\0' };
  scanf("%s", sa);
  scanf("%s", sb);
  scanf("%s", sc);
  int na = 0;
  int nb = 0;
  int nc = 0;
  int ma = 0;
  int mb = 0;
  int mc = 0;
  while(sa[ma] != '\0') ma++;
  while(sa[mb] != '\0') mb++;
  while(sa[mc] != '\0') mc++;
    int select = 3;
  char turn = 'a';
  while(select == 3){
    switch(turn){
    case 'a':
      if(na == ma) select = 0;
      turn = sa[na];
      na++;
      break;
    case 'b':
      if(nb == mb) select = 1;
      turn = sb[nb];
      nb++;
      break;
    default:
      if(nc == mc) select = 2;
      turn = sc[nc];
      nc++;
      break;
    }
  }

  if(select == 0) printf("A\n");
  else if(select == 1) printf("B\n");
  else printf("C\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	string c[3];

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

	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x >> y >> k;
    if(x + y >= k)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


struct ConvexHull{
  using cd=complex<double> ;
  vector<cd> ps,qs;
  int sz;
  ConvexHull(vector<cd> v){
    ps=v;
    sz=ps.size();
    qs.resize(sz*2);
    sort(ps.begin(),ps.end(),[](cd a,cd b){if(a.real()!=b.real()){return a.real()<b.real();}return a.imag()<b.imag();});
    calc();
  }
  void calc(){
    int k=0;
    for(int i=0;i<sz;i++){
      while(k>1 && ((qs[k-1]-ps[i])/(qs[k-2]-ps[i])).imag()<=0)k--;
      qs[k++]=ps[i];
    }
    int t=k;
    for(int i=sz-2;i>=0;i--){
      while(k>t && ((qs[k-1]-ps[i])/(qs[k-2]-ps[i])).imag()<=0)k--;
      qs[k++]=ps[i];
    }
    qs.resize(k-1);
  }
  /*最遠点　尺取
  double farlen()
  {
    double res=0,tres=0;
    int r=1;
    rep(l,qs.size())
    {
      tres=abs(qs[l]-qs[r-1]);
      while(r<qs.size() && chmax(tres,abs(qs[l]-qs[r])))r++;
      chmax(res,tres);
      if(l==r)r++;
    }
    return res;
  }
  */
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<complex<double>>conv;
  int n;
  cin>>n;
  conv.push_back({0,0});
  rep(i,n)
  {
    double x,y;
    cin>>x>>y;
    complex<double>vec(x,y);
    auto tv=conv;
    for(auto j:tv)conv.push_back(j+vec);
    ConvexHull ch(conv);
    ch.calc();
    conv=ch.qs;
    conv.erase(unique(all(conv)),conv.end());


  //  rep(i,ch.qs.size())conv.push_back(ch.qs[i]);
    //rep(i,conv.size())cout<<conv[i]<<endl;
    //cout<<endl;
  }
  double res=0;
  rep(i,conv.size())
  {
    chmax(res,abs(conv[i]));
  }
  cout<<setprecision(12)<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
double x[3], y[3], xp, yp;
int main() {
	while (std::cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>xp>>yp) {
		int bit = 3;
		for (int i=0; i<3; ++i) {
			double tmp = (x[(i+1)%3]-x[i])*(yp-y[i])-(y[(i+1)%3]-y[i])*(xp-x[i]);
			bit &= ~((tmp < 0) + 1);
		}
		std::cout << (bit ? "YES" : "NO") << "\n";
	}
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <string.h>
#include <math.h>

int list;
int clist[1000000];
int need[100];

int digit(int n)
{
    int digit;
    
    digit = 0;
    
    while (n != 0){
        n /= 10;
        digit++;
    }
    
    return (digit);
}

int combi(int used, int use, int now, int n, int *card){
    int i;
    
    
    if (used == use){
        for (i = 0; i < list; i++){
            if (now == clist[i]){
                return (0);
            }
        }
        clist[i] = now;
        list++;
        return (1);
    }
    
    for (i = 0; i < n; i++){
        if (need[i] != 1){
            need[i] = 1;
            combi(used + 1, use, now * pow(10, digit(card[i])) + card[i], n, card);
            need[i] = 0;
        }
    }
    
    return (list);
}

int main(void)
{
    int card[100];
    int n, k;
    int i;
    
    while (1){
        scanf("%d", &n);
        scanf("%d", &k);
        
        if (n + k == 0){
            break;
        }
        memset(need, 0, sizeof(need));
        for (i = 0; i < n; i++){
            scanf("%d", &card[i]);
        }
        list = 0;
        printf("%d\n", combi(0, k, 0, n, card));
    }
    
    return (0);
}

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

int K(int);

int main(){
  int A,B;
  cin >> A >> B;
  int count = 0,reverse;
  for(int i = A;i <= B;i++){
    reverse = 0;
    for(int j = 0;j < 5;j++)
      reverse += (i % K(j+1) - i % K(j)) / K(j) * K(4-j);
    if(reverse == i)
      count += 1;
  }
  cout << count << endl;
}

int K(int N){
  int pow = 1;
  for(int i = 0;i < N;i++)
    pow *= 10;
  return pow;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,cnt=0;
  cin >> a >> b >> c;
  if(a==b && a!=c){
    cnt++;
  }
  else if(a==c && a!=b){
    cnt++;
  }
  else if(b==c && a!=b){
    cnt++;
  }
  if(cnt>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

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

    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 2019;
int INF = (int)2e18;

signed main() {
    int L, R;
    cin >> L >> R;
    int ans = INF;
    for (int i = 0; i <= 2019 && i + L <= R; i++) {
        for (int j = i + 1; j <= 2019 && j + L <= R; j++) {
            ans = min(ans, ((i + L) * (j + L)) % 2019);
        }
    }
    cout << ans << endl;

}


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

def ans(x):
    ANS=0
    while x:
        x%=bin(x).count("1")
        ANS+=1
    return ANS

LEN=int(input())
S=input().strip()
ONE=S.count("1")

ONEP=ONE+1
ONEM=ONE-1

PANS=0
MANS=0
for i in range(LEN):
    if S[i]=="1":
        PANS+=pow(2,LEN-1-i,ONEP)
        if ONEM<=0:
            continue
        MANS+=pow(2,LEN-1-i,ONEM)

for i in range(LEN):
    if S[i]=="0":
        print(ans((PANS+pow(2,LEN-1-i,ONEP))%ONEP)+1)
    else:
        if ONEM==0:
            print(0)
        else:
            print(ans((MANS-pow(2,LEN-1-i,ONEM))%ONEM)+1)
        
    


Measured memory_bytes: 80884
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
#define fir first
#define sec second
#define tct template<class type>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int maxn = 5e3, mod = 1e9 + 7;
int n, A, B, p[maxn + 5];
ll f[maxn + 5];

inline void red(int &x) { x += x >> 31 & mod; }
tct inline void cmax(type &x, type y) { x < y ? x = y : 0; }
tct inline void cmin(type &x, type y) { x > y ? x = y : 0; }

int main() {
	scanf("%d %d %d", &n, &A, &B);
	rep(i, 1, n) scanf("%d", &p[i]);
	rep(i, 1, n) {
		ll mn = 1e18;
		rep(j, 1, p[i]) mn = min(mn, f[j]);
		f[p[i]] = mn;
		rep(j, 1, p[i] - 1) f[j] += A;
		rep(j, p[i] + 1, n) f[j] += B;
	}
	ll mn = 1e18;
	rep(i, 1, n) mn = min(mn, f[i]);
	printf("%lld\n", mn);
	return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int m; cin >> m;
    OUT(48-m)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  cout << (M1 != M2 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 3648
N,M=map(int,input().split())
WA_chk = [0] * (N+1)
AC_chk = [0] * (N+1)
result = [] * (M+1)
WA_ans = 0
AC_ans = 0
for i in range(M): 
    A = [str(i) for i in input().split()]
    if A[1] == "WA":
        WA_chk[int(A[0])] += 1
    else:
        if AC_chk[int(A[0])] ==0:
            AC_ans += 1
            WA_ans += WA_chk[int(A[0])]
            AC_chk[int(A[0])] = 1
print(str(AC_ans) + " " + str(WA_ans))

Measured memory_bytes: 51608
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0545?year=2010

#include <bits/stdc++.h>

using namespace std;

const auto INF = (long long) 1e9;

int main() {
    int n, m;

    while (cin >> n >> m, n | m) {

        // Warshall–Floyd
        int dp[510][510];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (i == j) {
                    dp[i][i] = 0;
                } else {
                    dp[i][j] = INF;
                }
            }
        }

        for (int i = 0; i < m; ++i) {
            int a, b;
            cin >> a >> b;
            a--;
            b--;
            dp[a][b] = 1;
            dp[b][a] = 1;
        }

        for (int k = 0; k < n; ++k) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < n; ++i) {
            if (dp[0][i] == 1 or dp[0][i] == 2) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

/*
 * ワーシャル・フロイド。
 * 自分からの距離が1か2の人を数える。
 *
 */


Measured memory_bytes: 4068
#include<iostream>

int main()
{
	double x[2][2], y[2][2];
	
	while( 1 ){
		for( int i = 0; i < 2; i++ ){
			for( int j = 0; j < 2; j++ ){
				if( !( std::cin >> x[i][j] >> y[i][j] ) ) goto end;
			}
		}
		
		if( x[0][1] >= x[1][0] && x[0][0] <= x[1][1] && y[0][1] >= y[1][0] && y[0][0] <= y[1][1] ){
			std::cout << "YES" << std::endl;
		}
		else{
		 	std::cout << "NO" << std::endl;
		}
	}
end:

 	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
//#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define read_file()                     \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
#define N 300
double dp[N+1][N+1][N+1];

int32_t main(){
IOS;
int n;
cin>>n;
int a;
int p = 0,q = 0,r = 0;
for(int i=0;i<n;i++)
{
cin>>a;
if(a == 1) p++;
else if(a == 2) q++;
else r++;
}
for(int k=0;k<=n;k++)
{
    for(int j=0;j+k<=n;j++)
    {
        for(int i=0;i+j+k<=n;i++)
        {
             dp[i][j][k] = 0; 
             if(i+j+k == 0)
             {
                 continue;
             }     

            double x = 1.0 * n/(i+j+k);
            double p1 = 1.0 * i/(i+j+k);
            double p2 = 1.0 * j/(i+j+k);
            double p3 = 1.0 * k/(i+j+k);

            if(i)
            dp[i][j][k] +=  p1 * dp[i-1][j][k];
            if(j)
            dp[i][j][k] += p2 * dp[i+1][j-1][k];
            if(k)
            dp[i][j][k] += p3 * dp[i][j+1][k-1];

            dp[i][j][k] += x;
        }
    }
}
cout<<fixed<<setprecision(10)<<dp[p][q][r]<<endl;

}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    string O,E;
    cin >> O >> E;
    int o=O.size(),e=E.size();

    rep(i,o+e){
        cout << (i%2==0?O[i/2]:E[i/2]);
    }
    out("")
}


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

using namespace std;

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

  vector<int> p(N);
  int l, ii=0;
  while (cin >> l) {
    p[ii] = l;
    ii++;
  }

  vector<long> expt_x2(N);
  for (int i=0; i<N; i++) {
    expt_x2[i] = p[i]+1;
  }

  vector<long> cumsum(N+1);
  cumsum[0] = 0.0;
  cumsum[1] = expt_x2[0];
  for (int i=2; i<N+1; i++) {
    cumsum[i] = cumsum[i-1]+expt_x2[i-1];
  }


  long answer;
  if (K < N) {
    long expt_x2_sum_max = 0;
    for (int start_pos=0; start_pos<=N-K; start_pos++) {
      int end_pos = start_pos+K-1;
      long expt_x2_sum = cumsum[end_pos+1] - cumsum[start_pos];
      if (expt_x2_sum>expt_x2_sum_max) {
        expt_x2_sum_max = expt_x2_sum;
      }
    }
    answer = expt_x2_sum_max;
  } else {
    answer = cumsum[N];
  }

  cout << setprecision(30) << answer / 2.0 << endl;

  return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D){
  	cout << "Left" << endl;
  }
  else if(A+B == C+D){
  	cout << "Balanced" << endl;
  }
  else{
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Sentou
            var line = ReadLine().ToList();
            int n = line[0];    //スイッチの押された回数
            int t = line[1];    //お湯の出続ける秒数

            long totalTime = CalcTotalTimeOfHotWater(n, t);
            Console.WriteLine(totalTime);
        }

        static long CalcTotalTimeOfHotWater(int n, int t)
        {
            var people = ReadLine().ToList();

            int startTime = 0;
            int endTime = t;
            long sum = 0;

            for(int i = 1; i < n; i++)
            {
                int nextStartTime = people[i];

                if (nextStartTime < endTime)
                {
                    int diff = nextStartTime - startTime;
                    sum += diff;
                }
                else
                {
                    sum += t;
                }

                startTime = nextStartTime;
                endTime = startTime + t;
            }

            return sum + t;
        }

        static IEnumerable<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');

            foreach (var s in array)
            {
                yield return int.Parse(s);
            }
        }
    }
}

Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k << endl;
  return 0;
}

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

double dp[2][602];

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

    vector<vector<int>> G(N);
    for(int i=0;i<M;i++){
        int s, t;
        cin >> s >> t;
        G[s - 1].push_back(t - 1);
    }

    double ans = N;
    for(int k=0;k<N;k++){
        vector<double> dp(N, 0);
        for(int i=N - 2;i>=0;i--){
            int m = G[i].size();
            double expect_sum = 0, expect_max = 0;
            for(int to : G[i]){
                expect_sum += dp[to];
                expect_max = max(expect_max, dp[to]);
            }
            if(i == k && m > 1){
                dp[i] = (expect_sum - expect_max) / (m - 1) + 1;
            }else{
                dp[i] = expect_sum / m + 1;
            }
        }
        ans = min(ans, dp[0]);
    }
    printf("%.8f\n", ans);

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	veci x(5);
	rep(i, 5) cin >> x[i];
	rep(i, 5)
	{
		if (x[i] == 0)
		{
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	vector<vector<ll>> dp(60,vector<ll>(2,-1));
	dp[50][0]=0;
	for(int i=49;i>=0;--i){
		ll mask=(ll)1<<i;
		int cnt1=0;
		rep(i,n) if(a.at(i)&mask) cnt1++;
		ll sum0=cnt1*mask,sum1=(n-cnt1)*mask;
		if(dp[i+1][1]!=-1) dp[i][1]=max(dp[i][1],max(dp[i+1][1]+sum1,dp[i+1][1]+sum0));
		if(k&mask){
			dp[i][1]=max(dp[i][1],dp[i+1][0]+sum0);
			dp[i][0]=max(dp[i][0],dp[i+1][0]+sum1);
		}
		else dp[i][0]=max(dp[i][0],dp[i+1][0]+sum0);
	}
	cout << max(dp[0][0],dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<n1<<"\n"
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll>arr(n);
    rep (i,0,n)
    {
        cin>>arr[i];
    }
    ll ans=0;
    rep (i,0,n)
    {
        rep (j,i+1,n)
        {
            ans+=arr[i]*arr[j];
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())	//昇順
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())	//降順
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 1000000000000000000


using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

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

    string S;
    cin>>S;

    if(N%2) {
        cout<<"No"<<endl;
        return 0;
    }

    else if(S.substr(0,N/2)==S.substr(N/2,N/2)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)



int main(){
	int N,K; cin >> N >> K;
	vector<LL> a(N),s(N+1),v;
	s[0] = 0;
	repp(i,0,N){
		cin >> a[i];
		s[i+1] = s[i] + a[i];
	}
	repp(i,0,N) repp(j,i+1,N+1) v.push_back(s[j]-s[i]);
	LL ans = 0;
	//sort(v.begin(),v.end(),greater<LL>());
	repm(i,40,-1){
		int c = 0;
		for(auto u : v){
			if((u&ans) == ans && (u&(1ll<<i))){
				++c;
			}
		}
		if(c >= K) ans += (1ll<<i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6388