akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}

bool ispow(int n){
    int rn=sqrt(n);
    if(rn*rn==n) return true;
    else return false;
}

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

    int res=0;

    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k]){
                    if(l[i]+l[j]>l[k]){
                        if(l[j]+l[k]>l[i]){
                            if(l[i]+l[k]>l[j]) res++;
                        }
                    }
                }
            }
        }
    }

    cout<<res<<endl;
}


Measured memory_bytes: 3652
<?php

$rank = array();
$team = array();
$q = false;
while (($line = trim(fgets(STDIN))) !== '') {
    if ($line === '0,0') {
        rsort($rank);
        $q = true;
        continue;
    }

    if ($q) {
        $i = (int)$line;
        echo array_search($team[$i], $rank) + 1, PHP_EOL;
    } else {
        sscanf($line, '%d,%d', $i, $n);
        $team[$i] = $n;
        if (!in_array($n, $rank)) {
            $rank[] = $n;
        }
    }
}

Measured memory_bytes: 6632
N = int(input())
a = list(map(int, input().split()))

a.sort()
color = [-1] * N
for i in range(N):
    if a[i] < 400:
        color[i] = 1
    elif a[i] < 800:
        color[i] = 2
    elif a[i] < 1200:
        color[i] = 3
    elif a[i] < 1600:
        color[i] = 4
    elif a[i] < 2000:
        color[i] = 5
    elif a[i] < 2400:
        color[i] = 6
    elif a[i] < 2800:
        color[i] = 7
    elif a[i] < 3200:
        color[i] = 8
    else:
        color[i] = 9

A = set(color)
if 9 in A:
    A.remove(9)

print(max(1, len(A)), len(A) + color.count(9))


Measured memory_bytes: 3064
char v[];a=12;f(x,z){if(v[x]-->48)for(;z;)f(x+"HJ<V"[--z]-73,4);}main(j,c){for(;~scanf("%s",v+a--*13);)for(j=170;a?c=0:--j||!printf("%d\n",c,a=12);f(j,4))c+=v[j]>48;}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	while(true){
		int n,m,h[1500],w[1500];
		cin >> n >> m;
		if(n==0&&m==0) break;
		REP(i,0,n) cin >> h[i];
		REP(i,0,m) cin >> w[i];
	
		int sumh[1500],sumw[1500];
		sumh[0]=h[0]; sumw[0]=w[0];
		REP(i,1,n) sumh[i]=sumh[i-1]+h[i];
		REP(i,1,m) sumw[i]=sumw[i-1]+w[i];
		
		unordered_map<int,int> cnth,cntw;
		REP(i,0,n){
			REP(j,i,n){
				if(i==0) ++cnth[sumh[j]];
				else ++cnth[sumh[j]-sumh[i-1]];
			}
		}
	
		REP(i,0,m){
			REP(j,i,m){
				if(i==0) ++cntw[sumw[j]];
				else ++cntw[sumw[j]-sumw[i-1]];
			}
		}
	
		int ans=0;
		for(auto it=cnth.begin(); it!=cnth.end(); ++it){
			if(cntw.count(it->first)==0) continue;
			ans+=it->second*cntw[it->first];
		}
	
		cout << ans << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 28284
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
  string s;

  while(cin >> s){

    int a[100],n = 10;
    for(int i=0;i<10;i++) a[i] = s[i] - 48;

    while(n > 0){

      for(int i=0;i<n-1;i++){
	if( a[i] + a[i + 1] > 9) a[i] += (a[i + 1] - 10);
	else a[i] += a[i + 1];
      }
      n--;
  
    }

    cout << a[0] << endl;
  }
}

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

int main(void){
  int N,A,B;
  cin >> N >> A >> B;
  int sum=0;
  for(int i=1;i<=N;i++){
    int count=0;
    int n=i;
    while(n>=1){
      count+=n%10;
      n/=10;
    }
    if(count>=A&&count<=B) sum+=i;
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    vi b = a;
    rep(i,n-1)b[i+1] += b[i];
    vi c(n,0);
    rep(i,n)c[i] = a[i] > 1;
    rep(i,n-1)c[i+1] += c[i];
    int ans = LINF;
    rep(i,n-1){//a[i],a[i+1]の間をきる
        int left = b[i];
        int right = b[n-1] - b[i];
        int diff = abs(left-right);
        /*
        bool c = false;
        if(left < right){
            //leftをのばす
            if(c[i] != i+1)c = true;
            //rightをへらす
            if(right - diff >= n-1-i)c = true;
        }else if(left > right){
            //rightをのばす
            if(c[n-1] - c[i] != i+1)c = true;
            //leftをへらす
            if(c[n-1] - c[i] < diff)c = true;
        }else{
            ans = 0;
        }
        if(c)
        */
        ans = min(ans, diff);
        //cout << left << " " << right << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X,Y;cin>>N>>X>>Y;
  int A[N];for(int i=0;i<N;i++)A[i]=0;
  for(int i=1;i<=N;i++)for(int j=1;j<i;j++)
    A[min(i-j,abs(X-j)+abs(Y-i)+1)]++;
  for(int i=1;i<N;i++)cout<<A[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  VVI G(n);
  REP (i, n - 1) {
    int x, y; cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  function<II(int, int)> dfs = [&](int v, int p) {
    II ret = {1, 1};
    for (int s: G[v]) if (s != p) {
      II tmp = dfs(s, v);
      (ret.fi *= tmp.fi + tmp.se) %= MOD;
      (ret.se *= tmp.fi) %= MOD;
    }
    return ret;
  };
  II ans = dfs(0, -1);
  cout << (ans.fi + ans.se) % MOD << endl;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
bool if_p(string s){
	int h=0,r=s.size()-1;
	while(h<r){
		if(s[h]!=s[r]){
			return false;
		}
		h++,r--;
	}
	return true;
}
int main() {
	string s;
	cin>>s;
	int j;
	j=s.size()/2;
	if(if_p(s)&&if_p(s.substr(0,j))&&if_p(s.substr(s.size()-j,j))){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int N, i, j, k, key;
	int A[1000];
	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (k = 0; k < N; k++) {
		if (k == 0) {
			printf("%d", A[k]);
		}
		else {
			printf(" %d", A[k]);
		}
	}
	printf("\n");
	for (i = 1; i <= N - 1; i++) {
		key = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > key) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = key;
		for (k = 0; k < N; k++) {
			if (k == 0) {
				printf("%d", A[k]);
			}
			else {
				printf(" %d", A[k]);
			}
		}
		
		
			printf("\n");
		

	}

	return 0;
}



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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int N, K, Digit[10], top, Carry;
bool Ban[10];

bool disolve(int x)
{
	while(x) {if(Ban[x%10]) return false; x/=10;}
	return true;
}
int main()
{
	sf("%d%d",&N,&K);
	fo(i,1,K) {int x; sf("%d",&x); Ban[x] = true;}
	for(;!disolve(N);++N);
	pf("%d\n",N);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int pow1(int n) {
	return n * n;
}

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (pow1(a - c) <= pow1(d))
		puts("Yes");
	else if (pow1(a - b) <= pow1(d) && pow1(b - c) <= pow1(d))
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n,m;
    int cnt = 0;
    vector<int> data;
    cin >> n >> m;
    int loop = 0;
    for(int i = 1;i <= n;i++){
        data.push_back(i * 2);
    }
    int size = data.size();
    for(int i = size + 1;i <= size + m;i++){
        data.push_back(i * 2 + 1);
    }

    size = data.size();

    for(int i = 0;i < size - 1;i++){
        for(int j = i + 1;j < size;j++){
            if(((data.at(i) + data.at(j)) % 2) == 0){
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  map<string, int> M;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      string key;
      cin >> key;
      int x;
      cin >> x;
      M[key] = x;
    }
    if (t == 1){
      string key;
      cin >> key;
      cout << M[key] << endl;
    }
    if (t == 2){
      string key;
      cin >> key;
      M.erase(key);
    }
  }
}


Measured memory_bytes: 27780
N = int(input())
A = list(map(int,input().split()))

color = [0]*8
count = 0

for a in A:
    if a < 400:
        color[0] = 1
    elif a < 800:
        color[1] = 1
    elif a < 1200:
        color[2] = 1
    elif a < 1600:
        color[3] = 1
    elif a < 2000:
        color[4] = 1
    elif a < 2400:
        color[5] = 1
    elif a < 2800:
        color[6] = 1
    elif a < 3200:
        color[7] = 1
    else:
        count += 1
sum_color = sum(color)

if sum_color == 0:
    print(1,count)
else:
    print(sum_color,sum_color+count)

Measured memory_bytes: 3064
sd = input()
t = input()

def compareStr(expected: str, actual: str) -> bool:
    for e, a in zip(expected, actual):
        if e != a and a != "?":
            return False

    return True

candidates = []
for i in range(len(sd)-len(t)+1):
    if compareStr(t, sd[i:i+len(t)]):
        s = sd.replace("?", "a")
        s = s[:i] + t + s[i+len(t):]
        candidates.append(s)

if len(candidates) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(candidates)[0])


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
b = tuple(a)
a.sort()
A1 = a[n//2-1]
A2 = a[n//2]
med = (A1+A2)/2
for i in range(n):
    if b[i] <= med:
        print(A2)
    else:
        print(A1)


Measured memory_bytes: 26180
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main(void){
  stack<int> stk;
  int a, b, x, num;
  string s;
  
  while (cin >> s) {
    if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
      a = stk.top(); stk.pop();
      b = stk.top(); stk.pop();
      if (s[0] == '+')
        stk.push(a + b);
      else if (s[0] == '-')
        stk.push(b - a);
      else if (s[0] == '*')
        stk.push(a * b);
    } else {
      stk.push(atoi(s.c_str()));
    }
  }
  cout << stk.top() << endl;
  
  return 0;
}

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



 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	int n,i,j,x,y;
   	cin>>x>>y;
   	int t1=4*x-y,t2=y-2*x;
   	if(t1>=0 && t2>=0 && t1&1^1 && t2&1^1)cout<<"Yes\n";
   	else cout<<"No\n";	
 
 
 
 
 
 
 
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vp v(n);
    rep(i,n)cin>>v[i].fi>>v[i].se;
    if(n&1){
        //md以上にできるか
        ll ok=0,ng=INF;
        while(ng-ok>1){
            ll md=(ok+ng)/2;
            ll cnt=0;
            rep(i,n)if(v[i].se>=md)cnt++;
            if(cnt*2>n)ok=md;
            else ng=md;
        }
        ll ans=ok;
        ok=INF;ng=0;
        while(ok-ng>1){
            ll md=(ok+ng)/2;
            ll cnt=0;
            rep(i,n)if(v[i].fi<=md)cnt++;
            if(cnt*2>n)ok=md;
            else ng=md;
        }
        ans-=ok;
        out(ans+1);
    }
    else{
        vi a(n),b(n);
        rep(i,n){
            a[i]=v[i].fi;
            b[i]=v[i].se;
        }
        sort(all(a));sort(all(b));
        out(b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1);
    }
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    map<ll,ll> ct;
    sll cc;
    ll mx=0;
    rep(i,1,n){
        ll x;cin>>x;
        ct[x]++;
        if(ct[x] >= 4) mx=max(mx,x*x);
        if(ct[x]>=2) cc.insert(x);
    }
    if(cc.size()>1){
        auto it=cc.end();it--;
        ll a=*it;
        it--;ll b=*it;
        mx=max(mx,a*b);
    }
    cout<<mx<<'\n';
}


Measured memory_bytes: 6528
#include<iostream>

using namespace std;

int main(){

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

   if(a==1||b==1){
      if(a==1&&b==1){
         cout<< "Draw"<< endl;
      }else if(a==1){
         cout<< "Alice"<< endl;
      }else{
         cout<< "Bob"<< endl;
      }
   }else{
      if(a>b){
         cout<< "Alice"<< endl;
      }else if(a<b){
         cout<< "Bob"<< endl;
      }else{
         cout<< "Draw"<< endl;
      }
   }

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define mod (int)(1e9 + 7) 
int main() 
{ 
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    ll arr1[n],arr2[m];
    for(ll i=0;i<n;i++)
    cin>>arr1[i];
    for(ll j=0;j<m;j++)
    cin>>arr2[j];
    ll dp[n + 1][m + 1]; 
    for (ll i = 0; i <= n; i++) 
        dp[i][0] = 1; 
    for (ll j = 0; j <= m; j++) 
        dp[0][j] = 1; 
  
    for (ll i = 1; i <= n; ++i) { 
        for (ll j = 1; j <= m; ++j) { 
            dp[i][j] = dp[i - 1][j] 
                       + dp[i][j - 1] 
                       - dp[i - 1][j - 1]; 
            if (arr1[i - 1] == arr2[j - 1]) 
                dp[i][j] += dp[i - 1][j - 1]; 
  
            dp[i][j] += mod; 
            dp[i][j] %= mod; 
        } 
    } 
    cout<<dp[n][m];
    return 0;
} 


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  int b;
  
  cin >> N >> A;
  
  b = N % 500;
  if(A >= b)
  {
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

using lint = long long;

void solve() {
    lint n, a;
    std::cin >> n >> a;

    lint ok = n, ng = -1;
    while (ok - ng > 1) {
        lint mid = (ok + ng) / 2;

        bool judge = false;
        for (lint t = 0;; ++t) {
            lint x = mid - a * t;
            lint low = x / (t + 1);
            if (x < 0 || low == 0) break;

            int hcnt = x - low * (t + 1);
            lint acc = 1;
            for (int i = 0; i < t + 1; ++i) {
                lint y = (i < hcnt ? low + 1 : low);
                if (y > n / acc) {
                    judge = true;
                    break;
                } else {
                    acc *= y;
                }
            }

            if (acc >= n) judge = true;
            if (judge) break;
        }

        if (judge) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    std::cout << ok << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to,num;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    ll goal=-1; // ここについたら終了
    bool found=false; // 終了の合図
    deque<ll> root; // 経路

    graph(ll n): N(n), G(N), used(N,false) {}

    void add_edge(ll s, ll t, ll nn){
        G[s].emplace_back((edge){t, nn});
        G[t].emplace_back((edge){s, nn}); //無向ならON
    }

    void dfs(ll v=0){
        used[v]=true;
        if(v==goal) found=true;
        for(auto E : G[v]){
            if(!used[E.to]){
                if(!found) root.emplace_back(E.num);
                dfs(E.to);
                if(!found) root.pop_back();
            }
            //if(found) break;
        }
        used[v]=false;
    }
};
const ll MAXN=51;
const ll MAXM=1<<20;
ll dp[MAXN][MAXM];
ll aru[MAXN];
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    graph g(N);
    rep(i,N-1){
        ll a,b; cin>>a>>b; --a,--b;
        g.add_edge(a,b,i);
    }
    ll M; cin>>M;

    rep(i,M){
        ll u,v; cin>>u>>v; --u,--v;
        g.found=false;
        g.goal=v;
        g.dfs(u);
        while(!g.root.empty()){
            ll xx=g.root.front();
            aru[xx]=aru[xx] bitor (1<<i);
            g.root.pop_front();
        }
    }
    dp[0][0]=1;
    rep(i,N-1){
        rep(j,1<<M){
            dp[i+1][j bitor aru[i]]+=dp[i][j];
            dp[i+1][j]+=dp[i][j];
        }
    }
    cout<< dp[N-1][(1<<M)-1]<<"\n";
}


//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 403712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)
	n := getNextInt(scanner)
	pp := make([]int, n)
	db := DoubleBucket{}
	db.init(n)
	for i := 0; i < n; i++ {
		pp[getNextInt(scanner)-1] = i
	}

	var ans int64
	for i := n; i > 0; i-- {
		db.update(pp[i-1], 1)
		l := db.nextLeft(pp[i-1])
		ll := db.nextLeft(l)
		r := db.nextRight(pp[i-1])
		rr := db.nextRight(r)

		ans += int64(l-ll) * int64(r-pp[i-1]) * int64(i)
		ans += int64(pp[i-1]-l) * int64(rr-r) * int64(i)
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

// DoubleBucket ...
type DoubleBucket struct {
	unit   int
	bucket [3][]int
}

func (db *DoubleBucket) init(n int) {
	db.unit = 32
	db.bucket[0] = make([]int, n)
	db.bucket[1] = make([]int, (n-1)/db.unit+1)
	db.bucket[2] = make([]int, (len(db.bucket[1])-1)/db.unit+1)
}

func (db *DoubleBucket) update(i, v int) {
	db.bucket[0][i] = v
	db.bucket[1][i/db.unit] = v
	db.bucket[2][i/db.unit/db.unit] = v
}

func (db *DoubleBucket) nextLeft(i int) int {
	big := db.unit * db.unit
	small := db.unit
	for i = i - 1; i >= 0; i-- {
		if db.bucket[0][i] > 0 {
			return i
		}
		if (i+1)%big == 0 && db.bucket[2][i/big] == 0 {
			i -= big - 1
			continue
		}
		if (i+1)%small == 0 && db.bucket[1][i/small] == 0 {
			i -= small - 1
			continue
		}
	}

	return -1
}

func (db *DoubleBucket) nextRight(i int) int {
	big := db.unit * db.unit
	small := db.unit
	n := len(db.bucket[0])
	for i = i + 1; i < n; i++ {
		if db.bucket[0][i] > 0 {
			return i
		}
		if i%big == 0 && db.bucket[2][i/big] == 0 {
			i += big - 1
			continue
		}
		if i%small == 0 && db.bucket[1][i/small] == 0 {
			i += small - 1
			continue
		}
	}

	return n
}


Measured memory_bytes: 3328
A,B,C,K=map(int,input().split())
if K%2==0:
    val=A-B
    if abs(val)>pow(10,18):
        print("Unfair")
    else:
        print(val)
else:
    val=B-A
    if abs(val)>pow(10,18):
        print("Unfair")
    else:
        print(val)

Measured memory_bytes: 38384
#include<stdio.h>
#include<string.h>
int main(){
  char s[100][101];
  int d[100];
  char w[101];
  char c[101];
  int i,j,k,n,m,o,p;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    for(i=0;i<n;i++)scanf("%s %d",s[i],&d[i]);
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%s %d",w,&o);
      p=0;
      for(j=0;j<o;j++){
	scanf("%s",c);
	for(k=0;k<n;k++)if(strcmp(s[k],c)==0)break;
	p+=d[k];
      }
      for(j=0;j<n;j++)if(strcmp(s[j],w)==0)break;
      if(p<d[j])d[j]=p;
    }
    scanf("%s",w);
    for(i=0;i<n;i++)if(strcmp(s[i],w)==0)break;
    printf("%d\n",d[i]);
  }
  return 0;
}

Measured memory_bytes: 624
#include <stdio.h>
#include <stdlib.h>
int main(int argv, char *argc[]){
    int hex, wide, x, y;
    
    while(1){
        scanf("%d %d", &hex ,&wide);
        
        if(hex == 0 || wide == 0)break;
        
        for(y=0;y<hex;y++){
            for(x=0;x<wide;x++){
                printf("#");        
            }
            printf("\n");
        }
        printf("\n");
        
    }
    return 0;
}

Measured memory_bytes: 572
// template version 1.11
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string a,b;
  cin >> a >> b;
  if((a == "H" && b == "H") || (a == "D" && b == "D")){
    cout << "H" << "\n";
  }
  else{
    cout << "D" << "\n";
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    long H = lread();
    long W = lread();
    writeln((N - W + 1) * (N - H + 1));
}


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

using namespace std;

int main()
{
    int X,Y;
    cin >> X >> Y;
    int ans = 0;
    if(X == 1){
        ans+=300000;
    }else if(X == 2){
        ans+=200000;
    }else if(X == 3){
        ans+=100000;
    }
    if(Y == 1){
        ans+=300000;
    }else if(Y == 2){
        ans+=200000;
    }else if(Y == 3){
        ans+=100000;
    }
    if(X == 1 && Y == 1){
        ans+=400000;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 1000000007

def modpow(base, exponent, modulus)
		result = 1
		while exponent > 0
				result   = (base * result) % modulus unless (exponent & 1).zero?
				base     = (base * base)   % modulus
				exponent >>= 1
		end
		result
end

gets

a = gets.chomp.split(" ").map(&:to_i)

a.sort!

if a.size % 2 == 0
  if a != ([*0..a.size/ 2-1].map{|t| 2 * t + 1} + [*0..a.size/ 2-1].map{|t| 2 * t + 1}).sort
  #else
  p 0
  exit
  end
else 
 if a != ([*0..a.size/ 2].map{|t| 2 * t} + [*1..a.size/ 2].map{|t| 2 * t}).sort
 p 0
  exit
end
end

p modpow(2, (a.size/  2), MOD) 


Measured memory_bytes: 13444
import * as fs from 'fs';

const [r, g, b]: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ');
const num: number = parseInt(r + g + b, 10);
const ans: string = (num % 4 === 0) ? 'YES' : 'NO';
console.log(ans);


Measured memory_bytes: 7372
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int h, n, i = 0;
	cin >> h >> n;
	vector<pair<int, int>>vec(n);
	rep(i, n) {
		cin >> vec[i].first >> vec[i].second;
	}
	vector<int>DP(100000000,0);//魔力をiとしDP[i]をダメージとする
	DP[0] = 0;
	while(1) {
		i++;
		rep(j, n) {
			if (i - vec[j].second >= 0) {
				DP[i] =max(DP[i],DP[i - vec[j].second] + vec[j].first);
				if (DP[i] >= h) {
					cout << i << endl;
					return 0;
				}
			}
		}
	}
}




Measured memory_bytes: 781568
#include<iostream>
#include<set>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;
typedef long long ll;
int N;
ll a[10001];

set<ll> ans;

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

void bunkai(ll a) {
	ll cnt = 2;
	while (cnt * cnt <= a) {
		if (a % cnt == 0)ans.insert(cnt), a /= cnt;
		else cnt++;
	}
	if (a != 1)ans.insert(a);
}

vector<ll> era() {
	vector<ll> rtn;
	bool notp[10001] = {};
	notp[0] = true, notp[1] = true;
	for (int i = 2; i <= N; i++) {
		if (!notp[i]) {
			rtn.push_back(i);
			for (int j = i * 2; j <= N; j += i) {
				notp[j] = true;
			}
		}
	}
	return rtn;
}

int main() {
	cin >> N;
	ll g = 0;
	for (int i = 0; i < N + 1; i++) {
		cin >> a[i];
		if (g == 0)g = abs(a[i]);
		else g = gcd(abs(a[i]), g);
	}
	bunkai(g);
	reverse(a, a + N + 1);
	auto prime = era();
	
	for (int i = 0; i < prime.size(); i++) {
		ll P = prime[i];
		//x^P-xでf(x)が割り切れるか？
		vector<ll> b(P, 0);
		for (int j = 0; j < P; j++)b[j] = a[j] % P;
		for (int j = P; j <= N; j++) {
			ll r = j % (P - 1);
			if (r == 0)r = P - 1;
			b[r] = (b[r] + (a[j] % P)) % P;
		}
		for (int j = 0; j < P; j++) {
			if (b[j] != 0)goto next;
		}
		ans.insert(P);
	next:;
	}
	for (auto p : ans) {
		cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 384
class UF:
    """Union Find
    """
    def __init__(self, n):
        self.n = n
        self.elements = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def union(self, v, w):
        assert 0 <= v < self.n
        assert 0 <= w < self.n
        rv = self.root(v)
        rw = self.root(w)

        if rv != rw:
            if self.size[rv] > self.size[rw]:
                self.elements[rw] = rv
                self.size[rv] += self.size[rw]
            else:
                self.elements[rv] = rw
                self.size[rw] += self.size[rv]

    def connected(self, v, w):
        assert 0 <= v < self.n
        assert 0 <= w < self.n
        return self.root(v) == self.root(w)

    def root(self, v):
        rv = self.elements[v]
        while rv != self.elements[rv]:
            rv = self.elements[rv]
        return rv


def run():
    n, q = [int(x) for x in input().split()]
    uf = UF(n)

    for _ in range(q):
        com, i, j = [int(x) for x in input().split()]
        if com == 0:
            uf.union(i, j)
        elif com == 1:
            if uf.connected(i, j):
                print(1)
            else:
                print(0)


if __name__ == '__main__':
    run()



Measured memory_bytes: 6052
h,n = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
ans = 0
summ = 0
for i in range(len(a)):
    summ += a[i]
    if summ >= h:
        ans = 1
        break
if ans == 1:
    print("Yes")
else:
    print("No")

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

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  
  if (A > K) {
    cout << A-K << " " << B << endl;
  }
  
  else if (A <= K && K < A + B) {
    cout << 0 << " " << A+B-K << endl;
  }
  
  else if (A + B <= K) {
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
from collections import defaultdict,deque
v,n=map(int,input().split())
n+=v-1
es=[[int(x)for x in input().split()]for _ in range(n)]
outs=defaultdict(list)
ins=defaultdict(int)
for v1,v2 in es:
    outs[v1].append(v2)
    ins[v2]+=1
q=deque(v1 for v1 in range(v)if ins[v1]==0)
res=[]
f=[0]*(v+1)
while q:
    v1=q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2]-=1
        if ins[v2]==0:
            q.append(v2)
            f[v2]=v1
for t in f[1:]:print(t)

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

struct Unionfind {
  // tree number
  vector<int> par;
  // tree rank
  vector<int> treerank;
  // constructor
  Unionfind(int n = 1) { stree(n + 1); }
  // make and initialization
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  // search root
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

long long n, m, k;
vector<vector<int>> fr, bl;
Unionfind uf;

int main() {
  cin >> n >> m >> k;
  uf = Unionfind(n);
  bl.resize(n);
  fr.resize(n);
  for(int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    uf.uni(a, b);
    fr[a].push_back(b);
    fr[b].push_back(a);
  }
  for(int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    bl[a].push_back(b);
    bl[b].push_back(a);
  }
  for(int i = 0; i < n; ++i) {
    int res = uf.size(i);
    res -= (int)fr[i].size();
    --res;
    for(auto x : bl[i])
      if(uf.issame(i, x)) --res;
    if(i != 0) cout << " ";
    cout << res;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 12664
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll a, b, k;
	cin >> a >> b >> k;
	if (b-a+1 <= k*2) {
		FOR(i, a, b+1) cout << i << endl;
	} else {
		REP(i, k) cout << (a+i) << endl;
		REP(i, k) cout << (b-k+1+i) << endl;
	}
	return 0;
}
 

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

string solve() {
    ll A, B;
    cin >> A >> B;
    string ans;
    if ( A < B ) {
        ans = string(B, '0'+A);
    } else {
        ans = string(A, '0'+B);
    }
    
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main( void )
{
  int a[4],b[4],hit,blow;
  while( 1 ){
    for( int i=0; i<4; i++ ) cin >> a[i];
    for( int i=0; i<4; i++ ) cin >> b[i];
    if( cin.eof() ) break;
    hit=0;
    blow=0;
    for( int i=0; i<4; i++ ) if( a[i] == b[i] ) hit++;
    for( int i=0; i<4; i++ ) for( int j=0; j<4; j++ )
      if( a[i] == b[j] ) blow++;
    blow -= hit;
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	string S;
	cin >> S;
	sort(all(S));
	if (S == "abc")
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math
def main():
    A, B, H, M = map(int, input().split())
    radh = (H*60+M)/720 * 2*math.pi
    radm = M/60 * 2*math.pi
    hx, hy = A*math.cos(radh), A*math.sin(radh)
    mx, my = B*math.cos(radm), B*math.sin(radm)
    ans = math.sqrt((hx-mx)**2 + (hy-my)**2)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 62756
import bisect

n = int(input())

l = []
r = []

for i in range(n):
    a, b = map(int, input().split())
    l.append(a)
    r.append(b)

l.sort()
r.sort(reverse=True)

if n%2 == 1:
    print(r[(n-1)//2]-l[(n-1)//2]+1)
else:
    l1, l2 = l[(n-2)//2], l[(n-2)//2+1]
    r1, r2 = r[(n-2)//2+1], r[(n-2)//2]
    d1, d2 = r1-l1+1, r2-l2+1
    d1, d2 = max(d1, d2), min(d1, d2)
    print(r2+r1-l1-l2+1)

Measured memory_bytes: 99020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

long long h;

long long solve( long long n )
{
	if( n == 1 )
	{
		return 1LL;
	}
	return 1 + 2 * solve( n / 2 );
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> h;
	cout << solve( h ) << "\n";	
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {

  ll n; cin >> n;
  string s; cin >> s;
  ll r = 0, ans = 0;
  for(ll i = 0; i < s.length(); ++i){
    if(s[i] == 'R')r++;
  }
  for(ll i = 0; i < r; ++i){
    if(s[i] != 'R')ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
using namespace std;
int n,c[100][100];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>c[i][j];
	long ans=0;
	for(int i=0;i<n;i++)for(int j=i;j<n;j++)ans+=min(c[i][j],c[j][i]);
	cout<<ans<<endl;
}



Measured memory_bytes: 3128
#include<cstdio>  
using namespace std;      
typedef long long LL;  
const LL mod = 1e9+7;  
LL dp[1000003];  
int main()  
{  
    LL n,sum=0;  
    scanf("%lld",&n);  
    dp[1]=n;  
    dp[2]=(n*n)%mod;  
    for(int i=3;i<=n;++i)  
    {  
        sum=(sum+dp[i-3])%mod;  
        dp[i]=(dp[i-1]+sum+(n-1)*(n-1)%mod+n-i+2)%mod;  
    }  
    printf("%lld\n",dp[n]);  
    return 0;  
}  

Measured memory_bytes: 7936
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define ll long long
using namespace std;
ll seg[800000];
ll a[100100];
vector<ll> vt;
ll update(ll pos, ll val, ll node, ll x, ll y)
{
	if (pos<x || pos>y)return seg[node];
	if (x == y)return seg[node] += val;
	ll mid = (x + y) / 2;
	return seg[node] = update(pos, val, node * 2, x, mid) + update(pos, val,node * 2 + 1, mid + 1, y);
}
ll query(ll lo, ll hi, ll node, ll x, ll y)
{
	if (hi < x || lo > y)return 0;
	if (lo <= x&& y<=hi)return seg[node];
	ll mid = (x + y) / 2;
	return query(lo, hi, node * 2, x, mid) + query(lo, hi, node * 2 + 1, mid + 1, y);
}
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		vt.push_back(a[i]);
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	ll left = 0;
	ll right = vt.size()-1;
	ll dap = 1e18;
	ll check = n*(n + 1) / 4+1;
	while (left <= right)
	{
		memset(seg, 0, sizeof(seg));
		ll mid = (left + right) / 2;
		ll x = 0;
		ll cnt = 0;
		update(n, 1, 1, 0, 2 * n + 1);
		for (int i = 0; i < n; i++)
		{
			if (a[i] > vt[mid]) {
				x--;
			}
			else {
				x++;
			}
			cnt += (query(0, x+n-1, 1, 0, 2 * n+1));
			update(x + n, 1, 1, 0, 2 * n+1);
		}
		if (cnt >= check)
		{
			right = mid - 1;
			dap = min(dap, vt[mid]);
		}
		else
			left = mid + 1;
	}
	printf("%lld", dap);
}

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

using namespace std;

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

  int n;
  cin >> n;
  long long t, a, x, y;
  cin >> x >> y;
  for (int i = 1; i < n; ++i) {
    cin >> t >> a;
    long long k = ((x+t-1)/t > (y+a-1)/a ? (x+t-1)/t : (y+a-1)/a);
    x = k*t;
    y = k*a;
  }
  cout << x + y << endl;

  return 0;
}



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

int main(){

  int a,b,c;
  int rmd=0,i=0,ans=0;

  cin >>a >>b >>c;

  do{
    if(rmd==c%(a+i)){
      ans++;
    }
    i++;
  }while(a+i<=b);

  cout <<ans <<endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define mod ((long long)(1e9 + 7))
vector<long long> fact;
vector<long long> factInv;

long long pow_mod(long long a, long long b) {
  long long ret = 1;
  while (b > 0) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b = b >> 1;
  }
  return ret;
}

void comb_init(long long n) {
  fact.resize(n + 1);
  factInv.resize(n + 1);
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    fact[i] %= mod;
  }
  factInv[n] = pow_mod(fact[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % mod;
  }
}

long long comb(long long n, long long r) {
  if (n == 0 && r == 0) return 1;
  if (r > n) return 0;
  long long ret = factInv[n - r] * factInv[r] % mod;
  return ret * fact[n] % mod;
}

int main(void) {
  long long N, K;
  cin >> N >> K;
  comb_init(N);
  for (long long i = 1; i <= K; i++) {
    long long ans = comb(N - K + 1, i) * comb(K - 1, i - 1) % mod;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256