akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"105"# => r#"1"#,
r#"7"# => r#"0"#,
r#"200"# => r#"5"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }
    let mut ans = 0;

    for i in (105..n+1).filter(|x| x % 2 != 0) {
        // print!("{} : ", i);
        let mut cnt = 0;
        for j in 1..i + 1  {
            if i % j == 0 {
                cnt += 1;
            }
        }
        if cnt == 8 {
            ans += 1;
        }
        // println!("{}", cnt);
    }

    ans.to_string()
}

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

using namespace std;

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

  const int coins[] = {
      1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049,
  };
  int N;
  cin >> N;

  vector<int> dp(N + 1, 100000);
  for (int i = 1; i <= N; ++i) {
    for (auto c : coins) {
      if (c == i) {
        dp[i] = 1;
        break;
      }
    }
  }
  for (int i = 2; i <= N; ++i) {
    for (auto c : coins) {
      if (i - c < 0) continue;
      dp[i] = min(dp[i], dp[i - c] + 1);
    }
  }
  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  string s; cin >> s;
  FOR(i,1,(int)s.length()+1) {
    if(i % 2 == 1) cout << s[i-1];
  }
  cout << endl;
  return 0;
}


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 1000 + 100;

int N, A[Maxn];
LL sum[2];
vector <int> vec, Ans;

inline void Judge ()
{
	int pos = 0;
	A[0] = INT_MIN;
	for (int i = 1; i <= N; ++i) if (A[i] > A[pos]) pos = i;
	if (A[pos] > 0) return ;
	for (int i = 1; i < pos; ++i) Ans.pb (1);
	int len = N - pos;
	for (int i = len; i >= 2; --i) Ans.pb (i);
	cout << A[pos] << endl;
	cout << Ans.size() << endl;
	for (int i = 0; i < Ans.size(); ++i) printf("%d\n", Ans[i]);
	exit(0);
}

inline void Solve ()
{
	Judge ();
	for (int i = 1; i <= N; ++i)
		sum[i & 1] += max (0, A[i]);
	int op = sum[0] > sum[1] ? 0 : 1;
	cout << sum[op] << endl;

	for (int i = 1; i <= N; ++i) if (A[i] > 0 && (i & 1) == op) vec.pb (i);

	for (int i = 1; i < vec[0]; ++i) Ans.pb (1);
	for (int i = 0; i < (int)vec.size() - 1; ++i)
	{
		int len = (vec[i + 1] - vec[i] + 2) / 2;
		for (int j = len; j >= 2; --j) Ans.pb (j);
	}
	int len = N - vec[(int)vec.size() - 1] + 1;
	for (int i = len; i >= 2; --i) Ans.pb (i);

	cout << Ans.size() << endl;
	for (int i = 0; i < Ans.size(); ++i) printf("%d\n", Ans[i]);
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main()
{

#ifdef hk_cnyali
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
    }
    let days = s.len();
    let w = s.match_indices("o").count();


    println!("{}", if 8usize - w <= 15usize - days {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	/*
		ABC121B問題

	*/
	int n, m, c;
	cin >> n >> m >> c;

	int *b = new int[m];
	for (int i = 0; i < m; i++)
		cin >> b[i];

	int a, cnt = 0;
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			cin >> a;
			sum += a * b[j];
		}
		if (sum + c > 0)
			cnt++;
	}

	cout << cnt;

	delete[] b;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a=0;
    int d=1;
    int e=2;
    int answer=0;
    cin>>a;
    char b[a];
    int c[a];
    for(int i=1;i<=a;i++){
        cin>>b[i];
    }
    for(int i=1;i<=a;i++){
        if(b[i]=='O'){
            c[i]=1;
        }else{
            c[i]=2;
        }
    }
    while(e<=a){
        if(c[d]==1&&c[e]==2){
            answer++;
            d=d+2;
            e=e+2;
        }else{
            if(c[d]==2&&c[e]==1){
                answer++;
                d=d+2;
                e=e+2;
            }else{
                d++;
                e++;
            }
        }
    }
    cout<<answer<<endl;
}



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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return a.first*b.second<a.second*b.first;
}

const ll mod = 1e9+7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    //clock_t tm = clock();
    fastio;
    ll n,x,l;
    cin>>n;
    vll a,b;
    f(i,0,n){
        cin>>x>>l;
        a.pb({x-l,x+l});
        b.pb({x+l,x-l});
    }
    sort(all(a));sort(all(b));
    int ans=0,j=n-1,i=n-2;
    while(i>=0){
        if(a[i].second>a[j].first){
            ans++;
        }
        else
            j=i;
        --i;
    }
    int ans1=0;j=0,i=1;
    while(i<n){
        if(b[i].second<b[j].first){
            ans1++;
        }
        else
            j=i;
        ++i;
    }
    cout<<n-min(ans,ans1)<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3564
//
// Created by yamunaku on 2019/08/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    priority_queue<double> q;
    rep(i,n){
        double c;
        cin >> c;
        q.push(-c);
    }
    while(q.size()>1){
        double x=q.top();
        q.pop();
        double y=q.top();
        q.pop();
        q.push((x+y)/2);
    }
    CST(10);
    cout << -q.top() << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 3e5+1;
const ll inf = 1e12;


ll ans[MAX],pot1[MAX],pot2[MAX];

ll bp(ll a,ll e,ll mod){
	if(e == 0)  return 1LL;
	if(e&1) return (a*bp(a,e-1,mod))%mod;
	ll x = bp(a,e>>1,mod);
	return (x*x)%mod;
}

int main(){
	ll n,l,r,d;
	string s;
	cin >> n>>s;
	f(i,1,MAX){
		ll aux = i,c = 0;
		while(aux>0){
			c = 0;
			f(j,0,20){
				if(aux&(1LL<<j)) c++;
			}
			aux = aux%c;
			ans[i]++;
		}
	}
	ll c = 0;
	f(i,0,n) if(s[i] == '1') c++;
	
	if(c == 0){
		f(i,0,n) cout << "1\n";
		return 0;
	}

	if(c == 1){
		f(i,0,n){
			if(s[i] == '1') cout << "0\n";
			else if (i == n-1 || s[n-1]  == '1') cout << "2\n";
			else cout << "1\n";
		}
		return 0;
	}


	ll sum1 = 0;
	ll sum2 = 0;
	f(i,0,n){
		(sum1*=2LL)%=(c-1);
		(sum1 += (s[i]-'0') )%=(c-1);
		(sum2*=2LL)%=(c+1);
		(sum2 += (s[i]-'0') )%=(c+1);
	}

//	cout << sum1 << " " << sum2<<endl;
	f(i,0,n){
		if(s[i] == '0'){
			ll aux = sum2;
			aux += bp(2,n-1-i,c+1);
	//		cout << "d"<< sum2 << endl;
			aux %=(c+1);
			cout << ans[aux] + 1<< endl;
		}
		else{
			ll aux = sum1;
			aux -= bp(2,n-1-i,c-1);
			aux+=(c-1);
			aux %= (c-1);
			cout << ans[aux] + 1<< endl;
		}
	}
}



Measured memory_bytes: 6104
n=int(input())
odd_list=list(range(1,n+1,2))
#print(odd_list)
cnt=0
for i in odd_list:
    ind=0
    temp=0
    while True:
        if ind>=len(odd_list):break
        if i<odd_list[ind]:break
        if i%odd_list[ind]==0:temp+=1
        ind+=1
    if temp==8:
        cnt+=1
#print(odd_list)
print(cnt)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if len(s) < 26 {
		alp := make([]int, 'z'-'a'+1)
		for _, ss := range s {
			alp[ss-'a']++
		}
		for i, v := range alp {
			if v == 0 {
				fmt.Println(s + string('a'+i))
				return
			}
		}
	}

	for i := len(s) - 2; i >= 0; i-- {
		if s[i] > s[i+1] {
			continue
		}
		for j := len(s) - 1; j >= i+1; j-- {
			if s[j] < s[i] {
				continue
			}
			ans := s[:i] + s[j:j+1]
			fmt.Println(ans)
			return
		}
	}

	fmt.Println("-1")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

typedef long long i64;

i64 MOD = 1e9 + 7;

// Eucli
i64 inv_mod(i64 a, i64 m = MOD) {
  i64 b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}

i64 fact[100010];

i64 nCr(int n, int r) {
  return (fact[n] * inv_mod(fact[r]) % MOD * inv_mod(fact[n - r]) % MOD) % MOD;
}

//重複組み合わせ
i64 nHr(int n, int r) { return (nCr(n + r - 1, r)) % MOD; }


int N;
vector<int> a;

int p1,p2;

int main(){
  fact[0] = 1;
  rep(i,1,100010 - 1) fact[i] = (fact[i - 1] * i) % MOD;

  cin >> N;
  a.resize(N + 1);
  rep(i,0,N){
    cin >> a[i];
  }
  vector<vector<int>> po(N + 1);
  rep(i,0,N){
    po[a[i]].push_back(i);
    if(po[a[i]].size() == 2){
      p1 = po[a[i]][0];
      p2 = po[a[i]][1];
    }
  }
  int left = p1;
  int right = N - p2;
  rep(k,1,N + 1){
    i64 ans = nCr(N + 1,k) % MOD;
    if(left + right >= k - 1)
      ans = (ans + MOD - nCr(left + right , k - 1)) % MOD;
    cout << ans % MOD << endl;
  }
}


Measured memory_bytes: 7808
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(usize, usize); m],
    }

    let mut graph = vec![Vec::new(); n];
    edges.iter().for_each(|&(a, b)| {
        graph[a - 1].push(b - 1);
        graph[b - 1].push(a - 1);
    });

    let mut prev = vec![std::usize::MAX; n];
    let mut q = VecDeque::new();
    q.push_back((0, 0));
    while let Some((current, parent)) = q.pop_front() {
        if prev[current] != std::usize::MAX {
            continue;
        }
        prev[current] = parent;
        graph[current]
            .iter()
            .for_each(|e| q.push_back((*e, current)));
    }

    println!("Yes");
    println!("{}", prev[1..].iter().map(|p| p + 1).join("\n"));
}


Measured memory_bytes: 22428
#include<bits/stdc++.h>
#define inf 2147400000
using namespace std;
string s;
int fg1=inf,fg2;
int main()
{
    cin >> s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C') fg1=min(fg1,i);
        else if(s[i]=='F') fg2=max(fg2,i);
    }
    printf("%s",fg1<fg2?"Yes":"No");
    return 0;
}

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

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = INF;
    int cnt = 0;
    for (int i = 0; i < S.length(); i += 2) {
        if (S[i] == '1') cnt++;
        if (S[i + 1] == '0') cnt++;
    }
    ans = min(ans, cnt);
    cnt = 0;
    for (int i = 0; i < S.length(); i += 2) {
        if (S[i] == '0') cnt++;
        if (S[i + 1] == '1') cnt++;
    }
    ans = min(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
x=int(input())
list=[]
for i in range(x):
    a,b,c=input().split()
    list.append((int(a),int(b),int(c)))
    a=int(a)
    b=int(b)
    c=int(c)
    if a*a==b*b+(c*c):
         print('YES')
    elif b*b==a*a+(c*c):
        print('YES')
    elif c*c==a*a+(b*b):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void print_endl(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i] << endl;
	}
}

vector<int> tmp;
void mer(vector<int> &data, int l, int m, int r){
	for (int i = l; i < r; ++i) tmp[i] = data[i];
	cnt += (r - l);

	int p1(l), p2(m);
	while (p1 < m && p2 < r) {
		if (tmp[p1] <= tmp[p2]) data[l++] = tmp[p1++];
		else data[l++] = tmp[p2++];
	}
	while (p1 < m) data[l++] = tmp[p1++];
	while (p2 < r) data[l++] = tmp[p2++];
}

void merS(vector<int> &data, int l, int r){
	if (l + 1 < r){
		int m = l + (r - l) / 2;
		merS(data, l, m);
		merS(data, m, r);
		mer(data, l, m, r);
	}
}

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

	tmp.resize(n);
	merS(data, 0, n);
	print(data);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 6708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int v = in.nextInt(), e = in.nextInt();
			E[] es = new E[e];
			for (int i = 0; i < e; i++) {
				int s = in.nextInt(), t = in.nextInt(), w = in.nextInt();
				es[i] = new E(s, t, w);
			}

			Arrays.sort(es, (a, b) -> a.weight - b.weight);
			DisjointSet set = new DisjointSet(v);
			int ans = 0;
			for (int i = 0; i < e; i++) {
				E edge = es[i];
				if (!set.same(edge.from, edge.to)) {
					set.unite(edge.from, edge.to);
					ans += edge.weight;
				}
			}

			out.println(ans);
		}

		public class DisjointSet {

			int[] p, rank;

			public DisjointSet(int size) {
				p = new int[size];
				rank = new int[size];

				for (int j = 0; j < size; j++) {
					makeSet(j);
				}
			}

			private void makeSet(int x) {
				p[x] = x;
				rank[x] = 0;
			}

			public int findSet(int x) {
				return p[x] == x ? x : findSet(p[x]);
			}

			public void link(int x, int y) {
				if (rank[x] > rank[y]) {
					p[y] = x;
				} else if (rank[x] < rank[y]) {
					p[x] = y;
				} else if (rank[x] == rank[y]) {
					p[x] = y;
					rank[y]++;
				}
			}

			public void unite(int x, int y) {
				link(findSet(x), findSet(y));
			}

			public boolean same(int x, int y) {
				return findSet(x) == findSet(y);
			}
		}
	}


	static class E {
		int from, to, weight;
		E (int from, int to, int weight) {
			this.from = from;
			this.to = to;
			this.weight = weight;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 68432
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n, 0);
  rep (i, n) cin >> a[i];

  vector<ll> maxH(n, 0);
  rep (i, n) {
    if (i == 0) maxH[i] = a[i];
    else maxH[i] = max(maxH[i-1], a[i]);
  }
  ll ans = 0;
  rep (i, n) {
    ans += (maxH[i] - a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h> 
using namespace std;
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; /*long long int は64bit*/
using vi = vector<int>;using Vi = vector<long long int>;using matrix = vector<vector<ll> >;using Pair = pair<ll,ll>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++) 
#define rev(i,N) for(long long int i=N-1;i>=0;i--) /*N-1からスタート*/
#define np nullptr
template<class T,class T2>bool chmax(T &former, const T2 &b) { if (former<=b) { former=b; return true; } return false; }
template<class T,class T2>bool chmin(T &former, const T2 &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; } /*sqrt(x)は平方根*/
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) /*降順↓でVをソート*/
#define fill(x,num) memset(x,num,sizeof(x));
template<class T1,class T2>bool p_compare(const pair<T1,T2> fir,const pair<T1,T2> sec){ return fir.second < sec.second; }
bool p_comp(const Pair fir,const Pair sec){return p_compare<ll,ll>(fir,sec);}
template<class T1,class T2>bool pcompare(pair<T1,T2> fir,pair<T1,T2> sec){ return !p_comp(fir,sec); }
bool pcomp(const Pair fir,const Pair sec){return pcompare<ll,ll>(fir,sec);}
/*sort(all(v),p_compare<ll,ll> 又は p_comp)で↑ソート , pcompは↓ソート*/

//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock


ll n;
ll hh[1000];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){
        cin>>hh[i];
    }
    ll ans = 0;
    bool key;
    rep(i,n){
        if(i==0)ans++;
        key = true;
        if(i!=0)rep(j,i){
            if(hh[j]>hh[i])key = false;
        }
        if(i!=0 && key)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
 
int main()
{ int a,b;
	scanf("%d %d",&a,&b);
	if(a>=13)
		printf("%d",b);
	else if(a>=6 && a<=12)
		printf("%d",b/2);
	else
		printf("0");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
 int n,a[1001],i;
 cin >> n;
 for(i=0;i<n;i++){
  cin >> a[i];
 }
 for(i=n-1;i>=1;i--){
  cout << a[i] << " ";
 }
 cout << a[0] <<endl;
}


Measured memory_bytes: 3056
N,D = map(int,input().split())

X_list = [list(map(int,input().split())) for i in range(N)]

aaa_list = []
cnt = 0
#print(X_list)

for i in range(N):
    for j in range(i+1,N):
        for k in range(D):
            aaa_list.append(abs(X_list[i][k]-X_list[j][k])**2)
        judge_aaa = (sum(aaa_list))**0.5
        #print(judge_aaa)
        if judge_aaa.is_integer() :
            cnt +=1
        aaa_list.clear()

print(cnt)


Measured memory_bytes: 3188
#include<iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
	int n,k; cin >>n>>k;
	vector<int> d(k);
	cinf(k,d);
	for(int i=n;;i++){
		bool ok=true;
		int x=i;
		while(x){
			for(int j=0;j<k;j++){
				if(x%10==d[j]) ok=false;
			}
			x/=10;
		}
		if(ok){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var nd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nd[0];
        var D = nd[1];
        var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] firstDeadPlace = new long[n + 1];
        firstDeadPlace[n] = 1;
        for (int i = n - 1; i >= 0; i--)
        {
            if (firstDeadPlace[i + 1] < d[i] / 2 + 1)
            {
                firstDeadPlace[i] = firstDeadPlace[i + 1];
                continue;
            }
            firstDeadPlace[i] = Min(int.MaxValue, firstDeadPlace[i + 1] + d[i]);
        }

        long currentPlace = D;
        bool alreadyArrived = false;
        bool[] canDisturb = new bool[n];
        for (int i = 0; i < canDisturb.Length; i++)
        {
            canDisturb[i] = firstDeadPlace[i + 1] <= currentPlace && !alreadyArrived;
            currentPlace = Min(currentPlace, Abs(currentPlace - d[i]));
            alreadyArrived |= currentPlace == 0;
        }
        Console.ReadLine();
        Console.WriteLine(string.Join("\n", Console.ReadLine().Split().Select(x => canDisturb[int.Parse(x) - 1] ? "YES" : "NO")));
    }
}


Measured memory_bytes: 67032
//C,Dの最小公倍数を求めたい
//ユークリッドの互除法で最大公約数を求めたら公式で出せる
#include <iostream>
using namespace std;

long int euclideam(long int c, long int d);//最大公約数
long int euclideam(long int c, long int d) {
	long int w, C=c,D=d;
	if (C < D) {
		w = C;
		C = D;
		D = w;
	}
	while (D!=0)
	{
		w = C % D;
		C = D;
		D = w;
	}
	return C;
}

int main()
{
	long int a, b, c, d, ans;
	cin >> a >> b >> c >> d;

	long int x = c * d / euclideam(c, d);
	ans = b - b / d - b / c + b / x;
	a--;
	ans -= a - a / c - a / d + a / x;
	cout << ans;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e7+5;
int main() {
    long double a,b,c;
    cin>>a>>b>>c;
    long double p = 2*sqrt(a*b);
    if(p<c-b-a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
n = int(input())
cards = list(map(int,input().split()))
print(*cards)
for i in range(1,n):
    v = cards[i]
    j = i-1
    while j >= 0 and cards[j] > v:
        cards[j+1] = cards[j]
        j -= 1
    cards[j+1] = v
    print(*cards)



Measured memory_bytes: 5972
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,l;
	cin>>n>>l;
	int s=0,q=10000;
	REP(i,n){
		s+=(l+i);
	}
	REP(i,n){
		if(abs(l+i)<abs(q)){
			q=l+i;
		}
	}
	cout<<s-q<<endl;
	return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = N * (N-1) / 2;
    print(ans);
    
}

Measured memory_bytes: 256
a=list(input())
a.reverse()
b=list(input())
b.reverse()
c=list(input())
c.reverse()
turn=1
while 1:
  if turn==1:
    if len(a)==0:
      print("A")
      exit()
    else:
      k=a.pop()
      if k=="a":
        turn=1
      elif k=="b":
        turn=2
      else:
        turn=3
  if turn==2:
    if len(b)==0:
      print("B")
      exit()
    else:
      k=b.pop()
      if k=="a":
        turn=1
      elif k=="b":
        turn=2
      else:
        turn=3
  if turn==3:
    if len(c)==0:
      print("C")
      exit()
    else:
      k=c.pop()
      if k=="a":
        turn=1
      elif k=="b":
        turn=2
      else:
        turn=3

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<40){
		a=40;
	}
	if(b<40){
		b=40;
	}
	if(c<40){
		c=40;
	}
	if(d<40){
		d=40;
	}
	if(e<40){
		e=40;
	}
	printf("%d\n",(a+b+c+d+e)/5);
	return 0;
}


Measured memory_bytes: 2076
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える場所
#define N_MAX 200


//問題文のとおり
string str;
int main() {
	cin >> str;
	bool flag = false;
	REP(i, str.size() - 1) {
		if (str[i] == 'A' && str[i + 1] == 'C')flag = true;
	}
	cout << (flag ? "Yes" : "No") << endl;
	cin >> str;
	return 0;
}

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

using namespace std;

const int MONTHS_IN_YEAR = 12;
const int DAYS_IN_WEEK = 7;
const int numOfDays[MONTHS_IN_YEAR] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const string days[DAYS_IN_WEEK] = {"Wednesday", "Thursday", "Friday",
    "Saturday", "Sunday", "Monday", "Tuesday"};

int main(){
    for(int month, day, sumOfDays; cin >> month >> day, sumOfDays = day; cout << days[sumOfDays % DAYS_IN_WEEK] << endl)
        for(int i = 0; i < month - 1; i ++) sumOfDays += numOfDays[i];

    return 0;
}

Measured memory_bytes: 1192
N = int(input())
H = list(map(int, input().split()))
Flg = "Yes"

cnt = 0
tmp = H[0]
for i in range(N-1):
    tmp = max(H[i], tmp)
    if(H[i] - H[i+1] > 1):
        Flg = "No"
        break
    if(H[i] > H[i+1] and tmp-H[i+1] > 1):
        Flg = "No"
        break
print(Flg)

Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		cntAB = 0;
		cntBA = 0;
		cntBX = 0;
		cntXA = 0;
	}

	public boolean hasNext() {
		return cnt < N;
	}

	int cntAB;
	int cntBA;
	int cntBX;
	int cntXA;

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		Pattern p = Pattern.compile("AB");
		Matcher m = p.matcher(str);
		for (; m.find();) {
			cntAB++;
		}
		if (str.charAt(0) == 'B' && str.charAt(str.length() - 1) == 'A')
			cntBA++;
		else if (str.charAt(0) == 'B')
			cntBX++;
		else if (str.charAt(str.length() - 1) == 'A')
			cntXA++;
	}

	public void solve() {
		int ans = 0;
		if (cntBA == 0) {
			ans = Integer.min(cntXA, cntBX);
		} else {
			if (cntXA + cntBX > 0) {
				ans = Integer.min(cntXA, cntBX) + cntBA;
			} else {
				ans = (cntBA - 1);
			}
		}
		ans += cntAB;
		System.out.println(ans);
	}
}


Measured memory_bytes: 30292
#include<stdio.h>
int main(void)
{
	int A, B, C, D;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);


	if (A < C) {
		if (B < C)
			printf("0");
		else if (B == C)
			printf("0");
		else if (B > C, B > D)
			printf("%d", B - C - B + D);
		else if (B > C, B <= D)
			printf("%d", B - C);
		else if (A == B, C < B)
			printf("%d", A - C);
		else if (A == B, C >= B)
			printf("%d", A - B);
	}

	else if (A == C) {
		if (B < D)
			printf("%d", B - A);
		else if (B >= D)
			printf("%d", D - A);
	}

	else if (A == D)
		printf("0");
	
	else {
		if (D < A)
			printf("0");
		else if (D == A)
			printf("0");
		else if (D > A, D > B)
			printf("%d", D - A - D + B);
		else if (D > A, D <= B)
			printf("%d", D - A);
		else if (C == D, A < D)
			printf("%d", C - A);
		else if (C == D, A >= D)
			printf("%d", C - D);
	}
	




	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int z = count(begin(s), end(s), '0');
  int res = 2 * min(z, n - z);
  cout << res << '\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll x;
  cin >> x;
  ll ans=0;
  ans+=1000*(x/500);
  x%=500;
  ans+=5*(x/5);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
from bisect import bisect_left as bisect
import sys
sys.setrecursionlimit(10**9)

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l):
    res = 0
    i = bisect(l,a[t])
    if len(l)==i:
        l.append(a[t])
    else:
        res = [i,l[i]]
        l[i]=a[t]
    ans[t] = len(l)
    for v in g[t]:
        if v != f:
            back = dfs(v,t,l)
            if back:
                l[back[0]] = back[1]
            else:
                l.pop()
    return res
dfs(0,0,[])
for i in range(N):
    print(ans[i])

Measured memory_bytes: 237592
N, X = map(int, input().split())

ans = N
a = N - X
b = X
while a != b:
    if a >= b:
        a, b = b, a
    if b%a != 0:
        ans += 2 * a * (b//a)
        b = b%a
    else:
        ans += 2 * a * (b//a - 1)
        b = a
print (ans + a)


    

Measured memory_bytes: 3060
import itertools

H,W=map(int, input().split())
garden=[]

for i in range(H):
    garden.append(list(input().replace(".","1").replace("#","0")))

#print(garden)
dct=[(1,0),(0,1),(-1,0),(0,-1)]
#garden=[[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1]]
#H,W=5,5
start=(0,0)
goal=(H-1,W-1)
path=[start]
d=[ [i+j for i in range(W)] for j in range(H)]
#print(d)
done=[(0,0)]
for i, j in itertools.product(range(H),range(W)):
    color=garden[i][j]
    for each in dct:
        di,dj=each[0],each[1]
        if i+di<H and j+dj< W and i+di>=0 and j+dj>=0 and  garden[i+di][j+dj]==color:
            d[i+di][j+dj]=min(d[i+di][j+dj],d[i][j])
            done.append((i+di,j+dj))
            #print((i,j),(i+di,j+dj))
            #print("same")
        elif i+di<H and j+dj< W and i+di>=0 and j+dj>=0 :
            d[i+di][j+dj]=min(d[i+di][j+dj],d[i][j]+1)
            done.append((i+di,j+dj))
            #print((i,j),(i+di,j+dj))
            #print("not same")
    #print(d)
if int(garden[0][0])+int(garden[H-1][W-1])==0:
  print(int((d[H-1][W-1]+1)/2)+1)
else:
  print(int((d[H-1][W-1]+1)/2))

Measured memory_bytes: 6120
k, s = [int(i) for i in input().split()]

count = 0
for x in range(k+1):
    if s - x > 2 * k:
        continue
    for y in range(k+1):
        if s - (x+y) > k or s -(x+y) < 0:
            continue
        count += 1

print(count)


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

string calc(int s[4]) {
    for (int bit = 1; bit < (1<<n); ++bit) {
        int total = s[0];
        string formula = to_string(s[0]);
        for (int i = 1; i < n; ++i) {
            if (bit & (1 << i)) {
                total -= s[i];
                formula += "-" + to_string(s[i]);
            } else {
                total += s[i];
                formula += "+" + to_string(s[i]);
            }
        }
        if (total == 7) return formula + "=7";
    }
    return "";
}

void solve() {
    char A,B,C,D;
    cin >> A >> B >> C >> D;
    int a = A - '0';
    int b = B - '0';
    int c = C - '0';
    int d = D - '0';
    int s[4] = {a, b, c, d};
    string x = calc(s);
    cout << x << endl;
}

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


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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);   //cin cout 高速化
    while(true){
        int n; cin >> n;
        if(cin.eof()) break;
        if(n == 0) continue; 
        rep(i,9){
            int p; cin >> p;
            n-=p;
        }
        cout << n << '\n';
    }
}


Measured memory_bytes: 3076
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
	    int a = in.readInt();
	    int b = in.readInt(); 
	    int c = in.readInt();
	    int x = in.readInt();
	    
	    System.out.println(a+b+c+Math.max(Math.max(a, b), c) * ((1<<x) -1));
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define N 1000005
using namespace std;
typedef long long int lo;
const int mod=1000000007;
lo a,b,c,d,e,f,g,h[100005],arr[100005];
string s;
vector<lo>v[200];
char ch;

int main(){
	// freopen("in.txt","r",stdin);
 //    freopen("out.txt","w",stdout);
    string s2;
    cin >> s >> s2;
    for(lo i=0;i<s.size();i++){
    	v[s[i]].pb(i);
    }
    lo ans=0,cur=-1;
    vector<lo>::iterator upper;
    for(lo i=0;i<s2.size();i++){
    	if(v[s2[i]].size()==0){
    		cout << -1;
    		return 0;
    	}
    	upper=upper_bound(v[s2[i]].begin(),v[s2[i]].end(),cur);
    	if((upper-v[s2[i]].begin())==v[s2[i]].size()){
    		ans+=s.size();
    		i--;
    		cur=-1;
    	}
    	else{
    		cur=v[s2[i]][(upper-v[s2[i]].begin())];
    	}
    }
    cout << ans+cur+1 << endl;
}

Measured memory_bytes: 1724
#ABC167-E Colorful Blocks
"""
隣り合うブロックの組の個数がi個(i=0~k)であるときの組み合わせ数を求めていく。
まず、k=0の時を考えると、m=4の時、
res = 4*3**(n-1)となることがわかる。
次に、k>0のときは、
どれか2つのブロックを1つにつなぎ合わせると考えて、
res = 4*3**(n-1-i)
これに合わせて、どのブロックが接続するのかを考える必要があり、
どのブロックも右隣のブロックにのみ接続できると考えた場合、
接続できるブロックの個数はn-1個(一番右のブロックは接続先がない)
そこからi個選んで右のブロックにつなぐので、
n-1Ciとなる。
よって、k>0の場合の組み合わせ数は、
res = 4*3**(n-1-i)*(n-1)Ci
となる。
これを for i in range(0,k+1)だけ足し合わせたものが答え。
補足：
例えば3つのブロックを接続すると考えた場合、
2つをつなぎ合わせる場合と区別しそうだが、
「つなぐブロックの個数」はどちらでも同じになる。
更に、その時に全体の分割されたブロックの個数はn-i個で固定されるので、
m*pow(m-1,n-1-i)の部分が変わることもなく、
どの隣のブロックを選ぶかというのも隣接しても不都合がない。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m,k = map(int,readline().split())
mod = 998244353
 
if m == 1:
    if k < n-1:
        print(0)
    else:
        print(1)
    exit()

def pow(n,p,mod=mod): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod

def factrial_memo(n=2*10**5,mod=mod):
    fact = [1, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % mod)
    return fact
fact = factrial_memo()

def fermat_cmb(n, r, mod=mod): #needs pow,factrial_memo(only fact). return nCk
    return fact[n] * pow(fact[r],mod-2) * pow(fact[n-r],mod-2) %mod
ans = 0
for i in range(k+1):
    res = m*pow(m-1,n-1-i) #塊を含めて分けられるもの達
    ans += res*fermat_cmb(n-1,i)%mod
print(ans%mod)

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

int main()
{
    string s;
    cin >> s;
    const int N = s.size();
    vector<int> n(N);
    for(int i=0; i<N; i++){
        n[i] = stoi(s.substr(i, 1));
    }
    vector<vector<int>> dp1(N+1, vector<int>(8, 0));
    vector<vector<int>> dp2(N+1, vector<int>(8, 0));
    dp1[0][0] = 1;
    for(int i=1; i<=N; i++){
        for(int j=0; j <= n[i-1]; j++){
            int k2 = (j == n[i-1])? 0 : 1;
            int mask = (j == 3)? 1 : (j == 5)? 2 : (j == 7)? 4 : 0;
            if(mask==0) continue;
            for(int l=0; l<8; l++){
                if(j == n[i-1]){
                    dp1[i][l | mask] += dp1[i-1][l];
                }else{
                    dp2[i][l | mask] += dp1[i-1][l];
                }
            }
        }
        for(int j=0; j <= 9; j++){
            int mask = (j == 3)? 1 : (j == 5)? 2 : (j == 7)? 4 : 0;
            if(mask==0) continue;
            for(int l=0; l<8; l++){
                dp2[i][l | mask] += dp2[i-1][l];
            }
        }
        dp2[i][0] += 1;
    }
    int res = dp1[N][7] + dp2[N][7];
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
m,d = map(int,input().split())
count=0
 
if d<20:
  print(count)
else:
  for i in range(1,m+1):
    for j in range(20, d+1):
      a = j//10
      b = j%10
      if b>=2:
        if i == a*b:
          count+=1
  print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
//const ll mod = 1000000007;
multiset<ll> st;
ll N, M;
vector<l_l> v;

int main() {
  int n;
  cin>>n;
  vector<double> a(n);
  double t=0;
  rep(i,n){
	cin>>a[i];
    t+=1.0/a[i];
  }
  
  cout<<1/t<<endl;
  
  
  
  
}


Measured memory_bytes: 256