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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9'
			) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << newl;
	}
	else{
		int a,b;
		cin >> a >> b;
		cout << a + b << newl;
	}

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
int fa[10001],n,q;
int f(int a){
	if(fa[a]==a) return a;
	return fa[a]=f(fa[a]);
}
bool j(int a,int b){
	return f(a)==f(b);
}
void hb(int a,int b){
	int q=f(a),p=f(b);
	fa[q]=p;
}
int main(){
	std::cin>>n>>q;
	for(int i=0;i<n;i++) fa[i]=i;
	for(int i=0;i<q;i++){
		int a,b,c;
		std::cin>>a>>b>>c;
		if(a) std::cout<<j(b,c)<<"\n";
		else hb(b,c);
	}
}

Measured memory_bytes: 3144
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(r => int.Parse(r)).ToArray();
            var a = input[0];
            var b = input[1];

            if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
                Console.WriteLine(a * b);
            } else {
                Console.WriteLine(-1);
            }
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main(void)
{
	int X, Y;
	int kame = 0, turu = 0;
	int sub;

	scanf("%d %d", &X, &Y);

	if (Y % 2 == 1)
	{
		printf("No\n");
		return (0);
	}

	kame = Y / 4;
	if (Y % 4 == 2)
		turu++;

	if (kame + turu == X)
		printf("Yes\n");
	else if (X < kame + turu)
		printf("No\n");
	else
	{
		sub = X - (kame + turu);
		if (kame % sub == 0)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return (0);
}

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

int main()
{
    char s;

    cin>>s;
//    getline(cin,s);

    if(s>=64 && s<=90)
    {
        cout<<"A";
    }
    else if(s>=97 && s<=122 )
    {
        cout<<"a";
    }


    return 0;
}


Measured memory_bytes: 3620
import bisect
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
INF = 10 ** 9
A.append(INF)

left, right = 0, 2 * max(A)
while left + 1 < right:
    mid = (left + right) >> 1
    cnt = sum(N - bisect.bisect_left(A, mid-A[i]) for i in range(N))
    if cnt >= M:
        left = mid
    else:
        right = mid
acc = [0]
for i in range(N):
    acc.append(acc[-1] + A[i])
ans = 0
cnt, min_val = 0, INF
for i in range(N):
    idx = bisect.bisect_left(A, left-A[i])
    cnt += N - idx
    min_val = min(min_val, A[i] + A[idx])
    ans += (N - idx) * A[i] + acc[N] - acc[idx]
ans -= (cnt - M) * min_val
print(ans)


Measured memory_bytes: 63896
// CppPractice.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;

	if (a < b && b<c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}




Measured memory_bytes: 3108
S = input()
# S = "aaaccacabaababc"
# S = "".join(["a" for i in range(2*10**5)])
N = len(S)

st = ""
last = 0
cnt = 0
for i in range(N):
  ss = S[last:i+1]
  # print(last, i+1, ss)
  if ss != st:
    st = ss
    cnt += 1
    last = i+1

print(cnt)

Measured memory_bytes: 41948
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int K, X;
  cin >> K >> X;
  for (int i=max(X-K+1, -1000000); i<=min(X+K-1,  1000000); i++) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int m;
    int b = 0;
    scanf ("%d" , &N);
    m = N;
    
    while(m > 0){
        b += m%10;
        m /= 10;
    }
    if(N%b == 0)
    printf("Yes\n");
    else
    printf("No\n");
}


Measured memory_bytes: 128
N = int(input())

def dfs(s):
#文字列sで始まる七五三数の個数
    if int(s) > N:
        return 0
    #s自体が七五三数なら+1
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))


Measured memory_bytes: 3060
import java.util.Scanner;

class Main 
{
	public static void main(String[] args)
	{
		int[][] x;	
		Scanner sc = new Scanner(System.in);
		int N, cnt = 1;

		while(true)
		{
			N = sc.nextInt();
			
			if(N == 0) 
			{
				break;
			}

			x = new int[N][2];

			for(int i = 0; i < N; i++)
			{
				for(int j = 0; j < 2; j++)
				{
					x[i][j] = sc.nextInt();
				}
			}

			System.out.println(cnt+" "+calc_area(x));
			cnt++;
		}

	}

	private static double calc_area(int[][] x)
	{
		int N = x.length;
		double s = 0.0;

		for(int i = 0; i < N; i++)
		{
			s += cross_product(x[i % N], x[(i + 1) % N]);
		}

		return 0.5 * Math.abs(s);
	}

	private static int cross_product(int[] a, int[] b)
	{
		return a[0] * b[1] - a[1] * b[0];
	}
}

Measured memory_bytes: 20988
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
ll N,K;
ll A[100010];
typedef pair<int,int> P;
ll dp[50];
ll dp2[50];
ll fp(ll b,ll s) {
    ll m=1ll<<s;
    ll t=0;
    REP(j,N)
      t+= (A[j]&m)^(b<<s);
    return t;
}
int main() {
  cout << fixed << setprecision(15);
  cin >> N >> K;
  REP(i,N)
    cin >> A[i];
  memset(dp,0,sizeof(dp));
  memset(dp2,0,sizeof(dp2));
  REP(i,45)
    REP(k,2)
      assign_if_greater(dp[i+1],dp[i]+fp(k,i));
  ll ans=0;
  REP(i,45) {
    if ((K>>i)&1) {
      assign_if_greater(dp2[i+1], dp2[i] + fp(1,i));
      assign_if_greater(dp2[i+1], dp[i]+fp(0,i));
    } else {
      dp2[i+1]=dp2[i]+fp(0,i);
    }
    assign_if_greater(ans, dp2[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, m] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)
const [_, ..._py] = stdin.split('\n')
const py = _py.map((v, i) => [...v.split(' ').map(Number), i])

const ans = () => {
  const pys = py.sort((a, b) => a[1] - b[1])

  let prefs = []

  let codeList = []

  for (let i = 0; i < m; i++) {
    const [p, y, idx] = pys[i]

    if (prefs[p] === undefined) {
      prefs[p] = 1
    } else {
      prefs[p]++
    }

    const x = prefs[p]
    const codeP = `000000${p}`.slice(-6)
    const codeX = `000000${x}`.slice(-6)

    const code = `${codeP}${codeX}`

    codeList[idx] = code
  }

  for (let i = 0; i < m; i++) {
    console.log(codeList[i])
  }
}

ans()


Measured memory_bytes: 78660
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
int n, u[100010], v[100010], w[100010];
vector<edge>s[100010];
int ans[100010];
bool x[100010];
void dfs(int a, int b) {
	if (x[a])return;
	x[a] = true;
	if (b % 2)ans[a] = 1;
	else ans[a] = 0;
	rep(i, s[a].size()) {
		dfs(s[a][i].to, b + s[a][i].cost);
	}
	return;
}
signed main() {	
	cin >> n;
	rep(i, n - 1) {
		cin >> u[i] >> v[i] >> w[i];
		u[i]--;
		v[i]--;
		s[u[i]].push_back({ v[i],w[i] });
		s[v[i]].push_back({ u[i],w[i] });
	}
	dfs(0, 0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 12544
// ABC 088 B
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int func(int n){
  int a=0;
  while(n){
    a += n%10;
    n /= 10;
  }
  return a;
}
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n,ans=0;
  cin >> n;
  VI a(n);
  REP(i,n){
    cin >> a[i];
  }
  RSORT(a);
  REP(i,n){
    if(i%2==0){ ans+=a[i];}
    else {ans-=a[i];}
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define P(x, y) make_pair(x, y)

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);


const int MAX = 300; /// 最大頂点数

ll N, ans; /// N:頂点数、M:辺の数

int dist[MAX][MAX]; /// dist[j][i]=dist[i][j]はi、j間の最短距離

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

bool warshall_floyd() {
  REP (k, N) REP (j, N) REP (i, N) if (dist[j][i] > dist[j][k] + dist[k][i]) return false;
  return true;
}

void warshall_floyd2() {
  REP (k, N) REP (j, N) FOR (i, j+1, N) if (k != j && k != i && dist[j][i] == dist[j][k] + dist[k][i]) {
    dist[j][i] = dist[i][j] = INF;
  }
}

int main() {
  cin >> N;
  Fill(dist, INF);


  REP (i, N) REP (j, N) {
    cin >> dist[i][j];
  }

  if (!warshall_floyd()) {
    cout << -1 << endl;
    return 0;
  }

  warshall_floyd2();
  ans = 0;
  REP (i, N) FOR (j, i+1, N) if (dist[j][i] != INF) {
    ans += dist[j][i];
  }

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


Measured memory_bytes: 640
/*
    Write a program which reads two integers a and b, and calculates the following values
        int d: a / d
        int r: remainder of a / b
        double f: a / b
*/

#include <stdio.h>

int main(void)
{
    int a, b;

    scanf("%d %d", &a, &b);
    printf("%d %d %5f\n", a/b, a%b, (double)a/b);
    return (0);
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;}
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}

#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
double pd(ll x1,ll x2,ll y1,ll y2)
{
    double an=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    double ans=sqrt(an);
    return ans;
}
int main()
{
// freopen("input.txt","r",stdin);
ll t;
t=1;
while(t--)
{
    ll n;
    cin>>n;
double ans=0;
vector<pair<ll,ll> > points(n);
loop(i,0,n)
cin>>points[i].ff>>points[i].ss;
vector<ll> p;
loop(i,0,n)
p.pb(i);
do
{
    loop(i,0,n-1)
    ans+=pd(points[p[i]].ff,points[p[i+1]].ff,points[p[i]].ss,points[p[i+1]].ss);
   // trace2(ans,ans);
}
while(next_permutation(p.begin(),p.end()));
ll fact=1;
for(ll i=1;i<=n;i++)
    fact*=i;
ans/=fact;
cout<<setprecision(15)<<ans<<"\n";
}
return 0;
}



Measured memory_bytes: 256
n, k, q = map(int, input().split())
score = [k] * n
data = [0] * n

for i in range(q):
    a = int(input())
    data[a - 1] += 1

for i in range(n):
    if(q - data[i] >= k):
        print("No")
    else:
        print("Yes")
    


Measured memory_bytes: 5448
from sys import stdin
import heapq
INF = 1<<21
n = int(stdin.readline())
adj = [[]] * n
for u in range(0, n):
    U = list(map(int, stdin.readline().split()[2:]))
    adj[u] = zip(U[0::2], U[1::2])
def dijkstra():
    d = [0] + [INF] * (n - 1)
    hq = [(0, 0)]
    while hq:
        u = heapq.heappop(hq)[1]
        for v, c in adj[u]:
            alt = d[u] + c
            if d[v] > alt:
                d[v] = alt
                heapq.heappush(hq, (alt, v))
    for i, c in enumerate(d):
        print(i, c)
dijkstra()

Measured memory_bytes: 42444
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}
	return x*f;
}
const int maxn = 101000;
char s[maxn];
int a[maxn],L[maxn],R[maxn],ll[maxn],rr[maxn];
int main()
{
	int n=read(),k=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) a[i] = s[i]-'0';
	if(k==0){
		int kkk=0,ans=0;
		for(int i=1;i<=n;i++){
			if(a[i-1]==0&&a[i]==1) kkk=0;
			if(a[i]==1) kkk++;
			ans = max(ans,kkk);
		}
		printf("%d\n",ans);
		return 0;
	}
	int nowl = 1,q = 0;
	a[0]=1,a[n+1]=1; 
	for(int i=1;i<=n;i++){
		if(a[i]==0&&a[i-1]==1) rr[q]=i-1,L[++q] = i,ll[q]=nowl;
		if(a[i]==0&&a[i+1]==1) R[q] = i,nowl = i+1;
	}
	rr[q]=n;
	if(q==0){
		printf("%d\n",n);
		return 0;
	}
//	for(int i=1;i<=q;i++){
//		printf("%d %d %d %d\n",L[i],R[i],ll[i],rr[i] );
//	}
	int ans = 0;
	for(int i=1;i<=q;i++){
		int p = i+k-1;
		if(p>q) p=q;
		ans = max(ans,rr[p]-ll[i]+1);
	}
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int,int);
int setHeight(int);
int getSibling(int);
void print(int);

int main(){
  int i,v,l,r,root = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i=0;i<n;i++)
    if(T[i].p == NIL)root = i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)
    print(i);

  return 0;
}

void setDepth(int u, int d){

  if(u == NIL)return;
  D[u] = d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}

int setHeight(int u){
  int h1,h2;

  h1 = h2 = 0;
  if(T[u].l != NIL)h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL)h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2); 
}

int getSibling(int u){

  if(T[u].p == NIL)return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL)
    return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL)
    return T[T[u].p].r;
  return NIL;
}

void print(int u){
  int deg;

  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,getSibling(u));

  deg = 0;

  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;

  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);

  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}

Measured memory_bytes: 624
import java.util.*;
 
public class Main{
    
    static int N;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        int Q = sc.nextInt();
        int[][] a = new int[2][N-1];
        int[][] p = new int[2][Q];
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N-1; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            map.put(a[1][i], a[0][i]);
        }

        long[] count = new long[N];
        Arrays.fill(count, 0);
        for(int i = 0; i < Q; i++){
            p[0][i] = sc.nextInt();
            p[1][i] = sc.nextInt();
            count[p[0][i]-1] += p[1][i];
        }
        sc.close();
 
        for(int i = 1; i < N; i++){
            count[i] += count[map.get(i+1)-1];
        }
        for(int i = 0; i < N; i++)
            System.out.println(count[i]);
    }
}

Measured memory_bytes: 196248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n, k;
  cin >> n >> k;
  vll d(k);
  for (ll i = 0; i < k; i++) cin >> d[i];
  
  for (ll i = n; i < 100000; i++) {
    ll judge = 0, x = i;
    while (x > 0) {
      for (ll j = 0; j < k; j++) {
        if (d[j] == x % 10) {
          judge = 1;
          break;
        }
      }
      if (judge == 1) break;
      x /= 10;
    }
    if (judge == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);
  sort(ALL(l));
  ll ans = 0;
  rep(i, n)rep2(j, i+1, n){
    int il = l.at(i), jl = l.at(j);
    int add = lower_bound(ALL(l), il+jl) - l.begin();
    // cerr << i << " " << j << " " << il+jl << " " << add << endl;
    add = max(0, add-j-1);
    ans += add;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : m : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ ((n * (pred n)) `div` 2) + ((m * (pred m)) `div` 2)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)) cout<<"B"<<endl;
	else cout<<"A"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int ans[100],tot=0,place=1;
int main(){
	int n;
	scanf("%d",&n);
	while(n!=0){
		int temp=n/(-2);
		if(n<0){
			if(-2*temp>n) ++temp;
			ans[++tot]=n-temp*(-2);
		}
		else{
			ans[++tot]=n-temp*(-2);
		}
		n=temp;
	}
	for(int i=tot;i;--i){
		//cout<<ans[i];
		if(ans[i]==1){
			place=i;
			break;
		}
	}
	for(int i=place;i;--i)
		printf("%d",ans[i]);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 1
lim = 10 ** 18
l = 0

A = list(map(int, input().split()))

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans > lim:
    l = 1
    break
  else:
    pass

if l == 1:
  print(-1)
else:
  print(ans)

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

int main()
{
	int a,b=0,c;
	cin>>a;
	c=a;
	for(int i=1;a!=0;i++)
	{
		b=b+a%10;
		a=a/10;
	}
	if(c%b==0)
	cout<<"Yes";
	else cout<<"No";
}

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

using namespace std;
// C++ program to generate all prime numbers
// less than N in O(N)
const long long MAX_SIZE = 10000001;

// isPrime[] : isPrime[i] is true if number is prime
// prime[] : stores all prime number less than N
// SPF[] that store smallest prime factor of number
// [for Exp : smallest prime factor of '8' and '16'
// is '2' so we put SPF[8] = 2 , SPF[16] = 2 ]
vector<long long >isprime(MAX_SIZE , true);
vector<long long >prime;
vector<long long >SPF(MAX_SIZE);

// function generate all prime number less then N in O(n)
void manipulated_seive(int N)
{
	// 0 and 1 are not prime
	isprime[0] = isprime[1] = false ;

	// Fill rest of the entries
	for (long long int i=2; i<N ; i++)
	{
		// If isPrime[i!] == True then i is
		// prime number
		if (isprime[i])
		{
			// put i into prime[] vector
			prime.push_back(i);

			// A prime number is its own smallest
			// prime factor
			SPF[i] = i;
		}

		// Remove all multiples of i*prime[j] which are
		// not prime by making isPrime[i*prime[j]] = false
		// and put smallest prime factor of i*Prime[j] as prime[j]
		// [ for exp :let i = 5 , j = 0 , prime[j] = 2 [ i*prime[j] = 10 ]
		// so smallest prime factor of '10' is '2' that is prime[j] ]
		// this loop run only one time for number which are not prime
		for (long long int j=0;
			j < (int)prime.size() &&
			i*prime[j] < N && prime[j] <= SPF[i];
			j++)
		{
			isprime[i*prime[j]]=false;

			// put smallest prime factor of i*prime[j]
			SPF[i*prime[j]] = prime[j] ;
		}
	}
}


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n=pow(10,7);
    int x;
    cin>>x;
    manipulated_seive(n);
    for (int i=0;i<n;i++)
    {
        if (prime[i]>=x)
            {
            cout<<prime[i];
            break;
            }
    }


return(0);
}


Measured memory_bytes: 166764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  int flag = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if ( S == "Y") {
      flag = 1;
      break;}
  }
  if (flag == 0) {cout << "Three" << endl;}
  else {cout << "Four" << endl;}
}

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

#define N 1024

int
main (
  int   argc,
  char *argv[ ]
  )
{
  char s[ N ];
  int i;

  scanf ( " %s", s );
  for ( i = 0; s[ i ] != '\0'; i += 2 )
  {
    if ( s[ i ] >= '1' && s[ i ] <= '9' )
    {
      static const char cs[ ] = { 'k', 's', 't', 'n', 'h', 'm', 'y', 'r' };

      if ( s[ i ] >= '2' )
        putchar ( cs[ s[ i ] - '2' ] );
      switch ( s[ i + 1 ] )
      {
        case 'T': putchar ( 'a' ); break ;
        case 'L': putchar ( 'i' ); break ;
        case 'U': putchar ( 'u' ); break ;
        case 'R': putchar ( 'e' ); break ;
        case 'D': putchar ( 'o' ); break ;
      }
    }
    else if ( s[ i ] == '0' )
    {
      switch ( s[ i + 1 ] )
      {
        case 'T': fputs ( "wa", stdout ); break ;
        case 'U': fputs ( "nn", stdout ); break ;
        case 'D': fputs ( "wo", stdout ); break ;
      }
    }
  }
  puts ( "" );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 524
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int baqet[200000]={};
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		baqet[tmp-1]++;
	}
	vector<int> a;
	for(int i=0; i<200000; i++){
		if(baqet[i])
			a.push_back(baqet[i]);
	}
	sort(a.rbegin(), a.rend());
	int ans=0;
	while(a.size()>k){
		ans += a[a.size()-1];
		a.pop_back();
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod = 1e9 + 7;
ll n,k;
mat mul(mat &A, mat &B) {
  mat C(A.size(),vec(B[0].size()));
  for(int i = 0; i < A.size(); i++) {
    for(int k = 0; k < B.size(); k++) {
      for(int j = 0; j < B[0].size(); j++) {
	C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
      }
    }
  }
  return C;
}

mat pow(mat A, ll n) {
  mat B(A.size(), vec(A.size()));
  for(int i = 0; i < A.size(); i++) {
    B[i][i] = 1;
  }
  while(n > 0) {
    if(n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}

int main() {
  cin >> n >> k;
  mat A(n,vec(n));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      cin >> A[i][j];
    }
  }

  A = pow(A,k);

  ll ans = 0;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      ans = (ans + A[i][j]) % mod;
    }
  }

  cout << ans << endl;
}
    


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


void solve(long long X){
  long long score = 0;
  while (500 <= X) {
    X -= 500;
    score += 1000;
  }

  while (5 <= X) {
    X -= 5;
    score += 5;
  }
  cout << score << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var cin = new Scanner();
            int N = int.Parse(Console.ReadLine());
            var A = cin.SplitRead();
            int[] c = new int[N];
            Initialize(ref c, 0);
            foreach(var a in A)
            {
                c[a - 1]++;
            }
            Sort(c);

            int[] d = new int[N + 1];
            d[0] = 0;
            for(var i = 0; i < N; i++)
            {
                d[i + 1] = d[i] + c[i];
            }

            for(var K = 1; K <= N; K++)
            {
                int l = -1;
                int r = (N / K) + 1;
                while (r - l > 1)
                {
                    int X = (l + r) / 2;

                    int ll = -1;
                    int rr = c.Length;
                    while (rr - ll > 1)
                    {
                        int cc = (ll + rr) / 2;
                        if (c[cc] >= X)
                        {
                            rr = cc;
                        }
                        else
                        {
                            ll = cc;
                        }
                    }

                    if (d[ll + 1] + X * (N - ll - 1) >= X * K)
                    {
                        l = X;
                    }
                    else
                    {
                        r = X;
                    }
                }

                Console.WriteLine(l);
            }

           
            Console.Out.Flush();
        }

        
    }

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 43048
n=int(input())
comments=[]
for i in range(n):
    num=int(input())
    comment=[]
    for j in range(num):
        comment.append(list(map(int,input().split(" "))))
    comments.append(comment)

ans=0
for i in range(2**n):
    evidences={}
    people=list(str(format(i,'b').zfill(n)))
    conflict=False
    for idx,person in enumerate(people):
        if person=='1':
            for comment in comments[idx]:
                evidences.setdefault(comment[0],[]).append(comment[1])
    for key,value in evidences.items():
        personality = int(people[key-1])
        if value.count(personality) != len(value):
            conflict=True
            break
    if not conflict:
        ans=people.count('1')
print(ans)


Measured memory_bytes: 49372
/******* all required header files *******/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	ios_base::sync_with_stdio(0);
	cin.tie(0);

    double n;
    cin>>n;
    int cnt = 0;
    for(int i = 1; i < n+1; i++)
    {
        if(i % 2 != 0)
        {
            cnt++;
        }
    }
    cout<<fixed<<setprecision(10)<<cnt/n;
    return 0;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define endl "\n"

#define k first
#define v second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define ALL(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.k << ", " << p.v << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int k, n;
    cin >> n >> k;
    unordered_map<int, int> counter;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        counter[a]++;
    }
    vi d;
    for (auto &p : counter) {
        d.push_back(p.second);
    }
    sort(d.begin(), d.end());
    if (k < counter.size()) {
        int moves = 0;
        for (int i = 0; i < counter.size() - k; i++) {
            moves += d[i];
        }
        cout << moves << endl;
    } else {
        cout << 0 << endl;
    }
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    string s = "";
    cin >> s;
    int ct = 0;
    REP(i, s.length())
    {
        if (s[i] == 'o')
        {
            ct++;
        }
    }

    if (ct >= 8)
    {
        COUT("YES");
        return 0;
    }

    int aa = 15 - s.length();

    if (ct + aa >= 8)
    {
        COUT("YES");
        return 0;
    }

    COUT("NO");

    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
from math import factorial

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M <=1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N <= 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<int> A(n + 1), B(n);

    loop (n + 1, i) cin >> A[i];
    loop (n, i) cin >> B[i];

    ll ans = 0;
    int b = 0;
    loop (n, i) {
        int kill = min(A[i], B[i] + b);
        ans += kill;
        b = min(B[i], B[i] + b - kill);
    }
    ans += min(A[n], b);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
//Bismillahir rahmanir rahim
#include<bits/stdc++.h>
#define ll long long
#define eps 0.000000001
using namespace std;

int arr [100005];
int main()
{   //freopen("in.txt","r",stdin);

    std::ios_base::sync_with_stdio(0);cin.tie(NULL);
    ll n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++){
        ll l,r;
        cin>>l>>r;
        arr[l]++;
        arr[r+1]--;
    }
    ll cnt =0;

    for(int i=1;i<100005;i++){
        arr[i]=arr[i]+arr[i-1];
    //cout<<arr[i]<<endl;
        if(arr[i]==m)cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#define pb push_back
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
signed main()
{
	long long n;
	vector<long long>b,g,r;
	string s;
	cin>>n;
	cin>>s;
	long long ans=0;
	for (long long i=0;i<n;i++){
		if (s[i]=='B')  b.pb(i);
		if (s[i]=='G')  g.pb(i);
		if (s[i]=='R')  r.pb(i);
	}
	for (auto i : b){
		for (auto j : g){
			long long a1=min(i,j);
			long long a2=max(i,j);
			vector<long long>::iterator rrt = find( all(r), a1+a1-a2 );
			vector<long long>::iterator rt = find( all(r), a2+a2-a1 );
			int y=0;
			if ( rt != r.end( ) )  y++;
			if ( rrt != r.end( ) )  y++;
			if ((a2-a1)%2==0)  if (find( all(r), (a2+a1)/2 )!=r.end())  y++;
			ans+=r.size()-y;
		}
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3660
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int TEST_CASE){
    string s;
    cin >> s;
    int c0=0, c1=0;
    fr(i,s.length()){
        if(i&1){
            if(s[i]=='1') c0++;
            else c1++;
        }else{
            if(s[i]=='1') c1++;
            else c0++;
        }
    }
    cout << min(c0,c1);
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
// const int N = ;
using ll = long long;
using ii = pair <int , int>;
using d = double;

int main() {
	d l; scanf("%lf" , &l);
	printf("%.10lf\n" , (l / 3) * (l / 3) * (l / 3));
	return 0;
}


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

typedef long long ll;

int n,A,B;

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

	if(A>B){printf("0\n");return 0;}
	if(n==1 && A!=B){printf("0\n");return 0;}

	ll L=(ll)(n-1)*A+B,R=(ll)(n-1)*B+A;
	printf("%lld\n",R-L+1);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

bool func(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	int N, A, B, ans = 0;

	cin >> N >> A >> B;

	for (int i = 1; i <= N; i++) {

		string S = to_string(i);
		int tmp = 0;
		for (int j = 0; j < S.size(); j++) {

			tmp += (int)(char)S[j] - (int)(char)'0';

		}
		if (A <= tmp&&tmp <= B)ans += i;

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static int mod = 1000000007;

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int S= sc.nextInt();
        int W =sc.nextInt();

        if(S <= W){
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }

}









Measured memory_bytes: 35708
N = int(input())
from math import sqrt,ceil
from collections import Counter

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)    
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    if n != 1:
        factor.append(n)
    return factor


factor = []
for i in range(1, N+1):
    t = prime_factorization(i)
    if len(t): factor += t

c = Counter(factor)
ans = 1
for i in c.values():
    ans *= (i+1)
    ans %= 10**9 + 7
print(ans)


Measured memory_bytes: 3316
from collections import deque
import sys
input = sys.stdin.buffer.readline

N = int(input())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

seen = [0] * (N+1)
seen[1] = 1
seq = []
que = deque()
que.append(1)
child = [[] for _ in range(N+1)]
while que:
    v = que.pop()
    seq.append(v)
    for u in adj[v]:
        if seen[u] == 0:
            seen[u] = 1
            child[v].append(u)
            que.appendleft(u)

grundy = [0] * (N+1)
for v in reversed(seq):
    tmp = 0
    for u in child[v]:
        tmp ^= grundy[u] + 1
    grundy[v] = tmp

if grundy[1]:
    print('Alice')
else:
    print('Bob')


Measured memory_bytes: 72096