akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll MOD = 1000000007;

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}


int main(){
  ll N,ans=1;
  string S;
  cin >> N >> S;
  vector<ll> A(26,0);
  rep(i,N){
    A.at(S.at(i)-'a')++;
  }
  rep(i,26){
    ans*=A.at(i)+1;
    ans%=MOD;
  }
  ans+=MOD;
  ans--;
  ans%=MOD;
  cout << ans << endl;
    
 
      
}

Measured memory_bytes: 512
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	
	v := make([]int, 0)
	l := make([]int, 0)
	
	for i := 0; i < n-1; i++ {
		v = append(v, nextInt())
	}

	answer := 0
	for i := 0; i < n-1; i++ {
		if(i == 0){ 
			l = append(l, v[i])
		}else{
			if( v[i-1] <= v[i] ){
				l = append(l, v[i-1])
			}else{
				l = append(l, v[i])
			}
		}	
	} 	
	
	for i := 0; i < n-1; i++ {
		answer += l[i]
	}
	
	Println(answer + v[n-2])
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<4000;i++){
      if(n==6174){cout<<i<<endl;break;}
      vector<int>v;
      for(int j=0;j<4;j++){
        v.push_back(n%10);
        n/=10;
      }
      sort(v.begin(),v.end());
      if(v[0]==v[3]){cout<<"NA"<<endl;break;}
      int p1,p2;
      p1=v[0]+v[1]*10+v[2]*100+v[3]*1000;
      p2=v[3]+v[2]*10+v[1]*100+v[0]*1000;
      n=p1-p2;
    }
  }
}

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

long long store[50] = {0,6,14};

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    for (int i = 3; i <= 41; ++i)
    {
        store[i] = store[i - 1] * 2 + 2;
    }

    cout << store[n];
    return 0;
}

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

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

  int x;
  cin >> x;

  int ans;

  for (int i = 1; i <= x; i++) {
    int val = ((i + 1) * i) / 2;

    if (val >= x) {
      ans = i;
      break;
    }
  }

  cout << min(ans, x) << endl;

  return 0;
}

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

int main() {
  long long A,B;
  
  cin>>A>>B;
  
  long long xa_min,xa_max;
  long long xb_min,xb_max;
  
  xa_min=A/0.08+A%2;
  xa_max=(A+1)/0.08-1;
  xb_min=B/0.1;
  xb_max=(B+1)/0.1-1;
  
  if(xa_max<xb_min||xb_max<xa_min){
    cout<<"-1"<<endl;
  }else{
    if(xa_min<xb_min){
      cout<<xb_min<<endl;
    }else{
      cout<<xa_min<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        h -= a;
    }

    cout << (h > 0 ? "No" : "Yes") << endl;

    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, c; cin >> a >> b >> c;
  cout << min(a+b, min(b+c, c+a)) << endl;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <bitset>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;



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

  int n;
  cin>>n;

  std::vector<int> d(n);

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

  std::sort(d.begin(), d.end());

  bool is_filled[24]={};
  is_filled[0]=true;
  bool place_left=true;
  for(auto v:d){
    int push_point;
    if(place_left){
      push_point=v;
      place_left=false;
    }else{
      push_point=24-v;
      place_left=true;
    }
    if(is_filled[push_point]){
      cout<<0<<endl;
      exit(0);
    }else{
      is_filled[push_point]=true;
    }
  }

  int result=24;
  for(int begin=0;begin<=23;begin++){
    if(!is_filled[begin]) continue;
    for(int step=1;step<=12;step++){
      if(is_filled[(begin+step)%24]){
        result=std::min(result,step);
        break;
      }
    }
  }

  cout<<result<<endl;




  return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    for(int i=0;i<s.length();i++){
        for(int j=i;j<s.length();j++){
            string s1=s.substr(0,i);
            string s2=s.substr(j,s.length());
            string s3=s1+s2;
            if(s3=="keyence"){
                cout<<"YES"<<Endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









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

#define int long long

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

int N, H;
int a[100000] = {}, b[100000] = {};

signed main() {
    cin >> N >> H;
    int max_a = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        max_a = max(max_a, a[i]);
    }
    sort(b, b + N, [](int x, int y) {
        return x > y;
    });
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (b[i] <= max_a) {
            break;
        }
        ans++;
        H -= b[i];
        if (H <= 0) {
            cout << ans << endl;
            return 0;
        }
    }
    ans += H % max_a == 0 ? H / max_a : H / max_a + 1;
    cout << ans << endl;
    return 0;
}


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

public class Main
{
    public static void main(String[] args) throws IOException
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=br.readLine())!=null){
			char[] chars = s.toCharArray();
			for(char c : chars){
					if(Character.isLowerCase(c)) System.out.print((char)(c-32));
					else	   						 System.out.print(c);
			}
			System.out.println();
		}
    }
}

Measured memory_bytes: 9340
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    vector<int> Q(N);
    rep(i,N){
        Q[P[i]-1] = i;
    }
    ll res = 0;
    ll cnt = 0;
    rep(i,N-1){
        if(Q[i] < Q[i+1]) cnt++;
        else{
            res = max(res,cnt);
            cnt = 0;
        }
    }
    res = max(res,cnt);
    res++;
    cout << N - res << endl;
}

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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    sort(s.begin(), s.end());
    string result = "No";
    if (s[0] == s[1] and s[2] == s[3] and s[0] != s[2]){
        result = "Yes";
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int k,s,ans=0;

    cin>>k>>s;

    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){

            int x = s-i-j;
            if(x>=0 && x<=k)
                ans++;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int Ans = 0;
  if(A == B)Ans++;
  if(B == C)Ans++;
  if(A == C)Ans++;
    
    if(Ans == 1){
      cout << "Yes" << endl;
    }
  
 else{
   cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include <utility>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,k,ct=0;
    cin >> n >> k;

    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
        if(h[i] >= k)
            ct++;
    }

    cout << ct << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>

using namespace std;

enum Face
{
	TOP = 0,
	FRONT = 1,
	RIGHT = 2,
	LEFT = 3,
	BACK = 4,
	BOTTOM = 5,
};

int main()
{
	string cmd;
	vector<int> f(6);
	int tmp;
	for (int i = 0; i < 6; i++)
	{
		cin >> f[i];
	}
	cin >> cmd;
	for (int i = 0; i < cmd.size(); i++)
	{
		switch (cmd[i])
		{
		case 'E':
			tmp = f[TOP];
			f[TOP] = f[LEFT];
			f[LEFT] = f[BOTTOM];
			f[BOTTOM] = f[RIGHT];
			f[RIGHT] = tmp;
			break;
		case 'N':
			tmp = f[TOP];
			f[TOP] = f[FRONT];
			f[FRONT] = f[BOTTOM];
			f[BOTTOM] = f[BACK];
			f[BACK] = tmp;
			break;
		case 'S':
			tmp = f[TOP];
			f[TOP] = f[BACK];
			f[BACK] = f[BOTTOM];
			f[BOTTOM] = f[FRONT];
			f[FRONT] = tmp;
			break;
		case 'W':
			tmp = f[TOP];
			f[TOP] = f[RIGHT];
			f[RIGHT] = f[BOTTOM];
			f[BOTTOM] = f[LEFT];
			f[LEFT] = tmp;
			break;
		default:
			break;
		}
	}
	cout << f[TOP] << endl;
}


Measured memory_bytes: 3220
#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=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 2000000000;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}


int ans[4];

int main(){
	int N; cin >> N;
	string aa[4] = {"AC", "WA", "TLE", "RE"};
	rep(i, N){
		string s; cin >> s;
		rep(x, 4){
			if(aa[x]==s){
				ans[x]++;
			}
		}
	}
	rep(i, 4){
		cout << aa[i] << " " << 'x' << " " << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let d: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let t: Vec<usize> = (0..m)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut mp = std::collections::HashMap::new();
    for i in 0..n {
        let p = mp.entry(d[i]).or_insert(0);
        *p += 1;
    }
    for i in 0..m {
        let p = mp.entry(t[i]).or_insert(0);
        if *p > 0 {
            *p -= 1;
        } else {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


Measured memory_bytes: 15580
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

int main() {
    using tup = array<ll, 3>;
    int x, y, z;
    cin >> x >> y >> z;
    int n = x+y+z;
    vector<tup> v(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            scanf("%lli", &v[i][j]);
        }
    }
    sort(v.begin(),v.end(), [](tup a, tup b){
        return a[0] - a[1] > b[0] - b[1];
    });
    vector<ll> a(n+1), b(n+1);
    GPQ<int> Q;
    ll s = 0, t = 0;
    for (int i = 0; i < n; ++i) {
        s += v[i][2];
        t += v[i][0]-v[i][2];
        Q.emplace(v[i][0]-v[i][2]);
        if(Q.size() > x) {
            t -= Q.top();
            Q.pop();
        }
        if(Q.size() == x && i+1 <= x+z){
            a[i+1] = s+t;
        }
    }
    Q = GPQ<int>();
    s = 0; t = 0;
    for (int i = n-1; i >= 0; --i) {
        s += v[i][2];
        t += v[i][1]-v[i][2];
        Q.emplace(v[i][1]-v[i][2]);
        if(Q.size() > y) {
            t -= Q.top();
            Q.pop();
        }
        if(Q.size() == y && n-i <= y+z){
            b[i] = s+t;
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, a[i]+b[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4860
@a=glob<>;
$x3=$a[2]-$a[3]+$a[1];
$y3=$a[3]-$a[0]+$a[2];
$x4=$a[0]-$a[3]+$a[1];
$y4=$a[1]-$a[0]+$a[2];
print "$x3 $y3 $x4 $y4"

Measured memory_bytes: 768
// AOJ DPL_1_A Coin Changing Problem
// 2018.5.9 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 0x33333333

int c[22];
int dp[50005];

int main()
{
	int n, m, i, j;

	n = in(), m = in();
	for (i = 1; i <= m; i++) c[i] = in();
	
	memset(dp, INF, sizeof(dp));
	dp[0] = 0;
	
	for (i = 1; i <= m; i++) for (j = 0; j+c[i] <= n; j++) {
		int x = dp[j]+1;
		if (x < dp[j+c[i]]) dp[j+c[i]] = x;
	}
	printf("%d\n", dp[n]);
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  string S;
  cin >> S;
  int M = 0;
  int M2 = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '(') {
      M++;
    }
    else {
      if (M > 0) {
        M--;
      }
      else {
        M2++;
      }
    }
  }
  for (int i = 0; i < M2; i++) {
    S = '(' + S;
  }
  for (int i = 0; i < M; i++) {
    S = S + ')';
  }
  cout << S << endl;
}

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

const int N = 1e5 + 5;
const double inf = 1e18;
double x[N], y[N];
double dx[N], dy[N];
int n;

double f(double a) {
    double minx = inf, maxx = -inf, miny = inf, maxy = -inf;
    for (int i = 0; i < n; i++) { //n个点
        double nx = x[i] + a * dx[i];
        double ny = y[i] + a * dy[i];
        minx = min(minx, nx);
        maxx = max(maxx, nx);
        miny = min(miny, ny);
        maxy = max(maxy, ny);
    }
    return (maxx - minx) * (maxy - miny);
}

double ternary_search(double l, double r) {
   double ans = inf;
  int times = 300;
    while (times--) {
        double m1 = l + (r - l) / 3;
         double m2 = r - (r - l) / 3;
        //double m1 = (l*2+r) / 3;
        //double m2 = (r*2+l) / 3;
        double f1 = f(m1);
        double f2 = f(m2);
        ans = min(ans, f1);
         ans = min(ans, f2);
        if (f1 < f2) r = m2;
        else l = m1;
    }
    return ans;
}

int main() {
   // while (cin >> n) {
      cin>>n;
        //memset(dx, 0, sizeof(dx));
        //memset(dy, 0, sizeof(dy));

        string s;
        for (int i = 0; i < n; i++) {
            cin >> x[i] >> y[i] >> s;
            if (s == "R") dx[i] = 1;
            if (s == "L") dx[i] = -1;
            if (s == "U") dy[i] = 1;
            if (s == "D") dy[i] = -1;
        }


       // cout << fixed << setprecision(11) <<ternary_search(0, 1e9) << endl;
      printf("%f\n",ternary_search(0, 1e9));
   // }

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll MOD = (ll)1e9 + 7 ;
const int MAXN = 1e5 + 100;

void solve(){
    int  n , x, y;
    cin >> n >> x >> y;
    vector<int> g[n + 1];
    for(int i = 1; i < n; ++i){
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    vector<int> dist(n + 1, 0);
    for(int i = 1; i <= n; ++i){
        queue<int> q;
        q.push(i);
        vector<int> d(n + 1, -1);
        d[i] = 0;
        while(!q.empty()){
            int u = q.front();
            q.pop();
            for(auto & x: g[u]){
                if( d[x] == -1){
                    d[x] = d[u] + 1;
                    q.push(x);
                    dist[d[x]]++;
                }
            }
        }
    }
    for(int i = 1; i < n; ++i)
        cout << dist[i]/2 << '\n';

}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 384
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

n = int(input())

a = [0] + input_numbers() +[0]

cost = 0
for i in range(1, len(a)):
    cost += abs(a[i] - a[i - 1])

sum = 0

for i in range(1, n + 1):
    temp = (a[i + 1] - a[i]) * (a[i - 1] - a[i])
    if(temp > 0):
        temp = min(abs(a[i + 1] - a[i]), abs(a[i - 1] - a[i])) * 2
        print(cost - temp)
    else:
        print(cost)

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

const int INF = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    int table[n][n];
    int c[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            c[i][j] = INF;
        }
    }

    bool candidate[m];
    for (int i = 0; i < m; i++) {
        int a, b, x;
        cin >> a >> b >> x;
        a--; b--;
        table[a][b] = table[b][a] = i;
        c[a][b] = c[b][a] = x;
        candidate[i] = false;
    }

    for (int i = 0; i < n; i++) {
        bool used[n];
        fill(used, used + n, false);
        int d[n + 1];
        fill(d, d + n + 1, INF);
        d[i] = 0;

        int parent[n];
        for (int j = 0; j < n; j++) {
            parent[j] = j;
        }
        while (true) {
            int u = n;
            for (int j = 0; j < n; j++) {
                if (!used[j] && d[j] < d[u])
                    u = j;
            }
            if (u == n)
                break;

            used[u] = true;
            if (u != parent[u])
                candidate[table[u][parent[u]]] = true;
            for (int j = 0; j < n; j++) {
                int dn = d[u] + c[j][u];
                if (dn < d[j]) {
                    d[j] = dn;
                    parent[j] = u;
                }
            }
        }
    }

    int ans = 0;
    for (bool b: candidate) {
        if (!b) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main( void )
{
	int a, b;
	char c;
	
	while( 1 ){
		scanf("%d %c %d", &a, &c, &b);
		
		switch( c ){
			case '+': printf("%d\n", a+b);	break;
			case '-': printf("%d\n", a-b);	break;
			case '*': printf("%ld\n", a*b);	break;
			case '/': printf("%d\n", a/b);	break;
			default: return 0;
		}
	}
	
	return 0;
}

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

int DivisorNumCount(int);
void Divisor(int *,int);
void RetMaxDivisor(int,int*,int,int*);

int main(void){

  int x;
  int y;
  int min;
  int max;
  int divnum;
  int i;

  cin >> x >> y;

  if(x <= y){
    min = x;
    max = y;
  }else{
    min = y;
    max = x;
  }

  for (divnum = min,i = 1; divnum > 0 ; divnum = min / (++i)){
      if (min % divnum == 0){
        if(max % divnum == 0){
          cout << divnum << endl;
          break;
        }
      }
    }
  return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main { // https://atcoder.jp/contests/abc088/tasks/abc088_c
	static int[][] grid;
	static int[] left;
	static int[] top;
	
	static int size = 3;
	
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		grid = new int[size][size];
		left = new int[size];
		top = new int[size];
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) grid[i][j] = x.nextInt();
		}
		for (int i = 0; i < size; i++) {
			left[i] = grid[i][0];
			top[i] = grid[0][i];
		}
		
		boolean good = true;
		int curdiff, nowdiff;
		for (int i = 1; i < size; i++) {
			if (!good) break;
			curdiff = grid[i][0] - top[0];
			for (int j = 1; j < size; j++) {
				nowdiff = grid[i][j] - top[j];
				if (nowdiff != curdiff) {
					good = false;
					break;
				}
			}
			
		}
		
		for (int i = 1; i < size; i++) {
			if (!good) break;
			curdiff = grid[0][i] - left[0];
			for (int j = 1; j < size; j++) {
				nowdiff = grid[j][i] - left[j];
				if (nowdiff != curdiff) {
					good = false;
					break;
				}
			}
			
		}
		
	//	System.out.println(good);
		if (good) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int n, a, b;

int32_t main()
{	
	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
	cin >> n >> a >> b;
	if(a > b)	swap(a, b);
	if((b - a) % 2 == 0)
		cout << (b - a) / 2;
	else
		cout << (b - a - 1) / 2 + min(a, n - b + 1);
	return 0; 
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  ll res = 0;
  while (x > 0) {
    if (x / 500 > 0) {
      x -= 500;
      res += 1000;
    } else if (x / 5 > 0) {
      x -= 5;
      res += 5;
    } else {
      break;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       X:i32
    }
    let ans = 8 - ((X - 400) / 200);
    println!("{}", ans);
}


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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;
int n;
vector<int> Adj[nax];
vector<ll> Ctr(nax), Mark(nax);

void dfs(int u, int p, ll prev)
{
	Mark[u] += prev + Ctr[u];
	prev += Ctr[u];
	for (auto x : Adj[u])
		if (x != p)
			dfs(x, u, prev);
}

void solve()
{
	int u, v, q;
	cin >> n >> q;
	for (int i = 1; i < n; ++i)
	{
		cin >> u >> v;
		Adj[u].pb(v);
		Adj[v].pb(u);
	}
	while (q--)
	{
		cin >> u >> v;
		Ctr[u] += v;
	}
	dfs(1, 0, 0);
	for (int i = 1; i <= n; ++i)
		cout << Mark[i] << ' ';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 25856
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
const double INF = 1e18;

int main(){
    cout << fixed;
    cout << setprecision(15);
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        
        double pw;
        cin >> pw;
        vector<double> vw(n),pf(n),vf(n),th(n);
        vector<double> w(1, 0);
        w.reserve(n+1);
        for(int i=0; i<n; i++){
            cin >> vw[i] >> pf[i] >> vf[i] >> th[i];
            if(th[i]*vw[i] > 0) w.push_back(th[i]/vw[i]);
        }
        sort(w.begin(), w.end());
        
        int lb=0, ub=w.size()-1;
        while(lb+2 < ub){
            int mid[2] = {lb +(ub-lb)/3, lb +(ub-lb)*2/3};
            double cost[2];
            for(int i=0; i<2; i++){
                cost[i] = w[mid[i]]*pw;
                for(int j=0; j<n; j++){
                    if(w[mid[i]]*vw[j] < th[j]){
                        cost[i] += (th[j] -w[mid[i]]*vw[j])/vf[j] *pf[j];
                    }
                }
            }
            if(cost[0] < cost[1]){
                ub = mid[1];
            }else{
                lb = mid[0];
            }
        }

        double ans = INF;
        for(int i=lb; i<=ub; i++){
            double cost = w[i]*pw;
            for(int j=0; j<n; j++){
                if(w[i]*vw[j] < th[j]){
                    cost += (th[j] -w[i]*vw[j])/vf[j] *pf[j];
                }
            }
            ans = min(ans, cost);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 6888
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
vector<int>sosuu2(100001, 0);
vector<int>sosuu3(100001, 0);
vector<int>sosuu;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q; cin >> Q;
	sosuu.push_back(2);
	sosuu2[2] = 1;
	for (int i = 3; i <= 100000; i++)
	{
		for (int j = 0; j < sosuu.size(); j++)
		{
			if (i%sosuu[j] == 0)
			{
				break;
			}
			if (j == sosuu.size() - 1)
			{
				sosuu.push_back(i);
				sosuu2[i] = 1;
			}
		}
	}
	sosuu3 = sosuu2;
	for (int i = 0; i <= 100000; i++)
	{
		if (i % 2 == 1 && sosuu2[i] == 1 && sosuu2[(i + 1) / 2] == 1)
		{
			sosuu3[i] = 1;
		}
		else
		{
			sosuu3[i] = 0;
		}
	}
	for (int i = 1; i <= 100000; i++)
	{
		sosuu3[i] += sosuu3[i - 1];
	}
	for (int i = 0; i < Q; i++)
	{
		int l, r; cin >> l >> r;
		cout << sosuu3[r] - sosuu3[l - 1] << "\n";
	}
}

Measured memory_bytes: 1536
N, K = map(int, input().split())
S = input()
l = [1]
for i in range(N-1):
  if S[i] == S[i+1]:
    l[-1] += 1
  else:
    l.append(1)
if S[0] == "0":
  l = [0] + l
if S[-1] == "0":
  l += [0]
#print(l)
n = len(l)
ans = sum(l[:min(K*2+1, n+1)])
i = 0
M = ans
while True:
  if K*2 + i+1 >= n:
    break
  M = M + l[K*2+1 + i] + l[K*2+1 + i+1] - l[i] -l[i+1]
  #print(ans, M)
  ans = max(ans, M)
  i += 2
print(ans)

Measured memory_bytes: 4980
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 26016
# 解説を見て解き直し
N, K = [int(x) for x in input().split()]

ranges = [tuple(int(x) for x in input().split()) for _ in range(K)]
ranges.sort()
p = 998244353

dpsum = [0] * (N + 1)
dpsum[1] = 1

for i in range(2, N + 1):
    dp = 0
    for l, r in ranges:
        rj = max(0, i - l)
        lj = max(1, i - r)
        dp += dpsum[rj] - dpsum[lj - 1]
        dp %= p
    dpsum[i] = dpsum[i - 1] + dp
    dpsum[i] %= p

print(dp)

Measured memory_bytes: 16792
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
struct UnionFind{
    vector<int> parent;
    vector<int> s;
 
    UnionFind(int n){
        parent.resize(n);
        s.resize(n, 1);
        for(int i = 0; i < n; i++) parent[i] = i;
    }
 
    int root(int node){
        if(parent[node] == node){
            return node;
        } else {
            return parent[node] = root(parent[node]);
        }
    }
 
    void unite(int x, int y){
        int rootx = root(x);
        int rooty = root(y);
        if(rootx == rooty) return;
        if(s[rootx] < s[rooty]) swap(rootx, rooty);
        s[rootx] += s[rooty];
        parent[rooty] = rootx;
    }
 
    bool isSame(int x, int y){
        return root(x) == root(y);
    }
 
    int size(int x){
        return s[root(x)];
    }
};
int main(void){
    int n, m, k;
    cin >> n >> m >> k;

    UnionFind uf(n);
    vector<vector<int>> fri(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        fri[a].push_back(b);
        fri[b].push_back(a);
    }
    vector<int> ans(n, 0);
    vector<int> minus(n, 0);
    for(int i = 0; i < k; i++){
        int d, c;
        cin >> c >> d;
        c--;
        d--;
        if(uf.isSame(c, d)){
            minus[c]++;
            minus[d]++;
        }
    }

    for(int i = 0; i < n; i++){
        cout << uf.size(i) - fri[i].size() - 1 - minus[i] << " ";
    }
    cout << endl;

}   

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll P = 1000000007;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;
  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }
  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }
  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }
  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }
  long long mul(long long a, long long b) { return (a * b) % P; }
  long long add(long long a, long long b) { return (a + b) % P; }
  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

ll bdp[201010] = {0}, wdp[201010] = {0};
int main() {
  C cmp(201010);
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll b, w;
  cin >> b >> w;

  ll n = b + w;
  bdp[0] = 0;
  for (int i = 0; i < n; i++)
    bdp[i + 1] =
        (bdp[i] + (cmp.power(cmp.inv[2], i + 1) * cmp.comb(i, b - 1)) % P) % P;
  wdp[0] = 0;
  for (int i = 0; i < n; i++)
    wdp[i + 1] =
        (wdp[i] + (cmp.power(cmp.inv[2], i + 1) * cmp.comb(i, w - 1)) % P) % P;
  for (int i = 0; i < n; i++) {
    cout << (((1 - bdp[i] + wdp[i]) % P + P) % P * cmp.inv[2]) % P << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int A, B = 0;
  for(int i=0; i<N; i++){
    if(i % 2 == 0){
      A += a.at(i);
    }
    else{
      B += a.at(i);
    }
  }
  cout << A - B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


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


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);
    vi a(n), b(n), c(n);
    vector<vector<int>> prizes(n, vector<int>(3, -1));
    f(i, 0, n){
        f(j, 0, 3){
            s(prizes[i][j]);
        }
    }
    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            int idx1 = (j + 1)%3;
            int idx2 = (j + 2)%3;
            dp[i + 1][j] = max(dp[i][idx1] + prizes[i][idx1], dp[i][idx2] + prizes[i][idx2]);
        }
    }

    int maxx = *max_element(dp[n].begin(), dp[n].end());
    p(maxx);
    return;
}

class CVacation {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CVacation solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 16340