akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll dist[301][301] = {}, dist2[301][301] = {};
signed main(void) {

	int n, m, l;
	cin >> n >> m >> l;
	Fill(dist, 10000000000000LL);
	Fill(dist2, 10000000000000LL);
	REP(i, n)
		dist[i][i] = 0;
	
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		dist[a][b] = c;
		dist[b][a] = c;
	}

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

	REP(i, n) {
		REP(j, n) {
			if (dist[i][j] <= l) {
				dist2[i][j] = 1;
			}
		}
		dist2[i][i] = 0;
	}


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

	int q;
	cin >> q;
	REP(i, q) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		if (dist2[s][t] == 10000000000000LL)
			cout << -1 << endl;
		else
			cout << dist2[s][t] - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

int n, c;
multiset<int> a;
int main()
{
	int t, i;
	multiset<int>::iterator it;
	cin >> n;
	while (n--) {
		scanf("%d", &t);
		a.insert(t);
	}
	while (!a.empty()) {
		t = *a.rbegin();
		a.erase(a.find(t));
		for (i = 1; i <= t; i *= 2);
		it = a.find(i - t);
		if (it != a.end()) {
			a.erase(it);
			c++;
		}
	}
    cout << c << endl;
    return 0;
}

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

int n, le, lw, re, rw, ans = 0x3f3f3f3f;
char rec[300005];

int main() {
	scanf("%d%s", &n, rec+1);
	for (int i = 1; i <= n; i++) {
		(rec[i] == 'E' ? re : rw)++;
	}
	for (int i = 1; i <= n; i++) {
		(rec[i] == 'E' ? re : rw)--;
		ans = min(ans, lw + re);
		(rec[i] == 'E' ? le : lw)++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    while(cin >> n){
        if(!n) break;

        int table[n+1][n+1];
        rep(i,n+1) table[i][n] = 0, table[n][i] = 0;

        rep(i,n)rep(j,n){
            cin >> table[i][j];
            table[i][n] += table[i][j];
            table[n][j] += table[i][j];
        }
        rep(i,n) table[n][n] += table[i][n];

        rep(i,n+1){
            rep(j,n){
                printf("%5d",table[i][j]);
            }
            printf("%5d\n",table[i][n]);
        }
    }

    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

float calc_crossZ(vector<float> v1, vector<float>v2){
  float result = v1[0]*v2[1] - v1[1]*v2[0];
  return result;
}

bool same_sign(float a, float b){
  if(a<0 && b<0){
    return true;
  }else if(a>0 && b>0){
    return true;
  }
  return false;
}
    

bool do_calc(float x1, float y1, float x2, float y2, float x3, float y3, float xp,float yp){

  // vector<vector <float> > points(3, 2);
  
  // points[0][0] = x1;
  // points[0][1] = y1;
  // points[1][0] = x2;
  // points[1][1] = y2;
  // points[2][0] = x3;
  // points[2][1] = y3;

  
  vector<float> AB;
  AB.push_back(x2-x1);
  AB.push_back(y2-y1);
  vector<float> AC;
  AC.push_back(x3-x1);
  AC.push_back(y3-y1);
  vector<float> AP;
  AP.push_back(xp-x1);
  AP.push_back(yp-y1);

  float std = calc_crossZ(AB, AC);
  float comp = calc_crossZ(AB, AP);

  if(same_sign(std, comp)){
    return true;
  }else{
    return false;
  }


}
  

int main(){
  float x1, y1, x2, y2, x3, y3, xp, yp;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    if(do_calc(x1, y1, x2, y2, x3, y3, xp, yp)&&do_calc(x2, y2, x3, y3, x1, y1, xp, yp)&&do_calc(x3, y3, x1, y1, x2, y2, xp, yp)){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner

object Main {

  def check2(num: Int, input: => Array[Array[Boolean]]): Int = {
    var ans = 0
    for (j <- 0 until input(0).length) {
      ans += {
        var N = 0
        for (i <- 0 until input.length) {
          N += (if (if ((num >> i) % 2 == 1) input(i)(j) else !(input(i)(j))) 0 else 1)
        }
        math.max(N, input.length - N)
      }
    }
    ans
  }

  def make(R: Int, C: Int, sc: => Scanner): Int = {
    val input: Array[Array[Boolean]] = Array.fill(R)(Array.fill(C)(sc.nextInt == 1))
    var ans = 0
    for (i <- 0 until 1 << (R - 1)) {
      ans = math.max(ans, check2(i, input))
    }
    ans
  }

  def solve(sc: => Scanner): Unit = {
    val R: Int = sc.nextInt
    val C: Int = sc.nextInt
    if (R != 0 && C != 0) {
      println(make(R, C, sc))
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define SORT(v) sort(v.begin(), v.end())
typedef long long ll;

int main()
{
    int k, a, b;
    string s;

    cin >> k >> a >> b;

    //vector<int> v(/*size*/);
    FOR(i, a, b + 1)
    {
        if (i % k == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}


Measured memory_bytes: 3624
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    K, X = InputToInt()
    for i in range(2*K-1):
        print(X-K+i+1, end=' ')


Measured memory_bytes: 3060
s = input()
switch = -1
prev_c = 'R'
prev_i = 0
ans = [0] * len(s)
for i, c in enumerate(s):
    if prev_c == 'R' and c == 'L':
        switch = i
        prev_c = 'L'
        continue
    if prev_c == 'L' and c == 'R':
        total = i - prev_i
        if (switch - prev_i) % 2 == 0:
            ans[switch - 1] = total // 2
            ans[switch] = total - total // 2
        else:
            ans[switch] = total // 2
            ans[switch - 1] = total - total // 2
        prev_i = i
        prev_c = c
total = len(s) - prev_i
if (switch - prev_i) % 2 == 0:
    ans[switch - 1] = total // 2
    ans[switch] = total - total // 2
else:
    ans[switch] = total // 2
    ans[switch - 1] = total - total // 2
print(*ans)


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  

  for(int i = 0;i < 2;i++){
    if(s[i]==s[i+1]&&s[i]==s[i+2]){
      cout << "Yes" <<endl;
      return 0;
    }
  }

  cout << "No" <<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll d;
vector<ll> c(26,0),last(26,-1);
vector<vector<ll>> s;

ll score(vector<ll> &t){
    ll ans=0;
    rep(i,d){
        ans+=s[i][t[i]];
        last[t[i]]=i;
        rep(j,26) ans-=c[j]*(i-last[j]);
        //cout<<ans<<endl;
    }
    return ans;
}

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

    scanf("%lld",&d);
    vector<set<ll>> st(26);
    rep(i,26){
        st[i].insert(-1);
        st[i].insert(d);
    }
    vector<ll> t(d,0);
    rep(i,d){
        t[i]=i%26;
    }
    rep(i,26) scanf("%lld",&c[i]);
    s.assign(d,vector<ll>(26,0));
    rep(i,d)rep(j,26){
        scanf("%lld",&s[i][j]);
    }
    /*
    rep(i,d){
        scanf("%d",&t[i]);
        t[i]--;
        st[t[i]].insert(i);
    }
    */
    ll ans=score(t);
    //printf("%lld\n",ans);
    //cout<<ans<<endl;
    
    ll m=1e7-1e5; //scanf("%d",&m);
    ll p,di=0,q=0,ddi=17,dq=17,pans;
    rep(i,m){
        if(t[di]==q) q=(q+1)%26;
        pans=ans;
         //scanf("%d",&di); scanf("%d",&q);
        //di--; q--;
        p=t[di];
        ans+=s[di][q]-s[di][p];
        ll dd=*st[p].upper_bound(di)-di;
        ll du=di-*(--st[p].lower_bound(di));
        ans-=du*dd*c[p];
        dd=*st[q].upper_bound(di)-di;
        du=di-*(--st[q].upper_bound(di));
        ans+=du*dd*c[q];
        di=(di+ddi)%d;
        q=(q+dq)%26;
        if(pans<ans){
            st[p].erase(di);
            st[q].insert(di);
            t[di]=q;
        }
        else ans=pans;
    }
    rep(i,d) printf("%lld\n",t[i]+1);
    //printf("%lld\n",ans);
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    ull a, b, x;
    cin >> a >> b >> x;
    ull ans = b / x - a / x;
    if(a % x == 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

LL power(LL x,LL y, LL m){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%m;
  else if(y%2==0){
    LL tmp=power(x, y/2,m) % m;
    return tmp*tmp%m;
  }else {
    LL tmp=power(x, y/2,m) % m;
    return ((tmp*tmp)%m)*x%m;
  }
}

int main(){
    int n;
    cin>>n;
	string x;
    cin>>x;
    vi bt(n,0);
    int c=0;
    FOR(i,0,n){
        if(x[i]=='1'){
            bt[i]=1;
            c++;
        }
    }
    if(c==0){
        FOR(i,0,n){
            cout<<1<<endl;
        }
        return 0;
    }
    int c1=c-1,c2=c+1;
    if(c1==0)c1=1;
    int a1=0,a2=0;
    FOR(i,0,n){
        a1*=2;
        a2*=2;
        a1+=x[i]-'0';
        a2+=x[i]-'0';
        a1%=c1;
        a2%=c2;
    }
    cerr<<"a1: "<<a1<<" a2:"<<a2<<" c1:"<<c<<" c2:"<<c2<<endl; 
    FOR(i,0,n){
        int aa=a1,cc=c1,ans=1;
        if(x[i]=='0'){
            aa=a2;
            cc=c2;
            aa+=power(2,n-i-1,c2);
            aa%=c2;
        }else{
            if(c==1){
                cout<<0<<endl;
                continue;
            }
            aa+=c1;
            aa-=power(2,n-i-1,c1);
            aa%=c1;
        }
        //cerr<<" "<<aa<<endl;
        while(aa!=0){
            ans++;
            aa=aa%(__builtin_popcount(aa));
        }
        cout<<ans<<endl;


    }




}


Measured memory_bytes: 4448
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int a,b,c,d,res;
  cin >> a >> b;
  res = 0;
  
  if(a<b){
    c = a;
    d = b;
  }else{
    c = b;
    d = a;
  }
  for(int i=0;i<d;i++){
    res = res + c*pow(10,i);
  }
  cout << res <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 2.40 + c[j] * 15;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> ans;
    int pos = n - 1;
    while (pos >= 0) {
        ans.push_back(a[pos]);
        pos -= 2;
    }
    if (n%2) pos = 1;
    else pos = 0;
    while (pos < n) {
        ans.push_back(a[pos]);
        pos += 2;
    }

    for (int i = 0; i < n - 1; i++) {
        cout << ans[i] << ' ';
    }
    cout << ans[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define pb push_back

using namespace std;

typedef pair<int,int> par;

const int N=55;

int n,a[N];

vector<par> v;

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  int mn=1,mx=1;
  for(int i=1;i<=n;i++){
    if(a[i]<a[mn]) mn=i;
    if(a[i]>a[mx]) mx=i;
  }
  int flg=0;
  if(-a[mn]>a[mx]){
    mx=mn; for(int i=1;i<=n;i++) a[i]=-a[i]; flg=1;
  }
  for(int i=1;i<=n;i++)
    if(a[i]<0) a[i]+=a[mx],v.pb(par(mx,i));
  if(!flg)
    for(int i=2;i<=n;i++){
      if(a[i]<a[i-1]) a[i]+=a[i-1],v.pb(par(i-1,i));
    }
  else
    for(int i=n-1;i;i--)
      if(a[i]<a[i+1]) a[i]+=a[i+1],v.pb(par(i+1,i));
  printf("%d\n",v.size());
  for(int i=0;i<v.size();i++) printf("%d %d\n",v[i].first,v[i].second);
  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,x;
    cin>>N>>x;
    N=2*N-1;
    if(x==1||x==N){
        cout<<"No"<<endl;
        return 0;
    }

    int l=x-1,r=x+1;
    deque<int>d;
    d.push_back(x);
    d.push_front(l--);
    d.push_back(r++);
    while(d.size()<N){
        if(r<=N)d.push_front(r++);
        else d.push_front(l--);

        if(l>=1)d.push_back(l--);
        else d.push_back(r++);
    }

    cout<<"Yes"<<endl;
    rep(i,d.size())cout<<d[i]<<endl;
    return 0;
}


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

using ll = long long;
using Vi = std::vector<int>;
using Vl = std::vector<ll>;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

constexpr int I_INF = std::numeric_limits<int>::max();
constexpr ll L_INF = std::numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }
        template <typename T>
        void pvec(const T& vec, size_t sz) const {
            for (size_t i = 0; i < sz; i++)
                std::cout << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T>
        void pmat(const T& mat, size_t h, size_t w) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++)
                    std::cout << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    if (S.back() == 's') {
        S += "es";
    }
    else {
        S += "s";
    }
    prints()(S);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    std::ifstream ifs("./in_out/input.txt");
    std::cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    std::ofstream ofs("./in_out/output.txt");
    std::cout.rdbuf(ofs.rdbuf());
#endif
    std::cout << std::setprecision(18) << std::fixed;
    solve();
    std::cout << std::flush;
    return 0;
}

Measured memory_bytes: 3652
n,C,*H=map(int,open(0).read().split());p=[0];P=[0]
for i in range(1,n):
 g=lambda x:(p[P[x-1]]-p[P[x]])/(H[P[x]]-H[P[x-1]])-H[P[x-1]]-H[P[x]]
 while len(P)>1and g(1)>-2*H[i]:P.pop(0)
 p+=[p[P[0]]+(H[P[0]]-H[i])**2+C];P+=[i]
 while len(P)>2and g(-1)>g(-2):P.pop(-2)
print(p[-1])

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

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<int> dp(n + 1, inf);
  multiset<int> ms{inf};
  ms.insert(dp[n] = 0);
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '0') {
      dp[i] = *begin(ms) + 1;
    }
    ms.insert(dp[i]);
    if (i + m <= n) {
      ms.erase(ms.find(dp[i + m]));
    }
  }
  if (dp[0] >= inf) {
    cout << "-1\n";
    return 0;
  }
  vector<int> res;
  int i = 0;
  while (i < n) {
    int ni = find(begin(dp) + i, end(dp), dp[i] - 1) - begin(dp);
    res.push_back(ni - i);
    i = ni;
  }
  m = res.size();
  for (int j = 0; j < m; ++j) {
    cout << res[j] << " \n"[j == m - 1];
  }
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll k;
ll a[200005];
void solve() {
    cin >> n >> k;
    reps(i, n) cin >> a[i];
    ++n;

    ll ans = 0;
    rep(i, n - 1) a[i + 1] += a[i];
    rep(i, n) { a[i] -= i; a[i] %= k; }

    map<ll, ll> mp;
    rep(i, min<ll>(n, k)) ++mp[a[i]];
    rep(i, n) {
        --mp[a[i]];
        ans += mp[a[i]];
        if (i + k < n) ++mp[a[i + k]];
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long int n,k,m,q,count=0,count1=0,l;cin>>n>>m;
 // char c[2];
  string s;
  map<long long int,long long int>a;
  map<long long int,long long int>b;
  for (long long int i=0;i<m;i++) {
      cin>>q>>s;
      if (a[q]==0) {
          if (s[0]=='A') {count++;a[q]=1;count1+=b[q];}
          else {b[q]++;}
      }
  }
  cout<<count<<"  "<<count1<<endl;












}
    

Measured memory_bytes: 12800
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int c[2000], v[2000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				sum += v[j] - c[j];
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;

    cin >> N;

    vector <int> A(N);

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

    long long sum = 0;

    for (int i = 1; i < N; ++i) {
        sum += max(0, A[i-1]-A[i]);
        A[i] = max(A[i], A[i-1]);
    }

    cout << sum << endl;

    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H+2, vector<char>(W+2));
    for (int i=0; i<W+2; i++) s.at(0).at(i) = '.';
    for (int i=0; i<W+2; i++) s.at(H+1).at(i) = '.';
    for (int i=1; i<=H; i++) {
        s.at(i).at(0) = '.';
        s.at(i).at(W+1) = '.';
        for (int j=1; j<=W; j++) cin >> s.at(i).at(j);
    }
    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            int cnt=0;
            if (s.at(i).at(j)=='.') {
                for (int m=-1; m<2; m++) {
                    for (int n=-1; n<2; n++) {
                        if (s.at(i+m).at(j+n)=='#') cnt++;
                    }
                }
                s.at(i).at(j) = '0'+cnt;
            }
        }
    }
    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            cout << s.at(i).at(j);
        }
        cout << "\n";
    }
}

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

ll n,m,x,X[100001],modx[100000],num_x[100000],ans;

int main(){
    cin>>n>>m;
    rep(i,n){
        cin>>x;
        X[x]++;
        modx[x%m]++;
    }
    rep(i,100001)num_x[i%m]+=(X[i]/2)*2;
    
    rep(i,m){
        ll j=(m-i)%m;
        ll mn=min(modx[i],modx[j]);
        if(i==j)mn/=2;
        ans+=mn;
        modx[i]-=mn;
        modx[j]-=mn;
        ans+=min(modx[i],num_x[i])/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

cnt = 0

for i in range(0, n):
  for j in range(i+1, n):
    D = []
    for k in range(d):
        D.append((x[i][k] - x[j][k])**2)
    D = math.sqrt(sum(D))
    if isinstance(D, int) == True or D.is_integer() == True:
      cnt += 1

print(cnt)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,t;
  cin >> a >> b >> t;
  int time = 0;
  int sum = 0;
  while(time < t + 0.5) {
    time += a;
    sum += b;
  }
  cout << sum - b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<string> v;
int n;
int d[10][10]={{}};
string ans;

void solve(vector<int> l){
  string b;
  b=v[l[0]];
  for(int i=1;i<n;i++){
    b+=v[l[i]].substr(d[l[i-1]][l[i]],v[l[i]].size()-d[l[i-1]][l[i]]);
  }
  //cout << b << endl;
  if(ans.size()>b.size()) ans=b;
  if(ans.size()==b.size()&&b<ans) ans=b;
}

int main(){
  while(cin >> n,n){
    string s;
    int i,j,k;
    v.clear();
    for(i=0;i<n;i++){
      cin >> s;
      v.push_back(s);
    }

    
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	d[i][j]=0;
      }
    }
    
    bool f;
    for(i=0;i<n;i++){
      f=false;
      for(j=0;j<n;j++){
	if(i==j) continue;
	if(v[j].find(v[i])!=-1) f=true;	
      }
      if(f){
	v.erase(v.begin()+i);
	i--;n--;
      }
    }
    
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i==j) continue;
	for(k=1;k<=v[i].size();k++){
	  if(v[i].substr(v[i].size()-k,k)==v[j].substr(0,k))
	    d[i][j]=max(d[i][j],k);
	}
      }
    }

    
    vector<int> l;
    l.clear();
    ans="";
    for(i=0;i<n;i++) {
      l.push_back(i);
      ans+=v[i];
    }

    do{
      solve(l);
    }while(next_permutation(l.begin(),l.end()));
    
    cout << ans << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> n >> x >> y;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << abs(a[0] - y) << endl;
    return 0;
  }
  cout << max(abs(a[n-1]-y), abs(a[n-2] - a[n-1])) << endl;
  return 0;
}


Measured memory_bytes: 256
readlines.map(&:chomp).each{|line|
  arr = line.split
  stack = []
  arr.each{|i|
    case i
    when "*"
      b = stack.pop
      a = stack.pop
      stack << a * b
    when "+"
      b = stack.pop
      a = stack.pop
      stack << a + b
    when "-"
      b = stack.pop
      a = stack.pop
      stack << a - b
    when "/"
      b = stack.pop
      a = stack.pop
      stack << a / b
    else
      stack << i.to_f
    end
  }
  puts stack[0]
}

Measured memory_bytes: 8664
#include<iostream>

using namespace std;
int main(void){
    int n,x,l;
    int d=0,out=0;
    cin >> n;
    cin >> x;
    while(out<=n&&d<=x){
        cin >> l;
        d+=l;
        out++;
    }
    cout << out <<endl;
    return 0;
}

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

const int md = 1000000007;

int mul(int x, int y) {
	return (long long)x * y % md;
}
 
int main() {
  int n;
  scanf("%d", &n);
  int ans = 1;
  for (int i = 1; i <= n; i++) {
  	ans = mul(ans, i);
  }
  printf("%d\n", ans);
	return 0;
}

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

n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

graph = [[] for _ in range(n)]
for i in range(n-1):
    graph[uvw[i][0]-1].append((uvw[i][1]-1, uvw[i][2]))
    graph[uvw[i][1]-1].append((uvw[i][0]-1, uvw[i][2]))

stack = [0]
ans = [-1]*n
ans[0] = 0
while stack:
    node = stack.pop()
    for child in graph[node]:
        if ans[child[0]]!=-1:
            continue
        
        stack.append(child[0])
        if child[1]%2 == 0:
            ans[child[0]] = ans[node]
        else:
            ans[child[0]] = (ans[node]+1)%2

for a in ans:
    print(a)



Measured memory_bytes: 58620
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	set := make(map[int]int)
	for i := 0; i < N; i++ {
		a := sc.nextInt()
		if a%4 == 0 {
			set[4]++
		} else if a%2 == 0 {
			set[2]++
		} else {
			set[1]++
		}
	}

	if set[4]-set[1] >= 0 || (set[1]-1 == set[4] && set[2] == 0) {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 2176
fun main(args: Array<String>) {
    abc093c()
}

fun abc093c() {
    var abc = readLine()!!.split(" ").map { it.toInt() }
        .sorted().toMutableList()

    var cnt = 0
    while (abc[0] != abc[1] || abc[1] != abc[2]) {
        if (abc[0] == abc[1]) {
            abc[0]++
            abc[1]++
        } else {
            abc[0] += 2
        }
        abc = abc.sorted().toMutableList()
        cnt++
    }

    println(cnt)
}


Measured memory_bytes: 37784
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    unsigned int n,k;
    double max,sum;
    double *expects;
    unsigned int p;
    scanf("%u %u", &n, &k);
    
    expects = malloc( sizeof(double)*n );

    for(unsigned int i=0; i<n; i++) {
        scanf("%u", &p);
        expects[i] = 0.5*(p+1);
    }

    sum = 0;
    for(unsigned int j=0; j<k; j++) {
        sum+=expects[j];
    }

    max = sum;
    for(unsigned int i=0; i<=n-k; i++) {
        sum = sum - expects[i] + expects[i+k];

        if( sum>max) {
            max = sum;
        }
    }
    
    printf("%lf\n", max);

    free(expects);
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			int east = (1 + (b - a)) * (b - a) / 2;
			int x = east - b;
			System.out.println(x);

		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int val[101];
int wei[101];
int DP[102][100001];
#define rep(i,n) for(int i=0;i<n;i++)

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,w;
    
    cin>>n>>w;
    int sum=0;
    //exit(0);
    for(int i=0;i<n;i++)
    {
        cin>>wei[i]>>val[i];
        sum +=val[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=sum;j++)
        DP[i][j] = INT_MAX;
    }
    for(int i=0;i<=n;++i)
        DP[i][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=sum;j++)
        {
           
            if(j<val[i-1])
            DP[i][j] = DP[i-1][j];
            else
            DP[i][j] = min(DP[i-1][j-val[i-1]]+ wei[i-1], DP[i-1][j]);
            
        }
    }
    

    
    int ans = 0;

    for(int i=1;i<=sum;++i)
    {
        if(DP[n][i]<=w)
        ans = i;
    }


    cout<<ans;
    
    
    return 0;
}


Measured memory_bytes: 79232
N,M = map(int,input().split())
L = [0]*M
R = [0]*M
for i in range(M):
    L[i],R[i] = map(int,input().split())

min = L[0]
max = R[0]

for j in range(1,M):
    if min < L[j]:
        min = L[j]
    if max > R[j]:
        max = R[j]
if max-min+1 >= 0:
	print(max-min+1)
else:
  print(0)

Measured memory_bytes: 10868
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);
    
    int n, k;
    int num = 1;
    while (cin >> n >> k) {
        while (n--) {
            if (num <= k)
                num *= 2;
            else
                num += k;
        }
        cout << num << endl;
        num = 1;
        
    }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident $($r:tt)*) => {
        let mut $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident $($r:tt)*) => {
        let $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().unwrap()
    };
}
#[allow(unused_macros)]
macro_rules! outbuf {
    ($var:ident) => {
        use std::io::{stdout, BufWriter, Write};
        let stdout = stdout();
        let mut $var = BufWriter::new(stdout.lock());
    };
}

fn lower_bownd(v: &Vec<isize>, k: isize) -> isize {
    let mut ok = v.len() as isize;
    let mut err = -1;
    while ok - err > 1 {
        let mid = err + (ok - err) / 2;
        if v[mid as usize] >= k {
            ok = mid;
        } else {
            err = mid;
        }
    }
    ok
}

fn main() {
    input! {n, a: [isize; n], b: [isize; n]};
    // outbuf! {out};
    let mut ans = 0;
    let mut k = 1;
    for _i in 0..29 {
        let mask = 2 * k - 1;
        let mut c = b.iter().map(|x| *x & mask).collect::<Vec<_>>();
        c.sort();
        let mut s = 0isize;
        for aa in &a {
            let am = aa & mask;
            s -= lower_bownd(&c, k-am);
            s += lower_bownd(&c, 2*k-am);
            s -= lower_bownd(&c, 3*k-am);
            s += lower_bownd(&c, 4*k-am);
        }
        ans += (s&1) * k;
        k <<= 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 19604
#pragma region Macros
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos ) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos ) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos ) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos ) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos ) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos ) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7836
A,B,C,D,E,F = map(int,input().split())
noudo_max = (100*E)/(100+E)

# noudo,water,sugar
res = [-float('inf')]*3

i,j = 0,0
while 100*A*i<=F:
    j = 0
    while 100*A*i+100*B*j<=F:
        water = 100*A*i + 100*B*j
        sugar_max = F - water
        # sugarを全探索
        p = 0
        while C*p<=sugar_max:
            q = 0
            while C*p+D*q<=sugar_max:
                sugar = C*p+D*q
                if water+sugar!=0:
                    noudo = (100*sugar)/(water+sugar)
                    if noudo<=noudo_max and res[0]<noudo:
                        res = noudo,water,sugar
                q += 1
            p += 1
        j += 1
    i += 1

print(res[1]+res[2],res[2])


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s,t;
    int a,b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (u==s) {
        cout << (a-1) << " " << b << endl;
    }
    else {
        cout << a << " " << (b-1) << endl;
    }
    return 0;
}






















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

const int MAX_N = 1e4 + 1;

int N;
bool is_checked[MAX_N];
int A[MAX_N], B[MAX_N], C[MAX_N], cost[MAX_N];
vector<int> tree[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        tree[A[i]].push_back(B[i]);
        tree[B[i]].push_back(A[i]);
    }
    for (int i = 0; i < N; i++) cin >> C[i];
    sort(C, C + N);
    int ans = 0;
    for (int i = 0; i < N - 1; i++) ans += C[i];
    cout << ans << endl;
    queue<int> Q;
    int idx = N - 1;
    Q.push(0);
    is_checked[0] = true;
    while (!Q.empty()) {
        int node = Q.front();
        Q.pop();
        is_checked[node] = true;
        cost[node] = C[idx--];
        for (int i = 0; i < tree[node].size(); i++) {
            if (is_checked[tree[node][i]]) continue;
            Q.push(tree[node][i]);
        }
    }
    for (int i = 0; i < N; i++) cout << cost[i] << " \n"[i == N - 1];
    return 0;
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    int d = 0; int e = 0;
    if (a[a.size()-1] == b[0]) d = 1;
    if (b[b.size()-1] == c[0]) e = 1;
    if (d && e) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;

//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************

const int NMAX = 200005;

int n,x,ans[NMAX];
bitset<NMAX>viz;
vector<int>v;

int main()
{
    int i;

   // freopen("input","r",stdin);
    //freopen("output","w",stdout);
    cin.sync_with_stdio(false);

    cin >> n >> x;
    int aux = 2*n - 1;
    if (x == 1 || x == aux) cout << "No\n";
    else 
    {
        cout << "Yes\n";
        if (n == 2)
        {
            for (i = 1; i <= aux; i++) cout << i << "\n";
            return 0;
        }

        int poz = n;
        ans[poz] = x;
        viz[x] = 1;
        if (x == 2)
        {
            ans[poz + 1] = 1;
            ans[poz - 1] = 3;
            ans[poz + 2] = 4;
            viz[1] = viz[3] = viz[4] = 1;  
        }
        else if (x == aux - 1)
        {
            ans[poz + 1] = aux;
            ans[poz + 2] = aux - 2;
            ans[poz - 1] = 1;
            viz[1] = viz[aux] = viz[aux - 2] = 1; 
        }
        else
        {
            ans[poz - 1] = x - 1;
            ans[poz - 2] = x + 1;
            ans[poz + 1] = x + 2;
            viz[x - 1] = viz[x + 1] = viz[x + 2] = 1;
        }

        v.clear();
        for (i = 1; i <= aux; i++)
            if (!viz[i])
                v.push_back(i);
        for (i = 1; i <= aux; i++)
            if (ans[i] == 0)
            {
                ans[i] = v.back();
                v.pop_back();
            }

        for (i = 1; i <= aux; i++) cout << ans[i] << "\n";
    }
    return 0;   
}

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

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

    vector<int> a_i(m);
    for (int i = 0; i < m; i++)
        cin >> a_i.at(i);

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

    int j;
    for (j = 0; j < m - 1; j++)
        if (a_i.at(j) < x && x < a_i.at(j + 1))
            break;

    cout << min(j + 1, m - 1 - j) << endl;
}

Measured memory_bytes: 3640