akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    bool flaga=0,flagb=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='A') flaga=1;
        if(s[i]=='B') flagb=1;
    }
    if(flaga && flagb) cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) cin >> s.at(i).at(j);
    }
    vector<int> t(D, 1);
    //for (int i = 0; i < D; i++) cin >> t.at(i);
    vector<int> dp(26, 0);
    ll ans = 0;
    int ans_c = 0;

    for (int i = 0; i < D; i++) {
        ll ans_pre = ans;
        for (int j = 0; j < 26; j++) {
            ll satisfy = s.at(i).at(j);
            ll tmp = ans_pre;
            tmp += satisfy;
            for (int k = 0; k < 26; k++) {
                if (k == j) continue;
                else tmp -= c.at(k) * (i + 1 - dp.at(k));
            }
            //if (i == 4 && j == 12) cout << "13: " << tmp << endl;
            if (tmp > ans) {
                ans = tmp;
                ans_c = j;
            }
        }
        //cout << ans << endl;
        dp.at(ans_c) = i + 1;
        //cout << "ans_c: " << ans_c << ", dp.at(ans_c): " << dp.at(ans_c) << endl;
        t.at(i) = ans_c + 1;
    }

    for (int i = 0; i < D; i++) {
        cout << t.at(i) << endl;
        //if (i < D - 1) cout << " ";
    }
    
    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int n, x;
    cin >> n >> x;
    n = n*2-1;
    if(x==1||x==n) cout << "No\n";
    else{
        cout << "Yes\n";
        if(n==3){
            cout << "1\n2\n3\n";
            return;
        }
        vector<int> ans(n, -1);
        
        set<int> aval;
        for(int i = 1; i <= n; ++i) aval.insert(i);
        if(x==n-1){
            ans[n/2-2]=x-2;
            ans[n/2-1]=x+1;
            ans[n/2]=x;
            ans[n/2+1]=x-1;
            aval.erase(aval.find(x-2));
            aval.erase(aval.find(x+1));
            aval.erase(aval.find(x));
            aval.erase(aval.find(x-1));
        }
        else{
            ans[n/2-2]=x+2;
            ans[n/2-1]=x-1;
            ans[n/2]=x;
            ans[n/2+1]=x+1;
            aval.erase(aval.find(x+2));
            aval.erase(aval.find(x-1));
            aval.erase(aval.find(x));
            aval.erase(aval.find(x+1));
        }
        
        for(int i = 0; i < n; ++i){
            if(ans[i]==-1){
                ans[i] = *aval.begin();
                aval.erase(aval.begin());
            }
        }

        for(int i : ans) cout << i << '\n';
        cout << '\n';
    }
}

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

Measured memory_bytes: 13532
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    s += '.';
    int ans = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != s[i - 1])
            ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
ll Get(int b) {
    return 1LL * (1 + b) * b / 2;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += i * Get(n / i);
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, k;
    cin>>n>>k;
    int p[n+5], vis[n+5] = {0};
    for(int i = 1; i <= n; i++)cin>>p[i];
    int cur = 1, cnt = 0;
    while(vis[cur] == 0){
        vis[cur] = ++cnt;
        cur = p[cur];
        k--;
        if(k == 0){cout<<cur;return ;}
    }
    int l = cnt - vis[cur] + 1;
    k %= l;
    f(i,k)cur = p[cur];
    cout<<cur;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

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

    vector<string> out{ "",
                        ".,!? ",
                        "abc",
                        "def",
                        "ghi",
                        "jkl",
                        "mno",
                        "pqrs",
                        "tuv",
                        "wxyz"};

    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        string ans = "";
        int base;
        int cnt = 0;
        rep(i, s.size()) {
            if (i >= 1 && s[i - 1] != '0' && s[i] == '0') {
                ans += out[base][(cnt - 1) % (int)out[base].size()];
                cnt = 0;
            } else if (s[i] != '0') {
                base = s[i] - '0';
                cnt++;
            }
        }

        cout << ans << endl;
        
    }

}

Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder.ABC171
{
    public class Problem1
    {
        public static void Main(string[] args)
        {
            var a = Console.ReadLine();

            var c = Convert.ToChar(a);

            if (Char.IsUpper(c))
            {
                Console.WriteLine("A");
            }
            else 
            {
                Console.WriteLine("a");
            }
        }
    }
}


Measured memory_bytes: 25920
int main() {
 
  double a,b,c;
  double S,L2, L, h;
 
  scanf("%lf %lf %lf",&a,&b,&c);
 
  S = 0.5*a*b*sin(c*3.14159265359/180);
  L2 = a*a+b*b-2*a*b*cos(c*3.1415926359/180);
  L = sqrt(L2)+a+b;
  h = 2*S/a;
 
  printf("%.11lf\n%.11lf\n%.11lf\n",S ,L,h); 
 
  return 0;
}


Measured memory_bytes: 2052
from collections import deque
S = deque(list(input()))
Q = int(input())
rev_cnt = 0
for i in range(Q):
    query = [_ for _ in input().split()]
    if len(query) == 1:
        rev_cnt += 1
    else:
        if query[1] == '1':
            if rev_cnt%2 == 0:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if rev_cnt%2 == 0:
                S.append(query[2])
            else:
                S.appendleft(query[2])
if rev_cnt % 2 == 0:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	char a, b;
	cin >> a >> b;
	if (a < b)
		cout << "<" << endl;
	else if (a > b)
		cout << ">" << endl;
	else
		cout << "=" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

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

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  std::vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  
  int result=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      result+=d[i]*d[j];
    }
  }
  cout<<result<<endl;



  return 0;
}


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

int main() {
    long long int n, m, k, ans = 0;
    cin >> n >> m >> k;
    long long int a[n], b[m], a_sum[n+1] = {0};
    vector<long long int> b_sum(m+1, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a_sum[i+1] += a_sum[i] + a[i];    
    }
    for(int i = 0; i < m; ++i) {
        cin >> b[i];
        b_sum[i+1] += b_sum[i] + b[i];    
    }
    for(long long int i = 0; i <= n; ++i) {  
        long long int t = k - a_sum[i];
        if(t < 0) continue;
        else if(t == 0) ans = max(ans, i);
        else ans = max(ans, i - 1 + distance(b_sum.begin(), upper_bound(b_sum.begin(), b_sum.end(), t)));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 9588
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p;
	vector<int>check;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		p.push_back(tmp);
		if (tmp == i+1) {
			check.push_back(1);
		}
		else {
			check.push_back(0);
		}
	}
	int answer = 0;
	for (int i = 0; i < N - 1; i++) {
		if (check[i] == 1) {
			answer++;
			check[i] = 0;
			if (check[i + 1] == 1) {
				check[i + 1] = 0;
			}
		}
	}
	if (check[N - 1] == 1) {
		answer++;
	}
	cout << answer << endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
using namespace std;

const double inf = 1e10;

struct D {
  vector<double> l, r;
  D():l(3,inf),r(3,-inf) {}
  void add(double x, int v) {
    ++v;
    mins(l[v],x);
    maxs(r[v],x);
  }
  double get(double t) {
    double nl = inf, nr = -inf;
    rep(i,3) {
      mins(nl, l[i]+i*t);
      maxs(nr, r[i]+i*t);
    }
    return nr-nl;
  }
  vector<double> events() {
    vector<double> ts;
    rep(i,3)rep(j,i) { // j < i
      {
        double t = (l[j]-l[i])/(i-j);
        if (t > 0) ts.push_back(t);
      }
      {
        double t = (r[j]-r[i])/(i-j);
        if (t > 0) ts.push_back(t);
      }
    }
    return ts;
  }
};

int main() {
  int n;
  cin >> n;
  D xd, yd;
  rep(i,n) {
    int x, y;
    char d;
    cin >> x >> y >> d;
    if (d == 'L') xd.add(x,-1), yd.add(y,0);
    if (d == 'R') xd.add(x,1), yd.add(y,0);
    if (d == 'U') xd.add(x,0), yd.add(y,1);
    if (d == 'D') xd.add(x,0), yd.add(y,-1);
  }
  vector<double> ts;
  ts.push_back(0);
  ts.push_back(inf);
  {
    auto nts = xd.events();
    ts.insert(ts.end(),nts.begin(),nts.end());
  }
  {
    auto nts = yd.events();
    ts.insert(ts.end(),nts.begin(),nts.end());
  }
  sort(ts.begin(),ts.end());
  double ans = 1e18;
  for (double t : ts) {
    double now = xd.get(t)*yd.get(t);
    mins(ans,now);
  }
  printf("%.10f\n", ans);
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    static pair<int, int> AB[200005];

    for (int i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }

    sort(AB, AB + N);

    cout << AB[N - 1].first + AB[N - 1].second << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

mint dp[3030][3030][3];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, S;
    cin >> N >> S;

    vi A(N);
    REP(i, N) cin >> A[i];

    dp[0][0][0] = 1;
    REP(i, N) {
        REP(j, S + 1) {
            dp[i + 1][j][0] += dp[i][j][0];
            dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1];
            dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2];
            if (j + A[i] <= S) {
                dp[i + 1][j + A[i]][1] += dp[i][j][0] + dp[i][j][1];
                dp[i + 1][j + A[i]][2] += dp[i][j][0] + dp[i][j][1];
            }
        }
    }

    print(dp[N][S][2]);

}


Measured memory_bytes: 218748
ans = [0] * 10**6

for x in range(1, 99):
    for y in range(1, 99):
        for z in range(1, 99):
            ans[(x + y + z)**2 - x * y - x * z - y * z] += 1

n = int(input())

for i in range(1, n + 1):
    print(ans[i])

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

using namespace std;
using int64 = long long;

int main() {
    int64 a, b, k;
    cin >> a >> b >> k;

    int64 tmp = a;
    a = max((int64)0, a - k);
    k = max((int64)0, k - tmp);
    b = max((int64)0, b - k);
    cout << a << " " << b << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> mpq;

const ll INF = 1e18;
const int mod = 1e9+7;
const int dX[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

#define whatis(x) cerr << #x << " is " << x << endl;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ft front()
#define bk back()
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define FOR(i, a) for(int i = 0; i < a; i++)
#define FoR(i, a) for(int i = 1; i <= a; i++)
#define ROF(i, a) for (int i = (a)-1; i >= 0; i--)
#define error(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) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//-----------------------| Template By: DakDak |----------------------------
int dp[100005];
int main(){
    int n, k; cin >> n >> k;
    int arr[n+1];
    FOR(i, n){
        cin >> arr[i];
    }
    int move[k]; iota(move, move+k, 1);
    for(auto &fill : dp){
        fill = 1e9;
    }
    dp[1] = 0;
    for(int i = 1; i < n; i++){
        for(int x : move){
            if(i + x <= n){
                dp[i+x] = min(dp[i+x], dp[i] + (abs(arr[i-1] - arr[i+x-1])));
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
    // Read nutes to self
}

/* NOTES TO SELF:
 * Check for int vs ll, worst case just switch everything to ll
 * Check for array bounds if you SEGFAULT, especially in range based loops
 * Always initialize everything in global 
 * Edge cases such as n = 1 or 0
 * Make sure to calculate big O complexity
 * You are geniosity you got this
 */





Measured memory_bytes: 1024
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vector<vi> f(n, vi(10, 0));
  REP(i, n) { cin >> f[i]; }

  vector<vi> p(n, vi(11, 0));
  REP(i, n) { cin >> p[i]; }

  int ans = -2e9;
  FOR(s, 1, (1 << 10)) {
    int tmp = 0;
    REP(i, n) {
      int c = 0;
      REP(j, 10) {
        if ((s >> j) % 2 == 1 && f[i][j] == 1)
          c++;
      }
      tmp += p[i][c];
    }
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iterator>

using namespace std;

vector<string> split(const string &str, char delim){
    vector<string> v;
    string buffer;
    stringstream ss(str);
    while(getline(ss, buffer, delim)) v.push_back(buffer);
    return v;
}

string getLine(){
    string str;
    getline(cin, str);
    return str;
}

template<typename T, typename R>
vector<R> map(vector<T> xs, R(*fp)(T)){
    vector<R> ys;
    for(T x : xs) ys.push_back(fp(x));
    return ys;   
}

vector<int> getLineNums(){
    return map(split(getLine(), ' '), +[](string x){ return stoi(x); });
}

string join(const char* delim = 0, const vector<string>& v = {}) {
    string s = "";
    if (!v.empty()) {
        s += v[0];
        for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
            if (delim) s += delim;
            s += v[i];
        }
    }
    return s;
}

template<typename T>
vector<T> cp_sort(vector<T> xs){
    vector<T> ys;
    copy(xs.begin(), xs.end(), back_inserter(ys));
    sort(ys.begin(), ys.end());
    return ys;
}

int main(void){
    cout << join(" ", map(cp_sort(getLineNums()), +[](int x){ return to_string(x); })) << endl;
    return 0;
}

Measured memory_bytes: 3256
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
*/
//根付き木
#include<iostream>
#include<string>
#include<vector>
using namespace std;

typedef struct Node{
  //int num; //ノード番号
  int parent; //親
  vector<int> children;
  string type;
}Node;

Node tree[100000];

int dep(int k){
  int depth=0;
  int x=tree[k].parent;
  for(int i=0;i<100000;i++){
    if(x==-1) return depth;
    else{
      x=tree[x].parent;
      depth++;
    }
  }
}
void output(int N){
  for(int i=0;i<N;i++){
    cout<<"node "<<i<<": "
    <<"parent = "<<tree[i].parent<<", "
    <<"depth = "<<dep(i)<<", "
    <<tree[i].type<<", "<<"[";
    for(int j=0;j<tree[i].children.size();j++){
      if(j)cout<<", ";
      cout<<tree[i].children[j];
    }
    cout<<"]"<<"\n";
  }
}
void makeTree(int N){
  int k,nodenum,child;
  for(int i=0;i<N;i++){
    cin>>nodenum>>k;
    for(int j=0;j<k;j++){
      cin>>child;
      tree[nodenum].children.push_back(child);
      tree[child].parent=nodenum;
    }
  }
  if(N==1) tree[0].type="root";else
  for(int i=0;i<N;i++){
    if(tree[i].parent==-1) tree[i].type="root";
    if(tree[i].children.size()==0) tree[i].type="leaf";
    }
}
int main(){
  int N;
  cin>>N;
  //初期化
  for(int i=0;i<N;i++){tree[i].parent=-1;tree[i].type="internal node";}
  makeTree(N);
  output(N);
}



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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

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

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	string s,t;cin>>s>>t;
	int n=s.size(),count=0;
	for(int i =0;i<n;i++){
		if(s[i]!=t[i])
		count++;
	}
	cout<<count<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;

int main(){
    int N;cin>>N;
    vector<int> B(N-1);
    REP(i, N-1) cin >> B[i];
    vector<int> A(N);
    while(true){
        bool update=false;
        REP(i,N){
            if(i==0){
                if(B[0]>=max(A[0]+1,A[1])) A[i]++,update=true;
            }
            else if(i==N-1){
                if(B[N-2]>=max(A[N-2],A[N-1]+1)) A[i]++,update=true;
            }
            else if(B[i]>=max(A[i]+1,A[i+1])&&B[i-1]>=max(A[i-1],A[i]+1)) A[i]++,update=true;
        }
        if(!update) break;
    }
    int ans=0;
    REP(i,N) ans+=A[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def main(n, m):
    dp = [(i + 1) for i in range(n)]
    dp = dp[::-1]
    for _ in range(m):
        p, c = map(int, input().split())
        dp = dp[p - 1:p + c - 1] + dp[:p - 1] + dp[p + c - 1:]
    print(dp[0])
while 1:
    n, r = map(int, input().split())
    if n == r == 0:
        break
    main(n,r)


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

int main(){
  double a, b;
  int c[8] = {0};

  while(cin >> a >> b){
    if(a<0.2)
      c[6]++;
    else if(a<0.6)
      c[4]++;
    else if(a<1.1)
      c[2]++;
    else
      c[0]++;
    if(b<0.2)
      c[7]++;
    else if(b<0.6)
      c[5]++;
    else if(b<1.1)
      c[3]++;
    else
      c[1]++;
  }
  cout << c[0] << " " << c[1] << "\n" << c[2] << " " << c[3] << "\n" << c[4] << " " << c[5] << "\n" << c[6] << " " << c[7] << "\n";
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

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

int main(){

  ll k;cin>>k;
  ll g[k+5][k+5];
  CLR(g,0);
  rep(i,1,k+1){
    rep(j,1,k+1){
      if(g[i][j]==0){
        g[i][j]=gcd(i,j);
        g[j][i]=gcd(i,j);
      }
    }
  }
  ll ans=0;
  rep(i,1,k+1){
    rep(j,1,k+1){
      rep(l,1,k+1){
        ans+=g[g[i][j]][l];
      }
    }
  }
  out(ans);


  return 0;
}


Measured memory_bytes: 3948
#include <stdio.h>
#include <math.h>
char str2num[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int main(void){
    int h, w, k;
    scanf("%d%d%d", &h, &w, &k);
    int i, j, m;
    long long int point;
    int c[30][30];
    char tmp[31];
    for(i = 0; i < h; i++){
        scanf("%s", tmp);
        for(j = 0; j < w; j++){
            for(m = 0; m < 10; m++){
                if(str2num[m] == tmp[j]){
                    c[i][j] = m;
                    break;
                }
            }
        }
    }
    int c_tmp[30][30];
    long long int ans = 0;
    int ii, jj;
    int tmp_list[30];
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            //c_tmpにコピー
            for(ii = 0; ii < h; ii++){
                for(jj = 0; jj < w; jj++){
                    c_tmp[ii][jj] = c[ii][jj];
                }
            }
            long long int point = 0;
            int cnt = 1;
            c_tmp[i][j] = 0;
            while(1){

                //ブロックを重力落下させる処理
                for(ii = 0; ii < w; ii++){
                    int kk = h-1;
                    for(jj = h-1; jj >= 0; jj--){
                        if(c_tmp[jj][ii] != 0){
                            c_tmp[kk][ii] = c_tmp[jj][ii];
                            kk--;
                        }
                    }
                    while(kk >= 0){
                        c_tmp[kk][ii] = 0;
                        kk--;
                    }
                }


                long long int point_tmp = 0;
                //ブロックに水平に隣り合ったマスを消す
                for(ii = 0; ii < h; ii++){

                    tmp_list[0] = 0;
                    for(jj = 1; jj < w; jj++){
                        if(c_tmp[ii][jj] == c_tmp[ii][jj-1]){
                            tmp_list[jj] = tmp_list[jj - 1] + 1;
                        }else{
                            tmp_list[jj] = 0;
                        }
                        //printf("%d ", tmp_list[jj]);
                    }
                    //printf("\n");

                    
                    for(int kk = 0; kk < w; kk++){
                        if(tmp_list[kk] >= k - 1){
                            for(int iii = 0; iii <= tmp_list[kk]; iii++){
                                point_tmp += c_tmp[ii][kk - iii];
                                c_tmp[ii][kk - iii] = 0;
                            }
                        }
                    }
                }

                if(point_tmp == 0){
                    break;
                }
                point += point_tmp * pow(2, cnt-1);
                cnt++;
            }
            ans = ans > point ? ans : point;
        }
    }
    printf("%lld\n", ans);
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int alpha[26]	= {0};

	char w[101]; scanf("%s", w);

	int len = strlen(w);
	REP(i,len){
		alpha[w[i] - 'a']++;
	}

	REP(i,26){
		if(alpha[i]%2 == 1){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;

}


Measured memory_bytes: 256
# coding: utf-8
import re
import math
import fractions
import random
import heapq
import time
import sys
input = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 
 
#main
N,Q=map(int,input().split())
E=[]
for a in range(N):
    s,t,x=map(int,input().split())
    E.append([s-x-0.5,1,x])
    E.append([t-x-0.5,-1,x])

for a in range(Q):
    E.append([int(input()),0,0])
E.sort(key=lambda x:x[0])
 
S=set()
H=[]
for time_,type_,x in E:
    if type_==1:
        S.add(x)
        heapq.heappush(H,x)
    elif type_==-1:
        if(x in S):S.remove(x)
    else:
        while H and H[0] not in S:
            heapq.heappop(H)
        print(H[0] if H else -1)

Measured memory_bytes: 147812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder=new StringBuilder();
		String[] str=new String[2];
		int x, y, z;

		try{
			while(true){
				str=reader.readLine().split(" ");
				x=Integer.parseInt(str[0]);
				y=Integer.parseInt(str[1]);
				if(x==0&&y==0)break;
				else{
					if(x>y){
						z=x;
						x=y;
						y=z;
					}
					builder.append(Integer.toString(x)).append(" ").append(Integer.toString(y)).append("\n");
				}
			}
		}catch(IOException e){
			e.printStackTrace();
		}

		System.out.print(builder);
	}
}

Measured memory_bytes: 26872
n=int(input())
#a,b=map(int,input().split())
#n,k=map(int,input().split())
d=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i+1,n):
        tmp=d[i]*d[j]
        ans+=tmp
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s.size() < 26) {
        for (char c = 'a'; c <= 'z'; ++c)
            if (!count(begin(s),end(s),c)) {
                cout << s + c <<endl;
                return 0;
            }
    } else {
        if (s == "zyxwvutsrqponmlkjihgfedcba") {
            cout << "-1\n";
            return 0;
        }
        bool ok[26] = {};
        for (;s.size();s.pop_back()) {
            for (int i = s.back() - 'a' + 1; i < 26; ++i)
                if (ok[i]) {
                    s.back() = 'a' + i;
                    cout << s << endl;
                    return 0;
                }
            ok[s.back()-'a'] = 1;
        }
    }
}


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

int main(){
    ll n;
    cin >>n;
    char al[] = {'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'};
    //vector<int>p;
    //int i=0;
    string ans;
    n =n-1;
    int cnt =0;
    for(;;){
        if(n<26){
            int num = (int)n;
            ans = al[n] + ans;
            break;
        }
        /*if(n%26 ==0){
            ans = al[25] + ans;
        }*/
        
        ans = al[n%26] +ans;
        n = n/26-1;

        
    }
    
    cout<< ans <<endl;

}



Measured memory_bytes: 3612
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int const mod = 1e9+7;

inline int safe_mul(const int x, const int y) {
    return x * 1LL * y % mod;
}

const int maxn = 100005;
vector<int> gr[maxn];

int k;
int dfs(const int v, const int p = -1, const int mins = 0, const int deep = 0) {
    int res = 1;
    int nmin = deep == gr[v].size() + 1;
    int cur = k - (deep == 0 ? 1 : 2);
    for (int ne : gr[v])
    if (ne != p) {
        res = safe_mul(res, dfs(ne, v, nmin, deep + 1));
        res = safe_mul(res, cur--);
    }
    return res;
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n >> k;

    for (int i = 1; i < n; ++i) {
        int a,b;
        cin >> a >> b;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }

    cout << safe_mul(k, dfs(1)) << endl;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
const int mod=1e9+7;
int qp(int a,int n){
    a%=mod;
    int res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
int inv(int x){
    return qp(x,mod-2);
}
int fact[maxn];
int c(int n,int k){
    if(n<=k)return 1;
    return fact[n]*inv(fact[k]*fact[n-k]%mod)%mod;
}
int a[maxn];
main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    fact[1]=1;
    for(int i=2;i<=n;++i)fact[i]=fact[i-1]*i%mod;
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=k;i<=n;++i){
        ans=(ans+c(i-1,k-1)*a[i])%mod;
    }
    for(int i=n-k+1;i>=1;--i){
        ans=(ans-c(n-i,k-1)*a[i]+mod)%mod;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 1792
def main():
    N = int(input())
    p = list(map(int,input().split()))
    count = 0
    for i in range(N-1):
        if p[i]!=i+1:
            count += 1
    
    if count >= 3:
        print("NO")
    else:
        print("YES")


if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<int> v[111111];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[141211];
int l[141211];
int j[114111];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s,s1;

//priority_queue<int> q;
queue<P> q;
string r1;
char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    if(a.y!=b.y)
    return a.y>b.y;
    return a.x>b.x;
}


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();
void f(int n,int m)
{
    o[n]++;
    if(n==k||n==e) return;
    for(int h=0;h<v[n].size();h++)
        if(v[n][h]!=m)
        f(v[n][h],n);
}

int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=b;t++)
    {
        scanf("%d %d",&n,&m);
        v[n].push_back(m);
        v[m].push_back(n);
    }
    for(int t=1;t<=a;t++)
        if(v[t].size()%2)
    {
        puts("No");
        return 0;
    }
    else if(v[t].size()>=6) c++;
    else if(v[t].size()>=4)
    {
        if(k) e=t;
        else k=t;
        d++;
    }
    if(c)
    {
        puts("Yes");
        return 0;
    }
    if(d<2)
    {
        puts("No");
        return 0;
    }
    if(d>=3)
    {
        puts("Yes");
        return 0;
    }
    //printf("%d %d",k,e);
    for(int h=0;h<v[k].size();h++)
    f(v[k][h],k);
    if(o[e]==2)
        puts("Yes");
    else puts("No");
}
/*
7 9
1 2
2 3
1 3
3 4
4 5
3 5
5 6
6 7
5 7
*/


Measured memory_bytes: 7552
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

const int dx2[] = { 1, 1, 1, 1,1,1,1,1,1,0,0,0,0 }; const int dy2[] = { 1,0,-1,1,0,-1,1,0,-1,0,-1,-1,-1 };const int dz2[] = { 1,1,1,0,0,0,-1,-1,-1,1,1,0,-1 };
struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, m, t;
	while (cin >> n >> m >> t,n) {
		vector<vvi> board(n, vvi(n, vi(n, 0)));
		vector<pii> sets(t);
		REP(i, t) {
			cin >> sets[i].first >> sets[i].second;
			sets[i].first--;
			sets[i].second--;
		}

		int win = 0;
		int turns = 0;
		REP(i, t) {
			REP(j, n)
				if (board[sets[i].first][sets[i].second][j] == 0) {
					board[sets[i].first][sets[i].second][j] = (i % 2) + 1;
					REP(k, 13) {
						int cnt = 1;
						int len = 1;
						while (0 <= sets[i].first + dx2[k] * len && sets[i].first + dx2[k] * len < n && 0 <= sets[i].second + dy2[k] * len && sets[i].second + dy2[k] * len < n && 0 <= j + dz2[k] * len && j + dz2[k] * len < n&&board[sets[i].first + dx2[k]*len][sets[i].second + dy2[k] * len][j + dz2[k] * len] == (i % 2) + 1) {
							cnt++;
							len++;
						}
						len = -1;
						while (0 <= sets[i].first + dx2[k] * len && sets[i].first + dx2[k] * len < n && 0 <= sets[i].second + dy2[k] * len && sets[i].second + dy2[k] * len < n && 0 <= j + dz2[k] * len && j + dz2[k] * len < n&&board[sets[i].first + dx2[k]*len][sets[i].second + dy2[k] * len][j + dz2[k] * len] == (i % 2) + 1) {
							cnt++;
							len--;
						}
						if (cnt >= m) {
							win = (i % 2) + 1;
							turns = i + 1;
							goto ANS;
						}
					}
					break;
				}
		}
	ANS:
		if (win == 0)
			cout << "Draw" << endl;
		if (win == 1)
			cout << "Black" << " " << turns << endl;
		if (win == 2)
			cout << "White" << " " << turns << endl;
	}
}

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

int main() {
  long long N, K;
  cin >> N >> K;
  long long p[N];
  for(long i=0; i<N; i++){
    cin >> p[i];
    p[i];
  }

  long long sum[N+1];
  sum[0] = 0;
  for(long long i=1; i<=N; i++){
    sum[i] = sum[i-1]+p[i-1];
  }

  long long ans = 0;
  for(long long i=K; i<=N; i++){
    ans = max(sum[i] - sum[i-K], ans);
  }

  cout << fixed << setprecision(10) << (ans+K)/2.0 << endl;
}


Measured memory_bytes: 3328