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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

ll lllog2(ll n)
{
    ll c = 0;
    while(n > 1) {
        n /= 2;
        ++c;
    }
    return c;
}

ll xorsum(ll n)
{
    if(n <= 0) return 0;
    else if(n == 1) return 1;
    else if(n == 2) return 3;
    else {
        ll l = lllog2(n + 1);
        ll m = n - (1LL << l);
        if((m + 2) % 2 == 1) return xorsum(m);
        else return (xorsum(m) ^ (1LL << l));
    }
}

int main()
{
    ll A, B;
    cin >> A >> B;

    PR(xorsum(B)^xorsum(A-1));

    return 0;
}

/*



*/

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

int main () {
    int n;
    cin >> n;
    int taro = 0, hanako = 0;
    string t_s, h_s;

    for (int i = 0; i < n; i++) {
        cin >> t_s >> h_s;
        if (t_s > h_s) {
            taro += 3;
        }
        else if (t_s < h_s) {
            hanako += 3;
        }
        else {
            taro++; hanako++;
        }
    }
    printf("%d %d\n", taro, hanako);
    return 0;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(i,a,b) for(int i=a;i<b;i++)
#define incl(i,a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define PII pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

int mygcd(int a,int b)
{
    if(b==0)
        return a;
    return mygcd(b,a%b);
}

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

signed main()
{
    fatafat;
    int n;
    cin>>n;
    int v[n],c[n];
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int i=0;i<n;i++)
        cin>>c[i];
    int ans=0;
    for(int i=0;i<n;i++)
        if(v[i]>c[i])
            ans+=(v[i]-c[i]);
    cout<<ans;
        
}

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

int main() {
	long long int n,h,w;
	cin>>n>>h>>w;
	long long int H,W,count=0;
	for(int i=0;i<n;i++){
		cin>>H>>W;
	if(H>=h&&W>=w)count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	string S;
	cin >> N;
	cin >> S;
	int l = 0;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == '(') cnt++;
		else if (cnt == 0) l++;
		else cnt--;
	}
	cout << string(l, '(') + S + string(cnt, ')') << endl;
}

Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)

Measured memory_bytes: 9372
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 3e5 + 5;

int a[N], sum[N];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = 0;
    for (int i = 0; i < 60; i++) {
        int o = 0, z = 0;
        for (int j = 1; j <= n; j++) {
            if (a[j] & (1ll << i)) o++;
            else z++;
        }
        ans += ((o*z) % MOD * ((1ll << i) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

const int N = 1e6 + 5;

vector< int> conn[N];
int inDegree[N], present[N];
vector< int> top;


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

    int n;
    cin >> n;

    for (int i = 1; i <= n; i ++) {
        int last = -1;
        for (int j = 1; j <= n - 1; j ++) {
            int y;
            cin >> y;
            int x = i;
            if (x > y) swap(x, y);
            x --, y --;

            if (last != -1) {
                inDegree[x * n + y] ++;
                conn[last].push_back(x * n + y);
            }
            last = x * n + y;
            present[last] = 1;
        }
    }

    vector< int> zero;
    for (int i = 0; i < n * n; i ++) {
        if (present[i] && inDegree[i] == 0) zero.push_back(i);
    }

    int answer = 0, processed = 0;

    while (!zero.empty()) {
        answer ++;
        int k = zero.size();
        processed += k;
        vector< int> nxtZero;

        for (const int& x : zero) {
            for (const int &y : conn[x]) {
                inDegree[y] --;
                if (inDegree[y] == 0) {
                    nxtZero.push_back(y);
                }
            }
        }
        zero = nxtZero;
    }

    if (processed != n * (n - 1) / 2) cout << -1 << endl;
    else {
        cout << answer << endl;
    }

}

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

int main() {
  int N,K;
  cin >> N>>K;
  int count = 0;
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    if (K/2 >= x){
      count += x*2;
    }
    else{
      count += (K - x)*2;
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 3552
//Dedicated to the two things I don't have in my life
//Ekagrata and Ekagrata
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(c)	c.begin(),c.end()
int odd[100005], even[100005];
bool co(int a, int b)
{return (odd[a] > odd[b]);}
bool ce(int a, int b)
{return (even[a] > even[b]);}
int cal(int a[], int odd, int ev, int n)
{
    if(ev == odd)
        return INT_MAX;
    int ans = 0;
    for(int i = 0; i < n; i++)
        if((i & 1 && a[i] != odd) || ((i & 1) == 0 && a[i] != ev))
            ans++;
    return ans;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n, i, ans = 0;
    cin >> n;
    int a[n];
    memset(odd, 0, sizeof odd);
    memset(even, 0, sizeof even);
    for(i = 0; i < n; i++)
        cin >> a[i];
    for(i = 0; i < n; i++)
    {
        if(i & 1)
            odd[a[i]]++;
        else
            even[a[i]]++;
    }
    int bo = a[1], be = a[0];
    vector <int> ov, ev;
    for(i = 0; i < 100005; i++)
    {
        if(odd[i])
            ov.pb(i);
        if(even[i])
            ev.pb(i);
    }
    if(ov.size() == 1)
        ov.pb(0);
    if(ev.size() == 1)
        ev.pb(0);
    sort(all(ov), co), sort(all(ev), ce);
    ans = min(cal(a, ov[0], ev[0], n), min(min(cal(a, ov[0], ev[1], n), cal(a, ov[1], ev[0], n)), cal(a, ov[1], ev[1], n))); 
    cout << ans << endl;
    return 0;
}

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

A = [list(map(int, input().split())) for _ in range(N)]

mi = sorted([A[i][0] for i in range(N)])
ma = sorted([A[i][1] for i in range(N)])

if N % 2 == 0:
    mi2 = mi[N//2-1] + mi[N//2]
    ma2 = ma[N//2-1] + ma[N//2]
else:
    mi2 = mi[N//2]
    ma2 = ma[N//2]

print(ma2 - mi2 + 1)




Measured memory_bytes: 50948
I=lambda:list(map(int,input().split()))
n,m=I()
a=[[i]+I() for i in range(m)]
a=sorted(a,key=lambda x:(x[1],x[2]))
b=[]
j0=0
p=1
for i,j,k in a:
  if j!=j0:
    p=1
  else:
    p+=1
  b.append([i,j,p])
  j0=j
b=sorted(b,key=lambda x:x[0])
for i,j,k in b:
  print("{:06d}{:06d}".format(j,k))

Measured memory_bytes: 39272
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n;
    int i, j;
    ll ans = 0;

    cin >> n;

    vector<int> d(n);

    rep(i, 0, n)
    {
        cin >> d[i];
    }

    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll modpow(ll m, ll p) {
    if (p == 0) return 1;
    ll tmp = modpow(m, p / 2);
    if (p & 1) return (tmp * tmp % MOD) * m % MOD;
    else return tmp * tmp % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;

    vll fac(n + 1, 1), invfac(n + 1, 1);
    for (ll i = 2; i <= n; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        invfac[i] = invfac[i - 1] * modpow(i, MOD - 2) % MOD;
    }

    // dp[i][j]: i 人以下のグループだけで j 人使う時の分け方
    vvll dp(b + 1, vll(n + 1, 0));
    dp[0][0] = 1;
    // i 人グループを g 個追加
    // 遷移: dp[i][j + i * g] = dp[i - 1][j] * {n-j}_C_{i * g} * (i * g)! / (i!) ^ g / g!
    for (ll i = 1; i <= b; i++) {
        if (i < a) {
            dp[i] = dp[i - 1];
            continue;
        }
        for (ll j = 0; j <= n; j++) {
            (dp[i][j] += dp[i - 1][j]) %= MOD;
            for (ll g = c; g <= d; g++) {
                if (j + i * g > n) break;
                ll tmp = dp[i - 1][j] * (fac[n - j] * (invfac[i * g] * invfac[n - j - i * g] % MOD) % MOD) % MOD;
                (tmp *= fac[i * g]) %= MOD;
                (tmp *= modpow(modpow(fac[i], g), MOD - 2)) %= MOD;
                (tmp *= invfac[g]) %= MOD;
                (dp[i][j + i * g] += tmp) %= MOD;
            }
        }
    }
    // for (ll i = 0; i <= b; i++) DEBUG_VLL(dp[i])
    cout << dp[b][n] << '\n';
    return 0;
}


Measured memory_bytes: 8192
X, K, D = map(int, input().split())

X = abs(X)
reach_or_before = X // D


if K <= reach_or_before:
    print(X - D * K)
else:
    #remaining jump
    remain = K - reach_or_before
    before_dist = X - D * reach_or_before #(>0)
    after_dist = D * (reach_or_before + 1) - X
    if remain % 2 == 0:
        print(before_dist)
    else:
        print(after_dist)


Measured memory_bytes: 9124
#include <stdio.h>
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int a[m],b[m],road[n];
    for (int i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for (int i=0;i<n;i++){
        road[i]=0;
        for (int j=0;j<m;j++){
            if (i+1==a[j]){
                road[i]++;
            }
            if (i+1==b[j]){
                road[i]++;
            }
        }
        printf("%d\n",road[i]);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first #define se second
using namespace std; typedef long long ll;
const int MAXN = 10 + 3e3;
const ll oo = 1 + 1e18, mod = 7 + 1e9;

ll n, m, a[MAXN], b[MAXN]; long long f[MAXN][MAXN];

int main(){
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin),freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        f[i][0] = 1ll;
    }
    for (int i = 1; i <= m; i++){
        cin >> b[i];
        f[0][i] = 1ll;
    }

    f[0][0] = 1ll;

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            f[i][j] = (f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] * 1ll * (a[i] != b[j]) + mod) % mod;

        }
    }

    cout << f[n][m];




    return 0;
}


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

int main(){
  long long n,k,ans=0,mod=1000000007,i,j;
  cin >> n >> k;
  vector<long long> a(n);
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      if(a[i]<a[j]){
        ans=(ans+k*(k-1)/2)%mod;
      }else if(a[i]>a[j]){
        ans=(ans+k*(k+1)/2)%mod;
      }
    }
  }
  cout << ans;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

#define db double

db dp[301][301][301];

db solve(int n, int x, int y, int z){
	if(x==0 && y == 0 && z == 0){
		return dp[0][0][0] = 0.0;
	}
	if(dp[x][y][z]==-1){
		db c = ((db)n)/(x+y+z), a1 = ((db)x)/n, b1 = ((db)y)/n,c1 = ((db)z)/n, res = 0.0;
		if(x){
			res += c*a1*solve(n, x-1, y, z);
		}
		if(y){
			res += c*b1*solve(n, x+1, y-1, z);
		}
		if(z){
			res += c*c1*solve(n, x, y+1, z-1);
		}
		return dp[x][y][z] = c + res;
	}
	else{
		return dp[x][y][z];
	}
}

void test(int n, int one, int two, int three){
	db answer = solve(n, one, two, three);
	cout << setprecision(15) << answer << endl;
}

int main(){
	for(int i = 0; i < 301; i++){
		for(int j = 0; j < 301; j++){
			for(int k = 0; k < 301; k++){
				dp[i][j][k] = -1;
			}
		}
	}
	int n, temp, one = 0, two = 0, three = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> temp;
		if(temp==1){
			one++;
		}
		else if(temp==2){
			two++;
		}
		else{
			three++;
		}
	}
	test(n,one, two, three);
	return 0;
}

Measured memory_bytes: 216924
#include <stdio.h>

int main(void)
{
        int N,D,i,A[100],X,j,s=0;

        scanf("%d%d%d",&N,&D,&X);

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

        for (i=0;i<N;i++){
                for (j=1;j<=D;j=j+A[i])
                        s++;
        }

        printf("%d\n",s+X);

        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>

using namespace std;

int N, M;

int a[100005], b[100005];

int C[100005];

int used[100005];

set<int> Adj[100005];


int rem;

int num;

void VISIT(int K) {

	//cout << "-- " << K << endl;

	//if ((used[K] % 2) == 1) { num++; }
	if (used[K]>0) { num++; }

	used[K]=1-used[K];

	if (Adj[K].size() > 0) {
		int L = *(Adj[K].begin());

		Adj[K].erase(L);
		Adj[L].erase(K);
		rem--;

		VISIT(L);
	}

}

int N6, N4;

int count_T;

void visit(int K) {

	used[K] = 1;

	for (auto it = Adj[K].begin(); it != Adj[K].end(); it++) {
		int M = (*it);

		if (used[M] == 0) { visit(M); }
	}

}

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
		C[a[i]]++; C[b[i]]++;
		Adj[a[i]].insert(b[i]);
		Adj[b[i]].insert(a[i]);
	}


	int flag = -1;

	for (int i = 1; i <= N; i++) {
		if (C[i] >= 6) { N6++; }
		if (C[i] >= 4) { N4++; }
	}

	for (int i = 1; i <= N; i++) {
		if ((C[i] % 2) == 1) { flag = -1;  cout << "No" << endl; return 0; }
	}

	

	rem = M;
	int K = 1;
	//======================
/*	while(rem>0){

		while(Adj[K].size() > 0) {

			used[K]++;   //cout << "K= " << K << endl;
			int L;
			L = *(Adj[K].begin());
			
			Adj[K].erase(L);
			Adj[L].erase(K);
			rem--;
			VISIT(L);
			
		}
		K++; if (K > N) { K = 1; }
	}
	*/
	//======================

	/*for (int i = 1; i <= N; i++) {
		cout << "used[" << i << "]= " << used[i] << endl;
	}

	cout << "num= " << num << endl;*/

	//if (num <= 2) { flag = -1; }

	if (N6 > 0) { flag = 1; }
	else if (N4 >= 3) { flag = 1; }
	else if (N4 == 2) {

		int S;
		for (int i = 1; i <= N; i++) {
			if (C[i] == 4) { S = i; break; }
		}

		int T;
		for (int i = 1; i <= N; i++) {
			if ((C[i] == 4) && (i != S)) { T = i; }
		}

		
		auto it = Adj[S].begin();

		for (int h = 0; h < 4; h++) { //4 
			for (int i = 1; i <= N; i++) {
				used[i] = 0;
			}
			used[S] = 1;
			int L = (*it);
			visit(L);
			if (used[T] > 0) { count_T++; }

			it++;

		}
		if (count_T == 4) { flag = -1; }
		else { flag = 1; }

		//cout << "count_T = " << count_T << endl;

	}
	else if (N4 <= 1) {
		flag = -1;
	}

	/*if (N4 >= 2) { flag = 1; }*/
	
	/*for (int i = 1; i <= N; i++) {
		cout << "C[" << i << "]= " << C[i] << endl;
	}
	cout << "num= " << num << endl;
	cout << "flag= " << flag << endl;*/
	
	if (flag == -1) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 17408
#include<stdio.h>
char s[9];
int main()
{
	int i,a,b,c;
	scanf("%d",&a);
	c=a,b=0;
	while(c)
	{
		b+=c%10;
		c/=10;
	}
	if(a%b==0)
	{
		printf("Yes\n");
	}
	else
		printf("No\n");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int H[100001];

int main() {
  int N, result;
  int i, max;
  scanf ("%d", &N);
  
  for (i=0;i<N;i++) {
      scanf("%d", &H[i]);
  }
  
  result = 0;
  max = 0;
  for (i=N-1;i>0;i--) {
    if (H[i-1]>=H[i]) {
        max++;
    }
    else {
        if (max>result) result = max;
        max=0;
    }
  }
  if (max>result) result = max;
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
}
int a,b;

int main(){
    while(cin>>a>>b){
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }
}



Measured memory_bytes: 3092
s = int(input())
ans_list = [0] * (10 ** 6 + 1)
ans_list[0] = s
now = s

i = 1
T = True
while T:
  if now % 2 == 0:
    now = int(now / 2)
  else:
    now = 3 * now + 1
  i += 1
  if now in ans_list:
    print(i)
    T = False
  ans_list[i - 1] = now
  #print(now)
  #print(ans_list)
  


Measured memory_bytes: 69560
def f(s):
    if s == "A":
        return A
    elif s == "B":
        return B
    elif s == "C":
        return C


def inc(s):
    global A, B, C

    if s == "A":
        A += 1
    elif s == "B":
        B += 1
    elif s == "C":
        C += 1


def dec(s):
    global A, B, C

    if s == "A":
        A -= 1
    elif s == "B":
        B -= 1
    elif s == "C":
        C -= 1


N, A, B, C = map(int, input().split())

if A + B + C == 0:
    print("No")

elif A + B + C == 1:
    ans = []
    for _ in range(N):
        s = input()
        if f(s[0]) == f(s[1]) == 0:
            print("No")
            exit()
        else:
            if f(s[0]) == 1:
                ans.append(s[1])
                dec(s[0])
                inc(s[1])
            elif f(s[1]) == 1:
                ans.append(s[0])
                inc(s[0])
                dec(s[1])
    print("Yes")
    for i in range(N):
        print(ans[i])

elif A + B + C >= 2:
    s = []
    for i in range(N):
        s.append(input())

    if f(s[0][0]) == f(s[0][1]) == 0:
        print("No")
        exit()

    ans = []
    for i in range(len(s)):
        if f(s[i][0]) >= 1 and f(s[i][1]) == 0:
            ans.append(s[i][1])
            dec(s[i][0])
            inc(s[i][1])
        elif f(s[i][0]) == 0 and f(s[i][1]) >= 1:
            ans.append(s[i][0])
            inc(s[i][0])
            dec(s[i][1])
        elif (A + B + C == 2) and (f(s[i][0]) == f(s[i][1]) == 1) and (i < N - 1) and (s[i] != s[i + 1]):
            if s[i][0] == s[i + 1][0] or s[i][0] == s[i + 1][1]:
                ans.append(s[i][0])
                inc(s[i][0])
                dec(s[i][1])
            elif s[i][1] == s[i + 1][0] or s[i][1] == s[i + 1][1]:
                ans.append(s[i][1])
                dec(s[i][0])
                inc(s[i][1])
        else:
            ###ここらへんちょっと改変###
            if f(s[i][0]) == 1:
                ans.append(s[i][0])
                inc(s[i][0])
                dec(s[i][1])
            else:
                ans.append(s[i][1])
                inc(s[i][1])
                dec(s[i][0])
                
    print("Yes")
    for i in range(N):
        print(ans[i])


Measured memory_bytes: 17092
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int solve(int W, vector<int> w, vector<int> v, int i, vector<vector<int> > &dp)
{
	// Base cases
	if (i < 0)
		return 0;
	if (dp[i][W] != -1)
		return dp[i][W];

	if (w[i] > W)
		return dp[i][W] = solve(W, w, v, i - 1, dp);

	else
		return dp[i][W] = max(v[i] + solve(W - w[i], w, v, i - 1, dp), solve(W, w, v, i - 1, dp));
}
int32_t main()
{
	fast();
	int n, W;	cin >> n >> W;
	vector<int> w(n), v(n);
	for (int i = 0; i < n; i++)	cin >> w[i] >> v[i];
	vector<vector<int> > dp(n + 1, vector<int> (W + 1, -1));
	cout << solve(W, w, v, n - 1, dp);
	return 0;
}


Measured memory_bytes: 83188
let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ass = Array.init h @@ fun _ ->
    Scanf.scanf "%s\n" @@ fun as_ -> as_ in
  let red = Array.map String.copy ass in
  let blue = Array.map String.copy ass in
  for i = 0 to w - 1 do
    red.(0).[i] <- '#';
    blue.(h - 1).[i] <- '#'
  done;
  for i = 1 to h - 2 do
    for j = 0 to w - 1 do
      if j mod 2 = 0 then
        red.(i).[j] <- '#'
      else
        blue.(i).[j] <- '#'
    done
  done;
  Array.iter print_endline red;
  print_newline ();
  Array.iter print_endline blue


Measured memory_bytes: 5120
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
	string S;

	cin >> S;

	int right, left;
	right = S.length() - 1;
	left = 0;

	int cnt = 0;

	while (left < right)
	{
		if (S[left] != S[right])
			cnt++;

		left++;
		right--;
	}

	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

class BIT{
	vector<int> bit;
public:
	BIT(int siz){
		bit.resize(siz + 1,0);
	}
	void add(int i,int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum(int i){
		int s = 0;
		while(i){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
};

signed main(){
	int n,ans = 0,ki = 0;
	queue<int> ind[26];
	string s;
	cin >> s;
	n = s.length();
	BIT bit(n + 5);
	for(int i = n - 1;i >= 0;i--){
		ind[s[i] - 'a'].push(i);
		bit.add(i + 1,1);
	}
	for(int i = 0;i < 26;i++){
		if(ind[i].size() % 2) ki++;
	}
	if(ki >= 2){
		cout << -1 << endl;
		return 0;
	}
	int now = 0;
	for(int i = 0;i < n / 2;i++){
		bit.add(now + 1,-1);
		ans += n - (i + 1) * 2 - (bit.sum(ind[s[now] - 'a'].front()) - bit.sum(now + 1));
		bit.add(ind[s[now] - 'a'].front() + 1,-1);
		ind[s[now] - 'a'].pop();
		now++;
		while(now < n && bit.sum(now + 1) - bit.sum(now) == 0) now++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

ll H,W;
ll calc(ll h){
  ll ret;
  ll s1 = h*W;
  ll w = W/2;
  ll s2 = (H-h)*w;
  ll s3 = (H-h)*(W-w);
  ret = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
  ll h2 = (H-h)/2;
  s2 = h2*W;
  s3 = (H-h-h2)*W;
  ret = min(ret, max(s1,max(s2,s3)) - min(s1,min(s2,s3)));
  return ret;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> H >> W;
  ll mini = MAX_LL;
  repp(h,1,H) mini = min(mini,calc(h));
  swap(H,W);
  repp(h,1,H) mini = min(mini,calc(h));
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int a[55];
int main(){
	cin>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a+1,a+5);
	if (a[1]==1 && a[2]==4 && a[3]==7 && a[4]==9)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 256
S = input()
ans = False
if(S.find("keyence") == 0 or S.find("keyence") == len(S) - 7):
  ans = True
else:
  for i in range(7):
    if(S[0: i + 1] + S[len(S) - 6  +i : len(S)]  == "keyence"):
      ans = True
      break
if ans:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38384
//Author:- S_Aditya
//Date created:- 24 February 2019

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

vector<int> v[N];

//dp[node][0] stores no. of possible colourings in subtree of node if we paint node white,
//and dp[node][1] stores the same if we colour node as black.

ll dp[N][2]; 

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

void dfs(int node,int par)
{
    dp[node][0]=dp[node][1]=1;
    
    for(int it:v[node])
    if(it!=par)
    {
        dfs(it,node);
        
        dp[node][1]=(dp[node][1]*dp[it][0])%mod;
        
        ll temp=dp[it][0];
        
        add_self(temp,dp[it][1]);
        
        dp[node][0]=(dp[node][0]*temp)%mod;
    }
    
    //printf("%d %d %d\n",node,dp[node][0],dp[node][1]);
}

int main()                  
{
    int n;
    
    scn(n);
    
    rep(i,0,n-1)
    {
        int a,b;
        
        scn(a); scn(b);
        
        v[a].pb(b);
        
        v[b].pb(a);
    }
    
    dfs(1,-1);
    
    ll ans=dp[1][0]+dp[1][1];
    
    if(ans>=mod)
    ans-=mod;
    
    printf("%lld ",ans);
} 


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl 
const int mod=1000000007;
typedef pair<int,int> pii;
const int N=1e5+5;
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	double a;
	cin>>a;
	a=(a/3.0);
	cout<<fixed<<setprecision(13);
	cout<<pow(a,3.0)<<endl;
}

Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(f); }
	itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(l - 1); }
	itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool maxi(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool mini(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool smaxi(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool smini(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }

#include <algorithm>
#include <iostream>
#include <utility>
#include <limits>

int main() {
	usize n;
	u64 x;
	::std::cin >> n >> x;
	::std::vector<u64> s(n), p(n);
	s[0] = 1;
	p[0] = 1;
	for (const auto i : rep<>(1, n)) {
		s[i] = s[i - 1] * 2 + 3;
		p[i] = p[i - 1] * 2 + 1;
	}
	u64 ans{ 0 };
	while (n--) {
		if (x == 0) {
			break;
		}
		if (x >= s[n] + 2) {
			ans += p[n] + 1;
			x -= s[n] + 2;
		}
		else {
			x -= 1;
		}
	}
	if (x >= 1) {
		++ans;
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    ll ord;
    cin >> s;
    cin >> ord;
    int not_one = s.size() - 1;
    rep(i, s.size()){
        if(s[i] != '1'){
            not_one = i;
            break;
        }
    }
    if(ord <= not_one){
        cout << '1' << endl;
    }else{
        cout << s[not_one] << endl;
    }
    return 0;
}


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

using namespace std;

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

    int count = 0;
    int consecutive_num = 0;
    char p = '1';
    vector<int> vec;
    for (int i = 0; i < N; i++) {
        if (S[i] == p) {
            consecutive_num++;
        } else {
            vec.push_back(consecutive_num);
            consecutive_num = 1;
            p = S[i];
        }
    }
    vec.push_back(consecutive_num);

    if (p != '1') {
        vec.push_back(0);
    }
    int max_count = vec[0];

    int size = vec.size();
    for (int i = 0; i < size; i += 2) {
        int count = vec[i];
        for (int j = 0; j < K; j++) {
            int idx = i + 2*j + 1;
            if (idx >= size) {
                break;
            }
            count += vec[idx];
            idx++;
            if (idx >= size) {
                break;
            }
            count += vec[i + 2*j + 2];
        }

        if (count > max_count) {
            max_count = count;
        }
    }

    cout << max_count << endl;
    return 0;
}


Measured memory_bytes: 1020
n = int(input())
a = list(map(int, input().split()))
a2 = {}
for i in a:
    a2.setdefault(i, 0)
    a2[i] += 1
count = 0
for i, j in a2.items():
    if i > j:
        count += j
    else:
        count += j - i
print(count)

Measured memory_bytes: 17780
Len, Split = map(int, input().split())
_res = (Len - 1) % (Split - 1)
if _res:
    res = int(((Len - 1) // (Split - 1)) + 1)
    print(res)
else:
    res = int((Len - 1) // (Split - 1))
    print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=(int)(a-'0'),y=(int)(b-'0'),z=(int)(c-'0'),w=(int)(d-'0');
  int sum=7-x;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        if((2*i-1)*y+(2*j-1)*z+(2*k-1)*w==sum){
          cout<<x<<((2*i-1)>0?'+':'-')<<y<<((2*j-1)>0?'+':'-')<<z<<((2*k-1)>0?'+':'-')<<w<<"=7"; return 0;}
      }
    }
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int):
    n = len(str(N))
    ans = 0
    candidate = ["3", "5", "7"]
    break_flag = False
    for i in range(1, n + 1):
        combi_int = []
        for tmp in itertools.product(candidate, repeat=i):
            combi_int.append(int("".join(tmp)))
        combi_int = sorted(combi_int)
        if break_flag:
            break
        for tmp in combi_int:
            if N < tmp:
                break_flag = True
                break
            else:
                if "3" in str(tmp) and "5" in str(tmp) and "7" in str(tmp):
                    #print(tmp)
                    ans += 1
    print(ans)

# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i] -= (i+1);
    }
    sort(A.begin(),A.end());
    ll ave = A[N/2];
    ll ans =0;
    for(int i=0;i<N;i++){
        ans += abs(A[i]-ave);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005

void solve(){
   string a,b;
   cin >> a >> b;
   int i,j,n=a.size();
   int ans=0;
   for(i=0; i<n; i++){
       if(a[i]!=b[i])ans++;
   }
   cout << ans << '\n';
}




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

        int tt;
        tt=1;
       // cin >> tt;
        while(tt--){
            solve();
        }
        

}

Measured memory_bytes: 3820
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class M>
struct LazySegmentTree{
    using T = typename M::T;
    using L = typename M::L;
    int sz, height{};
    vector<T> seg; vector<L> lazy;
    explicit LazySegmentTree(int n) {
        sz = 1;
        while(sz < n) sz <<= 1, height++;
        seg.assign(2*sz, M::e());
        lazy.assign(2*sz, M::l());
    }

    void set(int k, const T &x){
        seg[k + sz] = x;
    }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    T reflect(int k){ return lazy[k] == M::l() ? seg[k] : M::g(seg[k], lazy[k]); }

    void eval(int k){
        if(lazy[k] == M::l()) return;
        lazy[(k<<1)|0] = M::h(lazy[(k<<1)|0], lazy[k]);
        lazy[(k<<1)|1] = M::h(lazy[(k<<1)|1], lazy[k]);
        seg[k] = reflect(k);
        lazy[k] = M::l();
    }
    void thrust(int k){ for (int i = height; i; --i) eval(k>>i); }
    void recalc(int k) { while(k >>= 1) seg[k] = M::f(reflect((k<<1)|0), reflect((k<<1)|1));}
    void update(int a, int b, const L &x){
        thrust(a += sz); thrust(b += sz-1);
        for (int l = a, r = b+1;l < r; l >>=1, r >>= 1) {
            if(l&1) lazy[l] = M::h(lazy[l], x), l++;
            if(r&1) --r, lazy[r] = M::h(lazy[r], x);
        }
        recalc(a);
        recalc(b);
    }

    T query(int a, int b){ // [l, r)
        thrust(a += sz);
        thrust(b += sz-1);
        T ll = M::e(), rr = M::e();
        for(int l = a, r = b+1; l < r; l >>=1, r>>=1) {
            if (l & 1) ll = M::f(ll, reflect(l++));
            if (r & 1) rr = M::f(reflect(--r), rr);
        }
        return M::f(ll, rr);
    }

    T operator[](const int &k) const { // 0-indexed
        return seg[k + sz];
    }
};

struct Monoid{
    using T = int;
    using L = int;
    static T f(T a, T b) { return min(a, b); }
    static T g(T a, L b) {
        if(b == e()) return a; else return b;
    }
    static L h(L a, L b) {
        if(b == e()) return a; else return b;
    }
    static T e() { return INT32_MAX; }
    static L l() { return INT32_MAX; }
};

int main() {
    int n, q;
    cin >> n >> q;
    LazySegmentTree<Monoid> seg(n);
    for (int i = 0; i < q; ++i) {
        int c;
        scanf("%d", &c);
        if(c == 0){
            int s, t, x;
            scanf("%d %d %d", &s, &t, &x);
            seg.update(s, t+1, x);
        }else {
            int x;
            scanf("%d", &x);
            printf("%d\n", seg.query(x, x+1));
        }
    }
    return 0;
}


Measured memory_bytes: 4876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define drep(i,n) for (int i = n; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, n)
  {
    cout << '[';
    rep(p, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}


//------------------------------------------------------------
int main() {
  int a, b, c, x, y, sum=0, common;
  cin >> a >> b >> c >> x >> y;

  common = min(x, y);

  if (a+b > 2*c)
  {
    sum += common * 2*c;
  }
  else
  {
    sum += common * (a+b);
  }

  x -= common; y -= common;

  if (x == 0)
  {
    sum += b > 2*c ? y*2*c : y*b;
  }
  else
  {
    sum += a > 2*c ? x*2*c : x*a;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
m = input()
m = list(m)
m = list(map(int,m))
for i in range(2**3):
    n = m[0]
    x = i
    t = []
    for _ in range(3):
        if x % 2 != 0:
            n += m[_+1]
            t.append('+')
        else:
            n -= m[_+1]
            t.append('-')
        x = x // 2
    if n == 7:
        l = [m[0],t[0],m[1],t[1],m[2],t[2],m[3],'=',7]
        l = list(map(str,l))
        print(''.join(l))
        break

Measured memory_bytes: 9196
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7

def cmb(n, k):
    if k < 0 or k > n: return 0 
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 2 * 10 ** 6 + 10  # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)

r1, c1, r2, c2 = lr()
answer = cmb(r2+c2+2, r2+1) - 1
answer -= cmb(r2+c1+1, r2+1) - 1
answer -= cmb(r1+c2+1, c2+1) - 1
answer += cmb(r1+c1, r1) - 1
print(answer % MOD)
# 26

Measured memory_bytes: 90532
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    ha, aa, da, sa = map(int, readline().split())
    ans = 0
    S = []
    for i in range(N):
        hi, ai, di, si = map(int, readline().split())
        m0 = max(ai - da, 0)
        if si > sa:
            ans += m0
        m1 = max(aa - di, 0)
        if m1 == 0 and m0 > 0:
            write("-1\n")
            return
        if m0 > 0:
            k = (hi + m1 - 1) // m1
            S.append((k, m0))
    S.sort(key = lambda x: x[0]/x[1])
    cur = 0
    for k, d in S:
        ans += (cur+k-1)*d
        cur += k
    if ans < ha:
        write("%d\n" % ans)
    else:
        write("-1\n")
solve()


Measured memory_bytes: 12292
def cross((x0, y0, x1, y1), (x2, y2, x3, y3)):
    dx0 = x1 - x0
    dy0 = y1 - y0
    dx1 = x3 - x2
    dy1 = y3 - y2

    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if s < 0:
        s = -s
        sm = -sm
    t = (y2-y0)*dx0 - (x2-x0)*dy0
    tm = dx1*dy0 - dy1*dx0
    if t < 0:
        t = -t
        tm = -tm
    if 0 < s < max(sm, 0) and 0 < t < max(tm, 0):
        return (x0 + float(s*dx0)/sm, y0 + float(s*dy0)/sm)
    return None

from math import sqrt
def dist((x0, y0), (x1, y1)):
    return sqrt((x0 - x1)**2 + (y0 - y1)**2)

while 1:
    n = input()
    if n == 0:
        break
    ans = 1
    ls = []
    for i in xrange(n):
        e = map(int, raw_input().split())
        cnt = 0
        ps = []
        for l in ls:
            c = cross(e, l)
            if c is not None:
                for p in ps:
                    if dist(c, p) < 1e-10:
                        break
                else:
                    ps.append(c)
        ls.append(e)
        ans += len(ps)+1
    print ans

Measured memory_bytes: 6544