akhauriyash/Code-Regression huggingface dataset:
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 8*1001+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

bool find_if(const vector<int> &vec,const int &x){
  bool dp[vec.size()+1][4*maxn];
  memset(dp,0,sizeof dp);
  dp[0][2*maxn-1]=true;
  for(int i=0;i<vec.size();i++){
    for(int j=maxn;j<3*maxn-1;j++){
      dp[i+1][j]=max(dp[i][j-vec[i]],dp[i][j+vec[i]]);
    }
  }
  return dp[vec.size()][x+2*maxn-1];
}

int main(){
  IO;
  string s;
  cin>>s;
  int x,y;
  cin >> x >> y;
  int all=0;
  bool f=false;
  vector<int> ans[2];
  for(int i=0;i<s.size();i++){
    if(s[i]=='T'){
      ans[f].pb(all);
      all = 0;
      f = !f;
    }else{
      all++;
    }
  }
  ans[f].pb(all);
  vector<int> ans0(ans[0].begin()+1,ans[0].end());
  vector<int> ans1=ans[1];
  if(find_if(ans0,x-ans[0][0])&&find_if(ans1,y)){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  // for(int i=0;i<ans[0].size();i++)cout<<ans[0][i]<<' ';
  // cout<<endl;
  // for(int i=0;i<ans[1].size();i++)cout<<ans[1][i]<<' ';
  // cout<<endl;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  int s1=0,s2=0,s3=0,s4=0;
  
  for(int i=0;i<N;i++){
    cin>>S;
    
    if(S=="AC") s1++;
    else if(S=="WA") s2++;
    else if(S=="TLE") s3++;
    else if(S=="RE") s4++;
  }
  
  cout << "AC x " << s1 << endl;
  cout << "WA x " << s2 << endl;
  cout << "TLE x " << s3 << endl;
  cout << "RE x " << s4 << endl;
    
}


Measured memory_bytes: 3632
n, k = map(int,input().split())
x = list(map(int,input().split()))

cost = []

for i in range(n-k+1):
  cost_i = abs(x[i]-x[i+k-1])
  cost_i += min(abs(x[i]),abs(x[i+k-1]))
  cost.append(cost_i)
  
print(min(cost))

Measured memory_bytes: 14384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cout<<elem;}cerr<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	vector<llong> m,p;
	REP(i,n){
		int a;
		cin>>a;
		if(a<0) m.push_back(a);
		else p.push_back(a);
	}
	
	if(k==n){//全部選ぶ場合.
		llong ans=1;
		REP(i,m.size()) ans=ans*(MOD+m[i])%MOD;
		REP(i,p.size()) ans=ans*p[i]%MOD;
		cout<<ans<<endl;
		return 0;
	}
	
	if(m.size()==n and k%2==1){//全部負の数かつ奇数個選ぶ場合.
		llong ans=1;
		sort(ALL(m),greater<llong>());//絶対値が小さくなるように.
		REP(i,k) ans=ans*(MOD+m[i])%MOD;
		cout<<ans<<endl;
		return 0;
	}
	
	auto comp=[](int x,int y){
		return abs(x)>abs(y);
	};
	sort(ALL(m),comp);
	sort(ALL(p),comp);
	
	llong ans=1;
	int mp=0, pp=0;
	while(k>0){
		if(k==1 or m.size()-mp<2 or(m.size()-mp>=2 and p.size()-pp>=2 and m[mp]*m[mp+1]<p[pp]*p[pp+1])){
			ans=ans*p[pp++]%MOD;
			k--;
		}else{
			REP(i,2) ans=ans*(MOD+m[mp++])%MOD;
			k-=2;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 5396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{

    static void Main(string[] args)
    {
        int a = GetInputInt();
        if(a>= 3200)
        {
            Console.WriteLine(Console.ReadLine());
        }
        else
        {
            Console.WriteLine("red");
        }
       
        Console.ReadKey();
    }

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


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

void solve(int p,int q){
    cin.ignore();
    string buf;
    int ro=0,rc=0,co=0,cc=0,so=0,sc=0;
    auto incl=[&](string str){
        ro+=count(str.begin(),str.end(),'(');
        rc+=count(str.begin(),str.end(),')');
        co+=count(str.begin(),str.end(),'{');
        cc+=count(str.begin(),str.end(),'}');
        so+=count(str.begin(),str.end(),'[');
        sc+=count(str.begin(),str.end(),']');
    };
    auto cntIndent=[](string str){
        int res=0;
        for(int i=0;i<str.size();i++){
            if(str[i]!='.') break;
            res++;
        }
        return res;
    };
    vector<tuple<int,int,int>> rcs;
    for(int i=0;i<20;i++){
        for(int j=0;j<20;j++){
            for(int k=0;k<20;k++){
                rcs.push_back(make_tuple(i+1,j+1,k+1));
            }
        }
    }
    for(int i=0;i<p;i++){
        string str;
        getline(cin,str);
        vector<tuple<int,int,int>> tmp;
        int x=cntIndent(str);
        for(int i=0;i<rcs.size();i++){
            if(get<0>(rcs[i])*(ro-rc)+get<1>(rcs[i])*(co-cc)+get<2>(rcs[i])*(so-sc)==x){
                tmp.push_back(rcs[i]);
            }
        }
        rcs=tmp;
        incl(str);
    }
    ro=rc=0,co=cc=0,so=sc=0;
    vector<int> res;
    for(int i=0;i<q;i++){
        string str;
        getline(cin,str);
        int y=get<0>(rcs[0])*(ro-rc)+get<1>(rcs[0])*(co-cc)+get<2>(rcs[0])*(so-sc);
        for(int i=0;i<rcs.size();i++){
            if(get<0>(rcs[i])*(ro-rc)+get<1>(rcs[i])*(co-cc)+get<2>(rcs[i])*(so-sc)!=y){
                y=-1;
            }
        }
        res.push_back(y);
        incl(str);
    }
    for(int i=0;i<q;i++){
        cout<<res[i]<<(i+1==q ? "\n" : " ");
    }
    return;
}
int main(){
    int p,q;
    while(cin>>p>>q,p){
        solve(p,q);
    }
    return 0;    
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    ull T = 1, A = 1;
    while (N--) {
        ull a, b;
        cin >> a >> b;
        if (a < b) {
            ull k = T / a + ((T % a) > 0);
            ull T1 = k * a;
            ull A1 = k * b;
            if (T1 >= T && A1 >= A) {
                T = T1;
                A = A1;
            } else {
                k = A / b + ((A % b) > 0);
                A = k * b;
                T = k * a; 
            }
        } else if (a > b) {
            ull k = A / b + ((A % b) > 0);
            ull A1 = k * b;
            ull T1 = k * a;
            if (T1 >= T && A1 >= A) {
                T = T1;
                A = A1;
            } else {
                k = T / a + ((T % a) > 0);
                A = k * b;
                T = k * a; 
            }
        } else {
            T = max(T, A);
            A = T;
        }
    }
    cout << A + T << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
 
int main() {
  int a, b; cin >>a >>b;
  cout <<a * b <<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int a = 120;
    rep(i, 5) {
        int tmp; cin >> tmp;
        if(tmp != 0)
            a /= tmp;
    }
    cout << a << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200010
#define MOD 998244353
#define NIN -100000000
#define EPS 0.0000000001
char T[MAX];
int main()
{
    int n,i;
    char c;
    for(i=0;;i++)
    {
        scanf("%c",&c);
        if(!(c=='P'||c=='D'||c=='?')) break;
        T[i]=c;
        if(c=='?') T[i]='D';
    }
    n=i;
    for(i=0;i<n;i++)
    {
        printf("%c",T[i]);
    }
    return 0;
}


Measured memory_bytes: 3860
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int const MAX = 100002;
int const INFTY = 1000000005;
int a[MAX];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i<n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] << " ";
	int min = INFTY;
	int min_i;
	int half = a[n - 1] / 2;
	for (int i = n-2; i>=0; i--) {
		int v = a[i] - half;
		if (v<0) { v *= -1; }
		if (v<min) {
			min = v;
			min_i = i;
		}
	}
	cout << a[min_i] << endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

float diff(vint a, vint b){
  int n=a.size();
  float res=0;
  rep(i,n){
    int d = abs(a[i]-b[i]);
    res += d*d;
  }
  return sqrt(res);
}

bool sqrp(float n){
  if(ceil(n)==floor(n)) 
    return true;
  else return false;
}


signed main(void){
  int n,d;cin >> n >> d;
  int ans = 0;
  vvint x(n);rep(i,n)x[i].resize(d);
  rep(i,n)
    rep(j,d) cin >> x[i][j];

  rep(i,n-1){
    repi(j,i+1,n){
      bool p=false;
      p = sqrp(diff(x[i],x[j]));
      if(p){
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#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, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

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

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

int main(){
	int n;
	cin >> n;
	map<string, int> a;
	rep(i,n){
		string s, t;
		cin >> s >> t;
		if (s == "insert"){
			a[t] = 1;
		} else {
			if (a[t] == 1)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}

	return 0;
}




Measured memory_bytes: 52368
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
void solve()
{
    string str;
    cin>>str;
    int n=str.size();
    if(str[n-1]=='s')
    {
        str+="es";
    }
    else
        str+='s';
    cout<<str<<endl;

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


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n;
D dp[3005][3005],ans;
int main(void){
    scanf("%lld",&n);
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        D p;
        scanf("%lf",&p);
        for(int j=0;j<=i;j++){
            dp[i+1][j+1]+=dp[i][j]*p;
            dp[i+1][j]+=dp[i][j]*(D(1)-p);
        }
    }
    for(int i=n/2+1;i<=n;i++)ans+=dp[n][i];
    printf("%0.10lf\n",ans);
}


Measured memory_bytes: 68992
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int k, x;
	cin >> k >> x;
	string ans = "No";
	if (500 * k >= x) ans = "Yes";
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        x %= y;
        x = Math.min(Math.abs(y-x),x);
        System.out.println(x);
    }

    public static void main(String[] args) {
        new Main();
    }
}

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

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(){
 long long a,b,c,d; cin >> a >> b >> c >> d;
 long long e=lcm(c,d),sum=b-a+1;
 long long l=b/c-(a-1)/c; //lは[a,b]でcで割り切れる整数の個数
 long long m=b/d-(a-1)/d; //mは(ry
 long long n=b/e-(a-1)/e;

 //cout << e << ' ' << l << ' ' << m << ' ' << n << endl;
 cout << sum-l-m+n << endl;
}


Measured memory_bytes: 256
N, D=list(map(int,input().split()))
X=[]
Y=[]
for i in range(N):
    x, y=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
S=D**2
c=0
for i in range(N):
    if X[i]**2+Y[i]**2<=S:
        c+=1
print(c)

Measured memory_bytes: 96844
#include <cstdio>

int main() 
{
	int n;
	scanf("%d", &n);
	long long cur = 1000;
	int pr;
	scanf("%d", &pr);
	for (int i = 1; i < n; ++i) {
		int v;
		scanf("%d", &v);
		if (v > pr) cur = cur % pr + cur / pr * v;
		pr = v;
	}
	printf("%lld\n", cur);
	return 0;
}


Measured memory_bytes: 1732
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define ppb pop_back
int n,x,d;
map<int,vector<pair<int,int> > > rg;
bool cmp(pair<int,int> x,pair<int,int> y){
	return x.X==y.X?x.Y>y.Y:x.X<y.X;
}
signed main(){
	cin>>n>>x>>d;
	if(d==0)return cout<<(x?n+1:1),0;
	for(int i=0;i<=n;i++)rg[i*x%d].pb(mp((0+i-1)*i/2+i*x/d,(i?(n-i+n-1)*i/2:0)+i*x/d));
	int ans=0;
	for(map<int,vector<pair<int,int> > >::iterator i=rg.begin();i!=rg.end();i++){
		vector<pair<int,int> > &v=i->Y;
//		for(int j=0;j<v.size();j++)printf("[%lld,%lld] ",v[j].X,v[j].Y);puts("");
		sort(v.begin(),v.end(),cmp);
		vector<pair<int,int> > v0;
		for(int j=0;j<v.size();j++){
			if(v0.size()&&v0.back().Y>=v[j].Y)continue;
			if(v0.size()&&v0.back().Y>=v[j].X){
				int l=v0.back().X;
				v0.ppb();
				v0.pb(mp(l,v[j].Y));
			}
			else v0.pb(v[j]);
		}
		for(int j=0;j<v0.size();j++)ans+=v0[j].Y-v0[j].X+1;
	}
	cout<<ans;
	return 0;
}
/*1
3 4 2
*/
/*2
2 3 -3
*/
/*3
100 14 20
*/

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

class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        long[] arr = new long[itemCount];


        for (int i = 0; i < itemCount; i++)
        {
            long target = long.Parse(inpt[i]);
            arr[i] = target;
        }

        for (int i = itemCount / 2; i >= 0; i--)
        {
            MaxHieapfy(arr, i);
        }
        for (int i = 0; i < arr.Length; i++)
        {
            Console.Write(" " + arr[i]);
        }
        Console.WriteLine("");
    }

    public void MaxHieapfy(long[] arr, int rootIdx)
    {
        // ????????????INDEX
        int leftChildIndex = this.GetLeftChildIndex(rootIdx);
        int rightChildIndex = leftChildIndex + 1;
        int largest = -1;
        if (leftChildIndex < arr.Length && arr[rootIdx] < arr[leftChildIndex])
        {
            largest = leftChildIndex;
        }
        else
        {
            largest = rootIdx;
        }
        if (rightChildIndex < arr.Length && arr[largest] < arr[rightChildIndex])
        {
            largest = rightChildIndex;
        }
        if (largest != rootIdx)
        {
            long tmp = arr[rootIdx];
            arr[rootIdx] = arr[largest];
            arr[largest] = tmp;
            this.MaxHieapfy(arr, largest);
        }
    }


    private Dictionary<int, int> LeftChildDic = new Dictionary<int, int>();
    private int GetLeftChildIndex(int parentIndex)
    {
        if (LeftChildDic.ContainsKey(parentIndex))
        {
            return LeftChildDic[parentIndex];
        }
        int prev = 0;
        int idx = 0;
        for (int i = 0; i <= parentIndex; i++)
        {
            int plus = (int)Math.Pow(2, i);
            if (parentIndex >= prev && parentIndex < prev + plus)
            {
                int innerIdx = parentIndex - prev;
                idx = (innerIdx * 2) + (prev + plus);
                this.LeftChildDic.Add(parentIndex, idx);
                break;
            }
            else
            {
                prev += plus;
            }
        }
        return idx;
    }

    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 76556
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

long long dp[200100];

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

    for(int i = N; i<= 999; i++){
        if(i%111 == 0){
            cout <<i << endl;
            return 0;
        }

    }



}





Measured memory_bytes: 3576
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);

    // Input
    int n = s.nextInt();
    int[] v = new int[n];
    for (int i = 0; i < n; i++) {
      v[i] = s.nextInt();
    }
    int[] c = new int[n];
    for (int i = 0; i < n; i++) {
      c[i] = s.nextInt();
    }

    // Solve
    int maxValue = 0;
    for (int i = 0; i < n; i++) {
      maxValue += Math.max(0, v[i] - c[i]);
    }

    // Output
    System.out.println(maxValue);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int n,m;
string s;

int main(){
    //入力
    cin >> n >> s;
    m=0;
    for(int i=1;i<n;i++){
        int cnt_m=0;
        int cnt=0;
        for(int j=i;j<n;j++){
            if(s[j-i]==s[j]){
                cnt=min(cnt+1,i);
                cnt_m=max(cnt_m,cnt);
            }
            else{
                cnt_m=max(cnt_m,cnt);
                cnt=0;
            }
        }
        m=max(cnt_m,m);
    }
    cout << m << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  vector<ll> prime;
  map<ll, ll> amap;
  for(ll i=2;i*i<=N;++i) {
    if(N%i==0) {
      prime.push_back(i);
      while(N%i==0) {
        amap[i]++;
        N /= i;
      }
    }
  }
  if(N>1) {
    prime.push_back(N);
    amap[N]++;
  }
  int ans = 0;
  for(int i=0;i<prime.size();++i) {
    for(int j=0;j<1000;++j) {
      if(amap[prime[i]]<j*(j+1)/2) {
        ans += j-1;
        break;
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
      	LinkedList<Integer> l=new LinkedList<>();
    	int x=sc.nextInt();
    	int n=sc.nextInt();
    	for(int i=0;i<n;i++) {
    		l.add(sc.nextInt());
    	}
    	for(int i=0;true;i++) {
    		if(!l.contains(x-i)) {
    			System.out.println(x-i);
    			break;
    		}
    		else if(!l.contains(x+i)) {
    			System.out.println(x+i);
    			break;
    		}
    	}
    }
}


Measured memory_bytes: 27180
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int p = 1, j = 0, ans = 0;
    REP(i, N) {
        if (A[j] % p != 0) {
            ans += A[j] / p;
        } else if (A[j] > p) {
            ans += max(0LL, A[j] - 2 * p) / p + 1;
            if (p == 1) {
                p += 1;
            }
        } else {
            p += 1;
        }
        j++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        string str;
        while ((str = Console.ReadLine()) != "0 0 0")
        {
            string[] str2 = str.Split(' ');
            double a = double.Parse(str2[0]);
            double b = double.Parse(str2[1]);
            double c = double.Parse(str2[2]);
            double max = Math.Max(Math.Max(a, b), c);
            double r = (Math.Sqrt(a * a + b * b + c * c - max * max)) / 2;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                if (int.Parse(Console.ReadLine()) > r)
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}


Measured memory_bytes: 5664
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

	int arr[52];
	for (int i = 0; i < 52; i++) {
		arr[i] = 0;
	}

	int n;
	scanf("%d", &n);
	char suit;
	int num;
	for (int i = 0; i < n; i++) {
		scanf(" %c %d", &suit, &num);
		if (suit == 'S') {
			arr[num-1] = 1;
		} else if (suit == 'H') {
			arr[num+13-1] = 1;
		} else if (suit == 'C') {
			arr[num+13*2-1] = 1;
		} else if (suit == 'D') {
			arr[num+13*3-1] = 1;
		}
	}

	for (int i = 0; i < 52; i++) {
		if (arr[i] == 0) {
			if (i / 13 == 0) {
				printf("S %d\n", (i%13)+1);
			} else if (i / 13 == 1) {
				printf("H %d\n", (i%13)+1);
			} else if (i / 13 == 2) {
				printf("C %d\n", (i%13)+1);
			} else {
				printf("D %d\n", (i%13)+1);
			}
		}
	}

	return 0;
}




Measured memory_bytes: 2072
using System;
class abc148_d{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    String[] str = Console.ReadLine().Split(' ');
    int count = 0;
    int status = 1;
    foreach(String s in str){
      if(int.Parse(s) != status){
        count++;
      }
      else{
        status++;
      }
    }
    if(count == n){
      count = -1;
    }
    Console.WriteLine(count);
  }
}


Measured memory_bytes: 32348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();

		double ans = Math.sqrt(((x2 - x1) * (x2 - x1)) + (y2 - y1) * (y2 - y1));

		System.out.println(ans);
	}

}



Measured memory_bytes: 27996
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <queue>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef pair<int,int> P; // 状態を表すクラスpair

const int INF = 2510;
// 移動4方向のベクトル
int dx[4] = { 1,0,-1, 0 };
int dy[4] = { 0,1, 0,-1 };

int sx = 0, sy = 0; // スタートの座標
int gx, gy; // ゴールの座標
int H, W;
string s[60]; // 迷路を表す文字列の配列
int d[60][60] = {INF}; // 各点までの最短距離の配列
// {sx,sy}から{gx,gy}への最短距離を求める
// 辿り着けないとINF
int bfs() {
	queue<P> que;
	// スタート地点をキューに入れ、その点の距離を0に
	que.push(P(sx,sy));
	REP(i, H) {
		REP(j, W) {
			d[i][j] = INF;
		}
	}
	d[sx][sy] = 0;

	// キューが空になるまでループ
	while (!que.empty()) {
		// キューの先頭を取出す
		P p = que.front(); que.pop();
		// 取出してきた状態がゴールなら探索をやめる
		if (p.first == gx && p.second == gy)break;
		// 移動4方向をループ
		REP(i, 4) {
			// 移動後の点を(nx,ny)とする
			int nx = p.first + dx[i], ny = p.second + dy[i];
			// 移動が可能化の判定と既に訪れた事があるかの判定
			if (0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] != '#' 
				&& d[nx][ny] == INF) {
				// 移動できるならキューに入れ、その点の距離をpからの距離+1で確定する
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;
	gx = H - 1,gy = W - 1; // ゴールの座標
	int shCnt = 0;
	REP(i, H) {
		cin >> s[i];
		REP(j, W) {
			if (s[i][j] == '#') {
				shCnt++;
			}
		}
	} 

	int res = bfs();

	cout << (res!=INF?H*W-res-1-shCnt:-1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;
#define _ << ", " << 

using namespace std;

inline void read(int &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void read(long long &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void writeln(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar('\n');}
inline void write(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar(' ');}

const int N = 2e5 + 7;

int n, a, b, c, d;
char s[N];

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

	cin >> n >> a >> b >> c >> d;
	for (int i = 1; i <= n; i++)
		cin >> s[i];

	for (int i = a + 1; i <= max(c, d); i++)
		if (s[i] == '#' && s[i - 1] == '#'){
			cout << "No";
			return 0;
		}

	if (d < c){
		for (int i = b; i <= d; i++){
			if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.'){
				cout << "Yes";
				return 0;
			}
		}
		
		cout << "No";
	}
	else{
		cout << "Yes";
	}

}

Measured memory_bytes: 512
<?php
list($n, $m) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$aArray = array_map("intval", explode(" ", trim(fgets(STDIN))));
$pq = new SplPriorityQueue();
foreach($aArray as $a){
  $pq->insert($a, $a);
}
for($i = 0; $i < $m; $i++){
  $num = $pq->extract();
  $pq->insert(floor($num/2), floor($num/2));
}
$sum = 0;
for($i = 0 ; $i < $n; $i++){
  $sum += $pq->extract();
}
echo $sum;


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

// youtube回答を手打ちした直後なら組めた

int main() {
  int k;
  vector<long long> rr ;

  cin >> k;

  for ( int i=1 ; i < 10 ; ++i ) {
    rr.push_back(i);
  }
  while(1){
    if (rr.size() > k){
      cout << rr[k-1] << endl;
      return 0;
    }
    k -= rr.size();
    vector<long long> old;
    swap(old,rr);
    for (long long x : old){
      for (int i=-1 ; i<=1 ; i++){
        long long d = x%10 + i;
        if (d<0||d>9) continue;
        long long ans = x*10 + d;
        rr.push_back(ans); 
      }
    }
  }
  return 0;
}

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

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

ll dp[22][1 << 21];
int n;
bool a[22][22];
const int MOD = 1e9 + 7;

int main(){
	scanf("%d", &n);

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

	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < (1 << n); j++){
			if(dp[i][j] == 0) continue;

			for(int k = 0; k < n; k++){
				if(a[i][k] && (j & (1 << k)) == 0){
					int mask = j | (1 << k);
					dp[i + 1][mask] = (dp[i + 1][mask] + dp[i][j]) % MOD;
				}
			}
		}
	}

	printf("%lld\n", dp[n][(1 << n) - 1]);

	return 0;
}

Measured memory_bytes: 360832
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
V<int> v[200005]; 
P<int,int> p[200005];
bool vis[200005];
int ans[200005],co[200005],c,lst[200005];
map<P<int,int>,int> mp;
void dfs(int x){
	ans[c]++;co[x]=c;
	for(auto u:v[x])if(!vis[u]){
		vis[u]=1;
		dfs(u);
	}
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i,1,n)cin>>p[i].F>>p[i].S,mp[p[i]]=i;
	sort(p+1,p+n+1);
	set<P<int,int> > s;
	FOR(i,1,n){
		lst[mp[p[i]]]=i;
		auto it=s.upb(MP(p[i].S,i));
		if(it==s.begin()){
			s.emplace(MP(p[i].S,i));
		}else{
			auto now=s.begin();
			while(now!=it){
				v[i].PB((*now).S);
				v[(*now).S].PB(i);
				now++;
			}
			P<int,int> t=(*s.begin());
			while(!s.empty()&&(*s.begin()).F<p[i].S){
				s.erase(s.begin());
			} 
			s.emplace(t);
		}
	}
	FOR(i,1,n)if(!vis[i]){
		c++;
		vis[i]=1;
		dfs(i);
	}
	FOR(i,1,n)cout<<ans[co[lst[i]]]<<'\n';
	RE 0;
}




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


using namespace std;

#ifdef CLION
ifstream ifs("/home/kyuridenamida/CLionProjects/project/input.txt");
#define cin ifs
#define scanf DONT_USE_SCANF
#endif

typedef long long ll;

template<int M, bool IsPrime = false>
class Modulo {
    int n;

    static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
        return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
    }

public:
    Modulo() : n(0) { ; }

    Modulo(int m) : n(m) {
        if (n >= M)
            n %= M;
        else if (n < 0)
            n = (n % M + M) % M;
    }

    Modulo(ll m) {
        if (m >= M)
            m %= M;
        else if (m < 0)
            m = (m % M + M) % M;
        n = m;
    }

    explicit operator int() const { return n; }

    explicit operator ll() const { return n; }

    bool operator==(const Modulo &a) const { return n == a.n; }

    Modulo &operator+=(const Modulo &a) {
        n += a.n;
        if (n >= M) n -= M;
        return *this;
    }

    Modulo &operator-=(const Modulo &a) {
        n -= a.n;
        if (n < 0) n += M;
        return *this;
    }

    Modulo &operator*=(const Modulo &a) {
        n = (ll(n) * a.n) % M;
        return *this;
    }

    Modulo operator+(const Modulo &a) const {
        Modulo res = *this;
        return res += a;
    }

    Modulo operator-(const Modulo &a) const {
        Modulo res = *this;
        return res -= a;
    }

    Modulo operator-() const { return Modulo(0) - *this; }

    Modulo operator*(const Modulo &a) const {
        Modulo res = *this;
        return res *= a;
    }

    Modulo operator^(ll m) const {
        if (m == 0) return Modulo(1);
        const Modulo a = *this;
        Modulo res = (a * a) ^(m / 2);
        return m % 2 ? res * a : res;
    }

    typename std::enable_if<IsPrime, Modulo>::type
    operator/(const Modulo &a) const {
        return *this * inv(ll(a), M);
    }

    typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
        return *this *= inv(ll(a), M);
    }

    friend bool is_zero(const Modulo &x) { return int(x) == 0; }

    friend int abs(const Modulo &x) { return int(x); }

    static Modulo fact(int n, bool sw = true) {
        static std::vector<Modulo> v1 = {1}, v2 = {1};
        if (n >= (int) v1.size()) {
            const int from = v1.size(), to = n + 1024;
            v1.reserve(to);
            v2.reserve(to);
            for (int i = from; i < to; ++i) {
                v1.push_back(v1.back() * Modulo<M, true>(i));
                v2.push_back(v2.back() / Modulo<M, true>(i));
            }
        }
        return sw ? v1[n] : v2[n];
    }

    static Modulo comb(int a, int b) {
        if (b < 0 || b > a) return 0;
        return Modulo::fact(a, true) * Modulo::fact(b, false) *
               Modulo::fact(a - b, false);
    }
};

typedef Modulo<1000000007, true> mInt;


mInt f(int Y, int X) {
    return mInt::comb(X + Y + 2, Y + 1);
}

int main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    cout << (int) (f(r2, c2) + f(r1 - 1, c1 - 1) - f(r1 - 1, c2) - f(r2, c1 - 1)) << endl;
}


Measured memory_bytes: 21596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  vector<int> numbers;

  ll now = 1;
  ll count = 0;
  for (ll i = 0; i < N; i++) {
    if (S[i] == (char)('0' + now)) {
      count++;
    } else {
      numbers.push_back(count);
      now = 1 - now;
      count = 1;
    }
  }
  if (count != 0) {
    numbers.push_back(count);
  }

  // 1-0-1-0-1
  if (numbers.size() % 2 == 0) {
    numbers.push_back(0);
  }

  ll ans = 0;
  ll add = 2 * K + 1;
  ll left = 0;
  ll right = 0;
  ll sum = 0; // [left, right)のsum
  for (ll i = 0; i < numbers.size(); i += 2) {
    ll nextLeft = i;
    ll nextRight = min(i + add, (ll)numbers.size());

    while (nextLeft > left) {
      sum -= numbers[left];
      left++;
    }

    while (nextRight > right) {
      sum += numbers[right];
      right++;
    }

    ans = max(ans, sum);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
char buf[25000],out[10];
i;
X,Y,Z;
k;
p;
n;
main()
{
	n=read(0,buf,25000);
	while(buf[i++]-' ');
	while(buf[i++]-' ');
	for(;;)
	{
		k=buf[i++];
		if(k<'0')break;
		X=X*10+k-'0';
	}
	--n;--n;
	p=1;
	for(;;)
	{
		k=buf[n--];
		if(k<'0')break;
		Z+=p*(k-'0');
		p*=10;
	}
	p=1;
	for(;;)
	{
		k=buf[n--];
		if(k<'0')break;
		Y+=p*(k-'0');
		p*=10;
	}
	X-=Z;if(X<0)X=-X;
	Y-=Z;if(Y<0)Y=-Y;
	if(X<Y)X=Y;
	i=9;
	do{
		out[--i]=X%10+'0';
		X/=10;
	}while(X);
	write(1,out+i,9-i);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,n,u,v,c,e;
    double d;
    cin>>n>>d;
    double f;
    c=0;
    for(int i=0;i<n;i++)
    {
        cin>>u>>v;
        f=sqrt((u*u)+(v*v));
        //cout<<f<<endl;
        if(f<=d)
        {
            c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 3836
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#define F first
#define S second
using namespace std;
int t,p,r;
pair<int,pair<int,int> > s[55];
int w[55][11];
int main(void){
  while(cin >> t >> p >> r && t){
    for(int i = 0; i < t; i++){
      s[i].F = s[i].S.F = 0;
      s[i].S.S = i+1;
    }
    memset(w,0,sizeof(w));
    for(int i = 0; i < r; i++){
      int a,b,ti;
      string m;
      cin >> a >> b >> ti >> m;
      if(m == "WRONG"){
	w[a][b]++;
      }else{
	s[a-1].F--;
	s[a-1].S.F += w[a][b]*1200+ti;
      }
    }
    sort(s,s+t);
    for(int i = 0; i < t; i++){
      cout << s[i].S.S << " " << -s[i].F << " " << s[i].S.F << endl;
    }
  }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a , b , c , x ;
  cin >> a >> b >> c >> x ;
  int ans = 0 ;
  
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        int now = 500*i + 100*j + 50*k ;
        if(now == x) ans++;
      }
    }
  }
  
  cout << ans ;
  


}


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

using namespace std;





int n, m, cnt, ans, flag = 1, a[100001];
vector<int>v[100001];

void dfs(int u, int fa)
{
	for (auto i : v[u])
	{
		if (i == fa)continue;
		if (a[i] == -1)
		{
			a[i] = (a[u] ^ 1);
			dfs(i, u);
		}
		else
		{
			if (a[i] == a[u])flag = 0;
		}
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i<m; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	memset(a, -1, sizeof(a));
	a[1] = 0;
	dfs(1, 0);
	if (flag)
	{
		for (int i = 1; i <= n; i++)if (a[i])cnt++;
		cout << 1ll * cnt*(n - cnt) - m;
	}
	else
	{
		cout << 1ll * n*(n - 1) / 2 - m;
	}
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	map<ll,ll> mp;
	rep(i,n-1){
		ll a;
		cin>>a;
		a--;
		mp[a]++;
	}
	rep(i,n){
		cout<<mp[i]<<endl;
	}
}

Measured memory_bytes: 16120
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    int N, Q; cin>>N>>Q;
    string s; cin >> s;
    int n=(int)s.size();
    vector<int> CoC(n+1,0), CoA(n+1,0);
    REP(i, n-1){
        if(s[i]=='A' and s[i+1]=='C'){
            CoA[i+1] = 1;
            CoC[i+2] = 1;
        }
    }
    REP(i, n){
        CoA[i+1] += CoA[i];
        CoC[i+1] += CoC[i];
    }
    //cout << endl;
    //REP(i, n+1){
        //cout << CoA[i] << " ";
    //} cout << endl;
    //REP(i, n+1){
        //cout << CoC[i] << " ";
    //} cout << endl;
    
    REP(i,Q){
        int l, r; cin >>l>>r;
        cout << CoC[r]-CoA[l-1] << endl;
    }
    return 0;
    
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    map<string, int> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        mp[s]--;
    }
    int ans = 0;
    for (auto m : mp) {
        ans = max(ans, m.second);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 200005
#define int long long
using namespace std;
int n;
pair<int,int> p[li],tut[li];
bool cmp(pair<int,int> a, pair<int,int> b){
	if(a.fi<b.fi) return true;
	if(a.fi>b.fi) return false;
	if(p[a.se].fi>p[b.se].fi) return true;
	return false;
}
main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&p[i].fi,&p[i].se);
		tut[i]=mp(p[i].se,i);
	}
	sort(tut+1,tut+n+1,cmp);
	int sure=0;
	for(int i=1;i<=n;i++){
		int ind=tut[i].se;
		sure+=p[ind].fi;
		if(sure>p[ind].se){
			//printf("deb :: %d",i);
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}




Measured memory_bytes: 6528
#include<stdio.h>
int main(){
	int a,b,d,r; // int ??´??°
	// char ??????
	// double ???????°???°???
	double f;
	
	scanf("%d %d",&a,&b);
	
	d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	// f = (double)a / b;
	
	printf("%d %d %lf\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#!/usr/bin/env python3
h, w = map(int, input().split())
c = [[*map(int, input().split())] for _ in range(10)]
a = [[*map(int, input().split())] for _ in range(h)]
d = [c[i][1] for i in range(10)]
for i in range(10):
    for j in range(10):
        d[j] = min(d[j], min(c[j][k] + d[k] for k in range(10)))
d += [0]
print(sum(d[i] for i in sum(a,[])))


Measured memory_bytes: 10212