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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;

constexpr lli plusScore = (lli)1e6;
constexpr lli D = 365;
constexpr lli asize = 26;
constexpr lli maximumNone = 40;
constexpr lli minimumNone = 5;

array<lli, asize> C;
array<lli, asize> Cnum;

array<array<lli, asize>, D> S;
array<array<lli, asize>, D> Snum;
array<bool, D> needChange;

lli calcScore(const vector<lli>& t) {
	vector<lli> last_open(asize, -1);
	lli score = 0;
	for (int i = 0; i < D; i++) {
		score += S[i][t[i]];
		//if (last_open[t[i]] != -1 && (i - last_open[t[i]]) < minimumNone) {
		//	needChange[i] = true;
		//}
		last_open[t[i]] = i;
		for (int j = 0; j < asize; j++) {
			score -= C[j] * (i - last_open[j]);
		}
		//cout << score << "\n";
	}

	return score;
};

int main() {
	chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();

	std::random_device seed_gen;
	std::mt19937 engine(seed_gen());

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

#if 0
	{
		ifstream ifs("sample2.in");
		ifs >> devNull;
		for (lli& i : C)ifs >> i;
		for (auto& arr : S) {
			for (lli& i : arr) {
				ifs >> i;
			}
		}
		ifs.close();
	}

#else

	{
		cin >> devNull;
		for (lli& i : C)cin >> i;
		for (auto& arr : S) {
			for (lli& i : arr) {
				cin >> i;
			}
		}
	}
#endif
	for (bool& b : needChange)b = false;
	iota(Cnum.begin(), Cnum.end(), 0);
	sort(Cnum.begin(), Cnum.end(), [&](lli l, lli r) {
		return C[l] < C[r];
	});


	for (lli i = 0; i < D; i++) {
		iota(Snum[i].begin(), Snum[i].end(), 0);
		sort(Snum[i].begin(), Snum[i].end(), [&](lli l, lli r) {
			return S[i][l] < S[i][r];
		});
	}

	vector<lli> T(D);

	for (int i = 0; i < D; i++) {
		if (i % asize == 0)shuffle(Cnum.begin(), Cnum.end(), engine);
		T[i] = Cnum[i % asize];
	}

	lli beforescore = calcScore(T);
	lli cnt = 0;

	while (chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now().time_since_epoch() - start.time_since_epoch()) < chrono::duration_cast<chrono::milliseconds>(1950ms)) {
		lli changeday = engine() % D;
		lli i = engine() % asize;
		vector<lli> tt = T;
		tt[changeday] = i;
		if (calcScore(T) < calcScore(tt)) {
			//if (cnt % 1000 == 0) {
			//	debug(calcScore(tt));
			//}
			T[changeday] = i;
		}
		cnt++;
	}



	for (lli i : T) {
		cout << i + 1 << "\n";
	}

	debug(calcScore(T) + plusScore);
	debug(cnt);
	cout << flush;
	return 0;
}



Measured memory_bytes: 3824
#include <stdio.h>
#include <unistd.h>
 
static const unsigned char TABLE_BITS_COUNT[] = {
  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6
};
 
static const unsigned char TABLE_TRAILING_ZEROS[] = { 0, 1, 6, 2, 7, 5, 4, 3 };
 
static unsigned int
fold_bitflag_func(
  unsigned int  acc,
  unsigned int  x,
  unsigned char *ary,
           int  col)
{
  unsigned char i = TABLE_TRAILING_ZEROS[((x * 0x1d) >> 5) & 0x07];
  return acc + TABLE_BITS_COUNT[ary[i] & col];
}
 
static unsigned int
fold_bitflag(
  unsigned int  n,
  unsigned int  init,
  unsigned int  (*func)(unsigned int, unsigned int, unsigned char *, int),
  unsigned char *data0,
           int  data1)
{
  unsigned int flg;
 
  while (1) {
    flg = n & ((~n) + 1);
    if (flg == 0) {
      break;
    }
    init = func(init, flg, data0, data1);
    n ^= flg;
  }
 
  return init;
}
 
static void
abc173_c(void)
{
  unsigned int h, w, k;
  unsigned char ary[6];
 
  scanf("%d %d %d\n", &h, &w, &k);
 
  for (int i = 0; i < h; i++) {
    unsigned char buf[8];
    scanf("%s\n", buf);
 
    unsigned char c = 0;
    for (int j = 0; j < w; j++) {
      if (buf[j] == '#') {
        c |= (1 << j);
      }
    }
    ary[i] = c;
  }
 
  unsigned int ans = 0;
  for (int row = 0; row < 1 << h; row++) {
    for (int col = 0; col < 1 << w; col++) {
      unsigned int cnt = fold_bitflag(row, 0, fold_bitflag_func, ary, col);
      if (cnt == k) {
        ans += 1;
      }
    }
  }
  printf("%d\n", ans);
}
 
int
main(void)
{
  abc173_c();
  return 0;
}

Measured memory_bytes: 1696
n,l = map(int, input().split())
sum = 0
for i in range(n):
    sum += l+i
low =0
if l+n-1 <= 0:
    low = l+n-1
elif l <= 0 and 0<=l+n-1:
    low = 0
else:
    low = l
print(sum - low)

Measured memory_bytes: 3060
while True:
    h1 = ""
    h2 = ""
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break

    for j in range(W):
      if j%2 == 0:
        h1 = h1 + "#"
      else:
        h1 = h1 + "."
    for j in range(W):
      if j%2 == 0:
        h2 = h2 + "."
      else:
        h2 = h2 + "#"
    
    for i in range(H):
        if i%2 == 0:
            print(h1)
        else:
            print(h2)
    print()

Measured memory_bytes: 7612
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin >> x;
	ll ans=2*(x/11);
	x%=11;
	if(x==0);
	else if(x>6) ans+=2;
	else if(x<=6) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(S[k-1])


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


//グローバルの置くと全部0で初期化される。
int dp[101][4][4][4];
      
int main(){


        ll n,a,b,c,d,e;
        cin >> n >> a >> b >> c >> d >> e;

        ll min_val = min({a,b,c,d,e});

        ll tmp = (n+min_val-1) / min_val;


        if(tmp==0) cout << 5 << endl;
        else cout << 5 + tmp - 1 << endl;

        return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
bool debug = true;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  string X;
  cin >> N >> X;
  ll pc = 0;
  for (ll i = 0; i < N; ++i) {
    if (X.at(i) == '1') {
      pc += 1;
    }
  }
  ll chose1 = 0;
  ll chose0 = 0;
  for (ll i = 0; i < N; ++i) {
    if (X.at(i) == '1') {
      chose0 += modpow(2, (N - i - 1), pc + 1);
      chose0 %= pc + 1;
      if (pc - 1 != 0) {
        chose1 += modpow(2, (N - i - 1), pc - 1);
        chose1 %= pc - 1;
      }
    }
  }
  for (ll i = 0; i < N; ++i) {
    ll left;
    ll ans = 1;
    if (X.at(i) == '1') {
      if (pc - 1 == 0) {
        cout << 0 << "\n";
        continue;
      }
      left = chose1 - modpow(2, (N - i - 1), pc - 1);
      if (left < 0) {
        left += pc - 1;
      }
      left %= pc - 1;
    }
    else {
      left = chose0 + modpow(2, (N - i - 1), pc + 1);
      left %= pc + 1;
    }
    // cout << "left" << left << "\n";
    while (left != 0) {
      left %= __builtin_popcount(left);
      ans += 1;
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 3760
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
cnt = defaultdict(int)
data = []
for i in range(n):
    cnt[a[i]] += 1

if sum(v >= 2 for v in cnt.values()) < 2:
    print(0)
elif cnt[max(cnt.keys())] >= 4:
    print(max(cnt.keys()) ** 2)

else:
    for k, v in cnt.items():
        if v >= 2:
            data.append(k)
    data.sort(reverse = True)
    print(data[0] * data[1])

Measured memory_bytes: 18600
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;

int main(void) {
	ll n, sum1 = 0, sum2 = 0,ans=10000000000;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0;i < n;i++) {
		cin >> a[i];
		sum1 += a[i];
	}
	for (ll i = 0;i < n - 1;i++) {
		sum2 += a[i];
		sum1 -= a[i];
		ans = min(ans, (ll)abs(sum1 - sum2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int H,W;
    int h,w;
    cin >> H >> W;
    cin >> h >> w;
    cout << H*W - (H*w + h*W - h*w) << endl;
 }


Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad

profit :: [Int] -> Int
profit (a:b:cs) = f a (b - a) (b:cs)
  where
    f minv maxv []     = maxv
    f minv maxv (x:xs) = f (min minv x) (max maxv (x - minv)) xs

main :: IO ()
main = do
    getLine
    xs <- fmap read . lines <$> getContents :: IO [Int]
    print $ profit xs



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

const int MOD = (int)1e9+7;

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

	int ans=(N-M)*100+M*1900;
	for(int i=0;i<M;i++)	ans*=2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
X = int(input())

memo = []
A = -1
while True:
    A += 1
    A5 = A ** 5
    memo.append(A5)
    if A5 > X:
        try:
            i = memo.index(A5 - X)
        except ValueError:
            continue
        else:
            B = i
            break
    else:
        try:
            i = memo.index(X - A5)
        except ValueError:
            continue
        else:
            B = -i
            break

print(A, B)

Measured memory_bytes: 9196
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;cin>>N;
    vector<ll> A(N+10);
    REP(i,N)cin>>A[i];
    ll dp[101000][2];REP(i,100000)dp[i][0]=dp[i][1]=-INF;
    dp[0][0]=0;
    dp[0][1]=-INF;

    REP(i,N){
        dp[i+1][0]=max(dp[i][0]+A[i],dp[i][1]-A[i]);
        dp[i+1][1]=max(dp[i][0]-A[i],dp[i][1]+A[i]);
    }
    cout<<dp[N][0]<<"\n";
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;

/**
 *
 * @author yoshkur
 */
public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData(br);
			StringBuilder sb = new StringBuilder();
			sb.append("a ");
			sb.append(inputData.comparison());
			sb.append(" b");

			System.out.println(sb.toString());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class InputData {

	private Integer a;
	private Integer b;

	public InputData(BufferedReader br) throws IOException {
		String line = br.readLine().trim();
		String[] values = line.split(" ");
		this.a =Integer.valueOf(values[0]);
		this.b =Integer.valueOf(values[1]);
	}

	public Integer getA() {
		return a;
	}

	public void setA(Integer a) {
		this.a = a;
	}

	public Integer getB() {
		return b;
	}

	public void setB(Integer b) {
		this.b = b;
	}

	public String comparison() {
		if (this.getA() < this.getB()) {
			return "<";
		} else if(this.getA() > this.getB()) {
			return ">";
		} else {
			return "==";
		}
	}
}

Measured memory_bytes: 23960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll G;
int D;
const int BIG=100000;
int dfs(int idx,vector<ll> ps, vector<ll>&cs,vector<bool> &fs) {
  if(idx==D) {
    int ret=0;
    ll acc=0;
    rep(i,D) {
      if(fs[i]) {
	acc+=cs[i]+ps[i]*(i+1)*100;
	ret+=ps[i];
	ps[i]=0;
      } else {
	ps[i]--;
      }
    }
    if(acc>=G) return ret;
    for(int i=D-1; i>=0; i--) {
      rep(t,ps[i]) {
	acc+=100*(i+1);
	ret++;
	if(acc>=G) return ret;
      }
    }
    return BIG;
  }
  fs[idx]=true;
  int ret=dfs(idx+1,ps,cs,fs);
  fs[idx]=false;
  return min(ret,dfs(idx+1,ps,cs,fs));
}

int main() {
  cin>>D;
  cin>>G;
  vector<ll> ps(D);
  vector<ll> cs(D);
  vector<bool> fs(D);
  rep(i,D)cin>>ps[i]>>cs[i];
  cout<<dfs(0,ps,cs,fs)<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(X: int, Y: int):
    print(-1) if X%Y == 0 else print(X)
        
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
(n,m),*e=[[*map(int,t.split())]for t in open(0)]
t=[[]for _ in range(n+1)]
for a,b in e:t[a]+=[b];t[b]+=[a]
q=[1]
a=[0]*-~n
while q:q=[a[j]==0and(a.__setitem__(j,i)or j)for i in q for j in t[i]]
print('Yes',*a[2:])

Measured memory_bytes: 60048
#include <stdio.h>

int main()
{
  int a, n, i;
  double math = 0;
  
  scanf("%d", &a);
  
  for(i = 0; i < a; i++)
  {
    scanf("%d", &n);
    math += 1.0/n;
  }
  
  printf("%lf\n", 1/math);
  
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

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

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    --a;
    ll n1 = b - ((b / c) + (b / d) - (b / lcm(c, d)));
    ll n2 = a - ((a / c) + (a / d) - (a / lcm(c, d)));
    cout << n1 - n2 << endl;

    return 0;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
//const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>d(n);
  rep(i,0,n)cin>>d[i];
  if(d[0]!=0)judge=false;
  vector<ll> cnt(n);
  rep(i,0,n)cnt[d[i]]++;
  ll sumbuf=0;
  ll ret=1;
  rep(i,0,n){
    if(sumbuf==n)break;
    if(i==0){
      sumbuf+=cnt[i];
      if(cnt[i]!=1){
        judge=false;
        break;
      }
      else continue;
    }
    sumbuf+=cnt[i];
    rep(j,0,cnt[i])qmod(ret,cnt[i-1]);
  }
  if(!judge)ret=0;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1792
INF = 10**18


def chmax(a: list, b: list) -> bool:
    if a[0] < b[0]:
        a[0] = b[0]
        return True
    return False


def chmin(a: list, b: list) -> bool:
    if a[0] > b[0]:
        a[0] = b[0]
        return True
    return False


N = int(input())
H = [int(x) for x in input().split()]
dp = [[INF] for _ in range(N)]
dp[0] = [0]

for i in range(1, N):
    b = [dp[i-1][0] + abs(H[i] - H[i-1])]
    chmin(dp[i], b)
    if i > 1:
        b = [dp[i-2][0] + abs(H[i] - H[i-2])]
        chmin(dp[i], b)

print(*dp[-1])


Measured memory_bytes: 20784
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int w = sc.nextInt();
            int h = sc.nextInt();
            int island_c = 0;
            if(w==0 && h==0) break;
            int[][] maps = new int[h][w];
            for(int i = 0; i<h; i++){
                for(int j = 0; j<w; j++){
                    maps[i][j] = sc.nextInt();
                }
            }
            for(int i = 0; i<h; i++){
                for(int j = 0; j<w; j++){
                    if(maps[i][j] == 0) continue;
                    island_c++;
                    dfs(maps, w, h, i, j);
                }
            }
            System.out.println(island_c);
        }
    }

    static void dfs(int[][] maps, int w, int h, int i, int j){
        if(i>0){
            if(maps[i-1][j] == 1) {
                maps[i-1][j] = 0;
                dfs(maps, w, h, i-1, j);
            }
            if(j>0){
                if(maps[i-1][j-1] == 1){
                    maps[i-1][j-1] = 0;
                    dfs(maps, w, h, i-1, j-1);
                }
            }
            if(j<w-1){
                if(maps[i-1][j+1] == 1){
                    maps[i-1][j+1] = 0;
                    dfs(maps, w, h, i-1, j+1);
                }
            }
        }
        if(i<h-1){
            if(maps[i+1][j] == 1){
                maps[i+1][j] = 0;
                dfs(maps, w, h, i+1, j);
            }
            if(j>0){
                if(maps[i+1][j-1] == 1){
                    maps[i+1][j-1] = 0;
                    dfs(maps, w, h, i+1, j-1);
                }
            }
            if(j<w-1){
                if(maps[i+1][j+1] == 1){
                    maps[i+1][j+1] = 0;
                    dfs(maps, w, h, i+1, j+1);
                }
            }
        }
        if(j>0){
            if(maps[i][j-1] == 1){
                maps[i][j-1] = 0;
                dfs(maps, w, h, i, j-1);
            }
            if(i>0){
                if(maps[i-1][j-1] == 1){
                    maps[i-1][j-1] = 0;
                    dfs(maps, w, h, i-1, j-1);
                }
            }
            if(i<h-1){
                if(maps[i+1][j-1] == 1){
                    maps[i+1][j-1] = 0;
                    dfs(maps, w, h, i+1, j-1);
                }
            }
        }
        if(j<w-1){
            if(maps[i][j+1] == 1){
                maps[i][j+1] = 0;
                dfs(maps, w, h, i, j+1);
            }
            if(i>0){
                if(maps[i-1][j+1] == 1){
                    maps[i-1][j+1] = 0;
                    dfs(maps, w, h, i-1, j+1);
                }
            }
            if(i<h-1){
                if(maps[i+1][j+1] == 1){
                    maps[i+1][j+1] = 0;
                    dfs(maps, w, h, i+1, j+1);
                }
            }
        }
    }

}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t; cin >> s >> t;
  if (t.size() == s.size() + 1 && s == t.substr(0,s.size())){
    cout << "Yes\n";
  }
  else cout << "No\n";
  return 0;
}



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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 1; i <= 9; ++i) {
        for(int j = 1; j <= 9; ++j) {
            if (i * j == n) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout <<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>ve;
int main()
{
     int n;ve.clear();
    cin>>n;
  for(int i=0;i<2*n;++i)
    {
          int x;
        cin>>x; ve.push_back(x);
        //cout<<ve[i]<<endl;
    }
    sort(ve.begin(),ve.end());
     int  ans=0;
    for(int i=0;i<2*n;i+=2)
      ans+=ve[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <bitset>

/*----------------------------------------------------------------*/

using ld = long double;
using vld = std::vector<ld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using str = std::string;
using vstr = std::vector<str>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

/*----------------------------------------------------------------*/

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<typename T> T sqr(T a) { return a * a; }

/*----------------------------------------------------------------*/

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

/*----------------------------------------------------------------*/

ll gcd(ll n, ll m) { return m != 0 ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; sqr(i) <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll popcnt(ll n) {
    n = ((n & 0xaaaaaaaaaaaaaaaa) >> 1) + (n & 0x5555555555555555);
    n = ((n & 0xcccccccccccccccc) >> 2) + (n & 0x3333333333333333);
    n = ((n & 0xf0f0f0f0f0f0f0f0) >> 4) + (n & 0x0f0f0f0f0f0f0f0f);
    n = ((n & 0xff00ff00ff00ff00) >> 8) + (n & 0x00ff00ff00ff00ff);
    n = ((n & 0xffff0000ffff0000) >> 16) + (n & 0x0000ffff0000ffff);
    n = ((n & 0xffffffff00000000) >> 32) + (n & 0x00000000ffffffff);
    return n;
}

/*----------------------------------------------------------------*/

void solve();

/*----------------------------------------------------------------*/

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n, m; std::cin >> n >> m;

    vll c(m);
    for (ll i = 0; i < m; i++)
        std::cin >> c[i];

    vll dp(n + 1, 1e9); dp[0] = 0;
    for (ll i = 0; i < n; i++) for (ll j = 0; j < m; j++)
        if (i + c[j] <= n)
            chmin(dp[i] + 1, dp[i + c[j]]);

    std::cout << dp[n] << '\n';
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


const int VMAX = 10;

int dist[VMAX][VMAX];
signed main() {
  string s;
  cin >> s;
  int ac = 0;
  int bc = 0;
  int cc = 0;
  for (size_t i = 0; i < s.length(); i++) {
    ac += s[i] == 'a';
    bc += s[i] == 'b';
    cc += s[i] == 'c';
  }
  bool res = (abs(ac - bc) <= 1) && (abs(bc - cc) <= 1) && (abs(cc - ac) <= 1);
  cout << (res ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int a = sc.nextInt();
   int b = sc.nextInt();
 
   Integer[] sq = new Integer[350];
   int t10 = 1;
   if(b==100) t10=1000;
   else if(b>=10) t10=100;
   else t10=10;
   for(int i=1;i<=350;i++) 
   {
     sq[i-1]=i*i;
   }
   if(Arrays.asList(sq).contains(a*t10+b)) System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(32);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

vector<ll> fact;
map<ll, ll> mp;

void primeF(ll n){
    while(n % 2 == 0){
        mp[2]++;
        n /= 2;
    }
    for(ll i = 3 ; i <= sqrt(n) ; i += 2){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n > 2){
        mp[n]++;
    }
}

void solve()
{
    ll n; cin>>n;
    primeF(n);
    ll ans = 0;
    for(auto i : mp){
        ll cnt = i.S, j = 1;
        while(cnt >= j){
            cnt -= j++;
            ans++;
        }
    }
    cout<<ans<<nl;
}
 
int main(){
    boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 3704
import math
A, B, H, M = map(int, input().split())
rshort = H * (360 / 12) + M / 2;
rlong = M * (360 / 60)
ang = abs(rlong - rshort)
ang = min(ang, 360 - ang)
rad = ang * math.pi / 180
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad))
print(ans)

Measured memory_bytes: 9516
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
        int n; int ans=-1;
        string s;
        cin >> n;
        cin >> s;
        string s1,s2;
        for(int i=1; i<n; i++) {
                s1=s.substr(0,i);
                s2=s.substr(i,n-i);
                int c=s1.size(); int k=s2.size();
                sort(s1.begin(),s1.end());
                sort(s2.begin(),s2.end());
                string s3; string s4;
                s3=s1[0]; int d=0;
                s4=s2[0];
                for(int i=1; i<c; i++) {
                        if(s1[i]!=s1[d]) {
                                s3+=s1[i];
                                d=i;
                        }
                } d=0;
                for(int i=1; i<k; i++) {
                        if(s2[i]!=s2[d]) {
                                s4+=s2[i];
                                d=i;
                        }
                }
                int l=s3.size(); int o=s4.size(); int num=0;
                if(l<o) {
                        for(int j=0; j<l; j++) {
                                for(int i=0; i<o; i++) {
                                        if(s3[j]==s4[i]) num++;
                                }
                                ans=max(ans,num);
                        }
                }
                else{
                        for(int j=0; j<o; j++) {
                                for(int i=0; i<l; i++) {
                                        if(s4[j]==s3[i]) num++;
                                }
                                ans=max(ans,num);
                        }
                }
       }
        cout << ans<<endl;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    const input = arg.trim().split("\n");
    const N = parseInt(input[0].split(" ")[0],10);
    const K = parseInt(input[0].split(" ")[1],10);
    const pArray = input[1].split(" ").map(n => parseInt(n,10));

    const kitaichi = i => (i + 1) / 2;
    const kitaichiArray = pArray.map(p => kitaichi(p));

	const cumulativeSum = (array) => {
		let arr = [0];
		array.reduce((a, i) => {
			a === 0 ? arr.push(i) : arr.push(a + i);
			return a + i
		}, 0)
		return arr;
	}

	const cumulativeSumArray = cumulativeSum(kitaichiArray);
	
    let answer = 0;
    for (let i=K; i<N+1; i++) {
        if (answer < (cumulativeSumArray[i] - cumulativeSumArray[i-K])) {
            answer = (cumulativeSumArray[i] - cumulativeSumArray[i-K]);
        } else {
            continue;
        }
    }

	console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 43064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ts  ll t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr ll n,i;cin>>n; ll a[n+1];for(i=0;i<n;i++)
#define ln cout<<"\n"; 
#define prime  1000000007,mltp=263;

int main() {
fast
ll x[6],i;
for(i=1;i<6;i++)
{cin>>x[i];
if(x[i]==0)
{cout<<i;
break;}}
return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N, M = inpl()

G = [[] for _ in range(N)]
rG = [[] for _ in range(N)]

for i in range(M):
    a, b = inpl()
    G[a-1].append(b-1)
    rG[b-1].append(a-1)

def SCC(G, rG):
    N = len(G)
    def dfs(i):
        nonlocal t, rorder, searched
        searched[i] = True
        for j in G[i]:
            if not searched[j]:
                dfs(j)
        rorder[t] = i
        t += 1

    def rdfs(i):
        nonlocal t, group, g
        group[i] = g
        for j in rG[i]:
            if group[j] == -1:
                rdfs(j)

    t = 0
    rorder = [-1]*N
    searched = [0]*N
    group = [-1]*N

    for i in range(N):
        if not searched[i]:
            dfs(i)
    g = 0
    for i in range(N-1, -1, -1):
        if group[rorder[i]] == -1:
            rdfs(rorder[i])
            g += 1
    return group, g

group, g = SCC(G, rG)

ans = [[] for _ in range(g)]
for i in range(N):
    ans[group[i]].append(i+1)

for i in range(N):
    print(*ans[group[i]])


Measured memory_bytes: 9056
import java.util.Scanner;

public class Main {
	Scanner cin;
	int N,d;
	public void solve() {
		cin = new Scanner(System.in);
		N = cin.nextInt();
		d = cin.nextInt();
		int sum = 0;
		for(int i = 0;i < N;i++){
			int p = cin.nextInt() - d;
			sum += Math.max(0, p);
		}
		System.out.println(sum == 0 ? "kusoge" : sum);
	}

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

Measured memory_bytes: 29836
def a():
    N = int(input())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
        if i > 1:
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    return dp[i]

  
if __name__ == '__main__':
    ans = a()
    print(ans)

Measured memory_bytes: 13976
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
map <int,int> sum;
int n,a[200001],ans;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		if(a[i]<i)
		{
			++sum[i-a[i]];
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(a[i]<i)
		{
			--sum[i-a[i]];
		}
		ans+=sum[i+a[i]];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 19040
#include<iostream>
using namespace std;
int main(){
	int j,m,f,r,F,A,B,C,D,i;
	for(;;){
	cin>>m>>f>>r;
	if(m==-1 && f==-1 && r==-1){
	break;
	}
	if(m+f>=80){
	cout<<"A"<<endl;
	}
	else if(m+f>=65 && m+f<80){
		cout<<"B"<<endl;
	}
	else if(m+f>=50 && m+f<65 || r>=50){
	cout<<"C"<<endl;
	}
	else if(m+f<30 || m==-1 || f==-1){
	cout<<"F"<<endl;
	}	
	else if(m+f>=30 && m+f<50){
	cout<<"D"<<endl;
	}
	}
return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> C(n - 1), S(n - 1), F(n - 1);
    rep(i, n - 1) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 0; i < n - 1; i++) {
        // これでi+1に移動
        int res = S[i] + C[i];
        for (int j = i + 1; j < n - 1; j++) {
            if (res == S[j]) {
                res += 0;
            } else if (res > S[j]) {

                if ((res/ F[j]) * F[j] == res) {
                    res += 0;
                } else {
                    res += ((res/ F[j]) + 1) * F[j] - res;
                }
            } else {
                res += S[j] - res;
            }
            res += C[j];
        }

        cout << res << endl;
    }

    cout << 0 << endl;
}

Measured memory_bytes: 3596
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for _ in range(N):
    a = list(map(int, input().split()))
    A.append(a)
    
ans = 0
for pro in A:
    s = C
    for i in range(M):
        s += pro[i] * B[i]
    if s>0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
const int MOD = 1000000007;

int main() {
  ll Ans = 0;  // 回答：
  int N,M; cin >> N >> M; // 展望台数・道数
  vector<int> H(N);
  rep(i,N){cin >> H.at(i);}
  vector<int> HA(N,1);  // 判定フラグ
  vector<int> A(M),B(M);  // 道情報

  rep(i,M){
    int A,B;
    cin >> A >> B;  // 展望台情報
    if(H.at(A-1) == H.at(B-1)){  // 同じとき
      HA.at(A-1)=0;
      HA.at(B-1)=0;
    } else if ( H.at(A-1) < H.at(B-1) ){
      HA.at(A-1)=0;
    } else {
      HA.at(B-1)=0;
    }
    
  }
  rep(i,N){
//    cout << HA.at(i) << endl;
    if( HA.at(i) != 0 ) {
      Ans++;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n;  cin >> n;
    vector<pair<int, int> > a(n+1);
    for (int i = 1; i < n+1; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }

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

    for (int i = 1; i < n+1; i++)
        cout << a[i].second << " ";

    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int i, count;
  string str;
  string data = "yuiophjklnm";
  string::iterator iter1, iter2;

  while(1){
    cin >> str;
    if(str == "#") break;

    iter1 = find(data.begin(), data.end(), str[0]);

    for(i=1, count=0; i<str.size(); ++i){
      iter2 = find(data.begin(), data.end(), str[i]);

      if(iter1 == data.end() && iter2 != data.end()){
	++count;
	iter1 = iter2;
      }else if(iter1 != data.end() && iter2 == data.end()){
	++count;
	iter1 = iter2;
      }
    }

    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        long A = sc.nextLong();
        long B = sc.nextLong();

        if (A == B) {
            _out.println(1);
            return;
        }

        long c = 0x4000000000000000L;
        while ((A & c) == (B & c)) {
            A = (A | c) ^ c;
            B = (B | c) ^ c;
            c >>>= 1;
        }
        long d = (c >>> 1);
        while ((B & d) != d) {
            d >>>= 1;
        }
        int r = Long.numberOfTrailingZeros(c) + 1;
        int k = Long.numberOfTrailingZeros(d) + 1;
        if (d == 0) {
            k = 0;
        }
        long sum = ((1L << r) - A);
        if (A > (1L << k)) {
            sum -= A - (1L << k);
        }
        _out.println(sum);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <algorithm>
using namespace std;
long long f[100005],ans,a[100005],b[100005],c[100005],n;

int main(){
	scanf("%lld",&n);
	for (int i=1; i<=n; i++) scanf("%lld",&a[i]); sort(a+1,a+n+1);
	for (int i=1; i<=n; i++) scanf("%lld",&b[i]); sort(b+1,b+n+1);
	for (int i=1; i<=n; i++) scanf("%lld",&c[i]); sort(c+1,c+n+1);
	for (int i=n,j=n; i; i--){		//中间层选 b[i] 
		for (; j && c[j]>b[i]; j--);	//底层最小可以选 c[j]
		f[i]=f[i+1]+n-j;	//方案的前缀 
	}
	for (int i=n,j=n; i; i--){
		for (; j && b[j]>a[i]; j--);
		ans+=f[j+1];
	}
	printf("%lld",ans);
}

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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    int res=0;
    res=modpow(2,n,MOD)-1;

    int comba=1,combb=1;
    for(int i=n-a+1; i<=n; i++){
        comba*=i;
        comba%=MOD;
    }
    for(int i=1; i<=a; i++){
        comba*=modpow(i,MOD-2,MOD);
        comba%=MOD;
    }

    for(int i=n-b+1; i<=n; i++){
        combb*=i;
        combb%=MOD;
    }
    for(int i=1; i<=b; i++){
        combb*=modpow(i,MOD-2,MOD);
        combb%=MOD;
    }
    res-=(comba+combb);
    res%=MOD;
    if(res>=0) cout<<res<<endl;
    else cout<<res+MOD<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.sort()

def nibu(x, arr):
  if x <= arr[0]:
    return len(arr)
  if arr[-1] < x:
    return 0
  l = 0
  h = len(arr) - 1
  while h - l >1:
    m = (l + h) // 2
    if x <= arr[m]:
      h = m
    else:
      l = m
  return len(arr) - h

print(nibu(K, h))



Measured memory_bytes: 84064
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	a, b = map(int, input().strip().split())
	for i in range(1, 4):
		if a * b * i % 2 == 1:
			print('Yes')
			return
	print('No')

if __name__ == '__main__':
	main()


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

int main(){
    int S,h,tmp,m,s;
    cin >> S;
    h = S/3600;
    tmp = S%3600;
    m = tmp/60;
    s = tmp%60;
    
    cout << h << ":" << m << ":"  << s <<endl;
    
}


Measured memory_bytes: 3076
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	a = int(input())
	#b , c = tin()
	#s = input()
	al=lin()
	bl=[v+1 for v in al]
	cl=[v-1 for v in al]
	zl = al+bl+cl
	cc = collections.Counter(zl)
	ret = max(cc.values())
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)

char IO;
int rd(){
	int s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=1e5+10;





int main(){
	int n=rd(),x=rd();x=x<<1|1;
	cout<<(n+x-1)/x;
}


















Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    string s1,s2;
    while(cin >> s1 >> s2,s1!="."){
        if(s1==s2){
            cout << "IDENTICAL" << endl;
            continue;
        }
        vector<string> s1_strs,s2_strs;
        int ptr = 0;
        string s1_rest="",s2_rest="";
        while(ptr<s1.size()){
            if(s1[ptr]=='"'){
                s1_rest=s1_rest+" ";
                string push_str;
                while(s1[++ptr]!='"'){
                    push_str.push_back(s1[ptr]);
                }
                s1_strs.push_back(push_str);
            }else{
                s1_rest=s1_rest+s1[ptr];
            }
            ++ptr;
        }
        ptr=0;
        while(ptr<s2.size()){
            if(s2[ptr]=='"'){
                s2_rest=s2_rest+" ";
                string push_str;
                while(s2[++ptr]!='"'){
                    push_str.push_back(s2[ptr]);
                }
                s2_strs.push_back(push_str);
            }else{
                s2_rest=s2_rest+s2[ptr];
            }
            ++ptr;
        }
        int m = min(s1_strs.size(),s2_strs.size());
        int cnt=0;
        rep(i,m){
            if(s1_rest==s2_rest&&s1_strs[i]!=s2_strs[i])cnt++;
        }
        if(cnt==1)cout << "CLOSE" << endl;
        else cout << "DIFFERENT" << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SR(): return sys.stdin.readline().rstrip()

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


n,k = MI()
s = list(SR())

s[k-1] = s[k-1].lower()
p2E(s)


Measured memory_bytes: 3064
def m():
    N, K = [int(i) for i in input().split()]
    S = input()

    # 2K+1 ... 0
    # 2K ... 1
    results = [0]
    prev = 1
    for i in range(N):
        s = int(S[i])
        if prev == s:
            results[-1] += 1
        else:
            results.append(1)
        prev = s
    if prev == 0: # last is zero
        results.append(0)
    if K >= (len(results) // 2):
        return len(S)

    lh = 0
    ans = results[0]
    maximum = -1
    for rh in range(2, len(results), 2):
        diff = results[rh] + results[rh-1]
        if (rh - lh) > 2*K:
            lh += 2
            diff -= (results[lh-1] + results[lh-2])
        ans = ans + diff
        maximum = max(maximum, ans)
    return maximum

print(m())


Measured memory_bytes: 44780