akhauriyash/Code-Regression huggingface dataset:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
n,m=map(int,input().split())
N=cmb(n,2)
M=cmb(m,2)
if n == 0:
    print(M)
    exit()
elif m == 0:
    print(N)
    exit()
if n == 1 and m != 1:
    print(M)
elif m == 1 and n != 1:
    print(N)
elif m == 1 and n == 1:
    print(0)
else:
    print(cmb(n,2)+cmb(m,2))

Measured memory_bytes: 3188
import itertools


def calc(colo, target, d_mtx):
    ret = 0
    for i, item in enumerate(colo):
        ret += item * d_mtx[i][target]
    return ret


n, c = map(int, input().split())
d_mtx = []
c_mtx = []

for i in range(c):
    d_mtx.append(list(map(int, input().split())))

for i in range(n):
    c_mtx.append(list(map(int, input().split())))

color = [[0] * c for _ in range(3)]

for i in range(n):
    for j in range(n):
        color[((i+1)+(j+1)) % 3][c_mtx[i][j]-1] += 1

ret = 10 ** 10
for item in itertools.permutations(range(c), 3):
    tmp = 0
    for i in range(3):
        tmp += calc(color[i], item[i], d_mtx)
    ret = min(ret, tmp)

print(ret)


Measured memory_bytes: 5620
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int ctr[N];
bool ans[N];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		ctr[i] = 1;
	}
	ans[1] = true;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		cin >> x >> y;
		if (ans[x]) {
			ans[y] = true;
		}
		if (ctr[x] == 1) {
			ans[x] = false;
		}
		--ctr[x];
		++ctr[y];
	}
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		if (ans[i]) {
			++res;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 768
n,m = map(int,input().split())
mn = 0
mx = 10**5
for i in range(m):
    l,r = map(int,input().split())
    if mn < l:
        mn = l
    if mx > r:
        mx = r
if mn <= mx:
    print(mx-mn+1)
else:
    print(0)

Measured memory_bytes: 43496
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin >> n >> k >> s;
    rep(i,n){
        if(i == k-1) cout << char(s[i] + ('a' - 'A'));
        else cout << s[i];
    }   
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
ll qpow(ll a,int b) {
	ll ans=1;
	while(b) {
		if(b&1) ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	ll m,n;
	cin>>m>>n;
	cout<<qpow(m,n)<<'\n';
	return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>

int main(){
  int count, input;
  long long min=1000001, max=-1000001, sum=0;
  scanf("%d", &count);
  for(int i=0;i<count;i++){
    scanf("%d", &input);
    if(input<min) min = input;
    if(input>max) max = input;
    sum += input;
  }
  printf("%lld %lld %lld\n", min, max, sum);
  return 0;
}

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

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)){
    cout << 'A' << endl;
  }else{
    cout << 'B' << endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, x, A[100];
    cin >> N >> x;
    REP(i, N) cin >> A[i];
    sort(A, A + N);
    int ans = 0, i = 0;
    while (i < N - 1 && x - A[i] >= 0) {
        x -= A[i];
        ans++;
        i++;
    }
    if (x == A[i]) ans++;
    cout << ans << endl;
    return 0;
}

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

// vector <int> h;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	int O = 0, E = 0;
	for (int i = 0; i < s.size(); i++){
		if (i % 2 == 1)
			O += s[i] - '0';
		else
			E += s[i] - '0';
	}
	cout << min(O + (n / 2 + n % 2) - E, E + n / 2 - O);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=666;
ll a[N],base[N];
int n,_;
char s[N];
bool solve() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",a+i);
	scanf("%s",s+1);
	rep(i,0,60) base[i]=0;
	bool valid=1;
	per(i,1,n+1) {
		ll x=a[i];
		if (s[i]=='1') {
			per(j,0,60) {
				if ((x&(1ll<<j))&&base[j]==0) {
					return 0;
				}
				x=min(x,x^base[j]);
			}
		} else {
			per(j,0,60) {
				if ((x&(1ll<<j))&&base[j]==0) {
					base[j]=x;
					break;
				}
				x=min(x,x^base[j]);
			}
		}
	}
	return 1;
}

int main() {
	for (scanf("%d",&_);_;_--) {
		puts(solve()?"0":"1");
	}
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n){
		cin >> a[i];
	}
	sort(all(a), greater<ll>());

	Vec ans;
	rep(i, n-1){
		if(a[i] == a[i+1]){
			ans.pb(a[i]);
			i++;
		}
		if(ans.size() == 2) break;
	}

	if(ans.size() == 2){
		co(ans[0]*ans[1]);
	}else co(0);

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int bfs( P t_pos, P k_pos );

queue< pair< pair< P, P >, int > > q;
int mp[100][100];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while( true ) {
        int h, w;
        cin >> w >> h;
        if( h == 0 && w == 0 ) break;
        P t, k;
        cin >> t.S >> t.F >> k.S >> k.F;
        for( int i = 0; i < 55; ++i ) {
            for( int j = 0; j < 55; ++j ) mp[i][j] = 1;

        }

        for( int i = 1; i <= h; ++i ) {
            for( int j = 1; j <= w; ++j ) {
                cin >> mp[i][j];

            }
        }

        int res = bfs( t, k );
        if( res == -1 ) cout << "NA";
        else cout << res;
        cout << endl;

    }
    return 0;
}


int bfs( P t_pos, P k_pos ) {

    map< pair< P, P >, int > visit;
    visit[MP( t_pos, k_pos )] = 1;
    while( !q.empty() ) q.pop();

    q.push( MP( MP( t_pos, k_pos ), 0 ) );

    while( !q.empty() ) {
        pair< pair< P, P >, int > p = q.front();
        q.pop();
        if( p.F.F.F == p.F.S.F && p.F.F.S == p.F.S.S ) return p.S;
        if( p.S == 100 ) continue;

        for( int i = 0; i < 4; ++i ) {
            P t_pos = p.F.F;
            P k_pos = p.F.S;
            bool flg = false;
            if( mp[t_pos.F + dx[i]][t_pos.S + dy[i]] == 0 ) {
                t_pos.F += dx[i]; t_pos.S += dy[i];
                flg = true;

            }

            if( mp[k_pos.F - dx[i]][k_pos.S - dy[i]] == 0 ) {
                k_pos.F -= dx[i]; k_pos.S -= dy[i];
                flg = true;

            }
            
            if( visit[MP( t_pos, k_pos )] == 1 ) continue;
            if( t_pos.F == k_pos.F && t_pos.S == k_pos.S ) {
                return p.S + 1;

            }
            if( flg ) {
                visit[MP( t_pos, k_pos )] = 1;
                q.push( MP( MP( t_pos, k_pos ), p.S + 1 ) );

            }
        }
    }

    return -1;
}



Measured memory_bytes: 14204
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long W=sc.nextLong();

		if(A%W==0 && B%W==0) {
			System.out.println(B/W-A/W+1);
		}

		else if(A%W==0 && B%W!=0) {
			System.out.println(B/W-A/W+1);
		}

		else if(A%W!=0 && B%W==0) {
			System.out.println(B/W-A/W);
		}
		else {
			System.out.println(B/W-A/W);
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main(){
    long N;
    std::cin >> N;
    long result=0;
    for(long i=1; i<=N-1; i++){
        result+=(N-1)/i;
    }
    std::cout << result << std::endl;
    return 0;
}

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

typedef pair<long long, long long> ll;

vector<int> AdjList[105];

int depth[105];
int p[105];
bool visited[105];

int maxChildren[105];

// Edge X-Y is forbidden
void dfs(int u, int p2, int d, int X = -1, int Y = -1){
    if(visited[u]){return;}
    visited[u] = true;
    p[u] = p2;
    int children = 0;
    for(int v: AdjList[u]){
        if(!visited[v] && !(u == X && v == Y) && !(u == Y && v == X)){
            children ++;
            dfs(v, u, d+1, X, Y);
        }
    }
    maxChildren[d] = max(maxChildren[d], children);
}

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

    for(int i = 1; i < N; i ++){
        int x, y;
        scanf("%d%d", &x, &y);
        AdjList[x].push_back(y);
        AdjList[y].push_back(x);
    }

    ll ans = ll(N+2, 1);
    for(int i = 1; i <= N; i ++){
        memset(p, -1, sizeof(p));
        memset(maxChildren, 0, sizeof(maxChildren));
        memset(visited, false, sizeof(visited));

        //printf("i=%d\n", i);

        dfs(i, -1, 1, -1, -1);

        long long temp = 1;
        int maxDepth = 0;
        for(int d = 1; d <= N; d ++){
            if(maxChildren[d] == 0){
                maxDepth = d;
                break;
            }else{
                temp = temp*maxChildren[d];
            }
        }

        //printf("%d ll(%d, %lld)\n", i, maxDepth, temp);

        ans = min(ans, ll(maxDepth, temp));
    }

    for(int u = 1; u <= N; u ++){
        for(int v: AdjList[u]){
            AdjList[0].push_back(u);
            AdjList[0].push_back(v);

            memset(p, -1, sizeof(p));
            memset(maxChildren, 0, sizeof(maxChildren));
            memset(visited, false, sizeof(visited));

            dfs(0, -1, 0, u, v);

            AdjList[0].clear();

            long long temp = 1;
            int maxDepth = 0;
            for(int d = 0; d <= N; d ++){
                if(maxChildren[d] == 0){
                    maxDepth = d;
                    break;
                }else{
                    temp = temp*maxChildren[d];
                }
            }

            ans = min(ans, ll(maxDepth, temp));
        }
    }

    printf("%lld %lld", ans.first, ans.second);

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int N, K, Q;
int c[100000] = {};

signed main() {
	cin >> N >> K >> Q;
	rep(i, Q) {
		int A;
		cin >> A;
		c[A - 1]++;
	}
	rep(i, N) {
		c[i] += K;
		c[i] -= Q;
		if (c[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

bool isPrime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll L;
  cin >> L;

  cout << ((double)L / 3) * ((double)L / 3) * ((double)L / 3) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

ans=0

for i in range(1,n):
  count = 0
  memo={}
  for j in range(i):
    if s[0:i][j] not in memo:
      if s[0:i][j] in s[i:n]:
        count += 1 
        memo[s[0:i][j]] = 1
  ans = max(count,ans)
  
print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  vector<long long> b(N+1);
  b.at(0)=0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    b.at(i+1)=b.at(i)+a.at(i);
  }
  long long ans=1000000000;
  ans=ans*200001;
  for(int i=1; i<N; i++){
    ans = min(ans, abs(b.at(N)-b.at(i)*2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
use std::io;
use std::i64;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main()
{
    // input
    let a = read::<i64>();



    // output
    println!("{0}", a + a*a+ a*a*a);
}

Measured memory_bytes: 2116
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/


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

	int ans = 0;
	int d1, d2;

	for (int i = 1; i <= M; i++)
	{
		for (int j = 10; j <= D; j++)
		{
			d1 = j / 10;
			d2 = j % 10;

			if (d1 >= 2 && d2 >= 2 && d1*d2 == i)
			{
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = [int(i) if int(i)%2==0 else 1 for i in input().split()]

count = 0
while(not(1 in A)):
    A = [i/2 if (i/2)%2==0 else 1 for i in A]
    count += 1
    
print(count)

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){ if(n>0) initialize(n); }
    void initialize(int n){
        par.resize(n);
        sz.assign(n, 1);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

int main(){
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    while(M--){
        int a, b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }

    int ans = 1;
    for(int i=0; i<N; i++) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
  string s;
  cin >> s;
  if(s == "SUN")
  {
    cout << 7 << endl;
  }else if(s == "MON")
  {
    cout << 6 << endl;
  }else if(s == "TUE")
  {
    cout << 5 << endl;
  }else if(s == "WED")
  {
    cout << 4 << endl;
  }else if(s == "THU")
  {
    cout << 3 << endl;
  }else if(s == "FRI")
  {
    cout << 2 << endl;
  }else if(s == "SAT")
  {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    array<long long int, 1001> a;

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


    long long int ans = 0;
    long long int cmp = (1LL << 50);

    while (cmp) {
        int cnt = 0;

        for (int i = 0; i < N; ++i) {
            long long int acc = 0;
            for (int j = i; j < N; ++j) {
                acc += a[j];
                if ((acc & (ans | cmp)) == (ans | cmp)) {
                    ++cnt;
                }
            }
        }

        if (cnt >= K) {
            ans |= cmp;
        }
        cmp >>= 1;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll A[3][3];
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    ll N;
    cin >> N;
    rep(i, N){
        ll b;
        cin >> b;
        rep(j, 3) rep(k, 3) if (A[j][k] == b) A[j][k] = 0;
    }

    bool flag = false;

    rep(i, 3){
        bool f2 = true;
        rep(j, 3) if (A[i][j] != 0) f2 = false;
        flag = flag || f2;
    }

    rep(j, 3){
        bool f2 = true;
        rep(i, 3) if (A[i][j] != 0) f2 = false;
        flag = flag || f2;
    }

    if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) flag = true;
    if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) flag = true;

    if(flag) print("Yes");
    else    print("No");

    return 0;
}

Measured memory_bytes: 256
# |-| | | | |
# のように一番左の一本が決まったとき、残りの
#     | | | |
# には、線を引く場所が3つある
# 線を引く場所がN個あるときの線の引き方の組み合わせは
# A[1] = 2, A[2] = 3, A[N] = A[N - 2] + A[N - 1]
# のほぼフィボナッチ数列
# 2,3,5,8,13...
# これをあらかじめ最大数ぶん求めておく
# 横棒W本に対して、W - 1個の間隔があり、そのうち端の2か所が埋まった状態が最大なのでW - 3
# これを求める

import sys
readline = sys.stdin.readline

DIV = 10 ** 9 + 7
H,W,K = map(int,readline().split())

P = [0] * max(W - 2 + 1,3)
P[1],P[2] = 2,3
for i in range(3, len(P)):
  P[i] = P[i - 1] + P[i - 2]
  
# [0, 2, 3, 5, 8, 13, 21, 34, ...]

# 通らない線は上記で算出できるので、通る線を考える
# 上からi段目まで終えた時点で、縦棒jにいるときの場合の数でDPする

dp = [[0 for j in range(W)] for i in range(H + 1)]

dp[0][0] = 1 # 上から0段目を終えた時点(まだ何もしていない)ときに0にいるので1通り

def calc(L,R): # LとRの間に線を引いた場合の、残りの線の引き方
  res = 1
  if 1 < L:
    # | | |-| Lが2のときはじめてスペースが1 (L - 1)できる
    res *= P[L - 1]
    res %= DIV
  if (W - 1) - (R + 1) >= 1:
    # |-| | | R + 2 = W - 1のときはじめてスペースが1(W - R)できる
    res *= P[(W - 1) - (R + 1)]
    res %= DIV
  return res
  
# 右に移動する、左に移動する、何もしない、の3通りでDP
for i in range(H):
  for j in range(W):
    # 右に移動する
    if j + 1 < W:
      dp[i + 1][j + 1] += dp[i][j] * calc(j, j + 1)
      dp[i + 1][j + 1] %= DIV
    # 左に移動する
    if j - 1 >= 0:
      dp[i + 1][j - 1] += dp[i][j] * calc(j - 1,j)
      dp[i + 1][j - 1] %= DIV
    # 何もしない
    dp[i + 1][j] += dp[i][j] * calc(j,j) # 左端も右端も同じ
    dp[i + 1][j] % DIV
    
# i = H段目まで終えた時点で、j = K - 1にいる場合の数
print(dp[H][K - 1] % DIV)

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


int main(){
    string S;
    cin >> S;
    vector<ll> cnt(26,0);
    for(int i = 0; i < S.size(); i++){
        cnt[abs(int(S[i] - 'a'))]++;
    }

    for(int i = 0; i < 26; i++){
        if(cnt[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int a;
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)
    cin>>b[i];
  sort(b.begin(),b.end());
  cout<<b[a-1]-b[0]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back
const long long INF = 1LL << 60;


int main() {
  ll N, k = 1, money=0;
  cin >> N;
  vector<ll> m;
  m.push_back(1);
  while(money <= 100000){
    money = pow(6, k);
    m.push_back(money);
    k++;
  }
  k = 1;
  money=0;
  while(money <= 100000){
    money = pow(9, k);
    m.push_back(money);
    k++;
  }
  sort(m.begin(), m.end());


  vector<ll> dp(100001, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < m.size(); j++){ // とりあえずKまで代入しちゃう
      int h = i + m[j]; // 今の所持金
      if (h > 100000) continue;
      dp[h] = min(dp[h], dp[i] + 1);
    }
  }

  
  cout << dp[N] << endl;

}


Measured memory_bytes: 1024
X,Y = map(int,input().split())

def pay(n):
  if n==1:
    return 300000
  elif n==2:
    return 200000
  elif n==3:
    return 100000
  else:
    return 0
if X == Y == 1:
  print(300000+300000+400000)
else:
  print(pay(X)+pay(Y))

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

namespace C
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var an = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var dict = new Dictionary<int, int>(n);
			foreach (var a in an)
			{
				if (dict.ContainsKey(a)) { dict[a]++; }
				else { dict.Add(a, 1); }
			}

			var result = 0;
			foreach (var d in dict)
			{
				if (d.Key > d.Value) { result += d.Value; }
				else { result += d.Value - d.Key; }
			}

			Console.WriteLine(result);
		}
	}
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	
	string str;
	cin >> str;
	
	int ans = 100000;
	for(int i = 0;i < str.size()-2;i++){
		int tmp = 100 * (str[i] - '0') + 10 * (str[i+1] - '0') + (str[i+2] - '0');
		ans = min(ans,abs(753 - tmp));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int pt0=0, pt1=0;
    int i;
    for(i=0; i<n; i++) {
        char str0[105]={0}, str1[105]={0};
        scanf("%s%s", str0, str1);
        if(strcmp(str0,str1)>0) {
            pt0+=3;
        }
        else if(strcmp(str0,str1)<0) {
            pt1+=3;
        }
        else {
            pt0++; pt1++;
        }
    }
    printf("%d %d\n", pt0, pt1);

    return 0;
}



Measured memory_bytes: 2820
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
ans = 0

for i in range(1,N+1,2):
    if len(make_divisors(i)) == 8:
        # print(make_divisors(i))
        ans += 1

print(ans)

Measured memory_bytes: 3188
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
		Console.WriteLine(Math.Min(input[2], input[0] * input[1]));
	}
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
    getline(cin,s1);
    s2=s1;
    reverse(s2.begin(),s2.end());
    for(int i=0;i<s2.size();++i)
        s2[i]=='b'?s2[i]='d':s2[i]=='d'?s2[i]='b':s2[i]=='p'?s2[i]='q':s2[i]='p';
    if(s1==s2)  puts("Yes");
    else    puts("No");
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

inline void Solve () {
	//easy
	int a, b;
	cin >> a >> b;

	cout << abs(1ll * (a - 2) * (b - 2));
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 256
while True:
	n,x = map(int,input().split())
	
	if n==0 and x==0:
		break
		
	lst=list(range(1,n+1))
	count=0
	for i in range(n-2):
		
		for j in range(i+1,n-1):
			
			for k in range(j+1,n):
				
				if x==lst[i]+lst[j]+lst[k]:
					count += 1
	print(count)
	




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

def dog(n, b):
    arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y","z"]
   
    
    if (int(n/b)):
        return dog(int(n/b)-1, b) + str(arr[n%b])
    
    return str(arr[n%b])

print(dog(N-1,26))

Measured memory_bytes: 9108
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

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

	vector<int> problems;
	for (size_t i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		problems.push_back(tmp);
	}
	sort(begin(problems), end(problems));
	
	int cnt = 0;
	for (int k = 1; k < 1e5 + 1; ++k) {
		decltype(problems)::iterator ubit = lower_bound(begin(problems), end(problems), k);
		size_t ubid = distance(begin(problems), ubit);
		if (problems.size() - ubid == n/2) {
			cnt += 1;
		}
	}

	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 892
K, N = map(int, input().split())
house = list(map(int,input().split()))
house = house + house
min = house[N - 1] - house[0]

for i in range(N - 1):
  if K - (house[N + 1 + i] - house[i]) < min and house[N + 1 + i] - house[i] <= K/2 :
    min = K - (house[N + 1 + i] - house[i])

print(int(min))

Measured memory_bytes: 26444
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        long ret = 0;

        if (A[0] > 0) {
            System.out.println(-1);
            return;
        }

        int prevA = 0;
        for (int i = 1; i < N; i++) {
            if (A[i] > prevA + 1) {
                System.out.println(-1);
                return;
            } else if (A[i] == prevA + 1) {
                ret++;
            } else {
                ret += A[i];
            }

            prevA = A[i];
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 88640
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,int b)
{a-=b;return a<0?a+MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
inline void Add(int &a,int b)
{a+=b;a>=MOD?a-=MOD:1;}
const int Q=404;
int C[Q][Q],f[Q][Q][Q][2],h[Q],bok[Q][Q];
int iid[Q][Q],maxn=0,owo[Q][2],p2[Q];
void G(int l,int r,int lim)
{
    int id=iid[l][r];
    if(!id)id=iid[l][r]=++maxn;
    if(bok[id][lim])return;
    bok[id][lim]=1;
    for(int ii=l;ii<=r;ii++)
        if(h[ii]<lim){
            vector<pair<int,int>> rem;
            int now=r-l+1;
            for(int jj=l,k;jj<=r;jj=k)
                if(h[jj]>=lim){
                    for(k=jj+1;k<=r&&h[k]>=lim;k++);
                    G(jj,k-1,lim),rem.push_back(make_pair(jj,k-1));
                    now-=k-jj;
                }
                else k=jj+1;
            f[id][lim][now][0]=f[id][lim][0][1]=1;
            for(pair<int,int> o:rem){
                int nw=iid[o.first][o.second],len=o.second-o.first+1;
                for(int i=0;i<=now;i++)
                    for(int j=0;j<2;j++)
                        owo[i][j]=f[id][lim][i][j],f[id][lim][i][j]=0;
                for(int i=0;i<=now;i++)
                    for(int j=0;j<=len;j++)
                        for(int k=0;k<2;k++)
                            Add(f[id][lim][i+j][k],mul(owo[i][k],f[nw][lim][j][k]));
                now+=len;
            }
            return;
        }
    G(l,r,lim+1);
    int len=r-l+1;
    for(int i=0;i<=len;i++)
        for(int j=i;j<=len;j++) 
            Add(f[id][lim][j][0],mul(mul(p2[i]-(i==j),C[len-i][len-j]),f[id][lim+1][i][0])),
            Add(f[id][lim][j][1],mul(mul(p2[i]-(i==j),C[len-i][len-j]),f[id][lim+1][i][1]));
    for(int i=0;i<=len;i++)
        Add(f[id][lim][i][0],f[id][lim+1][i][1]),Add(f[id][lim][i][1],f[id][lim+1][i][1]);
}
int main()
{
    for(int i=0;i<Q;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=add(C[i-1][j-1],C[i-1][j]);
    }
    p2[0]=1;
    for(int i=1;i<Q;i++)
        p2[i]=add(p2[i-1],p2[i-1]);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&h[i]);
    G(1,n,1);
    printf("%d\n",f[iid[1][n]][1][n][0]);
    return 0;
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(n, 0));
    vector<int> p(m);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int a;
            cin >> a;
            a--;
            s[i][a] = 1;
        }
    }
    for (int i = 0; i < m; i++)
        cin >> p[i];
    int ret = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        bool f = true;
        for (int j = 0; j < m; j++)
        {
            int cnt = 0;
            for (int k = 0; k < n; k++)
            {
                if (s[j][k] && ((i >> k) & 1))
                    cnt++;
            }
            if (cnt % 2 == p[j])
                continue;
            f = false;
        }
        if (f)
            ret++;
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
A, B = list(map(int,input().split()))
def button(A, B):
  if A > B:
    result = A
    return([A - 1, B, result])
  elif A == B:
    result = A
    return([A - 1, B, result])
  else:
    result = B
    return([A, B - 1, result])
 
A, B, result_1 = button(A, B)
A, B, result_2 = button(A, B)
 
print(result_1 + result_2)

Measured memory_bytes: 3064
K = int(input())
A = list(map(int,input().split()))

if A[-1] != 2:
	print(-1)
	exit(0)

minval = 2
maxval = 3
for i in range(K-1,-1,-1):
	if maxval < A[i] or (minval > A[i] and ((maxval - (maxval % A[i]) < minval))):
		print(-1)
		exit(0)

	if minval > A[i]:
		if minval % A[i] != 0:
			minval = minval + (A[i] - (minval % A[i]))

		maxval = (maxval - (maxval % A[i]) + A[i] - 1)

	else:
		maxval = A[i] + (A[i] - 1)
		minval = A[i]
		

print(str(minval) + " " + str(maxval))


Measured memory_bytes: 14428
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a = -111, b = -111;
	//int m;
	//int k;
	string s;
	string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	//char a[1000000];
	//int a[100000];

	//int box[1000000000000000000];
	int box;
	//int box2;
	//int p[1111];

	//long double aaa;

	//int k, d;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	//int box[10000] = { 0 };

	//bool flag = true;
	bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	//cin >> n;
	//cin >> a >> b;
	cin >> s >> t;
	//for (int i = 0; i < n; i++)
	//{
	//	cin >> p[i];
	//}

	n = s.length();

	for (int i = 0; i < n; i++)
	{
		if (s[i] != t[i])
		{
			all++;
		}
	}

	//sort(p, p + n);
	//n = n - 'Z';

	/*if (n <= 26)
	{
		a[0] = 96 + n;
		cout << a[0] << "\n";
		return 0;
	}*/

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	cout << all << "\n";
	//cout << a << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	/*if (n == 0)
	{
		cout << x;
	}*/

	//cout << fixed << setprecision(111) << all;
}


Measured memory_bytes: 3916
// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++){
		sum+=(n/i);
		if(n%i==0){
			sum--;
		}
	}
	cout<<sum<<"\n";
	return 0;
	}
	
	
	
	
	



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2],fr[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;
  for(int i=1;i<=n;i++)cin>>aa[i],fr[aa[i]]++;

  sort(aa+1,aa+n+1);

  for(int i=1;i<=N;i++)
    fr[i]+=fr[i-1];

  long ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      int rt=aa[i]+aa[j]-1,lt=aa[j]-aa[i]+1;
      int ad=fr[rt];if(lt)ad-=fr[lt-1];

      if(aa[i]>=lt&&aa[i]<=rt)ad--;
      if(aa[j]>=lt&&aa[j]<=rt)ad--;

      ans+=ad;

      //cout<<i<<" "<<j<<" "<<fr[aa[i]+aa[j]-1]-2<<endl;
    }
  }
  cout<<ans/3<<endl;
  return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <bits/stdc++.h>
#define N 100015
using namespace std;
int n,u,v;
vector<int> e[N];
void dfs(int dep,int pre,int cur,int node[]){
    for(int i=0;i<e[cur].size();i++){
        if(node[e[cur][i]]==0&&e[cur][i]!=pre){
            node[e[cur][i]] = dep+1;
            dfs(dep+1,cur,e[cur][i],node);
        }
    }
}
int main(void){
    cin >> n >> u >> v;
    for(int i=1;i<n;i++){
        int a,b; cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int u_dist[N]={0},v_dist[N]={0};
    u_dist[u] = 0; dfs(0,u,u,u_dist);
    v_dist[v] = 0; dfs(0,v,v,v_dist);
    /*for(int i=1;i<=n;i++){
        printf("%d %d\n",u_dist[i],v_dist[i]);
    }*/
     int ma = -1;
    for(int i=1;i<=n;i++){
        if(u_dist[i]<v_dist[i]){
            ma = max(ma,v_dist[i]-1);
        }
    }
    cout << ma << endl;
}


Measured memory_bytes: 12928
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define maxx 2000000000
using namespace std;
int n,x,now,cnt;
map<int,int>mp;
int main()
{
  scanf("%d",&n);
  now=1;
  for (int i=1;i<=n;i++)
  {
  	scanf("%d",&x);
  	if (x<now) printf("No\n");
  	else
  	{ 
  	  printf("Yes\n");
  	  while ((mp[x]>0)&&(x>0))
  	  {
  	    mp[x]=0;
  	    cnt--;
  	    x--;
	  }
	  mp[x]=1; cnt++;
	  while ((mp[now]>0)&&(now<=n)) now++;
	  now=min(cnt,now);
	  if (x==0) now=maxx;
    }
  }
  return 0;
}

Measured memory_bytes: 14888
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
Count = [0 for i in range(10 ** 5 + 1)]
tmp = sum(A)

for i in range(Q):
    b, c = map(int, input().split())
    B.append(b), C.append(c)

for i in A:
    Count[i] += 1

for i in range(Q):
    tmp -= Count[B[i]] * B[i]
    tmp += Count[B[i]] * C[i]
    Count[C[i]] += Count[B[i]]
    Count[B[i]] = 0
    print(tmp)


Measured memory_bytes: 23400
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 200005;
string s;
vi v[26];
bool used[N];

class BinaryIndexTree {
  vector<int > BIT;
  int sz;

public:

  BinaryIndexTree(int _sz) {
    sz = _sz;
    BIT.resize(_sz+1, 0);
  }

  void update(int idx, int val) {
    for(int i = idx; i < sz; i += i & -i) {
      BIT[i] += val;
    }
  }

  int query(int idx) {
    int res = 0;
    for(int i = idx; i; i -= i & -i) {
      res += BIT[i];
    }
    return res;
  }

};

BinaryIndexTree bit(N);
int cnt[26];

int main() {
  cin >> s;
  int n = s.size();
  rep(i,0,n) {
    int x = s[i] - 'a';
    v[x].pb(i + 1);
    cnt[x]++;
  }
  int tmp = 0;
  rep(i,0,26) {
    tmp += (v[i].size()) & 1;
  }
  if(tmp > 1) {
    P(-1);
    return 0;
  }
  int a = -1;
  if(tmp == 1) {
    rep(i,0,26) if(v[i].size() & 1) {
      a = i;
    }
  }

  LL ans = 0;
  int rem = n;
  rep(i,0,s.size()) if(!used[i] && rem > 1) {
    int x = s[i] - 'a';
    if(x == a && cnt[x] == 1) {
      a = -2;
      rem--;
      continue;
    }
    cnt[x] -= 2;
    rem -= 2;
    int y = v[x].back();
    v[x].pop_back();

    used[y - 1] = true;
    ans += n - y - (bit.query(n) - bit.query(y)) + (a == -2);
    bit.update(y, 1);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 2684
public class Main{
  public static void main(String[] args){
    int num = new java.util.Scanner(System.in).nextInt();
    int hundredth = num/100;
    int tenth = (num-hundredth*100)/10;
    int oneth = (num-hundredth*100-tenth*10);

    if (hundredth == oneth){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
A = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
    A[i] = list(map(int, input().split()))

N = int(input())
judge = [0 for i in range(9)]
ans = 'No'

for i in range(N):
    b = int(input())
    
    for row in range(3):
        if (b in A[row]):
            index_r = A[row].index(b)
            index = 3 * row + index_r
            judge[index] += 1

for i in range(3):
    summ1 = sum(judge[i::3])
    summ2 = sum(judge[3 * i : 3 * i + 3])
    
    if (summ1 == 3 or summ2 == 3):
        ans = 'Yes'

summ3 = sum(judge[0::4])
summ4 = sum(judge[2:7:2])

if (summ3 == 3 or summ4 == 3):
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
    long long int n, a[100009], sm[100009];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sm[0] = a[0];
    for(int i=1;i<n;i++){
        sm[i] = sm[i-1]+a[i];
    }
    long long lsm = 0, cnta=0, cntb=0;
    for(int i=0;i<n;i++){
        if((i&1)==1){
            if(lsm+sm[i]<1){
                cnta+=1-lsm-sm[i];
                lsm+=1-lsm-sm[i];
            }
        }
        else{
            if(lsm+sm[i]>-1){
                cnta+=lsm+sm[i]+1;
                lsm-=lsm+sm[i]+1;
            }
        }
    }
    lsm=0;
    for(int i=0;i<n;i++){
        if((i&1)==0){ 
            if(lsm+sm[i]<1){
                cntb+=1-lsm-sm[i];
                lsm+=1-lsm-sm[i];
            }
        }
        else{
            if(lsm+sm[i]>-1){
                cntb+=lsm+sm[i]+1;
                lsm-=lsm+sm[i]+1;
            }
        }
    }
    cout << min(cnta, cntb) << endl;
}

Measured memory_bytes: 1792