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

typedef long long ll;

int n;
pair<int,int> p[100010];
set<int> st;
ll ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i].first;
        p[i].second = i;
    }
    
    sort(p,p+n);
    reverse(p,p+n);
    st.insert(-1);
    st.insert(n);

    for (int i = 0; i < n; i++) {
        st.insert(p[i].second);
        auto now = st.find(p[i].second);
        auto left = now;
        left--;
        auto right = now;
        right++;

        ll here = *now;
        ll l1 = *left;
        ll r0 = *right;

        ll l0,r1;

        if (l1 != -1) {
            left--;
            l0 = *left;
            
            ans += p[i].first * (l1 - l0) * (r0 - here);
        }
        if (r0 != n) {
            right++;
            r1 = *right;

            ans += p[i].first * (here - l1) * (r1 - r0);
        }
    }

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


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

int main(){
	
	string s; cin >> s;
	
	rep(i,s.size())
	{
		if(s[i]==',')cout << " ";
		else cout << s[i];
	}
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 101

void DFS(int);

int n,G[N][N],dfs[N],d[N],f[N],count=1;

int main() {
  int i,j,t,k,x;
  
  scanf("%d",&n);
  
  dfs[0] = 0;
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++) {
      G[i][j] = 0;
    }
  }
  
  for(i = 0 ; i < n ; i++) {
    scanf("%d%d",&t,&k);
    t--;
    for(j = 0 ; j < k ; j++) {
      scanf("%d",&x);
      x--;
      G[t][x] = 1;
    }
  }
  
  for(i = 0 ; i < n ; i++) {
    if(dfs[i] == 0) {
      DFS(i);
    }
  }
  
  for(i = 0 ; i < n ; i++) {
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void DFS(int x) {
  int y;
  
  d[x] = count++;
  dfs[x] = 1;
  for(y = 0 ; y < n ; y++) {
    if(G[x][y] == 1 && dfs[y] == 0) {
      DFS(y);
    }
  }
  f[x] = count++;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
typedef long long LL;
void work() {
}
int main() {
    LL q, h, s, d;
    scanf("%lld%lld%lld%lld", &q, &h, &s, &d);
    if (q * 4 < s) s = q * 4;
    if (h * 2 < s) s = h * 2;
    if (q * 8 < d) d = q * 8;
    if (h * 4 < d) d = h * 4;
    LL ans, n;
    scanf("%lld", &n);
    if (d > 2 * s) {
        ans = n * s;
    }
    else {
        ans = n / 2 * d + n % 2 * s;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        cc = x - i * 500 - j * 100

        if cc % 50 == 0 and 0 <= cc // 50 <= c:
            cnt += 1

print(cnt)


Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
int a[100005];
map<int,int>maps;
map<int,int>::iterator it;
int n,m;
int ac=0,wa=0;
int main(){
    cin>>n>>m;
    int num;
    string vis;
    for(int i=1;i<=m;i++){
        cin>>num>>vis;
        if(maps[num]==-1) continue;
        if(vis=="AC") {
            wa+=maps[num];
            ac+=1;
            maps[num]=-1;
            continue;
        }
        maps[num]++;
    }
    maps.clear();
    cout<<ac<<' '<<wa<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;

int main(){
  lli x;
  cin >> x;
  lli ans = x / 11 * 2;
  x %= 11;
  if (x != 0) ans++;
  if (x > 6) ans++;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  int cnt = 0;
  cin >> s >> t;
  for(int i = 0, j = 0; i < s.length() && j < t.length(); i++, j++)
  {
    if(s[i] != t[j])
      cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105],n;
int main(){
  cin>>n;
  for(int i=1;i<n;i++)cin>>b[i];
  a[1]=b[1];b[n]=b[n-1];
  for(int i=2;i<=n;i++)a[i]=min(b[i],b[i-1]);
  int ans=0;
  for(int i=1;i<=n;i++)ans+=a[i];
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

int main() {

  int a, b, c;
  cin >> a >> b >> c;

  int n = a-b;

  if(c-n<0) cout << 0 << endl;
  else cout << c-n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <complex>
#include <functional>
#include <bitset>
#include <map>
#include <random>
#include <memory>
#include <map>
#include <valarray>
#include <iomanip>
#include <queue>

#include <cassert>
#include <ctime>
#include <cmath>
#include <cstdlib>

using namespace std;

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

int C (int n, int k)
{
    static vector<vector<int>> dp (4001, vector<int> (2001, -1));

    if (n - k < k)
        return C (n, n - k);

    if (k <= 0)
        return k == 0 ? 1 : 0;

    if (dp[n][k] == -1)
        dp[n][k] = (C (n - 1, k - 1) + C (n - 1, k)) % inf;

    return dp[n][k];
}

template<class T>
T sqr (T x)
{
    return x * x;
}

int powmod (int x, int y)
{
    return y ? (y & 1 ? x * (long long)powmod (x, y - 1) :
                sqr ((long long)powmod (x, y >> 1))) % inf : 1;
}

int H (int a, int b)
{
    static vector<vector<int>> dp (2001, vector<int> (2001, -1));

    if (a < 0 || b < 0)
        return 0;

    if (b == 0 || a == 0)
        return 1;

    if (dp[a][b] == -1)
    {
        dp[a][b] = H (a, b - 1) + H (a - 1, b - 1);
        dp[a][b] %= inf;
    }

    return dp[a][b];
}

int F (int a, int b)
{
    static vector<vector<int>> dp (2001, vector<int> (2001, -1));

    if (a < 0 || b < 0)
        return 0;

    if (b == 0 || a == 0)
        return 1;

    if (dp[a][b] == -1)
    {
        dp[a][b] = 0;

        dp[a][b] = F (a - 1, b);

        int tb = b - 1;

        if (a >= tb)
        {
            dp[a][b] += powmod (2, b - 1);
            dp[a][b] %= inf;
        }
        else
        {
            dp[a][b] += H (a, b - 1);
            dp[a][b] %= inf;
            //for (int l = 0; l <= a; l++)
            //{
            //    dp[a][b] += C (b - 1, l);
            //    dp[a][b] %= inf;
            //}
        }
    }

    return dp[a][b];
}

int G (int a, int b)
{
    int ans = 0;

    for (int k = 0; k <= a; k++)
        for (int l = 0; l <= min (a, b - 1); l++)
            ans = (ans + C (b - 1, l) * (long long)F (a - k - l, l)) % inf;

    return ans;
}

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

    //int n;

    //cin >> n;

    //string s;

    //cin >> s;

    //vector<vector<int>> blocks (1);

    //int zer = 2;

    //for (int i = s.find ('1'); i < blocks.size (); i++)
    //{
    //    if (s[i] == '1')
    //    {
    //        if (zer > 1)
    //            blocks.push_back (vector<int> (1, 1));
    //        else if (zer == 1)
    //            blocks.back ().push_back (1);
    //        else
    //            blocks.back ().back ()++;

    //        zer = 0;
    //    }
    //    else
    //        zer++;
    //}

    //int ans;

    //for (const auto &row : blocks)
    //{
    //    for ()
    //}

    int a, b;

    cin >> a >> b;

    //for (int i = 0; i < 1001; i++)
    //    for (int j = 0; j < 1001; j++)
    //        F (i, j);

    //cout << clock () << endl;

    cout << G (a, b) << endl;

    return 0;
}


Measured memory_bytes: 65280
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

ll dp1[1<<15][15], dp2[1<<15][15], ans[16];
int X[15],Y[15], P[15], N;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

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

 cin >> N;
 rep(i, N) cin>>X[i]>>Y[i]>>P[i];
 rep(i, 1<<N) {
   rep(j, N) {
     ll ans = 1e15;
     ll ans2 = 1e15;
     rep(k, N) {
       if(i & (1<<k)) {
         ans = min(ans, abs(X[j]-X[k])*1LL*P[j]);
         ans2 = min(ans2, abs(Y[j]-Y[k])*1LL*P[j]);
       }
     }
     dp1[i][j] = min(ans, abs(X[j])*1LL*P[j]);
     dp2[i][j] = min(ans2, abs(Y[j])*1LL*P[j]);
   }
 }

 rep(i,N+1)ans[i]=1e15;
 rep(i, 1<<N) {
   int cnt = 0, ii = i;
   while (ii != 0) {cnt += (ii & 1);ii>>=1;}
   for(int j = i;j >= 0;j--) {
     j = j & i;
     ll ans1 = 0;
     rep(k, N) {
       ans1 += min(dp1[i^j][k], dp2[j][k]);
     }
     ans[cnt] = min(ans[cnt], ans1);
   }
 }

 rep(i,N+1) cout<<ans[i]<<endl;




 return 0;
}


Measured memory_bytes: 11332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int a[3][10],b[3][10],c[3][10],d[3][10],n;cin>>n;
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            a[i][j]=0;
            b[i][j]=0;
            c[i][j]=0;
            d[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        int j,f,k,e;cin>>j>>f>>k>>e;
        if(j==1) a[f-1][k-1]+=e;
        else if(j==2) b[f-1][k-1]+=e;
        else if(j==3) c[f-1][k-1]+=e;
        else d[f-1][k-1]+=e;
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<a[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<b[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<c[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<d[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n,k,sum=0;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(int i=0;i<k;i++)
sum+=a[i];
cout<<sum;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
	char c;
	int n;
	for(;;)
	{
		n=0;
		for(;~(c=getchar())&&c!=10;c>30?n+=(c-'0'):0);
		if(n==0)return 0;
		printf("%d\n",n);
	}
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
     const ll MAX_SIZE = 1000005;

    bool num[MAX_SIZE];
    for(int i = 0; i < MAX_SIZE; ++i)
    {
        num[i] = false;
    }

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        if(num[a[i]] == true)
        {
            continue;
        }

        // 重複がなければ
        if (!(i < n - 1 && a[i] == a[i + 1]))
        {
            ans++;
        }

        ll prime = 0;
        while(prime += a[i], prime < MAX_SIZE)
        {
            num[prime] = true;
        }
    }
    cout << ans; 
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

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

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int n, t;
priority_queue<int> que;

int main(){
	cin >> n >> t;
	int k;
	bool f = 0;
	REP(i, n){
		int a;
		cin >> a;
		if (i == 0)k = a;
		else{
			if (k > a){
				k = a;
				f = 1;
			}
			else{
				que.push(a - k);
			}
		}
	}
	int ans = 1;
	int p = -1;
	while (!que.empty()){
		if (p == -1){
			p = que.top();
		}
		else if (p != que.top()){
			break;
		}
		else ans++;
		que.pop();
	}
	cout << ans << endl;
}

//int n;
//map<string, int> msi;
//map<string, vector<string>> msvs;
//int m;
//string t;
//
//int main(){
//	cin >> n;
//	REP(i, n){
//		string s;
//		int p;
//		cin >> s >> p;
//		msi[s] = p;
//	}
//	cin >> m;
//	REP(i, m){
//		string o;
//		int k;
//		cin >> o >> k;
//		REP(j, k){
//			string q;
//			cin >> q;
//			msvs[o].push_back(q);
//		}
//	}
//	cin >> t;
//	cout << solve()
//}

Measured memory_bytes: 892
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const solve = memoization(function(i, m) {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  });

  arr2.map(m => solve(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();

function memoization(f) {
  let cache = {};
  function innerFunc(...param) {
    const c = cache[param];
    if (typeof c !== 'undefined') {return c;}
    return cache[param] = f(...param);
  }
  return innerFunc;
}



Measured memory_bytes: 24388
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        t1: i64, t2: i64,
        a1: i64, a2: i64,
        mut b1: i64, mut b2: i64,
    }
    b1 -= a1;
    b2 -= a2;
    if b1 < 0 {
        b1 = -b1;
        b2 = -b2;
    }
    let c = t1*b1+t2*b2;
    if c == 0 {
        println!("infinity");
        return;
    }
    if c > 0 {
        println!("0");
        return;
    }

    let d = b1 * t1;
    let mut res = d / c.abs() * 2;
    if d % c.abs() == 0 {
        res -= 1;
    }
    println!("{}", res + 1);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int total = 0;
  
  for (int i = 0; i < N; i++){
    int s,e;
    cin >> s >> e;
    //cout << s << " - " << e << endl;
    total += (e - s + 1);
  }
  
  cout << total << endl;
}

Measured memory_bytes: 256
def parent_id(id, H):
    if 1 <= id // 2 and id // 2 <= H:
        return id// 2
    return None

def left_id(id, H):
    if 1 <= id  *2 and id * 2 <= H:
        return id* 2
    return None

def right_id(id, H):
    if 1 <= (id * 2) + 1 and (id * 2) + 1 <= H:
        return (id * 2) + 1
    return None

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

T = [{} for _ in range(H)]

for i in range(H):
    T[i]["id"] = i + 1
    T[i]["key"] = A[i]
    T[i]["parent_id"] = parent_id(T[i]["id"], H)
    T[i]["left_id"] = left_id(T[i]["id"], H)
    T[i]["right_id"] = right_id(T[i]["id"], H)

for i in range(H):
    parent_str, left_str, right_str = "", "", ""
    node_str = "node {}: ".format(T[i]["id"])
    key_str = "key = {}, ".format(T[i]["key"])
    if T[i]["parent_id"] != None:
        parent_str = "parent key = {}, ".format(T[int(T[i]["parent_id"])-1]["key"])
    if T[i]["left_id"] != None:
        left_str = "left key = {}, ".format(T[int(T[i]["left_id"])-1]["key"])
    if T[i]["right_id"] != None:
        right_str = "right key = {}, ".format(T[int(T[i]["right_id"])-1]["key"])
    print(node_str + key_str + parent_str + left_str + right_str)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	int n;
	cin >> n;
	int ans = 0;
	int ea = 0;
	int sb = 0;
	int ba = 0;
	rep(i, n){
		string s;
		cin >> s;
		rep(j, s.size()-1){
			if(s.at(j) == 'A' && s.at(j+1) == 'B') ans++;
		}
		if(s.at(s.size()-1) == 'A' && s.at(0) == 'B') ba++;
		else if(s.at(s.size()-1) == 'A') ea++;
		else if(s.at(0) == 'B') sb++;
	}
	int mi = min(ea, sb);
	int ma = max(ea, sb);
	ans += mi;
	if(ma == 0 && ba != 0) ba--;
	ans += ba;
	cout << ans << endl;
	return 0;
}

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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

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

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int n;
	cin>>n;
	vector<int>a(n+1,0);
	for(int i =1;i<=n;i++){
		for(int j=0;j<=n;j+=i)
		a[j]++;
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
		ans+=(i*a[i]);
	cout<<ans<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


Measured memory_bytes: 81404
import collections

n = int(input())
a = [0]*n
count = 0
for i in range(n):
  a[i] = list(input())
  a[i].sort()
  d = ""
  for j in a[i]:
    d += j
  a[i] = d
c = collections.Counter(a)
for i in c.values():
  count += (i-1) * i // 2
print(count)

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if ((A==B && B!=C) || (B==C && C!=A) || (C==A && A!=B))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int tetr[200];
int dp1[1234567];
int dp2[1234567];
signed main() {
    REP(i,200) tetr[i]=(i+1)*(i+2)*(i+3)/6;
    REP(i,1000010) {
        dp1[i]=i;
        dp2[i]=i;
    }
    REP(i,200) {
        REP(j,1000010) {
            if(dp1[j]!=INF) {
                if(j+tetr[i]<=1000010) chmin(dp1[j+tetr[i]],dp1[j]+1);
            }
            if(tetr[i]%2==0) {
                continue;
            }
            if(dp2[j]!=INF) {
                if(j+tetr[i]<=1000010) chmin(dp2[j+tetr[i]],dp2[j]+1);
            }
        }
    }
    while(1) {
        int n;
        cin>>n;
        if(n==0) break;
        cout<<dp1[n]<<" "<<dp2[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 18732
// clang-format off
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <iomanip>
#include <queue>
#include <map>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
constexpr ll MOD = 1000000007;



int main()
{
    ll X;
    cin >>X;
    ll a =0;
    for(a = 1; ; a++){
        if(a *(a+1) >= 2*X){
            break;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
/*Code by Codercjh*/
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
int ans=1e9,n,m,x,a[15][15],nl[15];
void dfs(int step,int sum,int mn){
	if(sum>ans)return;
	if(mn>=x)return ans=sum,void();
	if(step>n)return;
	dfs(step+1,sum,mn);
	mn=1e9;
	fr(j,1,m)nl[j]+=a[step][j],mn=min(mn,nl[j]);
	dfs(step+1,sum+a[step][0],mn);
	fr(j,1,m)nl[j]-=a[step][j];
}
int main(){
    read(n),read(m),read(x);
    fr(i,1,n)fr(j,0,m)read(a[i][j]);
    dfs(1,0,0);
    cout<<(ans==1e9?-1:ans);
	return 0;
}


Measured memory_bytes: 3652
N = int(input())
count_dict = {}
add_dict = {}
for _ in range(N):
    s = "".join(sorted(list(input())))
    if s in count_dict:
        count_dict[s] += add_dict[s]
        add_dict[s] += 1
    else:
        count_dict[s] = 0
        add_dict[s] = 1

print(sum(count_dict.values()))

Measured memory_bytes: 24256
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

typedef long long int ll;
typedef pair<ll, ll> ii;



int main(){
	
		
	int N; cin >> N;
	int mat[N][3];
	rep(i, 0, N) rep(j, 0, 3) cin >> mat[i][j];
	
	int dp[N][3];
	rep(j, 0, 3) dp[0][j] = mat[0][j];
	rep(i, 1, N){
		rep(j, 0, 3){
			dp[i][j] = 0;
			rep(k, 0, 3){
				if(j==k) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k]);
			}
			dp[i][j] += mat[i][j];
		}
	}
	
	int ans = 0;
	rep(j, 0, 3) ans = max(ans, dp[N-1][j]);
	
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=LLONG_MAX,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
		ll n;cin>>n;ll sum=0;
		ll arr[n];
		for(ll i=0;i<n;i++)cin>>arr[i];
		stack<ll> s;
		s.push(0);
		ll ans[n];for(ll i=0;i<n;i++)ans[i]=-1;
  for (int i = 1; i < n; i++) {
    if (s.empty()) {
      s.push(arr[i]);
      continue;
    }
    while (s.empty() == false && arr[s.top()] < arr[i])
    {
        ans[s.top()]=i;
        s.pop();
    }
    s.push(i);
  }
  // for()
  // ll sum=0;
  ll nex;
  for(ll i=0;i<n;i++){
	  nex=ans[i];
	  if(nex==-1){
		  for(ll j=i;j<n;j++)
		  sum+=abs(arr[j]-arr[i]);
		  break;
	  }
	  else{
		  for(ll j=i;j<nex;j++)
		  sum+=abs(arr[j]-arr[i]);
		  i=nex-1;
	  }
  }
  cout<<sum;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  ll count = 0;
  rep(i, N) {
    if (i > 1 && S[i - 2] == 'A' && S[i - 1] == 'B' && S[i] == 'C') {
      count++;
    }
  }
  COUT(count);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5 +5;
string a,b;
char c[N];
int main(){
	scanf("%s",c);
	b=c[0];
	int cnt=1,len=strlen(c);
	for(int i=1;i<len;i++){
		a=a+c[i];
		if(a!=b){
			b=a;
			a.clear();
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 512
s = input()

l = len(s)

m = s[0]

def check(s, t):
    for i, j in zip(s, t):
        if i != j:
            return i > j

    return 1


if (check(m*l, s)):
    print(m*l)
else:
    print(chr(ord(m)+1)*l)


Measured memory_bytes: 2940
#include <stdio.h>

long long aaa(long long, long long);
long long t[100] = {};

long long aaa(long long x, long long y)
{
	long long r, x1, y1;
	if (x < y)
	{
		x1 = y;
		y1 = x;
	}
	else
	{
		x1 = x;
		y1 = y;
	}
	r = x1 % y1;
	while (r != 0)
	{
		x1 = y1;
		y1 = r;
		r = x1 % y1;
	}
	return y1;
}

int main()
{
	int n;
	long long ans;
	long long g;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &t[i]);
	}
	ans = t[0];
	for (int i = 0; i < n-1; i++)
	{
		g = aaa(ans, t[i + 1]);
		ans =ans * (t[i + 1] / g);
	}
	printf("%lld", ans);
	return 0;
}

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

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; }

using ll = long long;

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> vb(60,0LL);
  for(ll i = 0LL; i < N; i++) {
    ll x;
    cin>>x;
    bitset<60> y(x);
    for(ll j = 0LL; j < 60; j++) {
      if(y.test(j)) vb[j]++;
    }
  }
  ll k = 0LL;
  ll ans=0LL;
  for(ll i = 59;i >=0; i--){
    if((1LL<<i)+k<=K&&N-vb[i]>=N/2LL+1LL){
      k+=(1LL<<i);
      ans+=(1LL<<i)*(N-vb[i]);
    }
    else ans+=(1LL<<i)*vb[i];
  }
  cout<<ans <<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      String t = sc.next();
      char[] s1 = s.toCharArray();
      char[] t1 = t.toCharArray();
      Arrays.sort(s1);
      Arrays.sort(t1);
      String s2 = new String(s1);
      String t2 = new String(t1);
      String t3 = new StringBuilder(t2).reverse().toString();
      if(s2.compareTo(t3)<0){
      	System.out.println("Yes");
      }else{
      	System.out.println("No");
      }
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
//最大公約数求める
ll GCD(ll a,ll b){
  if(a%b==0)  return b;
  else return GCD(b,a%b);
}
//素因数分解
//例えば60=2^2*3*5だったら、{(2,2),(3,1),(5,1)}を返す
vector<pair<ll,ll>> prime_factrize(ll n){
  vector<pair<ll,ll>> res;
  for(ll i=2;i<=sqrt(n);i++){
    if(n%i!=0)continue;
    ll tmp=0;
    while(n%i==0){
      ++tmp;
      n/=i;
    }
    res.push_back(make_pair(i,tmp));
  }
  if(n!=1)res.push_back(make_pair(n,1));
  return res;
}
int main(){
  ll A,B;
  cin>>A>>B;
  ll G=GCD(A,B);
  auto  pf=prime_factrize(G);
  cout<<pf.size()+1<<endl;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}

int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   int k,a,b; cin >> k >> a >> b;
   string ans = "NG";
   for(int i = a; i <= b; ++i){
      if(i % k == 0){
         ans = "OK";
         break;
      }
   }

   cout << ans;
   return 0;
}


Measured memory_bytes: 3652
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int x;
		cin >>x;
		cout<<(!x);

	}
	return 0;
}

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

int top=0,ss[100];

void push(int);
int pop();


int main()
{
  top=0;
  int a,b,i=0;
  char s[100];

  while(scanf("%s", s) != EOF)
    {
      
      if(s[0] == '+')
	{
	  a=pop();
	  b=pop();
	  push(a+b);
	}
      else if(s[0] == '-')
	{
	  b=pop();
	  a=pop();
	  push(a-b);
	}
      else if(s[0] == '*')
	{
	  a=pop();
	  b=pop();
	  push(a * b);
	}
      else
	{
	  push(atoi(s));
	}
	i+=1;
  
    }
  printf("%d\n",pop());
  
  return 0;
}

void push(int x)
{
  ss[++top]=x;
}

int pop()
{
 
     top--;
     return ss[top+1];
  
}





Measured memory_bytes: 2048
///Happy copying <3

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    long long n,a,res;
    cin>>n;
    a = n%1000;
    res = 1000-a;

    cout<<res%1000<<endl;

    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,x,y,h[2],sl;scanf("%d",&n);bool ok;
  int j[n][3];
  for(i=0;i<n;i++) scanf("%d%d%d",&j[i][0],&j[i][1],&j[i][2]);
  for(x=0;x<=100;x++){
    for(y=0;y<=100;y++){
      ok = true;h[0] = 1;h[1] = 2000000000;
      for(i=0;i<n;i++){
        if(j[i][2]>0){
          sl = j[i][2]+abs(j[i][0]-x)+abs(j[i][1]-y);
          if(sl<h[0] || h[1]<sl){
            ok = false;break;
          } else h[0] = h[1] = sl;
        } else {
          sl = abs(j[i][0]-x)+abs(j[i][1]-y);
          if(sl<h[0]){
            ok = false;break;
          } else h[1] = min(h[1],sl);
        }
      }
      if(ok){
        printf("%d %d %d\n",x,y,h[0]);return 0;
      }
    }
  }
}      

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int arr[n];
    int tarr[4] = {0};
    for (int i = 0; i < n; tarr[arr[i]]++, ++i)
        cin >> arr[i];
    //cout << tarr[1] << " " << tarr[2] << " " << tarr[3] << endl;
    double dp[n + 1][n + 1][n + 1];
    dp[0][0][0] = 0;
    for (int k = 0; k <= n; k++)
    {
        for (int j = 0; j <= n - k; j++)
        {
            for (int i = 0; i <= n - (j + k); i++)
            {
                if (i == 0 && j == 0 && k == 0)
                    continue;
                double sum = (i + j + k);
                dp[i][j][k] = (double)n / sum;
                if (i - 1 >= 0)
                    dp[i][j][k] += (double)i / sum * (dp[i - 1][j][k]);
                if (j - 1 >= 0)
                    dp[i][j][k] += (double)j / sum * (dp[i + 1][j - 1][k]);
                if (k - 1 >= 0)
                    dp[i][j][k] += (double)k / sum * (dp[i][j + 1][k - 1]);
            }
        }
    }
    cout << setprecision(17) << dp[tarr[1]][tarr[2]][tarr[3]] << "\n";
    return 0;
}

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  string S; bool flag = false;
  cin >> S;
  if (S[0] == 'A') {
    FOR(i, 1, S.size()){
      if (S[i] == 'C') {
        if (!flag && i != 1 && i != S.size()-1) {
          flag = true;
        }else{
          cout << "WA" << endl;
          exit(0);          
        }
      }else if(S[i] >= 'A' && 'Z' >= S[i]) {
        cout << "WA" << endl;
        exit(0);
      }
    }
  }
  if (flag) {
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}


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

int func ( int x ) {
  if ( x % 100 != 0 ) return 0;
  return func(x/100)+1;
}

int main() {
  int D,N; cin >> D >> N;
  int cnt = 0;
  for ( int i = 1;;i++ ) {
    if ( func(i) == D ) cnt++;
    if ( cnt == N ) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int cnt[10000010];
ll ans;

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;

    for (int i=1;i<=n;i++) {
        for (int j=i;j<=n;j+=i) cnt[j]++;
    }
    for (int i=1;i<=n;i++) ans += 1LL*i*cnt[i];

    cout << ans << endl;
}


Measured memory_bytes: 42584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()

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

	string S, T;
	cin >> S >> T;
	// cout << S << endl;
	int t = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			S[i] = T[i];
			t++;
			// cout << S << endl;
		}
	}
	printf("%d\n", t);
}


Measured memory_bytes: 3876
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    long a=in.nextLong();
    long b=in.nextLong();
    long k=in.nextLong();
    if(a+b<=k)
    {
      System.out.println("0 0");
    }
    else if(a>=k)
    {
      System.out.println((a-k)+" "+b);
    }
    else
    {
      System.out.println("0 "+(b-(k-a)));
    }
  }
}

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

using namespace std;

const int N = 3 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
long long a[N], b[N];
long long dp[N][N];

bool read() {
    if (!(cin >> n >> m))
        return false;

    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    for (int i = 1; i <= m; ++i)
        cin >> b[i];

    return true;
}

void solve() {
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];

            if (a[i] == b[j])
                dp[i][j] += 1 + dp[i - 1][j - 1];

            dp[i][j] = (MOD + dp[i][j] % MOD) % MOD;
        }

    cout << (1 + dp[n][m]) % MOD << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 49152
instr = input()
x1, y1, x2, y2 = map(int, instr.split())
sax = x2 - x1
say = y2 - y1
x3 = x2 - say
y3 = y2 + sax
x4 = x3 - sax
y4 = y3 - say
print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))

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

namespace ABC159A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int res = 0;

            if (nm[0] != 0)
            {
                res += (nm[0] * (nm[0] - 1)) / 2;
            }
            if (nm[1] != 0)
            {
                res += (nm[1] * (nm[1] - 1)) / 2;
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
char str[100001];
int main(void)
{
	int len;
	scanf("%s",str);
	len=strlen(str);
	if((str[0]==str[len-1])!=len%2) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 256
A = list(map(int,(input().split())))
S1 = set(A)
S2 = set(A)
for i in range(2):
    B = list(map(int,input().split()))
    S1 = S1 | set(B)
    S2 = S2 & set(B)
if len(S1) == 4 and len(S2) == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
import numpy as np

H, W, K = map(int, input().split())
c = np.zeros((H,W),"int")
for i in range(H):
  ci_str = input()
  for j in range(W):
    c[i,j] = 0 if ci_str[j]=="." else 1

count = 0
for h in range(2**H):
  h_bin = np.array(list(map(int, list(format(h,f"0{H}b")))))
  d = c[h_bin==1,:]
  for w in range(2**W):
    w_bin = np.array(list(map(int, list(format(w,f"0{W}b")))))
    e = d[:,w_bin==1]
    if e.sum() == K:
      count += 1
print(count)

Measured memory_bytes: 27048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n,b;
	cin>>n;
	vector<int> a,c;
	for(int i=0;i<n;i++){
		cin>>b;
		a.push_back(b);
	}
	c=a;
	sort(a.begin(),a.end(),greater<int>());
	for(int i=0;i<n;i++){
		if(c[i]==a[0])
			cout<<a[1]<<endl;
		else
			cout<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3316
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;

int main()
{
    fastio;
    ll i,temp,sum=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        temp=s[i]-'0';
        sum+=temp;
    }
    if(sum%9)cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
ll ceil1(ll a,ll b)
{	if(a%b==0)
		return a/b;
	else
		return a/b+1;}

void solve()
{
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll ans=0;
	if(x%d==0)
	{
		ll rm=k-(x/d);
		if(rm>0)
		{
			if(rm%2==0)
				ans=0;
			else
				ans=d;
		}
		else
			ans=x-k*d;
	}
	ll stp=x/d;
	if(stp>k)
	{
		ans=x-k*d;
	}
	else
	{
		ll r=x-stp*d;
		ll l=r-d;
		if((k-stp)%2==0)
			ans=r;
		else
			ans=l;
	}
	cout<<abs(ans);
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



Measured memory_bytes: 3596
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; string s; cin >> N >> s;

    int pena = 0;
    for(int i=1; i<N; i++) {
        if(s[i] == 'E') pena++;
    }

    int ans = pena;
    for(int i=1; i<N; i++) {
        pena -= (s[i  ] == 'E');
        pena += (s[i-1] == 'W');
        chmin(ans, pena);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
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)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vvll edges;

ll dfs(ll i) {
    ll cs = edges[i].size();
    vll cls;
    for (ll to: edges[i]) cls.push_back(dfs(to));
    sort(cls.begin(), cls.end());
    ll ret = 0;
    REP(j, cls.size()) {
        chmax(ret, cls[j]+cs-j);
    }
    return ret;
} 

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    edges.resize(n+1);
    rep(i, 2, n+1) {
        ll a; cin >> a;
        edges[a].push_back(i);
    }
    cout << dfs(1) << '\n';
    return 0;
}


Measured memory_bytes: 15104
import sys
readline = sys.stdin.readline

H,W = map(int,readline().split())
S = [None] * H
for i in range(H):
  S[i] = readline().rstrip()

ans = 0
from collections import deque
cases = ((1,0),(-1,0),(0,1),(0,-1))
for i in range(H):
  for j in range(W):
    q = deque([[i,j,0]])
    seen = set()
    while q:
      y,x,d = q.popleft()
      if S[y][x] == "#":
        continue
      if (y,x) in seen:
        continue
      seen.add((y,x))
      if d > ans:
        ans = d
      for c in cases:
        if 0 <= y + c[0] < H and 0 <= x + c[1] < W:
          q.append([y + c[0], x + c[1], d + 1])

print(ans)

Measured memory_bytes: 9512