akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	char s;
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s;
		if(s=='P') a[0]=1;
		else if(s=='W') a[1]=1;
		else if(s=='G') a[2]=1;
		else a[3]=1;
	}
	if(a[0]+a[1]+a[2]+a[3]==4) cout<<"Four";
	else cout<<"Three";
	return 0;
}

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

int h, w;
int v[12][12];
bool ans = false;

bool palindrome(string &s) {
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (i > n-1-i) break;
        if (s[i] != s[n-1-i]) return false;
    }
    return true;
}

void judge(vector<int> &s) {
    vector<int> y(h);
    vector<bool> u(h, false);
    for (int i = 0; i < h; i++) {
        if (u[s[i]]) y[i] = h-1 - (h/2+s[i]); 
        else y[i] = h/2 + s[i]; 
        u[s[i]] = true;
    }
    vector<string> p(w, string(h, '0')), q;
    q = p;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            p[j][y[i]] = v[i][j];
            q[j][h-y[i]-1] = v[i][j];
        }
    }
    int pcount = 0;
    vector<string> a, b, c;
    for (int i = 0; i < w; i++) {
        if (palindrome(p[i])) c.emplace_back(p[i]);
        else {
            a.emplace_back(p[i]);
            b.emplace_back(q[i]);
        }
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    if (!a.empty()) {
        if (a.size() % 2 == 1) return;
        for (int i = 0; i < a.size(); i++) {
            if (a[i] != b[i]) return;
        }
    }
    if (!c.empty()) {
        int cnt = 0;
        for (int i = 0; i < c.size(); i++) {
            if (i != c.size()-1 && c[i] == c[i+1]) i++;
            else cnt++;
        }
        if (cnt > 1) return;
    }
    ans = true;
    return;
}

void search(int t, vector<int> &s) {
    if (t == h) {
        judge(s);
        return;
    }
    int first = -1;
    if ((h - t) % 2 == 1) {
        for (int i = 0; i < h; i++) {
            s[i] = (t+1) / 2;
            search(t+1, s);
            s[i] = -1;
        }
    } else {
        for (int i = 0; i < h; i++) {
            if (s[i] == -1) {
                first = i;
                break;
            }
        }
        bool flag = true;
        for (int j = first+1; j < h; j++) {
        if (s[j] == -1) {
                s[first] = (t+1) / 2;
                s[j] = (t+1) / 2;
                flag = false;
                search(t+2, s);
                s[first] = -1;
                s[j] = -1;
            }
        }
    }
    return;
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            v[i][j] = s[j];
        }
    }
    vector<int> s(h, -1);
    search(0, s);
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,M;
	cin>>N>>M;
	VI A(M);
	REP(i,M)cin>>A[i];
	if(N>=M){
		cout<<0<<endl;
		return 0;
	}
	SORT(A);
	VI B(M-1);
	REP(i,M-1)B[i]=A[i+1]-A[i];
	//REP(i,M-1)cout<<B[i]<<endl;
	SORT(B);
	ll ans=0;
	REP(i,M-N)ans+=B[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a,b,c = m()

if a == b and a != c:
    print("Yes")


elif c == b and a != c:
    print("Yes")

elif a == c and a != b:
    print("Yes")

else:
    print("No")








Measured memory_bytes: 38384
def is_ok(x):
    result = 0
    for i in range(N):
        a = A[i]
        t = x // F[i]
        if t < a:
            result += a - t
    return result <= K

N,K = map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
ok=A[-1]*F[0]
ng=-1
while(ng+1<ok):
  c=ng+(ok-ng)//2
  if is_ok(c):
    ok=c
  else:
    ng=c

print(ok)

Measured memory_bytes: 119500
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
pair<int, int> E[100001];
int H[100001];
int n[100001], kari[100001];
int sagasu(int A) {
	if (n[A] == n[A - 1]) return 0;
	int k = n[A - 1];
	for (int i = H[A]; i; i = E[i].second) {
		kari[k++] = sagasu(E[i].first);
	}
	sort(kari + n[A - 1], kari + n[A], greater<int>());
	int ret = 0;
	k = 1;
	for (int i = n[A - 1]; i < n[A]; i++) ret = max(ret, kari[i] + k++);
	return ret;
}

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


	int N = getint();

	for (int i = 2; i <= N; i++) {
		int a = getint();
		n[a]++;
		E[i] = mp(i, H[a]);
		H[a] = i;
	}
	rep1(i, N) n[i] = n[i - 1] + n[i];

	printf("%d\n", sagasu(1));

	Would you please return 0;
}

Measured memory_bytes: 9984
#include<iostream>
	#include<stdlib.h>
	#include<vector>
	#include<algorithm>
	#include<stdio.h>
	#include<string>
	#include<map>
	#include<math.h>
	#include<iomanip>
	#include<set>
	#include<limits.h>
	#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
	#define swap(a,b) a^=b;b^=a;a^=b;
	#define chmax(a,b) {if(a < b) a = b;}
	#define chmin(a,b) {if(a > b) a = b;}
	using namespace std;
	typedef long long ll;
	ll gcd(ll, ll);
	vector<bool> to_binary(int);
	int sum(vector<int>);
	int min(vector<int>);
	int max(vector<int>);
	ll nCr(ll n, ll r);

	const ll INF = 1LL << 60;

	typedef tuple<ll, ll> mtupl;

	bool mycomp(mtupl x, mtupl y) {
		return get<1>(x) < get<1>(y);
	}

	int main(void) {
		cin.tie(0);
		ios::sync_with_stdio(false);
		//Program Start	

		char S[5];
		cin >> S;

		vector<char> vS{ S[0],S[1],S[2],S[3] };

		sort(vS.begin(), vS.end());

		if (vS[0] == vS[1] && vS[2] == vS[3] && vS[0] != vS[2])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	ProgramEndPointLabel:;

		//Program End
		system("pause");

		return 0;
	}

	ll nCr(ll n, ll r) {
		ll res = 1;
		for (int i = 0; i < r; i++) {
			res *= (n - i);
		}
		for (int i = 1; i <= r; i++) {
			res /= i;
		}
		return res;
	}

	int vsum(vector<int> v) {
		int res = 0;
		for (auto it = v.begin(); it != v.end(); it++)
			res += *it;
		return res;
	}
	int vmin(vector<int> v) {
		int min = INT32_MAX;
		for (auto it = v.begin(); it != v.end(); it++)
			min = std::min(min, *it);
		return min;
	}
	int vmax(vector<int> v) {
		int max = 0;
		for (auto it = v.begin(); it != v.end(); it++)
			max = std::max(max, *it);
		return max;
	}

	ll gcd(ll A, ll B) {
		int r = A % B;
		while (r != 0) {
			A = B;
			B = r;
			r = A % B;
		}

		return B;
	}

	vector<bool> to_binary(int x) {
		vector<bool> res;
		while (x != 0) {
			res.push_back(x % 2);
			x /= 2;
		}
		return res;
	}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9+7;

//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//

//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//

ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};






int main(){

   int n, k;
   cin >> n >> k;
   vector <int> vec(n);
   for(int i = 0; i < n; i++){
       cin >> vec[i];
   }
   sort(vec.begin(), vec.end());
   int ans = 0;
   for(int i = 0; i < k; i++) ans += vec[i];
   cout << ans;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, x;
ll a[100000], ans;

int main() {
	cin >> n >> x;
	rep(i,n) cin >> a[i];
	
	if (a[0]>x) {
		ans += a[0]-x;
		a[0] = x;
	}
	rep(i,n-1) {
		ll y = (a[i+1]+a[i]-x);
		if (y>0) {
			a[i+1] -= y;
			ans += y;
		}
	}
	cout << ans << ln;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,c,k,ans,t[100001],la,nw,s;
int main()
{
	cin>>n>>c>>k;
	for(int i=1;i<=n;i++)
		cin>>t[i];
	sort(t+1,t+1+n);
	while(nw<n)
	{
		nw++;la=t[nw]+k;s=c-1;
		while(t[nw+1]<=la&&s>0&&nw<n) {s--;nw++;}
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
static const int INF = 1e9;

void solve()
{
	int n;
	cin >> n;
	vector< vector<int> > d(n + 1, vector<int>(n + 1));
	for (int i = 0; i < n + 1; ++i)
	{
		for (int j = 0; j < n + 1; ++j)
		{
			d[i][j] = INF;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int r, k;
		cin >> r >> k;
		for (int j = 0; j < k; ++j)
		{
			int t;
			cin >> t;
			d[r][t] = 1;
		}
	}
	for (int k = 1; k < n + 1; ++k)
	{
		for (int i = 1; i < n + 1; ++i)
		{
			for (int j = 1; j < n + 1; ++j)
			{
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int p;
	cin >> p;
	for (int i = 0; i < p; ++i)
	{
		int start, dist, v;
		cin >> start >> dist >> v;
		if (d[start][dist] + 1 <= v)
		{
			cout << d[start][dist] + 1 << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1256
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let x = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec take res n acc = match (n, acc) with
  | (_, []) | (0, _) -> List.rev res
  | (i, x :: xs) -> take (x :: res) (n - 1) xs
let take = take []

let rec drop n acc = match (n, acc) with
  | (0, acc) -> acc
  | (_, []) -> []
  | (n, x :: xs) -> drop (n - 1) xs

let xs, ys = let acc = List.sort compare x in take (n / 2) acc, drop (n / 2) acc
let a, b = List.rev xs |> List.hd, List.hd ys

let () = x
  |> List.map (fun i -> if i <= a then b else a)
  |> List.iter (Printf.printf "%d\n")

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

int main() {
  long a,b,c,n;
  cin>>a>>b>>c>>n;
  if(a>=n){
    cout<<n;
  }else if(a+b>=n){
    cout<<a;
  }else{
    cout<<a-(n-(a+b));
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<string>> data(n);
    rep(i,m) {
        int x;
        string s; 
        cin >> x >> s;
        data[x-1].push_back(s);
    }
    int n_ac = 0;
    int n_wa = 0;
    rep(i,n) {
        int tmp_wa = 0;
        rep(j,data[i].size()) {
            if (data[i][j] == "WA") tmp_wa++;
            if (data[i][j] == "AC") {
                n_ac++;
                n_wa += tmp_wa;
                break;
            }
        }
    }
    cout << n_ac << " " << n_wa << endl;
}

Measured memory_bytes: 10368
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 100000007;

void combination(int n, vector<vector<long long> >& comb)
{
    comb.assign(n+1, vector<long long>(n+1, 0));
    for(int i=0; i<=n; ++i){
        comb[i][0] = 1;
        for(int j=1; j<=i; ++j){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= MOD;
        }
    }
}

int main()
{
    vector<vector<long long> > comb;
    combination(1000, comb);

    int h, w, a1, a2, b1, b2;
    cin >> h >> w >> a1 >> a2 >> b1 >> b2;

    int dy = min(abs(a1 - b1), h - abs(a1 - b1));
    int dx = min(abs(a2 - b2), w - abs(a2 - b2));

    long long ret = comb[dy+dx][dy];
    if(dy * 2 == h)
        ret *= 2;
    if(dx * 2 == w)
        ret *= 2;
    ret %= MOD;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 8932
N = input().split()
N = [int(i) for i in N]
pi = [0 for i in range(N[0])]
ci = [0 for i in range(N[0])]
for i in range(N[0]):
    buf = input().split()
    pi[i] = int(buf[0])
    ci[i] = int(buf[1])

num_min = 10*100
G_new = N[1]

flag= [0 for i in range(N[0])]
for i in range(0, pow(2, N[0])):
    G_new = N[1]
    count = 0
    #print(bin(i))
    for j in range(N[0]):
        flag[j] = (i>>j & 1)
        if(flag[j]==1):
            G_new -= ci[j]
            G_new -= 100*(j+1)*pi[j]
            count += pi[j]
    #print(flag)

    if(G_new<=0):
        #print(i, flag)
        if(count < num_min):
            #print(count)
            num_min = count
            #print(count)
    else:
        for j in range(N[0]):
            if((flag[N[0]-1-j])==0):
                #print(i, flag, N[0]-1-j, G_new, pi[N[0]-1-j], count, -(-G_new//(100*(N[0]-j)))   )
                if(G_new - 100*(N[0]-j)*pi[N[0]-1-j] < 0):
                    count += -(-G_new//(100*(N[0]-j)))
                    if(count < num_min):
                       # print(count)
                        num_min = count
                break

    
print(num_min)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
ll N = 1000000;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	string s;
	cin >> s;
	ll g=0, p=0;
	rep(i, s.size()) {
		if (s[i] == 'g') g++;
		else p++;
	}
	g -= p;
	cout << g / 2 << endl;
	return 0;
}

Measured memory_bytes: 512
import numpy as np
h,w=map(int,input().split())
l=set()
for i in range(h):
    t=input()
    for j in range(w):
        if t[j]==".":
            l.add((i,j))

s=set()
from collections import deque
graph=np.zeros((h*w,h*w),dtype=np.int64)
for x,y in l:
        if (x+1,y) in l and (x*w+y,(x+1)*w+y) not in s:
            graph[x*w+y,(x+1)*w+y]=1
            s.add((x*w+y,(x+1)*w+y))
        if (x,y+1) in l and (x*w+y,x*w+y+1) not in s:
            graph[x*w+y,x*w+y+1]=1
            s.add((x*w+y,x*w+y+1))

from scipy.sparse.csgraph import floyd_warshall


ans=floyd_warshall(graph,directed=False)
cond=ans!=float("inf")
print(int(ans[cond].max()))

Measured memory_bytes: 18012
#include <stdio.h>
#include <string.h>
char B[101];
int A[10];
void Search(int num);
int main(void){
	int i,n,len;
	char str[100],*line;

	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); A[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); A[i]=n;
	}
	scanf("%s",B);
	for(i=0;B[i] !='\0';i++){
		switch(B[i]){
			case 'N': Search(2); break;
			case 'W': Search(3); break;
			case 'E': Search(4); break;
			case 'S': Search(5); break;
		}
	}
	printf("%d\n",A[1]);
	return 0;
}
			
void Search(int num){
	int tmp;
	tmp = A[1];
	A[1] = A[num];
	A[num] = A[6];
	A[6] = A[7-num];
	A[7-num] = tmp;
}

Measured memory_bytes: 608
#pragma comment (linker, "/STACK:256000000")

#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
#include <random>
#include <bitset>

using namespace std;

typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef long double ldouble;
typedef pair<int, int> pii;
typedef pair<int64, int64> pll;
typedef pair<uint64, uint64> puu;
typedef pair<pii, pii> piiii;

#define pb push_back
#define sq(x) ((x)*(x))
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define rand32() (((unsigned int)(rand()) << 16) | (unsigned int)(rand()))
#define rand64() (((unsigned int64)(rand32()) << 16) | (unsigned int64)(rand32()))
#define bit(mask, b) ((mask >> b) & 1)
#define biton(mask, bit) (mask | (((uint32)(1)) << bit))
#define bitoff(mask, bit) (mask & (~(((uint32)(1)) << bit)))
#define bitputon(mask, bit) (mask |= (((uint32)(1)) << bit))
#define bitputoff(mask, bit) (mask &= (~(((uint32)(1)) << bit)))
#define FAIL() (*((int*)(0)))++
#define INF ((int)(1e9) + 1337)
#define LINF ((int64)(1e18))
#define EPS 1e-13
#define PI (3.1415926535897932384626433832795)
#define y1 yy1
#define y0 yy0
#define j0 jj0
//#define MOD 1000000007LL
#define HMOD 1234567913LL
#define HMOD2 1000000007LL
#define HBASE 1000003


//#ifdef _MY_DEBUG
//    #define HMOD 1000000007
//    #define HBASE (1000003LL)
//#else
//    #define HMOD ((int64)(1e18) + 3LL)
//    #define HBASE (1000037LL)
//#endif
#define MAX 2000000000
mt19937 ggen;

int n, m;
int ctr[100010];
int f[100010];

void solve()
{
    cin >> n >> m;
    int cur = 0;
    for (int i = 0; i < n; i++)
        ctr[i] = 1;
    f[0] = 1;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        f[b] |= f[a];
        ctr[a]--;
        if (ctr[a] == 0)
            f[a] = 0;
        ctr[b]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += f[i];
    cout << ans;
}

#define TASK "substr"
int main()
{
    //testgen(100000);// return 0;
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    //stresstest(8); return 0;
    srand(1313);
    ggen = mt19937(13);

    solve();

    return 0;
}

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

using namespace std;

typedef long long int lli;

int main() {
    vector< vector<int> > vec(100001, vector<int>());
    vector<bool> ans(100001, true), used(100001, false);
    int n, u, v, w;
 
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> u >> v >> w;
        vec[u].push_back(v);
        vec[u].push_back(w);
        vec[v].push_back(u);
        vec[v].push_back(w);
    }

    priority_queue<int> pqu;
    pqu.push(1);
    while(!pqu.empty()) {
        // cout << pqu.top() << endl;
        int crnt = pqu.top();
        pqu.pop();
        for (int i = 0; i < vec[crnt].size(); i+=2) {
            int next = vec[crnt][i], _w = vec[crnt][i+1];
            
            if (used[next]) continue;
            
            if (_w%2)   ans[next] = !ans[crnt];
            else        ans[next] = ans[crnt];
            
            pqu.push(vec[crnt][i]);
        }
        used[crnt] = true;
    }

    for (int i=1; i<=n; i++) {
        cout << (ans[i] ? 1 : 0) << endl;
    }


    return 0;
}


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

// returns the index of the element which value equals to key.
// if no elements matched, it returns -1.
int search(const vector<int> &x, int key) {
	int left = 0, right = x.size();
	while (left < right) {
		int mid = (left + right) / 2;
		if (x[mid] == key) {
			return mid;
		} else if (key < x[mid]) {
			right = mid;
		} else if (x[mid] < key) {
			left = mid+1;
		}
	}
	return -1;
}

int main() {
	int n;
	cin >> n;
	vector<int> na(n,0);
	for(int i=0;i<n;i++) cin >> na[i];
	int q;
	cin >> q;
	int t;
	int ans = 0;
	for(int i=0;i<q;++i) {
		cin >> t;
		ans += search(na,t) >= 0 ? 1 : 0;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=1000000007;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
 ll n;
 cin>>n;
 ll sum=0;
 ll ans=0;
 for(ll i=0;i<n;i++)
 {
     ll k;
     cin>>k;
    
     ans=add(ans,mul(sum,k));
      sum=add(sum,k);
 }
 cout<<ans<<endl;



}



   
      
    
        



Measured memory_bytes: 3672
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h> 

using namespace std;


#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")

ll a[100][100];
int main(){
	ll n,m,c;
	sfl(n),sfl(m),sfl(c);
	ll b[m+10];
	for(ll i=1;i<=m;i++){
		sfl(b[i]);
	}
	ll ans=0,cnt;
	FOR(i,n){
		cnt=0;
		FOR(j,m){
			sfl(a[i][j]);
			cnt += a[i][j] * b[j];
		}
		cnt += c;
		if(cnt>0){
			ans++;
		}
	}

	pfl(ans);
}



Measured memory_bytes: 256
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return;
    }
  }
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int64_t Calc(const int64_t H, const int64_t W) {
  int64_t ave = H*W / 3;

  int64_t s1, s2, s3;
  int64_t result = H*W;

  int64_t h1 = ave / W;
  for (int64_t i = h1; i < h1 + 2; ++i) {
    s1 = W*i;

    int64_t k = (H - i) / 2;
    s2 = W*k;
    s3 = W*(H - i - k);

    int64_t min_ = min(s1, min(s2, s3));
    int64_t max_ = max(s1, max(s2, s3));

    result = min(result, max_ - min_);

    int64_t w1 = ave / (H - i);
    for (int64_t j = w1; j < w1 + 2; ++j) {
      s2 = (H - i)*j;
      s3 = (H - i)*(W - j);

      int64_t min_ = min(s1, min(s2, s3));
      int64_t max_ = max(s1, max(s2, s3));

      result = min(result, max_ - min_);
    }
  }

  return result;
}

int main() {
  int H, W;
  cin >> H >> W;

  if (H % 3 == 0 || W % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }

  int64_t result = min(Calc(H, W), Calc(W, H));
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define mp make_pair
#define pb push_back
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;


int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string str;
	int win;
	cin>>str;
	win=15-str.length();
	repp(i,0,str.size()-1,1){
		if(str[i]=='o')win++;
	}
	if(win>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int a, b;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> a >> b;
	if (a != 1 && b != 1) {
		cout << "1" << endl;
	}else if (a != 2 && b != 2) {
		cout << "2" << endl;
	}
	else {
		cout << "3" << endl;
	}

}

Measured memory_bytes: 256
a,b,c,x,y=list(map(int,input().split()))
ans = a*x+b*y
c = c * 2

for i in range(1,max(x,y)+1):
  if x-i < 0:
    ans1 = b*(y-i)+c*i
  elif y-i < 0:
    ans1 = a*(x-i)+c*i
  else:
    ans1 = a*(x-i)+b*(y-i)+c*i
  ans = min(ans,ans1)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = ["a", "i", "u", "e", "o"]
    c = S()
    if c[0] in a:
        print("vowel")
    else:
        print("consonant")
    return

#B
def B():
    _ = II()
    t = LI()
    tsum = sum(t)
    for _ in range(II()):
        p, x = LI()
        print(tsum - t[p - 1] + x)
    return

#C
def C():
    s = input()
    lens = len(s)
    check = ["dream", "dreamer", "erase", "eraser"]
    q = deque()
    q.append(0)
    while q:
        p = q.pop()
        if p == lens:
            print("YES")
            return
        for i in check:
            if s[p:p + len(i)] == i:
                q.appendleft(p + len(i))
    print("NO")
    return

#D
def D():
    class UnionFind():

        def __init__(self, n):
            self.par = [i for i in range(n)]
            self.size = [1] * n
        
        def find(self, a):
            if a == self.par[a]:
                return a
            x = self.find(self.par[a])
            self.par[a] = x
            return x

        def unite(self, a, b):
            a = self.find(a)
            b = self.find(b)
            if a == b: return
            if a > b: a, b = b, a
            self.par[b] = a
            self.size[a] += self.size[b]

    n, k, l = LI()
    rail = UnionFind(n)
    road = UnionFind(n)

    for _ in range(k):
        p, q = LI_()
        rail.unite(p, q)
    for _ in range(l):
        r,s = LI_()
        road.unite(r, s)
    d = defaultdict(int)
    for i in range(n):
        d[(rail.find(i), road.find(i))] += 1
    for i in range(n):
        print(d[(rail.find(i), road.find(i))], end=" ")
    print()
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 122780
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    set<int>st;
    for(int i=0;i<n;i++)
        st.insert(a[i]);
    if(st.find(x) == st.end())
    {
        cout<<x;
    }
    else
    {
        int i = x+1;
        int j = x-1;
        while(1)
        {
            if(st.find(j) == st.end())
            {
                cout<<j;
                break;
            }
            if(st.find(i) == st.end())
            {
                cout<<i;
                break;
            }
            i++;
            j--;
        }
    }
}

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

using namespace std;

int main () {
	int n;
	cin >> n;
	
	vector<int> input(n);
	for (int i = 0; i < n; i++) {
		cin >> input[i];
	}

	vector<int> ans(n);
	ans[0] = 0; ans[1] = abs(input[1] - input[0]);
	for (int i = 2; i <n; i++) {
		ans[i] = min ( ans[i-1] + abs(input[i] - input[i - 1]), ans[i-2] + abs(input[i] - input[i - 2]) );
	}
	
	cout << ans[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char s[1000001];
int main(){
	int i;
	scanf("%s",s);
	for(i=0;i<strlen(s);i++)
		if(s[i]=='C')break;
	for(;i<strlen(s);i++)
		if(s[i]=='F'){printf("Yes\n");return 0;}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < s.size(); i++)
		if(s[i] != t[i])
			ans++;
	cout << ans;
    return 0;
}



Measured memory_bytes: 3784
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  vector< vector<int> > C(H,vector<int>(W)), DP(H, vector<int>(W,0));
  for(int i = 0; i < H; ++i)
    for(int j = 0; j < W; ++j)
      cin >> C[i][j];
  for(int i = 0; i < H; ++i) DP[i][0] = (int)(1-C[i][0]);
  for(int i = 0; i < W; ++i) DP[0][i] = (int)(1-C[0][i]);
  for(int i = 1; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(C[i][j]) continue;
      DP[i][j] = min({DP[i-1][j], DP[i][j-1], DP[i-1][j-1]}) + 1;
    }
  }
  int ans = 0;
  for(int i = 0; i < H; ++i)
    for(int j = 0; j < W; ++j)
      ans = max(ans, DP[i][j]);
  cout << ans*ans << endl;
  return 0;
}



Measured memory_bytes: 18180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong a[200005];
map<llong, llong> mp;
llong x;

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

    for (auto s:mp) {
        x += s.second * (s.second - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        llong tmp = x;

        tmp -= mp[a[i]] * (mp[a[i]] - 1) / 2;
        tmp += (mp[a[i]] - 1) * (mp[a[i]] - 2) / 2;

        cout << tmp << '\n';
    }

    return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;

int main()
{
  int sum = 0, remain = 0;
  for (int i = 0; i < 5; i++){
    int a; cin >> a;
    int time = (a + 9) / 10 * 10;
    sum += time;
    remain = max(remain, time - a);
  }
  cout << sum - remain << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()

int main() 
{
	 //#ifndef ONLINE_JUDGE
      //  freopen("input.txt", "r", stdin);
     //   freopen("output.txt", "w", stdout);
    //#endif
    //fastio();
    ll n,m;
    cin>>n>>m;
    ll p = m+n;
    ll mn = p - max(m,n);
    ll cnt = p - mn;
    loop(i,0,cnt)
    	cout<<mn;
}

Measured memory_bytes: 256
import sys

orga = list(map(int, input().split()))
child = list(map(int, input().split()))
time = int(input())

speed = orga[1] - child[1]
dis = abs(orga[0] - child[0])

if speed <= 0:
    print("NO")
    sys.exit()

if dis / speed <= time:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9208
n, k = list(map(int, input().split()))
d = []
a = []
ans = 0

for i in range(k):
    d += [int(input())]
    a += [list(map(int, input().split()))]

for m in range(n):
    for array in a:
        if m+1 in array:
            ans -= 1
            break
    ans += 1

print(ans)

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
  int i,j;
  int x[200000],n;
  int xx[200000]; 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d ",&x[i]);
    xx[i]=x[i];
  }
  qsort(x,n,sizeof(int),compare_int);
  for(i=0;i<n;i++){
    if(xx[i]<=x[n/2-1])
      printf("%d\n",x[n/2]);
    else
      printf("%d\n",x[n/2-1]);
  }
  return 0;
}

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

int main() {
  long long int N;
  cin >> N;
  vector<long long int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  
  long long int ans = 0;
  for (long long int i = 0; i < N; i++) {
    for (long long int j = i + 1; j < N; j++) {
      for (long long int k = j + 1; k < N; k++) {
        if (L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i) &&
          L.at(i) + L.at(j) + L.at(k) > 2 * max(max(L.at(i), L.at(j)), L.at(k))) {
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
from collections import deque

n,m = map(int, input().split())
dic = {}

AB = [map(int, input().split()) for _ in range(m)]

dic = [[] for _ in range(n + 1)]

for a,b in AB:
    a -= 1
    b -= 1

    dic[a].append(b)
    dic[b].append(a)

#dist = {}
queue = deque([0])
visited = []
pre = [-1] * (n+1)

#dist[0] = 0 
queue.append(0)

while queue:
    v = queue.popleft()
    
    for i in dic[v]:
        if pre[i] == -1:
        #dist[i] = dist[v] + 1
            pre[i]= v
            queue.append(i)

print("Yes")
for i in range(n):
    ans = 0
    
    if(i == 0):
        continue
    
    ans = pre[i]
    ans += 1
    print(ans)

Measured memory_bytes: 104756
#ABC062A
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = list(map(int,input().split()))
if ((x in a) and (y in a)): print("Yes")
elif ((x in b) and (y in b)): print("Yes")
elif ((x in c) and (y in c)): print("Yes")
else: print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
const ll LIM =1e9+7;

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}



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

    ll ans =0;
    int k;cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++) {
            for (int l = 1; l <= k; l++) {
                int tmp = gcd(j,l);
                ans += gcd(tmp, i);
            }
        }
    }

    fin(ans);


}


Measured memory_bytes: 3640
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if A[i]!=A[minj]:
        count += 1
    A[i],A[minj] = A[minj],A[i]
print(*A)
print(count)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
#define ed '\n'
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll n;
	cin>>n;
	ll fin=0;
	for(ll i=2;i*i<=n-1;i++)
	{
		if((n-1)%i==0)
		{
			if(i*i==n-1)fin++;
			else fin+=2;
			}	
	}
	if(n-1!=1)
	fin++;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
		ll n1=n;
		ll j=n/i;
		while(n1%i==0)n1/=i;
		if((n1-1)%i==0)fin++;
		n1=n;
		if(i!=j)
		{while(n1%j==0)n1/=j;
		if((n1-1)%j==0)fin++;
		}
		}
	}
	fin++;
	cout<<fin<<endl;
}

Measured memory_bytes: 256
#pragma target("avx2")
#pragma optimize("O3")
#include<stdio.h>
#include<stdbool.h>

int main(void){
        char s[10];
        int l = 0, i, cnt = 0;
        bool ok = true;
        while((s[l]=getchar())!='\n') l++;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C') ok &= (1<i && i<l-1);
                else if(s[i]=='A') ok &= (i==0);
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(" ");

        var A = int.Parse(inputs[0]);
        var B = int.Parse(inputs[1]);
        var C = int.Parse(inputs[2]);
        var X = int.Parse(inputs[3]);
        var Y = int.Parse(inputs[4]);

        // A, Bピザのみでの購入を計算
        var priceA = A * X + B * Y;

        // Cピザの組み換えを検討
        var num = X > Y ? X * 2 : Y * 2;
        var priceB = int.MaxValue;
        for (int i = 0; i < num; i++)
        {
            var numOfC = i * 2;
            var numOfA = (X - i) > 0 ? X - i : 0; 
            var numOfB = (Y - i) > 0 ? Y - i : 0;
            var sum = (C * numOfC) + A * numOfA + B * numOfB;
            if (priceB > sum) priceB = sum;
        }

        if (priceA < priceB) Console.WriteLine(priceA);
        else Console.WriteLine(priceB);
    }
}



Measured memory_bytes: 27440
n, m = map(int, input().split())
c = list(map(int, input().split())) #0-index

# dp[i+1][x]:i種類のコインを使ってxを支払う際の最小のコイン枚数
dp = [[float('inf')]*(n+1) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for x in range(n+1):
        dp[i+1][x] = dp[i][x]

        if x -c[i]>= 0:
            dp[i+1][x] = min(dp[i+1][x - c[i]] + 1, dp[i][x])
print(dp[m][n])


Measured memory_bytes: 43732