akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
H = list(map(int, input().split()))
table = []
for i in range(N):
    table.append(set())
for i in range(M):
    Ai, Bi = map(lambda x: x - 1, map(int, input().split()))
    table[Ai].add(Bi)
    table[Bi].add(Ai)
answer = 0
for i, h in enumerate(H):
    highest = True
    for path in table[i]:
        if h <= H[path]:
            highest = False
    if highest:
        answer += 1
print(answer)


Measured memory_bytes: 45308
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a*b%2==0){
        cout << "Even";
    }else{
        cout << "Odd";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){
    string s;
    cin >> s;
    int cont = 0;
    for(int i=0,j=s.size()-1 ;i <s.size()/2;i++,j--)
    {
        if(s[i]!=s[j]) {cont++ ;}

    }
cout << cont <<endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

vector<int> dp(1<<15, INF);

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n, m;
	cin >> n >> m;
	dp[0] = 0;

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		int open = 0;
		rep(j, b) {
			int c;
			cin >> c;
			open += 1 << (--c);
		}
		rep(j, (1<<n)) {
			chmin(dp[j | open], dp[j] + a);
		}
	}

	int ans = dp[(1<<n) - 1];
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c,k;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
    while(k--)
    {
        ll tmp1=2*a;
        ll tmp2=2*b;
        ll tmp3=2*c;
        if(tmp1>=tmp2&&tmp1>=tmp3)
        {
            a=tmp1;
        }
        else if(tmp2>=tmp3)
        {
            b=tmp2;
        }
        else
            c=tmp3;
    }
    printf("%lld\n",a+b+c);
    return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  int n = 0;
  for(int i=0;i<s.size();i++)
    n += (s[i]-'0');
  int n1 = stoi(s);

  if(n1%n==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

int main(){
	int k;
	scanf("%d", &k);
	int ans = 0;
	for(int i=0; i < k; i++) {
		for(int j=0; j < k; j++) {
			for(int l=0; l < k; l++) {
				ans += gcd(gcd(i+1, j+1), l+1);
			}
		}
	}
	printf("%d\n", ans);
}


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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Functional
namespace fun{
	template<typename U> auto map(const auto& a, auto f){Arr<U> r; for(const auto& x:a)r.pushb(f(x)); return r;}
	template<typename T> auto reduce(const auto& a, T acc){ return accumulate(all(a),acc); }
	template<typename T> auto reduce(const auto& a, T acc, auto f){ return accumulate(all(a),acc,f); }
	template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
	Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
	struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
	#define defer(x) auto _##__COUNTER__ = fun::defer([&](){x;});
	#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
}

//Misc
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
int pow2ceil(int x){assert(x);return 1<<(32-__builtin_clz(x-1));}

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int k; cin>>k;
	string s; cin>>s;
	cout<<s.substr(0,k);
	if(sz(s)>k) cout<<"..."<<endl;
	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.next();
		int a = Integer.parseInt(String.valueOf(in.charAt(0)));
		int b = Integer.parseInt(String.valueOf(in.charAt(1)));
		int c = Integer.parseInt(String.valueOf(in.charAt(2)));
		int d = Integer.parseInt(String.valueOf(in.charAt(3)));
		if(a+b+c+d==7)System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
		else if(a+b+c-d==7)System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
		else if(a+b-c+d==7)System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
		else if(a-b+c+d==7)System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
		else if(a+b-c-d==7)System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
		else if(a-b+c-d==7)System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
		else if(a-b-c+d==7)System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
		else if(a-b-c-d==7)System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");
	}
}

Measured memory_bytes: 21716
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int a,b;

main(){
	cin>>a>>b;
	if(a<=0&&b>=0)dump("Zero");
	else if(a>0&&b>0)dump("Positive");
	else{
		if((b-a)%2==0)dump("Negative");
		else dump("Positive");
	}
}

Measured memory_bytes: 256
// ryan in ny / per jorner fills in: derivative code
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    
    vector<int> v(q + 10);
    rep(i, 0, q) cin >> v[i], v[i]--;
    
    vector<int> waiting(m + 10, 0);
    waiting[0] = n;
    vector<int> pos(m + 10, -1);
    int built = 0;
    vector<int> order(m + 10, -1);
    
    per(i, 0, q) {
        if (pos[v[i]] != -1) {
            if (waiting[pos[v[i]]]) {
                waiting[pos[v[i]]]--;
                waiting[pos[v[i]] + 1]++;
            }
        } else {
            pos[v[i]] = built;
            assert(waiting[built]);
            waiting[built]--;
            waiting[built + 1]++;
            order[built] = v[i];
            built++;
        }
    }
    
    int mn = m;
    rep(i, 0, n) if (pos[i] == -1) {
        mn = i;
        break;
    }
    if (mn != m) order[built] = mn;
    //cout << mn << endl;
    
    //rep(i, 0, m) cout << order[i] << ": " << waiting[i] << endl;
    
    
    
    bool ok = true;
    per(i, 0, m - 1) {
        if (order[i + 1] != -1 && order[i] > order[i + 1]) ok = false;
        if (!ok && waiting[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left"<<endl;
    else if(a+b<c+d) cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX],finv[MAX],inv[MAX];
typedef vector<vector<int> > Graph;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    vector<int> ans;
    vector<set<int>> t(26);
    for(int i=0;i<s.size();i++){
        t[s[i]-'a'].insert(i);
    }
    int q;cin>>q;
    for(int i=0;i<q;i++){
        int f;cin>>f;
        if(f==1){
            int a;cin>>a;
            a--;
            char b;cin>>b;
            t[s[a]-'a'].erase(a);
            s[a]=b;
            t[s[a]-'a'].insert(a);
        }
        else{
            int cnt=0;
            int a,b;cin>>a>>b;
            a--;
            for(int i=0;i<26;i++){
                auto it=t[i].lower_bound(a);
                if(it!=t[i].end()&&*it<b){
                    cnt++;
                }
            }
            ans.push_back(cnt);
        }
    }
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}

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


int main() {
	string s1;
	cin >> s1;
	int l=s1.size();
	int res=0;
	for(int i=0; i<s1.size(); i++){
		if(s1[i] != s1[l-1-i]) res++;
	}
	if(res % 2 == 0){
		cout << res/2 << endl;
	}else{
		cout << (res-1)/2+1 << endl;
	}

}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String n = scanner.nextLine();
        for (int i = 0; i < n.length(); i++) {
            if (n.charAt(i) == '9') {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23892
#include <cstdio>

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b)) puts("Yes");
  else puts("No");
  return 0;
}


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


using namespace std;
using ll = long long;
using vl = vector<ll>;
 
int main() {
  string s; cin >> s;
  if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])
     ||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
<?php
define("MOD", 10 ** 9 + 7);
list($n, $k) = ints();
for ($i = 0; $i < $n - 1; ++$i) {
    list($a, $b) = ints();
    --$a;
    --$b;
    $g[$a][] = $b;
    $g[$b][] = $a;
}
init($k);
echo dfs();
function dfs($v = 0)
{
    global $g, $seen, $k;
    $seen[$v] = true;

    if ($v === 0) {
        if (is_null($g[$v])) return $k;
        if ($k - 1 < count($g[$v])) return 0;
        $res = modMul($k, nPr2($k - 1, count($g[$v])));
    } else {
        if (is_null($g[$v])) return 1;
        if ($k - 2 < count($g[$v]) - 1) return 0;
        $res = nPr2($k - 2, count($g[$v]) - 1);
    }
    foreach ($g[$v] as $to) {
        if ($seen[$to]) continue;
        $res = modMul($res, dfs($to));
    }
    return $res;
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($n)
{
    global $fact, $ifact;
    $fact[0] = 1;
    for ($i = 1; $i <= $n; ++$i) $fact[$i] = modMul($fact[$i - 1], $i);
    $ifact[$n] = modDiv(1, $fact[$n]);
    for ($i = $n; $i >= 1; --$i)
        $ifact[$i - 1] = modMul($ifact[$i], $i);
}
// 順列（前処理）
function nPr2($n, $r)
{
    global $fact, $ifact;
    return modMul($fact[$n], $ifact[$n - $r]);
}
// 組み合わせ（前処理）
function nCr2($n, $r)
{
    global $fact, $ifact;
    return modMul(modMul($fact[$n], $ifact[$r]), $ifact[$n - $r]);
}


Measured memory_bytes: 124496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N;
    cin >> N;
    ll A, ans=0, MIN=1e15, neg=0;
    bool haveZERO=false;
    rep(i, N) {
        cin >> A;
        if(0==A) haveZERO = true;
        neg += (A<0);
        A = abs(A);
        ans += A;
        chmin(MIN, A);
    }
    
    if(haveZERO or neg%2==0) cout << ans << nl;
    else                   cout << ans - 2*MIN << nl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int N, a, count = 0, posi = 1;
    cin >> N;
    
    for(int i = 0; i < N; i++){
        cin >> a;
        if(posi != a){
            count++;
        }
        else{
            posi++;
        }
        
        if(N == count){
            count = -1;
        }
    }
    
    cout << count << endl;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
 string s;
 int cnt=1;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	
 	cin>>s;
 	for(int i=1;i<s.size();i++){
 		if(s[i]==s[i-1]){
 			cnt++;
 		}
 		else
 			cnt=1;
 		if(cnt==3)
 			break;
 	}
	if(cnt==3)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<iomanip>
using namespace std;
int n,x,c2=0,c4=0;
bool flag=false;
int read(){
    int ans=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();}
    return ans*f;
}
int main(){
	std::ios::sync_with_stdio(false);
	n=read();
	for (int i=0;i<n;i++){
		x=read();
		if (x%4==0)	c4++;
		else if (x%2==0) c2++;
	}
	if (c2==n) {cout<<"Yes";return 0;}	else if (!c4) {cout<<"No";return 0;}
	if (c2){n-=c2+1;c4-=1;flag=true;}
	if (c4>=(n/2)||((n<=1)&&flag)) cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
class WeightedUnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n+1)]
    self.rank = [0] * (n+1)
    # 根への距離を管理
    self.weight = [0] * (n+1)

  # 検索
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      y = self.find(self.par[x])
      # 親への重みを追加しながら根まで走査
      self.weight[x] += self.weight[self.par[x]]
      self.par[x] = y
      return y

  # 併合
  def union(self, x, y, w):
    rx = self.find(x)
    ry = self.find(y)
    # xの木の高さ < yの木の高さ
    if self.rank[rx] < self.rank[ry]:
      self.par[rx] = ry
      self.weight[rx] = w - self.weight[x] + self.weight[y]
    # xの木の高さ ≧ yの木の高さ
    else:
      self.par[ry] = rx
      self.weight[ry] = -w - self.weight[y] + self.weight[x]
      # 木の高さが同じだった場合の処理
      if self.rank[rx] == self.rank[ry]:
        self.rank[rx] += 1

  # 同じ集合に属するか
  def same(self, x, y):
    return self.find(x) == self.find(y)

  # xからyへのコスト
  def diff(self, x, y):
    return self.weight[x] - self.weight[y]

N, M = map(int, input().split())

wuf = WeightedUnionFind(N)

for _ in range(M):
  l, r, d = map(int, input().split())
  if wuf.same(l,r):
    if wuf.diff(l,r) != d:
      print('No')
      exit()
  else:
    wuf.union(l,r,d)
    
print('Yes')


Measured memory_bytes: 84400
import math
a=[]
while True:
    tmp=int(input())
    if tmp==0:
        break
    tmp1=[]
    tmp1.append(tmp)
    tmp1.append(list(map(int,input().split(" "))))
    a.append(tmp1)
for i in a:
    ave=sum(i[1])/i[0]
    sgm=math.sqrt(sum([(i[1][j]-ave)**2 for j in range(i[0])])/i[0])
    print(sgm)


Measured memory_bytes: 5704
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;


int k, x;

int main() {
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; ++i) {
		cout << i << " \n"[i == x + k - 1];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000
#define M 1000
#define mp make_pair
#define X first
#define Y second
#define pb push_back
char s[N+1][M+1];
vector<pair<int,int> > blk,wb_blk;
int main(){
	const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	int n,m,ans=0,i,j;scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)
		if(s[i][j]=='#')blk.pb(mp(i,j));
	while(blk.size()){
		for(i=0;i<blk.size();i++){
			int x=blk[i].X,y=blk[i].Y;
			for(j=0;j<4;j++){
				int xx=x+dx[j],yy=y+dy[j];
				if(s[xx][yy]=='.')wb_blk.pb(mp(xx,yy)),s[xx][yy]='#';
			}
		}
		blk.swap(wb_blk);wb_blk.clear();
		ans++;
	}
	printf("%d\n",ans-1);
	return 0;
}
/*1
3 3
...
.#.
...
*/
/*2
6 6
..#..#
......
#..#..
......
.#....
....#.
*/

Measured memory_bytes: 13032
'use strict';

const main = arg => {
  const [a, b, c, d] = arg.trim().split(' ').map(x => BigInt(x));
  var ans = a * c;
  if (ans < a * d) ans = a * d;
  if (ans < b * c) ans = b * c;
  if (ans < b * d) ans = b * d;
  console.log(ans.toString());
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30608
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    string s,t;
    int count = 0;
    cin >> s >> t;
    for(int i = 0; i < s.size();i++)
    {
        if(s[i] == t[i])
        {
            count++;
        }
    }
    if( s.size() == count )
    {
        cout << "Yes" <<endl;
    }else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

deque<char>q; 
int main() {
  string S;
  cin>>S;
  int Q;
  cin>>Q;
  for(char c:S){
    q.push_back(c);
  }
  int count=0;
  rep(i,Q){
    int f;
    char c;
    cin>>f;
    if(f==1){
      count++;
    }else{
      int f2;
      cin>>f2>>c;
      if(f2==1){
        if(count%2==0){
          q.push_front(c);
        }else{
          q.push_back(c);
        }
      }else{
        if(count%2==0){
          q.push_back(c);
        }else{
          q.push_front(c);
        }      
      }
    }
  }
  if(count%2==1){
    reverse(begin(q),end(q));
  }
  for(char c:q){
    cout<<c;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout<< "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};

mint Pow(ll m, ll n){
	if(n==0) return 1;
	mint x = Pow(m,n/2);
	x *= x;
	if(n%2==1) x *= m;
	return x; 
}

mint choose(ll n, ll a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

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

	mint two = Pow(2,n);
	mint ans = two - 1 - choose(n,a) - choose(n,b);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main ()
{
   int num, i, j, swap, a[3];

   num = 3;

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

   for (i = 0; i < num - 1; i++) {
      for (j = 0; j < num -1; j++) {

         if (a[j] > a[j+1]) {
            swap =a[j];
            a[j] = a[j+1];
            a[j+1] = swap;
         }
      }
   }

   for (i = 0; i < num; i++) {
      if (i == num-1) {
         printf("%d\n", a[i]);
      } else {
         printf("%d ", a[i]);
      }
   }

   return 0;

}

 
   

 

Measured memory_bytes: 1816
#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
map<int, int> m;
int N, result;

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        int num;
        scanf("%d", &num);
        m[num]++;
    }
    map<int, int>::iterator it;
    for(it = m.begin(); it != m.end(); it++)
    {
        if(it->first > it->second)
        {
            result += it->second;
        }
        else if(it->first < it->second)
        {
            result += it->second - it->first;
        }
    }
    printf("%d", result);
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int Stack[1000];
int top = 0;

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

int pop()
{
    return Stack[top--];
}

int main()
{
    int a, b;
    char Str[100];

    while (scanf("%s", &Str) != EOF)
    {
        if (Str[0] == '+')
        {
            b = pop();
            a = pop();
            push(a + b);
        }
        else if (Str[0] == '-')
        {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if (Str[0] == '*')
        {
            b = pop();
            a = pop();
            push(a * b);
        }
        else
        {
            push(atoi(Str));
        }
    }

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

    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(ll i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
 
ll nC2(ll n) {
  return n*(n-1)/2;
} 
 
int main(void) {
  ll n;cin>>n;
  vector<ll> a(n+1, 0);
  Fr(i, n) cin>>a[i];
  fr(i, n) a[i+1] = a[i+1] + a[i];
  sort(a.begin(), a.end());
  ll ans = 0, c = 1;
  a.push_back(-10e10);
  fr(i, n+1) {
    if(a[i] == a[i+1]) c++;
    else {
      ans += nC2(c);
      c=1;
    }
  }

  cout << ans << endl;


  return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s,a;
    cin >> s;
    int c = s[0];
    if(c=='S'){
        a = "Cloudy";
    }else if(c=='C'){
        a = "Rainy";
    }else {
        a = "Sunny";
    }
    cout<< a << "\n";
    return 0;
}

Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())

if x<(a*a*b/2):
    c=x*2/a/b
    print(math.degrees(math.atan(b/c)))

else:
    c=(a*a*b*2-x*2)/a/a
    print(math.degrees(math.atan(c/a)))

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

int main(){
	int n;	cin>>n;
	string s;	cin>>s;
	int ans=0;



	for(int a=0;a<n-1;a++){
		int alpha[26]={0};
		int sum=0;

		for(int i=0;i<=a;i++){ // 前半
			if(alpha[s[i]-'a']==0)alpha[s[i]-'a']=1;
		}

		for(int j=a+1;j<n;j++){ // 後半
			if(alpha[s[j]-'a']==1){
				sum++;
				alpha[s[j]-'a']=100;
			}
		}
		if(sum>ans)ans=sum;
	}




	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    ll n,t,k,a,b,d,c;
    
cin>>a>>b;
if((a>=1&&a<=9)&&(b>=1&&b<=9))
   cout<<a*b;
   else
   cout<<-1;
    
    
    
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let k = it.next().unwrap().parse::<usize>().unwrap();
    let x = (0..n).map(|_| it.next().unwrap().parse::<i32>().unwrap()).collect::<Vec<_>>();
    let mut res = 1_000_000_000;
    for i in 0..n-k+1 {
        if x[i+k-1] < 0 {
            res = std::cmp::min(res, -x[i]);
        } else if x[i] > 0 {
            res = std::cmp::min(res, x[i+k-1]);
        } else {
            res = std::cmp::min(res, 2*x[i+k-1]-x[i]);
            res = std::cmp::min(res, x[i+k-1]-2*x[i]);
        }
    }
    println!("{}", res);
}


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

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

    int trend = 0;
    int res = 1;
    for(int i = 0; i<N - 1; i++) {
        if(trend == 1 && a[i] > a[i + 1]) {
            trend = 0;
            res++;
        } else if (trend == -1 && a[i] < a[i + 1]) {
            trend = 0;
            res++;
        }
        else if ( trend == 0 && a[i] < a[i + 1]) trend = 1;
        else if ( trend == 0 && a[i] > a[i + 1]) trend = -1;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

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

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N)
{
    cout << (N * N * N) << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head=0, tail, n;

void enqueue(P x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t = x.t;
  tail++;
  if(tail == LEN){
    tail = 0; 
  }
}




int main(){
  int elaps = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail = n;

  while(tail!=head){
    if(Q[head].t > q){
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);

    }
    else{
      elaps+=Q[head].t; 
      printf("%s %d\n",Q[head].name,elaps);

    }
    head++;
    if(head == LEN){
      head = 0;
    }
  }  
  return 0;
}

Measured memory_bytes: 10768
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
string s;
long n;
inline void solve(void){
  in(s);
  out(~s.find("F",s.find("C"))?"Yes":"No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <cstdio>

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */

int main () {
	int A; 	// 1タップの口数(2≦A≦20)
	int B;	// 最低必要口数(1≦B≦20)
	int n;	// タップの数

	// 読込み
	scanf("%d %d", &A, &B);
	// 
	if(B == 1) n = 0;
	n = (B - 1) / (A - 1);
	n += ((B - 1) % (A - 1) > 0);						// n(A-1)+1≧B
	
	printf("%d\n", n);
	return 0;
}

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

string solve(int K)
{
    int count = 0;
    vector<string> list = vector<string>();

    for (int64_t i = 1; i < 10; i++)
    {
        string s = to_string(i);
        count++;
        if (count == K)
        {
            return s;
        }
        list.push_back(s);
    }

    while (true)
    {
        vector<string> prev_list = list;
        list = vector<string>();
        for (auto &&s : prev_list)
        {
            int tail = s.at(s.length() - 1) - '0';
            if (tail > 0)
            {
                string s1 = s + to_string(tail - 1);
                count++;
                if (count == K)
                {
                    return s1;
                }
                list.push_back(s1);
            }
            string s2 = s + to_string(tail);
            count++;
            if (count == K)
            {
                return s2;
            }
            list.push_back(s2);
            if (tail < 9)
            {
                string s3 = s + to_string(tail + 1);
                count++;
                if (count == K)
                {
                    return s3;
                }
                list.push_back(s3);
            }
        }
    }
}

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

    cout << solve(K) << endl;
}

Measured memory_bytes: 4384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if (a < b)
            System.out.println("a < b");
        else if (a > b)
            System.out.println("a > b");
        else
            System.out.println("a == b");
    }
}


Measured memory_bytes: 26312
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, k;
string str;
 
ll cal(ll n, ll k){
	if(n >= k){return 0;}
	
	ll r = 0;
	for(;n < k;r++){n *= 2;}
	return r;
}
 
int main(){
	cin >> n >> k;
	
	long double ans = 0.0;
	
	//cout << powl(2, 3) << endl;
	ll bunbo = powl(2, cal(n, k));
	
	for(ll i = 1; i <= n; i++){
		ans += 1.0 / pow(2, cal(i, k));
	}
	//long double ans = buf/bunbo;
	ans /= n;
	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {

	int i = 0;
	int x = 0;
	int y = 0;

	while(1){
		scanf("%d",&x);
		scanf("%d",&y);
		
		if(!x && !y){
			break;
		}
		
		if( x > y){
			i = x ;
			x = y ;
			y = i ;
		}
		
		printf("%d %d\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 600
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int hashe[26];
void solve()
{
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++)
	{
		hashe[s[i] - 'A']++;
	}
	int x = 0;
	for (int i = 0; i < 26; i++)
	{
		if (hashe[i] == 2)
		{
			x++;
		}
	}
	if (x == 2)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}
int main()
{
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int N = S.size(),X = 0;
  for(int i=0; i < N; i++){
    if (S[i] != T[i]){
      X += 1;
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 3888
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL add(LL a, LL b) { return (a + b) % kMod; }

int main() {
  int N, M; cin >> N >> M;
  set<LL> A;
  for (int i = 0; i < M; ++i) {
    int a; cin >> a; A.insert(a);
  }

  vector<LL> dp(N + 1); dp[0] = 1;
  dp[1] = (A.count(1)) ? 0 : 1;

  for (int i = 2; i <= N; ++i) {
    if (A.count(i)) {
      dp[i] = 0;
    } else {
      dp[i] = add(dp[i-2], dp[i-1]);
    }
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 8700
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <deque>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

int main() {
	int n, d;	cin >> n >> d;
	vector<int> dist(n);
	vector<int> left(n + 1);
	left[0] = d;
	for (int i = 0; i < n; i++) {
		cin >> dist[i];
		left[i + 1] = min(left[i], abs(left[i] - dist[i]));
	}
	int q;	cin >> q;
	vector<pii> query(q);
	for (int i = 0; i < q; i++) {
		cin >> query[i].fst;	query[i].fst--;
		query[i].scn = i;
	}
	vector<bool> ret(q, false);
	sort(query.begin(), query.end());
	reverse(query.begin(), query.end());
	int reach = 1;
	int s = 0;
	for (int i = n - 1; i >= 0; i--) {
		while (s < q&&query[s].fst == i) {
			if (left[i] < reach)	ret[query[s].scn] = true;
			else	ret[query[s].scn] = false;
			s++;
		}
		if (2 * reach > dist[i])	reach += dist[i];
	}
	for (int i = 0; i < q; i++)	cout << (ret[i] ? "NO" : "YES") << endl;
	return 0;
}

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

int main(){
  int M, N;
  string A[50];
  string B[50];
  cin >> N >> M;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<M; i++) cin >> B[i];
  for(int i=0; i<N-M+1; i++){
    for(int j=0; j<N-M+1; j++){
      bool flag = true;
      for(int k=0; k<M; k++){
        for(int l=0; l<M; l++){
          if(A[i+k][j+l]!=B[k][l]){
            flag = false;
            break;
          }
        }
        if(!flag) break;
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import defaultdict

h, w = map(int, input().split())
s = [input() for _ in range(h)]

class UnionFind:
    def __init__(self, n):
        self.rank = [0]*n
        self.parent = [i for i in range(n)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        elif self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(h * w)
for i in range(h):
    for j in range(w):
        if j < w-1:
            if s[i][j] != s[i][j + 1]:
                uf.merge(i*w + j, i*w + j + 1)
        if i < h-1:
            if s[i][j] != s[i+1][j]:
                uf.merge(i*w + j, (i+1)*w + j)

d_w = defaultdict(int)
d_b = defaultdict(int)
for i in range(h):
    for j in range(w):
        parent = uf.find(i*w + j)
        if s[i][j] == ".":
            d_w[parent] += 1
        else:
            d_b[parent] += 1

ans = 0
for i in range(h):
    for j in range(w):
        ans += d_w[i*w + j] * d_b[i*w + j]

print(ans)





Measured memory_bytes: 35720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int n;
	while(scanf("%d",&n)&&n>=1000&&n<=9999)
	{ 
		int a[5];
		memset(a,0,sizeof(a));
		for(int i=1;i<=4;i++)
		{
			a[i]=(n%10);
			n=n/10;
		}
		int flag=0;
		if(a[2]==a[3])
		{
			if(a[1]==a[3])flag=1;
			if(a[4]==a[3])flag=1;
		}
		if(flag==1)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;	
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n <= 999) {
		cout << "ABC";
	
	}
	else {
		cout << "ABD";
	}
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());

		Set<Integer> set = new HashSet<>();

		IntStream.range(0, n).forEach(i -> {int a = Integer.parseInt(sc.next());
											if (!set.add(a)) set.remove(a);}
									 );

		System.out.println(set.size());

		sc.close();
	}
}

Measured memory_bytes: 51568
eval'N,K,*A='+`dd`.split*?,
K.times{
	b=[0]*-~N
	N.times{
		b[[0,_1-A[_1]].max]+=1
		b[[N,_1-~A[_1]].min]-=1
	}
	b.pop
	t=0
	A=b.map{t+=_1}
	A.min<N||break
}
p *A


Measured memory_bytes: 99724
#include <stdio.h>

struct Node{
    int num;
    Node* parent;
    Node* left;
    Node* right;
};

Node node[25];

int get_root(int n){
    struct Node *nd = &(node[0]);
    while(nd){
        if(nd->parent){
            nd = nd->parent;
        }else{
            return nd->num;
        }
    }
    return -1;
}

void pre_order(int n){
    struct Node *l = node[n].left;
    struct Node *r = node[n].right;

    printf(" %d", node[n].num);
    if(l)
        pre_order(l->num);
    if(r)
        pre_order(r->num);
}

void in_order(int n){
    struct Node *l = node[n].left;
    struct Node *r = node[n].right;

    if(l)
        in_order(l->num);
    printf(" %d", node[n].num);
    if(r)
        in_order(r->num);
}

void post_order(int n){
    struct Node *l = node[n].left;
    struct Node *r = node[n].right;

    if(l)
        post_order(l->num);
    if(r)
        post_order(r->num);
    printf(" %d", node[n].num);
}

void output(int n){
    int root_num = get_root(n);
    printf("Preorder\n");
    pre_order(root_num);
    printf("\n");

    printf("Inorder\n");
    in_order(root_num);
    printf("\n");

    printf("Postorder\n");
    post_order(root_num);
    printf("\n");
}


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

    for(int i; i < n; i++){
        node[i].parent = NULL;
        node[i].left = NULL;
        node[i].right = NULL;
    }

    for(int i = 0; i < n; i++){
        int num, a, b;
        scanf("%d %d %d", &num, &a, &b);
        node[num].num = num;

        if(a != -1){
            node[num].left = &(node[a]);
            node[a].parent = &(node[num]);
        }
        if(b != -1){
            node[num].right = &(node[b]);
            node[b].parent = &(node[num]);
        }
    }

    output(n);
}



Measured memory_bytes: 2672