akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

LL LCM(LL a, LL b){
    LL c = a;
    LL d = b;
    while(d){
        c%=d;
        swap(c, d);
    }
    return a/c*b;
}

signed  main(){
    LL sum = 0;
    LL A, B, C, D;
    cin >> A >> B >> C >> D;
    sum += B / C;
    sum += B / D;
    sum -= B / LCM(C, D);
    sum -= (A-1) / C;
    sum -= (A-1) / D;
    sum += (A-1) / LCM(C, D);
    cout << B-A+1-sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
int n,m;
int a[MAXN],cnt[MAXN];
int tims[MAXN],sum;
void add(int x){
	cnt[x]++;
	if(x-cnt[x]+1>0&&tims[x-cnt[x]+1]==0)
		sum--;	
	if(x-cnt[x]+1>0)
		tims[x-cnt[x]+1]++;
}
void del(int x){
	if(x-cnt[x]+1>0&&tims[x-cnt[x]+1]==1)
		sum++;
	if(x-cnt[x]+1>0)
		tims[x-cnt[x]+1]--;	
	cnt[x]--;
}
int main(){
	SF("%d%d",&n,&m);
	sum=n;
	for(int i=1;i<=n;i++){
		SF("%d",&a[i]);
		add(a[i]);
	}
	int x,y;
	for(int i=1;i<=m;i++){
		SF("%d%d",&x,&y);
		del(a[x]);
		a[x]=y;
		add(a[x]);
		PF("%d\n",sum);
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	int N, K, i;
	long attack, HP[200005] = {};

	cin >> N >> K;

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

	sort(HP,HP+N,greater<long>());

	for (i = 0;i < K;i++) {
		attack -= HP[i];
	}

	cout << attack;
}

Measured memory_bytes: 1792
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range(n//g+1):
    if (n-i*r-j*g)%b==0 and (n-i*r-j*g)//b>=0:
      ans+=1
print(ans)


Measured memory_bytes: 40556
S = input()
memo = [[0]*(13) for _ in range(len(S))]
mod = 10**9 + 7
def main():
    cnt = 1
    R = []
    for _ in range(len(S)):
        R.append(cnt)
        cnt = (cnt*10)%13
    dic = [{} for _ in range(13)]#iに対してS[j]が?だった場合のi*range(13)%13の全列挙
    for i in range(13):
        for j in range(10):
            if (i*j)%13 not in dic[i]:
                dic[i][(i*j)%13] = 1
            else:
                dic[i][(i*j)%13] += 1
    if S[-1] == "?":
        for i in range(10):
            memo[0][i] = 1
    else:
        memo[0][int(S[-1])] = 1

    for d in range(len(S) - 1):
        s = S[-2-d]
        if s == "?":
            tmp = dic[R[d+1]]
            for key in tmp.keys():
                for i in range(13):
                    memo[d + 1][(key + i)%13] = (dic[R[d+1]][key]*(memo[d][i] + memo[d + 1][(key + i)%13]))%mod
        else:
            for i in range(13):
                memo[d + 1][(i + int(s)*R[d+1])%13] = (memo[d][i] + memo[d + 1][(i + int(s)*R[d+1])%13])%mod
    print(memo[len(S) - 1][5])
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 66012
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x>=k)++cnt;
    }

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<unordered_set>
#include<limits.h>
using namespace std;

typedef unsigned long long ll;

ll mod=1000000007ll;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int odd=0,even=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1){
            odd++;
        } else {
            even++;
        }
    }
    even+=odd/2;
    odd=odd%2;
   // cout<<odd%2<<endl;
    if((odd%2)==0){
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dp1[1500010] = {0}, dp2[1500010] = {0};
signed main(void) {
  while (true) {
    VI a[1500], b[1500];
    int n, m, h[1510], w[1510];
    cin >> n >> m;
    if(!n && !m) break;
    REP(i, n) cin >> h[i];
    REP(i, m) cin >> w[i];

    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));
    a[0].PB(h[0]);
    dp1[h[0]]++;
    FOR(i, 1, n) {
      for (int j : a[i - 1]) {
        a[i].PB(j + h[i]);
        dp1[j + h[i]]++;
      }
      a[i].PB(h[i]);
      dp1[h[i]]++;
    }

    b[0].PB(w[0]);
    dp2[w[0]]++;
    FOR(i, 1, m) {
      for (int j : b[i - 1]) {
        b[i].PB(j + w[i]);
        dp2[j + w[i]]++;
      }
      b[i].PB(w[i]);
      dp2[w[i]]++;
    }

    ll ret = 0;
    REP(i, 1500001) ret += dp1[i] * dp2[i];
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 27820
#include <cstdio>

int main()
{
    int len=0,slen=0;
    long long N;
    static bool a[50],b[101];

    scanf("%lld",&N);
    for (int i=0;i<50;++i)
        a[i]=0;
    for (int i=0;i<101;++i)
        b[i]=0;

    for (N=N+1;N>1;N=N>>1)
    {
        len++;
        slen++;
        if (N&1)
        {
            a[len]=1;
            slen++;
        }
    }
    printf("%d\n",slen<<1);
    for (int i=1;i<=len;++i)
    {
        if (a[i])
        {
            printf("%d ",101-i);
            b[101-i]=1;
        }
        printf("%d ",i);
        b[i]=1;
    }
    printf("1");
    for (int i=2;i<=100;++i)
        if (b[i]) printf(" %d",i);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

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

	if(a>9||b>9){
		cout << -1 << endl;
	}else{
		cout << a*b << endl;
	}
	return 0;

}

Measured memory_bytes: 256
char v[];a=12;f(x,z){if(v[x]-->48)for(;z;)f(x+"HJ<V"[--z]-73,4);}main(j,c){for(;a?j=170,c=0,~scanf("%s",v+a--*13):--j?c+=v[j]>48,f(j,4):printf("%d\n",c,a=12););}

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

using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && b != c) || (a == c && c != b) || (b == c && c != a)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

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

void trace(int *array, int n) {
    rep(i, n) cout << array[i] << ((i != n - 1) ? " " : "\n");
}

void insertionSort(int *array, int n) {
    for (int i = 1; i < n; i++) {
        trace(array, n);
        int v = array[i];
        int j = i - 1;
        while (j >= 0 && array[j] > v) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = v;
    }
}

int main() {
    int n;
    cin >> n;
    int array[n];
    rep(i, n) cin >> array[i];
    insertionSort(array, n);
    trace(array, n);
}




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

const int MAXN = 100010;
typedef long long LL;
bool ispri(int x) {
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return false;
	return true;
}
const int MAXM = 1000;
int li[MAXN], bak;
typedef std::pair<LL, int> pi;
typedef std::vector<pi> V;
V al(V x) {
	for (auto & t : x) t.second ^= 3;
	return x;
}
std::map<V, int> M;
int n;
std::map<LL, int> lv;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	for (int i = 2; bak <= 500; ++i)
		if (ispri(i)) li[++bak] = i;
	std::cin >> n;
	for (int i = 1; i <= n; ++i) {
		LL t; std::cin >> t; V tl;
		for (int j = 1; j <= bak; ++j)
			while (t % li[j] == 0)
				++lv[li[j]], t /= li[j];
		if (t > 1) {
			LL x = sqrtl(t);
			if (x * x == t) lv[x] += 2;
			else if ((x + 1) * (x + 1) == t) lv[x + 1] += 2;
			else lv[t] += 1;
		}
		for (auto t : lv) if (t.second % 3 != 0)
			tl.emplace_back(t.first, t.second % 3);
		lv.clear();
		++M[tl];
	}
	int ans = 0; M[V()] = (!!M[V()]) << 1;
	for (auto t : M) {
		auto a = al(t.first);
		if (M.count(a)) ans += std::max(t.second, M[a]);
		else ans += t.second << 1;
	}
	std::cout << ans / 2 << std::endl;
	return 0;
}


Measured memory_bytes: 14720
#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if ((r <= x && x <= (W - r)) &&
        (r <= y && y <= (H - r))) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 584
import sys
input = lambda : sys.stdin.readline().rstrip()

class SegmentTree:
    def __init__(self, n, ele, segfun):
        self.ide_ele = ele
        self.segfun = segfun
        self.n = n
        self.N0 = 1 << n.bit_length()
        self.data = [self.ide_ele] * (self.N0 * 2)
 
    def update(self, l, r, val):
        l += self.N0
        r += self.N0
        while l < r:
            if l & 1:
                self.data[l] = self.segfun(self.data[l], val)
                l += 1
            if r & 1:
                self.data[r - 1] = self.segfun(self.data[r - 1], val)
                r -= 1
            l //= 2
            r //= 2
 
    def query(self, i):
        i += len(self.data) // 2
        ret = self.data[i]
        while i > 0:
            i //= 2
            ret = self.segfun(ret, self.data[i])
        return ret

n, q = map(int, input().split())
stx = []
for _ in range(n):
    s, t, x = map(int, input().split())
    stx.append([x, s - x, t - x])
stx.sort(reverse=True)
d = [int(input()) for _ in range(q)]

import bisect

seg = SegmentTree(q, 10**9 + 1, lambda a, b : min(a, b))

for x, start, last in stx:
    l = bisect.bisect_left(d, start)
    r = bisect.bisect_left(d, last)
    seg.update(l, r, x)

for i, j in enumerate(d):
    res = seg.query(i)
    if res == 10**9 + 1:
        print(-1)
    else:
        print(res)
    



Measured memory_bytes: 110300
while (l = gets.chomp.split.map(&:to_i)) != [0, 0]
    h, w = l
    
    puts "#" * w
    (h-2).times do |i|
        puts "#" + ("." * (w - 2)) + "#"
    end
    puts "#" * w
    
    puts "\n"
end


Measured memory_bytes: 6956
#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>
using namespace std;

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

ll max(ll a, ll b) {

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

}
double max(double a, double b) {

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

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

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

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

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

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

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;

}
//????°???¬?????°

int main() {
	
	int a, b;

	cin >> a >> b;

	if (a < b)printf("a < b\n");
	if (a > b)printf("a > b\n");
	if (a == b)printf("a == b\n");

	return 0;
}

Measured memory_bytes: 3024
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

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

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=200005;


void solve(){
  int X,Y,Z;
  cin>>X>>Y>>Z;
  int n=X+Y+Z;
  ll ans=0;
  ll mx=-1e18;
  vector<pair<int,pi>>a(n);
  for(int i=0;i<n;i++){
    int x,y,z;
    cin>>x>>y>>z;
    ans+=z;
    a[i]={x-y,{x-z,y-z}};
  }
  sort(all(a));
  priority_queue<int,vector<int>,greater<int>>pq;
  ll val1=0,val2=0;
  vector<int>precleft(n),precright(n);
  for(int i=0;i<Y;i++){
    pq.push(a[i].S.S);
    val1+=a[i].S.S;
  }
  precleft[Y-1]=val1;
  for(int i=Y;i<n;i++){
    val1+=a[i].S.S;
    pq.push(a[i].S.S);
    val1-=pq.top();
    pq.pop();
    assert(pq.size()==Y);
    precleft[i]=val1;
  }
  priority_queue<int,vector<int>,greater<int>>pq2;
  for(int i=n-1;i>=n-X;i--){
    val2+=a[i].S.F;
    pq2.push(a[i].S.F);
  }
  precright[n-X]=val2;
  for(int i=n-X-1;i>=0;i--){
    val2+=a[i].S.F;
    pq2.push(a[i].S.F);
    val2-=pq2.top();
    pq2.pop();
    assert(pq2.size()==X);
    precright[i]=val2;
  }
  for(int i=Y-1;i<n-X;i++){
    mx=max(mx,precleft[i]+precright[i+1]);
  }
  cout<<ans+mx;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 5496
#include <stdio.h>

int main()
{
	int k, s;
	int x, y, z;
	long long ans = 0;

	scanf("%d %d", &k, &s);

	for (x = 0; x <= k; x++) {
		for (y = 0; y <= k; y++) {
			z = s - (x + y);

			if (z >= 0 && z <= k) {
				ans++;
			}
		}
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    int n;
    Solver(LL n):n(n){};

    void solve(){
        LL ans = 0;
        for(int i=0; i<n; ++i){
            LL a,k;
            cin >> a >> k;
            DBG(a,k,grundy(a,k))
            ans^=grundy(a,k);
        }
        DBG(ans)
        if(ans==0)cout << "Aoki"<<"\n";
        else cout << "Takahashi"<<"\n";
    }
    LL grundy(LL a, LL k){
        DBG(a,k)
        if(a%k==0)return a/k;
        if(a<k)return 0;
        //if((a+k-1)/k >=k) return grundy(a-(a+k-1)/k,k);
        LL l = ((a+k-1)/k);
        DBG(l)
        LL nxt = (a/k*k+l-1)/l*l+a%l;
        while(nxt>a/k*k)nxt-=l;
        return grundy(nxt,k);
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Problem::Solver sol(n);
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int oddEven(int digit, char *s){
    int ansx = 0;
    int ansy = 0;
    char ansA[1000000];
    char ansB[1000000];
    
    if(digit == 1)
        return 0;
    for(int i = 0; i < digit; i++){
        if(i == 0 || (i % 2) == 0){
            ansA[i] = '1';
            ansB[i] = '0';
        }else{
            ansA[i] = '0';
            ansB[i] = '1';
        }
    }
    for(int i = 0; i < digit; i++){
        if(ansA[i] == *(s+i)){
            ansy += 1;
        }else{
            ansx += 1;
        }
    }
    if(ansx < ansy){
        return ansx;
    }else{
        return ansy;
    }
}
int main(void){
    int n;
    int digit = 1;
    char order[1000001];
    
    if(fgets(order, 1000000, stdin) == NULL){
        printf("error");
    }
    while(1){
        if(order[digit] == '\n'){
            break;
        }
        digit += 1;
    }
    n = oddEven(digit, order);
    printf("%d\n", n);
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

ll n,k;
ll a[maxn];

int check(ll len){
	ll res=0;
	for(int i=0;i<n;i++)
		res+=(a[i]-1)/len;
	return res<=k;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		cin>>n>>k;
		ll l=0,r=1;
		for(int i=0;i<n;i++){
			cin>>a[i];
			r=max(r,a[i]);
		}
		ll ans=1e18;
		while(r-l>1){
			ll mid=(l+r)/2;
			if(check(mid)){
				r=mid;
				ans=min(ans,mid);
			}
			else l=mid;
		}
		cout<<r;
	}
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

ll dp[100010][3];

int main() {
  int N;
  cin >> N;
  ll a[N][3];
  for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> a[i][j];

  for (int i = 0; i < 3; i++) dp[0][i] = a[0][i];
  for (int i = 1; i < N; i++) {
    dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
  }

  cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
const int N=1e5+5;

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
	int n=nxi();
	double d=nxi(),k=nxi(),ans=0;
	for(; n; --n){
		ans+=(d+(d+k*((n<<1)-1)))/2;
		d=(((n+1)<<1)*d+k*5)/(n<<1);
		k=((double)n*2+4)/(n<<1)*k;
	}
	printf("%.9lf\n",ans);
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum[5000][5000], a[210000], b[210000]; 
double dp[30][210000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		if (i >= m)
			dp[0][m] += 1.0 / n;
		else
			dp[0][i] += 1.0 / n;
	}
	rep(i, 22) {
		rep(j, m) {
			if (j * 2 < m) {
				dp[i + 1][j * 2] += dp[i][j] / 2;
				dp[i + 1][0] += dp[i][j] / 2;
			}
			else {
				dp[i + 1][m] += dp[i][j] / 2;
				dp[i + 1][0] += dp[i][j] / 2;
			}
		}
		dp[i + 1][m] += dp[i][m];
	}
	printf("%.15f\n", dp[22][m]);
	return 0;
}


Measured memory_bytes: 37248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        string[] line = Console.ReadLine().Split(' ');
        int t = int.Parse(line[0]);
        int a = int.Parse(line[1]);

        Func<int, double> temp = (temp_a) => t - temp_a * 0.006d;
        Func<int, double> abs = (abs_a) => Math.Abs(a - temp(abs_a));

        int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int index = 0;
        double min = double.MaxValue;
        for(int i = 0; i < H.Length; i++)
        {
            if(IsMin(ref min, abs(H[i])))
            {
                index = i;
            }
        }

        Console.WriteLine(index + 1);
        Console.ReadLine();
    }

    static bool IsMin(ref double min, double value)
    {
        if (min > value)
        {
            min = value;
            return true;
        }
        else
        {
            return false;
        }
    }
}

Measured memory_bytes: 13340
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pi 3.1415926535897932

#define int long long

template<typename A, size_t N, typename T>

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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int A,B,H,M;
cin>>A>>B>>H>>M;


long double DO=abs(30*H + 0.5*M -6*M);

long double DO_R=DO*pi/180;


long double x =sqrt( A*A + B*B -2*A*B*cos(DO_R) );





printf("%.10LF\n", x);










return 0;

}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
int main() {
    FAST
   ld a,b,c;
    cin>>a>>b>>c;


    ld x=sqrt(a);
    ld y=sqrt(b);
    if(a+(2*(x*y))+b<c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
n,k=map(int,input().split())
m=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,n+1):
  g1.append((g1[-1]*i)%m)
  inverse.append((-inverse[m%i]*(m//i))%m)
  g2.append((g2[-1]*inverse[-1])%m)


for i in range(k):
  x=cmb(n-k+1,n-k-i,m)
  y=cmb(k-1,i,m)
  print((x*y)%m)

Measured memory_bytes: 3572
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(N)]
C = [[int(_) for _ in input().split()] + [_+1] for _ in range(M)]
for a, b in AB:
    ans = []
    for c in C:
        ans += [[(abs(c[0]-a)+abs(c[1]-b))*100+c[2], c[2]]]
    print(sorted(ans)[0][1])


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

int main() {
    int n, a;
    int min = INT_MAX;
    int max = INT_MIN;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        min = a < min ? a : min;
        max = a > max ? a : max;
        sum += a;
    }
    cout << min << ' ' << max << ' ' << sum << endl;
}

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

int main(){
    int A,B,C,D;

    cin >> A >> B >> C >> D;

    int time = 0;
    if(C < B && D > A){
        if(A < C){
            if(B < D)
                time = B - C;
            else
                time = D - C;
        }
        else if(A > C){
            if(B > D)
                time = D - A;
            else 
                time = B - A;
        }else{
            if(B > D)
                time = D - A;
            else
            {
                time = B - A;
            }
        }
    }else{
        time = 0;
    }
    
    cout << time  << endl;

}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc086/submissions/3526242
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, k;
int sum[4005][4005], b[2005][2005];

int calc(int x, int y){
	return sum[y+k][x+k] - sum[y+k][x] - sum[y][x+k] + sum[y][x];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	rep(i,n){
		int x, y;
		char c;
		cin >> x >> y >> c;
		if(c == 'W') x += k;
		x %= 2*k;
		y %= 2*k;
		b[y][x]++;
	}
	rep(i,4*k)rep(j,4*k) sum[i][j] = b[i%(2*k)][j%(2*k)];
	rep(i,4*k){
		for(int j = 1; j < 4*k; ++j){
			sum[i][j] += sum[i][j-1];
		}
	}
	for(int i = 1; i < 4*k; ++i){
		rep(j,4*k){
			sum[i][j] += sum[i-1][j];
		}
	}
	int ans = 0;
	rep(i,2*k)rep(j,2*k){
		int score = calc(j, i) + calc(j + k, i + k);
		chmax(ans, score);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	long n,a=0,x;
	cin>>n;
	vector<long>v(n);
	vector<long>c(n);
	for(int i=0;i<n;i++)cin>>v.at(i);
		
	
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		c.at(i)=2*v.at(i);
	}
	long j=0;
	while(c.at(j)<=v.at(n-1)&&j<n){
		a++;
		j++;
	}
	if(a==0){
		cout<<v.at(n-1)<<" "<<c.at(0)/2<<endl;
	}
	else{
		if(-c.at(a-1)+v.at(n-1)>c.at(a)-v.at(n-1)){
			x=c.at(a)/2;
		}
		else{
			x=c.at(a-1)/2;
		}
		cout<<v.at(n-1)<<" "<<x<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			String[] nums = kb.readLine().split( " " );
			
			Double a = Double.parseDouble( nums[0] );
			Double b = Double.parseDouble( nums[1] );
			Double C = Double.parseDouble( nums[2] );
			
			Double h = Math.sin( Math.toRadians( C ) ) * b;
			Double S = ( a*h )/2;
			
			Double a2 = Math.cos( Math.toRadians( C ) ) * b;
			a2 -= a;
			Double L = Math.sqrt( ( Math.pow( a2, 2 ) + Math.pow( h, 2 ) ) );
			L = L+a+b;
			
			System.out.print( S+"\n"+L+"\n"+h+"\n" );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 16932
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define LD long double

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

    LD h,a;
    cin>>h>>a;
    cout<<(LL)ceil(h/a)<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a[4],b[4],n,m,hit=0,brow=0;
  while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
    scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
    for(n=0;n<4;n++){
      if(a[n]==b[n]){
	hit=hit+1;
      }
      for(m=0;m<4;m++){
	if(a[n]==b[m] && m!=n){
	  brow=brow+1;
	}
      }
    }
    printf("%d %d\n",hit,brow);
    hit=0;
    brow=0;
  }
  return (0);
}

Measured memory_bytes: 596
#include<stdio.h>
int main(){
  int a,b;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0){
      break;
    }
    if(a<=b){
      printf("%d %d\n",a,b);
    }
    else{
      printf("%d %d\n",b,a);
    }
  }
  return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;
bool flags[1000001];

int main()
{
    ll n, cnt = 0, base, tmp;
    bool flag = false;

    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    rep(i, n)
    {
        if (!flags[a[i]])
        {
            if (i == n - 1 || a[i] != a[i + 1])
            {
                cnt++;
            }
            else
            {
                flags[a[i]] = true;
            }
        }
        else
        {
            continue;
        }
        base = a[i];
        tmp = base;
        while (true)
        {
            tmp += base;
            if (tmp > a[a.size() - 1])
            {
                break;
            }
            flags[tmp] = true;
            // cout << tmp << endl;
        }
        // flag = false;
        // rep(j, i)
        // {
        //     if (a[i] % a[j] == 0)
        //     {
        //         // cout << a[i] << ", " << a[j] << endl;
        //         flag = true;
        //         break;
        //     }
        // }
        // if (!flag && (i == n - 1 || a[i] != a[i + 1]))
        // {
        //     cnt++;
        //     // cout << a[i] << endl;
        // }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
int A[10],i,j,p;
int main(){
  for(i=0;i<10;i++){
    scanf(" %d",&A[i]);
  }
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(A[i]>A[j]){
        p=A[j];
        A[j]=A[i];
        A[i]=p;
      }
    }
  }
  for(i=9;i>6;i--){
    printf("%d\n",A[i]);
  }
  return 0;
}

Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int rows = a - c;
	int cols = b - d;
	cout<<rows * cols;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
RGB = ['R', 'G', 'B']
import collections
if len(set(list(S))) <= 2:
    print(0)
else:
    dct = dict(collections.Counter(S))

    cnt = 0
    for i in range(N-2):
        for k in range((N - 1 - i) // 2 + 1):
            temp = {S[i], S[i + k], S[i + k * 2]}
            if len(temp) == 3:
                cnt += 1
            #print(cnt)
    print(dct['R'] * dct['G'] * dct['B'] - cnt)

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

using namespace std;

int main(){
	int N, M;
	cin >> N >> M;
	int H[N];
	for(int i = 0; i < N; i++){
		cin >> H[i];
	}

	vector<int> v[N];
	for(int i = 0; i < M; i++){
		int A, B;
		cin >> A >> B;
		v[A-1].push_back(B-1);
		v[B-1].push_back(A-1);
	}

	int ans = 0;
	for(int i = 0; i < N; i++){
		bool flag = true;
		for(int j = 0; j < v[i].size(); j++){
			if (H[v[i][j]] >= H[i]){
				flag = false;
				break;
			}
		}
		if(flag){
			ans++;
		}
	}

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


Measured memory_bytes: 9096
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h,w,i,j;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0 && w==0)
            break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++)
                printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
var rows = require("fs").readFileSync("/dev/stdin", "utf8").split("\n")

var N = rows[0].trim()
var A = rows[1].split(" ").map(parseFloat)
var A_ = A.map(function (x, i) { return { x: x, i: i + 1 } })

A_.sort(function asc(a, b) {
    return a.x - b.x
  })

console.log(A_.map(function (p) { return p.i }).join(" "))


Measured memory_bytes: 34856
#include<stdio.h>

int main(){
  int N,val[200000];
  int i,j;
  int maxv,minv,benefit;
  
  scanf("%d",&N);

  for(i=0;i<N;++i){
    scanf("%d",&val[i]);
  }

  maxv=val[1]-val[0];
  minv=val[0];

  for(i=1;i<N;++i){
    if(maxv<val[i]-minv) maxv=val[i]-minv;
    if(minv>val[i]) minv=val[i];
  }

  printf("%d\n",maxv);

  return 0;
}

Measured memory_bytes: 1376
//13, 04, 2019, 09:10:51 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 2e5;
pii v[N];
int w[N];

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

    int n, k;

    string s;

    cin >> n >> k;
    k--;
    cin >> s;

    int carry = 0;
    int idx = 1;
    int id = 1;

    for(int i = 0 ; i < s.length() ; i++){
        if(s[i] == '1' && carry < 0){
            v[id++] = {abs(carry), max(1, idx - 1)};
            carry = 0;
        }else if(s[i] == '0' && carry > 0){
            w[idx++] = carry;
            carry = 0;
        }

        if(s[i] == '1'){
            carry++;
        }else{
            carry--;
        }
    }

    if(carry > 0){
        w[idx++] = carry;
    }else if(carry < 0){
        v[id++] = {abs(carry), idx - 1};
    }

    for(int i = 1 ; i <= idx ; i++){
        w[i] += w[i - 1];
    }

    for(int i = 1 ; i <= id ; i++){
        v[i].first += v[i - 1].first;
    }

    int best = 0;

    if(id == 1){
        cout << w[1] << endl;
        // cout << "aqui" << endl;
    }else{
        // cout << id << endl;
        for(int i = 1 ; i < id ; i++){
            // cout << "log = " << v[i].second << endl;
            // cout << v[i].first << " -> " ;

            if(i + k >= id){
                // cout << v[id].first << " y " << endl;
                best = max(best, v[id].first - v[i - 1].first + w[v[id - 1].second + 1] - w[v[i].second - 1]);
            }else{

                // cout << v[i + k].first << " x " << endl;
                best = max(best, v[i + k].first - v[i - 1].first + w[v[i + k].second + 1] - w[v[i].second - 1]);
            }

            // break;
        }

        cout << best << endl;
    }
    
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, h[101010], a,b;
void solve(){
	cin >> n >> a >> b;
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	
	i64 l = 0, r = INF;
	while(r-l > 1){
		i64 c = (l+r)/2;
		i64 cnt = 0;
		for(int i = 0; i < n; i++){
			cnt += max(0LL, (h[i]-c*b+(a-b)-1)/(a-b));
		}
		if(cnt > c) l = c;
		else r = c;
	}
	cout << r << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

int const N=1e2+5, M=1e5+5, OO = 0x3f3f3f3f;


int n,W,V;
int v[N],w[N];

int mem[N][M];
int solve(int i, int rem)
{
    if(i==n)
    {
        if(rem==0)
            return 0;
        return OO;
    }
    if(mem[i][rem]!=-1)
        return mem[i][rem];
    int op1=solve(i+1,rem);
    int op2=(rem>=v[i]) ? solve(i+1,rem-v[i])+w[i] : OO;
    return mem[i][rem]=min(op1,op2);

}




int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    scanf("%d %d",&n,&W);
    for(int i=0; i<n; i++)
    {
        scanf("%d %d",w+i,v+i);
        V+=v[i];
    }
    memset(mem, -1, sizeof mem);
    for(int i=V; i>=0; i--)
    {
        if(solve(0,i)<=W)
        {
            printf("%d\n",i);
            break;
        }
    }

    return 0;

}


Measured memory_bytes: 41216
/*
 * a.cc:
 */

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

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */
int main(){
  int x;
  cin>>x;

  if (x==3 || x==5 || x==7)
  cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}  

  

  


Measured memory_bytes: 3632
#!/usr/bin/env ruby

max = gets.to_i
# max = 3600

def include_only_357?(num)
  str = num.to_s
  str.include?('3') && str.include?('5') && str.include?('7') && !str.include?('0')
end

puts %w(0 3 5 7).repeated_permutation(9).lazy
  .map(&:join).map(&:to_i)
  .select(&method(:include_only_357?))
  .take_while {|i| i <= max }
  .count


Measured memory_bytes: 1916
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0;i < n;i++)
using namespace std;

int n, m;
string s, t;
int main() {
	cin >> s >> t;
	if (s.size() > t.size())
		cout << "GREATER" << endl;
	else if (s.size() < t.size())
		cout << "LESS" << endl;
	else {
		if (s > t) {
			cout << "GREATER" << endl;
		}
		else if (s < t) {
			cout << "LESS" << endl;
		}
		else
			cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i%3==0) continue;
        else if(i%5==0) continue;
        else if(i%3==0&&i%5==0) continue;
        else ans+=i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
S = [''.join(sorted(list(input()))) for i in range(N)]
ans = 0
for i in Counter(S).items():
    ans += i[1] * (i[1] - 1) // 2
print(ans)

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


int main()
{
	int n; cin >> n;
	int c = 0, ok = 0;
	for (int i = 0; i < n; ++i)
	{
		int a, b; cin >> a >> b;
		if (a == b)
		{
			c++;
			if (c == 3)
				ok = 1;
		}
		else
			c = 0;
	}
	cout << (ok ? "Yes" : "No") << endl;
}


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

using namespace std;
typedef long long ll;


void decompositPrime(ll n,ll &c)
{
    // 割る数の初期値
    ll a = 2;
    ll A = 0;
    ll nex = 1;
    ll now = 1;

    ll n_pre = n;

    
    while (n_pre >=a*a)
    {
        
       
        if (n%a==0)
        {

            A ++;
    
           
            
            if(A==nex){
               now++;
               nex = nex + now;
                c++;

            }
            n /= a;
        }
        else
        {
            
            a++;
            A = 0;
            nex = 1;

            now = 1;

        }
    }


    if(n!=1){

        c++;
    }


}


int main()
{
    ll N;

    ll c=0;

    cin >> N;



    decompositPrime(N,c);



   
    cout << c << endl;


    

    
    return 0;
}

Measured memory_bytes: 3596
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3"# => r#"6"#,
r#"10"# => r#"3628800"#,
r#"100000"# => r#"457992974"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }
    let m = 1_000_000_007;


    let mut ans = 1;
    for i in 1..n + 1 {
        ans = ans * i % m ;
    }

    ans.to_string()
}

Measured memory_bytes: 4352