akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    long long a, b, c, d;
    cin>>a>>b>>c;
    d = c -a -b;
    if(d > 0 && 4 * a* b < d* d){
        cout << "Yes" << endl;
    }else{            
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main
import "fmt"

func Max(x,y int) int{
  if x >= y{
    return x
  }
  return y
}

func Min(x,y int) int{
  if x <= y{
    return x
  }
  return y
}

func main(){
  var a,b,c,d int
  fmt.Scan(&a, &b, &c, &d);
  fmt.Println(Max(Min(b,d) - Max(a,c), 0))
}

Measured memory_bytes: 512
var
    i,n:longint;
    l:array[0..86]of int64;
begin
    readln(n);
    
    l[1]:=1;
    
    l[0]:=2;
    for i:=2 to n do l[i]:=l[i-1]+l[i-2];
    writeln(l[n]);
end.

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

int main() {
	int t;
	int hh,mm,ss;
	cin >> t;
	hh = t / 3600;
	mm = (t % 3600) / 60;
	ss = t % 60;
	
	cout << hh << ":" << mm << ":" << ss << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;


class Solution{

public:
    bool isHaiku(vector<int>& lines){

        sort(lines.begin(), lines.end());
        return lines[0] == 5 && lines[1] == 5 && lines[2] == 7;
    }
};

int main() {

    vector<int> lines(3);
    for(int i = 0; i < 3; i ++)
        scanf("%d", &lines[i]);

    printf("%s\n", Solution().isHaiku(lines) ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
using namespace std;
int main() {
	int price, mount, sum, cnt;
	char c;
	double ave;
	while( cin >> price >> c >> mount ){
		sum += price * mount;
		ave += mount;
		cnt++;
	}
	cout << sum << endl;
	cout << (int)((ave/ cnt) + 0.5) << endl;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int n,h[25],ans=1,pd;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		pd=1;
		cin>>h[i];
		if(i>=2){
			for(int j=1;j<i;j++)
				if(h[i]<h[j])
					pd=0;
			if(pd)
				ans++;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

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

    ll h, w, c;
    char tmp;
    cin >> h >> w;
    vvll grid (h, vll(w, 0));
    vvll dp (h, vll(w, inf));

    //初期値を入力
    REP(i, h){
        REP(j, w){
            cin >> tmp;
            grid[i][j] = (tmp == '#')? 1 : 0;//.だけ通れるからtrue
        }
    }
    //初期化
    dp[0][0] = grid[0][0];
    //各点までの最小flip回数をdpで求めていく. 行と列それぞれについて隣り合う#がないか調べて, あればまとめてひっくり返す.
    REP(i, h){
        REP(j, w){
            if (i > 0){
                c = grid[i][j];
				if(grid[i-1][j] == 1) c = 0;//行方向の隣が#ならひっくり返しはない
				dp[i][j] = min(dp[i-1][j] + c, dp[i][j]);
			}
            if (j > 0){
                c = grid[i][j];
				if(grid[i][j-1] == 1) c = 0;//列方向の隣が#ならひっくり返しはない
				dp[i][j] = min(dp[i][j-1] + c, dp[i][j]);
			}
        }
    }

    cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll MAXN=105;
const ll MOD=1e9+7;

ll n,m;
ll a[MAXN];
ll d[MAXN][MAXN*2][MAXN*2];

int main(){
    scanf("%lld",&n); m=2*n-1;
    for(ll i=1;i<=m;i++) scanf("%lld",&a[i]);
    sort(a+1,a+m+1);
    d[n][0][0]=1;
    for(ll i=n;i>1;i--){
        ll l=(a[i]!=a[i-1]),r=(a[m-i+1]!=a[m-i+2]);
        for(ll j=0;j<=m;j++)
            for(ll k=0;k<=m;k++){
                if(!d[i][j][k]) continue;
                d[i-1][j+l][k+r]=(d[i-1][j+l][k+r]+d[i][j][k])%MOD;
                for(ll dl=0;dl<j+l;dl++) (d[i-1][dl][k+r+1]+=d[i][j][k])%=MOD;
                for(ll dr=0;dr<k+r;dr++) (d[i-1][j+l+1][dr]+=d[i][j][k])%=MOD;
            }
    }
    ll ans=0;
    for(ll i=0;i<=m;i++)
        for(ll j=0;j<=m;j++)
            ans=(ans+d[1][i][j])%MOD;
    printf("%lld\n",ans);
}


Measured memory_bytes: 17280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long a = inputLongArray[0];
            long b = inputLongArray[1];

            string result = "Odd";
            if ((a*b)%2 == 0)
            {
                result = "Even";
            }
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

#define go(i,a,b) for(int i=a;i<=b;++i)
#define com(i,a,b) for(int i=a;i>=b;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define fo(i,a) for(int i=0;i<a;++i)
#define il inline
#define int long long

const int inf=0x3f3f3f3f,N=2010,mod=1e9+7;

int n,m,dp[N];

il void read(int &x){
	x=0;char c=getchar(),f=1;
	while(!isdigit(c)){ if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)){ x=x*10+c-'0'; c=getchar(); }
	x*=f;
}

signed main(){
	//freopen("input.txt","r",stdin);
	read(n),read(m);
	dp[n]=1;
	go(i,1,m){
		com(j,n,1){
			if(n-j+1<i) dp[j]=0;
			else (dp[j]+=dp[j+1])%=mod;
		}
	}
	int ans=1;
	go(i,1,n-m-1) ans=ans*2%mod;
	printf("%lld",ans*dp[1]%mod);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int H, W;
  cin >> H >> W;
  string s;
  for (int i = 0; i < (int)(H); ++i) {
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
  return 0;
}


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

int main()
{
  string str; cin >> str;
  bool n = false, s = false, e = false, w = false;
  for (auto c : str) {
	if (c == 'N') n = true;
    if (c == 'S') s = true;
    if (c == 'E') e = true;
    if (c == 'W') w = true;
  }
  if (n == s and e == w)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
/*----------------------------------------------------------------------*/

int n, a[22][22];
ll dp[22][2097153];

ll solve(int curr, ll mask) {
	if(curr == n) return 1;

	if(dp[curr][mask] != -1) return dp[curr][mask];
	ll ret = 0;

	F(j, 0, n) {
		if(a[curr][j] && !(mask & (1 << j))) {
			ret += solve(curr+1, (mask | (1 << j)));
			ret %= MOD;
		}
	}

	return dp[curr][mask] = ret;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
   	cin>>n;
   	F(i, 0, n) {
   		F(j, 0, n) {
   			cin>>a[i][j];
   		}
   	}

   	memset(dp, -1, sizeof(dp));
   	cout<<solve(0, 0);

    return 0;
}/*

*/

Measured memory_bytes: 360704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (;;) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3624
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

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

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

vvll edges;

ll dfs(ll i, ll p) {
    ll ret = 0;
    for (ll e: edges[i]) {
        if (e == p) continue;
        ret ^= dfs(e, i) + 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    edges.resize(n);
    REP(i, n - 1) {
        ll x, y; cin >> x >> y;
        edges[x - 1].emplace_back(y - 1);
        edges[y - 1].emplace_back(x - 1);
    }

    ll grun = dfs(0, -1);
    if (grun == 0) cout << "Bob\n";
    else cout << "Alice\n";
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define int long long
using namespace std;

int ans = 0, h, w, a, b;

int factorialNumInverse[200002], naturalNumInverse[200002], fact[200002], dp[200002], mod = 1e9 + 7;

int add(int x, int y) {
    return ((x % mod) + (y % mod)) % mod;
}

int sub(int x, int y) {
    return ((x % mod) - (y % mod) + mod * mod) % mod;
}

int mul(int x, int y) {
    return ((x % mod) * (y % mod)) % mod;
}

void InverseofNumber(int mod) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= 200000; i++) {
        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod; 
    }
}

void InverseofFactorial(int mod) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
    for (int i = 2; i <= 200000; i++) {
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
    }
} 
  
void factorial(int mod) 
{ 
    fact[0] = 1;
    for (int i = 1; i <= 200000; i++) { 
        fact[i] = (fact[i - 1] * i) % mod;  
    } 
}

int nCr(int N, int R) { 
    if(N < R || N <= 0 || R <= 0) return 1;
    return ((fact[N] * factorialNumInverse[R]) % mod * factorialNumInverse[N - R]) % mod; 
}

signed main() {
    InverseofNumber(mod); 
    InverseofFactorial(mod); 
    factorial(mod);
    cin >> h >> w >> a >> b;
    for(int i = 1; i <= h - a; i++) {
        ans = add(ans, mul(nCr(i + b - 2, b - 1), nCr(h - i + 1 + w - b - 2, w - b - 1)));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4992
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 200000
using namespace std;

typedef pair< int, int > pii;

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

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

  pii c[MAX_N];
  for(int i = 0; i < n; i++){
    c[i] = make_pair(a[i], i);
  }
  sort(c, c + n);
  int d[n];
  for(int i = 0; i < n; i++){
    d[c[i].second] = i;
  }

  int b[n];
  for(int i = 0; i < n; i++){
    if(d[i] < (n / 2)) b[i] = c[n / 2].first;
    else b[i] = c[n / 2 - 1].first;
  }

  string buf;
  for(int i = 0; i < n; i++){
    buf += to_string(b[i]) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
H a[200000];
int mi = Inf, ma = 0;
struct A {
	int x, y;
	bool operator<(const A &a) {
		int r = min(mi - a.x, a.y - ma);
		int k = min(mi - x, y - ma);
		return k < r;
	}
};
signed main() {
	cin >> n;
	int rmax = 0, rmin = Inf, bmax = 0, bmin = Inf;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
		if (a[i].x > a[i].y) swap(a[i].x, a[i].y);
		rmax = max(rmax, a[i].x);
		rmin = min(rmin, a[i].x);
		bmax = max(bmax, a[i].y);
		bmin = min(bmin, a[i].y);
	}
	int ans = (rmax - rmin)*(bmax - bmin);
	multiset<int>se;
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		se.insert(a[i].y);
	}
	for (int i = 0; i < n; i++) {
		se.erase(se.find(a[i].y));
		se.insert(a[i].x);
		ans = min(ans, (bmax - rmin)*(*prev(se.end()) - *(se.begin())));
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
N, K = map(int,input().split())
p = list(map(int,input().split()))

X = []

for i in p:
  X.append((i + 1) / 2)

fK = 0
for i in range(K):
  fK += X[i]

X_sum = [fK]

for i in range(N - K):
  X_sum.append(X_sum[i] - X[i] + X[i+K])

print(max(X_sum))
  

Measured memory_bytes: 24804
#!/usr/bin/env python3
from collections import Counter
import sys
sys.setrecursionlimit(10**6)


n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

ans = 0
for i in sorted(c.keys()):
    if c[i] < i:
        ans += c[i]
    elif c[i] == i:
        continue
    elif c[i] > i:
        ans += c[i]-i
print(ans)


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

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

int main(){
	int a;
	cin>>a;
	int b[a];
	rep(i, a){
		cin>>b[i];
	}
	int c = 0;
	rep(i, a){
		rep(j, a){
			if(i != j){
				c += b[i] * b[j];
			}
		}
	}
	cout<<c / 2<<endl;
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	vector<int> a;
	REP(i, 3) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	sort(a.begin(), a.end());
	long long ans = 10000;
	do {
		long long pre_ans = abs(a[1] - a[0]) + abs(a[2] - a[1]);
		ans = min(ans, pre_ans);
	} while (next_permutation(a.begin(), a.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

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

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	UnionFind uf(n + m);
	rep(i, n)
	{
		int k; cin >> k;
		rep(j, k)
		{
			int l; cin >> l;
			--l;
			uf.merge(i, n + l);
		}
	}
	bool ok = true;
	rep(i, n)
	{
		if (!uf.issame(0, i))ok = false;
	}
	if (ok)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int n, h, w;

int main() {
  cin >> n >> h >> w;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (h <= a && w <= b) ++res;
  }
  cout << res << endl;
  return 0;
}


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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

// abc 129 -c
int main() {
    // int n, w;
    int cBag, mxWgt;
    cin >> cBag >> mxWgt;
    // const int N_MAX = 100, WIGHT_MAX = 100000, VALUE_MAX = 1000000000;

    // value[idx][wight] = value;
    vector<int> wight(cBag);
    vector<int> value(cBag);
    rep(i, 0, cBag) { cin >> wight[i] >> value[i]; }

    // dp[bag_idx][sum_wight]
    vector<vector<ll>> dp(cBag, vector<ll>(mxWgt + 1, 0));
    repe(w, wight[0], mxWgt) dp[0][w] = value[0];

    rep(idxBag, 1, cBag) {
        repe(sumWgt, 0, mxWgt) {
            if (sumWgt >= wight[idxBag]) {
                dp[idxBag][sumWgt] = max(dp[idxBag - 1][sumWgt],
                                         dp[idxBag - 1][sumWgt - wight[idxBag]] + value[idxBag]);
                // dp[i + 1][w]         = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
                // dp[idxBag + 1][sumWgt] = max(dp[idxBag][sumWgt - wight[idxBag]] + value[idxBag],
                // dp[idxBag][sumWgt]);
            } else {
                // dp[i + 1][w] = dp[i][w];
                dp[idxBag][sumWgt] = dp[idxBag - 1][sumWgt];
            }
        }
    }

    // std::cout << "i 01 02 03 04 05 06 07 08" << endl;
    // rep(i, 0, cBag) {
    //     std::cout << i << " ";
    //     repe(j, 0, mxWgt) { std::cout << dp[i][j] << " "; }
    //     std::cout << endl;
    // }

    cout << dp[cBag - 1][mxWgt] << endl;
    return 0;
}



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

int main(void){
    int h, w; cin >> h >> w;
    vector<string> mass(h+2);

    for(int i=0;i<h+2;i++){
        if(i==0 || i==h+1){
            for(int j=0;j<w+2;j++)mass[i]+='.';
        }else{
            string a; cin >> a;
            mass[i] = '.'+a+'.';
        }
    }

    // for(int i=0;i<h+2;i++){
    //     cout <<mass[i]<< endl;
    // } 
    bool flag;
    int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            if(mass[i][j]=='#'){
                flag = false;
                for(int k=0;k<4;k++){
                    if(mass[i+dx[k]][j+dy[k]]=='#')flag = true;
                }
                if(flag == false) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

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

Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

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

  if(a<b) swap(a,b);

  if(a==b) cout<<a*2<<endl;
  else cout<<a*2-1<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = (int)(n-1); i >= 0; i--)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k, x;
    cin >> k >> x;
    for (int i = x-k+1; i <=k+x-1 ; ++i) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int A[100009];
int temp;


int Partition(int p, int r){
    int x=A[r];
    int i =p-1;
    temp;
    for(int j=p; j<=r-1; j++){
        if(A[j]<=x){
            i++;
            temp = A[i];
            A[i]=A[j];
            A[j]=temp;
        }
    }
    temp=A[i+1];
    A[i+1]=A[r];
    A[r]=temp;
    return i+1;
}


int main(){
    int n;
    cin >> n;
    for(int i=0;i<=n-1;i++)cin >> A[i];
    int _index=Partition(0, n-1);
    for(int i=0;i<=n-1;i++){
        if(i==_index){
            cout << "[";
        }
        cout << A[i];
        if(i==_index){
            cout << "]";
        }
        if(i!=n-1) cout << " ";
        else cout << "\n";
        
    }   
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

bool is_integer(double x) {
    return std::floor(x)==x;
}

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

    ll tall(0);
    ll ans(0);
    cin >> tall;
    for(int i=1;i<n;i++){
        int x;  cin >> x;
        if(tall<x){
            tall = x;
        }else{
            ans += tall-x;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, x;
    cin >> n >> x;
    ll ans = (n % x == 0) ? 0 : 1;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

vector<int> divisor(int n) {
  vector<int> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ALL(ret));
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  REP(i,n){ 
    cin >> a[i];
    mp[a[i]]++;
  }
  //sort(ALL(a));
  if(mp[1]>0){
    cout << (mp[1]==1 ? 1 : 0) << endl;
    return 0;
  }

  int ans = n;
  REP(i,n){
    mp[a[i]]--;

    auto div = divisor(a[i]);
    for(auto d: div){
      if(mp[d]>0){
        ans--;
        break;
      }
    }

    mp[a[i]]++;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 32816
str = gets.chomp
q = gets.chomp.to_i

q.times do
  cmd, a, b, rp = gets.chomp.split
  a = a.to_i
  b = b.to_i

  case cmd
  when 'print'
    puts str[a..b]
  when 'reverse'
    str[a..b] = str[a..b].reverse
  when 'replace'
    str[a..b] = rp
  end
end

Measured memory_bytes: 6920
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string x;
    cin >> n >> x;
    // init
    vector<LL> a(n+1);
    for ( int i=1; i<=n; i++ ) {
        a[i]=a[i%__builtin_popcount(i)]+1;
    }

    LL M=0;
    REP(i,n) if ( x[i]=='1' ) M++;

    vector<LL> ans(n);
    if ( M<n ) {
        LL p=1;
        LL res=0;
        for ( int i=n-1; i>=0; i-- ) {
            if ( x[i]=='1' ) {
                res+=p%(M+1);
            }
            p=(LL)p*2%(M+1);
        }

        p=1;
        for ( int i=n-1; i>=0; i-- ) {
            if ( x[i]=='0' ) {
                LL y=(res+p)%(M+1);
                ans[i]=a[y]+1;
            }
            p=p*2%(M+1);
        }
    }
    if ( M>1 ) {
        LL p=1;
        LL res=0;
        for ( int i=n-1; i>=0; i-- ) {
            if ( x[i]=='1' ) {
                res+=p%(M-1);
            }
            p=(LL)p*2%(M-1);
        }

        p=1;
        for ( int i=n-1; i>=0; i-- ) {
            if ( x[i]=='1' ) {
                LL y=(res-p)%(M-1);
                if ( y<0 ) y+=M-1;
                ans[i]=a[y]+1;
            }
            p=p*2%(M-1);
        }
    }
    REP(i,n) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 6756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		dice dice = new dice();
		String num[] = br.readLine().split("[\\s]+");

		for (int i = 0; i < num.length; i++) {
			dice.diceNum[i + 1] = Integer.parseInt(num[i]);
		}

		int diceCopy[] = new int[dice.diceNum.length];
		System.arraycopy(dice.diceNum, 0, diceCopy, 0, diceCopy.length);
		int questNum = Integer.parseInt(br.readLine());

		for (int i = 0; i < questNum; i++) {
			String quest[] = br.readLine().split("[\\s]+");
			int syoumen = Integer.parseInt(quest[0]);
			int temae = Integer.parseInt(quest[1]);

			for (int j = 0; j < 3; j++) {
				if (syoumen == dice.diceNum[1]) {
					break;
				}
				dice.oderN();
			}

			for (int j = 0; j < 3; j++) {
				if (syoumen == dice.diceNum[1]) {
					break;
				}
				dice.oderW();
			}

			for (int j = 0; j < 3; j++) {
				if (temae == dice.diceNum[2]) {
					break;
				}
				dice.oderRoll();
			}
			System.out.println(dice.diceNum[3]);
		}
	}
}

class dice {
	int diceNum[] = new int[7];
	int stoc;

	public void oderN() {
		stoc = diceNum[1];
		diceNum[1] = diceNum[2];
		diceNum[2] = diceNum[6];
		diceNum[6] = diceNum[5];
		diceNum[5] = stoc;
	}

	public void oderW() {
		stoc = diceNum[1];
		diceNum[1] = diceNum[3];
		diceNum[3] = diceNum[6];
		diceNum[6] = diceNum[4];
		diceNum[4] = stoc;
	}

	public void oderRoll() {
		stoc = diceNum[2];
		diceNum[2] = diceNum[3];
		diceNum[3] = diceNum[5];
		diceNum[5] = diceNum[4];
		diceNum[4] = stoc;
	}
}


Measured memory_bytes: 24400
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;

int main(){
  while(1){
    int n,m; cin >>n>>m;
    if(n==0&&m==0)break;
    vector<int> d(n),v(n);
    std::vector<vector<int> > V(m+1);
    V.clear();
    int ans=0;
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
      V[d[i]].push_back(v[i]);
    }
    for(int i=1;i<=m;i++){
      int cnt=0;
      for(auto p:V[i]){
        cnt=max(cnt,p);
      }
      ans+=cnt;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;







int main(){

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

    ios_base::sync_with_stdio(0); cin.tie(0);


    string s;
    cin >> s;

    bool a = false,b = false,c = false;
    string aa,bb,cc;
    aa = s;
    reverse(aa.begin(),aa.end());
    if(aa == s) a = true;
    int n = s.size();

    for(int i = 0;i < (n-1)/2;i++){
        bb+=s[i];
    }
    string c_b = bb;
    reverse(c_b.begin(),c_b.end());
    if(c_b == bb) b = true;

    for(int i = ((n+3)/2)-1;i < n;i++){
        cc+=s[i];
    }
    string c_c = cc;
    reverse(c_c.begin(),c_c.end());
    if(cc == c_c) c = true;

    if(a && b && c) cout<<"Yes\n";
    else cout<<"No\n";










    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();long sum =0;int max = -10000000;int min = 10000000;for (int i = 1; i <= n; i++) {int a = sc.nextInt();
sum += a; if(max < a){max = a;}if(min > a){min = a;}}System.out.printf("%d %d %d\n", min, max, sum);}}


Measured memory_bytes: 41052
def main():
    N = int(input())
    A = [int(x) - 1 for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    ans = B[A[0]]
    for n in range(1, N):
        ans += B[A[n]]
        if A[n] - A[n-1] == 1:
            ans += C[A[n-1]]
    print (ans)

if __name__ == "__main__":
    main()


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

using namespace std;


#define MOD 1e9+7
#define ll long long int
#define ff first
#define ss second


template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.ff<<", "<<a.ss<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

void solve()
{
	int n,k;
	cin>>n>>k;
	int h[n],c[n];
	for(int i=0;i<n;i++)
		cin>>h[i],c[i]=INT_MAX;
	c[0]=0;
	c[1]=abs(h[1]-h[0]);

	for(int i=2;i<n;i++)
	{
		for(int j=i-1;j>=max(0,i-k) ;j--)
			c[i]=min(c[i],abs(h[i]-h[j])+c[j]);
	}
	cout<<c[n-1]<<"\n";
}


int32_t main()
{

	//your code goes here...	
	int t=1;
	//cin>>t;
	while(t--)
	{
	    solve();
	}	
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct plane_t
{
	int x, y, d;
};


#define TIME_INF 9876543210

struct solve
{
	solve(){}
	ll check_h(vector<plane_t>&plane)
	{
		ll ret=TIME_INF;
		map<int,vpii> m;
		for(auto&mp:plane)
		{
			if(mp.d==0 || mp.d==2) m[mp.y].push_back(make_pair(mp.x, mp.d));
		}
		for(auto&mm:m)
		{
			auto&mmv=mm.second;
			sort(mmv.begin(), mmv.end());
			ll prev_x=-9999999, prev_d=2;
			for(auto&mvp:mmv)
			{
				if(prev_d==0 && mvp.second==2)
				{
					min_u(ret, (mvp.first-prev_x)*10/2);
				}
				prev_x=mvp.first;
				prev_d=mvp.second;
			}
		}
		return ret;
	}
	ll check_rud(vector<plane_t>&plane)
	{
		ll ret=TIME_INF;
		map<int,vpii> m;
		int n=plane.size();

		for(int i=0;i<n;i++)
		{
			auto&mp=plane[i];
			ll c=-mp.x-mp.y;
			if(mp.d==0 || mp.d==1) m[c].push_back(make_pair(mp.x, mp.d));
		}
		for(auto&mm:m)
		{
			auto&mmv=mm.second;
			sort(mmv.begin(), mmv.end());
			ll last_rx=-999999;
			for(auto&mvp:mmv)
			{
				if(mvp.second==1 && last_rx!=-999999)
				{
					min_u(ret, (mvp.first-last_rx)*10);
				}
				if(mvp.second==0)
				{
					last_rx=mvp.first;
				}
			}
		}
		return ret;
	}
	void rot(vector<plane_t>&plane)
	{
		for(auto&m:plane)
		{
			auto t=m;
			m.x=-t.y;
			m.y=t.x;
			m.d=(t.d+1)%4;
		}
	}
	void operator()(vector<plane_t>&plane) {
		ll ans=TIME_INF;

		for(int i=0;i<4;i++)
		{
			min_u(ans, check_h(plane));
			min_u(ans, check_rud(plane));
			rot(plane);
		}
		if(ans!=TIME_INF) cout << ans << "\n";
		else cout << "SAFE\n";
	}
};


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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vector<plane_t> plane(n);
		for(auto&m:plane)
		{
			int x, y, d=0;
			string u;
			cin >> x >> y >> u;
			if(u=="R") d=0;
			if(u=="U") d=1;
			if(u=="L") d=2;
			if(u=="D") d=3;
			m=plane_t{x, y, d};
		}
		solve()(plane);
	}
	return 0;
}


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

namespace Volume0_0019
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine
            (
                Enumerable
                    .Range(1, Convert.ToInt32(Console.ReadLine()))
                    .Select( i => (ulong)i )
                    .Aggregate((n, next) => n * next)
            );           
        }
    }
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;


int A,B;
int main(){
  cin>>A>>B;
  int x0_l,x0_u,x1_l,x1_u;
  x0_l=25*A;x0_u=25*(A+1);
  x1_l=20*B;x1_u=20*(B+1);
  int ans =INF;
  int mx = max(x0_l,x1_l);
  //print(x0_l<<x1_l<<x1_l<<x1_u)

  if(mx<min(x0_u,x1_u)){
    if(mx%2==1){
      print((mx/2+1));
      return 0;
    }
    else{
      print((mx/2));
      return 0;
    }
  }
  print("-1")
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,x,y,k;
 cin>>n;
 int sm=0;
 map<int,int> mp;
 for(int i=1;i<=n;i++)
 {
    cin>>x;
    mp[x]++;
    sm+=x;
 }

 cin>>k;
 while(k--)
 {
    cin>>x>>y;
    if(mp.find(x)!=mp.end())
    {
        int tot=mp[x];
        mp.erase(x);

        sm-=tot*x;
        sm+=y*tot; 
        mp[y]+=tot;
    }
    cout<<sm<<endl;
 }

}

Measured memory_bytes: 7564
# coding: utf-8
# Your code here!

s = input().rstrip()

if s == "0" or s == "1":
    print("0")
    exit()

length = len(s)

shou = length // 2
amari = length % 2
a = "10"*shou
b = "01"*shou
if amari == 1:
    a = a + "1"
    b = b + "0"

bins = int(s,2)
bina = int(a,2)
binb = int(b,2)

saxor = bin(bina ^ bins)
sbxor = bin(binb ^ bins)

saxor_cnt1 = sum(map(int, str(saxor.lstrip("0b"))))
sbxor_cnt1 = sum(map(int, str(sbxor.lstrip("0b"))))

out = min (saxor_cnt1, sbxor_cnt1)

print(out)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    char c;cin>>c;
    if((int)(c-'A')>25)cout<<'a'<<endl;
    else cout<<'A'<<endl;
    return 0;
}

Measured memory_bytes: 3636
from scipy.sparse.csgraph import shortest_path
import numpy as np
import itertools

N,M,R = map(int,input().split())
r = [int(x) for x in input().split()]

edge = np.zeros((N+1,N+1))
for _ in range(M):
    A,B,C = map(int,input().split())
    edge[A,B] = C

dist = shortest_path(edge,directed = False).astype(int)

answer = 10**18
for visit in itertools.permutations(r):
    p = 0
    prev = visit[0]
    for x in visit[1:]:
        if prev != None:
            p += dist[prev,x]
        prev = x
    answer = min(answer,p)

print(answer)




Measured memory_bytes: 27256
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



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

  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll ans=-INF;
  chmax(ans,a*c);
  chmax(ans,a*d);
  chmax(ans,b*c);
  chmax(ans,b*d);
  
  cout<<ans<<'\n';
  
  return 0;
}

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

int calc(int m, int tmp) {
  if (m < 10) {
    return tmp + m;
  }
  calc(m / 10, tmp + m % 10);
}
int main() {
  int n;
  cin>>n;
  int ans = 1e9;
  for (int a=1; a<n; a++) {
    int b = n - a;
    ans = min(ans, calc(a, 0) + calc(b, 0));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class UnionFindTree {
    int[] par;
    int[] rank;
    int[] size;
    UnionFindTree(int maxSize){
        par = new int[maxSize];
        rank = new int[maxSize];
        size = new int[maxSize];
        for(int i=0;i<maxSize;i++){
            par[i] = i;
            size[i] = 1;
        }
    }

    public int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    public boolean unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x == y)return false;
        
        if(rank[x] < rank[y]){
            par[x] = y;
            size[y]+=size[x];
        }else{
            par[y] = x;
            size[x]+=size[y];
            if(rank[x] == rank[y])rank[x]++;
        }
        return true;
    }
    public boolean same(int x,int y){
        return find(x) == find(y);
    }
    public int size(int x){
        return size[find(x)];
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        UnionFindTree islands = new UnionFindTree(n);
        int[] a = new int[m];
        int[] b = new int[m];
        for(int i=0;i<m;i++){
            a[i] = Integer.parseInt(sc.next())-1;
            b[i] = Integer.parseInt(sc.next())-1;
        }
        long[] res = new long[m];
        long size = 0;
        long aSize,bSize;
        long max = (long)n*(n-1)/2;
        for(int i=m-1;i>=0;i--){
            // calc res[i]
            res[i] = max - size;
            aSize = islands.size(a[i]);
            bSize = islands.size(b[i]);
            if(islands.unite(a[i], b[i])){
                size+=aSize*bSize;
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<m;i++){
            sb.append(res[i]);
            sb.append('\n');
        }
        System.out.println(sb.toString());
        sc.close();
    }
}

Measured memory_bytes: 62508
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = input().rstrip()

    M = len(N)

    tot = 0

    for i in range(M):
        tot += int(N[i])
        tot %= 9

    if tot == 0:
        res = 'Yes'
    else:
        res = 'No'

    print(res)



main()


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

int main(){
 int N;
 cin >> N;
 map<int,int> p;
   int a[N];
 for(int i = 0; i < N; i++) {
    cin >> a[i];
    p[a[i]] += 1;
 }
 int sum = 0;
 for(int i = 0; i < N; i++) {
    if(p[a[i]] > a[i]) { sum += p[a[i]] - a[i]; p[a[i]] = a[i]; }
    else if(p[a[i]] < a[i]) { sum += p[a[i]]; p[a[i]] = 0; }
 }

 cout << sum << endl;
 return 0;

}

Measured memory_bytes: 5120
#include <stdio.h>

int main(){
  int N,M,S=0,V=0;
  int A[102];
  scanf("%d %d",&N,&M);
  for(int i=1;i<=N;i++){
    scanf("%d",A+i);
    V+=A[i];
    A[i]*=4*M;
  }
  for(int i=1;i<=N;i++){
    if(A[i]>=V) S++;
  }
  if(S>=M) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1660
# 約数の個数の表を作る
N = int(input())
dp = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        dp[j] += 1
ans = 0
for i in range(1, N+1):
    ans += dp[i]*i
print(ans)


Measured memory_bytes: 151816